Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 112 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 113 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 29 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 47 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 12 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 230 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 231 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 230 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 231 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -365,21 +365,23 @@ |
366 | 366 | context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' ); |
367 | 367 | setTimeout( function() { |
368 | 368 | var $selection = context.$content.find( ':not(.wikiEditor)' ); |
369 | | - while ( $selection.length && $selection.length > 0){ |
| 369 | + while ( $selection.length && $selection.length > 0 ) { |
370 | 370 | var $currentElement = $selection.eq( 0 ); |
371 | 371 | while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) { |
372 | 372 | $currentElement = $currentElement.parent(); |
373 | 373 | } |
374 | | - if($currentElement.is("br")){ |
375 | | - $currentElement.addClass('wikiEditor'); |
376 | | - } |
377 | | - else{ |
378 | | - $("<p></p>").text( $currentElement.text() ).addClass( 'wikiEditor' ).insertAfter( $currentElement ); |
| 374 | + if ( $currentElement.is( 'br' ) ) { |
| 375 | + $currentElement.addClass( 'wikiEditor' ); |
| 376 | + } else { |
| 377 | + $( '<p></p>' ) |
| 378 | + .text( $currentElement.text() ) |
| 379 | + .addClass( 'wikiEditor' ) |
| 380 | + .insertAfter( $currentElement ); |
379 | 381 | $currentElement.remove(); |
380 | 382 | } |
381 | 383 | $selection = context.$content.find( ':not(.wikiEditor)' ); |
382 | | - } |
383 | | - }, 100 ); |
| 384 | + } |
| 385 | + }, 100 ); |
384 | 386 | return true; |
385 | 387 | } |
386 | 388 | }; |
— | — | @@ -503,30 +505,30 @@ |
504 | 506 | // Converting <p>s is wrong if there's nothing before them, so check that. |
505 | 507 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
506 | 508 | $pre.find( 'p' ).each( function() { |
507 | | - var text = $( this ).text(); |
508 | | - // If this <p> is preceded by some text, add a \n at the beginning, and if |
509 | | - // it's followed by a textnode, add a \n at the end |
510 | | - // We need the traverser because there can be other weird stuff in between |
511 | | - |
512 | | - // Check for preceding text |
513 | | - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev(); |
514 | | - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
515 | | - t = t.prev(); |
516 | | - } |
517 | | - if ( t ) { |
518 | | - text = "\n" + text; |
519 | | - } |
520 | | - |
521 | | - // Check for following text |
522 | | - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next(); |
523 | | - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
524 | | - t = t.next(); |
525 | | - } |
526 | | - if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n' |
527 | | - && t.node.nodeValue.charAt( 0 ) != '\r' ) { |
528 | | - text += "\n"; |
529 | | - } |
530 | | - $( this ).text( text ); |
| 509 | + var text = $( this ).text(); |
| 510 | + // If this <p> is preceded by some text, add a \n at the beginning, and if |
| 511 | + // it's followed by a textnode, add a \n at the end |
| 512 | + // We need the traverser because there can be other weird stuff in between |
| 513 | + |
| 514 | + // Check for preceding text |
| 515 | + var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev(); |
| 516 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 517 | + t = t.prev(); |
| 518 | + } |
| 519 | + if ( t ) { |
| 520 | + text = "\n" + text; |
| 521 | + } |
| 522 | + |
| 523 | + // Check for following text |
| 524 | + t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next(); |
| 525 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 526 | + t = t.next(); |
| 527 | + } |
| 528 | + if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n' |
| 529 | + && t.node.nodeValue.charAt( 0 ) != '\r' ) { |
| 530 | + text += "\n"; |
| 531 | + } |
| 532 | + $( this ).text( text ); |
531 | 533 | } ); |
532 | 534 | var retval; |
533 | 535 | if ( $.browser.msie ) { |
— | — | @@ -1285,7 +1287,7 @@ |
1286 | 1288 | .bind( 'keydown', function( event ) { |
1287 | 1289 | return context.fn.trigger( 'keydown', event ); |
1288 | 1290 | } ) |
1289 | | - .bind( 'paste', function( event ){ |
| 1291 | + .bind( 'paste', function( event ) { |
1290 | 1292 | return context.fn.trigger( 'paste', event ); |
1291 | 1293 | } ) |
1292 | 1294 | .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) { |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6706,6 +6706,7 @@ |
6707 | 6707 | * processing of events which did not actually change the content of the iframe. |
6708 | 6708 | */ |
6709 | 6709 | 'keydown': function( event ) { |
| 6710 | + |
6710 | 6711 | switch ( event.which ) { |
6711 | 6712 | case 90: // z |
6712 | 6713 | if ( ( event.ctrlKey || event.metaKey ) && context.history.length ) { |
— | — | @@ -6792,6 +6793,29 @@ |
6793 | 6794 | } |
6794 | 6795 | } |
6795 | 6796 | return true; |
| 6797 | + }, |
| 6798 | + 'paste': function( event ) { |
| 6799 | + context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' ); |
| 6800 | + setTimeout( function() { |
| 6801 | + var $selection = context.$content.find( ':not(.wikiEditor)' ); |
| 6802 | + while ( $selection.length && $selection.length > 0 ) { |
| 6803 | + var $currentElement = $selection.eq( 0 ); |
| 6804 | + while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) { |
| 6805 | + $currentElement = $currentElement.parent(); |
| 6806 | + } |
| 6807 | + if ( $currentElement.is( 'br' ) ) { |
| 6808 | + $currentElement.addClass( 'wikiEditor' ); |
| 6809 | + } else { |
| 6810 | + $( '<p></p>' ) |
| 6811 | + .text( $currentElement.text() ) |
| 6812 | + .addClass( 'wikiEditor' ) |
| 6813 | + .insertAfter( $currentElement ); |
| 6814 | + $currentElement.remove(); |
| 6815 | + } |
| 6816 | + $selection = context.$content.find( ':not(.wikiEditor)' ); |
| 6817 | + } |
| 6818 | + }, 100 ); |
| 6819 | + return true; |
6796 | 6820 | } |
6797 | 6821 | }; |
6798 | 6822 | |
— | — | @@ -6914,30 +6938,30 @@ |
6915 | 6939 | // Converting <p>s is wrong if there's nothing before them, so check that. |
6916 | 6940 | // .find( '* + p' ) isn't good enough because textnodes aren't considered |
6917 | 6941 | $pre.find( 'p' ).each( function() { |
6918 | | - var text = $( this ).text(); |
6919 | | - // If this <p> is preceded by some text, add a \n at the beginning, and if |
6920 | | - // it's followed by a textnode, add a \n at the end |
6921 | | - // We need the traverser because there can be other weird stuff in between |
6922 | | - |
6923 | | - // Check for preceding text |
6924 | | - var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev(); |
6925 | | - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
6926 | | - t = t.prev(); |
6927 | | - } |
6928 | | - if ( t ) { |
6929 | | - text = "\n" + text; |
6930 | | - } |
6931 | | - |
6932 | | - // Check for following text |
6933 | | - t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next(); |
6934 | | - while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
6935 | | - t = t.next(); |
6936 | | - } |
6937 | | - if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n' |
6938 | | - && t.node.nodeValue.charAt( 0 ) != '\r' ) { |
6939 | | - text += "\n"; |
6940 | | - } |
6941 | | - $( this ).text( text ); |
| 6942 | + var text = $( this ).text(); |
| 6943 | + // If this <p> is preceded by some text, add a \n at the beginning, and if |
| 6944 | + // it's followed by a textnode, add a \n at the end |
| 6945 | + // We need the traverser because there can be other weird stuff in between |
| 6946 | + |
| 6947 | + // Check for preceding text |
| 6948 | + var t = new context.fn.rawTraverser( this.firstChild, 0, this, $pre.get( 0 ) ).prev(); |
| 6949 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 6950 | + t = t.prev(); |
| 6951 | + } |
| 6952 | + if ( t ) { |
| 6953 | + text = "\n" + text; |
| 6954 | + } |
| 6955 | + |
| 6956 | + // Check for following text |
| 6957 | + t = new context.fn.rawTraverser( this.lastChild, 0, this, $pre.get( 0 ) ).next(); |
| 6958 | + while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) { |
| 6959 | + t = t.next(); |
| 6960 | + } |
| 6961 | + if ( t && !t.inP && t.node.nodeName == '#text' && t.node.nodeValue.charAt( 0 ) != '\n' |
| 6962 | + && t.node.nodeValue.charAt( 0 ) != '\r' ) { |
| 6963 | + text += "\n"; |
| 6964 | + } |
| 6965 | + $( this ).text( text ); |
6942 | 6966 | } ); |
6943 | 6967 | var retval; |
6944 | 6968 | if ( $.browser.msie ) { |
— | — | @@ -7696,6 +7720,9 @@ |
7697 | 7721 | .bind( 'keydown', function( event ) { |
7698 | 7722 | return context.fn.trigger( 'keydown', event ); |
7699 | 7723 | } ) |
| 7724 | + .bind( 'paste', function( event ) { |
| 7725 | + return context.fn.trigger( 'paste', event ); |
| 7726 | + } ) |
7700 | 7727 | .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) { |
7701 | 7728 | return context.fn.trigger( 'change', event ); |
7702 | 7729 | } ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -454,7 +454,9 @@ |
455 | 455 | switch(event.which){case 8:break;} |
456 | 456 | return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;event.data.scope='realchange';if(newHTML!==context.history[context.history.length+context.historyPosition].html){context.historyPosition=-1;} |
457 | 457 | context.history.push({'html':newHTML});while(context.history.length>10){context.history.shift();}} |
458 | | -return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
| 458 | +return true;},'paste':function(event){context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');setTimeout(function(){var $selection=context.$content.find(':not(.wikiEditor)');while($selection.length&&$selection.length>0){var $currentElement=$selection.eq(0);while(!$currentElement.parent().is('body')&&!$currentElement.parent().is('.wikiEditor')){$currentElement=$currentElement.parent();} |
| 459 | +if($currentElement.is('br')){$currentElement.addClass('wikiEditor');}else{$('<p></p>').text($currentElement.text()).addClass('wikiEditor').insertAfter($currentElement);$currentElement.remove();} |
| 460 | +$selection=context.$content.find(':not(.wikiEditor)');}},100);return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
459 | 461 | if(typeof event.data=='undefined'){event.data={};} |
460 | 462 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
461 | 463 | for(var module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){$.wikiEditor.modules[module].evt[name](context,event);}} |
— | — | @@ -528,7 +530,7 @@ |
529 | 531 | context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;}};context.$textarea.wrap($('<div></div>').addClass('wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrap($('<div></div>').addClass('wikiEditor-ui-left')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text'));context.$ui=context.$textarea.parent().parent().parent().parent().parent();context.$wikitext=context.$textarea.parent().parent().parent().parent();context.$wikitext.before($('<div></div>').addClass('wikiEditor-ui-controls').append($('<div></div>').addClass('wikiEditor-ui-tabs').hide()).append($('<div></div>').addClass('wikiEditor-ui-buttons'))).before($('<div style="clear:both;"></div>'));context.$controls=context.$ui.find('.wikiEditor-ui-buttons').hide();context.$buttons=context.$ui.find('.wikiEditor-ui-buttons');context.$tabs=context.$ui.find('.wikiEditor-ui-tabs');context.$ui.after($('<div style="clear:both;"></div>'));context.$wikitext.append($('<div></div>').addClass('wikiEditor-ui-right'));context.$wikitext.find('.wikiEditor-ui-left').prepend($('<div></div>').addClass('wikiEditor-ui-top'));context.view='wikitext';$(window).resize(function(event){context.fn.trigger('resize',event);});context.$iframe=$('<iframe></iframe>').attr({'frameBorder':0,'border':0,'tabindex':1,'src':wgScriptPath+'/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.html?'+'instance='+context.instance+'&ts='+(new Date()).getTime(),'id':'wikiEditor-iframe-'+context.instance}).css({'backgroundColor':'white','width':'100%','height':context.$textarea.height(),'display':'none','overflow-y':'scroll','overflow-x':'hidden'}).insertAfter(context.$textarea).load(function(){if(!this.isSecondRun){context.$iframe[0].contentWindow.document.designMode='on';if($.browser.msie){this.isSecondRun=true;return;}} |
530 | 532 | context.$content=$(context.$iframe[0].contentWindow.document.body);var html=context.$textarea.val().replace(/&esc;/g,'&esc;esc;').replace(/\<p\>/g,'&esc;<p>').replace(/\<\/p\>/g,'&esc;</p>').replace(/\<span class="wikiEditor-tab"\>\<\/span\>/g,'&esc;<span class="wikiEditor-tab"></span>').replace(/ /g,'&esc;&nbsp;');if($.browser.msie){html=html.replace(/\t/g,'<span class="wikiEditor-tab"></span>');if($.browser.versionNumber<=7){html=html.replace(/ /g," ");}else{html=html.replace(/(^|\n) /g,"$1 ");}} |
531 | 533 | html=$('<div />').text('<p>'+html.replace(/\r?\n/g,'</p><p>')+'</p>').html().replace(/&nbsp;/g,' ').replace(/<p>/g,'<p>').replace(/<\/p>/g,'</p>').replace(/<p><\/p>/g,'<br>').replace(/&esc;&amp;nbsp;/g,'&nbsp;').replace(/&esc;&lt;p&gt;/g,'<p>').replace(/&esc;&lt;\/p&gt;/g,'</p>').replace(/&esc;&lt;span&nbsp;class=&quot;wikiEditor-tab&quot;&gt;&lt;\/span&gt;/g,'<span class="wikiEditor-tab"><\/span>').replace(/&esc;esc;/g,'&esc;');context.$content.html(html);context.oldHTML=html;context.history.push({'html':html});if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
532 | | -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('keyup mouseup paste cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};} |
| 534 | +context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');$(context.$iframe[0].contentWindow.document).bind('keydown',function(event){return context.fn.trigger('keydown',event);}).bind('paste',function(event){return context.fn.trigger('paste',event);}).bind('keyup mouseup paste cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup mouseup paste cut encapsulateSelection',function(event){context.fn.trigger('delayedChange',event);});});context.$textarea.closest('form').submit(function(){context.$textarea.attr('disabled',false);context.$textarea.val(context.$textarea.textSelection('getContents'));});context.fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){context.$textarea.val(context.$textarea.textSelection('getContents'));if(context.fallbackWindowOnBeforeUnload){return context.fallbackWindowOnBeforeUnload();}};} |
533 | 535 | var args=$.makeArray(arguments);if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}} |
534 | 536 | return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,data)},openDialog:function(context,module){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('open');}},closeDialog:function(context,data){if(module in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[module].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];} |
535 | 537 | mw.usability.load(['$j.ui','$j.ui.dialog','$j.ui.draggable','$j.ui.resizable'],function(){for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');configuration.newButtons={};for(msg in configuration.buttons) |