|
105 | 105 | * @name jQuery.sceditor
|
106 | 106 | */
|
107 | 107 | $.sceditor = function (el, options) {
|
| 108 | + var IE_VER = $.sceditor.ie; |
| 109 | + |
| 110 | + // In IE < 11 a BR at the end of a block level element |
| 111 | + // causes a double line break. |
| 112 | + var IE_BR_FIX = IE_VER && IE_VER < 11; |
| 113 | + |
108 | 114 | /**
|
109 | 115 | * Alias of this
|
110 | 116 | * @private
|
|
365 | 371 |
|
366 | 372 | // Add IE version to the container to allow IE specific CSS
|
367 | 373 | // fixes without using CSS hacks or conditional comments
|
368 |
| - if($.sceditor.ie) |
369 |
| - $editorContainer.addClass('ie ie' + $.sceditor.ie); |
| 374 | + if(IE_VER) |
| 375 | + $editorContainer.addClass('ie ie' + IE_VER); |
370 | 376 |
|
371 | 377 | isRequired = !!$original.attr('required');
|
372 | 378 | $original.removeAttr('required');
|
|
474 | 480 |
|
475 | 481 | // Add IE version class to the HTML element so can apply
|
476 | 482 | // conditional styling without CSS hacks
|
477 |
| - if($.sceditor.ie) |
478 |
| - $wysiwygDoc.find('html').addClass('ie ie' + $.sceditor.ie); |
| 483 | + if(IE_VER) |
| 484 | + $wysiwygDoc.find('html').addClass('ie ie' + IE_VER); |
479 | 485 |
|
480 | 486 | // iframe overflow fix for iOS, also fixes an IE issue with the
|
481 | 487 | // editor not getting focus when clicking inside
|
482 |
| - if($.sceditor.ios || $.sceditor.ie) |
| 488 | + if($.sceditor.ios || IE_VER) |
483 | 489 | {
|
484 | 490 | $wysiwygBody.height('100%');
|
485 | 491 |
|
486 |
| - if(!$.sceditor.ie) |
| 492 | + if(!IE_VER) |
487 | 493 | $wysiwygBody.bind('touchend', base.focus);
|
488 | 494 | }
|
489 | 495 |
|
|
545 | 551 | .bind('blur', valueChangedBlur)
|
546 | 552 | .keyup(valueChangedKeyUp)
|
547 | 553 | .bind('paste', handlePasteEvt)
|
548 |
| - .bind($.sceditor.ie ? 'selectionchange' : 'keyup focus blur contextmenu mouseup touchend click', checkSelectionChanged) |
| 554 | + .bind(IE_VER ? 'selectionchange' : 'keyup focus blur contextmenu mouseup touchend click', checkSelectionChanged) |
549 | 555 | .bind('keydown keyup keypress focus blur contextmenu', handleEvent);
|
550 | 556 |
|
551 | 557 | if(options.emoticonsCompat && window.getSelection)
|
|
560 | 566 | $wysiwygDoc
|
561 | 567 | .mousedown(handleMouseDown)
|
562 | 568 | .bind('blur', valueChangedBlur)
|
563 |
| - .bind($.sceditor.ie ? 'selectionchange' : 'focus blur contextmenu mouseup click', checkSelectionChanged) |
| 569 | + .bind(IE_VER ? 'selectionchange' : 'focus blur contextmenu mouseup click', checkSelectionChanged) |
564 | 570 | .bind('beforedeactivate keyup', saveRange)
|
565 | 571 | .keyup(appendNewLine)
|
566 | 572 | .focus(function() {
|
|
704 | 710 | base.dimensions(newWidth, newHeight);
|
705 | 711 |
|
706 | 712 | // The resize cover will not fill the container in IE6 unless a height is specified.
|
707 |
| - if($.sceditor.ie < 7) |
| 713 | + if(IE_VER < 7) |
708 | 714 | $editorContainer.height(newHeight);
|
709 | 715 | }
|
710 | 716 |
|
|
745 | 751 | $(document).bind('touchend mouseup', mouseUpFunc);
|
746 | 752 |
|
747 | 753 | // The resize cover will not fill the container in IE6 unless a height is specified.
|
748 |
| - if($.sceditor.ie < 7) |
| 754 | + if(IE_VER < 7) |
749 | 755 | $editorContainer.height(startHeight);
|
750 | 756 |
|
751 | 757 | e.preventDefault();
|
|
1037 | 1043 | base.dimensions = function(width, height, save) {
|
1038 | 1044 | // IE6 & IE7 add 2 pixels to the source mode textarea height which must be ignored.
|
1039 | 1045 | // Doesn't seem to be any way to fix it with only CSS
|
1040 |
| - var ieBorderBox = $.sceditor.ie < 8 || document.documentMode < 8 ? 2 : 0; |
| 1046 | + var ieBorderBox = IE_VER < 8 || document.documentMode < 8 ? 2 : 0; |
1041 | 1047 |
|
1042 | 1048 | // set undefined width/height to boolean false
|
1043 | 1049 | width = (!width && width !== 0) ? false : width;
|
|
1178 | 1184 | maximize = !!maximize;
|
1179 | 1185 |
|
1180 | 1186 | // IE 6 fix
|
1181 |
| - if($.sceditor.ie < 7) |
| 1187 | + if(IE_VER < 7) |
1182 | 1188 | $('html, body').toggleClass('sceditor-maximize', maximize);
|
1183 | 1189 |
|
1184 | 1190 | $editorContainer.toggleClass('sceditor-maximize', maximize);
|
|
1916 | 1922 | */
|
1917 | 1923 | base.setWysiwygEditorValue = function (value) {
|
1918 | 1924 | if(!value)
|
1919 |
| - value = '<p>' + ($.sceditor.ie ? '' : '<br />') + '</p>'; |
| 1925 | + value = '<p>' + (IE_VER ? '' : '<br />') + '</p>'; |
1920 | 1926 |
|
1921 | 1927 | $wysiwygBody[0].innerHTML = value;
|
1922 | 1928 | replaceEmoticons($wysiwygBody[0]);
|
|
2146 | 2152 | */
|
2147 | 2153 | saveRange = function () {
|
2148 | 2154 | /* this is only needed for IE */
|
2149 |
| - if($.sceditor.ie) |
| 2155 | + if(IE_VER) |
2150 | 2156 | lastRange = rangeHelper.selectedRange();
|
2151 | 2157 | };
|
2152 | 2158 |
|
|
2208 | 2214 |
|
2209 | 2215 | // In IE, this is only called on the selectionchanged event so no need to
|
2210 | 2216 | // limit checking as it should always be valid to do.
|
2211 |
| - if($.sceditor.ie) |
| 2217 | + if(IE_VER) |
2212 | 2218 | check();
|
2213 | 2219 | else
|
2214 | 2220 | setTimeout(check, 100);
|
|
2377 | 2383 |
|
2378 | 2384 | // find the last non-empty text node or line break.
|
2379 | 2385 | if((node.nodeType === 3 && !/^\s*$/.test(node.nodeValue)) || name === 'br' ||
|
2380 |
| - ($.sceditor.ie && !node.firstChild && !$.sceditor.dom.isInline(node, false))) |
| 2386 | + (IE_BR_FIX && !node.firstChild && !$.sceditor.dom.isInline(node, false))) |
2381 | 2387 | {
|
2382 | 2388 | // this is the last text or br node, if its in a code or quote tag
|
2383 | 2389 | // then add a newline to the end of the editor
|
2384 | 2390 | if(requiresNewLine)
|
2385 | 2391 | {
|
2386 | 2392 | div = $wysiwygBody[0].ownerDocument.createElement('div');
|
2387 | 2393 | div.className = 'sceditor-nlf';
|
2388 |
| - div.innerHTML = !$.sceditor.ie ? '<br />' : ''; |
| 2394 | + div.innerHTML = !IE_BR_FIX ? '<br />' : ''; |
2389 | 2395 | $wysiwygBody[0].appendChild(div);
|
2390 | 2396 | }
|
2391 | 2397 |
|
|
3059 | 3065 | var node, offset, tmpRange, range, parent;
|
3060 | 3066 |
|
3061 | 3067 | // 8 is the backspace key
|
3062 |
| - if($.sceditor.ie || options.disableBlockRemove || e.which !== 8 || !(range = rangeHelper.selectedRange())) |
| 3068 | + if(IE_VER || options.disableBlockRemove || e.which !== 8 || !(range = rangeHelper.selectedRange())) |
3063 | 3069 | return;
|
3064 | 3070 |
|
3065 | 3071 | if(!window.getSelection)
|
|
3814 | 3820 | }, true);
|
3815 | 3821 |
|
3816 | 3822 | content.find('.button').click(function (e) {
|
| 3823 | + var IE_VER = $.sceditor.ie; |
3817 | 3824 | var rows = content.find('#rows').val() - 0,
|
3818 | 3825 | cols = content.find('#cols').val() - 0,
|
3819 | 3826 | html = '<table>';
|
|
3825 | 3832 | html += '<tr>';
|
3826 | 3833 |
|
3827 | 3834 | for (var col=0; col < cols; col++)
|
3828 |
| - html += '<td>' + ($.sceditor.ie ? '' : '<br />') + '</td>'; |
| 3835 | + html += '<td>' + (IE_VER && IE_VER < 11 ? '' : '<br />') + '</td>'; |
3829 | 3836 |
|
3830 | 3837 | html += '</tr>';
|
3831 | 3838 | }
|
|
3989 | 3996 | quote: {
|
3990 | 3997 | forceNewLineAfter: ['blockquote'],
|
3991 | 3998 | exec: function (caller, html, author) {
|
| 3999 | + var IE_VER = $.sceditor.ie; |
3992 | 4000 | var before = '<blockquote>',
|
3993 | 4001 | end = '</blockquote>';
|
3994 | 4002 |
|
|
4002 | 4010 | }
|
4003 | 4011 | // if not add a newline to the end of the inserted quote
|
4004 | 4012 | else if(this.getRangeHelper().selectedHtml() === '')
|
4005 |
| - end = $.sceditor.ie ? '' : '<br />' + end; |
| 4013 | + end = IE_VER && IE_VER < 11 ? '' : '<br />' + end; |
4006 | 4014 |
|
4007 | 4015 | this.wysiwygEditorInsertHtml(before, end);
|
4008 | 4016 | },
|
|
0 commit comments