Skip to content

Commit

Permalink
[fix] Add a digit keyboard on transfer screen (small device) fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Nov 7, 2017
1 parent 7298468 commit aa6748f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"leaflet.loading": "Leaflet.loading#^0.1.24",
"ui-leaflet": "^2.0.0",
"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": {
"angular-sanitize": "1.5.3",
Expand Down
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ <h4 style="text-align: center;"><i class="icon ion-load-a"></i></h4>
<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/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 -->
<script src="lib/ionic/js/angular/angular-chart.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
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)
'ngCordova',
// endRemoveIf(no-device)
Expand Down
59 changes: 58 additions & 1 deletion www/js/services/device-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
angular.module('cesium.device.services', ['cesium.utils.services', 'cesium.settings.services'])

.factory('Device',
function($translate, $ionicPopup, $q,
function($rootScope, $translate, $ionicPopup, $q,
// removeIf(no-device)
$cordovaClipboard, $cordovaBarcodeScanner, $cordovaCamera,
// endRemoveIf(no-device)
Expand Down Expand Up @@ -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() {
return !!navigator.userAgent.match(/iPhone | iPad | iPod/i) || ionic.Platform.isIOS();
};
Expand Down
22 changes: 1 addition & 21 deletions www/js/services/http-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,7 @@ angular.module('cesium.http.services', ['cesium.cache.services'])
return $q(function(resolve, reject) {
var config = {
timeout: forcedTimeout || timeout,
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...");
}
}
}
}
headers : {'Content-Type' : 'application/json;charset=UTF-8'}
};

prepare(url, params, config, function(url, config) {
Expand Down

0 comments on commit aa6748f

Please sign in to comment.