From 2f571a9c830df814902fbdda1e9240b36bb64e3e Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Thu, 16 May 2013 14:55:56 -0400 Subject: chore(ngdocs): move angular-bootstrap.js to be generated only inside the docs and remove from the build process --- docs/components/bootstrap/bootstrap.js | 208 +++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 docs/components/bootstrap/bootstrap.js (limited to 'docs/components/bootstrap/bootstrap.js') diff --git a/docs/components/bootstrap/bootstrap.js b/docs/components/bootstrap/bootstrap.js new file mode 100644 index 00000000..91d6590e --- /dev/null +++ b/docs/components/bootstrap/bootstrap.js @@ -0,0 +1,208 @@ +'use strict'; + +var directive = {}; + +directive.dropdownToggle = + ['$document', '$location', '$window', + function ($document, $location, $window) { + var openElement = null, close; + return { + restrict: 'C', + link: function(scope, element, attrs) { + scope.$watch(function dropdownTogglePathWatch(){return $location.path();}, function dropdownTogglePathWatchAction() { + close && close(); + }); + + element.parent().bind('click', function(event) { + close && close(); + }); + + element.bind('click', function(event) { + event.preventDefault(); + event.stopPropagation(); + + var iWasOpen = false; + + if (openElement) { + iWasOpen = openElement === element; + close(); + } + + if (!iWasOpen){ + element.parent().addClass('open'); + openElement = element; + + close = function (event) { + event && event.preventDefault(); + event && event.stopPropagation(); + $document.unbind('click', close); + element.parent().removeClass('open'); + close = null; + openElement = null; + } + + $document.bind('click', close); + } + }); + } + }; + }]; + +directive.syntax = function() { + return { + restrict: 'A', + link: function(scope, element, attrs) { + function makeLink(type, text, link, icon) { + return '' + + ' ' + text + + ''; + }; + var html = ''; + var nav = angular.element(html); + var node = element[0]; + var par = node.parentNode; + par.insertBefore(nav[0], node); + } + } +} + +directive.tabbable = function() { + return { + restrict: 'C', + compile: function(element) { + var navTabs = angular.element('
'), + tabContent = angular.element(''); + + tabContent.append(element.contents()); + element.append(navTabs).append(tabContent); + }, + controller: ['$scope', '$element', function($scope, $element) { + var navTabs = $element.contents().eq(0), + ngModel = $element.controller('ngModel') || {}, + tabs = [], + selectedTab; + + ngModel.$render = function() { + var $viewValue = this.$viewValue; + + if (selectedTab ? (selectedTab.value != $viewValue) : $viewValue) { + if(selectedTab) { + selectedTab.paneElement.removeClass('active'); + selectedTab.tabElement.removeClass('active'); + selectedTab = null; + } + if($viewValue) { + for(var i = 0, ii = tabs.length; i < ii; i++) { + if ($viewValue == tabs[i].value) { + selectedTab = tabs[i]; + break; + } + } + if (selectedTab) { + selectedTab.paneElement.addClass('active'); + selectedTab.tabElement.addClass('active'); + } + } + + } + }; + + this.addPane = function(element, attr) { + var li = angular.element('