From 713c8e629da3f7323ee8ca9abe72ba825afe9fa4 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Sun, 16 Feb 2014 18:54:52 -0500 Subject: docs(design): ui-fixes for examples, layout and API components --- docs/app/assets/js/angular-bootstrap/bootstrap.js | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'docs/app/assets/js/angular-bootstrap') diff --git a/docs/app/assets/js/angular-bootstrap/bootstrap.js b/docs/app/assets/js/angular-bootstrap/bootstrap.js index b9b5e382..643b5a50 100644 --- a/docs/app/assets/js/angular-bootstrap/bootstrap.js +++ b/docs/app/assets/js/angular-bootstrap/bootstrap.js @@ -2,6 +2,56 @@ var directive = {}; +directive.runnableExample = ['$templateCache', '$document', function($templateCache, $document) { + var exampleClassNameSelector = '.runnable-example-file'; + var doc = $document[0]; + var tpl = + ''; + + return { + restrict: 'C', + controller : ['$scope', function($scope) { + $scope.setTab = function(index) { + var tab = $scope.tabs[index]; + $scope.activeTabIndex = index; + $scope.$broadcast('tabChange', index, tab); + }; + }], + compile : function(element) { + element.html(tpl + element.html()); + return function(scope, element) { + var tabs = [], now = Date.now(); + angular.forEach(doc.querySelectorAll(exampleClassNameSelector), + function(child, index) { + + tabs.push(child.getAttribute('name')); + }); + + if(tabs.length > 0) { + scope.tabs = tabs; + scope.$on('tabChange', function(e, index, title) { + var elements = doc.querySelectorAll(exampleClassNameSelector); + angular.forEach(elements, function(child) { + child.style.display = 'none'; + }); + var selected = elements[index]; + selected.style.display = 'block'; + }); + scope.setTab(0); + } + } + } + }; +}]; + directive.dropdownToggle = ['$document', '$location', '$window', function ($document, $location, $window) { -- cgit v1.2.3