You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/10/25 23:33:53 UTC

[05/12] git commit: prompt added

prompt added


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/81ee294d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/81ee294d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/81ee294d

Branch: refs/heads/dev
Commit: 81ee294dae47142a087afadf6634f2820a860cd1
Parents: 531b10c
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Fri Sep 27 14:33:08 2013 +0200
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Fri Sep 27 14:33:08 2013 +0200

----------------------------------------------------------------------
 src/firefoxos/notification.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/81ee294d/src/firefoxos/notification.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/notification.js b/src/firefoxos/notification.js
index d7dee29..bba2d66 100644
--- a/src/firefoxos/notification.js
+++ b/src/firefoxos/notification.js
@@ -3,7 +3,7 @@ var firefoxos = require('cordova/platform');
 
 function _empty() {}
 
-function modal(message, callback, title, buttonLabels) {
+function modal(message, callback, title, buttonLabels, domObjects) {
     // create a modal window
     var box = document.createElement('div');
     box.classList.add('fxos-modal-window');
@@ -17,6 +17,10 @@ function modal(message, callback, title, buttonLabels) {
     var boxMessage = document.createElement('p');
     boxMessage.appendChild(document.createTextNode(message));
     box.appendChild(boxMessage);
+    // inject what's needed
+    if (domObjects) {
+        box.appendChild(domObjects);
+    }
     // add buttons and assign callbackButton on click
     for (var index = 0; index < buttonLabels.length; index++) {
         // TODO: first button is the default one (listens to Enter
@@ -53,6 +57,23 @@ var Notification = {
     confirm: function(successCallback, errorCallback, message, title, buttonLabels) {
         var _callback = (successCallback || _empty);
         modal(message, _callback, title, buttonLabels);
+    },
+    prompt: function(successCallback, errorCallback, message, title, buttonLabels, defaultText) {
+        var _tempcallback = (successCallback || _empty);
+        function _callback(labelIndex) {
+            var content = document.getElementById('prompt-input').value;
+            successCallback(labelIndex, content);
+        }
+        var inputParagraph = document.createElement('p');
+        inputParagraph.classList.add('input');
+        var inputElement = document.createElement('input');
+        inputElement.setAttribute('type', 'text');
+        inputElement.id = 'prompt-input';
+        if (defaultText) {
+            inputElement.setAttribute('placeholder', defaultText);
+        }
+        inputParagraph.appendChild(inputElement);
+        modal(message, _callback, title, buttonLabels, inputParagraph);
     }
 };