HomeHelpTrac

Changeset 15762 for trunk/inc


Ignore:
Timestamp:
12/14/11 19:00:44 (5 months ago)
Author:
Alexander Trofimov
Message:

dolPopup - onHide,onBeforeHide events

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/js/jquery.dolPopup.js

    r15752 r15762  
    1919            onBeforeShow: function () {}, 
    2020            onShow: function () {}, 
     21            onBeforeHide: function () {}, 
     22            onHide: function () {}, 
    2123            speed: 150 
    2224        }; 
     
    7072                $el._dolPopupSetPosition(o); 
    7173 
    72                 // attach event for "close element" 
    73                 if (o.closeElement) { 
    74                     $(o.closeElement, $el) 
    75                         .css('cursor', 'hand') 
    76                         .click(function() { 
    77                             $el.dolPopupHide(); 
    78                         }); 
    79                 } 
    80  
    8174                if (!$el.hasClass('bx-popup-applied')) { // do this only once 
    8275                    $el.addClass('bx-popup-applied'); 
     
    8477                    // save options for element 
    8578                    $el.data('bx-popup-options', o); 
     79 
     80                    // attach event for "close element" 
     81                    if (o.closeElement) { 
     82                        $(o.closeElement, $el) 
     83                            .css('cursor', 'hand') 
     84                            .click(function() { 
     85                                $el.dolPopupHide(); 
     86                            }); 
     87                    } 
    8688 
    8789                    // attach event for outer click checking 
     
    115117    }; 
    116118 
    117     $.fn.dolPopupHide = function(options) { 
    118  
    119         var defaults = { 
    120             onHide: function () {} 
    121         }; 
    122  
    123         var oHide = $.extend({}, defaults, options); 
     119    $.fn.dolPopupHide = function(options) {  
     120 
     121        if ('undefined' == typeof(options) || 'object' != typeof(options)) 
     122            options = {}; 
    124123 
    125124        return this.each(function() { 
     
    129128                return false; 
    130129 
    131             var o = $el.data('bx-popup-options'); 
     130            if (!$el.is(':visible') || 'hidden' == $el.css('visibility') || 'none' == $el.css('display')) 
     131                return false; 
     132 
     133            var o = $.extend({}, $el.data('bx-popup-options'), options); 
    132134 
    133135            if (!o) 
    134136                return false; 
    135137 
    136             if (!$el.is(':visible')) 
    137                 return false; 
     138            o.onBeforeHide(); 
    138139 
    139140            if (o.speed > 0) {                 
    140141                if (o.fog) 
    141142                    $('#bx-popup-fog').fadeOut(o.speed); 
    142                 $el.fadeOut(o.speed, oHide.onHide); 
     143                $el.fadeOut(o.speed, o.onHide); 
    143144            } else {                 
    144145                if (o.fog) 
    145146                    $('#bx-popup-fog').hide(); 
    146                 $el.hide(oHide.onHide); 
     147                $el.hide(o.onHide); 
    147148            } 
    148149        }); 
Note: See TracChangeset for help on using the changeset viewer.