Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.preview.css |
— | — | @@ -3,15 +3,31 @@ |
4 | 4 | background: #f3f3f3 !important; |
5 | 5 | font-size: 1em; |
6 | 6 | } |
7 | | - |
| 7 | +/* |
8 | 8 | .wikiEditor-ui .ui-widget-content .ui-state-default { |
9 | 9 | background: #ffffff; |
10 | 10 | } |
11 | | - |
12 | 11 | .wikiEditor-ui .ui-widget-content .ui-state-hover { |
13 | 12 | background: #dadada; |
14 | 13 | } |
15 | | - |
16 | 14 | .wikiEditor-ui .ui-widget-content .ui-state-active { |
17 | 15 | background: #f3f3f3; |
18 | 16 | } |
| 17 | +*/ |
| 18 | +.wikiEditor-ui .ui-tabs .wikiEditor-tab-edit { |
| 19 | + padding: 0; |
| 20 | + margin: 0; |
| 21 | +} |
| 22 | +.wikiEditor-ui .ui-tabs-nav { |
| 23 | + margin-bottom: 0 !important; |
| 24 | +} |
| 25 | +.wikiEditor-ui .ui-tabs { |
| 26 | + padding: 0; |
| 27 | +} |
| 28 | +.wikiEditor-ui .ui-widget-content { |
| 29 | + border-width: 0; |
| 30 | +} |
| 31 | +.wikiEditor-ui .ui-widget-header { |
| 32 | + border-width: 0; |
| 33 | + border-bottom-width: 1px; |
| 34 | +} |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -578,15 +578,31 @@ |
579 | 579 | background: #f3f3f3 !important; |
580 | 580 | font-size: 1em; |
581 | 581 | } |
582 | | - |
| 582 | +/* |
583 | 583 | .wikiEditor-ui .ui-widget-content .ui-state-default { |
584 | 584 | background: #ffffff; |
585 | 585 | } |
586 | | - |
587 | 586 | .wikiEditor-ui .ui-widget-content .ui-state-hover { |
588 | 587 | background: #dadada; |
589 | 588 | } |
590 | | - |
591 | 589 | .wikiEditor-ui .ui-widget-content .ui-state-active { |
592 | 590 | background: #f3f3f3; |
593 | 591 | } |
| 592 | +*/ |
| 593 | +.wikiEditor-ui .ui-tabs .wikiEditor-tab-edit { |
| 594 | + padding: 0; |
| 595 | + margin: 0; |
| 596 | +} |
| 597 | +.wikiEditor-ui .ui-tabs-nav { |
| 598 | + margin-bottom: 0 !important; |
| 599 | +} |
| 600 | +.wikiEditor-ui .ui-tabs { |
| 601 | + padding: 0; |
| 602 | +} |
| 603 | +.wikiEditor-ui .ui-widget-content { |
| 604 | + border-width: 0; |
| 605 | +} |
| 606 | +.wikiEditor-ui .ui-widget-header { |
| 607 | + border-width: 0; |
| 608 | + border-bottom-width: 1px; |
| 609 | +} |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -539,6 +539,7 @@ |
540 | 540 | background:#f3f3f3 !important; |
541 | 541 | font-size:1em; |
542 | 542 | } |
| 543 | +/* |
543 | 544 | .wikiEditor-ui .ui-widget-content .ui-state-default{ |
544 | 545 | background:#ffffff; |
545 | 546 | } |
— | — | @@ -548,3 +549,21 @@ |
549 | 550 | .wikiEditor-ui .ui-widget-content .ui-state-active{ |
550 | 551 | background:#f3f3f3; |
551 | 552 | } |
| 553 | +*/ |
| 554 | +.wikiEditor-ui .ui-tabs .wikiEditor-tab-edit{ |
| 555 | +padding:0; |
| 556 | +margin:0; |
| 557 | +} |
| 558 | +.wikiEditor-ui .ui-tabs-nav{ |
| 559 | +margin-bottom:0 !important; |
| 560 | +} |
| 561 | +.wikiEditor-ui .ui-tabs{ |
| 562 | +padding:0; |
| 563 | +} |
| 564 | +.wikiEditor-ui .ui-widget-content{ |
| 565 | +border-width:0; |
| 566 | +} |
| 567 | +.wikiEditor-ui .ui-widget-header{ |
| 568 | +border-width:0; |
| 569 | +border-bottom-width:1px; |
| 570 | +} |
Index: trunk/extensions/UsabilityInitiative/js/plugins/codepress/engines/engine.js |
— | — | @@ -1,574 +1,650 @@ |
2 | 2 | |
3 | 3 | gecko = false; |
4 | | -if($.browser.safari || $.browser.mozilla ){ |
| 4 | +if ( $.browser.safari || $.browser.mozilla ) { |
5 | 5 | gecko = true; |
6 | 6 | } |
7 | 7 | |
8 | 8 | WikiEditorEngine = { |
9 | | - scrolling : false, |
10 | | - autocomplete : true, |
| 9 | + scrolling : false, |
| 10 | + autocomplete : true, |
| 11 | + |
| 12 | + initialize : function() { |
| 13 | + if ( typeof ( editor ) == 'undefined' && !arguments[0] ) |
| 14 | + return; |
| 15 | + |
| 16 | + if ( gecko ) { |
| 17 | + body = document.getElementsByTagName( 'body' )[0]; |
| 18 | + body.innerHTML = body.innerHTML.replace( /\n/g, "" ); |
| 19 | + } |
| 20 | + |
| 21 | + chars = '|32|46|62|'; // charcodes that trigger syntax highlighting |
| 22 | + |
| 23 | + if ( gecko ) { |
| 24 | + chars += '8|'; |
| 25 | + } |
| 26 | + |
| 27 | + cc = '\u2009'; // carret char |
| 28 | + editorTag = 'pre'; |
| 29 | + if ( $.browser.opera ) { |
| 30 | + editorTag = 'body'; |
| 31 | + } |
| 32 | + editor = document.getElementsByTagName( editorTag )[0]; |
| 33 | + |
| 34 | + if ( $.browser.msie ) { |
| 35 | + editor.contentEditable = 'true'; |
| 36 | + document.getElementsByTagName( 'body' )[0].onfocus = function() { |
| 37 | + editor.focus(); |
| 38 | + } |
| 39 | + document.attachEvent( 'onkeydown', this.metaHandler ); |
| 40 | + document.attachEvent( 'onkeypress', this.keyHandler ); |
| 41 | + window.attachEvent( 'onscroll', function() { |
| 42 | + if ( !WikiEditorEngine.scrolling ) |
| 43 | + setTimeout( function() { |
| 44 | + WikiEditorEngine.syntaxHighlight( 'scroll' ) |
| 45 | + }, 1 ) |
| 46 | + } ); |
| 47 | + } else { // !$.browser.msie |
| 48 | + document.designMode = 'on'; |
| 49 | + if ( gecko ) { |
| 50 | + document.addEventListener( 'keypress', this.keyHandler, true ); |
| 51 | + } |
| 52 | + if ( $.browser.opera ) { |
| 53 | + document.addEventListener( 'keyup', this.keyHandler, true ); |
| 54 | + } |
| 55 | + window.addEventListener( 'scroll', function() { |
| 56 | + if ( !WikiEditorEngine.scrolling ) |
| 57 | + WikiEditorEngine.syntaxHighlight( 'scroll' ) |
| 58 | + }, false ); |
| 59 | + } |
| 60 | + |
| 61 | + completeChars = this.getCompleteChars(); |
| 62 | + if ( !$.browser.opera ) { |
| 63 | + completeEndingChars = this.getCompleteEndingChars(); |
| 64 | + } |
| 65 | + if ( $.browser.msie ) { |
| 66 | + setTimeout( function() { |
| 67 | + window.scroll( 0, 0 ) |
| 68 | + }, 50 ); // scroll IE to top |
| 69 | + } |
| 70 | + }, |
| 71 | + |
| 72 | + keyHandler : function( evt ) { |
| 73 | + if ( gecko ) { |
| 74 | + keyCode = evt.keyCode; |
| 75 | + charCode = evt.charCode; |
| 76 | + fromChar = String.fromCharCode( charCode ); |
| 77 | + |
| 78 | + if ( ( evt.ctrlKey || evt.metaKey ) && evt.shiftKey |
| 79 | + && charCode != 90 ) { // shortcuts = |
| 80 | + // ctrl||appleKey+shift+key!=z(undo) |
| 81 | + WikiEditorEngine.shortcuts( charCode ? charCode : keyCode ); |
| 82 | + } else if ( ( completeEndingChars.indexOf( '|' + fromChar + '|' ) != -1 || completeChars |
| 83 | + .indexOf( '|' + fromChar + '|' ) != -1 ) |
| 84 | + && WikiEditorEngine.autocomplete ) { // auto complete |
| 85 | + if ( !WikiEditorEngine.completeEnding( fromChar ) ) |
| 86 | + WikiEditorEngine.complete( fromChar ); |
| 87 | + } else if ( chars.indexOf( '|' + charCode + '|' ) != -1 |
| 88 | + || keyCode == 13 ) { // syntax highlighting |
| 89 | + top.setTimeout( function() { |
| 90 | + WikiEditorEngine.syntaxHighlight( 'generic' ); |
| 91 | + }, 100 ); |
| 92 | + } else if ( keyCode == 9 || evt.tabKey ) { // snippets activation |
| 93 | + // (tab) |
| 94 | + WikiEditorEngine.snippets( evt ); |
| 95 | + } else if ( keyCode == 46 || keyCode == 8 ) { // save to history |
| 96 | + // when delete or |
| 97 | + // backspace pressed |
| 98 | + WikiEditorEngine.actions.history[WikiEditorEngine.actions |
| 99 | + .next()] = editor.innerHTML; |
| 100 | + } else if ( ( charCode == 122 || charCode == 121 || charCode == 90 ) |
| 101 | + && evt.ctrlKey ) { // undo and redo |
| 102 | + ( charCode == 121 || evt.shiftKey ) ? WikiEditorEngine.actions |
| 103 | + .redo() : WikiEditorEngine.actions.undo(); |
| 104 | + evt.preventDefault(); |
| 105 | + } else if ( charCode == 118 && evt.ctrlKey ) { // handle paste |
| 106 | + top.setTimeout( function() { |
| 107 | + WikiEditorEngine.syntaxHighlight( 'generic' ); |
| 108 | + }, 100 ); |
| 109 | + } else if ( charCode == 99 && evt.ctrlKey ) { // handle cut |
| 110 | + // alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF')); |
| 111 | + } |
| 112 | + |
| 113 | + } else if ( $.browser.opera ) { |
| 114 | + keyCode = evt.keyCode; |
| 115 | + charCode = evt.charCode; |
| 116 | + |
| 117 | + if ( ( evt.ctrlKey || evt.metaKey ) && evt.shiftKey |
| 118 | + && charCode != 90 ) { // shortcuts = |
| 119 | + // ctrl||appleKey+shift+key!=z(undo) |
| 120 | + WikiEditorEngine.shortcuts( charCode ? charCode : keyCode ); |
| 121 | + } else if ( completeChars.indexOf( '|' + String |
| 122 | + .fromCharCode( charCode ) + '|' ) != -1 |
| 123 | + && WikiEditorEngine.autocomplete ) { // auto complete |
| 124 | + WikiEditorEngine.complete( String.fromCharCode( charCode ) ); |
| 125 | + } else if ( chars.indexOf( '|' + charCode + '|' ) != -1 |
| 126 | + || keyCode == 13 ) { // syntax highlighting |
| 127 | + WikiEditorEngine.syntaxHighlight( 'generic' ); |
| 128 | + } else if ( keyCode == 9 || evt.tabKey ) { // snippets activation |
| 129 | + // (tab) |
| 130 | + WikiEditorEngine.snippets( evt ); |
| 131 | + } else if ( keyCode == 46 || keyCode == 8 ) { // save to history |
| 132 | + // when delete or |
| 133 | + // backspace pressed |
| 134 | + WikiEditorEngine.actions.history[WikiEditorEngine.actions |
| 135 | + .next()] = editor.innerHTML; |
| 136 | + } else if ( ( charCode == 122 || charCode == 121 || charCode == 90 ) |
| 137 | + && evt.ctrlKey ) { // undo and redo |
| 138 | + ( charCode == 121 || evt.shiftKey ) ? WikiEditorEngine.actions |
| 139 | + .redo() : WikiEditorEngine.actions.undo(); |
| 140 | + evt.preventDefault(); |
| 141 | + } else if ( keyCode == 86 && evt.ctrlKey ) { // paste |
| 142 | + // TODO: pasted text should be parsed and highlighted |
| 143 | + } |
| 144 | + } |
11 | 145 | |
12 | | - initialize : function() { |
13 | | - if(typeof(editor)=='undefined' && !arguments[0]) return; |
14 | | - |
15 | | - if(gecko){ |
16 | | - body = document.getElementsByTagName('body')[0]; |
17 | | - body.innerHTML = body.innerHTML.replace(/\n/g,""); |
18 | | - } |
19 | | - |
20 | | - chars = '|32|46|62|'; // charcodes that trigger syntax highlighting |
21 | | - |
22 | | - if(gecko){ |
23 | | - chars += '8|'; |
24 | | - } |
25 | | - |
26 | | - cc = '\u2009'; // carret char |
27 | | - editorTag = 'pre'; |
28 | | - if($.browser.opera){ |
29 | | - editorTag = 'body'; |
30 | | - } |
31 | | - editor = document.getElementsByTagName(editorTag)[0]; |
32 | | - |
33 | | - if($.browser.msie){ |
34 | | - editor.contentEditable = 'true'; |
35 | | - document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();} |
36 | | - document.attachEvent('onkeydown', this.metaHandler); |
37 | | - document.attachEvent('onkeypress', this.keyHandler); |
38 | | - window.attachEvent('onscroll', function() { if(!WikiEditorEngine.scrolling) setTimeout(function(){WikiEditorEngine.syntaxHighlight('scroll')},1)}); |
39 | | - } |
40 | | - else{ //!$.browser.msie |
41 | | - document.designMode = 'on'; |
42 | | - if(gecko){ |
43 | | - document.addEventListener('keypress', this.keyHandler, true); |
44 | | - } |
45 | | - if($.browser.opera){ |
46 | | - document.addEventListener('keyup', this.keyHandler, true); |
47 | | - } |
48 | | - window.addEventListener('scroll', function() { if(!WikiEditorEngine.scrolling) WikiEditorEngine.syntaxHighlight('scroll') }, false); |
49 | | - } |
50 | | - |
51 | | - completeChars = this.getCompleteChars(); |
52 | | - if(!$.browser.opera){ |
53 | | - completeEndingChars = this.getCompleteEndingChars(); |
54 | | - } |
55 | | - if($.browser.msie){ |
56 | | - setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top |
57 | | - } |
58 | | - }, |
59 | | - |
60 | | - keyHandler : function(evt) { |
61 | | - |
62 | | - if(gecko){ |
63 | | - keyCode = evt.keyCode; |
64 | | - charCode = evt.charCode; |
65 | | - fromChar = String.fromCharCode(charCode); |
66 | | - |
67 | | - if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) |
68 | | - WikiEditorEngine.shortcuts(charCode?charCode:keyCode); |
69 | | - } |
70 | | - else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && WikiEditorEngine.autocomplete) { // auto complete |
71 | | - if(!WikiEditorEngine.completeEnding(fromChar)) |
72 | | - WikiEditorEngine.complete(fromChar); |
73 | | - } |
74 | | - else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting |
75 | | - top.setTimeout(function(){WikiEditorEngine.syntaxHighlight('generic');},100); |
76 | | - } |
77 | | - else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) |
78 | | - WikiEditorEngine.snippets(evt); |
79 | | - } |
80 | | - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed |
81 | | - WikiEditorEngine.actions.history[WikiEditorEngine.actions.next()] = editor.innerHTML; |
82 | | - } |
83 | | - else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo |
84 | | - (charCode==121||evt.shiftKey) ? WikiEditorEngine.actions.redo() : WikiEditorEngine.actions.undo(); |
85 | | - evt.preventDefault(); |
86 | | - } |
87 | | - else if(charCode==118 && evt.ctrlKey) { // handle paste |
88 | | - top.setTimeout(function(){WikiEditorEngine.syntaxHighlight('generic');},100); |
89 | | - } |
90 | | - else if(charCode==99 && evt.ctrlKey) { // handle cut |
91 | | - //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF')); |
92 | | - } |
93 | | - |
94 | | - } |
95 | | - else if($.browser.opera){ |
96 | | - keyCode = evt.keyCode; |
97 | | - charCode = evt.charCode; |
98 | | - |
99 | | - if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) |
100 | | - WikiEditorEngine.shortcuts(charCode?charCode:keyCode); |
101 | | - } |
102 | | - else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && WikiEditorEngine.autocomplete) { // auto complete |
103 | | - WikiEditorEngine.complete(String.fromCharCode(charCode)); |
104 | | - } |
105 | | - else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting |
106 | | - WikiEditorEngine.syntaxHighlight('generic'); |
107 | | - } |
108 | | - else if(keyCode==9 || evt.tabKey) { // snippets activation (tab) |
109 | | - WikiEditorEngine.snippets(evt); |
110 | | - } |
111 | | - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed |
112 | | - WikiEditorEngine.actions.history[WikiEditorEngine.actions.next()] = editor.innerHTML; |
113 | | - } |
114 | | - else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo |
115 | | - (charCode==121||evt.shiftKey) ? WikiEditorEngine.actions.redo() : WikiEditorEngine.actions.undo(); |
116 | | - evt.preventDefault(); |
117 | | - } |
118 | | - else if(keyCode==86 && evt.ctrlKey) { // paste |
119 | | - // TODO: pasted text should be parsed and highlighted |
120 | | - } |
121 | | - } |
122 | | - |
123 | | - else if($.browser.msie){ |
124 | | - charCode = evt.keyCode; |
125 | | - fromChar = String.fromCharCode(charCode); |
126 | | - |
127 | | - if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1 )&& WikiEditorEngine.autocomplete) { // auto complete |
128 | | - if(!WikiEditorEngine.completeEnding(fromChar)) |
129 | | - WikiEditorEngine.complete(fromChar); |
130 | | - } |
131 | | - else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting |
132 | | - WikiEditorEngine.syntaxHighlight('generic'); |
133 | | - } |
134 | | - } |
135 | | - }, |
136 | | - |
137 | | - //IE SPECIFIC FN |
138 | | - metaHandler : function(evt) { |
139 | | - keyCode = evt.keyCode; |
140 | | - |
141 | | - if(keyCode==9 || evt.tabKey) { |
142 | | - WikiEditorEngine.snippets(); |
143 | | - } |
144 | | - else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo |
145 | | - (keyCode==121||evt.shiftKey) ? WikiEditorEngine.actions.redo() : WikiEditorEngine.actions.undo(); |
146 | | - evt.returnValue = false; |
147 | | - } |
148 | | - else if(keyCode==34||keyCode==33) { // handle page up/down for IE |
149 | | - self.scrollBy(0, (keyCode==34) ? 200 : -200); |
150 | | - evt.returnValue = false; |
151 | | - } |
152 | | - else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed |
153 | | - WikiEditorEngine.actions.history[WikiEditorEngine.actions.next()] = editor.innerHTML; |
154 | | - } |
155 | | - else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90) { // shortcuts = ctrl||appleKey+shift+key!=z(undo) |
156 | | - WikiEditorEngine.shortcuts(keyCode); |
157 | | - evt.returnValue = false; |
158 | | - } |
159 | | - else if(keyCode==86 && evt.ctrlKey) { // handle paste |
160 | | - window.clipboardData.setData('Text',window.clipboardData.getData('Text').replace(/\t/g,'\u2008')); |
161 | | - top.setTimeout(function(){WikiEditorEngine.syntaxHighlight('paste');},10); |
162 | | - } |
163 | | - else if(keyCode==67 && evt.ctrlKey) { // handle cut |
164 | | - // window.clipboardData.setData('Text',x[0]); |
165 | | - // code = window.clipboardData.getData('Text'); |
166 | | - } |
167 | | - }, |
168 | | - |
169 | | - // put cursor back to its original position after every parsing |
170 | | - findString : function() { |
171 | | - if(gecko){ |
172 | | - if(self.find(cc)) |
173 | | - window.getSelection().getRangeAt(0).deleteContents(); |
174 | | - } |
175 | | - else if($.browser.opera) { |
176 | | - var sel = window.getSelection(); |
177 | | - var range = window.document.createRange(); |
178 | | - var span = window.document.getElementsByTagName('span')[0]; |
179 | | - |
180 | | - range.selectNode(span); |
181 | | - sel.removeAllRanges(); |
182 | | - sel.addRange(range); |
183 | | - span.parentNode.removeChild(span); |
184 | | - //if(self.find(cc)) |
185 | | - //window.getSelection().getRangeAt(0).deleteContents(); |
186 | | - } |
187 | | - else if($.browser.msie){ |
188 | | - range = self.document.body.createTextRange(); |
189 | | - if(range.findText(cc)){ |
190 | | - range.select(); |
191 | | - range.text = ''; |
192 | | - } |
193 | | - } |
194 | | - }, |
195 | | - |
196 | | - // split big files, highlighting parts of it |
197 | | - split : function(code,flag) { |
198 | | - if(gecko){ |
199 | | - if(flag=='scroll') { |
200 | | - this.scrolling = true; |
201 | | - return code; |
202 | | - } |
203 | | - else { |
204 | | - this.scrolling = false; |
205 | | - mid = code.indexOf(cc); |
206 | | - if(mid-2000<0) {ini=0;end=4000;} |
207 | | - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} |
208 | | - else {ini=mid-2000;end=mid+2000;} |
209 | | - code = code.substring(ini,end); |
210 | | - return code; |
211 | | - } |
212 | | - } |
213 | | - else if($.browser.opera){ |
214 | | - if(flag=='scroll') { |
215 | | - this.scrolling = true; |
216 | | - return code; |
217 | | - } |
218 | | - else { |
219 | | - this.scrolling = false; |
220 | | - mid = code.indexOf('<SPAN>'); |
221 | | - if(mid-2000<0) {ini=0;end=4000;} |
222 | | - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} |
223 | | - else {ini=mid-2000;end=mid+2000;} |
224 | | - code = code.substring(ini,end); |
225 | | - return code; |
226 | | - } |
227 | | - } |
228 | | - else if($.browser.msie){ |
229 | | - if(flag=='scroll') { |
230 | | - this.scrolling = true; |
231 | | - return code; |
232 | | - } |
233 | | - else { |
234 | | - this.scrolling = false; |
235 | | - mid = code.indexOf(cc); |
236 | | - if(mid-2000<0) {ini=0;end=4000;} |
237 | | - else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;} |
238 | | - else {ini=mid-2000;end=mid+2000;} |
239 | | - code = code.substring(ini,end); |
240 | | - return code.substring(code.indexOf('<P>'),code.lastIndexOf('</P>')+4); |
241 | | - } |
242 | | - } |
243 | | - }, |
244 | | - |
245 | | -//GECKO SPECIFIC |
246 | | - getEditor : function() { |
247 | | - if(!document.getElementsByTagName('pre')[0]) { |
248 | | - body = document.getElementsByTagName('body')[0]; |
249 | | - if(!body.innerHTML) return body; |
250 | | - if(body.innerHTML=="<br>") body.innerHTML = "<pre> </pre>"; |
251 | | - else body.innerHTML = "<pre>"+body.innerHTML+"</pre>"; |
252 | | - } |
253 | | - return document.getElementsByTagName('pre')[0]; |
254 | | - }, |
255 | | - |
256 | | - |
257 | | - |
258 | | - // syntax highlighting parser |
259 | | - syntaxHighlight : function(flag) { |
260 | | - if(gecko){ |
261 | | - if(flag != 'init') { window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));} |
262 | | - editor = WikiEditorEngine.getEditor(); |
263 | | - o = editor.innerHTML; |
264 | | - o = o.replace(/<br>/g,'\n'); |
265 | | - o = o.replace(/<.*?>/g,''); |
266 | | - x = z = this.split(o,flag); |
267 | | - x = x.replace(/\n/g,'<br>'); |
268 | | - |
269 | | - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); |
270 | | - |
271 | | - for(i=0;i<Language.syntax.length;i++) |
272 | | - x = x.replace(Language.syntax[i].input,Language.syntax[i].output); |
273 | | - |
274 | | - editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.split(z).join(x); |
275 | | - if(flag!='init') this.findString(); |
276 | | - } |
277 | | - else if($.browser.opera){ |
278 | | - if(flag!='init') { |
279 | | - var span = document.createElement('span'); |
280 | | - window.getSelection().getRangeAt(0).insertNode(span); |
281 | | - } |
282 | | - |
283 | | - o = editor.innerHTML; |
284 | | - |
285 | | - o = o.replace(/<(?!span|\/span|br).*?>/gi,''); |
286 | | - x = z = this.split(o,flag); |
287 | | - x = x.replace(/\t/g, ' '); |
288 | | - |
289 | | - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); |
290 | | - |
291 | | - for(i=0;i<Language.syntax.length;i++) |
292 | | - x = x.replace(Language.syntax[i].input,Language.syntax[i].output); |
293 | | - |
294 | | - editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.split(z).join(x); |
295 | | - |
296 | | - if(flag!='init') this.findString(); |
297 | | - } |
298 | | - else if($.browser.msie){ |
299 | | - if(flag!='init') document.selection.createRange().text = cc; |
300 | | - o = editor.innerHTML; |
301 | | - if(flag=='paste') { // fix pasted text |
302 | | - o = o.replace(/<BR>/g,'\r\n'); |
303 | | - o = o.replace(/\u2008/g,'\t'); |
304 | | - } |
305 | | - o = o.replace(/<P>/g,'\n'); |
306 | | - o = o.replace(/<\/P>/g,'\r'); |
307 | | - o = o.replace(/<.*?>/g,''); |
308 | | - o = o.replace(/ /g,''); |
309 | | - o = '<PRE><P>'+o+'</P></PRE>'; |
310 | | - o = o.replace(/\n\r/g,'<P></P>'); |
311 | | - o = o.replace(/\n/g,'<P>'); |
312 | | - o = o.replace(/\r/g,'<\/P>'); |
313 | | - o = o.replace(/<P>(<P>)+/,'<P>'); |
314 | | - o = o.replace(/<\/P>(<\/P>)+/,'</P>'); |
315 | | - o = o.replace(/<P><\/P>/g,'<P><BR/></P>'); |
316 | | - x = z = this.split(o,flag); |
317 | | - |
318 | | - if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]); |
319 | | - |
320 | | - for(i=0;i<Language.syntax.length;i++) |
321 | | - x = x.replace(Language.syntax[i].input,Language.syntax[i].output); |
322 | | - |
323 | | - editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.replace(z,x); |
324 | | - if(flag!='init') this.findString(); |
325 | | - } |
326 | | - }, |
327 | | - |
328 | | - getLastWord : function() { |
329 | | - var rangeAndCaret = WikiEditorEngine.getRangeAndCaret(); |
330 | | - words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]); |
331 | | - words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n'); |
332 | | - return words[words.length-1].replace(/[\W]/gi,'').toLowerCase(); |
333 | | - }, |
334 | | - |
335 | | - |
336 | | - snippets : function(evt) { |
337 | | - var snippets = Language.snippets; |
338 | | - var trigger = this.getLastWord(); |
339 | | - for (var i=0; i<snippets.length; i++) { |
340 | | - if(snippets[i].input == trigger) { |
341 | | - var content = snippets[i].output.replace(/</g,'<'); |
342 | | - content = content.replace(/>/g,'>'); |
343 | | - if(content.indexOf('$0')<0) content += cc; |
344 | | - else content = content.replace(/\$0/,cc); |
345 | | - content = content.replace(/\n/g,'<br>'); |
346 | | - var pattern = new RegExp(trigger+cc,'gi'); |
347 | | - if(!$.browser.msie){ |
348 | | - evt.preventDefault(); // prevent the tab key from being added |
349 | | - } |
350 | | - this.syntaxHighlight('snippets',pattern,content); |
351 | | - } |
352 | | - } |
353 | | - }, |
354 | | - |
355 | | - readOnly : function() { |
356 | | - if($.browser.msie){ |
357 | | - editor.contentEditable = (arguments[0]) ? 'false' : 'true'; |
358 | | - } |
359 | | - else if (gecko || $.browser.opera){ |
360 | | - document.designMode = (arguments[0]) ? 'off' : 'on'; |
361 | | - } |
362 | | - }, |
363 | | - |
364 | | - |
365 | | - complete : function(trigger) { |
366 | | - window.getSelection().getRangeAt(0).deleteContents(); |
367 | | - var complete = Language.complete; |
368 | | - for (var i=0; i<complete.length; i++) { |
369 | | - if(complete[i].input == trigger) { |
370 | | - var pattern = new RegExp('\\'+trigger+cc); |
371 | | - var content = complete[i].output.replace(/\$0/g,cc); |
372 | | - parent.setTimeout(function () { WikiEditorEngine.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen |
373 | | - } |
374 | | - } |
375 | | - }, |
376 | | - |
377 | | - getCompleteChars : function() { |
378 | | - var cChars = ''; |
379 | | - for(var i=0;i<Language.complete.length;i++) |
380 | | - cChars += '|'+Language.complete[i].input; |
381 | | - return cChars+'|'; |
382 | | - }, |
383 | | - |
384 | | - //not in Opera |
385 | | - getCompleteEndingChars : function() { |
386 | | - var cChars = ''; |
387 | | - for(var i=0;i<Language.complete.length;i++) |
388 | | - cChars += '|'+Language.complete[i].output.charAt(Language.complete[i].output.length-1); |
389 | | - return cChars+'|'; |
390 | | - }, |
391 | | - |
392 | | - |
393 | | -//also not in opera |
394 | | - completeEnding : function(trigger) { |
395 | | - if(gecko){ |
396 | | - var range = window.getSelection().getRangeAt(0); |
397 | | - try { |
398 | | - range.setEnd(range.endContainer, range.endOffset+1) |
399 | | - } |
400 | | - catch(e) { |
401 | | - return false; |
402 | | - } |
403 | | - var next_character = range.toString() |
404 | | - range.setEnd(range.endContainer, range.endOffset-1) |
405 | | - if(next_character != trigger) return false; |
406 | | - else { |
407 | | - range.setEnd(range.endContainer, range.endOffset+1) |
408 | | - range.deleteContents(); |
409 | | - return true; |
410 | | - } |
411 | | - } |
412 | | - else if($.browser.msie){ |
413 | | - var range = document.selection.createRange(); |
414 | | - try { |
415 | | - range.moveEnd('character', 1) |
416 | | - } |
417 | | - catch(e) { |
418 | | - return false; |
419 | | - } |
420 | | - var next_character = range.text |
421 | | - range.moveEnd('character', -1) |
422 | | - if(next_character != trigger ) return false; |
423 | | - else { |
424 | | - range.moveEnd('character', 1) |
425 | | - range.text='' |
426 | | - return true; |
427 | | - } |
428 | | - } |
429 | | - }, |
430 | | - |
431 | | - shortcuts : function() { |
432 | | - var cCode = arguments[0]; |
433 | | - if(cCode==13) cCode = '[enter]'; |
434 | | - else if(cCode==32) cCode = '[space]'; |
435 | | - else cCode = '['+String.fromCharCode(charCode).toLowerCase()+']'; |
436 | | - for(var i=0;i<Language.shortcuts.length;i++) |
437 | | - if(Language.shortcuts[i].input == cCode) |
438 | | - this.insertCode(Language.shortcuts[i].output,false); |
439 | | - }, |
440 | | - |
441 | | - getRangeAndCaret : function() { |
442 | | - if($.browser.msie){ |
443 | | - var range = document.selection.createRange(); |
444 | | - var caret = Math.abs(range.moveStart('character', -1000000)+1); |
445 | | - range = this.getCode(); |
446 | | - range = range.replace(/\n\r/gi,' '); |
447 | | - range = range.replace(/\n/gi,''); |
448 | | - return [range.toString(),caret]; |
449 | | - } |
450 | | - else if(!$.browser.msie){ |
451 | | - var range = window.getSelection().getRangeAt(0); |
452 | | - var range2 = range.cloneRange(); |
453 | | - var node = range.endContainer; |
454 | | - var caret = range.endOffset; |
455 | | - range2.selectNode(node); |
456 | | - return [range2.toString(),caret]; |
457 | | - } |
458 | | - }, |
459 | | - |
460 | | - insertCode : function(code,replaceCursorBefore) { |
461 | | - if($.browser.msie){ |
462 | | - var repdeb = ''; |
463 | | - var repfin = ''; |
464 | | - |
465 | | - if(replaceCursorBefore) { repfin = code; } |
466 | | - else { repdeb = code; } |
467 | | - |
468 | | - if(typeof document.selection != 'undefined') { |
469 | | - var range = document.selection.createRange(); |
470 | | - range.text = repdeb + repfin; |
471 | | - range = document.selection.createRange(); |
472 | | - range.move('character', -repfin.length); |
473 | | - range.select(); |
474 | | - } |
475 | | - } |
476 | | - else if(!$.browser.msie){ |
477 | | - var range = window.getSelection().getRangeAt(0); |
478 | | - var node = window.document.createTextNode(code); |
479 | | - var selct = window.getSelection(); |
480 | | - var range2 = range.cloneRange(); |
481 | | - // Insert text at cursor position |
482 | | - selct.removeAllRanges(); |
483 | | - range.deleteContents(); |
484 | | - range.insertNode(node); |
485 | | - // Move the cursor to the end of text |
486 | | - range2.selectNode(node); |
487 | | - range2.collapse(replaceCursorBefore); |
488 | | - selct.removeAllRanges(); |
489 | | - selct.addRange(range2); |
490 | | - } |
491 | | - }, |
492 | | - |
493 | | - getCode : function() { |
494 | | - if(gecko && !document.getElementsByTagName('pre')[0] || editor.innerHTML == '') |
495 | | - editor = WikiEditorEngine.getEditor(); |
496 | | - var code = editor.innerHTML; |
497 | | - code = code.replace(/<br>/g,'\n'); |
498 | | - code = code.replace(/\u2009/g,''); |
499 | | - code = code.replace(/<.*?>/g,''); |
500 | | - code = code.replace(/</g,'<'); |
501 | | - code = code.replace(/>/g,'>'); |
502 | | - code = code.replace(/&/gi,'&'); |
503 | | - |
504 | | - if($.browser.msie){ |
505 | | - code = code.replace(/<\/p>/gi,'\r'); |
506 | | - code = code.replace(/<p>/i,''); // IE first line fix |
507 | | - code = code.replace(/<p>/gi,'\n'); |
508 | | - code = code.replace(/ /gi,''); |
509 | | - } |
510 | | - return code; |
511 | | - }, |
512 | | - |
513 | | - setCode : function() { |
514 | | - var code = arguments[0]; |
515 | | - code = code.replace(/\u2009/gi,''); |
516 | | - code = code.replace(/&/gi,'&'); |
517 | | - code = code.replace(/</g,'<'); |
518 | | - code = code.replace(/>/g,'>'); |
519 | | - if($.browser.msie){ |
520 | | - editor.innerHTML = '<pre>'+code+'</pre>';} |
521 | | - else if (!$.browser.msie){ |
522 | | - editor.innerHTML = code; |
| 146 | + else if ( $.browser.msie ) { |
| 147 | + charCode = evt.keyCode; |
| 148 | + fromChar = String.fromCharCode( charCode ); |
| 149 | + |
| 150 | + if ( ( completeEndingChars.indexOf( '|' + fromChar + '|' ) != -1 || completeChars |
| 151 | + .indexOf( '|' + fromChar + '|' ) != -1 ) |
| 152 | + && WikiEditorEngine.autocomplete ) { // auto complete |
| 153 | + if ( !WikiEditorEngine.completeEnding( fromChar ) ) |
| 154 | + WikiEditorEngine.complete( fromChar ); |
| 155 | + } else if ( chars.indexOf( '|' + charCode + '|' ) != -1 |
| 156 | + || charCode == 13 ) { // syntax highlighting |
| 157 | + WikiEditorEngine.syntaxHighlight( 'generic' ); |
| 158 | + } |
| 159 | + } |
| 160 | + }, |
| 161 | + |
| 162 | + // IE SPECIFIC FN |
| 163 | + metaHandler : function( evt ) { |
| 164 | + keyCode = evt.keyCode; |
| 165 | + |
| 166 | + if ( keyCode == 9 || evt.tabKey ) { |
| 167 | + WikiEditorEngine.snippets(); |
| 168 | + } else if ( ( keyCode == 122 || keyCode == 121 || keyCode == 90 ) |
| 169 | + && evt.ctrlKey ) { // undo and redo |
| 170 | + ( keyCode == 121 || evt.shiftKey ) ? WikiEditorEngine.actions |
| 171 | + .redo() : WikiEditorEngine.actions.undo(); |
| 172 | + evt.returnValue = false; |
| 173 | + } else if ( keyCode == 34 || keyCode == 33 ) { // handle page up/down |
| 174 | + // for IE |
| 175 | + self.scrollBy( 0, ( keyCode == 34 ) ? 200 : -200 ); |
| 176 | + evt.returnValue = false; |
| 177 | + } else if ( keyCode == 46 || keyCode == 8 ) { // save to history when |
| 178 | + // delete or backspace |
| 179 | + // pressed |
| 180 | + WikiEditorEngine.actions.history[WikiEditorEngine.actions.next()] = editor.innerHTML; |
| 181 | + } else if ( ( evt.ctrlKey || evt.metaKey ) && evt.shiftKey |
| 182 | + && keyCode != 90 ) { // shortcuts = |
| 183 | + // ctrl||appleKey+shift+key!=z(undo) |
| 184 | + WikiEditorEngine.shortcuts( keyCode ); |
| 185 | + evt.returnValue = false; |
| 186 | + } else if ( keyCode == 86 && evt.ctrlKey ) { // handle paste |
| 187 | + window.clipboardData.setData( 'Text', window.clipboardData.getData( |
| 188 | + 'Text' ).replace( /\t/g, '\u2008' ) ); |
| 189 | + top.setTimeout( function() { |
| 190 | + WikiEditorEngine.syntaxHighlight( 'paste' ); |
| 191 | + }, 10 ); |
| 192 | + } else if ( keyCode == 67 && evt.ctrlKey ) { // handle cut |
| 193 | + // window.clipboardData.setData('Text',x[0]); |
| 194 | + // code = window.clipboardData.getData('Text'); |
| 195 | + } |
| 196 | + }, |
| 197 | + |
| 198 | + // put cursor back to its original position after every parsing |
| 199 | + findString : function() { |
| 200 | + if ( gecko ) { |
| 201 | + if ( self.find( cc ) ) |
| 202 | + window.getSelection().getRangeAt( 0 ).deleteContents(); |
| 203 | + } else if ( $.browser.opera ) { |
| 204 | + var sel = window.getSelection(); |
| 205 | + var range = window.document.createRange(); |
| 206 | + var span = window.document.getElementsByTagName( 'span' )[0]; |
| 207 | + |
| 208 | + range.selectNode( span ); |
| 209 | + sel.removeAllRanges(); |
| 210 | + sel.addRange( range ); |
| 211 | + span.parentNode.removeChild( span ); |
| 212 | + // if(self.find(cc)) |
| 213 | + // window.getSelection().getRangeAt(0).deleteContents(); |
| 214 | + } else if ( $.browser.msie ) { |
| 215 | + range = self.document.body.createTextRange(); |
| 216 | + if ( range.findText( cc ) ) { |
| 217 | + range.select(); |
| 218 | + range.text = ''; |
| 219 | + } |
| 220 | + } |
| 221 | + }, |
| 222 | + |
| 223 | + // split big files, highlighting parts of it |
| 224 | + split : function( code, flag ) { |
| 225 | + if ( gecko ) { |
| 226 | + if ( flag == 'scroll' ) { |
| 227 | + this.scrolling = true; |
| 228 | + return code; |
| 229 | + } else { |
| 230 | + this.scrolling = false; |
| 231 | + mid = code.indexOf( cc ); |
| 232 | + if ( mid - 2000 < 0 ) { |
| 233 | + ini = 0; |
| 234 | + end = 4000; |
| 235 | + } else if ( mid + 2000 > code.length ) { |
| 236 | + ini = code.length - 4000; |
| 237 | + end = code.length; |
| 238 | + } else { |
| 239 | + ini = mid - 2000; |
| 240 | + end = mid + 2000; |
| 241 | + } |
| 242 | + code = code.substring( ini, end ); |
| 243 | + return code; |
| 244 | + } |
| 245 | + } else if ( $.browser.opera ) { |
| 246 | + if ( flag == 'scroll' ) { |
| 247 | + this.scrolling = true; |
| 248 | + return code; |
| 249 | + } else { |
| 250 | + this.scrolling = false; |
| 251 | + mid = code.indexOf( '<SPAN>' ); |
| 252 | + if ( mid - 2000 < 0 ) { |
| 253 | + ini = 0; |
| 254 | + end = 4000; |
| 255 | + } else if ( mid + 2000 > code.length ) { |
| 256 | + ini = code.length - 4000; |
| 257 | + end = code.length; |
| 258 | + } else { |
| 259 | + ini = mid - 2000; |
| 260 | + end = mid + 2000; |
| 261 | + } |
| 262 | + code = code.substring( ini, end ); |
| 263 | + return code; |
| 264 | + } |
| 265 | + } else if ( $.browser.msie ) { |
| 266 | + if ( flag == 'scroll' ) { |
| 267 | + this.scrolling = true; |
| 268 | + return code; |
| 269 | + } else { |
| 270 | + this.scrolling = false; |
| 271 | + mid = code.indexOf( cc ); |
| 272 | + if ( mid - 2000 < 0 ) { |
| 273 | + ini = 0; |
| 274 | + end = 4000; |
| 275 | + } else if ( mid + 2000 > code.length ) { |
| 276 | + ini = code.length - 4000; |
| 277 | + end = code.length; |
| 278 | + } else { |
| 279 | + ini = mid - 2000; |
| 280 | + end = mid + 2000; |
| 281 | + } |
| 282 | + code = code.substring( ini, end ); |
| 283 | + return code.substring( code.indexOf( '<P>' ), code |
| 284 | + .lastIndexOf( '</P>' ) + 4 ); |
| 285 | + } |
| 286 | + } |
| 287 | + }, |
| 288 | + |
| 289 | + // GECKO SPECIFIC |
| 290 | + getEditor : function() { |
| 291 | + if ( !document.getElementsByTagName( 'pre' )[0] ) { |
| 292 | + body = document.getElementsByTagName( 'body' )[0]; |
| 293 | + if ( !body.innerHTML ) |
| 294 | + return body; |
| 295 | + if ( body.innerHTML == "<br>" ) |
| 296 | + body.innerHTML = "<pre> </pre>"; |
| 297 | + else |
| 298 | + body.innerHTML = "<pre>" + body.innerHTML + "</pre>"; |
| 299 | + } |
| 300 | + return document.getElementsByTagName( 'pre' )[0]; |
| 301 | + }, |
| 302 | + |
| 303 | + // syntax highlighting parser |
| 304 | + syntaxHighlight : function( flag ) { |
| 305 | + if ( gecko ) { |
| 306 | + if ( flag != 'init' ) { |
| 307 | + window.getSelection().getRangeAt( 0 ).insertNode( |
| 308 | + document.createTextNode( cc ) ); |
| 309 | + } |
| 310 | + editor = WikiEditorEngine.getEditor(); |
| 311 | + o = editor.innerHTML; |
| 312 | + o = o.replace( /<br>/g, '\n' ); |
| 313 | + o = o.replace( /<.*?>/g, '' ); |
| 314 | + x = z = this.split( o, flag ); |
| 315 | + x = x.replace( /\n/g, '<br>' ); |
| 316 | + |
| 317 | + if ( arguments[1] && arguments[2] ) |
| 318 | + x = x.replace( arguments[1], arguments[2] ); |
| 319 | + |
| 320 | + for ( i = 0; i < Language.syntax.length; i++ ) |
| 321 | + x = x.replace( Language.syntax[i].input, |
| 322 | + Language.syntax[i].output ); |
| 323 | + |
| 324 | + editor.innerHTML = this.actions.history[this.actions.next()] = ( flag == 'scroll' ) ? x |
| 325 | + : o.split( z ).join( x ); |
| 326 | + if ( flag != 'init' ) |
| 327 | + this.findString(); |
| 328 | + } else if ( $.browser.opera ) { |
| 329 | + if ( flag != 'init' ) { |
| 330 | + var span = document.createElement( 'span' ); |
| 331 | + window.getSelection().getRangeAt( 0 ).insertNode( span ); |
| 332 | + } |
| 333 | + |
| 334 | + o = editor.innerHTML; |
| 335 | + |
| 336 | + o = o.replace( /<(?!span|\/span|br).*?>/gi, '' ); |
| 337 | + x = z = this.split( o, flag ); |
| 338 | + x = x.replace( /\t/g, ' ' ); |
| 339 | + |
| 340 | + if ( arguments[1] && arguments[2] ) |
| 341 | + x = x.replace( arguments[1], arguments[2] ); |
| 342 | + |
| 343 | + for ( i = 0; i < Language.syntax.length; i++ ) |
| 344 | + x = x.replace( Language.syntax[i].input, |
| 345 | + Language.syntax[i].output ); |
| 346 | + |
| 347 | + editor.innerHTML = this.actions.history[this.actions.next()] = ( flag == 'scroll' ) ? x |
| 348 | + : o.split( z ).join( x ); |
| 349 | + |
| 350 | + if ( flag != 'init' ) |
| 351 | + this.findString(); |
| 352 | + } else if ( $.browser.msie ) { |
| 353 | + if ( flag != 'init' ) |
| 354 | + document.selection.createRange().text = cc; |
| 355 | + o = editor.innerHTML; |
| 356 | + if ( flag == 'paste' ) { // fix pasted text |
| 357 | + o = o.replace( /<BR>/g, '\r\n' ); |
| 358 | + o = o.replace( /\u2008/g, '\t' ); |
| 359 | + } |
| 360 | + o = o.replace( /<P>/g, '\n' ); |
| 361 | + o = o.replace( /<\/P>/g, '\r' ); |
| 362 | + o = o.replace( /<.*?>/g, '' ); |
| 363 | + o = o.replace( / /g, '' ); |
| 364 | + o = '<PRE><P>' + o + '</P></PRE>'; |
| 365 | + o = o.replace( /\n\r/g, '<P></P>' ); |
| 366 | + o = o.replace( /\n/g, '<P>' ); |
| 367 | + o = o.replace( /\r/g, '<\/P>' ); |
| 368 | + o = o.replace( /<P>(<P>)+/, '<P>' ); |
| 369 | + o = o.replace( /<\/P>(<\/P>)+/, '</P>' ); |
| 370 | + o = o.replace( /<P><\/P>/g, '<P><BR/></P>' ); |
| 371 | + x = z = this.split( o, flag ); |
| 372 | + |
| 373 | + if ( arguments[1] && arguments[2] ) |
| 374 | + x = x.replace( arguments[1], arguments[2] ); |
| 375 | + |
| 376 | + for ( i = 0; i < Language.syntax.length; i++ ) |
| 377 | + x = x.replace( Language.syntax[i].input, |
| 378 | + Language.syntax[i].output ); |
| 379 | + |
| 380 | + editor.innerHTML = this.actions.history[this.actions.next()] = ( flag == 'scroll' ) ? x |
| 381 | + : o.replace( z, x ); |
| 382 | + if ( flag != 'init' ) |
| 383 | + this.findString(); |
| 384 | + } |
| 385 | + }, |
| 386 | + |
| 387 | + getLastWord : function() { |
| 388 | + var rangeAndCaret = WikiEditorEngine.getRangeAndCaret(); |
| 389 | + words = rangeAndCaret[0].substring( rangeAndCaret[1] - 40, |
| 390 | + rangeAndCaret[1] ); |
| 391 | + words = words.replace( /[\s\n\r\);\W]/g, '\n' ).split( '\n' ); |
| 392 | + return words[words.length - 1].replace( /[\W]/gi, '' ).toLowerCase(); |
| 393 | + }, |
| 394 | + |
| 395 | + snippets : function( evt ) { |
| 396 | + var snippets = Language.snippets; |
| 397 | + var trigger = this.getLastWord(); |
| 398 | + for ( var i = 0; i < snippets.length; i++ ) { |
| 399 | + if ( snippets[i].input == trigger ) { |
| 400 | + var content = snippets[i].output.replace( /</g, '<' ); |
| 401 | + content = content.replace( />/g, '>' ); |
| 402 | + if ( content.indexOf( '$0' ) < 0 ) |
| 403 | + content += cc; |
| 404 | + else |
| 405 | + content = content.replace( /\$0/, cc ); |
| 406 | + content = content.replace( /\n/g, '<br>' ); |
| 407 | + var pattern = new RegExp( trigger + cc, 'gi' ); |
| 408 | + if ( !$.browser.msie ) { |
| 409 | + evt.preventDefault(); // prevent the tab key from being |
| 410 | + // added |
| 411 | + } |
| 412 | + this.syntaxHighlight( 'snippets', pattern, content ); |
| 413 | + } |
| 414 | + } |
| 415 | + }, |
| 416 | + |
| 417 | + readOnly : function() { |
| 418 | + if ( $.browser.msie ) { |
| 419 | + editor.contentEditable = ( arguments[0] ) ? 'false' : 'true'; |
| 420 | + } else if ( gecko || $.browser.opera ) { |
| 421 | + document.designMode = ( arguments[0] ) ? 'off' : 'on'; |
| 422 | + } |
| 423 | + }, |
| 424 | + |
| 425 | + complete : function( trigger ) { |
| 426 | + window.getSelection().getRangeAt( 0 ).deleteContents(); |
| 427 | + var complete = Language.complete; |
| 428 | + for ( var i = 0; i < complete.length; i++ ) { |
| 429 | + if ( complete[i].input == trigger ) { |
| 430 | + var pattern = new RegExp( '\\' + trigger + cc ); |
| 431 | + var content = complete[i].output.replace( /\$0/g, cc ); |
| 432 | + parent.setTimeout( function() { |
| 433 | + WikiEditorEngine.syntaxHighlight( 'complete', pattern, |
| 434 | + content ) |
| 435 | + }, 0 ); // wait for char to appear on screen |
| 436 | + } |
| 437 | + } |
| 438 | + }, |
| 439 | + |
| 440 | + getCompleteChars : function() { |
| 441 | + var cChars = ''; |
| 442 | + for ( var i = 0; i < Language.complete.length; i++ ) |
| 443 | + cChars += '|' + Language.complete[i].input; |
| 444 | + return cChars + '|'; |
| 445 | + }, |
| 446 | + |
| 447 | + // not in Opera |
| 448 | + getCompleteEndingChars : function() { |
| 449 | + var cChars = ''; |
| 450 | + for ( var i = 0; i < Language.complete.length; i++ ) |
| 451 | + cChars += '|' + Language.complete[i].output |
| 452 | + .charAt( Language.complete[i].output.length - 1 ); |
| 453 | + return cChars + '|'; |
| 454 | + }, |
| 455 | + |
| 456 | + // also not in opera |
| 457 | + completeEnding : function( trigger ) { |
| 458 | + if ( gecko ) { |
| 459 | + var range = window.getSelection().getRangeAt( 0 ); |
| 460 | + try { |
| 461 | + range.setEnd( range.endContainer, range.endOffset + 1 ) |
| 462 | + } catch ( e ) { |
| 463 | + return false; |
| 464 | + } |
| 465 | + var next_character = range.toString() |
| 466 | + range.setEnd( range.endContainer, range.endOffset - 1 ) |
| 467 | + if ( next_character != trigger ) |
| 468 | + return false; |
| 469 | + else { |
| 470 | + range.setEnd( range.endContainer, range.endOffset + 1 ) |
| 471 | + range.deleteContents(); |
| 472 | + return true; |
| 473 | + } |
| 474 | + } else if ( $.browser.msie ) { |
| 475 | + var range = document.selection.createRange(); |
| 476 | + try { |
| 477 | + range.moveEnd( 'character', 1 ) |
| 478 | + } catch ( e ) { |
| 479 | + return false; |
| 480 | + } |
| 481 | + var next_character = range.text |
| 482 | + range.moveEnd( 'character', -1 ) |
| 483 | + if ( next_character != trigger ) |
| 484 | + return false; |
| 485 | + else { |
| 486 | + range.moveEnd( 'character', 1 ) |
| 487 | + range.text = '' |
| 488 | + return true; |
| 489 | + } |
| 490 | + } |
| 491 | + }, |
| 492 | + |
| 493 | + shortcuts : function() { |
| 494 | + var cCode = arguments[0]; |
| 495 | + if ( cCode == 13 ) |
| 496 | + cCode = '[enter]'; |
| 497 | + else if ( cCode == 32 ) |
| 498 | + cCode = '[space]'; |
| 499 | + else |
| 500 | + cCode = '[' + String.fromCharCode( charCode ).toLowerCase() + ']'; |
| 501 | + for ( var i = 0; i < Language.shortcuts.length; i++ ) |
| 502 | + if ( Language.shortcuts[i].input == cCode ) |
| 503 | + this.insertCode( Language.shortcuts[i].output, false ); |
| 504 | + }, |
| 505 | + |
| 506 | + getRangeAndCaret : function() { |
| 507 | + if ( $.browser.msie ) { |
| 508 | + var range = document.selection.createRange(); |
| 509 | + var caret = Math.abs( range.moveStart( 'character', -1000000 ) + 1 ); |
| 510 | + range = this.getCode(); |
| 511 | + range = range.replace( /\n\r/gi, ' ' ); |
| 512 | + range = range.replace( /\n/gi, '' ); |
| 513 | + return [ range.toString(), caret ]; |
| 514 | + } else if ( !$.browser.msie ) { |
| 515 | + var range = window.getSelection().getRangeAt( 0 ); |
| 516 | + var range2 = range.cloneRange(); |
| 517 | + var node = range.endContainer; |
| 518 | + var caret = range.endOffset; |
| 519 | + range2.selectNode( node ); |
| 520 | + return [ range2.toString(), caret ]; |
| 521 | + } |
| 522 | + }, |
| 523 | + |
| 524 | + insertCode : function( code, replaceCursorBefore ) { |
| 525 | + if ( $.browser.msie ) { |
| 526 | + var repdeb = ''; |
| 527 | + var repfin = ''; |
| 528 | + |
| 529 | + if ( replaceCursorBefore ) { |
| 530 | + repfin = code; |
| 531 | + } else { |
| 532 | + repdeb = code; |
| 533 | + } |
| 534 | + |
| 535 | + if ( typeof document.selection != 'undefined' ) { |
| 536 | + var range = document.selection.createRange(); |
| 537 | + range.text = repdeb + repfin; |
| 538 | + range = document.selection.createRange(); |
| 539 | + range.move( 'character', -repfin.length ); |
| 540 | + range.select(); |
| 541 | + } |
| 542 | + } else if ( !$.browser.msie ) { |
| 543 | + var range = window.getSelection().getRangeAt( 0 ); |
| 544 | + var node = window.document.createTextNode( code ); |
| 545 | + var selct = window.getSelection(); |
| 546 | + var range2 = range.cloneRange(); |
| 547 | + // Insert text at cursor position |
| 548 | + selct.removeAllRanges(); |
| 549 | + range.deleteContents(); |
| 550 | + range.insertNode( node ); |
| 551 | + // Move the cursor to the end of text |
| 552 | + range2.selectNode( node ); |
| 553 | + range2.collapse( replaceCursorBefore ); |
| 554 | + selct.removeAllRanges(); |
| 555 | + selct.addRange( range2 ); |
| 556 | + } |
| 557 | + }, |
| 558 | + |
| 559 | + getCode : function() { |
| 560 | + if ( gecko && !document.getElementsByTagName( 'pre' )[0] |
| 561 | + || editor.innerHTML == '' ) |
| 562 | + editor = WikiEditorEngine.getEditor(); |
| 563 | + var code = editor.innerHTML; |
| 564 | + code = code.replace( /<br>/g, '\n' ); |
| 565 | + code = code.replace( /\u2009/g, '' ); |
| 566 | + code = code.replace( /<.*?>/g, '' ); |
| 567 | + code = code.replace( /</g, '<' ); |
| 568 | + code = code.replace( />/g, '>' ); |
| 569 | + code = code.replace( /&/gi, '&' ); |
| 570 | + |
| 571 | + if ( $.browser.msie ) { |
| 572 | + code = code.replace( /<\/p>/gi, '\r' ); |
| 573 | + code = code.replace( /<p>/i, '' ); // IE first line fix |
| 574 | + code = code.replace( /<p>/gi, '\n' ); |
| 575 | + code = code.replace( / /gi, '' ); |
| 576 | + } |
| 577 | + return code; |
| 578 | + }, |
| 579 | + |
| 580 | + setCode : function() { |
| 581 | + var code = arguments[0]; |
| 582 | + code = code.replace( /\u2009/gi, '' ); |
| 583 | + code = code.replace( /&/gi, '&' ); |
| 584 | + code = code.replace( /</g, '<' ); |
| 585 | + code = code.replace( />/g, '>' ); |
| 586 | + if ( $.browser.msie ) { |
| 587 | + editor.innerHTML = '<pre>' + code + '</pre>'; |
| 588 | + } else if ( !$.browser.msie ) { |
| 589 | + editor.innerHTML = code; |
| 590 | + } |
| 591 | + if ( gecko && code == '' ) { |
| 592 | + document.getElementsByTagName( 'body' )[0].innerHTML = ''; |
| 593 | + } |
| 594 | + }, |
| 595 | + |
| 596 | + // g |
| 597 | + actions : { |
| 598 | + pos : -1, // actual history position |
| 599 | + history : [], // history vector |
| 600 | + |
| 601 | + undo : function() { |
| 602 | + if ( gecko ) { |
| 603 | + editor = WikiEditorEngine.getEditor(); |
| 604 | + } |
| 605 | + if ( editor.innerHTML.indexOf( cc ) == -1 ) { |
| 606 | + if ( opera || ( gecko && editor.innerHTML != " " ) ) |
| 607 | + window.getSelection().getRangeAt( 0 ).insertNode( |
| 608 | + document.createTextNode( cc ) ); |
| 609 | + if ( $.browser.msie ) { |
| 610 | + document.selection.createRange().text = cc; |
| 611 | + } |
| 612 | + this.history[this.pos] = editor.innerHTML; |
| 613 | + } |
| 614 | + this.pos--; |
| 615 | + if ( typeof ( this.history[this.pos] ) == 'undefined' ) |
| 616 | + this.pos++; // in gecko it was pos ++ with a space. necessary? |
| 617 | + editor.innerHTML = this.history[this.pos]; |
| 618 | + if ( gecko && editor.innerHTML.indexOf( cc ) > -1 ) |
| 619 | + editor.innerHTML += cc; |
| 620 | + WikiEditorEngine.findString(); |
| 621 | + }, |
| 622 | + |
| 623 | + redo : function() { |
| 624 | + // editor = WikiEditorEngine.getEditor(); |
| 625 | + this.pos++; |
| 626 | + if ( typeof ( this.history[this.pos] ) == 'undefined' ) |
| 627 | + this.pos--; |
| 628 | + editor.innerHTML = this.history[this.pos]; |
| 629 | + WikiEditorEngine.findString(); |
| 630 | + }, |
| 631 | + |
| 632 | + next : function() { // get next vector position and clean old ones |
| 633 | + if ( this.pos > 20 ) |
| 634 | + this.history[this.pos - 21] = undefined; |
| 635 | + return ++this.pos; |
523 | 636 | } |
524 | | - if (gecko && code == ''){ |
525 | | - document.getElementsByTagName('body')[0].innerHTML = ''; |
526 | | - } |
527 | | - }, |
528 | | - |
529 | | -//g |
530 | | - actions : { |
531 | | - pos : -1, // actual history position |
532 | | - history : [], // history vector |
533 | | - |
534 | | - undo : function() { |
535 | | - if(gecko){ |
536 | | - editor = WikiEditorEngine.getEditor(); |
537 | | - } |
538 | | - if(editor.innerHTML.indexOf(cc)==-1){ |
539 | | - if(opera || (gecko && editor.innerHTML != " ")) |
540 | | - window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc)); |
541 | | - if($.browser.msie){ |
542 | | - document.selection.createRange().text = cc; |
543 | | - } |
544 | | - this.history[this.pos] = editor.innerHTML; |
545 | | - } |
546 | | - this.pos --; |
547 | | - if(typeof(this.history[this.pos])=='undefined') this.pos++; //in gecko it was pos ++ with a space. necessary? |
548 | | - editor.innerHTML = this.history[this.pos]; |
549 | | - if(gecko && editor.innerHTML.indexOf(cc)>-1) editor.innerHTML+=cc; |
550 | | - WikiEditorEngine.findString(); |
551 | | - }, |
552 | | - |
553 | | - redo : function() { |
554 | | - // editor = WikiEditorEngine.getEditor(); |
555 | | - this.pos++; |
556 | | - if(typeof(this.history[this.pos])=='undefined') this.pos--; |
557 | | - editor.innerHTML = this.history[this.pos]; |
558 | | - WikiEditorEngine.findString(); |
559 | | - }, |
560 | | - |
561 | | - next : function() { // get next vector position and clean old ones |
562 | | - if(this.pos>20) this.history[this.pos-21] = undefined; |
563 | | - return ++this.pos; |
564 | | - } |
565 | | - } |
566 | | - |
567 | | -}//end WikiEditorEngine obj |
| 637 | + } |
568 | 638 | |
569 | | -Language={}; |
570 | | -if($.browser.msie){ |
571 | | - window.attachEvent('onload', function() { WikiEditorEngine.initialize('new');}); |
572 | 639 | } |
573 | | -else if(!$.browser.msie){ |
574 | | - window.addEventListener('load', function() { WikiEditorEngine.initialize('new'); }, true); |
| 640 | +// end WikiEditorEngine obj |
| 641 | + |
| 642 | +Language = {}; |
| 643 | +if ( $.browser.msie ) { |
| 644 | + window.attachEvent( 'onload', function() { |
| 645 | + WikiEditorEngine.initialize( 'new' ); |
| 646 | + } ); |
| 647 | +} else if ( !$.browser.msie ) { |
| 648 | + window.addEventListener( 'load', function() { |
| 649 | + WikiEditorEngine.initialize( 'new' ); |
| 650 | + }, true ); |
575 | 651 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.code.js |
— | — | @@ -40,6 +40,13 @@ |
41 | 41 | }; |
42 | 42 | // Make it happen! |
43 | 43 | $.wikiEditor.modules.code.fn.active( context, true ); |
| 44 | + |
| 45 | + // Before the form is submitted, if in iframe mode, we need to sync the textarea and the iframe |
| 46 | + context.$textarea.closest( 'form' ).submit( function() { |
| 47 | + if ( context.modules.code.editor.active ) { |
| 48 | + $.wikiEditor.modules.code.fn.active( context, false ); |
| 49 | + } |
| 50 | + } ); |
44 | 51 | }, |
45 | 52 | // Set config / get config |
46 | 53 | config: function( context, config ) { |
— | — | @@ -85,19 +92,32 @@ |
86 | 93 | if ( value !== undefined ) { |
87 | 94 | if ( value && !context.modules.code.editor.active ) { |
88 | 95 | context.$textarea.attr( 'disabled', true ); |
| 96 | + // We need to properly escape any HTML entities like &, < and > so they end up as visible |
| 97 | + // characters rather than actual HTML tags in the code editor container. |
89 | 98 | context.modules.code.editor.container.text( context.$textarea.val() ); |
90 | 99 | context.$textarea.hide(); |
91 | 100 | context.$iframe.show(); |
| 101 | + context.modules.code.editor.active = true; |
92 | 102 | } else if ( !value && context.modules.code.editor.active ) { |
93 | 103 | context.$textarea.attr( 'disabled', false ); |
94 | | - context.$textarea.val( context.modules.code.editor.container.text() ); |
| 104 | + // To properly decode the HTML entities, we set the HTML rather than the val of the textarea - also, all |
| 105 | + // of the text will have been properly escaped with HTML entities except the <br> tags which are in the |
| 106 | + // place of end line characters - so we just swap those out. |
| 107 | + context.$textarea.html( context.modules.code.editor.container.html().replace( /\<br\>/g, "\n" ) ); |
95 | 108 | context.$textarea.show(); |
96 | 109 | context.$iframe.hide(); |
| 110 | + context.modules.code.editor.active = false; |
97 | 111 | } |
98 | 112 | } else { |
99 | 113 | return context.modules.code.editor.active; |
100 | 114 | } |
101 | 115 | } |
| 116 | + getCaretPosition: function( context ) { |
| 117 | + |
| 118 | + } |
102 | 119 | } |
103 | 120 | |
104 | | -}; } ) ( jQuery ); |
\ No newline at end of file |
| 121 | +}; } ) ( jQuery ); |
| 122 | + |
| 123 | + |
| 124 | +$j( '#wpTextbox1' ).wikiEditor( 'caretPosition' ) |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -2639,6 +2639,13 @@ |
2640 | 2640 | }; |
2641 | 2641 | // Make it happen! |
2642 | 2642 | $.wikiEditor.modules.code.fn.active( context, true ); |
| 2643 | + |
| 2644 | + // Before the form is submitted, if in iframe mode, we need to sync the textarea and the iframe |
| 2645 | + context.$textarea.closest( 'form' ).submit( function() { |
| 2646 | + if ( context.modules.code.editor.active ) { |
| 2647 | + $.wikiEditor.modules.code.fn.active( context, false ); |
| 2648 | + } |
| 2649 | + } ); |
2643 | 2650 | }, |
2644 | 2651 | // Set config / get config |
2645 | 2652 | config: function( context, config ) { |
— | — | @@ -2684,22 +2691,35 @@ |
2685 | 2692 | if ( value !== undefined ) { |
2686 | 2693 | if ( value && !context.modules.code.editor.active ) { |
2687 | 2694 | context.$textarea.attr( 'disabled', true ); |
| 2695 | + // We need to properly escape any HTML entities like &, < and > so they end up as visible |
| 2696 | + // characters rather than actual HTML tags in the code editor container. |
2688 | 2697 | context.modules.code.editor.container.text( context.$textarea.val() ); |
2689 | 2698 | context.$textarea.hide(); |
2690 | 2699 | context.$iframe.show(); |
| 2700 | + context.modules.code.editor.active = true; |
2691 | 2701 | } else if ( !value && context.modules.code.editor.active ) { |
2692 | 2702 | context.$textarea.attr( 'disabled', false ); |
2693 | | - context.$textarea.val( context.modules.code.editor.container.text() ); |
| 2703 | + // To properly decode the HTML entities, we set the HTML rather than the val of the textarea - also, all |
| 2704 | + // of the text will have been properly escaped with HTML entities except the <br> tags which are in the |
| 2705 | + // place of end line characters - so we just swap those out. |
| 2706 | + context.$textarea.html( context.modules.code.editor.container.html().replace( /\<br\>/g, "\n" ) ); |
2694 | 2707 | context.$textarea.show(); |
2695 | 2708 | context.$iframe.hide(); |
| 2709 | + context.modules.code.editor.active = false; |
2696 | 2710 | } |
2697 | 2711 | } else { |
2698 | 2712 | return context.modules.code.editor.active; |
2699 | 2713 | } |
2700 | 2714 | } |
| 2715 | + getCaretPosition: function( context ) { |
| 2716 | + |
| 2717 | + } |
2701 | 2718 | } |
2702 | 2719 | |
2703 | | -}; } ) ( jQuery );/* Preview module for wikiEditor */ |
| 2720 | +}; } ) ( jQuery ); |
| 2721 | + |
| 2722 | + |
| 2723 | +$j( '#wpTextbox1' ).wikiEditor( 'caretPosition' )/* Preview module for wikiEditor */ |
2704 | 2724 | ( function( $ ) { $.wikiEditor.modules.preview = { |
2705 | 2725 | |
2706 | 2726 | /** |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -172,7 +172,9 @@ |
173 | 173 | outline[i].nLevel=nLevel;lastLevel=outline[i].level;} |
174 | 174 | var structure=buildStructure(outline);if($('input[name=wpSection]').val()==''){structure.unshift({'text':wgPageName.replace(/_/g,' '),'level':1,'index':0,'position':0});} |
175 | 175 | context.modules.$toc.html(buildList(structure));if(wgNavigableTOCResizable){context.modules.$toc.append(buildResizeControls());}else if(wgNavigableTOCCollapseEnable){context.modules.$toc.append(buildCollapseBar());} |
176 | | -context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.wikiEditor.modules.toc.defaults={width:"13em"}})(jQuery);(function($){$.wikiEditor.modules.code={api:{},fn:{create:function(context,config){context.$iframe=$('<iframe></iframe>').attr('frameborder',0).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none'}).insertAfter(context.$textarea);context.$iframe[0].contentWindow.document.open();context.$iframe[0].contentWindow.document.write('<html><head><title>wikiEditor</title></head><body style="margin:0;padding:0;width:100%;height:100%;">'+'<pre style="margin:0;padding:0;width:100%;height:100%;white-space:pre-wrap;"></pre></body></html>');context.$iframe[0].contentWindow.document.close();context.$iframe[0].contentWindow.document.designMode='on';context.modules.code={'editor':{'container':context.$iframe.contents().find('body > pre'),'active':false,'config':{}}};$.wikiEditor.modules.code.fn.active(context,true);},config:function(context,config){if(config!=undefined){$.extend(context.modules.code.editor.config,config);}else{return context.modules.code.editor.config;}},code:function(context,code){if(code!==undefined){context.modules.code.editor.active?context.modules.code.editor.container.text(code):context.$textarea.val(code);}else{context.modules.code.editor.active?context.modules.code.editor.container.text():context.$textarea.val();}},locked:function(context,value){if(value!==undefined){if(value){context.$textarea.attr('readonly',true);if(context.$iframe.css('display')!='none'){context.$iframe.attr('readonly',true);}}else{context.$textarea.attr('readonly',false);if(context.$iframe.css('display')!='none'){context.$iframe.attr('readonly',false);}}}else{return context.modules.code.editor.active?context.$iframe.attr('readonly'):context.$textarea.attr('readonly');}},active:function(context,value){if(value!==undefined){if(value&&!context.modules.code.editor.active){context.$textarea.attr('disabled',true);context.modules.code.editor.container.text(context.$textarea.val());context.$textarea.hide();context.$iframe.show();}else if(!value&&context.modules.code.editor.active){context.$textarea.attr('disabled',false);context.$textarea.val(context.modules.code.editor.container.text());context.$textarea.show();context.$iframe.hide();}}else{return context.modules.code.editor.active;}}}};})(jQuery);(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){mvJsLoader.doLoad(['$j.ui','$j.ui.tabs'],function(){if('preview'in context.modules) |
| 176 | +context.modules.$toc.find('div').autoEllipse({'position':'right','tooltip':true});context.data.outline=outline;}}};$.wikiEditor.modules.toc.defaults={width:"13em"}})(jQuery);(function($){$.wikiEditor.modules.code={api:{},fn:{create:function(context,config){context.$iframe=$('<iframe></iframe>').attr('frameborder',0).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none'}).insertAfter(context.$textarea);context.$iframe[0].contentWindow.document.open();context.$iframe[0].contentWindow.document.write('<html><head><title>wikiEditor</title></head><body style="margin:0;padding:0;width:100%;height:100%;">'+'<pre style="margin:0;padding:0;width:100%;height:100%;white-space:pre-wrap;"></pre></body></html>');context.$iframe[0].contentWindow.document.close();context.$iframe[0].contentWindow.document.designMode='on';context.modules.code={'editor':{'container':context.$iframe.contents().find('body > pre'),'active':false,'config':{}}};$.wikiEditor.modules.code.fn.active(context,true);context.$textarea.closest('form').submit(function(){if(context.modules.code.editor.active){$.wikiEditor.modules.code.fn.active(context,false);}});},config:function(context,config){if(config!=undefined){$.extend(context.modules.code.editor.config,config);}else{return context.modules.code.editor.config;}},code:function(context,code){if(code!==undefined){context.modules.code.editor.active?context.modules.code.editor.container.text(code):context.$textarea.val(code);}else{context.modules.code.editor.active?context.modules.code.editor.container.text():context.$textarea.val();}},locked:function(context,value){if(value!==undefined){if(value){context.$textarea.attr('readonly',true);if(context.$iframe.css('display')!='none'){context.$iframe.attr('readonly',true);}}else{context.$textarea.attr('readonly',false);if(context.$iframe.css('display')!='none'){context.$iframe.attr('readonly',false);}}}else{return context.modules.code.editor.active?context.$iframe.attr('readonly'):context.$textarea.attr('readonly');}},active:function(context,value){if(value!==undefined){if(value&&!context.modules.code.editor.active){context.$textarea.attr('disabled',true);context.modules.code.editor.container.text(context.$textarea.val());context.$textarea.hide();context.$iframe.show();context.modules.code.editor.active=true;}else if(!value&&context.modules.code.editor.active){context.$textarea.attr('disabled',false);context.$textarea.html(context.modules.code.editor.container.html().replace(/\<br\>/g,"\n"));context.$textarea.show();context.$iframe.hide();context.modules.code.editor.active=false;}}else{return context.modules.code.editor.active;}} |
| 177 | +getCaretPosition:function(context){}}};})(jQuery);$j('#wpTextbox1').wikiEditor('caretPosition') |
| 178 | +(function($){$.wikiEditor.modules.preview={api:{},fn:{create:function(context,config){mvJsLoader.doLoad(['$j.ui','$j.ui.tabs'],function(){if('preview'in context.modules) |
177 | 179 | return;context.$ui.wrapInner($j('<div />').addClass('wikiEditor-tab-edit').attr('id','wikiEditor-'+context.instance+'-tab-edit')).wrapInner($j('<div />').addClass('wikiEditor-tabs'));var tabList=context.$ui.children();var editTab=tabList.children();var loadingMsg=gM('sidebysidepreview-loading');var previewTab=$j('<div />').addClass('wikiEditor-tab-preview').attr('id','wikiEditor-'+context.instance+'-tab-preview').append($j('<div />').addClass('wikiEditor-preview-spinner').append($j('<img />').attr({'src':$j.wikiEditor.imgPath+'dialogs/loading.gif','alt':loadingMsg,'title':loadingMsg}))).append($j('<div />').addClass('wikiEditor-preview-contents')).insertAfter(editTab);tabList.append($j('<ul />').append($j('<li />').append($j('<a />').attr('href','#wikiEditor-'+context.instance+'-tab-edit').text(gM('sidebysidepreview-tab-edit')))).append($j('<li />').append($j('<a />').attr('href','#wikiEditor-'+context.instance+'-tab-preview').text(gM('sidebysidepreview-tab-preview'))))).append(editTab).append(previewTab);context.modules.preview={'editTab':editTab,'previewTab':previewTab,'tabList':tabList,'prevText':null};tabList.bind('tabsshow',function(){if(context.modules.preview.previewTab.is(':visible')) |
178 | 180 | $.wikiEditor.modules.preview.fn.showPreview(context);}).tabs();tabList.closest('.ui-tabs').removeClass('ui-widget');});},showPreview:function(context){var wikitext=context.$textarea.val();if(context.modules.preview.prevText==wikitext) |
179 | 181 | return;context.modules.preview.previewTab.children('.wikiEditor-preview-contents').empty();context.modules.preview.previewTab.children('.wikiEditor-preview-spinner').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(data.parse==undefined||data.parse.text==undefined||data.parse.text['*']==undefined) |