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' => 138 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 139 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 31 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 49 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 15 ), |
— | — | @@ -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' => 260 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 261 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 260 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 261 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -312,7 +312,7 @@ |
313 | 313 | // Only act if we are switching to a valid state |
314 | 314 | if ( newPosition >= ( context.history.length * -1 ) && newPosition < 0 ) { |
315 | 315 | // Make sure we run the history storing code before we make this change |
316 | | - context.evt.delayedChange( event ); |
| 316 | + context.fn.updateHistory( context.oldDelayedHTML != context.$content.html() ); |
317 | 317 | context.oldDelayedHistoryPosition = context.historyPosition; |
318 | 318 | context.historyPosition = newPosition; |
319 | 319 | // Change state |
— | — | @@ -436,6 +436,11 @@ |
437 | 437 | } |
438 | 438 | }, 0 ); |
439 | 439 | return true; |
| 440 | + }, |
| 441 | + 'ready': function( event ) { |
| 442 | + // Initialize our history queue |
| 443 | + context.history.push( { 'html': context.$content.html(), 'sel': context.fn.getCaretPosition() } ); |
| 444 | + return true; |
440 | 445 | } |
441 | 446 | }; |
442 | 447 | |
— | — | @@ -1392,7 +1397,6 @@ |
1393 | 1398 | // Was text changed? Was it because of a REDO or UNDO action? |
1394 | 1399 | if ( context.history.length == 0 || ( htmlChange && context.oldDelayedHistoryPosition == context.historyPosition ) ) { |
1395 | 1400 | context.fn.purgeOffsets(); |
1396 | | - context.oldDelayedHTML = newHTML; |
1397 | 1401 | context.oldDelayedSel = newSel; |
1398 | 1402 | // Do we need to trim extras from our history? |
1399 | 1403 | // FIXME: this should really be happing on change, not on the delay |
— | — | @@ -1554,8 +1558,6 @@ |
1555 | 1559 | context.$textarea.attr( 'disabled', true ); |
1556 | 1560 | context.$textarea.hide(); |
1557 | 1561 | context.$iframe.show(); |
1558 | | - // Trigger the dealyedChange event to ensure the initial state is stored as our first history state |
1559 | | - context.fn.trigger( 'delayedChange' ); |
1560 | 1562 | // Let modules know we're ready to start working with the content |
1561 | 1563 | context.fn.trigger( 'ready' ); |
1562 | 1564 | // Only save HTML now: ready handlers may have modified it |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6745,7 +6745,7 @@ |
6746 | 6746 | // Only act if we are switching to a valid state |
6747 | 6747 | if ( newPosition >= ( context.history.length * -1 ) && newPosition < 0 ) { |
6748 | 6748 | // Make sure we run the history storing code before we make this change |
6749 | | - context.evt.delayedChange( event ); |
| 6749 | + context.fn.updateHistory( context.oldDelayedHTML != context.$content.html() ); |
6750 | 6750 | context.oldDelayedHistoryPosition = context.historyPosition; |
6751 | 6751 | context.historyPosition = newPosition; |
6752 | 6752 | // Change state |
— | — | @@ -6869,6 +6869,11 @@ |
6870 | 6870 | } |
6871 | 6871 | }, 0 ); |
6872 | 6872 | return true; |
| 6873 | + }, |
| 6874 | + 'ready': function( event ) { |
| 6875 | + // Initialize our history queue |
| 6876 | + context.history.push( { 'html': context.$content.html(), 'sel': context.fn.getCaretPosition() } ); |
| 6877 | + return true; |
6873 | 6878 | } |
6874 | 6879 | }; |
6875 | 6880 | |
— | — | @@ -7825,7 +7830,6 @@ |
7826 | 7831 | // Was text changed? Was it because of a REDO or UNDO action? |
7827 | 7832 | if ( context.history.length == 0 || ( htmlChange && context.oldDelayedHistoryPosition == context.historyPosition ) ) { |
7828 | 7833 | context.fn.purgeOffsets(); |
7829 | | - context.oldDelayedHTML = newHTML; |
7830 | 7834 | context.oldDelayedSel = newSel; |
7831 | 7835 | // Do we need to trim extras from our history? |
7832 | 7836 | // FIXME: this should really be happing on change, not on the delay |
— | — | @@ -7987,8 +7991,6 @@ |
7988 | 7992 | context.$textarea.attr( 'disabled', true ); |
7989 | 7993 | context.$textarea.hide(); |
7990 | 7994 | context.$iframe.show(); |
7991 | | - // Trigger the dealyedChange event to ensure the initial state is stored as our first history state |
7992 | | - context.fn.trigger( 'delayedChange' ); |
7993 | 7995 | // Let modules know we're ready to start working with the content |
7994 | 7996 | context.fn.trigger( 'ready' ); |
7995 | 7997 | // Only save HTML now: ready handlers may have modified it |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -446,7 +446,7 @@ |
447 | 447 | var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':$.wikiEditor.instances.push($(this))-1,'offsets':null,'htmlToTextMap':{},'oldHTML':null,'oldDelayedHTML':null,'oldDelayedSel':null,'savedSelection':null,'history':[],'historyPosition':-1,'oldDelayedHistoryPosition':-1};context.api={'addModule':function(context,data){var modules={};if(typeof data=='string'){modules[data]={};}else if(typeof data=='object'){modules=data;} |
448 | 448 | for(var module in modules){if(typeof module=='string'&&$.wikiEditor.isSupported(module)){if('api'in $.wikiEditor.modules[module]){for(var call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}} |
449 | 449 | 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={'keydown':function(event){switch(event.which){case 90:if((event.ctrlKey||event.metaKey)&&context.history.length){var newPosition;if(event.shiftKey){newPosition=context.historyPosition+1;}else{newPosition=context.historyPosition-1;} |
450 | | -if(newPosition>=(context.history.length*-1)&&newPosition<0){context.evt.delayedChange(event);context.oldDelayedHistoryPosition=context.historyPosition;context.historyPosition=newPosition;context.$content.html(context.history[context.history.length+context.historyPosition].html);context.fn.purgeOffsets();if(context.history[context.history.length+context.historyPosition].sel){context.fn.setSelection({start:context.history[context.history.length+context.historyPosition].sel[0],end:context.history[context.history.length+context.historyPosition].sel[1]});}} |
| 450 | +if(newPosition>=(context.history.length*-1)&&newPosition<0){context.fn.updateHistory(context.oldDelayedHTML!=context.$content.html());context.oldDelayedHistoryPosition=context.historyPosition;context.historyPosition=newPosition;context.$content.html(context.history[context.history.length+context.historyPosition].html);context.fn.purgeOffsets();if(context.history[context.history.length+context.historyPosition].sel){context.fn.setSelection({start:context.history[context.history.length+context.historyPosition].sel[0],end:context.history[context.history.length+context.historyPosition].sel[1]});}} |
451 | 451 | return false;} |
452 | 452 | break;case 9:if(event.ctrlKey||event.altKey||event.shiftKey){return true;}else{var $tabindexList=$j('[tabindex]:visible').sort(function(a,b){return a.tabIndex-b.tabIndex;});for(var i=0;i<$tabindexList.length;i++){if($tabindexList.eq(i).attr('id')==context.$iframe.attr('id')){$tabindexList.get(i+1).focus();break;}} |
453 | 453 | return false;} |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | $selection=context.$content.find(':not(.wikiEditor)');} |
464 | 464 | context.$content.find('.wikiEditor').removeClass('wikiEditor');var t=context.fn.traverser(context.$content);while(t){if(t.node.nodeName=='#text'&&(t.node.nodeValue.indexOf('\n')!=1||t.node.nodeValue.indexOf('\r')!=-1)){t.node.nodeValue=t.node.nodeValue.replace(/\r|\n/g,' ');} |
465 | 465 | t=t.next();} |
466 | | -if($.layout.name!=='webkit'){context.$content.removeClass('pasting');}},0);return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
| 466 | +if($.layout.name!=='webkit'){context.$content.removeClass('pasting');}},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
467 | 467 | if(typeof event.data=='undefined'){event.data={};} |
468 | 468 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
469 | 469 | 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);}} |
— | — | @@ -553,12 +553,12 @@ |
554 | 554 | pos=nextPos+(leavingP?1:0);if(t.node.nodeName=='#text'){lastTextNode=t.node;lastTextNodeDepth=t.depth;} |
555 | 555 | t=nextT;}},'saveSelection':function(){if(!$.browser.msie){return;} |
556 | 556 | context.$iframe[0].contentWindow.focus();context.savedSelection=context.$iframe[0].contentWindow.document.selection.createRange();},'restoreSelection':function(){if(!$.browser.msie||context.savedSelection===null){return;} |
557 | | -context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;},'updateHistory':function(htmlChange){var newHTML=context.$content.html();var newSel=context.fn.getCaretPosition();if(context.history.length==0||(htmlChange&&context.oldDelayedHistoryPosition==context.historyPosition)){context.fn.purgeOffsets();context.oldDelayedHTML=newHTML;context.oldDelayedSel=newSel;if(context.historyPosition<-1){context.history.splice(context.history.length+context.historyPosition+1);context.historyPosition=-1;} |
| 557 | +context.$iframe[0].contentWindow.focus();context.savedSelection.select();context.savedSelection=null;},'updateHistory':function(htmlChange){var newHTML=context.$content.html();var newSel=context.fn.getCaretPosition();if(context.history.length==0||(htmlChange&&context.oldDelayedHistoryPosition==context.historyPosition)){context.fn.purgeOffsets();context.oldDelayedSel=newSel;if(context.historyPosition<-1){context.history.splice(context.history.length+context.historyPosition+1);context.historyPosition=-1;} |
558 | 558 | context.history.push({'html':newHTML,'sel':newSel});while(context.history.length>10){context.history.shift();}}else if(context.oldDelayedSel!=newSel){context.oldDelayedSel=newSel;context.history[context.history.length+context.historyPosition].sel=newSel;} |
559 | 559 | context.oldDelayedHistoryPosition=context.historyPosition;}};context.$textarea.wrapAll($('<div></div>').addClass('wikiEditor-ui')).wrapAll($('<div></div>').addClass('wikiEditor-ui-view wikiEditor-ui-view-wikitext')).wrapAll($('<div></div>').addClass('wikiEditor-ui-left')).wrapAll($('<div></div>').addClass('wikiEditor-ui-bottom')).wrapAll($('<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.fn.setupIframe=function(){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()+'&is=content','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;}} |
560 | 560 | 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 ");}} |
561 | 561 | 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(/<span( | )class=("|")wikiEditor-tab("|")><\/span>/g,'<span class="wikiEditor-tab"></span>').replace(/<p><\/p>/g,'<p><br></p>').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);if($('body').is('.rtl')){context.$content.addClass('rtl').attr('dir','rtl');} |
562 | | -context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('delayedChange');context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(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 paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup 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();}};};} |
| 562 | +context.$textarea.attr('disabled',true);context.$textarea.hide();context.$iframe.show();context.fn.trigger('ready');context.oldHTML=context.oldDelayedHTML=context.$content.html();$(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 paste mouseup cut encapsulateSelection',function(event){return context.fn.trigger('change',event);}).delayedBind(250,'keyup paste mouseup 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();}};};} |
563 | 563 | var args=$.makeArray(arguments);if(typeof context.$iframe==='undefined'&&arguments[0]=='addModule'){var supported=false;for(module in arguments[1]){if($.wikiEditor.isSupported(module)&&module!=='toolbar'){supported=true;}} |
564 | 564 | if(supported){context.fn.setupIframe();}} |
565 | 565 | if(args.length>0){var call=args.shift();if(call in context.api){context.api[call](context,typeof args[0]=='undefined'?{}:args[0]);}} |