comparison src/sceditor.js @ 18:1334920263a2

remove more object-oriented code
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 08 Aug 2022 16:20:23 -0600
parents a199722647d0
children 13df5ac9b34b
comparison
equal deleted inserted replaced
17:a199722647d0 18:1334920263a2
262 function find(node, selector) { 262 function find(node, selector) {
263 return node.querySelectorAll(selector); 263 return node.querySelectorAll(selector);
264 } 264 }
265 265
266 /** 266 /**
267 * For on() and off() if to add/remove the event 267 * For onEvent() and offEvent() if to add/remove the event
268 * to the capture phase 268 * to the capture phase
269 * 269 *
270 * @type {boolean} 270 * @type {boolean}
271 */ 271 */
272 var EVENT_CAPTURE = true; 272 var EVENT_CAPTURE = true;
282 * @param {!Node} node 282 * @param {!Node} node
283 * @param {string} events 283 * @param {string} events
284 * @param {string} [selector] 284 * @param {string} [selector]
285 * @param {function(Object)} fn 285 * @param {function(Object)} fn
286 * @param {boolean} [capture=false] 286 * @param {boolean} [capture=false]
287 * @see off() 287 * @see offEvent()
288 */ 288 */
289 // eslint-disable-next-line max-params 289 // eslint-disable-next-line max-params
290 function on(node, events, selector, fn, capture) { 290 function onEvent(node, events, selector, fn, capture) {
291 events.split(' ').forEach(function (event) { 291 events.split(' ').forEach(function (event) {
292 var handler; 292 var handler;
293 293
294 if (isString(selector)) { 294 if (isString(selector)) {
295 handler = fn['_sce-event-' + event + selector] || function (e) { 295 handler = fn['_sce-event-' + event + selector] || function (e) {
296 var target = e.target; 296 var target = e.target;
297 while (target && target !== node) { 297 while (target && target !== node) {
298 if (is(target, selector)) { 298 if (is(target, selector)) {
299 fn.call(target, e); 299 fn(target, e);
300 return; 300 return;
301 } 301 }
302 302
303 target = target.parentNode; 303 target = target.parentNode;
304 } 304 }
320 * @param {!Node} node 320 * @param {!Node} node
321 * @param {string} events 321 * @param {string} events
322 * @param {string} [selector] 322 * @param {string} [selector]
323 * @param {function(Object)} fn 323 * @param {function(Object)} fn
324 * @param {boolean} [capture=false] 324 * @param {boolean} [capture=false]
325 * @see on() 325 * @see onEvent()
326 */ 326 */
327 // eslint-disable-next-line max-params 327 // eslint-disable-next-line max-params
328 function off(node, events, selector, fn, capture) { 328 function offEvent(node, events, selector, fn, capture) {
329 events.split(' ').forEach(function (event) { 329 events.split(' ').forEach(function (event) {
330 var handler; 330 var handler;
331 331
332 if (isString(selector)) { 332 if (isString(selector)) {
333 handler = fn['_sce-event-' + event + selector]; 333 handler = fn['_sce-event-' + event + selector];
479 */ 479 */
480 function is(node, selector) { 480 function is(node, selector) {
481 var result = false; 481 var result = false;
482 482
483 if (node && node.nodeType === ELEMENT_NODE) { 483 if (node && node.nodeType === ELEMENT_NODE) {
484 result = (node.matches || node.msMatchesSelector || 484 if(node.matches) {
485 node.webkitMatchesSelector).call(node, selector); 485 result = node.matches(selector);
486 } else if(node.msMatchesSelector) {
487 result = node.msMatchesSelector(selector);
488 } else if(node.webkitMatchesSelector) {
489 result = node.webkitMatchesSelector(selector);
490 }
486 } 491 }
487 492
488 return result; 493 return result;
489 } 494 }
490 495
2035 // START_COMMAND: Font 2040 // START_COMMAND: Font
2036 font: { 2041 font: {
2037 _dropDown: function (editor, caller, callback) { 2042 _dropDown: function (editor, caller, callback) {
2038 var content = createElement('div'); 2043 var content = createElement('div');
2039 2044
2040 on(content, 'click', 'a', function (e) { 2045 onEvent(content, 'click', 'a', function (target, e) {
2041 callback(data(this, 'font')); 2046 callback(data(target, 'font'));
2042 editor.closeDropDown(true); 2047 editor.closeDropDown(true);
2043 e.preventDefault(); 2048 e.preventDefault();
2044 }); 2049 });
2045 2050
2046 editor.opts.fonts.split(',').forEach(function (font) { 2051 editor.opts.fonts.split(',').forEach(function (font) {
2062 // START_COMMAND: Size 2067 // START_COMMAND: Size
2063 size: { 2068 size: {
2064 _dropDown: function (editor, caller, callback) { 2069 _dropDown: function (editor, caller, callback) {
2065 var content = createElement('div'); 2070 var content = createElement('div');
2066 2071
2067 on(content, 'click', 'a', function (e) { 2072 onEvent(content, 'click', 'a', function (target, e) {
2068 callback(data(this, 'size')); 2073 callback(data(target, 'size'));
2069 editor.closeDropDown(true); 2074 editor.closeDropDown(true);
2070 e.preventDefault(); 2075 e.preventDefault();
2071 }); 2076 });
2072 2077
2073 for (var i = 1; i <= 7; i++) { 2078 for (var i = 1; i <= 7; i++) {
2110 cmd._htmlCache = html; 2115 cmd._htmlCache = html;
2111 } 2116 }
2112 2117
2113 appendChild(content, parseHTML(cmd._htmlCache)); 2118 appendChild(content, parseHTML(cmd._htmlCache));
2114 2119
2115 on(content, 'click', 'a', function (e) { 2120 onEvent(content, 'click', 'a', function (target, e) {
2116 callback(data(this, 'color')); 2121 callback(data(target, 'color'));
2117 editor.closeDropDown(true); 2122 editor.closeDropDown(true);
2118 e.preventDefault(); 2123 e.preventDefault();
2119 }); 2124 });
2120 2125
2121 editor.createDropDown(caller, 'color-picker', content); 2126 editor.createDropDown(caller, 'color-picker', content);
2170 'Paste your text inside the following box:' 2175 'Paste your text inside the following box:'
2171 ), 2176 ),
2172 insert: editor._('Insert') 2177 insert: editor._('Insert')
2173 }, true)); 2178 }, true));
2174 2179
2175 on(content, 'click', '.button', function (e) { 2180 onEvent(content, 'click', '.button', function (target, e) {
2176 val = find(content, '#txt')[0].value; 2181 val = find(content, '#txt')[0].value;
2177 2182
2178 if (val) { 2183 if (val) {
2179 editor.wysiwygEditorInsertText(val); 2184 editor.wysiwygEditorInsertText(val);
2180 } 2185 }
2282 rows: editor._('Rows:'), 2287 rows: editor._('Rows:'),
2283 cols: editor._('Cols:'), 2288 cols: editor._('Cols:'),
2284 insert: editor._('Insert') 2289 insert: editor._('Insert')
2285 }, true)); 2290 }, true));
2286 2291
2287 on(content, 'click', '.button', function (e) { 2292 onEvent(content, 'click', '.button', function (target, e) {
2288 var rows = Number(find(content, '#rows')[0].value), 2293 var rows = Number(find(content, '#rows')[0].value),
2289 cols = Number(find(content, '#cols')[0].value), 2294 cols = Number(find(content, '#cols')[0].value),
2290 html = '<table>'; 2295 html = '<table>';
2291 2296
2292 if (rows > 0 && cols > 0) { 2297 if (rows > 0 && cols > 0) {
2346 2351
2347 var urlInput = find(content, '#image')[0]; 2352 var urlInput = find(content, '#image')[0];
2348 2353
2349 urlInput.value = selected; 2354 urlInput.value = selected;
2350 2355
2351 on(content, 'click', '.button', function (e) { 2356 onEvent(content, 'click', '.button', function (target, e) {
2352 if (urlInput.value) { 2357 if (urlInput.value) {
2353 cb( 2358 cb(
2354 urlInput.value, 2359 urlInput.value,
2355 find(content, '#width')[0].value, 2360 find(content, '#width')[0].value,
2356 find(content, '#height')[0].value 2361 find(content, '#height')[0].value
2400 label: editor._('E-mail:'), 2405 label: editor._('E-mail:'),
2401 desc: editor._('Description (optional):'), 2406 desc: editor._('Description (optional):'),
2402 insert: editor._('Insert') 2407 insert: editor._('Insert')
2403 }, true)); 2408 }, true));
2404 2409
2405 on(content, 'click', '.button', function (e) { 2410 onEvent(content, 'click', '.button', function (target, e) {
2406 var email = find(content, '#email')[0].value; 2411 var email = find(content, '#email')[0].value;
2407 2412
2408 if (email) { 2413 if (email) {
2409 cb(email, find(content, '#des')[0].value); 2414 cb(email, find(content, '#des')[0].value);
2410 } 2415 }
2448 ins: editor._('Insert') 2453 ins: editor._('Insert')
2449 }, true)); 2454 }, true));
2450 2455
2451 var linkInput = find(content, '#link')[0]; 2456 var linkInput = find(content, '#link')[0];
2452 2457
2453 function insertUrl(e) { 2458 function insertUrl(target,e) {
2454 if (linkInput.value) { 2459 if (linkInput.value) {
2455 cb(linkInput.value, find(content, '#des')[0].value); 2460 cb(linkInput.value, find(content, '#des')[0].value);
2456 } 2461 }
2457 2462
2458 editor.closeDropDown(true); 2463 editor.closeDropDown(true);
2459 e.preventDefault(); 2464 e.preventDefault();
2460 } 2465 }
2461 2466
2462 on(content, 'click', '.button', insertUrl); 2467 onEvent(content, 'click', '.button', insertUrl);
2463 on(content, 'keypress', function (e) { 2468 onEvent(content, 'keypress', function (target, e) {
2464 // 13 = enter key 2469 // 13 = enter key
2465 if (e.which === 13 && linkInput.value) { 2470 if (e.which === 13 && linkInput.value) {
2466 insertUrl(e); 2471 insertUrl(e);
2467 } 2472 }
2468 }, EVENT_CAPTURE); 2473 }, EVENT_CAPTURE);
2556 2561
2557 appendChild(content, line); 2562 appendChild(content, line);
2558 2563
2559 perLine = Math.sqrt(Object.keys(emoticons).length); 2564 perLine = Math.sqrt(Object.keys(emoticons).length);
2560 2565
2561 on(content, 'click', 'img', function (e) { 2566 onEvent(content, 'click', 'img', function (target, e) {
2562 editor.insert(startSpace + attr(this, 'alt') + endSpace, 2567 editor.insert(startSpace + attr(target, 'alt') + endSpace,
2563 null, false).closeDropDown(true); 2568 null, false).closeDropDown(true);
2564 2569
2565 e.preventDefault(); 2570 e.preventDefault();
2566 }); 2571 });
2567 2572
2584 }); 2589 });
2585 2590
2586 appendChild(moreLink, 2591 appendChild(moreLink,
2587 document.createTextNode(editor._('More'))); 2592 document.createTextNode(editor._('More')));
2588 2593
2589 on(moreLink, 'click', function (e) { 2594 onEvent(moreLink, 'click', function (e) {
2590 editor.createDropDown( 2595 editor.createDropDown(
2591 caller, 'more-emoticons', createContent(true) 2596 caller, 'more-emoticons', createContent(true)
2592 ); 2597 );
2593 2598
2594 e.preventDefault(); 2599 e.preventDefault();
2617 appendChild(content, _tmpl('youtubeMenu', { 2622 appendChild(content, _tmpl('youtubeMenu', {
2618 label: editor._('Video URL:'), 2623 label: editor._('Video URL:'),
2619 insert: editor._('Insert') 2624 insert: editor._('Insert')
2620 }, true)); 2625 }, true));
2621 2626
2622 on(content, 'click', '.button', function (e) { 2627 onEvent(content, 'click', '.button', function (target, e) {
2623 var val = find(content, '#link')[0].value; 2628 var val = find(content, '#link')[0].value;
2624 var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/); 2629 var idMatch = val.match(/(?:v=|v\/|embed\/|youtu.be\/)?([a-zA-Z0-9_-]{11})/);
2625 var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/); 2630 var timeMatch = val.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/);
2626 var time = 0; 2631 var time = 0;
2627 2632
5880 } 5885 }
5881 5886
5882 updateActiveButtons(); 5887 updateActiveButtons();
5883 5888
5884 var loaded = function () { 5889 var loaded = function () {
5885 off(globalWin, 'load', loaded); 5890 offEvent(globalWin, 'load', loaded);
5886 5891
5887 if (options.autofocus) { 5892 if (options.autofocus) {
5888 autofocus(!!options.autofocusEnd); 5893 autofocus(!!options.autofocusEnd);
5889 } 5894 }
5890 5895
5894 pluginManager.call('ready'); 5899 pluginManager.call('ready');
5895 if ('onReady' in format) { 5900 if ('onReady' in format) {
5896 format.onReady.call(base); 5901 format.onReady.call(base);
5897 } 5902 }
5898 }; 5903 };
5899 on(globalWin, 'load', loaded); 5904 onEvent(globalWin, 'load', loaded);
5900 if (globalDoc.readyState === 'complete') { 5905 if (globalDoc.readyState === 'complete') {
5901 loaded(); 5906 loaded();
5902 } 5907 }
5903 }; 5908 };
5904 5909
5983 base.readOnly(!!options.readOnly); 5988 base.readOnly(!!options.readOnly);
5984 5989
5985 // iframe overflow fix for iOS 5990 // iframe overflow fix for iOS
5986 if (ios) { 5991 if (ios) {
5987 height(wysiwygBody, '100%'); 5992 height(wysiwygBody, '100%');
5988 on(wysiwygBody, 'touchend', base.focus); 5993 onEvent(wysiwygBody, 'touchend', base.focus);
5989 } 5994 }
5990 5995
5991 var tabIndex = attr(original, 'tabindex'); 5996 var tabIndex = attr(original, 'tabindex');
5992 attr(sourceEditor, 'tabindex', tabIndex); 5997 attr(sourceEditor, 'tabindex', tabIndex);
5993 attr(wysiwygEditor, 'tabindex', tabIndex); 5998 attr(wysiwygEditor, 'tabindex', tabIndex);
6012 * @private 6017 * @private
6013 */ 6018 */
6014 initOptions = function () { 6019 initOptions = function () {
6015 // auto-update original textbox on blur if option set to true 6020 // auto-update original textbox on blur if option set to true
6016 if (options.autoUpdate) { 6021 if (options.autoUpdate) {
6017 on(wysiwygBody, 'blur', autoUpdate); 6022 onEvent(wysiwygBody, 'blur', autoUpdate);
6018 on(sourceEditor, 'blur', autoUpdate); 6023 onEvent(sourceEditor, 'blur', autoUpdate);
6019 } 6024 }
6020 6025
6021 if (options.rtl === null) { 6026 if (options.rtl === null) {
6022 options.rtl = css(sourceEditor, 'direction') === 'rtl'; 6027 options.rtl = css(sourceEditor, 'direction') === 'rtl';
6023 } 6028 }
6024 6029
6025 base.rtl(!!options.rtl); 6030 base.rtl(!!options.rtl);
6026 6031
6027 if (options.autoExpand) { 6032 if (options.autoExpand) {
6028 // Need to update when images (or anything else) loads 6033 // Need to update when images (or anything else) loads
6029 on(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE); 6034 onEvent(wysiwygBody, 'load', autoExpand, EVENT_CAPTURE);
6030 on(wysiwygBody, 'input keyup', autoExpand); 6035 onEvent(wysiwygBody, 'input keyup', autoExpand);
6031 } 6036 }
6032 6037
6033 if (options.resizeEnabled) { 6038 if (options.resizeEnabled) {
6034 initResize(); 6039 initResize();
6035 } 6040 }
6049 'keydown keyup keypress focus blur contextmenu input'; 6054 'keydown keyup keypress focus blur contextmenu input';
6050 var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ? 6055 var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ?
6051 'selectionchange' : 6056 'selectionchange' :
6052 'keyup focus blur contextmenu mouseup touchend click'; 6057 'keyup focus blur contextmenu mouseup touchend click';
6053 6058
6054 on(globalDoc, 'click', handleDocumentClick); 6059 onEvent(globalDoc, 'click', handleDocumentClick);
6055 6060
6056 if (form) { 6061 if (form) {
6057 on(form, 'reset', handleFormReset); 6062 onEvent(form, 'reset', handleFormReset);
6058 on(form, 'submit', base.updateOriginal, EVENT_CAPTURE); 6063 onEvent(form, 'submit', base.updateOriginal, EVENT_CAPTURE);
6059 } 6064 }
6060 6065
6061 on(window, 'pagehide', base.updateOriginal); 6066 onEvent(window, 'pagehide', base.updateOriginal);
6062 on(window, 'pageshow', handleFormReset); 6067 onEvent(window, 'pageshow', handleFormReset);
6063 on(wysiwygBody, 'keypress', handleKeyPress); 6068 onEvent(wysiwygBody, 'keypress', handleKeyPress);
6064 on(wysiwygBody, 'keydown', handleKeyDown); 6069 onEvent(wysiwygBody, 'keydown', handleKeyDown);
6065 on(wysiwygBody, 'keydown', handleBackSpace); 6070 onEvent(wysiwygBody, 'keydown', handleBackSpace);
6066 on(wysiwygBody, 'keyup', appendNewLine); 6071 onEvent(wysiwygBody, 'keyup', appendNewLine);
6067 on(wysiwygBody, 'blur', valueChangedBlur); 6072 onEvent(wysiwygBody, 'blur', valueChangedBlur);
6068 on(wysiwygBody, 'keyup', valueChangedKeyUp); 6073 onEvent(wysiwygBody, 'keyup', valueChangedKeyUp);
6069 on(wysiwygBody, 'paste', handlePasteEvt); 6074 onEvent(wysiwygBody, 'paste', handlePasteEvt);
6070 on(wysiwygBody, 'cut copy', handleCutCopyEvt); 6075 onEvent(wysiwygBody, 'cut copy', handleCutCopyEvt);
6071 on(wysiwygBody, compositionEvents, handleComposition); 6076 onEvent(wysiwygBody, compositionEvents, handleComposition);
6072 on(wysiwygBody, checkSelectionEvents, checkSelectionChanged); 6077 onEvent(wysiwygBody, checkSelectionEvents, checkSelectionChanged);
6073 on(wysiwygBody, eventsToForward, handleEvent); 6078 onEvent(wysiwygBody, eventsToForward, handleEvent);
6074 6079
6075 if (options.emoticonsCompat && globalWin.getSelection) { 6080 if (options.emoticonsCompat && globalWin.getSelection) {
6076 on(wysiwygBody, 'keyup', emoticonsCheckWhitespace); 6081 onEvent(wysiwygBody, 'keyup', emoticonsCheckWhitespace);
6077 } 6082 }
6078 6083
6079 on(wysiwygBody, 'blur', function () { 6084 onEvent(wysiwygBody, 'blur', function () {
6080 if (!base.val()) { 6085 if (!base.val()) {
6081 addClass(wysiwygBody, 'placeholder'); 6086 addClass(wysiwygBody, 'placeholder');
6082 } 6087 }
6083 }); 6088 });
6084 6089
6085 on(wysiwygBody, 'focus', function () { 6090 onEvent(wysiwygBody, 'focus', function () {
6086 removeClass(wysiwygBody, 'placeholder'); 6091 removeClass(wysiwygBody, 'placeholder');
6087 }); 6092 });
6088 6093
6089 on(sourceEditor, 'blur', valueChangedBlur); 6094 onEvent(sourceEditor, 'blur', valueChangedBlur);
6090 on(sourceEditor, 'keyup', valueChangedKeyUp); 6095 onEvent(sourceEditor, 'keyup', valueChangedKeyUp);
6091 on(sourceEditor, 'keydown', handleKeyDown); 6096 onEvent(sourceEditor, 'keydown', handleKeyDown);
6092 on(sourceEditor, compositionEvents, handleComposition); 6097 onEvent(sourceEditor, compositionEvents, handleComposition);
6093 on(sourceEditor, eventsToForward, handleEvent); 6098 onEvent(sourceEditor, eventsToForward, handleEvent);
6094 6099
6095 on(wysiwygDocument, 'mousedown', handleMouseDown); 6100 onEvent(wysiwygDocument, 'mousedown', handleMouseDown);
6096 on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged); 6101 onEvent(wysiwygDocument, checkSelectionEvents, checkSelectionChanged);
6097 on(wysiwygDocument, 'keyup', appendNewLine); 6102 onEvent(wysiwygDocument, 'keyup', appendNewLine);
6098 6103
6099 on(editorContainer, 'selectionchanged', checkNodeChanged); 6104 onEvent(editorContainer, 'selectionchanged', checkNodeChanged);
6100 on(editorContainer, 'selectionchanged', updateActiveButtons); 6105 onEvent(editorContainer, 'selectionchanged', updateActiveButtons);
6101 // Custom events to forward 6106 // Custom events to forward
6102 on( 6107 onEvent(
6103 editorContainer, 6108 editorContainer,
6104 'selectionchanged valuechanged nodechanged pasteraw paste', 6109 'selectionchanged valuechanged nodechanged pasteraw paste',
6105 handleEvent 6110 handleEvent
6106 ); 6111 );
6107 }; 6112 };
6152 } 6157 }
6153 6158
6154 button._sceTxtMode = !!command.txtExec; 6159 button._sceTxtMode = !!command.txtExec;
6155 button._sceWysiwygMode = !!command.exec; 6160 button._sceWysiwygMode = !!command.exec;
6156 toggleClass(button, 'disabled', !command.exec); 6161 toggleClass(button, 'disabled', !command.exec);
6157 on(button, 'click', function (e) { 6162 onEvent(button, 'click', function (e) {
6158 if (!hasClass(button, 'disabled')) { 6163 if (!hasClass(button, 'disabled')) {
6159 handleCommand(button, command); 6164 handleCommand(button, command);
6160 } 6165 }
6161 6166
6162 updateActiveButtons(); 6167 updateActiveButtons();
6163 e.preventDefault(); 6168 e.preventDefault();
6164 }); 6169 });
6165 // Prevent editor losing focus when button clicked 6170 // Prevent editor losing focus when button clicked
6166 on(button, 'mousedown', function (e) { 6171 onEvent(button, 'mousedown', function (e) {
6167 base.closeDropDown(); 6172 base.closeDropDown();
6168 e.preventDefault(); 6173 e.preventDefault();
6169 }); 6174 });
6170 6175
6171 if (command.tooltip) { 6176 if (command.tooltip) {
6289 6294
6290 isDragging = false; 6295 isDragging = false;
6291 6296
6292 hide(cover); 6297 hide(cover);
6293 removeClass(editorContainer, 'resizing'); 6298 removeClass(editorContainer, 'resizing');
6294 off(globalDoc, moveEvents, mouseMoveFunc); 6299 offEvent(globalDoc, moveEvents, mouseMoveFunc);
6295 off(globalDoc, endEvents, mouseUpFunc); 6300 offEvent(globalDoc, endEvents, mouseUpFunc);
6296 6301
6297 e.preventDefault(); 6302 e.preventDefault();
6298 }; 6303 };
6299 6304
6300 if (icons.create) { 6305 if (icons.create) {
6307 6312
6308 appendChild(editorContainer, grip); 6313 appendChild(editorContainer, grip);
6309 appendChild(editorContainer, cover); 6314 appendChild(editorContainer, cover);
6310 hide(cover); 6315 hide(cover);
6311 6316
6312 on(grip, 'touchstart mousedown', function (e) { 6317 onEvent(grip, 'touchstart mousedown', function (e) {
6313 // iOS uses window.event 6318 // iOS uses window.event
6314 if (e.type === 'touchstart') { 6319 if (e.type === 'touchstart') {
6315 e = globalWin.event; 6320 e = globalWin.event;
6316 startX = e.touches[0].pageX; 6321 startX = e.touches[0].pageX;
6317 startY = e.touches[0].pageY; 6322 startY = e.touches[0].pageY;
6324 startHeight = height(editorContainer); 6329 startHeight = height(editorContainer);
6325 isDragging = true; 6330 isDragging = true;
6326 6331
6327 addClass(editorContainer, 'resizing'); 6332 addClass(editorContainer, 'resizing');
6328 show(cover); 6333 show(cover);
6329 on(globalDoc, moveEvents, mouseMoveFunc); 6334 onEvent(globalDoc, moveEvents, mouseMoveFunc);
6330 on(globalDoc, endEvents, mouseUpFunc); 6335 onEvent(globalDoc, endEvents, mouseUpFunc);
6331 6336
6332 e.preventDefault(); 6337 e.preventDefault();
6333 }); 6338 });
6334 }; 6339 };
6335 6340
6789 6794
6790 if (dropdown) { 6795 if (dropdown) {
6791 remove(dropdown); 6796 remove(dropdown);
6792 } 6797 }
6793 6798
6794 off(globalDoc, 'click', handleDocumentClick); 6799 offEvent(globalDoc, 'click', handleDocumentClick);
6795 6800
6796 var form = original.form; 6801 var form = original.form;
6797 if (form) { 6802 if (form) {
6798 off(form, 'reset', handleFormReset); 6803 offEvent(form, 'reset', handleFormReset);
6799 off(form, 'submit', base.updateOriginal, EVENT_CAPTURE); 6804 offEvent(form, 'submit', base.updateOriginal, EVENT_CAPTURE);
6800 } 6805 }
6801 6806
6802 off(window, 'pagehide', base.updateOriginal); 6807 offEvent(window, 'pagehide', base.updateOriginal);
6803 off(window, 'pageshow', handleFormReset); 6808 offEvent(window, 'pageshow', handleFormReset);
6804 remove(sourceEditor); 6809 remove(sourceEditor);
6805 remove(toolbar); 6810 remove(toolbar);
6806 remove(editorContainer); 6811 remove(editorContainer);
6807 6812
6808 delete original._sceditor; 6813 delete original._sceditor;
6846 }); 6851 });
6847 6852
6848 css(dropdown, dropDownCss); 6853 css(dropdown, dropDownCss);
6849 appendChild(dropdown, content); 6854 appendChild(dropdown, content);
6850 appendChild(editorContainer, dropdown); 6855 appendChild(editorContainer, dropdown);
6851 on(dropdown, 'click focusin', function (e) { 6856 onEvent(dropdown, 'click focusin', function (e) {
6852 // stop clicks within the dropdown from being handled 6857 // stop clicks within the dropdown from being handled
6853 e.stopPropagation(); 6858 e.stopPropagation();
6854 }); 6859 });
6855 6860
6856 if (dropdown) { 6861 if (dropdown) {
8431 } 8436 }
8432 8437
8433 options.emoticonsEnabled = enable; 8438 options.emoticonsEnabled = enable;
8434 8439
8435 if (enable) { 8440 if (enable) {
8436 on(wysiwygBody, 'keypress', emoticonsKeyPress); 8441 onEvent(wysiwygBody, 'keypress', emoticonsKeyPress);
8437 8442
8438 if (!base.sourceMode()) { 8443 if (!base.sourceMode()) {
8439 rangeHelper.saveRange(); 8444 rangeHelper.saveRange();
8440 8445
8441 replaceEmoticons(); 8446 replaceEmoticons();
8451 var text = data(img, 'sceditor-emoticon'); 8456 var text = data(img, 'sceditor-emoticon');
8452 var textNode = wysiwygDocument.createTextNode(text); 8457 var textNode = wysiwygDocument.createTextNode(text);
8453 img.parentNode.replaceChild(textNode, img); 8458 img.parentNode.replaceChild(textNode, img);
8454 }); 8459 });
8455 8460
8456 off(wysiwygBody, 'keypress', emoticonsKeyPress); 8461 offEvent(wysiwygBody, 'keypress', emoticonsKeyPress);
8457 8462
8458 triggerValueChanged(); 8463 triggerValueChanged();
8459 } 8464 }
8460 8465
8461 return base; 8466 return base;