MDL-16654 Move javascript used by the emoticons help file from javascript.php to javascript-static.js. Fix it so that it actually works.

This commit is contained in:
tjhunt 2008-09-25 10:07:11 +00:00
parent 16851b22ad
commit 740939ec61
5 changed files with 99 additions and 75 deletions

View file

@ -514,7 +514,7 @@ function getElementsByClassName(oElm, strTagName, oClassNames){
}
function openpopup(url, name, options, fullscreen) {
var fullurl = moodle_config.wwwroot + url;
var fullurl = moodle_cfg.wwwroot + url;
var windowobj = window.open(fullurl,name,options);
if (fullscreen) {
windowobj.moveTo(0,0);
@ -523,3 +523,34 @@ function openpopup(url, name, options, fullscreen) {
windowobj.focus();
return false;
}
/* This is only used on a few help pages. */
emoticons_help = {
inputarea: null,
init: function(formname, fieldname, listid) {
if (!opener || !opener.document.forms[formname]) {
return;
}
emoticons_help.inputarea = opener.document.forms[formname][fieldname];
if (!emoticons_help.inputarea) {
return;
}
var emoticons = document.getElementById(listid).getElementsByTagName('li');
for (var i = 0; i < emoticons.length; i++) {
var text = emoticons[i].getElementsByTagName('img')[0].alt;
YAHOO.util.Event.addListener(emoticons[i], 'click', emoticons_help.inserttext, text);
}
},
inserttext: function(e, text) {
text = ' ' + text + ' ';
if (emoticons_help.inputarea.createTextRange && emoticons_help.inputarea.caretPos) {
var caretPos = emoticons_help.inputarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
} else {
emoticons_help.inputarea.value += text;
}
emoticons_help.inputarea.focus();
}
}