r63208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63207‎ | r63208 | r63209 >
Date:15:30, 3 March 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Redo r63192 in a saner way, using descendant selectors instead of additional classes
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -78,14 +78,14 @@
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 19 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 96 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 34 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 35 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 302 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 303 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 302 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 303 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -161,12 +161,12 @@
162162 .prependTo( $template );
163163
164164 var $templateExpand = $( '<span />' )
165 - .addClass( 'wikiEditor-template-expand wikiEditor-noinclude wikiEditor-template-expand-collapsed' )
 165+ .addClass( 'wikiEditor-template-expand wikiEditor-noinclude' )
166166 .mousedown( toggleWikiTextEditor )
167167 .prependTo( $template );
168168
169169 var $templateDialog = $( '<span />' )
170 - .addClass( 'wikiEditor-template-dialog wikiEditor-noinclude wikiEditor-template-dialog-collapsed' )
 170+ .addClass( 'wikiEditor-template-dialog wikiEditor-noinclude' )
171171 .mousedown( function() { createDialog( $template ); return false; } )
172172 .insertAfter( $templateName );
173173
@@ -176,21 +176,12 @@
177177 $template
178178 .toggleClass( 'wikiEditor-template-expanded' )
179179 .toggleClass( 'wikiEditor-template-collapsed' );
180 - var $templateExpand = $template.find('.wikiEditor-template-expand');
181 - var $templateDialog = $template.find('.wikiEditor-template-dialog');
182180 var $wikitext = $template.children( '.wikiEditor-template-text' );
183181
184 - $templateExpand
185 - .toggleClass('wikiEditor-template-expand-collapsed')
186 - .toggleClass('wikiEditor-template-expand-expanded');
187 - $templateDialog
188 - .toggleClass('wikiEditor-template-dialog-collapsed')
189 - .toggleClass('wikiEditor-template-dialog-expanded');
190 -
191182 $wikitext.toggleClass( 'wikiEditor-nodisplay' );
192183
193184 //if we just collapsed this
194 - if( $template.hasClass( 'wikiEditor-template-collapsed' ) ) {
 185+ if ( $template.hasClass( 'wikiEditor-template-collapsed' ) ) {
195186 var model = new $.wikiEditor.modules.templateEditor.fn.model(
196187 $template.children( '.wikiEditor-template-text' ).text()
197188 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html
@@ -74,16 +74,16 @@
7575 padding-right: 11px;
7676 background-position: 50%; /*FF3*/
7777 }
78 - .wikiEditor-template-expand-collapsed{
79 - background-image: url(../../images/wikiEditor/templateEditor/expand.png);
 78+ .wikiEditor-template-expanded .wikiEditor-template-expand {
 79+ background-image: url(../../images/wikiEditor/templateEditor/collapse.png);
8080 }
81 - .wikiEditor-template-expand-expanded{
82 - background-image: url(../../images/wikiEditor/templateEditor/collapse.png);
83 - }
84 - .wikiEditor-template-dialog-expanded{
 81+ .wikiEditor-template-expanded .wikiEditor-template-dialog {
8582 background-image: url(../../images/wikiEditor/templateEditor/dialog-expanded.png);
8683 }
87 - .wikiEditor-template-dialog-collapsed{
 84+ .wikiEditor-template-collapsed .wikiEditor-template-expand {
 85+ background-image: url(../../images/wikiEditor/templateEditor/expand.png);
 86+ }
 87+ .wikiEditor-template-collapsed .wikiEditor-template-dialog {
8888 background-image: url(../../images/wikiEditor/templateEditor/dialog-collapsed.png);
8989 }
9090 .wikiEditor-template-expanded img,
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -9270,15 +9270,11 @@
92719271
92729272 var $templateExpand = $( '<span />' )
92739273 .addClass( 'wikiEditor-template-expand wikiEditor-noinclude' )
9274 - .append( '<img src="' + $.wikiEditor.autoIcon( 'templateEditor/expand.png' ) + '" width="12" height="16" />' )
9275 - .append( '<img src="' + $.wikiEditor.autoIcon( 'templateEditor/collapse.png' ) + '" width="12" height="16" style="display:none;" />' )
92769274 .mousedown( toggleWikiTextEditor )
92779275 .prependTo( $template );
92789276
92799277 var $templateDialog = $( '<span />' )
92809278 .addClass( 'wikiEditor-template-dialog wikiEditor-noinclude' )
9281 - .append( '<img src="' + $.wikiEditor.autoIcon( 'templateEditor/dialog-collapsed.png' ) + '" width="22" height="16" />' )
9282 - .append( '<img src="' + $.wikiEditor.autoIcon( 'templateEditor/dialog-expanded.png' ) + '" width="22" height="16" style="display:none;" />' )
92839279 .mousedown( function() { createDialog( $template ); return false; } )
92849280 .insertAfter( $templateName );
92859281
@@ -9287,16 +9283,13 @@
92889284 var $template = $( this ).closest( '.wikiEditor-template' );
92899285 $template
92909286 .toggleClass( 'wikiEditor-template-expanded' )
9291 - .toggleClass( 'wikiEditor-template-collapsed' )
9292 - .find( 'img' )
9293 - .each( function() {
9294 - $( this ).toggle();
9295 - } );
 9287+ .toggleClass( 'wikiEditor-template-collapsed' );
92969288 var $wikitext = $template.children( '.wikiEditor-template-text' );
 9289+
92979290 $wikitext.toggleClass( 'wikiEditor-nodisplay' );
92989291
92999292 //if we just collapsed this
9300 - if( $template.hasClass( 'wikiEditor-template-collapsed' ) ) {
 9293+ if ( $template.hasClass( 'wikiEditor-template-collapsed' ) ) {
93019294 var model = new $.wikiEditor.modules.templateEditor.fn.model(
93029295 $template.children( '.wikiEditor-template-text' ).text()
93039296 );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -640,7 +640,7 @@
641641 $('#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={'browsers':{'ltr':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]]}},'req':['iframe'],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++;}
642642 if(tokenIndex<tokenArray.length){var beginIndex=tokenIndex;var endIndex=-1;var openTemplates=1;var templatesMatched=false;while(tokenIndex<tokenArray.length-1&&endIndex==-1){tokenIndex++;if(tokenArray[tokenIndex].label=='TEMPLATE_BEGIN'){openTemplates++;}else if(tokenArray[tokenIndex].label=='TEMPLATE_END'){openTemplates--;if(openTemplates==0){endIndex=tokenIndex;}}}
643643 if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',splitPs:false,afterWrap:function(node){var model=new $.wikiEditor.modules.templateEditor.fn.model($(node).text());$(node).data('model',model);if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}else{$(node).addClass('wikiEditor-template-text');}},beforeUnwrap:function(node){if($(node).parent().hasClass('wikiEditor-template')){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}},onSkip:function(node){if($(node).data('model').getText()==$(node).text()){return;}
644 -var model=new $.wikiEditor.modules.templateEditor.fn.model($(node).text());$(node).data('model',model);if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/expand.png')+'" width="12" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/collapse.png')+'" width="12" height="16" style="display:none;" />').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-collapsed.png')+'" width="22" height="16" />').append('<img src="'+$.wikiEditor.autoIcon('templateEditor/dialog-expanded.png')+'" width="22" height="16" style="display:none;" />').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);function toggleWikiTextEditor(){context.fn.purgeOffsets();var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('img').each(function(){$(this).toggle();});var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.children('.wikiEditor-template-text').data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}else{$wikitext.text($template.children('.wikiEditor-template-text').data('model').getText());}
 644+var model=new $.wikiEditor.modules.templateEditor.fn.model($(node).text());$(node).data('model',model);if($(node).parent().hasClass('wikiEditor-template')&&!model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.unwrapTemplate($(node));}else if(!$(node).parent().hasClass('wikiEditor-template')&&model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));}},getAnchor:function(ca1,ca2){return $(ca1.parentNode).is('span.wikiEditor-template-text')?ca1.parentNode:null;},context:context});}else{tokenArray[beginIndex].label='TEMPLATE_FALSE_BEGIN';tokenIndex=beginIndex;}}}}},exp:[{'regex':/{{/,'label':"TEMPLATE_BEGIN"},{'regex':/}}/,'label':"TEMPLATE_END",'markAfter':true}],cfg:{},fn:{create:function(context,config){context.modules.templateEditor={};},wrapTemplate:function($wrapper){var model=$wrapper.data('model');var context=$wrapper.data('marker').context;var $template=$wrapper.wrap('<span class="wikiEditor-template"></span>').addClass('wikiEditor-template-text wikiEditor-nodisplay').parent().addClass('wikiEditor-template-collapsed').data('model',model);var $templateName=$('<span />').addClass('wikiEditor-template-name wikiEditor-noinclude').text(model.getName()).mousedown(toggleWikiTextEditor).prependTo($template);var $templateExpand=$('<span />').addClass('wikiEditor-template-expand wikiEditor-noinclude').mousedown(toggleWikiTextEditor).prependTo($template);var $templateDialog=$('<span />').addClass('wikiEditor-template-dialog wikiEditor-noinclude').mousedown(function(){createDialog($template);return false;}).insertAfter($templateName);function toggleWikiTextEditor(){context.fn.purgeOffsets();var $template=$(this).closest('.wikiEditor-template');$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed');var $wikitext=$template.children('.wikiEditor-template-text');$wikitext.toggleClass('wikiEditor-nodisplay');if($template.hasClass('wikiEditor-template-collapsed')){var model=new $.wikiEditor.modules.templateEditor.fn.model($template.children('.wikiEditor-template-text').text());$template.children('.wikiEditor-template-text').data('model',model);$template.children('.wikiEditor-template-name').text(model.getName());}else{$wikitext.text($template.children('.wikiEditor-template-text').data('model').getText());}
645645 return false;};var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\
646646 <fieldset>\
647647 <div class="wikiEditor-template-dialog-title" />\

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63192using spans with images so everything clicks rightnimishg00:43, 3 March 2010

Status & tagging log