r68845 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68844‎ | r68845 | r68846 >
Date:18:37, 1 July 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: (bug 24216) Fix regression from r68229 causing the second attempt to leave the page not to trigger EditWarning. Solved in a kind of hackish way but it works.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/Vector/Modules/EditWarning/EditWarning.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Vector/Modules/EditWarning/EditWarning.js
@@ -14,6 +14,7 @@
1515 var ourWindowOnBeforeUnload = function() {
1616 var fallbackResult = undefined;
1717 var retval = undefined;
 18+ var thisFunc = arguments.callee;
1819 // Check if someone already set on onbeforeunload hook
1920 if ( fallbackWindowOnBeforeUnload ) {
2021 // Get the result of their onbeforeunload hook
@@ -39,6 +40,10 @@
4041 // Unset the onbeforeunload handler so we don't break page caching in Firefox
4142 window.onbeforeunload = null;
4243 if ( retval !== undefined ) {
 44+ // ...but if the user chooses not to leave the page, we need to rebind it
 45+ setTimeout( function() {
 46+ window.onbeforeunload = thisFunc;
 47+ } );
4348 return retval;
4449 }
4550 };
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
@@ -15,15 +15,15 @@
1616 array( 'src' => 'Modules/CollapsibleNav/CollapsibleNav.js', 'version' => 28 ),
1717 array( 'src' => 'Modules/CollapsibleTabs/CollapsibleTabs.js', 'version' => 8 ),
1818 array( 'src' => 'Modules/ExpandableSearch/ExpandableSearch.js', 'version' => 5 ),
19 - array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 9 ),
 19+ array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 10 ),
2020 array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ),
2121 array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 21 ),
2222 ),
2323 'combined' => array(
24 - array( 'src' => 'Vector.combined.js', 'version' => 63 ),
 24+ array( 'src' => 'Vector.combined.js', 'version' => 64 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'Vector.combined.min.js', 'version' => 64 ),
 27+ array( 'src' => 'Vector.combined.min.js', 'version' => 65 ),
2828 ),
2929 );
3030 static $modules = array(
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -312,6 +312,7 @@
313313 var ourWindowOnBeforeUnload = function() {
314314 var fallbackResult = undefined;
315315 var retval = undefined;
 316+ var thisFunc = arguments.callee;
316317 // Check if someone already set on onbeforeunload hook
317318 if ( fallbackWindowOnBeforeUnload ) {
318319 // Get the result of their onbeforeunload hook
@@ -337,6 +338,10 @@
338339 // Unset the onbeforeunload handler so we don't break page caching in Firefox
339340 window.onbeforeunload = null;
340341 if ( retval !== undefined ) {
 342+ // ...but if the user chooses not to leave the page, we need to rebind it
 343+ setTimeout( function() {
 344+ window.onbeforeunload = thisFunc;
 345+ } );
341346 return retval;
342347 }
343348 };
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js
@@ -15,9 +15,9 @@
1616 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')
1717 $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)
1818 $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());});var fallbackWindowOnBeforeUnload=window.onbeforeunload;var ourWindowOnBeforeUnload=function(){var fallbackResult=undefined;var retval=undefined;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();}
 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;var thisFunc=arguments.callee;if(fallbackWindowOnBeforeUnload){fallbackResult=fallbackWindowOnBeforeUnload();}
2020 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);}
 21+window.onbeforeunload=null;if(retval!==undefined){setTimeout(function(){window.onbeforeunload=thisFunc;});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);}
2222 $j('form').submit(function(){window.onbeforeunload=fallbackWindowOnBeforeUnload;});});var fallbackWindowOnBeforeUnload=null;$j(document).ready(function(){if(!wgVectorEnabledModules.expandablesearch||skin!='vector'){return true;}
2323 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;}
2424 $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;}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68229UsabilityInitiative: (bug 22680) Make EditWarning no longer break Firefox's p...catrope18:28, 18 June 2010

Status & tagging log