Use single expression instead of a function call to show selected tab

This commit is contained in:
Siteshwar Vashisht 2013-10-19 22:47:18 +05:30
parent 892cc7da31
commit 3d2315d596
2 changed files with 6 additions and 15 deletions

View File

@ -97,12 +97,12 @@ function interpret_color(str) {
<span style="font-size: 16pt; color: #8888FF">fish</span><p id="global_error" class="error_msg" error-message></p>
<div id="parent">
<div id="tab_parent" ng-controller="main">
<div ng-class="tabCssClass('colors')" id="tab_colors" ng-click="changeView('colors')">colors</div>
<div ng-class="tabCssClass('prompt')" id="tab_prompt" ng-click="changeView('prompt')">prompt</div>
<div ng-class="tabCssClass('functions')" id="tab_functions" ng-click="changeView('functions')">functions</div>
<div ng-class="tabCssClass('variables')" id="tab_variables" ng-click="changeView('variables')">variables</div>
<div ng-class="tabCssClass('history')" id="tab_history" ng-click="changeView('history')">history</div>
<div ng-class="tabCssClass('bindings')" id="tab_bindings" ng-click="changeView('bindings')">bindings</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab =='colors'}" id="tab_colors" ng-click="changeView('colors')">colors</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'prompt'}" id="tab_prompt" ng-click="changeView('prompt')">prompt</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'functions'}" id="tab_functions" ng-click="changeView('functions')">functions</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'variables'}" id="tab_variables" ng-click="changeView('variables')">variables</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'history'}" id="tab_history" ng-click="changeView('history')">history</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'bindings'}" id="tab_bindings" ng-click="changeView('bindings')">bindings</div>
</div>
<div id="tab_contents">
<ng-view></ng-view>

View File

@ -7,15 +7,6 @@ controllers.controller("main", function($scope, $location) {
$location.path(view);
$scope.currentTab = view;
}
$scope.tabCssClass = function(view) {
var cls = "tab";
if ($scope.currentTab == view) {
cls += " selected_tab";
}
return cls;
}
})
controllers.controller("colorsController", function($scope, $http) {