Browse Source

#1880 Fixes modal showing while another hiding unsucessfully attaches callback to 'hide others'. Dimmer no longer hides between modals appearances with allowMultiple

pull/1785/merge
jlukic 9 years ago
parent
commit
aac5321d47
2 changed files with 16 additions and 11 deletions
  1. 1
      RELEASE-NOTES.md
  2. 26
      src/definitions/modules/modal.js

1
RELEASE-NOTES.md

@ -9,6 +9,7 @@
- **Form** - `<select>` now receive error formatting on `form error` **Thanks @davialexandre** - **Form** - `<select>` now receive error formatting on `form error` **Thanks @davialexandre**
- **Transition** - Added more reasonable default durations for each animation - **Transition** - Added more reasonable default durations for each animation
- **Loader** - `inline loader` now has a `centered` variation - **Loader** - `inline loader` now has a `centered` variation
- **Modal** - Modal no longer hides and reshows dimmer when opening a modal with another modal open with `exclusive: true`
- **Popup** - Added `exclusive` parameter to automatically close other popups on open - **Popup** - Added `exclusive` parameter to automatically close other popups on open
- **Transition** - Added `toggle` behavior and docs for `show` and `hide` - **Transition** - Added `toggle` behavior and docs for `show` and `hide`
- **Transition** - transition now has `stop`, `stop all`, and `clear queue` for removing transitions, (undocumented method `stop`, and `start` renamed to `enable` and `disable`) - **Transition** - transition now has `stop`, `stop all`, and `clear queue` for removing transitions, (undocumented method `stop`, and `start` renamed to `enable` and `disable`)

26
src/definitions/modules/modal.js

@ -302,7 +302,7 @@ $.fn.modal = function(parameters) {
module.set.type(); module.set.type();
module.set.clickaway(); module.set.clickaway();
if( !settings.allowMultiple && $otherModals.filter(':visible').length > 0) {
if( !settings.allowMultiple && $otherModals.filter('.' + className.active).length > 0) {
module.debug('Other modals visible, queueing show animation'); module.debug('Other modals visible, queueing show animation');
module.hideOthers(module.showModal); module.hideOthers(module.showModal);
} }
@ -347,7 +347,7 @@ $.fn.modal = function(parameters) {
} }
}, },
hideModal: function(callback) {
hideModal: function(callback, keepDimmed) {
callback = $.isFunction(callback) callback = $.isFunction(callback)
? callback ? callback
: function(){} : function(){}
@ -366,7 +366,7 @@ $.fn.modal = function(parameters) {
duration : settings.duration, duration : settings.duration,
useFailSafe : true, useFailSafe : true,
onStart : function() { onStart : function() {
if( !module.othersActive() ) {
if(!module.othersActive() && !keepDimmed) {
module.hideDimmer(); module.hideDimmer();
} }
module.remove.keyboardShortcuts(); module.remove.keyboardShortcuts();
@ -422,30 +422,34 @@ $.fn.modal = function(parameters) {
}, },
hideAll: function(callback) { hideAll: function(callback) {
var
$visibleModals = $allModals.filter(':visible')
;
callback = $.isFunction(callback) callback = $.isFunction(callback)
? callback ? callback
: function(){} : function(){}
; ;
if( $allModals.is(':visible') ) {
if( $visibleModals.length > 0 ) {
module.debug('Hiding all visible modals'); module.debug('Hiding all visible modals');
module.hideDimmer(); module.hideDimmer();
$allModals
.filter(':visible')
.modal('hide modal', callback)
$visibleModals
.modal('hide modal', callback)
; ;
} }
}, },
hideOthers: function(callback) { hideOthers: function(callback) {
var
$visibleModals = $otherModals.filter(':visible')
;
callback = $.isFunction(callback) callback = $.isFunction(callback)
? callback ? callback
: function(){} : function(){}
; ;
if( $otherModals.is(':visible') ) {
if( $visibleModals.length > 0 ) {
module.debug('Hiding other modals', $otherModals); module.debug('Hiding other modals', $otherModals);
$otherModals
.filter(':visible')
.modal('hide modal', callback)
$visibleModals
.modal('hide modal', callback, true)
; ;
} }
}, },

Loading…
Cancel
Save