Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -153,12 +153,12 @@ |
154 | 154 | array( |
155 | 155 | 'src' => 'js/plugins/jquery.wikiEditor.js', |
156 | 156 | 'class' => 'j.wikiEditor', |
157 | | - 'version' => 48 |
| 157 | + 'version' => 49 |
158 | 158 | ), |
159 | 159 | array( |
160 | 160 | 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', |
161 | 161 | 'class' => 'j.wikiEditor.modules.highlight', |
162 | | - 'version' => 12 |
| 162 | + 'version' => 13 |
163 | 163 | ), |
164 | 164 | array( |
165 | 165 | 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | 'version' => 1 ), |
193 | 193 | ), |
194 | 194 | 'combined' => array( |
195 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 148 ), |
| 195 | + array( 'src' => 'js/plugins.combined.js', 'version' => 149 ), |
196 | 196 | ), |
197 | 197 | 'minified' => array( |
198 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 148 ), |
| 198 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 149 ), |
199 | 199 | ), |
200 | 200 | ), |
201 | 201 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | } |
96 | 96 | var context = window.parent.jQuery.wikiEditor.instances[get( 'instance' )].data( 'wikiEditor-context' ); |
97 | 97 | $j( document ) |
98 | | - .bind( "keydown keypress keyup mousedown mouseup cut paste", function( event ) { |
| 98 | + .bind( "keyup mouseup paste cut", function( event ) { |
99 | 99 | context.fn.trigger( "change", event ); |
100 | 100 | } ) |
101 | 101 | .delayedBind( 250, "keydown keypress keyup mousedown mouseup cut paste", function( event ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -269,23 +269,22 @@ |
270 | 270 | 'change': function( event ) { |
271 | 271 | // Event filtering |
272 | 272 | switch ( event.type ) { |
273 | | - case 'keypress': |
274 | | - if ( /* TODO: test if something interesting was deleted */ true ) { |
275 | | - event.data.scope = 'keydown'; |
276 | | - } else { |
277 | | - event.data.scope = 'character'; |
278 | | - } |
| 273 | + // We are looking for characters being inserted and deleted one at a time here, and keyp happens after a |
| 274 | + // key has already been pressed and proceesed - it also works the same on all browsers |
| 275 | + case 'keyup': |
| 276 | + // TODO: Test if something was deleted, because if nothing was deleted, we can go with a less |
| 277 | + // resource intensive character level event scope - like: "event.data.scope = 'character'" |
| 278 | + event.data.scope = 'division'; |
279 | 279 | break; |
280 | | - case 'mousedown': // FIXME: mouseup? |
281 | | - if ( /* TODO: test if text was dragged and dropped */ true ) { |
282 | | - event.data.scope = 'division'; |
283 | | - } else { |
284 | | - return false; |
285 | | - } |
286 | | - break; |
287 | | - default: |
| 280 | + // Here we are looking for the user dragging and dropping content around or cutting and pasting |
| 281 | + case 'mouseup': |
| 282 | + case 'paste': |
| 283 | + case 'cut': |
| 284 | + // TODO: Verify our suspicion that something really did change |
288 | 285 | event.data.scope = 'division'; |
289 | 286 | break; |
| 287 | + // When nothing of interest happened, we can go ahead and move on - nothing to see here |
| 288 | + default: break; |
290 | 289 | } |
291 | 290 | return true; |
292 | 291 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js |
— | — | @@ -34,26 +34,13 @@ |
35 | 35 | * ; Definition |
36 | 36 | * : Definition |
37 | 37 | */ |
38 | | - if ( event.data.scope == 'none' ) { |
| 38 | + if ( event.data.scope == 'division' ) { |
39 | 39 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
40 | 40 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
41 | 41 | } |
42 | 42 | }, |
43 | 43 | ready: function( context, event ) { |
44 | | - /* |
45 | | - // Add our CSS to the iframe |
46 | | - // Style version for wikiEditor.highlight.css is here |
47 | | - // FIXME: That's not ideal |
48 | | - context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( { |
49 | | - 'rel': 'stylesheet', |
50 | | - 'type': 'text/css', |
51 | | - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?' + |
52 | | - $.wikiEditor.modules.highlight.cfg.styleVersion, |
53 | | - } ) ); |
54 | | - */ |
55 | 44 | // Highlight stuff for the first time |
56 | | - |
57 | | - |
58 | 45 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
59 | 46 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
60 | 47 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6631,23 +6631,22 @@ |
6632 | 6632 | 'change': function( event ) { |
6633 | 6633 | // Event filtering |
6634 | 6634 | switch ( event.type ) { |
6635 | | - case 'keypress': |
6636 | | - if ( /* TODO: test if something interesting was deleted */ true ) { |
6637 | | - event.data.scope = 'keydown'; |
6638 | | - } else { |
6639 | | - event.data.scope = 'character'; |
6640 | | - } |
| 6635 | + // We are looking for characters being inserted and deleted one at a time here, and keyp happens after a |
| 6636 | + // key has already been pressed and proceesed - it also works the same on all browsers |
| 6637 | + case 'keyup': |
| 6638 | + // TODO: Test if something was deleted, because if nothing was deleted, we can go with a less |
| 6639 | + // resource intensive character level event scope - like: "event.data.scope = 'character'" |
| 6640 | + event.data.scope = 'division'; |
6641 | 6641 | break; |
6642 | | - case 'mousedown': // FIXME: mouseup? |
6643 | | - if ( /* TODO: test if text was dragged and dropped */ true ) { |
6644 | | - event.data.scope = 'division'; |
6645 | | - } else { |
6646 | | - return false; |
6647 | | - } |
6648 | | - break; |
6649 | | - default: |
| 6642 | + // Here we are looking for the user dragging and dropping content around or cutting and pasting |
| 6643 | + case 'mouseup': |
| 6644 | + case 'paste': |
| 6645 | + case 'cut': |
| 6646 | + // TODO: Verify our suspicion that something really did change |
6650 | 6647 | event.data.scope = 'division'; |
6651 | 6648 | break; |
| 6649 | + // When nothing of interest happened, we can go ahead and move on - nothing to see here |
| 6650 | + default: break; |
6652 | 6651 | } |
6653 | 6652 | return true; |
6654 | 6653 | } |
— | — | @@ -7294,26 +7293,13 @@ |
7295 | 7294 | * ; Definition |
7296 | 7295 | * : Definition |
7297 | 7296 | */ |
7298 | | - if ( event.data.scope == 'none' ) { |
| 7297 | + if ( event.data.scope == 'division' ) { |
7299 | 7298 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
7300 | 7299 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
7301 | 7300 | } |
7302 | 7301 | }, |
7303 | 7302 | ready: function( context, event ) { |
7304 | | - /* |
7305 | | - // Add our CSS to the iframe |
7306 | | - // Style version for wikiEditor.highlight.css is here |
7307 | | - // FIXME: That's not ideal |
7308 | | - context.$content.parent().find( 'head' ).append( $j( '<link />' ).attr( { |
7309 | | - 'rel': 'stylesheet', |
7310 | | - 'type': 'text/css', |
7311 | | - 'href': wgScriptPath + '/extensions/UsabilityInitiative/css/wikiEditor.highlight.css?' + |
7312 | | - $.wikiEditor.modules.highlight.cfg.styleVersion, |
7313 | | - } ) ); |
7314 | | - */ |
7315 | 7303 | // Highlight stuff for the first time |
7316 | | - |
7317 | | - |
7318 | 7304 | $.wikiEditor.modules.highlight.fn.scan( context, "" ); |
7319 | 7305 | $.wikiEditor.modules.highlight.fn.mark( context, "", "" ); |
7320 | 7306 | } |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -434,9 +434,7 @@ |
435 | 435 | return src+'?'+wgWikiEditorIconVersion;}};$.fn.wikiEditor=function(){if(!$j.wikiEditor.isSupported()){return $(this);} |
436 | 436 | var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':$.wikiEditor.instances.push($(this))-1};context.api={'addModule':function(context,data){var modules={};if(typeof data=='string'){modules[data]={};}else if(typeof data=='object'){modules=data;} |
437 | 437 | for(module in modules){if(typeof module=='string'&&module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}} |
438 | | -if('fn'in $.wikiEditor.modules[module]&&'create'in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn.create(context,modules[module]);}}}}};context.evt={'change':function(event){switch(event.type){case'keypress':if(true){event.data.scope='keydown';}else{event.data.scope='character';} |
439 | | -break;case'mousedown':if(true){event.data.scope='division';}else{return false;} |
440 | | -break;default:event.data.scope='division';break;} |
| 438 | +if('fn'in $.wikiEditor.modules[module]&&'create'in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn.create(context,modules[module]);}}}}};context.evt={'change':function(event){switch(event.type){case'keyup':event.data.scope='division';break;case'mouseup':case'paste':case'cut':event.data.scope='division';break;default:break;} |
441 | 439 | return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
442 | 440 | if(typeof event.data=='undefined'){event.data={};} |
443 | 441 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
— | — | @@ -475,7 +473,7 @@ |
476 | 474 | 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);});} |
477 | 475 | var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
478 | 476 | 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);} |
479 | | -$(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':3},evt:{delayedChange:function(context,event){if(event.data.scope=='none'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){$.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,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
| 477 | +$(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':3},evt:{delayedChange:function(context,event){if(event.data.scope=='division'){$.wikiEditor.modules.highlight.fn.scan(context,"");$.wikiEditor.modules.highlight.fn.mark(context,"","");}},ready:function(context,event){$.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,match){this.offset=offset;this.label=label;this.tokenStart=tokenStart;this.match=match;} |
480 | 478 | 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;} |
481 | 479 | 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;} |
482 | 480 | tokenArray.push(new Token(match.index+oldOffset+markOffset,label,tokenStart,match));oldOffset+=match.index+match[0].length;newSubstring=text.substring(oldOffset);match=newSubstring.match(regex);}}}} |