You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by br...@apache.org on 2013/07/08 23:00:09 UTC
[02/28] git commit: implemented confirm function in notification js
this should fix jira issue #RIPPLE-22
implemented confirm function in notification js
this should fix jira issue #RIPPLE-22
Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/6b92b52b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/6b92b52b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/6b92b52b
Branch: refs/heads/master
Commit: 6b92b52bb772bc8338cd74aa45dbad6863fe937e
Parents: dfdf1f7
Author: Mike Ebinum <me...@gmail.com>
Authored: Thu May 30 18:55:15 2013 +1000
Committer: Brent Lintner <br...@gmail.com>
Committed: Thu Jun 13 12:05:34 2013 -0400
----------------------------------------------------------------------
lib/client/notifications.js | 36 ++++++++++++++++++++
.../cordova/2.0.0/bridge/notification.js | 11 ++++--
.../ui/plugins/confirm-dialog/dialog.html | 7 ++++
lib/client/ui/plugins/notifications.js | 6 ++++
4 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/6b92b52b/lib/client/notifications.js
----------------------------------------------------------------------
diff --git a/lib/client/notifications.js b/lib/client/notifications.js
index 45ebe79..17eefe1 100644
--- a/lib/client/notifications.js
+++ b/lib/client/notifications.js
@@ -75,6 +75,38 @@ function _processNotification(nType, stateType, message) {
}
+function _processConfirm (message,resultCallback,title,buttonLabels) {
+ buttonLabels = buttonLabels || "";
+ message = message || "";
+ title = title || "Confirm";
+ var btnArray = (!buttonLabels || 0 === buttonLabels.length) ? [] : buttonLabels.split(',');
+ var buttons = [];
+
+ btnArray.forEach(function(btnLabel,index) {
+ var button = {};
+ button["text"] = btnLabel;
+ button["click"] = function () {
+ if(resultCallback !== typeof "undefined")
+ resultCallback(index);
+ jQuery( this ).dialog( "close" );
+ };
+ buttons.push(button);
+ });
+ var dialogBox = jQuery("#confirm-dialog");
+ dialogBox.dialog("option","title", title);
+ jQuery("#confirm-message").text(message);
+ dialogBox.dialog("open");
+ if(btnArray.length > 0){
+ dialogBox.dialog( "option", "buttons", buttons);
+ return;
+ }
+ var closeBox = function() {
+ dialogBox.dialog("close");
+ };
+ jQuery("#confirm-cancel").button().unbind().bind('click', closeBox).show();
+ jQuery("#confirm-ok").button().unbind().bind('click', closeBox).show();
+}
+
module.exports = {
openNotification: function (nType, msg) {
_processNotification(nType, constants.NOTIFICATIONS.STATE_TYPES.OPEN, msg);
@@ -82,5 +114,9 @@ module.exports = {
closeNotification: function (nType) {
_processNotification(nType, constants.NOTIFICATIONS.STATE_TYPES.CLOSE);
+ },
+
+ confirmNotification: function (message, resultCallback, title, buttonLabels) {
+ _processConfirm(message,resultCallback,title,buttonLabels);
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/6b92b52b/lib/client/platform/cordova/2.0.0/bridge/notification.js
----------------------------------------------------------------------
diff --git a/lib/client/platform/cordova/2.0.0/bridge/notification.js b/lib/client/platform/cordova/2.0.0/bridge/notification.js
index aa7be30..c278c6e 100644
--- a/lib/client/platform/cordova/2.0.0/bridge/notification.js
+++ b/lib/client/platform/cordova/2.0.0/bridge/notification.js
@@ -28,8 +28,15 @@ module.exports = {
return success && success();
},
- confirm: function () {
- throw "Not Implemented";
+ confirm: function (resultCallback, someObject, confirmStrings) {
+ // For some reason only 3 parameters are passed i
+ //with all the options as the last parameter
+ //this is a HACK to get it to work
+ var options = confirmStrings;
+ var message = options[0] || "";
+ var title = options[1] || "";
+ var buttonLabels = options[2];
+ notifications.confirmNotification(message, resultCallback, title, buttonLabels);
},
activityStart: function () {
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/6b92b52b/lib/client/ui/plugins/confirm-dialog/dialog.html
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/confirm-dialog/dialog.html b/lib/client/ui/plugins/confirm-dialog/dialog.html
new file mode 100644
index 0000000..c8cca77
--- /dev/null
+++ b/lib/client/ui/plugins/confirm-dialog/dialog.html
@@ -0,0 +1,7 @@
+<div id="confirm-dialog">
+ <p id="confirm-message">
+ </p>
+ <br/>
+ <button id="confirm-cancel" style="display:none">Cancel</button>
+ <button id="confirm-ok" style="display:none">Ok</button>
+</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/6b92b52b/lib/client/ui/plugins/notifications.js
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/notifications.js b/lib/client/ui/plugins/notifications.js
index 3bab7b9..0a3768d 100644
--- a/lib/client/ui/plugins/notifications.js
+++ b/lib/client/ui/plugins/notifications.js
@@ -26,5 +26,11 @@ module.exports = {
jQuery("." + constants.NOTIFICATIONS.CLOSE_BUTTON_CLASS).bind("click", function () {
notifications.closeNotification();
});
+ jQuery("#confirm-dialog").dialog({
+ autoOpen: false,
+ modal: true,
+ width: 200,
+ position: 'center',
+ });
}
};