Commit d66c2e8a49f6cf042a2ccab7b7a12ed4741c78bb

Authored by Marcelo Puebla
Exists in master and in 1 other branch develop

Merge branch 'master' of git.focasoftware.com:mpuebla/foca-botonera-facturador

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 function($scope, $window) { 5 'APP',
6 function($scope, $window, APP) {
6 this.$onInit = function() { 7 this.$onInit = function() {
7 $scope.botones = $scope.$ctrl.botones; 8 $scope.botones = $scope.$ctrl.botones;
9 //TODO: controlar que no se estiren los botones
10 if(APP) return;
8 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; 11 var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12;
9
10 if($window.innerWidth > 576) { 12 if($window.innerWidth > 576) {
11 while(($scope.botones.length % max) !== 0) { 13 while(($scope.botones.length % max) !== 0) {
12 $scope.botones.push(''); 14 $scope.botones.push('');
13 } 15 }
14 }else { 16 }else {
15 while(($scope.botones.length % 4) !== 0) { 17 while(($scope.botones.length % 4) !== 0) {
16 $scope.botones.push(''); 18 $scope.botones.push('');
17 } 19 }
18 } 20 }
19 }; 21 };
20 22
21 function nombreFuncion(string) { 23 function nombreFuncion(string) {
22 var texto = 'seleccionar'; 24 var texto = 'seleccionar';
23 var arr = string.split(' '); 25 var arr = string.split(' ');
24 arr.forEach(function(palabra) { 26 arr.forEach(function(palabra) {
25 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 27 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
26 texto += palabra; 28 texto += palabra;
27 }); 29 });
28 return texto; 30 return texto;
29 } 31 }
30 32
31 $scope.ejecutarFuncion = function(nombre) { 33 $scope.ejecutarFuncion = function(nombre) {
32 $scope.$parent[nombreFuncion(nombre)](); 34 $scope.$parent[nombreFuncion(nombre)]();
33 }; 35 };
34 }]); 36 }]);