This repository has been archived by the owner on Apr 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsytabs.js
198 lines (157 loc) · 5.71 KB
/
sytabs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
(function () {
'use strict';
var sytabsDirective = __webpack_require__(1);
var sypaneDirective = __webpack_require__(2);
var sylinkDirective = __webpack_require__(3);
module.exports = exports = angular.module('sy.tabs', []).directive('syTabs', sytabsDirective).directive('syPane', sypaneDirective).directive('syLink', sylinkDirective);
})();
/***/ },
/* 1 */
/***/ function(module, exports) {
'use strict';
(function () {
'use strict';
module.exports = function syTabs() {
return {
restrict: 'E',
transclude: true,
scope: {
animated: '=',
justified: '=',
scrollable: '=',
scrollableHeight: '='
},
controller: ['$scope', function ($scope) {
var self = this,
panes = self.panes = $scope.panes = [];
$scope.$watchGroup(['animated', 'scrollable', 'scrollableHeight'], function (newValue, oldValue) {
$scope.$broadcast('attrChange', newValue);
});
$scope.$watch('panes', function (newValue, oldValue) {
$scope.$broadcast('panesChange', newValue);
});
self.animated = $scope.animated;
self.scrollable = $scope.scrollable;
self.scrollableHeight = $scope.scrollableHeight;
$scope.select = this.select = function (pane) {
angular.forEach(panes, function (_pane) {
return _pane.selected = _pane == pane ? true : false;
});
};
this.addPane = function (pane) {
if (panes.length === 0) $scope.select(pane);
panes.push(pane);
};
}],
template: '<div class="tabbable">\n <ul class="nav nav-tabs" data-ng-class="{\'nav-justified\': justifed}">\n <li ng-repeat="pane in panes" data-ng-class="{active: pane.selected}">\n <a href="javascript:void(0)" data-ng-click="select(pane)">\n {{pane.title}}\n <span data-ng-if="pane.icon" data-ng-class="pane.icon"></span>\n </a>\n </li>\n </ul>\n <div class="tab-content" data-ng-transclude></div>\n </div>'
};
};
})();
/***/ },
/* 2 */
/***/ function(module, exports) {
'use strict';
(function () {
'use strict';
module.exports = exports = function syPane() {
return {
require: '^syTabs',
restrict: 'E',
transclude: true,
scope: {
title: '@',
icon: '@'
},
link: function link(scope, ele, attrs, tabsCtrl) {
if (angular.isUndefined(scope.title)) scope.title = 'Pane';
if (angular.isUndefined(scope.icon)) scope.icon = false;
tabsCtrl.addPane(scope);
/**
* [setAnim description]
* @param {[type]} bool [description]
*/
function setAnim(bool) {
scope.anim = bool;
}
/**
* [setScrollable description]
* @param {[type]} bool [description]
* @param {[type]} height [description]
*/
function setScrollable(bool, height) {
var tabPanes = angular.element(document.querySelectorAll('.tab-pane')),
css = bool ? { maxHeight: height + 'px', overflowY: 'auto' } : { maxHeight: '', overflowY: '' };
tabPanes.css(css);
}
scope.$on('attrChange', function (e, values) {
setAnim(values[0]);
setScrollable(values[1], values[2]);
});
setAnim(tabsCtrl.animated);
setScrollable(tabsCtrl.scrollable);
},
template: '<div class="tab-pane fade" data-ng-class="{fade: anim, in: selected, hidden: !anim && !selected}" data-ng-transclude></div>'
};
};
})();
/***/ },
/* 3 */
/***/ function(module, exports) {
'use strict';
(function () {
'use strict';
module.exports = exports = function syLink() {
return {
require: '^syTabs',
restrict: 'E',
scope: {
pane: '@'
},
link: function link(scope, ele, attr, tabsCtrl) {
scope.pane = angular.isUndefined(scope.pane) ? 0 : parseInt(scope.pane);
scope.$on('panesChange', function (e, val) {
return scope.panes = val;
});
scope.select = tabsCtrl.select;
},
template: '<a href="javascript:void(0)" data-ng-click="select(panes[pane])">{{panes[pane].title}}</a>'
};
};
})();
/***/ }
/******/ ]);