fc93190b69646ec2606a08187375d1e31633cf52 tdreszer Fri Sep 3 10:34:21 2010 -0700 Encapulated waitMaskSetup and waitMaskClear to use them with ajaxWait code. Also made sure that waitmask has a timeout. diff --git src/hg/js/utils.js src/hg/js/utils.js index 21f3872..6bc56ca 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -799,6 +799,34 @@ var gWaitFuncArgs = []; var gWaitFunc; +function waitMaskClear() +{ // Clears the waitMask + var waitMask = $('#waitMask'); + if( waitMask != undefined ) + $(waitMask).hide(); +} + +function waitMaskSetup(timeOutInMs) +{ // Sets up the waitMask to block page manipulation until cleared + + // Find or create the waitMask (which masks the whole page) + var waitMask = $('#waitMask'); + if( waitMask == undefined || waitMask.length != 1) { + // create the waitMask + $("body").append("
"); + waitMask = $('#waitMask'); + // Special for IE + if ($.browser.msie) + $(waitMask).css('filter','alpha(opacity= 0)'); + } + $(waitMask).css('display','block'); + + // Things could fail, so always have a timeout. + if(timeOutInMs == undefined || timeOutInMs <=0) + timeOutInMs = 5000; // Don't ever leave this as infinite + setTimeout('waitMaskClear();',timeOutInMs); // Just in case +} + function _launchWaitOnFunction() { // should ONLY be called by waitOnFunction() // Launches the saved function @@ -832,7 +860,7 @@ } } // Now we can get rid of the wait cursor - $('#waitMask').css('display','none'); + waitMaskClear(); } function waitOnFunction(func) @@ -846,17 +874,7 @@ return false; } - // Find or create the waitMask (which masks the whole page) - var waitMask = $('#waitMask'); - if( waitMask == undefined || waitMask.length != 1) { - // create the waitMask - $("body").append("
"); - waitMask = $('#waitMask'); - // Special for IE - if ($.browser.msie) - $(waitMask).css('filter','alpha(opacity= 0)'); - } - $(waitMask).css('display','block'); + waitMaskSetup(5000); // Find or create the waitMask (which masks the whole page) but gives up after 5sec // Special if the first var is a button that can visually be inset if(arguments.length > 1 && arguments[1].type != undefined) {