Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Templates/Templates.i18n.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation for the Highlight module of the Usability Initiative wikiEditor extension |
| 4 | + * Internationalisation for the Templates module of the Usability Initiative wikiEditor extension |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
Index: trunk/extensions/UsabilityInitiative/WikiEditor/Modules/Templates/Templates.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* JavaScript for WikiEditor Templates module */ |
3 | 3 | |
4 | 4 | $j(document).ready( function() { |
5 | | - // Check preferences for templateEditor |
| 5 | + // Check preferences for templates |
6 | 6 | if ( !wgWikiEditorEnabledModules.templates ) { |
7 | 7 | return true; |
8 | 8 | } |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | if ( wgNamespaceNumber == 10 ) { |
11 | 11 | return true; |
12 | 12 | } |
13 | | - // Add the templateEditor module |
| 13 | + // Add the templates module |
14 | 14 | if ( $j.fn.wikiEditor ) { |
15 | 15 | $j( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'templates' ); |
16 | 16 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templates.js |
— | — | @@ -35,8 +35,8 @@ |
36 | 36 | var tokens = context.modules.highlight.tokenArray; |
37 | 37 | // Use depth-tracking to extract top-level templates from tokens |
38 | 38 | var depth = 0, bias, start; |
39 | | - for ( i in tokens ) { |
40 | | - depth += bias = tokens[i].label == 'TEMPLATE_BEGIN' ? 1 : tokens[i].label == 'TEMPLATE_END' ? -1 : 0; |
| 39 | + for ( var i in tokens ) { |
| 40 | + depth += ( bias = tokens[i].label == 'TEMPLATE_BEGIN' ? 1 : ( tokens[i].label == 'TEMPLATE_END' ? -1 : 0 ) ); |
41 | 41 | if ( bias > 0 && depth == 1 ) { |
42 | 42 | // Top-level opening - use offset as start |
43 | 43 | start = tokens[i].offset; |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | if ( depth < 0 ) { |
52 | | - depth = 0; |
| 52 | + depth = 0; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -50,15 +50,17 @@ |
51 | 51 | // Scan text for new tokens |
52 | 52 | var text = context.fn.getContents(); |
53 | 53 | // Perform a scan for each module which provides any expressions to scan for |
54 | | - for ( module in context.modules ) { |
| 54 | + // FIXME: This traverses the entire string once for every regex. Investigate |
| 55 | + // whether |-concatenating regexes then traversing once is faster. |
| 56 | + for ( var module in context.modules ) { |
55 | 57 | if ( module in $.wikiEditor.modules && 'exp' in $.wikiEditor.modules[module] ) { |
56 | | - for ( exp in $.wikiEditor.modules[module].exp ) { |
| 58 | + for ( var exp in $.wikiEditor.modules[module].exp ) { |
57 | 59 | // Prepare configuration |
58 | 60 | var regex = $.wikiEditor.modules[module].exp[exp].regex; |
59 | 61 | var label = $.wikiEditor.modules[module].exp[exp].label; |
60 | | - var markAfter = ( typeof $.wikiEditor.modules[module].exp[exp].markAfter != 'undefined' ); |
| 62 | + var markAfter = $.wikiEditor.modules[module].exp[exp].markAfter || false; |
61 | 63 | // Search for tokens |
62 | | - var offset = 0, left, right; |
| 64 | + var offset = 0, left, right, match; |
63 | 65 | while ( ( match = text.substr( offset ).match( regex ) ) != null ) { |
64 | 66 | right = ( left = offset + match.index ) + match[0].length; |
65 | 67 | tokenArray[tokenArray.length] = { |
— | — | @@ -75,7 +77,7 @@ |
76 | 78 | } |
77 | 79 | // Sort by start |
78 | 80 | tokenArray.sort( function( a, b ) { return a.tokenStart - b.tokenStart; } ); |
79 | | - // Let the world know, a scan just happend! |
| 81 | + // Let the world know, a scan just happened! |
80 | 82 | context.fn.trigger( 'scan' ); |
81 | 83 | }, |
82 | 84 | /** |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -8665,15 +8665,17 @@ |
8666 | 8666 | // Scan text for new tokens |
8667 | 8667 | var text = context.fn.getContents(); |
8668 | 8668 | // Perform a scan for each module which provides any expressions to scan for |
8669 | | - for ( module in context.modules ) { |
| 8669 | + // FIXME: This traverses the entire string once for every regex. Investigate |
| 8670 | + // whether |-concatenating regexes then traversing once is faster. |
| 8671 | + for ( var module in context.modules ) { |
8670 | 8672 | if ( module in $.wikiEditor.modules && 'exp' in $.wikiEditor.modules[module] ) { |
8671 | | - for ( exp in $.wikiEditor.modules[module].exp ) { |
| 8673 | + for ( var exp in $.wikiEditor.modules[module].exp ) { |
8672 | 8674 | // Prepare configuration |
8673 | 8675 | var regex = $.wikiEditor.modules[module].exp[exp].regex; |
8674 | 8676 | var label = $.wikiEditor.modules[module].exp[exp].label; |
8675 | | - var markAfter = ( typeof $.wikiEditor.modules[module].exp[exp].markAfter != 'undefined' ); |
| 8677 | + var markAfter = $.wikiEditor.modules[module].exp[exp].markAfter || false; |
8676 | 8678 | // Search for tokens |
8677 | | - var offset = 0, left, right; |
| 8679 | + var offset = 0, left, right, match; |
8678 | 8680 | while ( ( match = text.substr( offset ).match( regex ) ) != null ) { |
8679 | 8681 | right = ( left = offset + match.index ) + match[0].length; |
8680 | 8682 | tokenArray[tokenArray.length] = { |
— | — | @@ -8690,7 +8692,7 @@ |
8691 | 8693 | } |
8692 | 8694 | // Sort by start |
8693 | 8695 | tokenArray.sort( function( a, b ) { return a.tokenStart - b.tokenStart; } ); |
8694 | | - // Let the world know, a scan just happend! |
| 8696 | + // Let the world know, a scan just happened! |
8695 | 8697 | context.fn.trigger( 'scan' ); |
8696 | 8698 | }, |
8697 | 8699 | /** |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -588,7 +588,7 @@ |
589 | 589 | configuration.newButtons[mw.usability.getMsg(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);$.wikiEditor.modules.dialogs.fn.setTabindexes(dialogDiv.closest('.ui-dialog').find('button').not('[tabindex]'));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);});} |
590 | 590 | dialogDiv.bind('dialogclose',function(){context.fn.restoreSelection();});context.$textarea.trigger('wikiEditor-dialogs-loaded-'+mod);});},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);} |
591 | 591 | $(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});},setTabindexes:function($elements){var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
592 | | -maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],'cfg':{'styleVersion':3},'evt':{'delayedChange':function(context,event){if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,event.data.scope);}},'ready':function(context,event){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,'ready');}},'fn':{'create':function(context,config){context.modules.highlight.markersStr='';},'scan':function(context,division){var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(exp in $.wikiEditor.modules[module].exp){var regex=$.wikiEditor.modules[module].exp[exp].regex;var label=$.wikiEditor.modules[module].exp[exp].label;var markAfter=(typeof $.wikiEditor.modules[module].exp[exp].markAfter!='undefined');var offset=0,left,right;while((match=text.substr(offset).match(regex))!=null){right=(left=offset+match.index)+match[0].length;tokenArray[tokenArray.length]={'offset':markAfter?right:left,'label':label,'tokenStart':left,'match':match};offset=right;}}}} |
| 592 | +maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],'cfg':{'styleVersion':3},'evt':{'delayedChange':function(context,event){if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,event.data.scope);}},'ready':function(context,event){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,'ready');}},'fn':{'create':function(context,config){context.modules.highlight.markersStr='';},'scan':function(context,division){var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(var module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var exp in $.wikiEditor.modules[module].exp){var regex=$.wikiEditor.modules[module].exp[exp].regex;var label=$.wikiEditor.modules[module].exp[exp].label;var markAfter=$.wikiEditor.modules[module].exp[exp].markAfter||false;var offset=0,left,right,match;while((match=text.substr(offset).match(regex))!=null){right=(left=offset+match.index)+match[0].length;tokenArray[tokenArray.length]={'offset':markAfter?right:left,'label':label,'tokenStart':left,'match':match};offset=right;}}}} |
593 | 593 | tokenArray.sort(function(a,b){return a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},'mark':function(context,division,tokens){var markers=[];if(context.modules.highlight.markers&&division!=''){for(var i=0;i<context.modules.highlight.markers.length;i++){if(context.modules.highlight.markers[i].skipDivision==division){markers.push(context.modules.highlight.markers[i]);}}} |
594 | 594 | context.modules.highlight.markers=markers;context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var markersStr='';for(var i=0;i<markers.length;i++){markersStr+=markers[i].start+','+markers[i].end+','+markers[i].type+',';} |
595 | 595 | if(context.modules.highlight.markersStr==markersStr){return;} |