github.com/sym3tri/etcd@v0.2.1-0.20140422215517-a563d82f95d6/mod/dashboard/app/ui/breadcrumb.js (about) 1 /** 2 * @fileoverview 3 * 4 */ 5 6 'use strict'; 7 8 angular.module('etcd.ui') 9 .directive('coBreadcrumb', function(_, pathSvc) { 10 11 return { 12 templateUrl: '/ui/breadcrumb.html', 13 restrict: 'E', 14 replace: true, 15 scope: { 16 path: '=', 17 callback: '&' 18 }, 19 link: function postLink(scope, elem, attrs) { 20 21 scope.goToRoot = function() { 22 scope.callback({ path: '/' }); 23 }; 24 25 scope.onClick = function(part) { 26 var selected, selectedPath; 27 selected = scope.pathParts.slice(0, scope.pathParts.indexOf(part) + 1); 28 selectedPath = pathSvc.make(_.pluck(selected, 'name')); 29 scope.callback({ path: selectedPath }); 30 }; 31 32 scope.$watch('path', function(path) { 33 scope.pathParts = pathSvc.explode(path).map(function(part) { 34 return { 35 name: part 36 }; 37 }); 38 }); 39 40 } 41 }; 42 43 });