delete this.opts.woltlab.originalValue;
$(document).trigger('resize');
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
}).bind(this);
this.opts.pasteBeforeCallback = $.proxy(this.wbbcode._pasteBeforeCallback, this);
this.button.get('html').children('i').removeClass('fa-square').addClass('fa-square-o');
$tooltip.text(WCF.Language.get('wcf.bbcode.button.toggleBBCode'));
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
}
}).bind(this);
// insert a new line if user clicked into the editor and the last children is a quote (same behavior as arrow down)
this.wutil.setOption('clickCallback', (function(event) {
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
if (event.target === this.$editor[0]) {
if (this.$editor[0].lastElementChild && this.$editor[0].lastElementChild.tagName === 'BLOCKQUOTE') {
this.wutil.insertAtCaret($openTag + plainText + $closingTag);
}
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
return $quote;
},
"use strict";
return {
- /**
- * saved selection range
- * @var range
- */
- _range: null,
-
/**
* Initializes the RedactorPlugins.wmonkeypatch plugin.
*/
this.wmonkeypatch.fixWebKit();
},
- /**
- * Saves current caret position.
- */
- saveSelection: function() {
- var $selection = getSelection();
-
- if ($selection.rangeCount) {
- this.wmonkeypatch._range = $selection.getRangeAt(0);
- }
- },
-
- /**
- * Restores saved selection.
- */
- restoreSelection: function() {
- if (document.activeElement !== this.$editor[0]) {
- this.$editor.focus();
- }
-
- if (this.wmonkeypatch._range !== null) {
- var $selection = window.getSelection();
- $selection.removeAllRanges();
- $selection.addRange(this.wmonkeypatch._range);
-
- this.wmonkeypatch._range = null;
- }
- },
-
/**
* Setups event listeners and callbacks.
*/
// keyup
this.wutil.setOption('keyupCallback', (function(event) {
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
var $data = {
cancel: false,
this.$editor.on('mouseup.redactor keyup.redactor focus.redactor', $.proxy(this.observe.buttons, this));
this.$editor.on('keyup.redactor', $.proxy(this.keyup.init, this));
}
-
- // blur is unreliable in Firefox, especially since 'focusout' is not available
- /*this.$editor.on('blur.wredactor', (function() {
- var $selection = window.getSelection();
- if ($selection.rangeCount) {
- this.wmonkeypatch._range = $selection.getRangeAt(0);
- }
- }).bind(this));*/
},
/**
$fixDropdown($dropdown);
if ($.browser.iOS) {
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
}
$mpShow.call(this, e, key);
}
else {
if (document.activeElement !== this.$editor[0]) {
- this.$editor.focus();
-
- if (this.wmonkeypatch._range) {
- var $selection = window.getSelection();
- $selection.removeAllRanges();
- $selection.addRange(this.wmonkeypatch._range);
-
- this.wmonkeypatch._range = null;
- }
+ this.wutil.restoreSelection();
}
}
}).bind(this);
});
if ($removedSpan) {
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
}
}).bind(this);
$mpHtml.call(this, html, clean);
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
if ($isWebKit) {
setTimeout(function() {
*/
_autosaveWorker: null,
+ /**
+ * saved selection range
+ * @var range
+ */
+ _range: null,
+
/**
* Initializes the RedactorPlugins.wutil plugin.
*/
}).bind(this);
},
+ /**
+ * Saves current caret position.
+ */
+ saveSelection: function() {
+ var $selection = getSelection();
+
+ if ($selection.rangeCount) {
+ this.wutil._range = $selection.getRangeAt(0);
+ }
+ },
+
+ /**
+ * Restores saved selection.
+ */
+ restoreSelection: function() {
+ if (document.activeElement !== this.$editor[0]) {
+ this.$editor.focus();
+ }
+
+ if (this.wutil._range !== null) {
+ var $selection = window.getSelection();
+ $selection.removeAllRanges();
+ $selection.addRange(this.wutil._range);
+
+ this.wutil._range = null;
+ }
+ },
+
/**
* Allows inserting of text contents in Redactor's source area.
*
reset: function() {
if (this.opts.visual) {
this.$editor.html('<p>' + this.opts.invisibleSpace + '</p>');
- this.wmonkeypatch.saveSelection();
+ this.wutil.saveSelection();
}
this.$textarea.val('');
else {
this.wutil.setCaretAfter($lastChild);
}
+
+ this.wutil.saveSelection();
},
/**