mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
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:
parent
16851b22ad
commit
740939ec61
5 changed files with 99 additions and 75 deletions
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue