Browse Source

Modification to modal to account for changes in transition rewrite

pull/474/head
jlukic 11 years ago
parent
commit
cdacbab204
1 changed files with 54 additions and 46 deletions
  1. 100
      src/modules/modal.js

100
src/modules/modal.js

@ -71,9 +71,11 @@ $.fn.modal = function(parameters) {
$dimmable = $context $dimmable = $context
.dimmer({ .dimmer({
closable : false, 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) .dimmer('add content', $module)
; ;
@ -281,18 +283,22 @@ $.fn.modal = function(parameters) {
}, },
hideDimmer: function() { 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'); 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) { hideModal: function(callback) {
@ -300,29 +306,31 @@ $.fn.modal = function(parameters) {
? callback ? callback
: function(){} : 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) { hideAll: function(callback) {
@ -569,13 +577,14 @@ $.fn.modal = function(parameters) {
}, },
invoke: function(query, passedArguments, context) { invoke: function(query, passedArguments, context) {
var var
object = instance,
maxDepth, maxDepth,
found, found,
response response
; ;
passedArguments = passedArguments || queryArguments; passedArguments = passedArguments || queryArguments;
context = element || context; context = element || context;
if(typeof query == 'string' && instance !== undefined) {
if(typeof query == 'string' && object !== undefined) {
query = query.split(/[\. ]/); query = query.split(/[\. ]/);
maxDepth = query.length - 1; maxDepth = query.length - 1;
$.each(query, function(depth, value) { $.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) ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
: query : 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; 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; return false;
} }
else { else {
module.error(error.method, query);
return false; return false;
} }
}); });
@ -648,7 +656,7 @@ $.fn.modal.settings = {
name : 'Modal', name : 'Modal',
namespace : 'modal', namespace : 'modal',
debug : true,
debug : false,
verbose : true, verbose : true,
performance : true, performance : true,

Loading…
Cancel
Save