Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -21,17 +21,17 @@ |
22 | 22 | array( 'src' => 'css/suggestions.css', 'version' => 6 ), |
23 | 23 | array( 'src' => 'css/wikiEditor.css', 'version' => 7 ), |
24 | 24 | array( 'src' => 'css/wikiEditor.toolbar.css', 'version' => 8 ), |
25 | | - array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 8 ), |
| 25 | + array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 9 ), |
26 | 26 | array( 'src' => 'css/wikiEditor.toc.css', 'version' => 25 ), |
27 | 27 | array( 'src' => 'css/wikiEditor.preview.css', 'version' => 1 ), |
28 | 28 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
29 | 29 | ), |
30 | 30 | 'combined' => array( |
31 | | - array( 'src' => 'css/combined.css', 'version' => 39 ), |
| 31 | + array( 'src' => 'css/combined.css', 'version' => 40 ), |
32 | 32 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
33 | 33 | ), |
34 | 34 | 'minified' => array( |
35 | | - array( 'src' => 'css/combined.min.css', 'version' => 39 ), |
| 35 | + array( 'src' => 'css/combined.min.css', 'version' => 40 ), |
36 | 36 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
37 | 37 | ), |
38 | 38 | ) |
— | — | @@ -71,20 +71,20 @@ |
72 | 72 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 6 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 21 ), |
75 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 36 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 8 ), |
| 75 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 37 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 9 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 52 ), |
80 | 80 | array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 8 ), |
81 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 10 ), |
| 81 | + array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 11 ), |
82 | 82 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ), |
83 | 83 | ), |
84 | 84 | 'combined' => array( |
85 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 121 ), |
| 85 | + array( 'src' => 'js/plugins.combined.js', 'version' => 122 ), |
86 | 86 | ), |
87 | 87 | 'minified' => array( |
88 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 121 ), |
| 88 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 122 ), |
89 | 89 | ), |
90 | 90 | ), |
91 | 91 | ); |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -199,9 +199,6 @@ |
200 | 200 | margin: 0 !important; |
201 | 201 | } |
202 | 202 | .wikieditor-toolbar-table-preview-content * { |
203 | | - |
204 | | -} |
205 | | -.wikieditor-toolbar-table-preview-content *:hover { |
206 | 203 | cursor: default; |
207 | 204 | }/* wikiEditor toc module */ |
208 | 205 | .wikiEditor-ui-toc { |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -187,8 +187,6 @@ |
188 | 188 | margin:0 !important; |
189 | 189 | } |
190 | 190 | .wikieditor-toolbar-table-preview-content *{ |
191 | | -} |
192 | | -.wikieditor-toolbar-table-preview-content *:hover{ |
193 | 191 | cursor:default; |
194 | 192 | } |
195 | 193 | .wikiEditor-ui-toc{ |
— | — | @@ -746,4 +744,4 @@ |
747 | 745 | .wikiEditor-preview-contents{ |
748 | 746 | padding:1em; |
749 | 747 | background-color:white; |
750 | | -} |
| 748 | +} |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -140,13 +140,9 @@ |
141 | 141 | } |
142 | 142 | } |
143 | 143 | //sort by offset, or if offset same, sort by start |
144 | | - tokenArray.sort( function( a, b ) { |
145 | | - if( a.offset - b.offset == 0 ){ |
146 | | - return a.tokenStart- b.tokenStart; |
147 | | - } else { |
148 | | - return a.offset - b.offset; |
149 | | - } |
150 | | - } ); |
| 144 | + tokenArray.sort( function( a, b ) { |
| 145 | + return a.offset - b.offset || a.tokenStart - b.tokenStart; |
| 146 | + } ); |
151 | 147 | context.fn.trigger( 'scan' ); |
152 | 148 | }, |
153 | 149 | /** |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1700,7 +1700,7 @@ |
1701 | 1701 | |
1702 | 1702 | //get rid of the noincludes when getting text |
1703 | 1703 | var $dummyDiv = $( '<div />' ).html( context.$content.html().replace( /\<br\>/g, "\n" ) ); |
1704 | | - $dummyDiv.find( ".wikieditor-noinclude" ).each( function() { $( this ).remove(); } ); |
| 1704 | + $dummyDiv.find( ".wikiEditor-noinclude" ).each( function() { $( this ).remove(); } ); |
1705 | 1705 | return $dummyDiv.text(); |
1706 | 1706 | |
1707 | 1707 | }, |
— | — | @@ -2162,7 +2162,7 @@ |
2163 | 2163 | * ; Definition |
2164 | 2164 | * : Definition |
2165 | 2165 | */ |
2166 | | - if ( event.data.scope == 'keydown' ) { |
| 2166 | + if ( event.data.scope == 'none' ) { |
2167 | 2167 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
2168 | 2168 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
2169 | 2169 | } |
— | — | @@ -2231,9 +2231,10 @@ |
2232 | 2232 | * @param offset |
2233 | 2233 | * @param label |
2234 | 2234 | */ |
2235 | | - function Token( offset, label ) { |
| 2235 | + function Token( offset, label, tokenStart ) { |
2236 | 2236 | this.offset = offset; |
2237 | 2237 | this.label = label; |
| 2238 | + this.tokenStart = tokenStart; |
2238 | 2239 | } |
2239 | 2240 | // Reset tokens |
2240 | 2241 | var tokenArray = context.modules.highlight.tokenArray = []; |
— | — | @@ -2252,11 +2253,12 @@ |
2253 | 2254 | var oldOffset = 0; |
2254 | 2255 | while ( match != null ) { |
2255 | 2256 | var markOffset = 0; |
| 2257 | + var tokenStart = match.index + oldOffset + markOffset; |
2256 | 2258 | if ( markAfter ) { |
2257 | 2259 | markOffset += match[0].length; |
2258 | 2260 | } |
2259 | 2261 | tokenArray.push( |
2260 | | - new Token( match.index + oldOffset + markOffset, label ) |
| 2262 | + new Token( match.index + oldOffset + markOffset, label, tokenStart ) |
2261 | 2263 | ); |
2262 | 2264 | oldOffset += match.index + match[0].length; |
2263 | 2265 | newSubstring = text.substring( oldOffset ); |
— | — | @@ -2265,7 +2267,10 @@ |
2266 | 2268 | } |
2267 | 2269 | } |
2268 | 2270 | } |
2269 | | - tokenArray.sort( function( a, b ) { return a.offset - b.offset; } ); |
| 2271 | + //sort by offset, or if offset same, sort by start |
| 2272 | + tokenArray.sort( function( a, b ) { |
| 2273 | + return a.offset - b.offset || a.tokenStart - b.tokenStart; |
| 2274 | + } ); |
2270 | 2275 | context.fn.trigger( 'scan' ); |
2271 | 2276 | }, |
2272 | 2277 | /** |
— | — | @@ -2789,7 +2794,18 @@ |
2790 | 2795 | collapseTemplate( $visibleDiv ); |
2791 | 2796 | }); |
2792 | 2797 | }, |
| 2798 | + |
| 2799 | + |
2793 | 2800 | /** |
| 2801 | + * Gets templateInfo node from templateInfo extension, if it exists |
| 2802 | + */ |
| 2803 | + getTemplateInfo: function ( templateName ){ |
| 2804 | + var templateInfo = ''; |
| 2805 | + //API call here |
| 2806 | + return $( templateInfo ); |
| 2807 | + }, |
| 2808 | + |
| 2809 | + /** |
2794 | 2810 | * Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents |
2795 | 2811 | * of the template while preserving whitespace and formatting. |
2796 | 2812 | * |
— | — | @@ -2985,11 +3001,12 @@ |
2986 | 3002 | divider = sanatizedStr.length; |
2987 | 3003 | doneParsing = true; |
2988 | 3004 | } |
2989 | | - nameMatch = wikitext.substring( oldDivider, divider ).match( /[^{\s]+/ ); |
| 3005 | + nameMatch = wikitext.substring( 0, divider ).match( /[^{\s]+/ ); |
2990 | 3006 | if ( nameMatch != undefined ) { |
2991 | | - ranges.push( new Range( oldDivider,nameMatch.index ) ); //whitespace and squiggles upto the name |
| 3007 | + ranges.push( new Range( 0 ,nameMatch.index ) ); //whitespace and squiggles upto the name |
| 3008 | + nameEndMatch = sanatizedStr.substring( 0 , divider ).match( /[^\s]\s*$/ ); //last nonwhitespace character |
2992 | 3009 | templateNameIndex = ranges.push( new Range( nameMatch.index, |
2993 | | - nameMatch.index + nameMatch[0].length ) ); |
| 3010 | + nameEndMatch.index + 1 ) ); |
2994 | 3011 | templateNameIndex--; //push returns 1 less than the array |
2995 | 3012 | ranges[templateNameIndex].old = wikitext.substring( ranges[templateNameIndex].begin, |
2996 | 3013 | ranges[templateNameIndex].end ); |
— | — | @@ -3013,7 +3030,7 @@ |
3014 | 3031 | if ( currentField.indexOf( '=' ) == -1 ) { |
3015 | 3032 | // anonymous field, gets a number |
3016 | 3033 | valueBegin = currentField.match( /\S+/ ); //first nonwhitespace character |
3017 | | - valueBeginIndex = valueBegin.index + oldDivider + 1; |
| 3034 | + valueBeginIndex = valueBegin.index + oldDivider+1; |
3018 | 3035 | valueEnd = currentField.match( /[^\s]\s*$/ ); //last nonwhitespace character |
3019 | 3036 | valueEndIndex = valueEnd.index + oldDivider + 2; |
3020 | 3037 | ranges.push( new Range( ranges[ranges.length-1].end, |
— | — | @@ -3037,7 +3054,6 @@ |
3038 | 3055 | nameBegin = currentName.match( /\S+/ ); |
3039 | 3056 | if ( nameBegin == null ) { |
3040 | 3057 | // This is a comment inside a template call / parser abuse. let's not encourage it |
3041 | | - divider++; |
3042 | 3058 | currentParamNumber--; |
3043 | 3059 | continue; |
3044 | 3060 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | event.preventDefault();return false;}).text($.wikiEditor.autoMsg(options,'title'))).appendTo(context.$tabs);} |
102 | 102 | if(!context.$tabs.children().size()){addTab({'name':'wikitext','titleMsg':'wikieditor-wikitext-tab'});} |
103 | 103 | addTab(options);return $('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-'+options.name).hide().appendTo(context.$ui);},'getContents':function(){if($.browser.name=='msie'){return context.$content.text();} |
104 | | -var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br\>/g,"\n"));$dummyDiv.find(".wikieditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
| 104 | +var $dummyDiv=$('<div />').html(context.$content.html().replace(/\<br\>/g,"\n"));$dummyDiv.find(".wikiEditor-noinclude").each(function(){$(this).remove();});return $dummyDiv.text();},'setContents':function(options){context.$content.text(options.contents);return context.$textarea;},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();} |
105 | 105 | if(retval.text){retval=retval.text;}else if(retval.toString){retval=retval.toString();} |
106 | 106 | return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';} |
107 | 107 | var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0){pre="\n"+options.pre;} |
— | — | @@ -119,12 +119,12 @@ |
120 | 120 | configuration.newButtons[gM(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
121 | 121 | var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
122 | 122 | maxTI=ti;});var tabIndex=maxTI+1;$j('.ui-dialog input, .ui-dialog button').not('[tabindex]').each(function(){$j(this).attr('tabindex',tabIndex++);});}}});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
123 | | -$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':2},evt:{change:function(context,event){if(event.data.scope=='keydown'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){context.$content.parent().find('head').append($j('<link />').attr({'rel':'stylesheet','type':'text/css','href':wgScriptPath+'/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?'+ |
124 | | -$.wikiEditor.modules.highlight.cfg.styleVersion,}));$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label){this.offset=offset;this.label=label;} |
| 123 | +$(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={cfg:{'styleVersion':2},evt:{change:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){context.$content.parent().find('head').append($j('<link />').attr({'rel':'stylesheet','type':'text/css','href':wgScriptPath+'/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?'+ |
| 124 | +$.wikiEditor.modules.highlight.cfg.styleVersion,}));$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},fn:{create:function(context,config){},divide:function(context){},isolate:function(context){return[];},strip:function(context,division){return $('<div />').html(division.html().replace(/\<br[^\>]*\>/g,"\n")).text();},scan:function(context,division){function Token(offset,label,tokenStart){this.offset=offset;this.label=label;this.tokenStart=tokenStart;} |
125 | 125 | var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in $.wikiEditor.modules){if('exp'in $.wikiEditor.modules[module]){for(var i=0;i<$.wikiEditor.modules[module].exp.length;i++){var regex=$.wikiEditor.modules[module].exp[i].regex;var label=$.wikiEditor.modules[module].exp[i].label;var markAfter=false;if(typeof $.wikiEditor.modules[module].exp[i].markAfter!='undefined'){markAfter=true;} |
126 | | -match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;if(markAfter){markOffset+=match[0].length;} |
127 | | -tokenArray.push(new Token(match.index+oldOffset+markOffset,label));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |
128 | | -tokenArray.sort(function(a,b){return a.offset-b.offset;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var pos=0;var node=context.$content.get(0);var next=null;var i=0;var startNode=null;var depth=0,nextDepth=0,startDepth=null;while(node.firstChild){node=node.firstChild;depth++;} |
| 126 | +match=text.match(regex);var oldOffset=0;while(match!=null){var markOffset=0;var tokenStart=match.index+oldOffset+markOffset;if(markAfter){markOffset+=match[0].length;} |
| 127 | +tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |
| 128 | +tokenArray.sort(function(a,b){return a.offset-b.offset||a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},mark:function(context,division,tokens){var markers=context.modules.highlight.markers=[];context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var pos=0;var node=context.$content.get(0);var next=null;var i=0;var startNode=null;var depth=0,nextDepth=0,startDepth=null;while(node.firstChild){node=node.firstChild;depth++;} |
129 | 129 | while(i<markers.length&&node){var p=node;nextDepth=depth;while(p&&!p.nextSibling){p=p.parentNode;nextDepth--;} |
130 | 130 | p=p?p.nextSibling:null;while(p&&p.firstChild){p=p.firstChild;nextDepth++;} |
131 | 131 | next=p;if(node.nodeName!='#text'){if(node.nodeName=='BR'){pos++;} |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | $('#wikiEditor-'+context.instance+'-dialog-watch').attr('checked','checked');$(this).find('form').submit(function(e){$(this).closest('.ui-dialog').find('button:first').click();e.preventDefault();});},dialog:{buttons:{'wikieditor-publish-dialog-publish':function(){var minorChecked=$('#wikiEditor-'+context.instance+'-dialog-minor').is(':checked')?'checked':'';var watchChecked=$('#wikiEditor-'+context.instance+'-dialog-watch').is(':checked')?'checked':'';$('#wpMinoredit').attr('checked',minorChecked);$('#wpWatchthis').attr('checked',watchChecked);$('#wpSummary').val($j('#wikiEditor-'+context.instance+'-dialog-summary').val());$('#editform').submit();},'wikieditor-publish-dialog-goback':function(){$(this).dialog('close');}},open:function(){$('#wikiEditor-'+context.instance+'-dialog-summary').focus();},width:500},resizeme:false}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-publish','action':function(){$('#'+dialogID).dialog('open');return false;}});context.fn.addButton({'captionMsg':'wikieditor-publish-button-cancel','action':function(){}});}}};})(jQuery);(function($){$.wikiEditor.modules.templateEditor={evt:{mark:function(context,event){var markers=context.modules.highlight.markers;var tokenArray=context.modules.highlight.tokenArray;var level=0;var tokenIndex=0;while(tokenIndex<tokenArray.length){while(tokenIndex<tokenArray.length&&tokenArray[tokenIndex].label!='TEMPLATE_BEGIN'){tokenIndex++;} |
174 | 174 | if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}} |
175 | 175 | if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,needsWrap:function(ca1,ca2){return!$(ca1.parentNode).is('div.wikiEditor-template')||ca1.previousSibling!=null||ca1.nextSibling!=null;},afterWrap:$.wikiEditor.modules.templateEditor.fn.stylize});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],fn:{create:function(context,config){context.modules.templateEditor={};},stylize:function(wrappedTemplate){$(wrappedTemplate).each(function(){if(typeof $(this).data('model')!='undefined'){return;} |
176 | | -$(this).addClass('wikiEditor-nodisplay wikiEditor-template');$(this).data('model',new $.wikiEditor.modules.templateEditor.fn.model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};var $visibleDiv=$("<div />").addClass('wikiEditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext',$(this));$(this).after($visibleDiv);$visibleDiv.mousedown(function(){if($(this).hasClass('wikiEditor-template-collapsed')){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
| 176 | +$(this).addClass('wikiEditor-nodisplay wikiEditor-template');$(this).data('model',new $.wikiEditor.modules.templateEditor.fn.model($(this).text()));var model=$(this).data('model');function expandTemplate($displayDiv){$displayDiv.removeClass('wikiEditor-template-collapsed');$displayDiv.addClass('wikiEditor-template-expanded');$keyValueTable=$('<table />').appendTo($displayDiv);$header_row=$('<tr />').appendTo($keyValueTable);$('<th />').attr('colspan','2').text(model.getName()).appendTo($header_row);for(param in model.getAllParamNames()){$keyVal_row=$('<tr />').appendTo($keyValueTable);$('<td />').text(param).appendTo($keyVal_row);$('<td />').text(model.getValue(param)).appendTo($keyVal_row);}};function collapseTemplate($displayDiv){$displayDiv.addClass('wikiEditor-template-collapsed');$displayDiv.removeClass('wikiEditor-template-expanded');$displayDiv.text(model.getName());};var $visibleDiv=$("<div />").addClass('wikiEditor-noinclude');$(this).data('display',$visibleDiv);$visibleDiv.data('wikitext',$(this));$(this).after($visibleDiv);$visibleDiv.mousedown(function(){if($(this).hasClass('wikiEditor-template-collapsed')){expandTemplate($(this));}else{collapseTemplate($(this));}});collapseTemplate($visibleDiv);});},getTemplateInfo:function(templateName){var templateInfo='';return $(templateInfo);},model:function(wikitext){function Param(name,value,number,nameIndex,equalsIndex,valueIndex){this.name=name;this.value=value;this.number=number;this.nameIndex=nameIndex;this.equalsIndex=equalsIndex;this.valueIndex=valueIndex;} |
177 | 177 | function Range(begin,end){this.begin=begin;this.end=end;} |
178 | 178 | function getSetValue(name,value,original){var valueRange;var rangeIndex;var retVal;if(isNaN(name)){if(typeof paramsByName[name]=='undefined'){return"";} |
179 | 179 | rangeIndex=paramsByName[name];}else{rangeIndex=parseInt(name);} |
— | — | @@ -186,9 +186,9 @@ |
187 | 187 | sanatizedStr.substring(endBraces.index+2);while(sanatizedStr.indexOf('{{')!=-1){startIndex=sanatizedStr.indexOf('{{')+1;openBraces=2;endIndex=startIndex;while(openBraces>0){var brace=sanatizedStr[++endIndex];openBraces+=brace=='}'?-1:brace=='{'?1:0;} |
188 | 188 | sanatizedSegment=sanatizedStr.substring(startIndex,endIndex).replace(/[{}|=]/g,'X');sanatizedStr=sanatizedStr.substring(0,startIndex)+sanatizedSegment+sanatizedStr.substring(endIndex);} |
189 | 189 | var ranges=[];var params=[];var templateNameIndex=0;var doneParsing=false;oldDivider=0;divider=sanatizedStr.indexOf('|',oldDivider);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
190 | | -nameMatch=wikitext.substring(oldDivider,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(oldDivider,nameMatch.index));templateNameIndex=ranges.push(new Range(nameMatch.index,nameMatch.index+nameMatch[0].length));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);} |
| 190 | +nameMatch=wikitext.substring(0,divider).match(/[^{\s]+/);if(nameMatch!=undefined){ranges.push(new Range(0,nameMatch.index));nameEndMatch=sanatizedStr.substring(0,divider).match(/[^\s]\s*$/);templateNameIndex=ranges.push(new Range(nameMatch.index,nameEndMatch.index+1));templateNameIndex--;ranges[templateNameIndex].old=wikitext.substring(ranges[templateNameIndex].begin,ranges[templateNameIndex].end);} |
191 | 191 | params.push(ranges[templateNameIndex].old);var currentParamNumber=0;var valueEndIndex;var paramsByName=[];while(!doneParsing){currentParamNumber++;oldDivider=divider;divider=sanatizedStr.indexOf('|',oldDivider+1);if(divider==-1){divider=sanatizedStr.length;doneParsing=true;} |
192 | | -currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){divider++;currentParamNumber--;continue;} |
| 192 | +currentField=sanatizedStr.substring(oldDivider+1,divider);if(currentField.indexOf('=')==-1){valueBegin=currentField.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentField.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex));nameIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;equalsIndex=ranges.push(new Range(valueBeginIndex,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(currentParamNumber,wikitext.substring(ranges[valueIndex].begin,ranges[valueIndex].end),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[currentParamNumber]=currentParamNumber;}else{currentName=currentField.substring(0,currentField.indexOf('='));nameBegin=currentName.match(/\S+/);if(nameBegin==null){currentParamNumber--;continue;} |
193 | 193 | nameBeginIndex=nameBegin.index+oldDivider+1;nameEnd=currentName.match(/[^\s]\s*$/);nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBegin=currentValue.match(/\S+/);valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);valueEndIndex=valueEnd.index+oldDivider+2;equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} |
194 | 194 | ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={cfg:{defaultWidth:'166px',minimumWidth:'70px',},api:{},evt:{ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().delayedBind(250,'mouseup scrollToTop keyup change',function(){$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(event){var context=event.data.context;context.$textarea.delayedBindCancel(250,'mouseup scrollToTop keyup change');$.wikiEditor.modules.toc.fn.unhighlight(context);});},resize:function(context,event){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
195 | 195 | context.$ui.find('.tab-toc').outerHeight());}},fn:{create:function(context,config){if('$toc'in context.modules.toc){return;} |