Skip to content
Snippets Groups Projects
Commit aa6748f3 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Add a digit keyboard on transfer screen (small device) fix #30

parent 72984686
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
"leaflet.loading": "Leaflet.loading#^0.1.24", "leaflet.loading": "Leaflet.loading#^0.1.24",
"ui-leaflet": "^2.0.0", "ui-leaflet": "^2.0.0",
"leaflet.markercluster": "0.5", "leaflet.markercluster": "0.5",
"Leaflet.FeatureGroup.SubGroup": "0.1.2" "Leaflet.FeatureGroup.SubGroup": "0.1.2",
"ion-digit-keyboard": "skol-pro/ion-digit-keyboard"
}, },
"resolutions": { "resolutions": {
"angular-sanitize": "1.5.3", "angular-sanitize": "1.5.3",
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<script src="lib/ionic/js/angular/angular-idle.js"></script> <script src="lib/ionic/js/angular/angular-idle.js"></script>
<script src="lib/ionic/js/angular/angular-simple-logger.light.js"></script> <script src="lib/ionic/js/angular/angular-simple-logger.light.js"></script>
<script src="lib/ionic/js/angular/ui-leaflet.js"></script> <script src="lib/ionic/js/angular/ui-leaflet.js"></script>
<script src="lib/ion-digit-keyboard/dist/ion-digit-keyboard.min.js"></script>
<!--removeIf(ubuntu)--> <!-- FIXME: issue #463 under ubuntu OS --> <!--removeIf(ubuntu)--> <!-- FIXME: issue #463 under ubuntu OS -->
<script src="lib/ionic/js/angular/angular-chart.min.js"></script> <script src="lib/ionic/js/angular/angular-chart.min.js"></script>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// the 2nd parameter is an array of 'requires' // the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js // 'starter.controllers' is found in controllers.js
angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht.translate', angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht.translate',
'ngApi', 'angular-cache', 'angular.screenmatch', 'angular.bind.notifier', 'ImageCropper', 'ngApi', 'angular-cache', 'angular.screenmatch', 'angular.bind.notifier', 'ImageCropper', 'ion-digit-keyboard',
// removeIf(no-device) // removeIf(no-device)
'ngCordova', 'ngCordova',
// endRemoveIf(no-device) // endRemoveIf(no-device)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.settings.services']) angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.settings.services'])
.factory('Device', .factory('Device',
function($translate, $ionicPopup, $q, function($rootScope, $translate, $ionicPopup, $q,
// removeIf(no-device) // removeIf(no-device)
$cordovaClipboard, $cordovaBarcodeScanner, $cordovaCamera, $cordovaClipboard, $cordovaBarcodeScanner, $cordovaCamera,
// endRemoveIf(no-device) // endRemoveIf(no-device)
...@@ -141,6 +141,63 @@ angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.setti ...@@ -141,6 +141,63 @@ angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.setti
} }
}; };
// Numerical keyboard - fix #30
exports.keyboard.digit = {
settings: {
bindModel: function(modelScope, modelPath, settings) {
settings = settings || {};
modelScope = modelScope || $rootScope;
var getModelValue = function() {
return (modelPath||'').split('.').reduce(function(res, path) {
return res ? res[path] : undefined;
}, modelScope);
};
var setModelValue = function(value) {
var paths = (modelPath||'').split('.');
var property = paths.length && paths[paths.length-1];
paths.reduce(function(res, path) {
if (path == property) {
res[property] = value;
return;
}
return res[path];
}, modelScope);
};
settings.action = settings.action || function(number) {
setModelValue((getModelValue() ||'') + number);
};
if (settings.decimal) {
settings.decimalSeparator = settings.decimalSeparator || '.';
settings.leftButton = settings.leftButton = {
html: '<span>.</span>',
action: function () {
var text = getModelValue() || '';
// only one '.' allowed
if (text.indexOf(settings.decimalSeparator) >= 0) return;
// Auto add zero when started with '.'
if (!text.trim().length) {
text = '0';
}
setModelValue(text + settings.decimalSeparator);
}
};
}
settings.rightButton = settings.rightButton || {
html: '<i class="icon ion-backspace-outline"></i>',
action: function() {
var text = getModelValue();
if (text && text.length) {
text = text.slice(0, -1);
setModelValue(text);
}
}
};
return settings;
}
}
};
exports.isIOS = function() { exports.isIOS = function() {
return !!navigator.userAgent.match(/iPhone | iPad | iPod/i) || ionic.Platform.isIOS(); return !!navigator.userAgent.match(/iPhone | iPad | iPod/i) || ionic.Platform.isIOS();
}; };
......
...@@ -132,27 +132,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) ...@@ -132,27 +132,7 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
return $q(function(resolve, reject) { return $q(function(resolve, reject) {
var config = { var config = {
timeout: forcedTimeout || timeout, timeout: forcedTimeout || timeout,
headers : {'Content-Type' : 'application/json;charset=UTF-8'}, headers : {'Content-Type' : 'application/json;charset=UTF-8'}
eventHandlers: {
readystatechange: function(event) {
if(event.currentTarget.readyState === 4) {
console.log("readyState=4: Server has finished extra work!");
}
}
},
uploadEventHandlers: {
progress: function(e) {
if (e.lengthComputable) {
progress = Math.round(e.loaded * 100 / e.total);
console.log("progress: " + progress + "%");
if (e.loaded == e.total) {
console.log("File upload finished!");
console.log("Server will perform extra work now...");
}
}
}
}
}; };
prepare(url, params, config, function(url, config) { prepare(url, params, config, function(url, config) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment