Rename functions

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-30 14:56:36 -03:00
commit 5e33b19b0e
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
4 changed files with 24 additions and 55 deletions

View file

@ -1,42 +1,17 @@
'use strict';
angular.module('copayApp.services').service('modalService', function($rootScope, $log, $ionicModal, $ionicPopup, platformInfo) {
angular.module('copayApp.services').service('popupService', function($log, $ionicPopup, platformInfo) {
var isCordova = platformInfo.isCordova;
var _modalIonic = function(tpl, scope) {
var promise;
scope = scope || $rootScope.$new();
promise = $ionicModal.fromTemplateUrl(tpl, {
scope: scope
}).then(function(modal) {
scope.modal = modal;
return modal;
});
scope.openModal = function() {
scope.modal.show();
};
scope.closeModal = function() {
scope.modal.hide();
};
scope.$on('$destroy', function() {
scope.modal.remove();
});
return promise;
};
/*************** Ionic ****************/
var _ionicAlert = function(title, message, cb) {
if (!cb) cb = function() {};
var promise = $ionicPopup.alert({
$ionicPopup.alert({
title: title,
template: message
}).then(cb);
return promise;
};
var _ionicConfirm = function(title, message, cb) {
@ -60,6 +35,8 @@ angular.module('copayApp.services').service('modalService', function($rootScope,
});
};
/*************** Cordova ****************/
var _cordovaAlert = function(title, message, cb) {
if (!cb) cb = function() {};
navigator.notification.alert(message, cb, title);
@ -75,7 +52,7 @@ angular.module('copayApp.services').service('modalService', function($rootScope,
var _cordovaPrompt = function(title, message, cb) {
var onPrompt = function (results) {
if (results.buttonIndex) return cb(results.input1);
if (results.buttonIndex == 1) return cb(results.input1);
else return cb();
}
navigator.notification.prompt(message, onPrompt, title);
@ -86,8 +63,7 @@ angular.module('copayApp.services').service('modalService', function($rootScope,
*
* @param {String} Title
* @param {String} Message
* @param {Callback} Function
* @returns {Promise}
* @param {Callback} Function (optional)
*/
this.showAlert = function(title, msg, cb) {
@ -123,7 +99,7 @@ angular.module('copayApp.services').service('modalService', function($rootScope,
*
* @param {String} Title
* @param {String} Message
* @param {Object} Object{ inputType, inputPlaceholder }
* @param {Object} Object{ inputType, inputPlaceholder } (optional)
* @param {Callback} Function
* @returns {Callback} Return the value of the input if user presses OK
*/
@ -137,17 +113,5 @@ angular.module('copayApp.services').service('modalService', function($rootScope,
_ionicPrompt(title, message, opts, cb);
};
/**
* Show a modal popup
*
* @param {String} TemplateURL
* @param {Object} Scope
* @returns {Promise}
*/
this.showModal = function(tpl, scope) {
return _modalIonic(tpl, scope);
};
});