angularjs-rails 1.2.0.rc2 → 1.2.0.rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,175 +0,0 @@
1
- /**
2
- * @license AngularJS v1.0.7
3
- * (c) 2010-2012 Google, Inc. http://angularjs.org
4
- * License: MIT
5
- */
6
- (function(window, angular, undefined) {
7
- 'use strict';
8
-
9
- var directive = {};
10
-
11
- directive.dropdownToggle =
12
- ['$document', '$location', '$window',
13
- function ($document, $location, $window) {
14
- var openElement = null, close;
15
- return {
16
- restrict: 'C',
17
- link: function(scope, element, attrs) {
18
- scope.$watch(function dropdownTogglePathWatch(){return $location.path();}, function dropdownTogglePathWatchAction() {
19
- close && close();
20
- });
21
-
22
- element.parent().bind('click', function(event) {
23
- close && close();
24
- });
25
-
26
- element.bind('click', function(event) {
27
- event.preventDefault();
28
- event.stopPropagation();
29
-
30
- var iWasOpen = false;
31
-
32
- if (openElement) {
33
- iWasOpen = openElement === element;
34
- close();
35
- }
36
-
37
- if (!iWasOpen){
38
- element.parent().addClass('open');
39
- openElement = element;
40
-
41
- close = function (event) {
42
- event && event.preventDefault();
43
- event && event.stopPropagation();
44
- $document.unbind('click', close);
45
- element.parent().removeClass('open');
46
- close = null;
47
- openElement = null;
48
- }
49
-
50
- $document.bind('click', close);
51
- }
52
- });
53
- }
54
- };
55
- }];
56
-
57
-
58
- directive.tabbable = function() {
59
- return {
60
- restrict: 'C',
61
- compile: function(element) {
62
- var navTabs = angular.element('<ul class="nav nav-tabs"></ul>'),
63
- tabContent = angular.element('<div class="tab-content"></div>');
64
-
65
- tabContent.append(element.contents());
66
- element.append(navTabs).append(tabContent);
67
- },
68
- controller: ['$scope', '$element', function($scope, $element) {
69
- var navTabs = $element.contents().eq(0),
70
- ngModel = $element.controller('ngModel') || {},
71
- tabs = [],
72
- selectedTab;
73
-
74
- ngModel.$render = function() {
75
- var $viewValue = this.$viewValue;
76
-
77
- if (selectedTab ? (selectedTab.value != $viewValue) : $viewValue) {
78
- if(selectedTab) {
79
- selectedTab.paneElement.removeClass('active');
80
- selectedTab.tabElement.removeClass('active');
81
- selectedTab = null;
82
- }
83
- if($viewValue) {
84
- for(var i = 0, ii = tabs.length; i < ii; i++) {
85
- if ($viewValue == tabs[i].value) {
86
- selectedTab = tabs[i];
87
- break;
88
- }
89
- }
90
- if (selectedTab) {
91
- selectedTab.paneElement.addClass('active');
92
- selectedTab.tabElement.addClass('active');
93
- }
94
- }
95
-
96
- }
97
- };
98
-
99
- this.addPane = function(element, attr) {
100
- var li = angular.element('<li><a href></a></li>'),
101
- a = li.find('a'),
102
- tab = {
103
- paneElement: element,
104
- paneAttrs: attr,
105
- tabElement: li
106
- };
107
-
108
- tabs.push(tab);
109
-
110
- attr.$observe('value', update)();
111
- attr.$observe('title', function(){ update(); a.text(tab.title); })();
112
-
113
- function update() {
114
- tab.title = attr.title;
115
- tab.value = attr.value || attr.title;
116
- if (!ngModel.$setViewValue && (!ngModel.$viewValue || tab == selectedTab)) {
117
- // we are not part of angular
118
- ngModel.$viewValue = tab.value;
119
- }
120
- ngModel.$render();
121
- }
122
-
123
- navTabs.append(li);
124
- li.bind('click', function(event) {
125
- event.preventDefault();
126
- event.stopPropagation();
127
- if (ngModel.$setViewValue) {
128
- $scope.$apply(function() {
129
- ngModel.$setViewValue(tab.value);
130
- ngModel.$render();
131
- });
132
- } else {
133
- // we are not part of angular
134
- ngModel.$viewValue = tab.value;
135
- ngModel.$render();
136
- }
137
- });
138
-
139
- return function() {
140
- tab.tabElement.remove();
141
- for(var i = 0, ii = tabs.length; i < ii; i++ ) {
142
- if (tab == tabs[i]) {
143
- tabs.splice(i, 1);
144
- }
145
- }
146
- };
147
- }
148
- }]
149
- };
150
- };
151
-
152
- directive.table = function() {
153
- return {
154
- restrict: 'E',
155
- link: function(scope, element, attrs) {
156
- element[0].className = 'table table-bordered table-striped code-table';
157
- }
158
- };
159
- };
160
-
161
- directive.tabPane = function() {
162
- return {
163
- require: '^tabbable',
164
- restrict: 'C',
165
- link: function(scope, element, attrs, tabsCtrl) {
166
- element.bind('$remove', tabsCtrl.addPane(element, attrs));
167
- }
168
- };
169
- };
170
-
171
-
172
- angular.module('bootstrap', []).directive(directive);
173
-
174
-
175
- })(window, window.angular);