Browse Source

Fixes #239 issue with changes to modal, dimmer close event not destroyed on dimmer on hide

pull/258/head
jlukic 11 years ago
parent
commit
2f2439f446
1 changed files with 28 additions and 13 deletions
  1. 41
      src/modules/modal.js

41
src/modules/modal.js

@ -50,6 +50,7 @@ $.fn.modal = function(parameters) {
$close = $module.find(selector.close), $close = $module.find(selector.close),
$focusedElement, $focusedElement,
$dimmable,
$dimmer, $dimmer,
element = this, element = this,
@ -62,9 +63,12 @@ $.fn.modal = function(parameters) {
initialize: function() { initialize: function() {
module.verbose('Initializing dimmer', $context); module.verbose('Initializing dimmer', $context);
$dimmer = $context
$dimmable = $context
.dimmer('add content', $module) .dimmer('add content', $module)
; ;
$dimmer = $context
.dimmer('get dimmer')
;
module.verbose('Attaching close events', $close); module.verbose('Attaching close events', $close);
$close $close
@ -125,6 +129,13 @@ $.fn.modal = function(parameters) {
module.verbose('Close button pressed'); module.verbose('Close button pressed');
module.hide(); module.hide();
}, },
click: function(event) {
module.verbose('Determining if event occured on dimmer', event);
if( $dimmer.find(event.target).size() === 0 ) {
module.hide();
event.stopImmediatePropagation();
}
},
debounce: function(method, delay) { debounce: function(method, delay) {
clearTimeout(module.timer); clearTimeout(module.timer);
module.timer = setTimeout(method, delay); module.timer = setTimeout(method, delay);
@ -141,7 +152,7 @@ $.fn.modal = function(parameters) {
} }
}, },
resize: function() { resize: function() {
if( $dimmer.dimmer('is active') ) {
if( $dimmable.dimmer('is active') ) {
module.refresh(); module.refresh();
} }
} }
@ -178,12 +189,17 @@ $.fn.modal = function(parameters) {
showDimmer: function() { showDimmer: function() {
module.debug('Showing modal'); module.debug('Showing modal');
module.set.dimmerSettings(); module.set.dimmerSettings();
$dimmer.dimmer('show');
$dimmable.dimmer('show');
}, },
hide: function() { hide: function() {
if( $dimmer.dimmer('is active') ) {
$dimmer.dimmer('hide');
if(settings.closable) {
$dimmer
.off('click' + eventNamespace)
;
}
if( $dimmable.dimmer('is active') ) {
$dimmable.dimmer('hide');
} }
if( module.is.active() ) { if( module.is.active() ) {
module.hideModal(); module.hideModal();
@ -196,7 +212,7 @@ $.fn.modal = function(parameters) {
hideDimmer: function() { hideDimmer: function() {
module.debug('Hiding dimmer'); module.debug('Hiding dimmer');
$dimmer.dimmer('hide');
$dimmable.dimmer('hide');
}, },
hideModal: function() { hideModal: function() {
@ -261,7 +277,7 @@ $.fn.modal = function(parameters) {
; ;
}, },
scrolling: function() { scrolling: function() {
$dimmer.removeClass(className.scrolling);
$dimmable.removeClass(className.scrolling);
$module.removeClass(className.scrolling); $module.removeClass(className.scrolling);
} }
}, },
@ -271,7 +287,7 @@ $.fn.modal = function(parameters) {
height : $module.outerHeight() + settings.offset, height : $module.outerHeight() + settings.offset,
contextHeight : (settings.context == 'body') contextHeight : (settings.context == 'body')
? $(window).height() ? $(window).height()
: $dimmer.height()
: $dimmable.height()
}; };
module.debug('Caching modal and container sizes', module.cache); module.debug('Caching modal and container sizes', module.cache);
}, },
@ -297,14 +313,13 @@ $.fn.modal = function(parameters) {
; ;
if(settings.closable) { if(settings.closable) {
$dimmer $dimmer
.dimmer('get dimmer')
.on('click', module.hide)
.on('click' + eventNamespace, module.event.click)
; ;
} }
}, },
dimmerSettings: function() { dimmerSettings: function() {
module.debug('Setting dimmer settings', $dimmer);
$dimmer
module.debug('Setting dimmer settings', $dimmable);
$dimmable
.dimmer('setting', 'closable', false) .dimmer('setting', 'closable', false)
.dimmer('setting', 'duration', { .dimmer('setting', 'duration', {
show : settings.duration * 0.95, show : settings.duration * 0.95,
@ -317,7 +332,7 @@ $.fn.modal = function(parameters) {
; ;
}, },
scrolling: function() { scrolling: function() {
$dimmer.addClass(className.scrolling);
$dimmable.addClass(className.scrolling);
$module.addClass(className.scrolling); $module.addClass(className.scrolling);
}, },
type: function() { type: function() {

Loading…
Cancel
Save