Skip to content

Commit

Permalink
make top-nav methods a little easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
w33ble committed Jun 20, 2016
1 parent f46fa87 commit abda2f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/ui/public/kbn_top_nav/kbn_top_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ module.directive('kbnTopNav', function (Private) {
ng-repeat="menuItem in kbnTopNav.menuItems"
aria-label="{{::menuItem.description}}"
aria-haspopup="{{!menuItem.hasFunction}}"
aria-expanded="{{kbnTopNav.is(menuItem.key)}}"
ng-class="{active: kbnTopNav.is(menuItem.key)}"
ng-click="menuItem.run(menuItem)"
aria-expanded="{{kbnTopNav.isCurrent(menuItem.key)}}"
ng-class="{active: kbnTopNav.isCurrent(menuItem.key)}"
ng-click="menuItem.run(menuItem, kbnTopNav)"
ng-bind="menuItem.label">
</button>
</div>
Expand Down
12 changes: 6 additions & 6 deletions src/ui/public/kbn_top_nav/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function ($compile) {
}

// change the current key and rerender
set(key) {
setCurrent(key) {
if (key && !this.templates.hasOwnProperty(key)) {
throw new TypeError(`KbnTopNav: unknown template key "${key}"`);
}
Expand All @@ -39,11 +39,11 @@ export default function ($compile) {
}

// little usability helpers
which() { return this.currentKey; }
is(key) { return this.which() === key; }
open(key) { this.set(key); }
close(key) { (!key || this.is(key)) && this.set(null); }
toggle(key) { this.set(this.is(key) ? null : key); }
getCurrent() { return this.currentKey; }
isCurrent(key) { return this.getCurrent() === key; }
open(key) { this.setCurrent(key); }
close(key) { (!key || this.isCurrent(key)) && this.setCurrent(null); }
toggle(key) { this.setCurrent(this.isCurrent(key) ? null : key); }

// apply the defaults to individual options
_applyOptDefault(opt = {}) {
Expand Down

0 comments on commit abda2f6

Please sign in to comment.