ripple-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brentlint...@apache.org
Subject [1/3] incubator-ripple git commit: RIPPLE 71: Adding BarcodeScanner plugin support
Date Sun, 16 Nov 2014 19:48:22 GMT
Repository: incubator-ripple
Updated Branches:
  refs/heads/master 520a149e4 -> 57c75494a


RIPPLE 71: Adding BarcodeScanner plugin support


Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/27d7470d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/27d7470d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/27d7470d

Branch: refs/heads/master
Commit: 27d7470d24642df7177ac26632e9eb428912ce47
Parents: cd50e49
Author: Ilya Buziuk <ibuziuk@exadel.com>
Authored: Wed Oct 8 15:46:58 2014 +0300
Committer: Ilya Buziuk <ibuziuk@exadel.com>
Committed: Fri Oct 10 18:07:57 2014 +0300

----------------------------------------------------------------------
 assets/client/ripple.css                        | 48 ++++++++++
 .../cordova/3.0.0/bridge/barcodescanner.js      | 95 ++++++++++++++++++++
 lib/client/platform/cordova/3.0.0/spec.js       |  3 +
 .../ui/plugins/barcode-encode/overlay.html      | 27 ++++++
 lib/client/ui/plugins/barcode-scan/dialog.html  | 37 ++++++++
 5 files changed, 210 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/27d7470d/assets/client/ripple.css
----------------------------------------------------------------------
diff --git a/assets/client/ripple.css b/assets/client/ripple.css
index 2cc2585..629451e 100644
--- a/assets/client/ripple.css
+++ b/assets/client/ripple.css
@@ -1241,3 +1241,51 @@ fieldset {
     -webkit-transition: background 0.5s;
     background-color: #66ccff;
 }
