From 6636a6f00f4bb44aa8178e43bd3490187886c32f Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Tue, 13 Nov 2012 19:03:12 -0500 Subject: [PATCH] fix ui issues with enabling batarang --- css/panel.css | 13 +++++++++++ js/controllers/PanelCtrl.js | 19 ---------------- js/directives/tabs.js | 43 +++++++++++++++++++++++++++++++++++-- panel.html | 11 +--------- 4 files changed, 55 insertions(+), 31 deletions(-) delete mode 100644 js/controllers/PanelCtrl.js diff --git a/css/panel.css b/css/panel.css index 65f11d6..c3ed388 100644 --- a/css/panel.css +++ b/css/panel.css @@ -23,6 +23,19 @@ body { background-color: #E0E0E0; } +.bat-nav-check { + background-color: #fff; + border: 1px solid #ddd; + border-bottom-color: transparent; + border-radius: 4px 4px 0 0; + + padding: 8px 12px 8px 12px; + margin-right: 2px; + line-height: 18px; +} +.bat-nav-check input[type="checkbox"] { + margin: 0; +} /* * Slider widget style based on jquery-ui-bootstrap diff --git a/js/controllers/PanelCtrl.js b/js/controllers/PanelCtrl.js deleted file mode 100644 index 9e7c928..0000000 --- a/js/controllers/PanelCtrl.js +++ /dev/null @@ -1,19 +0,0 @@ -panelApp.controller('PanelCtrl', function PanelCtrl($scope, appContext) { - - // TODO: remove this (newVal === oldVal ?) - var first = true; - - appContext.getDebug(function (result) { - $scope.enable = result; - - $scope.$watch('enable', function (newVal, oldVal) { - // prevent refresh on initial pageload - if (first) { - first = false; - } else { - appContext.setDebug(newVal); - } - }); - }); - -}); diff --git a/js/directives/tabs.js b/js/directives/tabs.js index 4e4ea7d..b3f9e6a 100644 --- a/js/directives/tabs.js +++ b/js/directives/tabs.js @@ -10,18 +10,52 @@ panelApp.directive('batTabs', function ($compile, $templateCache, $http) { '
  • '+ '{{pane.title}}' + '
  • ' + + + '
  • ' + + '
    ' + + ' ' + + 'Enable' + + '
    ' + + '
  • ' + + '' + '' + '
    ' + '
    ' + '', replace: true, - controller: function ($scope, $element) { + controller: function ($scope, appContext) { var panes = $scope.panes = []; this.addPane = function(pane) { panes.push(pane); }; + + // TODO: remove this (newVal === oldVal ?) + var first = true; + + appContext.getDebug(function (result) { + $scope.enable = result; + + $scope.$watch('enable', function (newVal, oldVal) { + // prevent refresh on initial pageload + if (first) { + first = false; + } else { + appContext.setDebug(newVal); + if (!newVal) { + $scope.lastPane = $scope.currentPane; + $scope.select($scope.panes[$scope.panes.length - 1]); + } else { + $scope.select($scope.lastPane); + } + } + }); + + if (result) { + $scope.select($scope.panes[0]); + } + }); }, link: function (scope, element, attr) { @@ -36,6 +70,9 @@ panelApp.directive('batTabs', function ($compile, $templateCache, $http) { } scope.select = function (pane) { + if (!scope.enable && pane !== scope.panes[scope.panes.length - 1]) { + return; + } $http.get(pane.src, { cache: $templateCache }). then(function (response) { var template = response.data; @@ -51,9 +88,11 @@ panelApp.directive('batTabs', function ($compile, $templateCache, $http) { pane.selected = false; }); pane.selected = true; + scope.currentPane = pane; }; - scope.select(scope.panes[0]); + scope.lastPane = scope.panes[0]; + scope.select(scope.panes[scope.panes.length - 1]); } }; diff --git a/panel.html b/panel.html index d07112a..b014312 100644 --- a/panel.html +++ b/panel.html @@ -41,19 +41,10 @@ - - - +