remove angular foundation and use only ionic modals
This commit is contained in:
parent
61f6909d9a
commit
0cca8f6367
24 changed files with 249 additions and 230 deletions
102
src/js/controllers/modals/scanner.js
Normal file
102
src/js/controllers/modals/scanner.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout) {
|
||||
|
||||
// QR code Scanner
|
||||
var video;
|
||||
var canvas;
|
||||
var $video;
|
||||
var context;
|
||||
var localMediaStream;
|
||||
var prevResult;
|
||||
var scanTimer;
|
||||
|
||||
var _scan = function(evt) {
|
||||
if (localMediaStream) {
|
||||
context.drawImage(video, 0, 0, 300, 225);
|
||||
try {
|
||||
qrcode.decode();
|
||||
} catch (e) {
|
||||
//qrcodeError(e);
|
||||
}
|
||||
}
|
||||
scanTimer = $timeout(_scan, 800);
|
||||
};
|
||||
|
||||
var _scanStop = function() {
|
||||
$timeout.cancel(scanTimer);
|
||||
if (localMediaStream && localMediaStream.active) {
|
||||
var localMediaStreamTrack = localMediaStream.getTracks();
|
||||
for (var i = 0; i < localMediaStreamTrack.length; i++) {
|
||||
localMediaStreamTrack[i].stop();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
localMediaStream.stop();
|
||||
} catch (e) {
|
||||
// Older Chromium not support the STOP function
|
||||
};
|
||||
}
|
||||
localMediaStream = null;
|
||||
video.src = '';
|
||||
};
|
||||
|
||||
qrcode.callback = function(data) {
|
||||
if (prevResult != data) {
|
||||
prevResult = data;
|
||||
return;
|
||||
}
|
||||
_scanStop();
|
||||
$scope.cancel();
|
||||
$scope.onScan({
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
var _successCallback = function(stream) {
|
||||
video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
|
||||
localMediaStream = stream;
|
||||
video.play();
|
||||
$timeout(_scan, 1000);
|
||||
};
|
||||
|
||||
var _videoError = function(err) {
|
||||
$scope.cancel();
|
||||
};
|
||||
|
||||
var setScanner = function() {
|
||||
navigator.getUserMedia = navigator.getUserMedia ||
|
||||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia ||
|
||||
navigator.msGetUserMedia;
|
||||
window.URL = window.URL || window.webkitURL ||
|
||||
window.mozURL || window.msURL;
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
setScanner();
|
||||
$timeout(function() {
|
||||
if ($scope.beforeScan) {
|
||||
$scope.beforeScan();
|
||||
}
|
||||
canvas = document.getElementById('qr-canvas');
|
||||
context = canvas.getContext('2d');
|
||||
|
||||
video = document.getElementById('qrcode-scanner-video');
|
||||
$video = angular.element(video);
|
||||
canvas.width = 300;
|
||||
canvas.height = 225;
|
||||
context.clearRect(0, 0, 300, 225);
|
||||
|
||||
navigator.getUserMedia({
|
||||
video: true
|
||||
}, _successCallback, _videoError);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
_scanStop();
|
||||
$scope.scannerModal.hide();
|
||||
$scope.scannerModal.remove();
|
||||
};
|
||||
|
||||
});
|
||||
11
src/js/controllers/modals/txStatus.js
Normal file
11
src/js/controllers/modals/txStatus.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txStatusController', function($scope, $timeout) {
|
||||
|
||||
if ($scope.cb) $timeout($scope.cb, 100);
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.txStatusModal.hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -223,7 +223,8 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.close = function(txp) {
|
||||
$scope.loading = null;
|
||||
if (txp) {
|
||||
txStatus.notify(txp, function() {
|
||||
var type = txStatus.notify(txp);
|
||||
$scope.openStatusModal(type, txp, function() {
|
||||
$scope.$emit('Local/TxProposalAction', txp.status == 'broadcasted');
|
||||
});
|
||||
} else {
|
||||
|
|
@ -234,6 +235,20 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.cancel();
|
||||
};
|
||||
|
||||
$scope.openStatusModal = function(type, txp, cb) {
|
||||
$scope.type = type;
|
||||
$scope.tx = txFormatService.processTx(txp);
|
||||
$scope.cb = cb;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-status.html', {
|
||||
scope: $scope,
|
||||
animation: 'slide-in-up'
|
||||
}).then(function(modal) {
|
||||
$scope.txStatusModal = modal;
|
||||
$scope.txStatusModal.show();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.txpDetailsModal.hide();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue