Skip to content

Instantly share code, notes, and snippets.

@melbourne2991
Created February 5, 2014 13:45
Show Gist options
  • Save melbourne2991/8823903 to your computer and use it in GitHub Desktop.
Save melbourne2991/8823903 to your computer and use it in GitHub Desktop.
navbarbstrpimp
pantherDirectives.directive('bootstrapNavBar', function() {
return {
scope: {},
template: '<nav class="navbar navbar-default" role="navigation">'
+ '<div class="container-fluid" data-ng-transclude>'
+ '</div>'
+ '</nav>',
transclude: true,
replace: true
}
}).directive('navBarHeader', function() {
return {
scope: {},
template: '<div class="navbar-header">'
+ '<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">'
+ '<span class="sr-only">Toggle navigation</span>'
+ '<span class="icon-bar"></span>'
+ '<span class="icon-bar"></span>'
+ '<span class="icon-bar"></span>'
+ '</button>'
+ '<a class="navbar-brand" href="#" data-ng-transclude></a>'
+ '</div>',
transclude: true,
replace: true
}
}).directive('navBarBody', function() {
return {
scope: {},
template: '<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" data-ng-transclude>'
+ '</div>',
transclude: true,
replace: true,
controller: function($scope, $element) {
var items = $scope.items = [];
this.select = function(item) {
angular.forEach(items, function(item) {
item.selected = false;
});
item.selected = true;
}
this.addItem = function(item) {
if(items.length === 0) {
this.select(item);
}
items.push(item);
}
}
}
}).directive('navBarDropDown', function() {
return {
scope: {},
transclude: true,
replace: true
}
}).directive('navItem', function() {
return {
scope: true,
transclude: true,
require: '^navBarBody',
template: '<li ngclass="" data-ng-click="select(this_scope)" data-ng-class="{active:selected}" data-ng-transclude></li>',
replace: true,
priority: 1000,
controller: function($scope, $element, $attrs) {
},
link: function(scope, element, attrs, navBarBody) {
navBarBody.addItem(scope);
scope.this_scope = scope;
scope.select = function(scope) {
navBarBody.select(scope);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment