Changeset 28942
- Timestamp:
- 2014-03-21T19:20:22+13:00 (10 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/jquery.blockUI.js
r26305 r28942 1 1 /*! 2 2 * jQuery blockUI plugin 3 * Version 2. 50 (04-OCT-2012)4 * @requires jQuery v1.3or later3 * Version 2.66.0-2013.10.09 4 * Requires jQuery v1.7 or later 5 5 * 6 6 * Examples at: http://malsup.com/jquery/block/ 7 * Copyright (c) 2007-201 2M. Alsup7 * Copyright (c) 2007-2013 M. Alsup 8 8 * Dual licensed under the MIT and GPL licenses: 9 9 * http://www.opensource.org/licenses/mit-license.php … … 14 14 15 15 ;(function() { 16 /*jshint eqeqeq:false curly:false latedef:false */ 16 17 "use strict"; 17 18 18 19 function setup($) { 19 if (/^1\.(0|1|2)/.test($.fn.jquery)) {20 /*global alert:true */21 alert('blockUI requires jQuery v1.3 or later! You are using v' + $.fn.jquery);22 return;23 }24 25 20 $.fn._fadeIn = $.fn.fadeIn; 26 21 … … 28 23 29 24 // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle 30 // retardeduserAgent strings on Vista)25 // confusing userAgent strings on Vista) 31 26 var msie = /MSIE/.test(navigator.userAgent); 32 var ie6 = /MSIE 6.0/.test(navigator.userAgent) ;27 var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent); 33 28 var mode = document.documentMode || 0; 34 // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8);35 29 var setExpr = $.isFunction( document.createElement('div').style.setExpression ); 36 30 … … 45 39 if (message) $m.append('<h2>'+message+'</h2>'); 46 40 if (timeout === undefined) timeout = 3000; 47 $.blockUI({ 48 message: $m, fadeIn: 700, fadeOut: 1000, centerY: false, 49 timeout: timeout, showOverlay: false, 50 onUnblock: onClose, 51 css: $.blockUI.defaults.growlCSS 41 42 // Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications 43 var callBlock = function(opts) { 44 opts = opts || {}; 45 46 $.blockUI({ 47 message: $m, 48 fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700, 49 fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000, 50 timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout, 51 centerY: false, 52 showOverlay: false, 53 onUnblock: onClose, 54 css: $.blockUI.defaults.growlCSS 55 }); 56 }; 57 58 callBlock(); 59 var nonmousedOpacity = $m.css('opacity'); 60 $m.mouseover(function() { 61 callBlock({ 62 fadeIn: 0, 63 timeout: 30000 64 }); 65 66 var displayBlock = $('.blockMsg'); 67 displayBlock.stop(); // cancel fadeout if it has started 68 displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency 69 }).mouseout(function() { 70 $('.blockMsg').fadeOut(1000); 52 71 }); 72 // End konapun additions 53 73 }; 54 74 55 75 // plugin method for blocking element content 56 76 $.fn.block = function(opts) { 77 if ( this[0] === window ) { 78 $.blockUI( opts ); 79 return this; 80 } 57 81 var fullOpts = $.extend({}, $.blockUI.defaults, opts || {}); 58 82 this.each(function() { … … 64 88 65 89 return this.each(function() { 66 if ($.css(this,'position') == 'static') 90 if ($.css(this,'position') == 'static') { 67 91 this.style.position = 'relative'; 92 $(this).data('blockUI.static', true); 93 } 68 94 this.style.zoom = 1; // force 'hasLayout' in ie 69 95 install(this, opts); … … 73 99 // plugin method for unblocking element content 74 100 $.fn.unblock = function(opts) { 101 if ( this[0] === window ) { 102 $.unblockUI( opts ); 103 return this; 104 } 75 105 return this.each(function() { 76 106 remove(this, opts); … … 78 108 }; 79 109 80 $.blockUI.version = 2. 50; // 2nd generation blocking at no extra cost!110 $.blockUI.version = 2.66; // 2nd generation blocking at no extra cost! 81 111 82 112 // override these in your code to change the default behavior and style … … 119 149 cursor: 'wait' 120 150 }, 151 152 // style to replace wait cursor before unblocking to correct issue 153 // of lingering wait cursor 154 cursorReset: 'default', 121 155 122 156 // styles applied when using $.growlUI … … 179 213 focusInput: true, 180 214 215 // elements that can receive focus 216 focusableElements: ':input:enabled:visible', 217 181 218 // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) 182 219 // no longer needed in 2012 … … 192 229 onUnblock: null, 193 230 231 // callback method invoked when the overlay area is clicked. 232 // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used. 233 onOverlayClick: null, 234 194 235 // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 195 236 quirksmodeOffsetHack: 4, … … 218 259 opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); 219 260 css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); 261 if (opts.onOverlayClick) 262 opts.overlayCSS.cursor = 'pointer'; 263 220 264 themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); 221 265 msg = msg === undefined ? opts.message : msg; … … 270 314 if ( opts.title ) { 271 315 s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || ' ')+'</div>'; 272 } 316 } 273 317 s += '<div class="ui-widget-content ui-dialog-content"></div>'; 274 318 s += '</div>'; … … 391 435 if (full) { 392 436 pageBlock = lyr3[0]; 393 pageBlockEls = $( ':input:enabled:visible',pageBlock);437 pageBlockEls = $(opts.focusableElements,pageBlock); 394 438 if (opts.focusInput) 395 439 setTimeout(focus, 20); … … 412 456 // remove the block 413 457 function remove(el, opts) { 458 var count; 414 459 var full = (el == window); 415 460 var $el = $(el); … … 434 479 els = $el.find('>.blockUI'); 435 480 481 // fix cursor issue 482 if ( opts.cursorReset ) { 483 if ( els.length > 1 ) 484 els[1].style.cursor = opts.cursorReset; 485 if ( els.length > 2 ) 486 els[2].style.cursor = opts.cursorReset; 487 } 488 436 489 if (full) 437 490 pageBlock = pageBlockEls = null; 438 491 439 492 if (opts.fadeOut) { 440 els.fadeOut(opts.fadeOut); 441 setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut); 493 count = els.length; 494 els.stop().fadeOut(opts.fadeOut, function() { 495 if ( --count === 0) 496 reset(els,data,opts,el); 497 }); 442 498 } 443 499 else … … 447 503 // move blocking element back into the DOM where it started 448 504 function reset(els,data,opts,el) { 505 var $el = $(el); 506 if ( $el.data('blockUI.isBlocked') ) 507 return; 508 449 509 els.each(function(i,o) { 450 510 // remove via DOM calls so we don't lose event handlers … … 458 518 if (data.parent) 459 519 data.parent.appendChild(data.el); 460 $(el).removeData('blockUI.history'); 520 $el.removeData('blockUI.history'); 521 } 522 523 if ($el.data('blockUI.static')) { 524 $el.css('position', 'static'); // #22 461 525 } 462 526 … … 481 545 482 546 // don't bind events when overlay is not in use or if bindEvents is false 483 if (! opts.bindEvents || (b && !opts.showOverlay))547 if (!full || !opts.bindEvents || (b && !opts.showOverlay)) 484 548 return; 485 549 486 550 // bind anchors and inputs for mouse and key events 487 var events = 'mousedown mouseup keydown keypress touchstart touchend touchmove';551 var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove'; 488 552 if (b) 489 553 $(document).bind(events, opts, handler); … … 499 563 function handler(e) { 500 564 // allow tab navigation (conditionally) 501 if (e. keyCode && e.keyCode == 9) {565 if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) { 502 566 if (pageBlock && e.data.constrainTabKey) { 503 567 var els = pageBlockEls; … … 511 575 } 512 576 var opts = e.data; 577 var target = $(e.target); 578 if (target.hasClass('blockOverlay') && opts.onOverlayClick) 579 opts.onOverlayClick(e); 580 513 581 // allow events within the message content 514 if ( $(e.target).parents('div.' + opts.blockMsgClass).length > 0)582 if (target.parents('div.' + opts.blockMsgClass).length > 0) 515 583 return true; 516 584 517 585 // allow events for content that is not being blocked 518 return $(e.target).parents().children().filter('div.blockUI').length === 0;586 return target.parents().children().filter('div.blockUI').length === 0; 519 587 } 520 588
Note:
See TracChangeset
for help on using the changeset viewer.