Changeset 28942


Ignore:
Timestamp:
2014-03-21T19:20:22+13:00 (10 years ago)
Author:
ak19
Message:

When testing on the Win 7 machine with Firefox, the jquery.blockUI.js file caused popups on every page load, because its test for whether the blockUI version was too old was faulty. I downloaded a newer jquery.blockUI.js from malsup.github.io/jquery.blockUI.js. This steps up the version from 2.50 to 2.66. The old version now has a _2.50 suffix in case we ever need to return to it. Dr Bainbridge suggested leaving the file on svn for now along with this descriptive commit comment, as an indicator for what changed and why.

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  
    11/*!
    22 * jQuery blockUI plugin
    3  * Version 2.50 (04-OCT-2012)
    4  * @requires jQuery v1.3 or later
     3 * Version 2.66.0-2013.10.09
     4 * Requires jQuery v1.7 or later
    55 *
    66 * Examples at: http://malsup.com/jquery/block/
    7  * Copyright (c) 2007-2012 M. Alsup
     7 * Copyright (c) 2007-2013 M. Alsup
    88 * Dual licensed under the MIT and GPL licenses:
    99 * http://www.opensource.org/licenses/mit-license.php
     
    1414
    1515;(function() {
     16/*jshint eqeqeq:false curly:false latedef:false */
    1617"use strict";
    1718
    1819    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 
    2520        $.fn._fadeIn = $.fn.fadeIn;
    2621
     
    2823
    2924        // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
    30         // retarded userAgent strings on Vista)
     25        // confusing userAgent strings on Vista)
    3126        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);
    3328        var mode = document.documentMode || 0;
    34         // var setExpr = msie && (($.browser.version < 8 && !mode) || mode < 8);
    3529        var setExpr = $.isFunction( document.createElement('div').style.setExpression );
    3630
     
    4539            if (message) $m.append('<h2>'+message+'</h2>');
    4640            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);
    5271            });
     72            // End konapun additions
    5373        };
    5474
    5575        // plugin method for blocking element content
    5676        $.fn.block = function(opts) {
     77            if ( this[0] === window ) {
     78                $.blockUI( opts );
     79                return this;
     80            }
    5781            var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
    5882            this.each(function() {
     
    6488
    6589            return this.each(function() {
    66                 if ($.css(this,'position') == 'static')
     90                if ($.css(this,'position') == 'static') {
    6791                    this.style.position = 'relative';
     92                    $(this).data('blockUI.static', true);
     93                }
    6894                this.style.zoom = 1; // force 'hasLayout' in ie
    6995                install(this, opts);
     
    7399        // plugin method for unblocking element content
    74100        $.fn.unblock = function(opts) {
     101            if ( this[0] === window ) {
     102                $.unblockUI( opts );
     103                return this;
     104            }
    75105            return this.each(function() {
    76106                remove(this, opts);
     
    78108        };
    79109
    80         $.blockUI.version = 2.50; // 2nd generation blocking at no extra cost!
     110        $.blockUI.version = 2.66; // 2nd generation blocking at no extra cost!
    81111
    82112        // override these in your code to change the default behavior and style
     
    119149                cursor:             'wait'
    120150            },
     151
     152            // style to replace wait cursor before unblocking to correct issue
     153            // of lingering wait cursor
     154            cursorReset: 'default',
    121155
    122156            // styles applied when using $.growlUI
     
    179213            focusInput: true,
    180214
     215            // elements that can receive focus
     216            focusableElements: ':input:enabled:visible',
     217
    181218            // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
    182219            // no longer needed in 2012
     
    192229            onUnblock: null,
    193230
     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
    194235            // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
    195236            quirksmodeOffsetHack: 4,
     
    218259            opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
    219260            css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
     261            if (opts.onOverlayClick)
     262                opts.overlayCSS.cursor = 'pointer';
     263
    220264            themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
    221265            msg = msg === undefined ? opts.message : msg;
     
    270314                if ( opts.title ) {
    271315                    s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
    272                 } 
     316                }
    273317                s += '<div class="ui-widget-content ui-dialog-content"></div>';
    274318                s += '</div>';
     
    391435            if (full) {
    392436                pageBlock = lyr3[0];
    393                 pageBlockEls = $(':input:enabled:visible',pageBlock);
     437                pageBlockEls = $(opts.focusableElements,pageBlock);
    394438                if (opts.focusInput)
    395439                    setTimeout(focus, 20);
     
    412456        // remove the block
    413457        function remove(el, opts) {
     458            var count;
    414459            var full = (el == window);
    415460            var $el = $(el);
     
    434479                els = $el.find('>.blockUI');
    435480
     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
    436489            if (full)
    437490                pageBlock = pageBlockEls = null;
    438491
    439492            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                });
    442498            }
    443499            else
     
    447503        // move blocking element back into the DOM where it started
    448504        function reset(els,data,opts,el) {
     505            var $el = $(el);
     506            if ( $el.data('blockUI.isBlocked') )
     507                return;
     508
    449509            els.each(function(i,o) {
    450510                // remove via DOM calls so we don't lose event handlers
     
    458518                if (data.parent)
    459519                    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
    461525            }
    462526
     
    481545
    482546            // 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))
    484548                return;
    485549
    486550            // 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';
    488552            if (b)
    489553                $(document).bind(events, opts, handler);
     
    499563        function handler(e) {
    500564            // allow tab navigation (conditionally)
    501             if (e.keyCode && e.keyCode == 9) {
     565            if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
    502566                if (pageBlock && e.data.constrainTabKey) {
    503567                    var els = pageBlockEls;
     
    511575            }
    512576            var opts = e.data;
     577            var target = $(e.target);
     578            if (target.hasClass('blockOverlay') && opts.onOverlayClick)
     579                opts.onOverlayClick(e);
     580
    513581            // 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)
    515583                return true;
    516584
    517585            // 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;
    519587        }
    520588
Note: See TracChangeset for help on using the changeset viewer.