Index: trunk/extensions/UsabilityInitiative/Vector/Modules/EditWarning/EditWarning.js |
— | — | @@ -10,9 +10,10 @@ |
11 | 11 | $j(this).data( 'origtext', $j(this).val() ); |
12 | 12 | }); |
13 | 13 | // Attach our own handler for onbeforeunload which respects the current one |
14 | | - fallbackWindowOnBeforeUnload = window.onbeforeunload; |
15 | | - window.onbeforeunload = function() { |
| 14 | + var fallbackWindowOnBeforeUnload = window.onbeforeunload; |
| 15 | + var ourWindowOnBeforeUnload = function() { |
16 | 16 | var fallbackResult = undefined; |
| 17 | + var retval = undefined; |
17 | 18 | // Check if someone already set on onbeforeunload hook |
18 | 19 | if ( fallbackWindowOnBeforeUnload ) { |
19 | 20 | // Get the result of their onbeforeunload hook |
— | — | @@ -21,19 +22,37 @@ |
22 | 23 | // Check if their onbeforeunload hook returned something |
23 | 24 | if ( fallbackResult !== undefined ) { |
24 | 25 | // Exit here, returning their message |
25 | | - return fallbackResult; |
| 26 | + retval = fallbackResult; |
| 27 | + } else { |
| 28 | + // Check if the current values of some form elements are the same as |
| 29 | + // the original values |
| 30 | + if ( |
| 31 | + wgAction == 'submit' || |
| 32 | + $j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val() || |
| 33 | + $j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val() |
| 34 | + ) { |
| 35 | + // Return our message |
| 36 | + retval = mw.usability.getMsg( 'vector-editwarning-warning' ); |
| 37 | + } |
26 | 38 | } |
27 | | - // Check if the current values of some form elements are the same as |
28 | | - // the original values |
29 | | - if( |
30 | | - wgAction == 'submit' || |
31 | | - $j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val() || |
32 | | - $j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val() |
33 | | - ) { |
34 | | - // Return our message |
35 | | - return mw.usability.getMsg( 'vector-editwarning-warning' ); |
| 39 | + |
| 40 | + // Unset the onbeforeunload handler so we don't break page caching in Firefox |
| 41 | + window.onbeforeunload = null; |
| 42 | + if ( retval !== undefined ) { |
| 43 | + return retval; |
36 | 44 | } |
| 45 | + }; |
| 46 | + var pageShowHandler = function() { |
| 47 | + // Re-add onbeforeunload handler |
| 48 | + window.onbeforeunload = ourWindowOnBeforeUnload; |
| 49 | + }; |
| 50 | + pageShowHandler(); |
| 51 | + if ( window.addEventListener ) { |
| 52 | + window.addEventListener('pageshow', pageShowHandler, false); |
| 53 | + } else if ( window.attachEvent ) { |
| 54 | + window.attachEvent( 'pageshow', pageShowHandler ); |
37 | 55 | } |
| 56 | + |
38 | 57 | // Add form submission handler |
39 | 58 | $j( 'form' ).submit( function() { |
40 | 59 | // Restore whatever previous onbeforeload hook existed |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php |
— | — | @@ -15,15 +15,15 @@ |
16 | 16 | array( 'src' => 'Modules/CollapsibleNav/CollapsibleNav.js', 'version' => 25 ), |
17 | 17 | array( 'src' => 'Modules/CollapsibleTabs/CollapsibleTabs.js', 'version' => 8 ), |
18 | 18 | array( 'src' => 'Modules/ExpandableSearch/ExpandableSearch.js', 'version' => 5 ), |
19 | | - array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ), |
| 19 | + array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 9 ), |
20 | 20 | array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ), |
21 | 21 | array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 18 ), |
22 | 22 | ), |
23 | 23 | 'combined' => array( |
24 | | - array( 'src' => 'Vector.combined.js', 'version' => 55 ), |
| 24 | + array( 'src' => 'Vector.combined.js', 'version' => 56 ), |
25 | 25 | ), |
26 | 26 | 'minified' => array( |
27 | | - array( 'src' => 'Vector.combined.min.js', 'version' => 56 ), |
| 27 | + array( 'src' => 'Vector.combined.min.js', 'version' => 57 ), |
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | static $modules = array( |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js |
— | — | @@ -308,9 +308,10 @@ |
309 | 309 | $j(this).data( 'origtext', $j(this).val() ); |
310 | 310 | }); |
311 | 311 | // Attach our own handler for onbeforeunload which respects the current one |
312 | | - fallbackWindowOnBeforeUnload = window.onbeforeunload; |
313 | | - window.onbeforeunload = function() { |
| 312 | + var fallbackWindowOnBeforeUnload = window.onbeforeunload; |
| 313 | + var ourWindowOnBeforeUnload = function() { |
314 | 314 | var fallbackResult = undefined; |
| 315 | + var retval = undefined; |
315 | 316 | // Check if someone already set on onbeforeunload hook |
316 | 317 | if ( fallbackWindowOnBeforeUnload ) { |
317 | 318 | // Get the result of their onbeforeunload hook |
— | — | @@ -319,19 +320,37 @@ |
320 | 321 | // Check if their onbeforeunload hook returned something |
321 | 322 | if ( fallbackResult !== undefined ) { |
322 | 323 | // Exit here, returning their message |
323 | | - return fallbackResult; |
| 324 | + retval = fallbackResult; |
| 325 | + } else { |
| 326 | + // Check if the current values of some form elements are the same as |
| 327 | + // the original values |
| 328 | + if ( |
| 329 | + wgAction == 'submit' || |
| 330 | + $j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val() || |
| 331 | + $j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val() |
| 332 | + ) { |
| 333 | + // Return our message |
| 334 | + retval = mw.usability.getMsg( 'vector-editwarning-warning' ); |
| 335 | + } |
324 | 336 | } |
325 | | - // Check if the current values of some form elements are the same as |
326 | | - // the original values |
327 | | - if( |
328 | | - wgAction == 'submit' || |
329 | | - $j( '#wpTextbox1' ).data( 'origtext' ) != $j( '#wpTextbox1' ).val() || |
330 | | - $j( '#wpSummary' ).data( 'origtext' ) != $j( '#wpSummary' ).val() |
331 | | - ) { |
332 | | - // Return our message |
333 | | - return mw.usability.getMsg( 'vector-editwarning-warning' ); |
| 337 | + |
| 338 | + // Unset the onbeforeunload handler so we don't break page caching in Firefox |
| 339 | + window.onbeforeunload = null; |
| 340 | + if ( retval !== undefined ) { |
| 341 | + return retval; |
334 | 342 | } |
| 343 | + }; |
| 344 | + var pageShowHandler = function() { |
| 345 | + // Re-add onbeforeunload handler |
| 346 | + window.onbeforeunload = ourWindowOnBeforeUnload; |
| 347 | + }; |
| 348 | + pageShowHandler(); |
| 349 | + if ( window.addEventListener ) { |
| 350 | + window.addEventListener('pageshow', pageShowHandler, false); |
| 351 | + } else if ( window.attachEvent ) { |
| 352 | + window.attachEvent( 'pageshow', pageShowHandler ); |
335 | 353 | } |
| 354 | + |
336 | 355 | // Add form submission handler |
337 | 356 | $j( 'form' ).submit( function() { |
338 | 357 | // Restore whatever previous onbeforeload hook existed |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js |
— | — | @@ -15,9 +15,9 @@ |
16 | 16 | var rtl=$j('body').is('.rtl');$j.collapsibleTabs.moveToCollapsed=function(ele){var $moving=$j(ele);$j.collapsibleTabs.getSettings($j($j.collapsibleTabs.getSettings($moving).expandedContainer)).shifting=true;var data=$j.collapsibleTabs.getSettings($moving);var target=data.collapsedContainer;$moving.css("position","relative").css((rtl?'left':'right'),0).animate({width:'1px'},"normal",function(){$j(this).hide();$j('<span class="placeholder" style="display:none;"></span>').insertAfter(this);$j(this).remove().prependTo(target).data('collapsibleTabsSettings',data);$j(this).attr('style','display:list-item;');$j.collapsibleTabs.getSettings($j($j.collapsibleTabs.getSettings($j(ele)).expandedContainer)).shifting=false;$j.collapsibleTabs.handleResize();});};$j.collapsibleTabs.moveToExpanded=function(ele){var $moving=$j(ele);$j.collapsibleTabs.getSettings($j($j.collapsibleTabs.getSettings($moving).expandedContainer)).shifting=true;var data=$j.collapsibleTabs.getSettings($moving);var $target=$j(data.expandedContainer).find('span.placeholder:first');var expandedWidth=data.expandedWidth;$moving.css("position","relative").css((rtl?'right':'left'),0).css('width','1px');$target.replaceWith($moving.remove().css('width','1px').data('collapsibleTabsSettings',data).animate({width:expandedWidth+"px"},"normal",function(){$j(this).attr('style','display:block;');$j.collapsibleTabs.getSettings($j($j.collapsibleTabs.getSettings($moving).expandedContainer)).shifting=false;$j.collapsibleTabs.handleResize();}));};$j('#p-views ul').bind("beforeTabCollapse",function(){if($j('#p-cactions').css('display')=='none') |
17 | 17 | $j("#p-cactions").addClass("filledPortlet").removeClass("emptyPortlet").find('h5').css('width','1px').animate({'width':'26px'},390);}).bind("beforeTabExpand",function(){if($j('#p-cactions li').length==1) |
18 | 18 | $j("#p-cactions h5").animate({'width':'1px'},370,function(){$j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");});}).collapsibleTabs({expandCondition:function(eleWidth){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width()+1)<($j('#left-navigation').position().left-eleWidth);}else{return($j('#left-navigation').position().left+$j('#left-navigation').width()+1)<($j('#right-navigation').position().left-eleWidth);}},collapseCondition:function(){if(rtl){return($j('#right-navigation').position().left+$j('#right-navigation').width())>$j('#left-navigation').position().left;}else{return($j('#left-navigation').position().left+$j('#left-navigation').width())>$j('#right-navigation').position().left;}}});});$j(document).ready(function(){if(!wgVectorEnabledModules.editwarning||$j('#wpTextbox1').size()==0){return true;} |
19 | | -$j('#wpTextbox1, #wpSummary').each(function(){$j(this).data('origtext',$j(this).val());});fallbackWindowOnBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){var fallbackResult=undefined;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();} |
20 | | -if(fallbackResult!==undefined){return fallbackResult;} |
21 | | -if(wgAction=='submit'||$j('#wpTextbox1').data('origtext')!=$j('#wpTextbox1').val()||$j('#wpSummary').data('origtext')!=$j('#wpSummary').val()){return mw.usability.getMsg('vector-editwarning-warning');}} |
| 19 | +$j('#wpTextbox1, #wpSummary').each(function(){$j(this).data('origtext',$j(this).val());});var fallbackWindowOnBeforeUnload=window.onbeforeunload;var ourWindowOnBeforeUnload=function(){var fallbackResult=undefined;var retval=undefined;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();} |
| 20 | +if(fallbackResult!==undefined){retval=fallbackResult;}else{if(wgAction=='submit'||$j('#wpTextbox1').data('origtext')!=$j('#wpTextbox1').val()||$j('#wpSummary').data('origtext')!=$j('#wpSummary').val()){retval=mw.usability.getMsg('vector-editwarning-warning');}} |
| 21 | +window.onbeforeunload=null;if(retval!==undefined){return retval;}};var pageShowHandler=function(){window.onbeforeunload=ourWindowOnBeforeUnload;};pageShowHandler();if(window.addEventListener){window.addEventListener('pageshow',pageShowHandler,false);}else if(window.attachEvent){window.attachEvent('pageshow',pageShowHandler);} |
22 | 22 | $j('form').submit(function(){window.onbeforeunload=fallbackWindowOnBeforeUnload;});});var fallbackWindowOnBeforeUnload=null;$j(document).ready(function(){if(!wgVectorEnabledModules.expandablesearch||skin!='vector'){return true;} |
23 | 23 | var map={'ltr':{'msie':[['>=',8]],'blackberry':false,'ipod':false,'iphone':false,'ps3':false},'rtl':{'msie':[['>=',8]],'blackberry':false,'ipod':false,'iphone':false,'ps3':false}};if(!mw.usability.testBrowser(map)){return true;} |
24 | 24 | $j('#searchInput').expandableField({'beforeExpand':function(context){$j(this).parent().animate({'borderTopColor':'#a0d8ff','borderLeftColor':'#a0d8ff','borderRightColor':'#a0d8ff','borderBottomColor':'#a0d8ff'},'fast');},'beforeCondense':function(context){$j(this).parent().animate({'borderTopColor':'#aaaaaa','borderLeftColor':'#aaaaaa','borderRightColor':'#aaaaaa','borderBottomColor':'#aaaaaa'},'fast');},'afterExpand':function(context){if(typeof $j.collapsibleTabs!='undefined'){$j.collapsibleTabs.handleResize();}},'afterCondense':function(context){if(typeof $j.collapsibleTabs!='undefined'){$j.collapsibleTabs.handleResize();}},'expandToLeft':!$j('body').is('.rtl')}).css('float',$j('body').is('.rtl')?'right':'left').siblings('button').css('float',$j('body').is('.rtl')?'right':'left');});$j(document).ready(function(){if(!wgVectorEnabledModules.footercleanup){return true;} |