Commit b56907ac131ca7c2afe06935aca28b359d6618ff
1 parent
0a2eccb4d7
Exists in
master
logita para botonera de pausa
Showing
1 changed file
with
77 additions
and
77 deletions
Show diff stats
src/js/service.js
1 | 1 | angular.module('focaBotoneraLateral') |
2 | 2 | .service('focaBotoneraLateralService', ['$localStorage', |
3 | - function($localStorage) { | |
3 | + function ($localStorage) { | |
4 | 4 | |
5 | - this.botones = { | |
6 | - teclado: true, | |
7 | - salir: false, | |
8 | - cancelar: false, | |
9 | - pausar: false, | |
10 | - guardar: false, | |
11 | - guardando: false, | |
12 | - funcionGuardar: undefined, | |
13 | - pathCancelar: undefined, | |
14 | - custom: [] | |
15 | - }; | |
5 | + this.botones = { | |
6 | + teclado: true, | |
7 | + salir: false, | |
8 | + cancelar: false, | |
9 | + pausar: false, | |
10 | + guardar: false, | |
11 | + guardando: false, | |
12 | + funcionGuardar: undefined, | |
13 | + pathCancelar: undefined, | |
14 | + custom: [] | |
15 | + }; | |
16 | 16 | |
17 | - this.pausarData = { | |
18 | - label: '', | |
19 | - val: '' | |
20 | - }; | |
17 | + this.pausarData = { | |
18 | + label: '', | |
19 | + val: '' | |
20 | + }; | |
21 | 21 | |
22 | - this.rutasPausadas = { | |
23 | - label: 'rutas', | |
24 | - val: [] | |
25 | - }; | |
22 | + this.rutasPausadas = { | |
23 | + label: 'rutas', | |
24 | + val: [] | |
25 | + }; | |
26 | 26 | |
27 | - this.showTeclado = function(value) { | |
28 | - this.botones.teclado = value; | |
29 | - }; | |
30 | - this.showSalir = function(value) { | |
31 | - this.botones.custom = []; | |
32 | - this.botones.salir = value; | |
33 | - }; | |
34 | - this.showPausar = function(value) { | |
35 | - this.botones.custom = []; | |
36 | - this.botones.pausar = value; | |
37 | - }; | |
38 | - this.setPausarData = function(obj) { | |
39 | - this.pausarData = obj; | |
40 | - }; | |
41 | - this.setRutasPausadas = function(obj) { | |
42 | - var auxArray = []; | |
43 | - this.rutasPausadas.val.push(obj.val); | |
44 | - angular.forEach(this.rutasPausadas.val, function(ruta) { | |
45 | - var exists = false; | |
46 | - angular.forEach(auxArray, function(val2) { | |
47 | - if(angular.equals(ruta, val2)){ exists = true }; | |
27 | + this.showTeclado = function (value) { | |
28 | + this.botones.teclado = value; | |
29 | + }; | |
30 | + this.showSalir = function (value) { | |
31 | + this.botones.custom = []; | |
32 | + this.botones.salir = value; | |
33 | + }; | |
34 | + this.showPausar = function (value) { | |
35 | + this.botones.custom = []; | |
36 | + this.botones.pausar = value; | |
37 | + }; | |
38 | + this.setPausarData = function (obj) { | |
39 | + this.pausarData = obj; | |
40 | + }; | |
41 | + this.setRutasPausadas = function (obj) { | |
42 | + var auxArray = []; | |
43 | + this.rutasPausadas.val.push(obj.val); | |
44 | + angular.forEach(this.rutasPausadas.val, function (ruta) { | |
45 | + var exists = false; | |
46 | + angular.forEach(auxArray, function (val2) { | |
47 | + if (angular.equals(ruta, val2)) { exists = true }; | |
48 | + }); | |
49 | + if (exists == false && ruta !== "") { auxArray.push(ruta); } | |
48 | 50 | }); |
49 | - if(exists == false && ruta !== "") { auxArray.push(ruta); } | |
50 | - }); | |
51 | - | |
52 | - this.rutasPausadas.val = auxArray; | |
53 | - }; | |
54 | - this.showCancelar = function(value, path) { | |
55 | - this.botones.custom = []; | |
56 | - this.botones.cancelar = value; | |
57 | - this.botones.pathCancelar = (path) ? path : undefined; | |
58 | - }; | |
59 | - this.showGuardar = function(value, funcion) { | |
60 | - angular.element('#guardar').removeClass('guardado'); | |
61 | - this.botones.custom = []; | |
62 | - this.botones.guardar = value; | |
63 | - if (value) this.botones.funcionGuardar = funcion; | |
64 | - }; | |
65 | - this.addCustomButton = function(title, funcion) { | |
66 | - this.botones.custom.push({ | |
67 | - title: title, | |
68 | - funcion: funcion | |
69 | - }); | |
70 | - }; | |
71 | - this.startGuardar = function() { | |
72 | - this.botones.guardando = true; | |
73 | - }; | |
74 | - this.endGuardar = function(guardado) { | |
75 | - this.botones.guardando = false; | |
76 | - if (guardado) angular.element('#guardar').addClass('guardado'); | |
77 | - }; | |
78 | 51 | |
79 | - this.setLSItem = function() { | |
80 | - $localStorage[this.pausarData.label] = JSON.stringify(this.pausarData.val); | |
81 | - }; | |
52 | + this.rutasPausadas.val = auxArray; | |
53 | + }; | |
54 | + this.showCancelar = function (value, path) { | |
55 | + this.botones.custom = []; | |
56 | + this.botones.cancelar = value; | |
57 | + this.botones.pathCancelar = (path) ? path : undefined; | |
58 | + }; | |
59 | + this.showGuardar = function (value, funcion) { | |
60 | + angular.element('#guardar').removeClass('guardado'); | |
61 | + this.botones.custom = []; | |
62 | + this.botones.guardar = value; | |
63 | + if (value) this.botones.funcionGuardar = funcion; | |
64 | + }; | |
65 | + this.addCustomButton = function (title, funcion) { | |
66 | + this.botones.custom.push({ | |
67 | + title: title, | |
68 | + funcion: funcion | |
69 | + }); | |
70 | + }; | |
71 | + this.startGuardar = function () { | |
72 | + this.botones.guardando = true; | |
73 | + }; | |
74 | + this.endGuardar = function (guardado) { | |
75 | + this.botones.guardando = false; | |
76 | + if (guardado) angular.element('#guardar').addClass('guardado'); | |
77 | + }; | |
78 | + | |
79 | + this.setLSItem = function () { | |
80 | + $localStorage[this.pausarData.label] = JSON.stringify(this.pausarData.val); | |
81 | + }; | |
82 | 82 | |
83 | - this.setLSRuta = function() { | |
84 | - $localStorage[this.rutasPausadas.label] = JSON.stringify(this.rutasPausadas.val); | |
85 | - }; | |
86 | - }]); | |
83 | + this.setLSRuta = function () { | |
84 | + $localStorage[this.rutasPausadas.label] = JSON.stringify(this.rutasPausadas.val); | |
85 | + }; | |
86 | + }]); |