app/assets/javascripts/semantic-ui/modal.js in semantic-ui-sass-1.8.1.0 vs app/assets/javascripts/semantic-ui/modal.js in semantic-ui-sass-1.11.4.0
- old
+ new
@@ -1,11 +1,11 @@
-/*
- * # Semantic - Modal
+/*!
+ * # Semantic UI - Modal
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2014 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
@@ -118,13 +118,13 @@
$dimmable.dimmer('add content', $module);
}
$dimmer = $dimmable.dimmer('get dimmer');
},
id: function() {
- module.verbose('Creating unique id for element');
- id = module.get.uniqueID();
+ id = (Math.random().toString(16) + '000000000').substr(2,8);
elementNamespace = '.' + id;
+ module.verbose('Creating unique id for element', id);
}
},
destroy: function() {
module.verbose('Destroying previous modal');
@@ -184,21 +184,17 @@
}
},
bind: {
events: function() {
- $close
- .on('click' + eventNamespace, module.event.close)
- ;
- $window
- .on('resize' + elementNamespace, module.event.resize)
- ;
+ $close.on('click' + eventNamespace, module.event.close);
+ $window.on('resize' + elementNamespace, module.event.resize);
}
},
get: {
- uniqueID: function() {
+ id: function() {
return (Math.random().toString(16) + '000000000').substr(2,8);
}
},
event: {
@@ -304,11 +300,11 @@
module.set.position();
module.set.screenHeight();
module.set.type();
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.hideOthers(module.showModal);
}
else {
settings.onShow.call(element);
@@ -349,11 +345,11 @@
else {
module.debug('Modal is already visible');
}
},
- hideModal: function(callback) {
+ hideModal: function(callback, keepDimmed) {
callback = $.isFunction(callback)
? callback
: function(){}
;
module.debug('Hiding modal');
@@ -368,11 +364,11 @@
animation : settings.transition + ' out',
queue : settings.queue,
duration : settings.duration,
useFailSafe : true,
onStart : function() {
- if( !module.othersActive() ) {
+ if(!module.othersActive() && !keepDimmed) {
module.hideDimmer();
}
module.remove.keyboardShortcuts();
},
onComplete : function() {
@@ -424,34 +420,38 @@
return;
}
},
hideAll: function(callback) {
+ var
+ $visibleModals = $allModals.filter(':visible')
+ ;
callback = $.isFunction(callback)
? callback
: function(){}
;
- if( $allModals.is(':visible') ) {
+ if( $visibleModals.length > 0 ) {
module.debug('Hiding all visible modals');
module.hideDimmer();
- $allModals
- .filter(':visible')
- .modal('hide modal', callback)
+ $visibleModals
+ .modal('hide modal', callback)
;
}
},
hideOthers: function(callback) {
+ var
+ $visibleModals = $otherModals.filter(':visible')
+ ;
callback = $.isFunction(callback)
? callback
: function(){}
;
- if( $otherModals.is(':visible') ) {
+ if( $visibleModals.length > 0 ) {
module.debug('Hiding other modals', $otherModals);
- $otherModals
- .filter(':visible')
- .modal('hide modal', callback)
+ $visibleModals
+ .modal('hide modal', callback, true)
;
}
},
othersActive: function() {
@@ -528,11 +528,11 @@
module.debug('Caching modal and container sizes', module.cache);
},
can: {
fit: function() {
- return (module.cache.height < module.cache.contextHeight);
+ return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight);
}
},
is: {
active: function() {
@@ -572,19 +572,19 @@
.on('click' + elementNamespace, module.event.click)
;
}
},
screenHeight: function() {
- if(module.cache.height > module.cache.pageHeight) {
+ if( module.can.fit() ) {
+ $body.css('height', '');
+ }
+ else {
module.debug('Modal is taller than page content, resizing page height');
$body
- .css('height', module.cache.height + settings.padding)
+ .css('height', module.cache.height + (settings.padding / 2) )
;
}
- else {
- $body.css('height', '');
- }
},
active: function() {
$module.addClass(className.active);
},
scrolling: function() {
@@ -785,11 +785,11 @@
}
module.invoke(query);
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
})
;
@@ -825,10 +825,10 @@
duration : 500,
easing : 'easeOutExpo',
offset : 0,
transition : 'scale',
- padding : 30,
+ padding : 50,
onShow : function(){},
onHide : function(){},
onVisible : function(){},