Browse Source

Modal now only closes on approve or deny selector match

pull/2300/head
jlukic 9 years ago
parent
commit
eb0e67ed59
2 changed files with 21 additions and 24 deletions
  1. 40
      src/definitions/modules/modal.js
  2. 5
      src/themes/default/modules/modal.variables

40
src/definitions/modules/modal.js

@ -202,6 +202,8 @@ $.fn.modal = function(parameters) {
module.verbose('Attaching events'); module.verbose('Attaching events');
$module $module
.on('click' + eventNamespace, selector.close, module.event.close) .on('click' + eventNamespace, selector.close, module.event.close)
.on('click' + eventNamespace, selector.approve, module.event.approve)
.on('click' + eventNamespace, selector.deny, module.event.deny)
; ;
$window $window
.on('resize' + elementNamespace, module.event.resize) .on('resize' + elementNamespace, module.event.resize)
@ -216,30 +218,22 @@ $.fn.modal = function(parameters) {
}, },
event: { event: {
close: function() {
var
$element = $(this)
;
module.verbose('Closing element activated');
if( $element.is(selector.approve) ) {
if(settings.onApprove.call(element, $element) !== false) {
module.hide();
}
else {
module.verbose('Approve callback returned false cancelling hide');
}
}
else if( $element.is(selector.deny) ) {
if(settings.onDeny.call(element, $element) !== false) {
module.hide();
}
else {
module.verbose('Deny callback returned false cancelling hide');
}
approve: function() {
if(settings.onApprove.call(element, $(this)) === false) {
module.verbose('Approve callback returned false cancelling hide');
return;
} }
else {
module.hide();
module.hide();
},
deny: function() {
if(settings.onDeny.call(element, $(this)) === false) {
module.verbose('Deny callback returned false cancelling hide');
return;
} }
module.hide();
},
close: function() {
module.hide();
}, },
click: function(event) { click: function(event) {
var var
@ -884,7 +878,7 @@ $.fn.modal.settings = {
onDeny : function(){ return true; }, onDeny : function(){ return true; },
selector : { selector : {
close : '.close, .actions .button',
close : '.close',
approve : '.actions .positive, .actions .approve, .actions .ok', approve : '.actions .positive, .actions .approve, .actions .ok',
deny : '.actions .negative, .actions .deny, .actions .cancel', deny : '.actions .negative, .actions .deny, .actions .cancel',
modal : '.ui.modal' modal : '.ui.modal'

5
src/themes/default/modules/modal.variables

@ -6,7 +6,10 @@
@border: none; @border: none;
@zIndex: 1001; @zIndex: 1001;
@borderRadius: @defaultBorderRadius; @borderRadius: @defaultBorderRadius;
@boxShadow: 1px 3px 10px 2px rgba(0, 0, 0, 0.5);
@boxShadow:
1px 3px 3px 0px rgba(0, 0, 0, 0.2),
1px 3px 15px 2px rgba(0, 0, 0, 0.2)
;
/* Close Icon */ /* Close Icon */
@closeOpacity: 0.8; @closeOpacity: 0.8;

Loading…
Cancel
Save