1 2 3 mw.tools.richtextEditorSettings = { 4 width: '100%', 5 height: 'auto', 6 addControls: false, 7 hideControls: false, 8 ready: false 9 }; 10 11 mw.tools.richtextEditor = function (obj) { 12 if (typeof obj.element === 'string') { 13 obj.element = mw.$(obj.element)[0]; 14 } 15 if (!obj.element || obj.element === undefined) return false; 16 17 var o = $.extend({}, mw.tools.richtextEditorSettings, obj); 18 var frame = document.createElement('iframe'); 19 frame.richtextEditorSettings = o; 20 frame.className = 'mw-fullscreen mw-iframe-editor'; 21 frame.scrolling = 'no'; 22 var name = 'mw-editor' + mw.random(); 23 frame.id = name; 24 frame.name = name; 25 frame.style.backgroundColor = "white"; 26 frame.setAttribute('frameborder', 0); 27 frame.setAttribute('allowtransparency', 'true'); 28 mw.$(o.element).after(frame); 29 mw.$(o.element).hide(); 30 $.get(mw.external_tool('editor_toolbar'), function (a) { 31 if (frame.contentWindow.document === null) { 32 return; 33 } 34 frame.contentWindow.document.open('text/html', 'replace'); 35 frame.contentWindow.document.write(a); 36 frame.contentWindow.document.close(); 37 frame.contentWindow.editorArea = o.element; 38 frame.contentWindow.thisFrame = frame; 39 frame.contentWindow.pauseChange = true; 40 frame.contentWindow.richtextEditorSettings = o; 41 42 frame.onload = function () { 43 var val = o.element.nodeName !== 'TEXTAREA' ? o.element.innerHTML : o.element.value 44 frame.contentWindow.document.getElementById('editor-area').innerHTML = val; 45 if (!!o.hideControls && o.hideControls.constructor === [].constructor) { 46 var l = o.hideControls.length, i = 0; 47 for (; i < l; i++) { 48 mw.$('.mw_editor_' + o.hideControls[i], frame.contentWindow.document).hide(); 49 } 50 } 51 if (!!o.addControls && (typeof o.addControls === 'string' || typeof o.addControls === 'function' || !!o.addControls.nodeType)) { 52 mw.$('.editor_wrapper', frame.contentWindow.document).append(o.addControls); 53 } 54 frame.api = frame.contentWindow.mw.wysiwyg; 55 if (typeof o.ready === 'function') { 56 o.ready.call(frame, frame.contentWindow.document); 57 } 58 setTimeout(function () { 59 if (frame.contentWindow) { 60 frame.contentWindow.pauseChange = false; 61 } 62 63 }, frame.contentWindow.SetValueTime); 64 mw.$(obj.element).on('sourceChanged', function(e, val){ 65 frame.contentWindow.document.getElementById('editor-area').innerHTML = val; 66 }) 67 mw.$(frame.contentWindow.document.getElementById('editor-area')).on('keyup paste change', function(){ 68 if (frame.richtextEditorSettings.element.nodeName !== 'TEXTAREA') { 69 frame.richtextEditorSettings.element.innerHTML = this.innerHTML 70 } else { 71 frame.richtextEditorSettings.element.value = this.innerHTML; 72 } 73 }) 74 frame.contentWindow.mw.tools.createStyle(undefined, '#editor-area{' + (obj.style || '') + '}'); 75 } 76 mw.$(obj.element).on('sourceChanged', function (e, val) { 77 frame.contentWindow.document.getElementById('editor-area').innerHTML = val; 78 }); 79 80 }); 81 o.width = o.width != 'auto' ? o.width : '100%'; 82 mw.$(frame).css({width: o.width, height: o.height}); 83 if(o.height === 'auto') { 84 mw.tools.iframeAutoHeight(frame); 85 } 86 frame.setValue = function (val) { 87 frame.contentWindow.pauseChange = true; 88 frame.contentWindow.document.getElementById('editor-area').innerHTML = val; 89 if (frame.richtextEditorSettings.element.nodeName !== 'TEXTAREA') { 90 frame.richtextEditorSettings.element.innerHTML = val 91 } 92 else { 93 frame.richtextEditorSettings.element.value = val; 94 } 95 frame.value = val; 96 frame.contentWindow.pauseChange = false;
97 } 98 return frame; 99 } 100 101 mw.editor = mw.tools.richtextEditor;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.