diff --git a/Themes/default/scripts/jquery.sceditor.smf.js b/Themes/default/scripts/jquery.sceditor.smf.js index f02dadc563..612b4d085b 100644 --- a/Themes/default/scripts/jquery.sceditor.smf.js +++ b/Themes/default/scripts/jquery.sceditor.smf.js @@ -56,6 +56,7 @@ return current_value; }, appendEmoticon: function (code, emoticon, description) { + var base = this; if (emoticon == '') line.append($('
')); else @@ -95,7 +96,7 @@ var popup_exists = false; content = $('
'); line = $('
'); - base = this; + var base = this; for (smiley_popup in this.opts.emoticons.popup) { @@ -106,9 +107,10 @@ { base.opts.emoticons.more = base.opts.emoticons.popup; moreButton = $('
').text(this._('More')).click(function () { - if ($(".sceditor-smileyPopup").length > 0) + var smileyPopup = base.editorMainWrapper.querySelector(".sceditor-smileyPopup"); + if (smileyPopup) { - $(".sceditor-smileyPopup").fadeIn('fast'); + $(smileyPopup).fadeIn('fast'); } else { @@ -122,7 +124,7 @@ popupContent.append(titlebar); closeButton = $('').text(base._('Close')).click(function () { - $(".sceditor-smileyPopup").fadeOut('fast'); + $(base.editorMainWrapper.querySelector(".sceditor-smileyPopup")).fadeOut('fast'); }); $.each(emoticons, function( code, emoticon ) { @@ -145,9 +147,9 @@ adjheight = closeButton.height() + titlebar.height(); $dropdown = $('
') .append(popupContent) - .appendTo($('.sceditor-container')); + .appendTo(base.editorMainWrapper); - $('.sceditor-smileyPopup').animaDrag({ + $(base.editorMainWrapper.querySelector('.sceditor-smileyPopup')).animaDrag({ speed: 150, interval: 120, during: function (e) { @@ -172,14 +174,13 @@ }); if (line.children().length > 0) content.append(line); - $(".sceditor-toolbar").append(content); + $(base.editorMainWrapper.querySelector(".sceditor-toolbar")).append(content); if (typeof moreButton !== "undefined") content.append($('
').append(moreButton)); } }; var createFn = sceditor.create; - var isPatched = false; sceditor.create = function (textarea, options) { // Call the original create function @@ -188,8 +189,9 @@ // Constructor isn't exposed so get reference to it when // creating the first instance and extend it then var instance = sceditor.instance(textarea); - if (!isPatched && instance) { + if (instance && typeof instance.isPatched == 'undefined') { sceditor.utils.extend(instance.constructor.prototype, extensionMethods); + instance.editorMainWrapper = instance.getContentAreaContainer().closest('.sceditor-container'); window.addEventListener('beforeunload', instance.updateOriginal, false); /* @@ -197,11 +199,11 @@ * toolbars and tons of smilies play havoc with this. * Only resize the text areas instead. */ - document.querySelector(".sceditor-container").removeAttribute("style"); - document.querySelector(".sceditor-container textarea").style.height = options.height; - document.querySelector(".sceditor-container textarea").style.flexBasis = options.height; + instance.editorMainWrapper.removeAttribute("style"); + instance.editorMainWrapper.querySelector("textarea").style.height = options.height; + instance.editorMainWrapper.querySelector("textarea").style.flexBasis = options.height; - isPatched = true; + instance.isPatched = true; } }; })(jQuery);