fixing index + prompt response
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/85f37ff2 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/85f37ff2 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/85f37ff2 Branch: refs/heads/dev Commit: 85f37ff2b63dd951c8e9cc55ab70be77f62a7391 Parents: 3516df4 Author: Piotr Zalewa <[email protected]> Authored: Mon Jan 27 14:36:51 2014 +0100 Committer: Archana Naik <[email protected]> Committed: Thu Mar 20 16:28:55 2014 -0700 ---------------------------------------------------------------------- src/firefoxos/notification.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/85f37ff2/src/firefoxos/notification.js ---------------------------------------------------------------------- diff --git a/src/firefoxos/notification.js b/src/firefoxos/notification.js index 7362934..5c14829 100644 --- a/src/firefoxos/notification.js +++ b/src/firefoxos/notification.js @@ -45,7 +45,7 @@ function modal(message, callback, title, buttonLabels, domObjects) { function addButton(label, index, recommended) { var button = document.createElement('button'); button.appendChild(document.createTextNode(label)); - button.labelIndex = index; + button.labelIndex = index + 1; button.addEventListener('click', callbackButton, false); if (recommended) { // TODO: default one listens to Enter key @@ -56,7 +56,17 @@ function modal(message, callback, title, buttonLabels, domObjects) { // call callback and destroy modal function callbackButton() { - callback(this.labelIndex); + var promptInput = document.getElementById('prompt-input'); + var promptValue; + var response; + if (promptInput) { + response = { + input1: promptInput.value, + buttonIndex: this.labelIndex + } + } + response = response || this.labelIndex; + callback(response); box.parentNode.removeChild(box); } } @@ -80,16 +90,15 @@ var Notification = { modal(message, _callback, title, buttonLabels); }, prompt: function(successCallback, errorCallback, args) { - console.log(args); var message = args[0]; var title = args[1]; var buttonLabels = args[2]; var defaultText = args[3]; - var _tempcallback = (successCallback || _empty); - function _callback(labelIndex) { - var content = document.getElementById('prompt-input').value; - successCallback(labelIndex, content); - } + var _callback = (successCallback || _empty); + // function _callback(labelIndex) { + // console.log(content); + // successCallback(labelIndex, content); + // } var inputParagraph = document.createElement('p'); inputParagraph.classList.add('input'); var inputElement = document.createElement('input');