+
+/* START - RIPPLE-71 Barcode Scanner styles */
+.skan-dialog-field-set label {
+  float: left;
+  width: 25%;
+  margin-right: 0.5em;
+  padding-top: 0.2em;
+  text-align: right;
+  font-weight: bold;
+}
+
+.skan-dialog-field-set select {
+    width: 305px;
+}
+
+.skan-dialog-field-set input[type=text] {
+    width: 300px;
+}
+
+.barcode-overlay {
+    z-index: 10000;
+    width: 100%;
+    height: 100%;
+    display: none;
+    background-color: white;
+}
+
+.barcode-close {
+    z-index: 10000;
+    width: 100%;
+    height: 100%;
+}
+
+.barcode-image {
+    z-index: 10000;
+    width: 100%;
+}
+
+.barcode-data {
+    z-index: 10000;
+    text-align: center;
+    font-family: Tahoma, Geneva, sans-serif;
+    font-size: 25px;
+    color: black;
+    padding: 20px;
+    background-color: white;
+}
+/* END - RIPPLE-71 Barcode Scanner styles */

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/27d7470d/lib/client/platform/cordova/3.0.0/bridge/barcodescanner.js
----------------------------------------------------------------------
diff --git a/lib/client/platform/cordova/3.0.0/bridge/barcodescanner.js b/lib/client/platform/cordova/3.0.0/bridge/barcodescanner.js
new file mode 100644
index 0000000..e8803be
--- /dev/null
+++ b/lib/client/platform/cordova/3.0.0/bridge/barcodescanner.js
@@ -0,0 +1,95 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+var ui = ripple('ui'),
+    serviceUrl = "https://chart.googleapis.com/chart?cht=qr&chs=300x300&chld=L|5&chl=";
+
+function _processScanOk(success) {
+    var scannedResult = {
+        cancelled: false,
+        text: $('#scannedText').val(),
+        format: $('#formatDropDown option:selected').text()
+    };
+    success(scannedResult);
+}
+
+function _processScanCancel(success) {
+    var scannedResult = {
+        cancelled: true,
+        text: "",
+        format: ""
+    };
+    success(scannedResult);
+}
+
+module.exports = {
+    scan: function(success, error, args) {
+        try {
+            // Showing the dialog
+            $("#scanDialog").dialog({
+                autoOpen: true,
+                modal: true,
+                title: "Barcode Scanner",
+                heigh: 50,
+                width: 510,
+                position: 'center',
+                resizable: false,
+                buttons: [{
+                    text: "OK",
+                    click: function() {
+                        $(this).dialog('close');
+                        _processScanOk(success);
+                    },
+                    class: "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only
small-button",
+                }, {
+                    text: "Cancel",
+                    click: function() {
+                        $(this).dialog('close');
+                        _processScanCancel(success);
+                    },
+                    class: "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only
small-button",
+                }]
+            });
+        } catch (err) {
+            error("Fail to emulate BarcodeScanner.scan() method"); // Something went wrong
+        }
+    },
+
+    // Uses google QR service - https://developers.google.com/chart/infographics/docs/qr_codes
+    encode: function(success, error, args) {
+        var data = args[0].data,
+            type = args[0].type,
+            url = serviceUrl + data;
+
+        try {
+
+            document.getElementById('barcodeClose').addEventListener("click", function()
{
+                ui.hideOverlay("barcodeBackground");
+            });
+
+            $('#barcodeImage').attr("src", url); // Adding encoded image  
+            $('#barcodeData').html(data); // Adding data
+            ui.showOverlay("barcodeBackground");
+            success(); // ?! on Android VM success function is never called ?!
+        } catch (err) {
+            error("Fail to emulate BarcodeScanner.encode() method"); // Something went wrong
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/27d7470d/lib/client/platform/cordova/3.0.0/spec.js
----------------------------------------------------------------------
diff --git a/lib/client/platform/cordova/3.0.0/spec.js b/lib/client/platform/cordova/3.0.0/spec.js
index d658af1..4c4553a 100644
--- a/lib/client/platform/cordova/3.0.0/spec.js
+++ b/lib/client/platform/cordova/3.0.0/spec.js
@@ -57,6 +57,9 @@ module.exports = {
         /** external plugins **/
         // scandit barcode scanner @see https://github.com/Scandit/BarcodeScannerPlugin
         bridge.add("ScanditSDK", ripple('platform/cordova/3.0.0/bridge/scanditsdk'));
+        
+        // RIPPLE-71 BarcodeScaner plugin support @see https://github.com/phonegap-build/BarcodeScanner

+        bridge.add("BarcodeScanner", ripple('platform/cordova/3.0.0/bridge/barcodescanner'));
 
         honeypot.monitor(win, "cordova").andRun(get, set);
 

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/27d7470d/lib/client/ui/plugins/barcode-encode/overlay.html
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/barcode-encode/overlay.html b/lib/client/ui/plugins/barcode-encode/overlay.html
new file mode 100644
index 0000000..57c2b01
--- /dev/null
+++ b/lib/client/ui/plugins/barcode-encode/overlay.html
@@ -0,0 +1,27 @@
+<!--
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+-->
+<section id="barcodeBackground" class="barcode-overlay">
+    <img id="barcodeImage" class="barcode-image"></img>
+    <div id="barcodeData" class="barcode-data"></div>
+    <button id="barcodeClose" class="ui-button ui-widget ui-state-default ui-button-text-only
small-button barcode-close">
+        <span class="ui-button-text">Close</span>
+    </button>
+</section>

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/27d7470d/lib/client/ui/plugins/barcode-scan/dialog.html
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/barcode-scan/dialog.html b/lib/client/ui/plugins/barcode-scan/dialog.html
new file mode 100644
index 0000000..7978f3b
--- /dev/null
+++ b/lib/client/ui/plugins/barcode-scan/dialog.html
@@ -0,0 +1,37 @@
+<!--
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+-->
+<div id="scanDialog" class="overlay-scan-dialog">
+    <fieldset id="skanDialogFieldSet" class="skan-dialog-field-set">
+        <label for="scannedText">Scanned Text:</label>
+        <input type="text" id="scannedText"></input>
+        <label for="formatDropDown">Format:</label>
+        <select id="formatDropDown">
+            <option value="QR_CODE">QR_CODE</option>
+            <option value="DATA_MATRIX">DATA_MATRIX</option>
+            <option value="UPC_E">UPC_E</option>
+            <option value="UPC_A">UPC_A</option>
+            <option value="EAN_8">EAN_8</option>
+            <option value="EAN_13">EAN_13</option>
+            <option value="CODE_128">CODE_128</option>
+            <option value="CODE_39">CODE_39</option>
+        </select>
+    </fieldset>
+</div>


Mime
View raw message