r63792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63791‎ | r63792 | r63793 >
Date:00:49, 16 March 2010
Author:tparscal
Status:ok
Tags:
Comment:
Added enter to edit as a form, space to expand/contract to template capsules.
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.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' => 21 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ),
8181 array( 'src' => 'js/plugins/jquery.wikiEditor.preview.js', 'version' => 11 ),
82 - array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 60 ),
 82+ array( 'src' => 'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 61 ),
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 340 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 341 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 340 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 341 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js
@@ -128,44 +128,55 @@
129129 }, //mark
130130
131131 keydown: function( context, event ) {
132 - // reset our ignoreKeypress variable if it's set to true
133 - if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false );
 132+ // Reset our ignoreKeypress variable if it's set to true
 133+ if ( context.$iframe.data( 'ignoreKeypress' ) ) {
 134+ context.$iframe.data( 'ignoreKeypress', false );
 135+ }
134136 var $evtElem = event.jQueryNode;
135 - if( $evtElem.hasClass( 'wikiEditor-template-label' ) ) {
136 - // allow anything if the command or control key are depressed
 137+ if ( $evtElem.hasClass( 'wikiEditor-template-label' ) ) {
 138+ // Allow anything if the command or control key are depressed
137139 if ( event.ctrlKey || event.metaKey ) return true;
138140 switch ( event.which ) {
139 - case 37://left
140 - case 38://up
141 - case 39://right
142 - case 40: return true;//down
 141+ case 13: // Enter
 142+ $evtElem.click();
 143+ return false;
 144+ case 32: // Space
 145+ $evtElem.parent().siblings( '.wikiEditor-template-expand' ).click();
 146+ return false;
 147+ case 37:// Left
 148+ case 38:// Up
 149+ case 39:// Right
 150+ case 40: //Down
 151+ return true;
143152 default:
144 - // set the ignroreKeypress variable so we don't allow typing if the key is held
 153+ // Set the ignroreKeypress variable so we don't allow typing if the key is held
145154 context.$iframe.data( 'ignoreKeypress', true );
146 - //can't type in a template name
 155+ // Can't type in a template name
147156 return false;
148157 }
149158 } else if ( $evtElem.hasClass( 'wikiEditor-template-text' ) ) {
150159 switch ( event.which ) {
151 - case 13: //enter
 160+ case 13: // Enter
152161 // Ensure that the user can't break this by holding in the enter key
153162 context.$iframe.data( 'ignoreKeypress', true );
154 - //FIXME: may be a more elegant way to do this, but this works too
155 - context.fn.encapsulateSelection( { 'pre':'\n', 'peri':'', 'post':'' } );
 163+ // FIXME: May be a more elegant way to do this, but this works too
 164+ context.fn.encapsulateSelection( { 'pre': '\n', 'peri': '', 'post': '' } );
156165 return false;
157166 default: return true;
158167 }
159 - }//classes
160 - }, //keydown
 168+ }
 169+ },
161170 keyup: function( context, event ) {
162 - // rest our ignoreKeypress variable if it's set to true
163 - if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false );
 171+ // Rest our ignoreKeypress variable if it's set to true
 172+ if ( context.$iframe.data( 'ignoreKeypress' ) ) {
 173+ context.$iframe.data( 'ignoreKeypress', false );
 174+ }
164175 return true;
165 - }, //keyup
 176+ },
166177 keypress: function( context, event ) {
167 - // if this event is from a keydown event which we want to block, ignore it
 178+ // If this event is from a keydown event which we want to block, ignore it
168179 return ( context.$iframe.data( 'ignoreKeypress' ) ? false : true );
169 - } //keypress
 180+ }
