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