cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [03/12] git commit: fixed "exec" calls addedd css, but not working yet
Date Fri, 25 Oct 2013 21:33:51 GMT
fixed "exec" calls
addedd css, but not working yet


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/1f8a91f9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/1f8a91f9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/1f8a91f9

Branch: refs/heads/dev
Commit: 1f8a91f928c1836dac80c291cc006d77f01cc137
Parents: cd576b9
Author: Piotr Zalewa <piotr@zalewa.info>
Authored: Thu Sep 19 14:10:59 2013 +0200
Committer: Piotr Zalewa <piotr@zalewa.info>
Committed: Thu Sep 19 14:10:59 2013 +0200

----------------------------------------------------------------------
 plugin.xml                     |  7 ++--
 src/firefoxos/dialogs.js       | 76 -------------------------------------
 src/firefoxos/notification.js  | 59 ++++++++++++++++++++++++++++
 www/firefoxos/notification.css |  2 +
 www/notification.js            |  2 +-
 5 files changed, 66 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1f8a91f9/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 0253a35..d4bc774 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -16,12 +16,13 @@
     <!-- firefoxos -->
     <platform name="firefoxos">
         <config-file target="config.xml" parent="/*">
-            <feature name="Dialogs">
-                <param name="firefoxos-package" value="Dialogs" />
+            <feature name="Notification">
+                <param name="firefoxos-package" value="Notification" />
             </feature>
         </config-file>                                         
         
-        <js-module src="src/firefoxos/dialogs.js" name="dialogs-impl">
+		<asset src="www/firefoxos/notification.css" target="css/notification.css" />
+        <js-module src="src/firefoxos/notification.js" name="dialogs-impl">
           <runs />
         </js-module>
     </platform>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1f8a91f9/src/firefoxos/dialogs.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/dialogs.js b/src/firefoxos/dialogs.js
deleted file mode 100644
index 3a16ed2..0000000
--- a/src/firefoxos/dialogs.js
+++ /dev/null
@@ -1,76 +0,0 @@
-
-var firefoxos = require('cordova/platform');
-
-function modal(message, callback, tittle, buttonLabels, cancelButton) {
-    // create a modal window
-    var box = document.createElement('div');
-    box.classList.add('fxos-modal-window');
-    // add title
-    if (tittle) {
-        var boxTittle = document.createElement('h3');
-        boxTittle.appendChild(document.createTextNode(tittle));
-        box.appendChild(boxTittle);
-    }
-    // add message
-    var boxMessage = document.createElement('p');
-    boxMessage.appendChild(document.createTextNode(message));
-    box.appendChild(boxMessage);
-    // add buttons and assign callbackButton on click
-    // TODO: find a way handle different languages
-    if (cancelButton) {
-        addButton('Cancel', -1, true);
-        // TODO: listen escape key
-    }
-    if (buttonLabels.length == 0) {
-        // only OK button
-        addButton('OK');
-        // TODO: listen to Enter Key
-    } else {
-        for (var index = 0; index < buttonLabels.length; index++) {
-            // TODO: first button is the default one (listens to Enter
-            // key)
-            addButton(buttonLabels[index], index);
-        }
-    }
-    document.body.appendChild(box);
-
-    function addButton(label, index, cancelButton) {
-        var button = document.createElement('button');
-        button.appendChild(document.createTextNode(label));
-        if (cancelButton) {
-            button.classList.add('cancel');
-        }
-        if (!index) {
-            index = 0;
-        }
-        if (cancelButton) {
-            index = -1;
-        }
-        button.labelIndex = index;
-        button.addEventListener('click', callbackButton, false);
-        box.appendChild(button);
-    }
-
-    // call callback and destroy modal
-    function callbackButton() {
-        callback(this.labelIndex);
-        // destroy window
-        box.parentNode.removeChild(box);
-    }
-}
-
-var Dialogs = {
-    vibrate: function(milliseconds) {
-        navigator.vibrate(milliseconds);
-    },
-    alert: function(message, alertCallback, tittle, buttonName) {
-        // TODO: display tittle and buttonName
-        modal(message, alertCallback, tittle, [buttonName]);
-    },
-    confirm: function(message, confirmCallback, tittle, buttonLabels) {
-        // TODO: display tittle and multiple buttons
-        modal(message, confirmCallback, tittle, buttonLabels, true);
-    }
-};
-
-firefoxos.registerPlugin('Dialogs', Dialogs);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1f8a91f9/src/firefoxos/notification.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/notification.js b/src/firefoxos/notification.js
new file mode 100644
index 0000000..d7dee29
--- /dev/null
+++ b/src/firefoxos/notification.js
@@ -0,0 +1,59 @@
+
+var firefoxos = require('cordova/platform');
+
+function _empty() {}
+
+function modal(message, callback, title, buttonLabels) {
+    // create a modal window
+    var box = document.createElement('div');
+    box.classList.add('fxos-modal-window');
+    // add title
+    if (title) {
+        var boxtitle = document.createElement('h3');
+        boxtitle.appendChild(document.createTextNode(title));
+        box.appendChild(boxtitle);
+    }
+    // add message
+    var boxMessage = document.createElement('p');
+    boxMessage.appendChild(document.createTextNode(message));
+    box.appendChild(boxMessage);
+    // 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
+        // key)
+        // TODO: last button listens to the cancel key
+        addButton(buttonLabels[index], index);
+    }
+    document.body.appendChild(box);
+
+    function addButton(label, index) {
+        var button = document.createElement('button');
+        button.appendChild(document.createTextNode(label));
+        button.labelIndex = index;
+        button.addEventListener('click', callbackButton, false);
+        box.appendChild(button);
+    }
+
+    // call callback and destroy modal
+    function callbackButton() {
+        callback(this.labelIndex);
+        box.parentNode.removeChild(box);
+    }
+}
+
+var Notification = {
+    vibrate: function(milliseconds) {
+        navigator.vibrate(milliseconds);
+    },
+    alert: function(successCallback, errorCallback, message, title, buttonName) {
+        var _callback = (successCallback || _empty);
+        var _buttonLabels = [buttonName];
+        modal(message, _callback, title, _buttonLabels);
+    },
+    confirm: function(successCallback, errorCallback, message, title, buttonLabels) {
+        var _callback = (successCallback || _empty);
+        modal(message, _callback, title, buttonLabels);
+    }
+};
+
+firefoxos.registerPlugin('Notification', Notification);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1f8a91f9/www/firefoxos/notification.css
----------------------------------------------------------------------
diff --git a/www/firefoxos/notification.css b/www/firefoxos/notification.css
new file mode 100644
index 0000000..2954083
--- /dev/null
+++ b/www/firefoxos/notification.css
@@ -0,0 +1,2 @@
+
+dy { background-color: red; }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/1f8a91f9/www/notification.js
----------------------------------------------------------------------
diff --git a/www/notification.js b/www/notification.js
index c16c367..ae4e77d 100644
--- a/www/notification.js
+++ b/www/notification.js
@@ -63,7 +63,7 @@ module.exports = {
         // Some platforms take an array of button label names.
         // Other platforms take a comma separated list.
         // For compatibility, we convert to the desired type based on the platform.
-        if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone")
{
+        if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone"
|| platform.id == "firefoxos") {
             if (typeof _buttonLabels === 'string') {
                 var buttonLabelString = _buttonLabels;
                 _buttonLabels = _buttonLabels.split(","); // not crazy about changing the
var type here


Mime
View raw message