Commit 17bdcefdde1412bb69457aee19c260c4bc15821f
1 parent
f83339a06b
Exists in
master
and in
1 other branch
parametro max
Showing
2 changed files
with
4 additions
and
2 deletions
Show diff stats
src/js/app.js
1 | angular.module('focaBotoneraFacturador', []) | 1 | angular.module('focaBotoneraFacturador', []) |
2 | .component('focaBotoneraFacturador', { | 2 | .component('focaBotoneraFacturador', { |
3 | templateUrl: 'src/views/botonera-facturador.html', | 3 | templateUrl: 'src/views/botonera-facturador.html', |
4 | controller: 'focaBotoneraFacturadorController', | 4 | controller: 'focaBotoneraFacturadorController', |
5 | bindings: { | 5 | bindings: { |
6 | botones: '<' | 6 | botones: '<', |
7 | max: '<' | ||
7 | } | 8 | } |
8 | }); | 9 | }); |
9 | 10 |
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 | 9 | ||
9 | if($window.innerWidth > 576) { | 10 | if($window.innerWidth > 576) { |
10 | while(($scope.botones.length % 12) !== 0) { | 11 | while(($scope.botones.length % max) !== 0) { |
11 | $scope.botones.push(''); | 12 | $scope.botones.push(''); |
12 | } | 13 | } |
13 | }else { | 14 | }else { |
14 | while(($scope.botones.length % 3) !== 0) { | 15 | while(($scope.botones.length % 3) !== 0) { |
15 | $scope.botones.push(''); | 16 | $scope.botones.push(''); |
16 | } | 17 | } |
17 | } | 18 | } |
18 | }; | 19 | }; |
19 | 20 | ||
20 | function nombreFuncion(string) { | 21 | function nombreFuncion(string) { |
21 | var texto = 'seleccionar'; | 22 | var texto = 'seleccionar'; |
22 | var arr = string.split(' '); | 23 | var arr = string.split(' '); |
23 | arr.forEach(function(palabra) { | 24 | arr.forEach(function(palabra) { |
24 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 25 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
25 | texto += palabra; | 26 | texto += palabra; |
26 | }); | 27 | }); |
27 | return texto; | 28 | return texto; |
28 | } | 29 | } |
29 | 30 | ||
30 | $scope.ejecutarFuncion = function(nombre) { | 31 | $scope.ejecutarFuncion = function(nombre) { |
31 | $scope.$parent[nombreFuncion(nombre)](); | 32 | $scope.$parent[nombreFuncion(nombre)](); |
32 | }; | 33 | }; |
33 | }]); | 34 | }]); |
34 | 35 |