From cdacbab2046d14bee8ecf4aabf43416d618544cb Mon Sep 17 00:00:00 2001 From: jlukic Date: Wed, 25 Dec 2013 12:55:38 -0500 Subject: [PATCH] Modification to modal to account for changes in transition rewrite --- src/modules/modal.js | 100 +++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/src/modules/modal.js b/src/modules/modal.js index 0278c7fcf..3df3c1b6b 100755 --- a/src/modules/modal.js +++ b/src/modules/modal.js @@ -71,9 +71,11 @@ $.fn.modal = function(parameters) { $dimmable = $context .dimmer({ closable : false, - useCSS : module.is.modernBrowser(), - show : settings.duration * 0.9, - hide : settings.duration * 1.1 + useCSS : true, + duration: { + show : settings.duration * 0.9, + hide : settings.duration * 1.1 + } }) .dimmer('add content', $module) ; @@ -281,18 +283,22 @@ $.fn.modal = function(parameters) { }, hideDimmer: function() { - if( module.is.active() ) { - module.debug('Hiding dimmer'); - if(settings.closable) { - $dimmer - .off('click' + eventNamespace) - ; - } - $dimmable.dimmer('hide'); - } - else { + if( !module.is.active() ) { module.debug('Dimmer is not visible cannot hide'); + return; + } + module.debug('Hiding dimmer'); + if(settings.closable) { + $dimmer + .off('click' + eventNamespace) + ; } + $dimmable.dimmer('hide', function() { + $module + .transition('reset') + ; + module.remove.active(); + }); }, hideModal: function(callback) { @@ -300,29 +306,31 @@ $.fn.modal = function(parameters) { ? callback : function(){} ; - if( module.is.active() ) { - module.debug('Hiding modal'); - module.remove.keyboardShortcuts(); - if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { - $module - .transition(settings.transition + ' out', settings.duration, function() { - module.remove.active(); - module.restore.focus(); - callback(); - }) - ; - } - else { - $module - .fadeOut(settings.duration, settings.easing, function() { - module.remove.active(); - module.restore.focus(); - callback(); - }) - ; - } - $.proxy(settings.onHide, element)(); + if( !module.is.active() ) { + module.debug('Cannot hide modal it is not active'); + return; + } + module.debug('Hiding modal'); + module.remove.keyboardShortcuts(); + if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { + $module + .transition(settings.transition + ' out', settings.duration, function() { + module.remove.active(); + module.restore.focus(); + callback(); + }) + ; + } + else { + $module + .fadeOut(settings.duration, settings.easing, function() { + module.remove.active(); + module.restore.focus(); + callback(); + }) + ; } + $.proxy(settings.onHide, element)(); }, hideAll: function(callback) { @@ -569,13 +577,14 @@ $.fn.modal = function(parameters) { }, invoke: function(query, passedArguments, context) { var + object = instance, maxDepth, found, response ; passedArguments = passedArguments || queryArguments; context = element || context; - if(typeof query == 'string' && instance !== undefined) { + if(typeof query == 'string' && object !== undefined) { query = query.split(/[\. ]/); maxDepth = query.length - 1; $.each(query, function(depth, value) { @@ -583,22 +592,21 @@ $.fn.modal = function(parameters) { ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) : query ; - if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) { - instance = instance[camelCaseValue]; + if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { + object = object[camelCaseValue]; } - else if( instance[camelCaseValue] !== undefined ) { - found = instance[camelCaseValue]; + else if( object[camelCaseValue] !== undefined ) { + found = object[camelCaseValue]; return false; } - else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) { - instance = instance[value]; + else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { + object = object[value]; } - else if( instance[value] !== undefined ) { - found = instance[value]; + else if( object[value] !== undefined ) { + found = object[value]; return false; } else { - module.error(error.method, query); return false; } }); @@ -648,7 +656,7 @@ $.fn.modal.settings = { name : 'Modal', namespace : 'modal', - debug : true, + debug : false, verbose : true, performance : true,