Browse Source

Adds onApprove/deny callback can cancel hide

pull/2229/head
jlukic 11 years ago
parent
commit
eca00d8fce
1 changed files with 18 additions and 6 deletions
  1. 24
      src/modules/modal.js

24
src/modules/modal.js

@ -63,6 +63,11 @@ $.fn.modal = function(parameters) {
initialize: function() { initialize: function() {
module.verbose('Initializing dimmer', $context); module.verbose('Initializing dimmer', $context);
if(typeof $.fn.dimmer === undefined) {
module.error(error.dimmer);
return;
}
$dimmable = $context $dimmable = $context
.dimmer({ .dimmer({
closable : false, closable : false,
@ -140,12 +145,18 @@ $.fn.modal = function(parameters) {
close: function() { close: function() {
module.verbose('Closing element pressed'); module.verbose('Closing element pressed');
if( $(this).is(selector.approve) ) { if( $(this).is(selector.approve) ) {
$.proxy(settings.onApprove, element)();
if($.proxy(settings.onApprove, element)()) {
modal.hide();
}
} }
if( $(this).is(selector.deny) ) { if( $(this).is(selector.deny) ) {
$.proxy(settings.onDeny, element)();
if($.proxy(settings.onDeny, element)()) {
modal.hide();
}
}
else {
module.hide();
} }
module.hide();
}, },
click: function(event) { click: function(event) {
module.verbose('Determining if event occured on dimmer', event); module.verbose('Determining if event occured on dimmer', event);
@ -282,7 +293,7 @@ $.fn.modal = function(parameters) {
restore: { restore: {
focus: function() { focus: function() {
if($focusedElement.size() > 0) {
if($focusedElement && $focusedElement.size() > 0) {
$focusedElement.focus(); $focusedElement.focus();
} }
} }
@ -571,8 +582,8 @@ $.fn.modal.settings = {
onShow : function(){}, onShow : function(){},
onHide : function(){}, onHide : function(){},
onApprove : function(){},
onDeny : function(){},
onApprove : function(){ return true; },
onDeny : function(){ return true; },
selector : { selector : {
close : '.close, .actions .button', close : '.close, .actions .button',
@ -580,6 +591,7 @@ $.fn.modal.settings = {
deny : '.actions .negative, .actions .cancel' deny : '.actions .negative, .actions .cancel'
}, },
error : { error : {
dimmer : 'UI Dimmer, a required component is not included in this page',
method : 'The method you called is not defined.' method : 'The method you called is not defined.'
}, },
className : { className : {

Loading…
Cancel
Save