Browse Source

Merge branch 'master' of https://github.com/Knotix/Semantic-UI

pull/881/head
jlukic 10 years ago
parent
commit
7f7aaf6785
2 changed files with 82 additions and 65 deletions
  1. 19
      server/documents/modules/modal.html.eco
  2. 128
      src/modules/modal.js

19
server/documents/modules/modal.html.eco

@ -365,31 +365,38 @@ type : 'UI Module'
<tr>
<td>detachable</td>
<td>true</td>
<td>If set to false will prevent the modal from being moved to inside the dimmer</td>
<td>Setting to to false will prevent the modal from being removed from the DOM and appended to the dimmer</td>
</tr>
<tr>
<td>allowMultiple</td>
<td>false</td>
<td>If set to true will not close other visible modals when opening a new one</td>
<td>Setting to true will prevent closing other visible modals when opening a new one</td>
</tr>
<tr>
<td>offset</td>
<td>0</td>
<td>A vertical offset to allow for content outside of modal, for example a close button, to be centered.</td>
<td>A vertical offset to allow for content outside of the modal (close button, etc)</td>
</tr>
<tr>
<td>context</td>
<td>
body
</td>
<td>Selector or jquery object specifying the area to dim</td>
<td>A CSS selector or jQuery object specifying the area to dim</td>
</tr>
<tr>
<td>closable</td>
<td>
true
</td>
<td>Settings to false will not allow you to close the modal by clicking on the dimmer</td>
<td>Setting to false will not allow you to close the modal by clicking on the dimmer</td>
</tr>
<tr>
<td>autofocus</td>
<td>
true
</td>
<td>Setting to false will prevent autofocusing on the first input within the modal</td>
</tr>
<tr>
<td>useCSS</td>
@ -417,7 +424,7 @@ type : 'UI Module'
<td>
easeOutExpo
</td>
<td>Animation easing is only used if javascript animations are used.</td>
<td>Animation easing is only used if javascript animations are used</td>
</tr>
</tbody>
</table>

128
src/modules/modal.js

@ -252,50 +252,52 @@ $.fn.modal = function(parameters) {
},
showModal: function(callback) {
if(module.is.active()) {
module.debug('Modal is already visible');
return;
}
callback = $.isFunction(callback)
? callback
: function(){}
;
if( !module.is.active() ) {
if(module.cache === undefined) {
module.cacheSizes();
}
module.set.position();
module.set.screenHeight();
module.set.type();
module.save.focus();
module.add.keyboardShortcuts();
if(module.cache === undefined) {
module.cacheSizes();
}
module.set.position();
module.set.screenHeight();
module.set.type();
if(module.othersVisible() && !settings.allowMultiple) {
module.debug('Other modals visible, queueing show animation');
module.hideOthers(module.showModal);
if(module.othersVisible() && !settings.allowMultiple) {
module.debug('Other modals visible, queueing show animation');
module.hideOthers(module.showModal);
}
else {
$.proxy(settings.onShow, element)();
var transitionCallback = function() {
module.set.active();
$.proxy(settings.onVisible, element)();
callback();
};
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
module.debug('Showing modal with css animations');
$module
.transition(settings.transition + ' in', settings.duration, transitionCallback)
;
}
else {
$.proxy(settings.onShow, element)();
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
module.debug('Showing modal with css animations');
$module
.transition(settings.transition + ' in', settings.duration, function() {
$.proxy(settings.onVisible, element)();
module.set.active();
callback();
})
;
}
else {
module.debug('Showing modal with javascript');
$module
.fadeIn(settings.duration, settings.easing, function() {
$.proxy(settings.onVisible, element)();
module.set.active();
callback();
})
;
}
module.debug('Showing modal with javascript');
$module
.fadeIn(settings.duration, settings.easing, transitionCallback)
;
}
}
else {
module.debug('Modal is already visible');
}
},
showDimmer: function() {
@ -304,7 +306,7 @@ $.fn.modal = function(parameters) {
$dimmable.dimmer('show');
}
else {
module.debug('Dimmer already visible');
module.debug('Dimmer is already visible');
}
},
@ -322,7 +324,7 @@ $.fn.modal = function(parameters) {
hideDimmer: function() {
if( !module.is.active() ) {
module.debug('Dimmer is not visible cannot hide');
module.debug('Dimmer is already hidden');
return;
}
module.debug('Hiding dimmer');
@ -343,35 +345,37 @@ $.fn.modal = function(parameters) {
},
hideModal: function(callback) {
if(!module.is.active()) {
module.debug('Modal is already hidden');
return;
}
callback = $.isFunction(callback)
? callback
: function(){}
;
if( !module.is.active() ) {
module.debug('Cannot hide modal it is not active');
return;
}
module.debug('Hiding modal');
module.restore.focus();
module.remove.keyboardShortcuts();
$.proxy(settings.onHide, element)();
var transitionCallback = function() {
module.remove.active();
$.proxy(settings.onHidden, element)();
callback();
};
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
module.debug('Hiding modal with css animations');
$module
.transition(settings.transition + ' out', settings.duration, function() {
$.proxy(settings.onHidden, element)();
module.remove.active();
module.restore.focus();
callback();
})
.transition(settings.transition + ' out', settings.duration, transitionCallback)
;
}
else {
module.debug('Hiding modal with javascript');
$module
.fadeOut(settings.duration, settings.easing, function() {
$.proxy(settings.onHidden, element)();
module.remove.active();
module.restore.focus();
callback();
})
.fadeOut(settings.duration, settings.easing, transitionCallback)
;
}
},
@ -489,17 +493,22 @@ $.fn.modal = function(parameters) {
}
},
active: function() {
module.add.keyboardShortcuts();
module.save.focus();
$module
.addClass(className.active)
;
$module.addClass(className.active);
if(settings.closable) {
$dimmer
.off('click' + eventNamespace)
.on('click' + eventNamespace, module.event.click)
;
}
if(settings.autofocus) {
var $inputs = $module.find(':input:visible');
var $autofocus = $inputs.filter('[autofocus]');
var $input = $autofocus.length ? $autofocus : $inputs;
$input.first().focus();
}
},
scrolling: function() {
$dimmable.addClass(className.scrolling);
@ -724,6 +733,7 @@ $.fn.modal.settings = {
allowMultiple : true,
detachable : true,
closable : true,
autofocus : true,
context : 'body',
duration : 500,
@ -765,4 +775,4 @@ $.extend( $.easing, {
}
});
})( jQuery, window , document );
})( jQuery, window , document );
Loading…
Cancel
Save