From 5e2d38f7b7a7130cbe437b0d52a6528d4c68a360 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 14 Oct 2013 21:51:59 -0400 Subject: [PATCH] Adds onapprove and ondeny callback to modal, and doc info #241 --- server/documents/modules/modal.html.eco | 22 +++++++++++++++++----- src/modules/modal.js | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/server/documents/modules/modal.html.eco b/server/documents/modules/modal.html.eco index 5fa4cadc1..21b380bdf 100755 --- a/server/documents/modules/modal.html.eco +++ b/server/documents/modules/modal.html.eco @@ -26,11 +26,11 @@ type : 'UI Module'
-
+
No
-
+
Yes
@@ -57,7 +57,7 @@ type : 'UI Module'
Cancel
-
+
Add Photo
@@ -337,6 +337,16 @@ type : 'UI Module' Modal Is called after a modal is hidden. + + onApprove + Modal + Is called after a positive or approve button is pressed + + + onDeny + Modal + Is called after a negative or cancel button is pressed. + @@ -358,8 +368,10 @@ type : 'UI Module' selector
- selector : { - close : '.close, .actions .button' + selector : { + close : '.close, .actions .button', + approve : '.actions .positive, .actions .approve', + deny : '.actions .negative, .actions .cancel' },
diff --git a/src/modules/modal.js b/src/modules/modal.js index 52baa9a14..79ae112d7 100755 --- a/src/modules/modal.js +++ b/src/modules/modal.js @@ -133,7 +133,13 @@ $.fn.modal = function(parameters) { event: { close: function() { - module.verbose('Close button pressed'); + module.verbose('Closing element pressed'); + if( $(this).is(selector.approve) ) { + $.proxy(settings.onApprove, element)(); + } + if( $(this).is(selector.deny) ) { + $.proxy(settings.onDeny, element)(); + } module.hide(); }, click: function(event) { @@ -566,9 +572,13 @@ $.fn.modal.settings = { onShow : function(){}, onHide : function(){}, + onApprove : function(){ console.log('approved'); }, + onDeny : function(){ console.log('denied'); }, selector : { - close : '.close, .actions .button' + close : '.close, .actions .button', + approve : '.actions .positive, .actions .approve', + deny : '.actions .negative, .actions .cancel' }, error : { method : 'The method you called is not defined.'