PageSourceSearch

https://www.orient-fund.com/javascript/jquery.blockUI.js

js orient-fund.com collected 2026-10-04 10:15:58 UTC 15,567 bytes, 486 lines download raw bytes

1/*!
2 * jQuery blockUI plugin
3 * Version 2.33 (29-MAR-2010)
4 * @requires jQuery v1.2.3 or later
5 *
6 * Examples at: http://malsup.com/jquery/block/
7 * Copyright (c) 2007-2008 M. Alsup
8 * Dual licensed under the MIT and GPL licenses:
9 * http://www.opensource.org/licenses/mit-license.php
10 * http://www.gnu.org/licenses/gpl.html
11 *
12 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
13 */
14
15;(function($) {
16
17if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
18	alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
19	return;
20}
21
22$.fn._fadeIn = $.fn.fadeIn;
23
24var noOp = function() {};
25
26// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
27// retarded userAgent strings on Vista)
28var mode = document.documentMode || 0;
29var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
30var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
31
32// global $ methods for blocking/unblocking the entire page
33$.blockUI   = function(opts) { install(window, opts); };
34$.unblockUI = function(opts) { remove(window, opts); };
35
36// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
37$.growlUI = function(title, message, timeout, onClose) {
38	var $m = $('<div class="growlUI"></div>');
39	if (title) $m.append('<h1>'+title+'</h1>');
40	if (message) $m.append('<h2>'+message+'</h2>');
41	if (timeout == undefined) timeout = 3000;
42	$.blockUI({
43		message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
44		timeout: timeout, showOverlay: false,
45		onUnblock: onClose, 
46		css: $.blockUI.defaults.growlCSS
47	});
48};
49
50// plugin method for blocking element content
51$.fn.block = function(opts) {
52	return this.unblock({ fadeOut: 0 }).each(function() {
53		if ($.css(this,'position') == 'static')
54			this.style.position = 'relative';
55		if ($.browser.msie)
56			this.style.zoom = 1; // force 'hasLayout'
57		install(this, opts);
58	});
59};
60
61// plugin method for unblocking element content
62$.fn.unblock = function(opts) {
63	return this.each(function() {
64		remove(this, opts);
65	});
66};
67
68$.blockUI.version = 2.33; // 2nd generation blocking at no extra cost!
69
70// override these in your code to change the default behavior and style
71$.blockUI.defaults = {
72	// message displayed when blocking (use null for no message)
73	message:  '<h1>Please wait...</h1>',
74
75	title: null,	  // title string; only used when theme == true
76	draggable: true,  // only used when theme == true (requires jquery-ui.js to be loaded)
77	
78	theme: false, // set to true to use with jQuery UI themes
79	
80	// styles for the message when blocking; if you wish to disable
81	// these and use an external stylesheet then do this in your code:
82	// $.blockUI.defaults.css = {};
83	css: {
84		padding:	0,
85		margin:		0,
86		width:		'30%',
87		top:		'40%',
88		left:		'35%',
89		textAlign:	'center',
90		color:		'#000',
91		border:		'3px solid #aaa',
92		backgroundColor:'#fff',
93		cursor:		'wait'
94	},
95	
96	// minimal style set used when themes are used
97	themedCSS: {
98		width:	'30%',
99		top:	'40%',
100		left:	'35%'
101	},
102
103	// styles for the overlay
104	overlayCSS:  {
105		backgroundColor: '#000',
106		opacity:	  	 0.6,
107		cursor:		  	 null
108	},
109
110	// styles applied when using $.growlUI
111	growlCSS: {
112		width:  	'350px',
113		top:		'10px',
114		left:   	'',
115		right:  	'10px',
116		border: 	'none',
117		padding:	'5px',
118		opacity:	0.6,
119		cursor: 	'default',
120		color:		'#fff',
121		backgroundColor: '#000',
122		'-webkit-border-radius': '10px',
123		'-moz-border-radius':	 '10px',
124		'border-radius': 		 '10px'
125	},
126	
127	// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
128	// (hat tip to Jorge H. N. de Vasconcelos)
129	iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
130
131	// force usage of iframe in non-IE browsers (handy for blocking applets)
132	forceIframe: false,
133
134	// z-index for the blocking overlay
135	baseZ: 1000,
136
137	// set these to true to have the message automatically centered
138	centerX: true, // <-- only effects element blocking (page block controlled via css above)
139	centerY: true,
140
141	// allow body element to be stetched in ie6; this makes blocking look better
142	// on "short" pages.  disable if you wish to prevent changes to the body height
143	allowBodyStretch: true,
144
145	// enable if you want key and mouse events to be disabled for content that is blocked
146	bindEvents: true,
147
148	// be default blockUI will supress tab navigation from leaving blocking content
149	// (if bindEvents is true)
150	constrainTabKey: true,
151
152	// fadeIn time in millis; set to 0 to disable fadeIn on block
153	fadeIn:  200,
154
155	// fadeOut time in millis; set to 0 to disable fadeOut on unblock
156	fadeOut:  400,
157
158	// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
159	timeout: 0,
160
161	// disable if you don't want to show the overlay
162	showOverlay: true,
163
164	// if true, focus will be placed in the first available input field when
165	// page blocking
166	focusInput: true,
167
168	// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
169	applyPlatformOpacityRules: true,
170	
171	// callback method invoked when fadeIn has completed and blocking message is visible
172	onBlock: null,
173
174	// callback method invoked when unblocking has completed; the callback is
175	// passed the element that has been unblocked (which is the window object for page
176	// blocks) and the options that were passed to the unblock call:
177	//	 onUnblock(element, options)
178	onUnblock: null,
179
180	// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
181	quirksmodeOffsetHack: 4
182};
183
184// private data and functions follow...
185
186var pageBlock = null;
187var pageBlockEls = [];
188
189function install(el, opts) {
190	var full = (el == window);
191	var msg = opts && opts.message !== undefined ? opts.message : undefined;
192	opts = $.extend({}, $.blockUI.defaults, opts || {});
193	opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
194	var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
195	var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
196	msg = msg === undefined ? opts.message : msg;
197
198	// remove the current block (if there is one)
199	if (full && pageBlock)
200		remove(window, {fadeOut:0});
201
202	// if an existing element is being used as the blocking content then we capture
203	// its current place in the DOM (and current display style) so we can restore
204	// it when we unblock
205	if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
206		var node = msg.jquery ? msg[0] : msg;
207		var data = {};
208		$(el).data('blockUI.history', data);
209		data.el = node;
210		data.parent = node.parentNode;
211		data.display = node.style.display;
212		data.position = node.style.position;
213		if (data.parent)
214			data.parent.removeChild(node);
215	}
216
217	var z = opts.baseZ;
218
219	// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
220	// layer1 is the iframe layer which is used to supress bleed through of underlying content
221	// layer2 is the overlay layer which has opacity and a wait cursor (by default)
222	// layer3 is the message content that is displayed while blocking
223
224	var lyr1 = ($.browser.msie || opts.forceIframe) 
225		? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
226		: $('<div class="blockUI" style="display:none"></div>');
227	var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
228	
229	var lyr3, s;
230	if (opts.theme && full) {
231		s = '<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:fixed">' +
232				'<div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
233				'<div class="ui-widget-content ui-dialog-content"></div>' +
234			'</div>';
235	}
236	else if (opts.theme) {
237		s = '<div class="blockUI blockMsg blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:absolute">' +
238				'<div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
239				'<div class="ui-widget-content ui-dialog-content"></div>' +
240			'</div>';
241	}
242	else if (full) {
243		s = '<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>';
244	}			
245	else {
246		s = '<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>';
247	}
248	lyr3 = $(s);
249
250	// if we have a message, style it
251	if (msg) {
252		if (opts.theme) {
253			lyr3.css(themedCSS);
254			lyr3.addClass('ui-widget-content');
255		}
256		else 
257			lyr3.css(css);
258	}
259
260	// style the overlay
261	if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
262		lyr2.css(opts.overlayCSS);
263	lyr2.css('position', full ? 'fixed' : 'absolute');
264
265	// make iframe layer transparent in IE
266	if ($.browser.msie || opts.forceIframe)
267		lyr1.css('opacity',0.0);
268
269	//$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
270	var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
271	$.each(layers, function() {
272		this.appendTo($par);
273	});
274	
275	if (opts.theme && opts.draggable && $.fn.draggable) {
276		lyr3.draggable({
277			handle: '.ui-dialog-titlebar',
278			cancel: 'li'
279		});
280	}
281
282	// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
283	var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
284	if (ie6 || expr) {
285		// give body 100% height
286		if (full && opts.allowBodyStretch && $.boxModel)
287			$('html,body').css('height','100%');
288
289		// fix ie6 issue when blocked element has a border width
290		if ((ie6 || !$.boxModel) && !full) {
291			var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
292			var fixT = t ? '(0 - '+t+')' : 0;
293			var fixL = l ? '(0 - '+l+')' : 0;
294		}
295
296		// simulate fixed position
297		$.each([lyr1,lyr2,lyr3], function(i,o) {
298			var s = o[0].style;
299			s.position = 'absolute';
300			if (i < 2) {
301				full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quir
301ksmodeOffsetHack+') + "px"')
302					 : s.setExpression('height','this.parentNode.offsetHeight + "px"');
303				full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
304					 : s.setExpression('width','this.parentNode.offsetWidth + "px"');
305				if (fixL) s.setExpression('left', fixL);
306				if (fixT) s.setExpression('top', fixT);
307			}
308			else if (opts.centerY) {
309				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"');
310				s.marginTop = 0;
311			}
312			else if (!opts.centerY && full) {
313				var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
314				var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
315				s.setExpression('top',expression);
316			}
317		});
318	}
319
320	// show the message
321	if (msg) {
322		if (opts.theme)
323			lyr3.find('.ui-widget-content').append(msg);
324		else
325			lyr3.append(msg);
326		if (msg.jquery || msg.nodeType)
327			$(msg).show();
328	}
329
330	if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
331		lyr1.show(); // opacity is zero
332	if (opts.fadeIn) {
333		var cb = opts.onBlock ? opts.onBlock : noOp;
334		var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
335		var cb2 = msg ? cb : noOp;
336		if (opts.showOverlay)
337			lyr2._fadeIn(opts.fadeIn, cb1);
338		if (msg)
339			lyr3._fadeIn(opts.fadeIn, cb2);
340	}
341	else {
342		if (opts.showOverlay)
343			lyr2.show();
344		if (msg)
345			lyr3.show();
346		if (opts.onBlock)
347			opts.onBlock();
348	}
349
350	// bind key and mouse events
351	bind(1, el, opts);
352
353	if (full) {
354		pageBlock = lyr3[0];
355		pageBlockEls = $(':input:enabled:visible',pageBlock);
356		if (opts.focusInput)
357			setTimeout(focus, 20);
358	}
359	else
360		center(lyr3[0], opts.centerX, opts.centerY);
361
362	if (opts.timeout) {
363		// auto-unblock
364		var to = setTimeout(function() {
365			full ? $.unblockUI(opts) : $(el).unblock(opts);
366		}, opts.timeout);
367		$(el).data('blockUI.timeout', to);
368	}
369};
370
371// remove the block
372function remove(el, opts) {
373	var full = (el == window);
374	var $el = $(el);
375	var data = $el.data('blockUI.history');
376	var to = $el.data('blockUI.timeout');
377	if (to) {
378		clearTimeout(to);
379		$el.removeData('blockUI.timeout');
380	}
381	opts = $.extend({}, $.blockUI.defaults, opts || {});
382	bind(0, el, opts); // unbind events
383	
384	var els;
385	if (full) // crazy selector to handle odd field errors in ie6/7
386		els = $('body').children().filter('.blockUI').add('body > .blockUI');
387	else
388		els = $('.blockUI', el);
389
390	if (full)
391		pageBlock = pageBlockEls = null;
392
393	if (opts.fadeOut) {
394		els.fadeOut(opts.fadeOut);
395		setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
396	}
397	else
398		reset(els, data, opts, el);
399};
400
401// move blocking element back into the DOM where it started
402function reset(els,data,opts,el) {
403	els.each(function(i,o) {
404		// remove via DOM calls so we don't lose event handlers
405		if (this.parentNode)
406			this.parentNode.removeChild(this);
407	});
408
409	if (data && data.el) {
410		data.el.style.display = data.display;
411		data.el.style.position = data.position;
412		if (data.parent)
413			data.parent.appendChild(data.el);
414		$(el).removeData('blockUI.history');
415	}
416
417	if (typeof opts.onUnblock == 'function')
418		opts.onUnblock(el,opts);
419};
420
421// bind/unbind the handler
422function bind(b, el, opts) {
423	var full = el == window, $el = $(el);
424
425	// don't bother unbinding if there is nothing to unbind
426	if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
427		return;
428	if (!full)
429		$el.data('blockUI.isBlocked', b);
430
431	// don't bind events when overlay is not in use or if bindEvents is false
432	if (!opts.bindEvents || (b && !opts.showOverlay)) 
433		return;
434
435	// bind anchors and inputs for mouse and key events
436	var events = 'mousedown mouseup keydown keypress';
437	b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);
438
439// former impl...
440//	   var $e = $('a,:input');
441//	   b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
442};
443
444// event handler to suppress keyboard/mouse events when blocking
445function handler(e) {
446	// allow tab navigation (conditionally)
447	if (e.keyCode && e.keyCode == 9) {
448		if (pageBlock && e.data.constrainTabKey) {
449			var els = pageBlockEls;
450			var fwd = !e.shiftKey && e.target == els[els.length-1];
451			var back = e.shiftKey && e.target == els[0];
452			if (fwd || back) {
453				setTimeout(function(){focus(back)},10);
454				return false;
455			}
456		}
457	}
458	// allow events within the message content
459	if ($(e.target).parents('div.blockMsg').length > 0)
460		return true;
461
462	// allow events for content that is not being blocked
463	return $(e.target).parents().children().filter('div.blockUI').length == 0;
464};
465
466function focus(back) {
467	if (!pageBlockEls)
468		return;
469	var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
470	if (e)
471		e.focus();
472};
473
474function center(el, x, y) {
475	var p = el.parentNode, s = el.style;
476	var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
477	var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
478	if (x) s.left = l > 0 ? (l+'px') : '0';
479	if (y) s.top  = t > 0 ? (t+'px') : '0';
480};
481
482function sz(el, p) {
483	return parseInt($.css(el,p))||0;
484};
485
486})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.