170181 },
171182 /**
172183 * Regular expressions that produce tokens
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -9373,44 +9373,55 @@
93749374 }, //mark
93759375
93769376 keydown: function( context, event ) {
9377 - // reset our ignoreKeypress variable if it's set to true
9378 - if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false );
 9377+ // Reset our ignoreKeypress variable if it's set to true
 9378+ if ( context.$iframe.data( 'ignoreKeypress' ) ) {
 9379+ context.$iframe.data( 'ignoreKeypress', false );
 9380+ }
93799381 var $evtElem = event.jQueryNode;
9380 - if( $evtElem.hasClass( 'wikiEditor-template-label' ) ) {
9381 - // allow anything if the command or control key are depressed
 9382+ if ( $evtElem.hasClass( 'wikiEditor-template-label' ) ) {
 9383+ // Allow anything if the command or control key are depressed
93829384 if ( event.ctrlKey || event.metaKey ) return true;
93839385 switch ( event.which ) {
9384 - case 37://left
9385 - case 38://up
9386 - case 39://right
9387 - case 40: return true;//down
 9386+ case 13: // Enter
 9387+ $evtElem.click();
 9388+ return false;
 9389+ case 32: // Space
 9390+ $evtElem.parent().siblings( '.wikiEditor-template-expand' ).click();
 9391+ return false;
 9392+ case 37:// Left
 9393+ case 38:// Up
 9394+ case 39:// Right
 9395+ case 40: //Down
 9396+ return true;
93889397 default:
9389 - // set the ignroreKeypress variable so we don't allow typing if the key is held
 9398+ // Set the ignroreKeypress variable so we don't allow typing if the key is held
93909399 context.$iframe.data( 'ignoreKeypress', true );
9391 - //can't type in a template name
 9400+ // Can't type in a template name
93929401 return false;
93939402 }
93949403 } else if ( $evtElem.hasClass( 'wikiEditor-template-text' ) ) {
93959404 switch ( event.which ) {
9396 - case 13: //enter
 9405+ case 13: // Enter
93979406 // Ensure that the user can't break this by holding in the enter key
93989407 context.$iframe.data( 'ignoreKeypress', true );
9399 - //FIXME: may be a more elegant way to do this, but this works too
9400 - context.fn.encapsulateSelection( { 'pre':'\n', 'peri':'', 'post':'' } );
 9408+ // FIXME: May be a more elegant way to do this, but this works too
 9409+ context.fn.encapsulateSelection( { 'pre': '\n', 'peri': '', 'post': '' } );
94019410 return false;
94029411 default: return true;
94039412 }
9404 - }//classes
9405 - }, //keydown
 9413+ }
 9414+ },
94069415 keyup: function( context, event ) {
9407 - // rest our ignoreKeypress variable if it's set to true
9408 - if( context.$iframe.data( 'ignoreKeypress' ) ) context.$iframe.data( 'ignoreKeypress', false );
 9416+ // Rest our ignoreKeypress variable if it's set to true
 9417+ if ( context.$iframe.data( 'ignoreKeypress' ) ) {
 9418+ context.$iframe.data( 'ignoreKeypress', false );
 9419+ }
94099420 return true;
9410 - }, //keyup
 9421+ },
94119422 keypress: function( context, event ) {
9412 - // if this event is from a keydown event which we want to block, ignore it
 9423+ // If this event is from a keydown event which we want to block, ignore it
94139424 return ( context.$iframe.data( 'ignoreKeypress' ) ? false : true );
9414 - } //keypress
 9425+ }
94159426 },
94169427 /**
94179428 * Regular expressions that produce tokens
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -646,7 +646,9 @@
647647 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;}}}
648648 if(endIndex!=-1){markers.push({start:tokenArray[beginIndex].offset,end:tokenArray[endIndex].offset,type:'template',anchor:'wrap',afterWrap:function(node){var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if(model.isCollapsible()){$.wikiEditor.modules.templateEditor.fn.wrapTemplate($(node));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(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).html()==$(node).data('oldHTML')){return;}
649649 var model=$.wikiEditor.modules.templateEditor.fn.updateModel($(node));if($(node).parent().hasClass('wikiEditor-template')){var $label=$(node).parent().find('.wikiEditor-template-label');var displayName=$.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName(model);if($label.text()!=displayName){$label.text(displayName);}}
650 -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));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(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;}}}},keydown:function(context,event){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);var $evtElem=event.jQueryNode;if($evtElem.hasClass('wikiEditor-template-label')){if(event.ctrlKey||event.metaKey)return true;switch(event.which){case 37:case 38:case 39:case 40:return true;default:context.$iframe.data('ignoreKeypress',true);return false;}}else if($evtElem.hasClass('wikiEditor-template-text')){switch(event.which){case 13:context.$iframe.data('ignoreKeypress',true);context.fn.encapsulateSelection({'pre':'\n','peri':'','post':''});return false;default:return true;}}},keyup:function(context,event){if(context.$iframe.data('ignoreKeypress'))context.$iframe.data('ignoreKeypress',false);return true;},keypress:function(context,event){return(context.$iframe.data('ignoreKeypress')?false:true);}},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').prepend($('<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>'+'<span class="wikiEditor-template-name wikiEditor-noinclude">'+'<span class="wikiEditor-template-label wikiEditor-noinclude">'+
 650+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));$.wikiEditor.modules.templateEditor.fn.bindTemplateEvents($(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;}}}},keydown:function(context,event){if(context.$iframe.data('ignoreKeypress')){context.$iframe.data('ignoreKeypress',false);}
 651+var $evtElem=event.jQueryNode;if($evtElem.hasClass('wikiEditor-template-label')){if(event.ctrlKey||event.metaKey)return true;switch(event.which){case 13:$evtElem.click();return false;case 32:$evtElem.parent().siblings('.wikiEditor-template-expand').click();return false;case 37:case 38:case 39:case 40:return true;default:context.$iframe.data('ignoreKeypress',true);return false;}}else if($evtElem.hasClass('wikiEditor-template-text')){switch(event.which){case 13:context.$iframe.data('ignoreKeypress',true);context.fn.encapsulateSelection({'pre':'\n','peri':'','post':''});return false;default:return true;}}},keyup:function(context,event){if(context.$iframe.data('ignoreKeypress')){context.$iframe.data('ignoreKeypress',false);}
 652+return true;},keypress:function(context,event){return(context.$iframe.data('ignoreKeypress')?false:true);}},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').prepend($('<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>'+'<span class="wikiEditor-template-name wikiEditor-noinclude">'+'<span class="wikiEditor-template-label wikiEditor-noinclude">'+
651653 $.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName(model)+'</span>'+'<span class="wikiEditor-template-dialog wikiEditor-noinclude"></span>'+'</span>'));},unwrapTemplate:function($wrapper){$wrapper.parent().replaceWith($wrapper);},bindTemplateEvents:function($wrapper){var $template=$wrapper.parent('.wikiEditor-template');$template.find('.wikiEditor-template-name').click(function(){$.wikiEditor.modules.templateEditor.fn.createDialog($wrapper);return false;}).mousedown(function(){return false;});$template.find('.wikiEditor-template-expand').click(function(){$.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor($wrapper);return false;}).mousedown(function(){return false;});},toggleWikiTextEditor:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');context.fn.purgeOffsets();$template.toggleClass('wikiEditor-template-expanded').toggleClass('wikiEditor-template-collapsed').find('.wikiEditor-template-text').toggleClass('wikiEditor-nodisplay');},createDialog:function($wrapper){var context=$wrapper.data('marker').context;var $template=$wrapper.parent('.wikiEditor-template');var dialog={'titleMsg':'wikieditor-template-editor-dialog-title','id':'wikiEditor-template-dialog','html':'\
652654 <fieldset>\
653655 <div class="wikiEditor-template-dialog-title" />\

Status & tagging log