/*<br /> * jQuery blockUI plugin<br /> * Version 2.10 (10/22/2008)<br /> * @requires jQuery v1.2.3 or later<br /> *<br /> * Examples at: http://malsup.com/jquery/block/<br /> * Copyright (c) 2007-2008 M. Alsup<br /> * Dual licensed under the MIT and GPL licenses:<br /> * http://www.opensource.org/licenses/mit-license.php<br /> * http://www.gnu.org/licenses/gpl.html<br /> *<br /> * Thanks to Amir-Hossein Sobhi for some excellent contributions!<br /> */</p><p>;(function($) {</p><p>if (/1/.(0|1|2)/.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {<br /> alert('blockUI requires jQuery v1.2.3 or later! You are using v' + $.fn.jquery);<br /> return;<br />}</p><p>// global $ methods for blocking/unblocking the entire page<br />$.blockUI = function(opts) { install(window, opts); };<br />$.unblockUI = function(opts) { remove(window, opts); };</p><p>// plugin method for blocking element content<br />$.fn.block = function(opts) {<br /> return this.each(function() {<br /> if ($.css(this,'position') == 'static')<br /> this.style.position = 'relative';<br /> if ($.browser.msie)<br /> this.style.zoom = 1; // force 'hasLayout'<br /> install(this, opts);<br /> });<br />};</p><p>// plugin method for unblocking element content<br />$.fn.unblock = function(opts) {<br /> return this.each(function() {<br /> remove(this, opts);<br /> });<br />};</p><p>$.blockUI.version = 2.09; // 2nd generation blocking at no extra cost!</p><p>// override these in your code to change the default behavior and style<br />$.blockUI.defaults = {<br /> // message displayed when blocking (use null for no message)<br /> message: '<h1>Please wait...</h1>',</p><p> // styles for the message when blocking; if you wish to disable<br /> // these and use an external stylesheet then do this in your code:<br /> // $.blockUI.defaults.css = {};<br /> css: {<br /> padding: 0,<br /> margin: 0,<br /> width: '30%',<br /> top: '25%',<br /> left: '35%',<br /> textAlign: 'center',<br /> color: '#000',<br /> border: '3px solid #aaa',<br /> backgroundColor:'#fff',<br /> cursor: 'wait'<br /> },</p><p> // styles for the overlay<br /> overlayCSS: {<br /> backgroundColor:'#000',<br /> opacity: '0.0'<br /> },</p><p> // z-index for the blocking overlay<br /> baseZ: 1000,</p><p> // set these to true to have the message automatically centered<br /> centerX: true, // <-- only effects element blocking (page block controlled via css above)<br /> centerY: true,</p><p> // allow body element to be stetched in ie6; this makes blocking look better<br /> // on "short" pages. disable if you wish to prevent changes to the body height<br /> allowBodyStretch: true,</p><p> // be default blockUI will supress tab navigation from leaving blocking content;<br /> constrainTabKey: true,</p><p> // fadeOut time in millis; set to 0 to disable fadeout on unblock<br /> fadeOut: 400,</p><p> // if true, focus will be placed in the first available input field when<br /> // page blocking<br /> focusInput: true,</p><p> // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)<br /> applyPlatformOpacityRules: true,</p><p> // callback method invoked when unblocking has completed; the callback is<br /> // passed the element that has been unblocked (which is the window object for page<br /> // blocks) and the options that were passed to the unblock call:<br /> // onUnblock(element, options)<br /> onUnblock: null,</p><p> // don't ask (if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493)<br /> quirksmodeOffsetHack: 4<br />};</p><p>// private data and functions follow...</p><p>var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);<br />var pageBlock = null;<br />var pageBlockEls = [];</p><p>function install(el, opts) {<br /> var full = (el == window);<br /> var msg = opts && opts.message !== undefined ? opts.message : undefined;<br /> opts = $.extend({}, $.blockUI.defaults, opts || {});<br /> opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});<br /> var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});<br /> msg = msg === undefined ? opts.message : msg;</p><p> // remove the current block (if there is one)<br /> if (full && pageBlock)<br /> remove(window, {fadeOut:0}); </p><p> // if an existing element is being used as the blocking content then we capture<br /> // its current place in the DOM (and current display style) so we can restore<br /> // it when we unblock<br /> if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {<br /> var node = msg.jquery ? msg[0] : msg;<br /> var data = {};<br /> $(el).data('blockUI.history', data);<br /> data.el = node;<br /> data.parent = node.parentNode;<br /> data.display = node.style.display;<br /> data.position = node.style.position;<br /> data.parent.removeChild(node);<br /> }</p><p> var z = opts.baseZ;</p><p> // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;<br /> // layer1 is the iframe layer which is used to supress bleed through of underlying content<br /> // layer2 is the overlay layer which has opacity and a wait cursor<br /> // layer3 is the message content that is displayed while blocking</p><p> var lyr1 = ($.browser.msie) ? $('<iframe class="blockUI" style="z-index:'+ z++ +';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;" mce_src="javascript:false;"></iframe>')<br /> : $('<div class="blockUI" style="display:none" mce_style="display:none"></div>');<br /> var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ z++ +';cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');<br /> var lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';position:fixed" mce_style="z-index:'+z+';position:fixed"></div>')<br /> : $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute" mce_style="z-index:'+z+';display:none;position:absolute"></div>');</p><p> // if we have a message, style it<br /> if (msg)<br /> lyr3.css(css);</p><p> // style the overlay<br /> if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))<br /> lyr2.css(opts.overlayCSS);<br /> lyr2.css('position', full ? 'fixed' : 'absolute');</p><p> // make iframe layer transparent in IE<br /> if ($.browser.msie)<br /> lyr1.css('opacity','0.0');</p><p> $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);</p><p> // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)<br /> var expr = $.browser.msie && (!$.boxModel || $('object,embed', full ? null : el).length > 0);<br /> if (ie6 || expr) {<br /> // give body 100% height<br /> if (full && opts.allowBodyStretch && $.boxModel)<br /> $('html,body').css('height','100%');</p><p> // fix ie6 issue when blocked element has a border width<br /> if ((ie6 || !$.boxModel) && !full) {<br /> var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');<br /> var fixT = t ? '(0 - '+t+')' : 0;<br /> var fixL = l ? '(0 - '+l+')' : 0;<br /> }</p><p> // simulate fixed position<br /> $.each([lyr1,lyr2,lyr3], function(i,o) {<br /> var s = o[0].style;<br /> s.position = 'absolute';<br /> if (i < 2) {<br /> full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')<br /> : s.setExpression('height','this.parentNode.offsetHeight + "px"');<br /> full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')<br /> : s.setExpression('width','this.parentNode.offsetWidth + "px"');<br /> if (fixL) s.setExpression('left', fixL);<br /> if (fixT) s.setExpression('top', fixT);<br /> }<br /> else if (opts.centerY) {<br /> if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');<br /> s.marginTop = 0;<br /> }<br /> });<br /> }</p><p> // show the message<br /> lyr3.append(msg).show();<br /> if (msg && (msg.jquery || msg.nodeType))<br /> $(msg).show();</p><p> // bind key and mouse events<br /> bind(1, el, opts);</p><p> if (full) {<br /> pageBlock = lyr3[0];<br /> pageBlockEls = $(':input:enabled:visible',pageBlock);<br /> if (opts.focusInput)<br /> setTimeout(focus, 20);<br /> }<br /> else<br /> center(lyr3[0], opts.centerX, opts.centerY);<br />};</p><p>// remove the block<br />function remove(el, opts) {<br /> var full = el == window;<br /> var data = $(el).data('blockUI.history');<br /> opts = $.extend({}, $.blockUI.defaults, opts || {});<br /> bind(0, el, opts); // unbind events<br /> var els = full ? $('body').children().filter('.blockUI') : $('.blockUI', el);</p><p> if (full)<br /> pageBlock = pageBlockEls = null;</p><p> if (opts.fadeOut) {<br /> els.fadeOut(opts.fadeOut);<br /> setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);<br /> }<br /> else<br /> reset(els, data, opts, el);<br />};</p><p>// move blocking element back into the DOM where it started<br />function reset(els,data,opts,el) {<br /> els.each(function(i,o) {<br /> // remove via DOM calls so we don't lose event handlers<br /> if (this.parentNode)<br /> this.parentNode.removeChild(this);<br /> });<br /> if (data && data.el) {<br /> data.el.style.display = data.display;<br /> data.el.style.position = data.position;<br /> data.parent.appendChild(data.el);<br /> $(data.el).removeData('blockUI.history');<br /> }<br /> if (typeof opts.onUnblock == 'function')<br /> opts.onUnblock(el,opts);<br />};</p><p>// bind/unbind the handler<br />function bind(b, el, opts) {<br /> var full = el == window, $el = $(el);</p><p> // don't bother unbinding if there is nothing to unbind<br /> if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))<br /> return;<br /> if (!full)<br /> $el.data('blockUI.isBlocked', b);</p><p> // bind anchors and inputs for mouse and key events<br /> var events = 'mousedown mouseup keydown keypress click';<br /> b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);</p><p>// former impl...<br />// var $e = $('a,:input');<br />// b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);<br />};</p><p>// event handler to suppress keyboard/mouse events when blocking<br />function handler(e) {<br /> // allow tab navigation (conditionally)<br /> if (e.keyCode && e.keyCode == 9) {<br /> if (pageBlock && e.data.constrainTabKey) {<br /> var els = pageBlockEls;<br /> var fwd = !e.shiftKey && e.target == els[els.length-1];<br /> var back = e.shiftKey && e.target == els[0];<br /> if (fwd || back) {<br /> setTimeout(function(){focus(back)},10);<br /> return false;<br /> }<br /> }<br /> }<br /> // allow events within the message content<br /> if ($(e.target).parents('div.blockMsg').length > 0)<br /> return true;</p><p> // allow events for content that is not being blocked<br /> return $(e.target).parents().children().filter('div.blockUI').length == 0;<br />};</p><p>function focus(back) {<br /> if (!pageBlockEls)<br /> return;<br /> var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];<br /> if (e)<br /> e.focus();<br />};</p><p>function center(el, x, y) {<br /> var p = el.parentNode, s = el.style;<br /> var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');<br /> var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');<br /> if (x) s.left = l > 0 ? (l+'px') : '0';<br /> if (y) s.top = t > 0 ? (t+'px') : '0';<br />};</p><p>function sz(el, p) {<br /> return parseInt($.css(el,p))||0;<br />};</p><p>})(jQuery);<br />