Skip to content

Commit

Permalink
Merge pull request SimpleMachines#7971 from asmith20002/sceditor-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesquipedalian authored Dec 28, 2023
2 parents 09978fc + e8739f4 commit 467525e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Themes/default/scripts/jquery.sceditor.smf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
return current_value;
},
appendEmoticon: function (code, emoticon, description) {
var base = this;
if (emoticon == '')
line.append($('<br>'));
else
Expand Down Expand Up @@ -95,7 +96,7 @@
var popup_exists = false;
content = $('<div class="sceditor-insertemoticon">');
line = $('<div>');
base = this;
var base = this;

for (smiley_popup in this.opts.emoticons.popup)
{
Expand All @@ -106,9 +107,10 @@
{
base.opts.emoticons.more = base.opts.emoticons.popup;
moreButton = $('<div class="sceditor-more-button sceditor-more button">').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
{
Expand All @@ -122,7 +124,7 @@

popupContent.append(titlebar);
closeButton = $('<span class="button">').text(base._('Close')).click(function () {
$(".sceditor-smileyPopup").fadeOut('fast');
$(base.editorMainWrapper.querySelector(".sceditor-smileyPopup")).fadeOut('fast');
});

$.each(emoticons, function( code, emoticon ) {
Expand All @@ -145,9 +147,9 @@
adjheight = closeButton.height() + titlebar.height();
$dropdown = $('<div class="centerbox sceditor-smileyPopup">')
.append(popupContent)
.appendTo($('.sceditor-container'));
.appendTo(base.editorMainWrapper);

$('.sceditor-smileyPopup').animaDrag({
$(base.editorMainWrapper.querySelector('.sceditor-smileyPopup')).animaDrag({
speed: 150,
interval: 120,
during: function (e) {
Expand All @@ -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($('<center/>').append(moreButton));
}
};

var createFn = sceditor.create;
var isPatched = false;

sceditor.create = function (textarea, options) {
// Call the original create function
Expand All @@ -188,20 +189,21 @@
// 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);

/*
* Stop SCEditor from resizing the entire container. Long
* 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);
Expand Down

0 comments on commit 467525e

Please sign in to comment.