Commit 823bd5793e4d6999dd92255b6587a4674a9b862d

Authored by Eric
1 parent 7bed244e75
Exists in master and in 1 other branch develop

pre commit

Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaBotoneraFacturador') 1 angular.module('focaBotoneraFacturador')
2 .controller('focaBotoneraFacturadorController', [ 2 .controller('focaBotoneraFacturadorController', [
3 '$scope', 3 '$scope',
4 '$window', 4 '$window',
5 'APP', 5 'APP',
6 function($scope, $window, APP) { 6 function($scope, $window, APP) {
7 this.$onInit = function() { 7 this.$onInit = function() {
8 ordenarBotones(); 8 ordenarBotones();
9 }; 9 };
10 10
11 this.$onChanges = function(p) { 11 this.$onChanges = function() {
12 ordenarBotones(); 12 ordenarBotones();
13 } 13 };
14 14
15 function nombreFuncion(string) { 15 function nombreFuncion(string) {
16 var texto = 'seleccionar'; 16 var texto = 'seleccionar';
17 var arr = string.split(' '); 17 var arr = string.split(' ');
18 arr.forEach(function(palabra) { 18 arr.forEach(function(palabra) {
19 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 19 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
20 texto += palabra; 20 texto += palabra;
21 }); 21 });
22 return texto; 22 return texto;
23 } 23 }
24 24
25 $scope.ejecutarFuncion = function(nombre) { 25 $scope.ejecutarFuncion = function(nombre) {
26 $scope.$parent[nombreFuncion(nombre)](); 26 $scope.$parent[nombreFuncion(nombre)]();
27 }; 27 };
28 28
29 $scope.ejecutarFuncionDelete = function(variable) { 29 $scope.ejecutarFuncionDelete = function(variable) {
30 $scope.$parent['clean' + variable](); 30 $scope.$parent['clean' + variable]();
31 }; 31 };
32 32
33 $scope.existeFuncionDelete = function(variable) { 33 $scope.existeFuncionDelete = function(variable) {
34 if ($scope.$parent['clean' + variable]) return true; 34 if ($scope.$parent['clean' + variable]) return true;
35 return false; 35 return false;
36 } 36 };
37 37
38 function ordenarBotones() { 38 function ordenarBotones() {
39 $scope.botones = $scope.$ctrl.botones; 39 $scope.botones = $scope.$ctrl.botones;
40 //TODO: controlar que no se estiren los botones 40 //TODO: controlar que no se estiren los botones
41 if(APP) return; 41 if(APP) return;
42 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; 42 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12;
43 if ($window.innerWidth > 576) { 43 if ($window.innerWidth > 576) {
44 while(($scope.botones.length % max) !== 0) { 44 while(($scope.botones.length % max) !== 0) {
45 $scope.botones.push(''); 45 $scope.botones.push('');
46 } 46 }
47 } else { 47 } else {
48 while(($scope.botones.length % 4) !== 0) { 48 while(($scope.botones.length % 4) !== 0) {
49 $scope.botones.push(''); 49 $scope.botones.push('');
50 } 50 }
51 } 51 }
52 } 52 }
53 }]); 53 }]);
54 54