Permalink
Browse files

Change collapse buttons' colors when bind options exist for its key g…

…roup in Multi-Key Generator
  • Loading branch information...
1 parent 20defba commit ff9766730e3484ec38b54692eab310c166246023 @jessewebb committed Sep 8, 2015
Showing with 38 additions and 4 deletions.
  1. +32 −1 js/controllers.js
  2. +6 −3 partials/multi-key-generator.phtml
View
@@ -102,7 +102,11 @@ buyndsControllers.controller('SingleKeyGenCtrl', ['$scope', '$route', '$window',
};
}]);
-buyndsControllers.controller('MultiKeyGenCtrl', ['$scope', '$modal', '$route', '$window', 'bindBuilder', function ($scope, $modal, $route, $window, bindBuilder) {
+buyndsControllers.controller('MultiKeyGenCtrl', ['$scope', '$modal', '$route', '$window', 'bindBuilder', 'dataService', function ($scope, $modal, $route, $window, bindBuilder, dataService) {
+
+ dataService.getBindableKeysAsync().then(function(data) {
+ $scope.bindableKeys = data;
+ });
$scope.bindOptionsMap = {};
$scope.buyBinds = [];
@@ -118,6 +122,33 @@ buyndsControllers.controller('MultiKeyGenCtrl', ['$scope', '$modal', '$route', '
return keyBind in $scope.bindOptionsMap;
};
+ var hasKeyGroupKeypadKeyBindOptions = function (keyGroupName) {
+ for (var i = 0; i < $scope.bindableKeys.keyGroups.length; i++) {
+ var keyGroup = $scope.bindableKeys.keyGroups[i];
+ if (keyGroup.name == keyGroupName) {
+ for (var j = 0; j < keyGroup.keys.length; j++) {
+ var key = keyGroup.keys[j];
+ if (key.bind in $scope.bindOptionsMap) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ };
+
+ $scope.hasNumpadKeypadKeyBindOptions = function () {
+ return hasKeyGroupKeypadKeyBindOptions('Numeric Keypad');
+ };
+
+ $scope.hasNavKeysKeypadKeyBindOptions = function () {
+ return hasKeyGroupKeypadKeyBindOptions('Navigation Keys');
+ };
+
+ $scope.hasFuncKeysKeypadKeyBindOptions = function () {
+ return hasKeyGroupKeypadKeyBindOptions('Function Keys');
+ };
+
$scope.hasGeneratedBuyBinds = function() {
return $scope.buyBinds.length > 0;
};
@@ -11,7 +11,8 @@
<div class="form-group">
<label class="control-label col-lg-4 col-sm-3 col-xs-12">
Numeric Keypad
- <button class="btn btn-sm btn-default" ng-click="showNumpadKeypad = !showNumpadKeypad">
+ <button class="btn btn-sm btn-default" ng-click="showNumpadKeypad = !showNumpadKeypad"
+ ng-class="{ 'btn-default': !hasNumpadKeypadKeyBindOptions(), 'btn-info': hasNumpadKeypadKeyBindOptions() }">
<span class="glyphicon"
ng-class="{ 'glyphicon-collapse-up': showNumpadKeypad, 'glyphicon-collapse-down': !showNumpadKeypad }"></span>
</button>
@@ -124,7 +125,8 @@
<div class="form-group">
<label class="control-label col-lg-4 col-sm-3 col-xs-12">
Navigation Keys
- <button class="btn btn-sm btn-default" ng-click="showNavKeysKeypad = !showNavKeysKeypad">
+ <button class="btn btn-sm btn-default" ng-click="showNavKeysKeypad = !showNavKeysKeypad"
+ ng-class="{ 'btn-default': !hasNavKeysKeypadKeyBindOptions(), 'btn-info': hasNavKeysKeypadKeyBindOptions() }">
<span class="glyphicon"
ng-class="{ 'glyphicon-collapse-up': showNavKeysKeypad, 'glyphicon-collapse-down': !showNavKeysKeypad }"></span>
</button>
@@ -214,7 +216,8 @@
<div class="form-group">
<label class="control-label col-lg-4 col-sm-3 col-xs-12">
Function Keys
- <button class="btn btn-sm btn-default" ng-click="showFuncKeysKeypad = !showFuncKeysKeypad">
+ <button class="btn btn-sm btn-default" ng-click="showFuncKeysKeypad = !showFuncKeysKeypad"
+ ng-class="{ 'btn-default': !hasFuncKeysKeypadKeyBindOptions(), 'btn-info': hasFuncKeysKeypadKeyBindOptions() }">
<span class="glyphicon"
ng-class="{ 'glyphicon-collapse-up': showFuncKeysKeypad, 'glyphicon-collapse-down': !showFuncKeysKeypad }"></span>
</button>

0 comments on commit ff97667

Please sign in to comment.