Commit ad1f83ff27b281d18f0d897fc1abb1c480d6e950
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !11
Showing
1 changed file
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 | function($scope, $window) { | 5 | function($scope, $window) { |
6 | this.$onInit = function() { | 6 | this.$onInit = function() { |
7 | $scope.botones = $scope.$ctrl.botones; | 7 | $scope.botones = $scope.$ctrl.botones; |
8 | var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; | 8 | var max = ($scope.$ctrl.max) ? $scope.$ctrl.max : 12; |
9 | 9 | ||
10 | if($window.innerWidth > 576) { | 10 | if($window.innerWidth > 576) { |
11 | while(($scope.botones.length % max) !== 0) { | 11 | while(($scope.botones.length % max) !== 0) { |
12 | $scope.botones.push(''); | 12 | $scope.botones.push(''); |
13 | } | 13 | } |
14 | }else { | 14 | }else { |
15 | while(($scope.botones.length % 3) !== 0) { | 15 | while(($scope.botones.length % 4) !== 0) { |
16 | $scope.botones.push(''); | 16 | $scope.botones.push(''); |
17 | } | 17 | } |
18 | } | 18 | } |
19 | }; | 19 | }; |
20 | 20 | ||
21 | function nombreFuncion(string) { | 21 | function nombreFuncion(string) { |
22 | var texto = 'seleccionar'; | 22 | var texto = 'seleccionar'; |
23 | var arr = string.split(' '); | 23 | var arr = string.split(' '); |
24 | arr.forEach(function(palabra) { | 24 | arr.forEach(function(palabra) { |
25 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 25 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
26 | texto += palabra; | 26 | texto += palabra; |
27 | }); | 27 | }); |
28 | return texto; | 28 | return texto; |
29 | } | 29 | } |
30 | 30 | ||
31 | $scope.ejecutarFuncion = function(nombre) { | 31 | $scope.ejecutarFuncion = function(nombre) { |
32 | $scope.$parent[nombreFuncion(nombre)](); | 32 | $scope.$parent[nombreFuncion(nombre)](); |
33 | }; | 33 | }; |
34 | }]); | 34 | }]); |
35 | 35 |