fomantic-ui 2.9.1-beta.16 → 2.9.1-beta.18
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.
- package/.eslintrc.js +109 -0
- package/.github/workflows/ci.yml +13 -3
- package/dist/components/accordion.css +1 -1
- package/dist/components/accordion.js +571 -598
- package/dist/components/accordion.min.css +1 -1
- package/dist/components/accordion.min.js +1 -1
- package/dist/components/ad.css +1 -1
- package/dist/components/ad.min.css +1 -1
- package/dist/components/api.js +1164 -1186
- package/dist/components/api.min.js +1 -1
- package/dist/components/breadcrumb.css +1 -1
- package/dist/components/breadcrumb.min.css +1 -1
- package/dist/components/button.css +1 -1
- package/dist/components/button.min.css +1 -1
- package/dist/components/calendar.css +1 -1
- package/dist/components/calendar.js +1897 -1818
- package/dist/components/calendar.min.css +1 -1
- package/dist/components/calendar.min.js +1 -1
- package/dist/components/card.css +1 -1
- package/dist/components/card.min.css +1 -1
- package/dist/components/checkbox.css +1 -1
- package/dist/components/checkbox.js +844 -841
- package/dist/components/checkbox.min.css +1 -1
- package/dist/components/checkbox.min.js +1 -1
- package/dist/components/comment.css +1 -1
- package/dist/components/comment.min.css +1 -1
- package/dist/components/container.css +3 -1
- package/dist/components/container.min.css +2 -2
- package/dist/components/dimmer.css +1 -1
- package/dist/components/dimmer.js +710 -737
- package/dist/components/dimmer.min.css +1 -1
- package/dist/components/dimmer.min.js +1 -1
- package/dist/components/divider.css +1 -1
- package/dist/components/divider.min.css +1 -1
- package/dist/components/dropdown.css +11 -8
- package/dist/components/dropdown.js +4163 -4234
- package/dist/components/dropdown.min.css +2 -2
- package/dist/components/dropdown.min.js +2 -2
- package/dist/components/embed.css +1 -1
- package/dist/components/embed.js +653 -675
- package/dist/components/embed.min.css +1 -1
- package/dist/components/embed.min.js +1 -1
- package/dist/components/feed.css +1 -1
- package/dist/components/feed.min.css +1 -1
- package/dist/components/flag.css +1 -1
- package/dist/components/flag.min.css +1 -1
- package/dist/components/flyout.css +6 -3
- package/dist/components/flyout.js +1466 -1467
- package/dist/components/flyout.min.css +2 -2
- package/dist/components/flyout.min.js +1 -1
- package/dist/components/form.css +1 -1
- package/dist/components/form.js +1981 -2004
- package/dist/components/form.min.css +1 -1
- package/dist/components/form.min.js +1 -1
- package/dist/components/grid.css +1 -1
- package/dist/components/grid.min.css +1 -1
- package/dist/components/header.css +1 -1
- package/dist/components/header.min.css +1 -1
- package/dist/components/icon.css +1 -1
- package/dist/components/icon.min.css +1 -1
- package/dist/components/image.css +1 -1
- package/dist/components/image.min.css +1 -1
- package/dist/components/input.css +1 -1
- package/dist/components/input.min.css +1 -1
- package/dist/components/item.css +1 -1
- package/dist/components/item.min.css +1 -1
- package/dist/components/label.css +1 -1
- package/dist/components/label.min.css +1 -1
- package/dist/components/list.css +1 -1
- package/dist/components/list.min.css +1 -1
- package/dist/components/loader.css +1 -1
- package/dist/components/loader.min.css +1 -1
- package/dist/components/message.css +1 -1
- package/dist/components/message.min.css +1 -1
- package/dist/components/modal.css +7 -1
- package/dist/components/modal.js +1493 -1487
- package/dist/components/modal.min.css +2 -2
- package/dist/components/modal.min.js +1 -1
- package/dist/components/nag.css +1 -1
- package/dist/components/nag.js +520 -529
- package/dist/components/nag.min.css +1 -1
- package/dist/components/nag.min.js +1 -1
- package/dist/components/placeholder.css +1 -1
- package/dist/components/placeholder.min.css +1 -1
- package/dist/components/popup.css +1 -1
- package/dist/components/popup.js +1439 -1456
- package/dist/components/popup.min.css +1 -1
- package/dist/components/popup.min.js +1 -1
- package/dist/components/progress.css +1 -1
- package/dist/components/progress.js +971 -997
- package/dist/components/progress.min.css +1 -1
- package/dist/components/progress.min.js +1 -1
- package/dist/components/rail.css +1 -1
- package/dist/components/rail.min.css +1 -1
- package/dist/components/rating.css +1 -1
- package/dist/components/rating.js +508 -524
- package/dist/components/rating.min.css +1 -1
- package/dist/components/rating.min.js +1 -1
- package/dist/components/reset.css +1 -1
- package/dist/components/reset.min.css +1 -1
- package/dist/components/reveal.css +1 -1
- package/dist/components/reveal.min.css +1 -1
- package/dist/components/search.css +3 -1
- package/dist/components/search.js +1500 -1534
- package/dist/components/search.min.css +2 -2
- package/dist/components/search.min.js +1 -1
- package/dist/components/segment.css +3 -1
- package/dist/components/segment.min.css +2 -2
- package/dist/components/shape.css +1 -1
- package/dist/components/shape.js +794 -809
- package/dist/components/shape.min.css +1 -1
- package/dist/components/shape.min.js +1 -1
- package/dist/components/sidebar.css +3 -1
- package/dist/components/sidebar.js +1079 -1104
- package/dist/components/sidebar.min.css +2 -2
- package/dist/components/sidebar.min.js +1 -1
- package/dist/components/site.css +1 -1
- package/dist/components/site.js +457 -472
- package/dist/components/site.min.css +1 -1
- package/dist/components/site.min.js +1 -1
- package/dist/components/slider.js +1289 -1311
- package/dist/components/slider.min.js +1 -1
- package/dist/components/state.js +641 -657
- package/dist/components/state.min.js +1 -1
- package/dist/components/statistic.css +1 -1
- package/dist/components/statistic.min.css +1 -1
- package/dist/components/step.css +1 -1
- package/dist/components/step.min.css +1 -1
- package/dist/components/sticky.css +1 -1
- package/dist/components/sticky.js +859 -903
- package/dist/components/sticky.min.css +1 -1
- package/dist/components/sticky.min.js +1 -1
- package/dist/components/tab.css +1 -1
- package/dist/components/tab.js +923 -963
- package/dist/components/tab.min.css +1 -1
- package/dist/components/tab.min.js +1 -1
- package/dist/components/table.css +5 -1
- package/dist/components/table.min.css +2 -2
- package/dist/components/text.css +1 -1
- package/dist/components/text.min.css +1 -1
- package/dist/components/toast.css +1 -1
- package/dist/components/toast.js +889 -891
- package/dist/components/toast.min.css +1 -1
- package/dist/components/toast.min.js +1 -1
- package/dist/components/transition.css +1 -1
- package/dist/components/transition.js +1043 -1077
- package/dist/components/transition.min.css +1 -1
- package/dist/components/transition.min.js +1 -1
- package/dist/components/visibility.js +1222 -1244
- package/dist/components/visibility.min.js +1 -1
- package/dist/semantic.css +84 -60
- package/dist/semantic.js +29033 -29475
- package/dist/semantic.min.css +2 -2
- package/dist/semantic.min.js +2 -2
- package/examples/assets/show-examples.js +13 -13
- package/gulpfile.js +9 -10
- package/package.json +5 -2
- package/scripts/nightly-version.js +81 -75
- package/src/definitions/behaviors/api.js +1163 -1185
- package/src/definitions/behaviors/form.js +1980 -2003
- package/src/definitions/behaviors/state.js +647 -663
- package/src/definitions/behaviors/visibility.js +1221 -1243
- package/src/definitions/collections/table.less +2 -0
- package/src/definitions/elements/container.less +1 -0
- package/src/definitions/elements/segment.less +1 -0
- package/src/definitions/globals/site.js +456 -471
- package/src/definitions/modules/accordion.js +570 -597
- package/src/definitions/modules/calendar.js +1896 -1817
- package/src/definitions/modules/checkbox.js +849 -846
- package/src/definitions/modules/dimmer.js +709 -736
- package/src/definitions/modules/dropdown.js +4162 -4233
- package/src/definitions/modules/dropdown.less +5 -8
- package/src/definitions/modules/embed.js +652 -674
- package/src/definitions/modules/flyout.js +1465 -1466
- package/src/definitions/modules/flyout.less +15 -12
- package/src/definitions/modules/modal.js +1492 -1486
- package/src/definitions/modules/modal.less +3 -0
- package/src/definitions/modules/nag.js +519 -528
- package/src/definitions/modules/popup.js +1438 -1455
- package/src/definitions/modules/progress.js +970 -996
- package/src/definitions/modules/rating.js +507 -523
- package/src/definitions/modules/search.js +1499 -1533
- package/src/definitions/modules/search.less +1 -0
- package/src/definitions/modules/shape.js +801 -816
- package/src/definitions/modules/sidebar.js +1078 -1103
- package/src/definitions/modules/sidebar.less +1 -0
- package/src/definitions/modules/slider.js +1288 -1310
- package/src/definitions/modules/sticky.js +875 -919
- package/src/definitions/modules/tab.js +922 -962
- package/src/definitions/modules/toast.js +888 -890
- package/src/definitions/modules/transition.js +1048 -1082
- package/src/themes/default/elements/container.variables +0 -7
- package/src/themes/default/elements/segment.variables +0 -7
- package/src/themes/default/globals/site.variables +7 -0
- package/src/themes/default/globals/variation.variables +1 -0
- package/tasks/admin/components/create.js +274 -276
- package/tasks/admin/components/init.js +123 -130
- package/tasks/admin/components/update.js +149 -157
- package/tasks/admin/distributions/create.js +184 -187
- package/tasks/admin/distributions/init.js +123 -130
- package/tasks/admin/distributions/update.js +145 -152
- package/tasks/admin/publish.js +5 -7
- package/tasks/admin/register.js +36 -38
- package/tasks/admin/release.js +8 -10
- package/tasks/build/assets.js +42 -39
- package/tasks/build/css.js +225 -216
- package/tasks/build/javascript.js +118 -113
- package/tasks/build.js +10 -10
- package/tasks/check-install.js +14 -16
- package/tasks/clean.js +5 -5
- package/tasks/collections/admin.js +34 -36
- package/tasks/collections/build.js +18 -20
- package/tasks/collections/docs.js +9 -11
- package/tasks/collections/install.js +9 -11
- package/tasks/collections/rtl.js +9 -11
- package/tasks/collections/various.js +8 -10
- package/tasks/config/admin/github.js +17 -17
- package/tasks/config/admin/oauth.example.js +4 -4
- package/tasks/config/admin/release.js +98 -98
- package/tasks/config/admin/templates/component-package.js +9 -10
- package/tasks/config/admin/templates/css-package.js +18 -20
- package/tasks/config/admin/templates/less-package.js +11 -13
- package/tasks/config/defaults.js +116 -116
- package/tasks/config/docs.js +23 -23
- package/tasks/config/npm/gulpfile.js +8 -9
- package/tasks/config/project/config.js +127 -134
- package/tasks/config/project/install.js +715 -713
- package/tasks/config/project/release.js +32 -38
- package/tasks/config/tasks.js +163 -164
- package/tasks/config/user.js +23 -29
- package/tasks/docs/build.js +97 -95
- package/tasks/docs/metadata.js +90 -96
- package/tasks/docs/serve.js +80 -81
- package/tasks/install.js +370 -378
- package/tasks/rtl/build.js +2 -2
- package/tasks/rtl/watch.js +2 -2
- package/tasks/version.js +4 -4
- package/tasks/watch.js +28 -30
- package/test/meteor/assets.js +10 -13
- package/test/meteor/fonts.js +12 -13
- package/test/modules/accordion.spec.js +6 -8
- package/test/modules/checkbox.spec.js +5 -7
- package/test/modules/dropdown.spec.js +5 -7
- package/test/modules/modal.spec.js +6 -8
- package/test/modules/module.spec.js +158 -178
- package/test/modules/popup.spec.js +5 -7
- package/test/modules/search.spec.js +5 -7
- package/test/modules/shape.spec.js +5 -7
- package/test/modules/sidebar.spec.js +5 -7
- package/test/modules/tab.spec.js +6 -8
- package/test/modules/transition.spec.js +5 -7
- package/test/modules/video.spec.js +5 -7
@@ -8,1012 +8,972 @@
|
|
8
8
|
*
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
function
|
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
|
-
$allModules
|
50
|
-
.each(function() {
|
51
|
-
var
|
52
|
-
|
53
|
-
settings = ( $.isPlainObject(parameters) )
|
54
|
-
? $.extend(true, {}, $.fn.tab.settings, parameters)
|
55
|
-
: $.extend({}, $.fn.tab.settings),
|
56
|
-
|
57
|
-
className = settings.className,
|
58
|
-
metadata = settings.metadata,
|
59
|
-
selector = settings.selector,
|
60
|
-
error = settings.error,
|
61
|
-
regExp = settings.regExp,
|
62
|
-
|
63
|
-
eventNamespace = '.' + settings.namespace,
|
64
|
-
moduleNamespace = 'module-' + settings.namespace,
|
65
|
-
|
66
|
-
$module = $(this),
|
67
|
-
$context,
|
68
|
-
$tabs,
|
69
|
-
|
70
|
-
cache = {},
|
71
|
-
firstLoad = true,
|
72
|
-
recursionDepth = 0,
|
73
|
-
element = this,
|
74
|
-
instance = $module.data(moduleNamespace),
|
75
|
-
|
76
|
-
activeTabPath,
|
77
|
-
parameterArray,
|
78
|
-
module,
|
79
|
-
|
80
|
-
historyEvent
|
81
|
-
|
82
|
-
;
|
83
|
-
|
84
|
-
module = {
|
85
|
-
|
86
|
-
initialize: function() {
|
87
|
-
module.debug('Initializing tab menu item', $module);
|
88
|
-
module.fix.callbacks();
|
89
|
-
module.determineTabs();
|
90
|
-
|
91
|
-
module.debug('Determining tabs', settings.context, $tabs);
|
92
|
-
// set up automatic routing
|
93
|
-
if(settings.auto) {
|
94
|
-
module.set.auto();
|
95
|
-
}
|
96
|
-
module.bind.events();
|
97
|
-
|
98
|
-
if(settings.history && !initializedHistory) {
|
99
|
-
module.initializeHistory();
|
100
|
-
initializedHistory = true;
|
101
|
-
}
|
102
|
-
|
103
|
-
var activeTab = module.determine.activeTab();
|
104
|
-
if(settings.autoTabActivation && instance === undefined && activeTab == null) {
|
105
|
-
activeTab = settings.autoTabActivation === true ? module.get.initialPath() : settings.autoTabActivation;
|
106
|
-
module.debug('No active tab detected, setting tab active', activeTab);
|
107
|
-
module.changeTab(activeTab);
|
108
|
-
}
|
109
|
-
if(activeTab != null && settings.history) {
|
110
|
-
var autoUpdate = $.address.autoUpdate();
|
111
|
-
$.address.autoUpdate(false);
|
112
|
-
$.address.value(activeTab);
|
113
|
-
$.address.autoUpdate(autoUpdate);
|
114
|
-
}
|
115
|
-
|
116
|
-
module.instantiate();
|
117
|
-
},
|
11
|
+
(function ($, window, document, undefined) {
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
function isWindow(obj) {
|
15
|
+
return obj != null && obj === obj.window;
|
16
|
+
}
|
17
|
+
function isFunction(obj) {
|
18
|
+
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
|
19
|
+
}
|
20
|
+
|
21
|
+
window = (typeof window != 'undefined' && window.Math == Math)
|
22
|
+
? window
|
23
|
+
: (typeof self != 'undefined' && self.Math == Math)
|
24
|
+
? self
|
25
|
+
: Function('return this')();
|
26
|
+
|
27
|
+
$.fn.tab = function (parameters) {
|
28
|
+
var
|
29
|
+
// use window context if none specified
|
30
|
+
$allModules = isFunction(this)
|
31
|
+
? $(window)
|
32
|
+
: $(this),
|
33
|
+
$document = $(document),
|
34
|
+
moduleSelector = $allModules.selector || '',
|
35
|
+
time = new Date().getTime(),
|
36
|
+
performance = [],
|
37
|
+
|
38
|
+
query = arguments[0],
|
39
|
+
methodInvoked = (typeof query == 'string'),
|
40
|
+
queryArguments = [].slice.call(arguments, 1),
|
41
|
+
|
42
|
+
initializedHistory = false,
|
43
|
+
returnedValue
|
44
|
+
;
|
45
|
+
|
46
|
+
$allModules.each(function () {
|
47
|
+
var
|
118
48
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
$module
|
123
|
-
.data(moduleNamespace, module)
|
124
|
-
;
|
125
|
-
},
|
49
|
+
settings = ($.isPlainObject(parameters))
|
50
|
+
? $.extend(true, {}, $.fn.tab.settings, parameters)
|
51
|
+
: $.extend({}, $.fn.tab.settings),
|
126
52
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
;
|
133
|
-
},
|
53
|
+
className = settings.className,
|
54
|
+
metadata = settings.metadata,
|
55
|
+
selector = settings.selector,
|
56
|
+
error = settings.error,
|
57
|
+
regExp = settings.regExp,
|
134
58
|
|
135
|
-
|
136
|
-
|
137
|
-
// if using $.tab don't add events
|
138
|
-
if( !isWindow( element ) ) {
|
139
|
-
module.debug('Attaching tab activation events to element', $module);
|
140
|
-
$module
|
141
|
-
.on('click' + eventNamespace, module.event.click)
|
142
|
-
;
|
143
|
-
}
|
144
|
-
}
|
145
|
-
},
|
59
|
+
eventNamespace = '.' + settings.namespace,
|
60
|
+
moduleNamespace = 'module-' + settings.namespace,
|
146
61
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
;
|
62
|
+
$module = $(this),
|
63
|
+
$context,
|
64
|
+
$tabs,
|
151
65
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
else {
|
159
|
-
$reference = $module;
|
160
|
-
}
|
161
|
-
$context = $reference.parent();
|
162
|
-
module.verbose('Determined parent element for creating context', $context);
|
163
|
-
}
|
164
|
-
else if(settings.context) {
|
165
|
-
$context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context);
|
166
|
-
module.verbose('Using selector for tab context', settings.context, $context);
|
167
|
-
}
|
168
|
-
else {
|
169
|
-
$context = $('body');
|
170
|
-
}
|
171
|
-
// find tabs
|
172
|
-
if(settings.childrenOnly) {
|
173
|
-
$tabs = $context.children(selector.tabs);
|
174
|
-
module.debug('Searching tab context children for tabs', $context, $tabs);
|
175
|
-
}
|
176
|
-
else {
|
177
|
-
$tabs = $context.find(selector.tabs);
|
178
|
-
module.debug('Searching tab context for tabs', $context, $tabs);
|
179
|
-
}
|
180
|
-
},
|
66
|
+
cache = {},
|
67
|
+
firstLoad = true,
|
68
|
+
recursionDepth = 0,
|
69
|
+
element = this,
|
70
|
+
instance = $module.data(moduleNamespace),
|
181
71
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
if(parameters.onTabLoad) {
|
186
|
-
parameters.onLoad = parameters.onTabLoad;
|
187
|
-
delete parameters.onTabLoad;
|
188
|
-
module.error(error.legacyLoad, parameters.onLoad);
|
189
|
-
}
|
190
|
-
if(parameters.onTabInit) {
|
191
|
-
parameters.onFirstLoad = parameters.onTabInit;
|
192
|
-
delete parameters.onTabInit;
|
193
|
-
module.error(error.legacyInit, parameters.onFirstLoad);
|
194
|
-
}
|
195
|
-
settings = $.extend(true, {}, $.fn.tab.settings, parameters);
|
196
|
-
}
|
197
|
-
}
|
198
|
-
},
|
72
|
+
activeTabPath,
|
73
|
+
parameterArray,
|
74
|
+
module,
|
199
75
|
|
200
|
-
|
201
|
-
module.debug('Initializing page state');
|
202
|
-
if( $.address === undefined ) {
|
203
|
-
module.error(error.state);
|
204
|
-
return false;
|
205
|
-
}
|
206
|
-
else {
|
207
|
-
if(settings.historyType == 'state') {
|
208
|
-
module.debug('Using HTML5 to manage state');
|
209
|
-
if(settings.path !== false) {
|
210
|
-
$.address
|
211
|
-
.history(true)
|
212
|
-
.state(settings.path)
|
213
|
-
;
|
214
|
-
$(window).trigger('popstate');
|
215
|
-
}
|
216
|
-
else {
|
217
|
-
module.error(error.path);
|
218
|
-
return false;
|
219
|
-
}
|
220
|
-
}
|
221
|
-
$.address
|
222
|
-
.bind('change', module.event.history.change)
|
76
|
+
historyEvent
|
223
77
|
;
|
224
|
-
}
|
225
|
-
},
|
226
78
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
}
|
262
|
-
}
|
263
|
-
}
|
264
|
-
},
|
79
|
+
module = {
|
80
|
+
|
81
|
+
initialize: function () {
|
82
|
+
module.debug('Initializing tab menu item', $module);
|
83
|
+
module.fix.callbacks();
|
84
|
+
module.determineTabs();
|
85
|
+
|
86
|
+
module.debug('Determining tabs', settings.context, $tabs);
|
87
|
+
// set up automatic routing
|
88
|
+
if (settings.auto) {
|
89
|
+
module.set.auto();
|
90
|
+
}
|
91
|
+
module.bind.events();
|
92
|
+
|
93
|
+
if (settings.history && !initializedHistory) {
|
94
|
+
module.initializeHistory();
|
95
|
+
initializedHistory = true;
|
96
|
+
}
|
97
|
+
|
98
|
+
var activeTab = module.determine.activeTab();
|
99
|
+
if (settings.autoTabActivation && instance === undefined && activeTab == null) {
|
100
|
+
activeTab = settings.autoTabActivation === true ? module.get.initialPath() : settings.autoTabActivation;
|
101
|
+
module.debug('No active tab detected, setting tab active', activeTab);
|
102
|
+
module.changeTab(activeTab);
|
103
|
+
}
|
104
|
+
if (activeTab != null && settings.history) {
|
105
|
+
var autoUpdate = $.address.autoUpdate();
|
106
|
+
$.address.autoUpdate(false);
|
107
|
+
$.address.value(activeTab);
|
108
|
+
$.address.autoUpdate(autoUpdate);
|
109
|
+
}
|
110
|
+
|
111
|
+
module.instantiate();
|
112
|
+
},
|
265
113
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
114
|
+
instantiate: function () {
|
115
|
+
module.verbose('Storing instance of module', module);
|
116
|
+
instance = module;
|
117
|
+
$module
|
118
|
+
.data(moduleNamespace, module)
|
119
|
+
;
|
120
|
+
},
|
272
121
|
|
273
|
-
|
122
|
+
destroy: function () {
|
123
|
+
module.debug('Destroying tabs', $module);
|
124
|
+
$module
|
125
|
+
.removeData(moduleNamespace)
|
126
|
+
.off(eventNamespace)
|
127
|
+
;
|
128
|
+
},
|
274
129
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
remove: function(cacheKey) {
|
287
|
-
cacheKey = cacheKey || activeTabPath;
|
288
|
-
module.debug('Removing cached content for', cacheKey);
|
289
|
-
delete cache[cacheKey];
|
290
|
-
}
|
291
|
-
},
|
130
|
+
bind: {
|
131
|
+
events: function () {
|
132
|
+
// if using $.tab don't add events
|
133
|
+
if (!isWindow(element)) {
|
134
|
+
module.debug('Attaching tab activation events to element', $module);
|
135
|
+
$module
|
136
|
+
.on('click' + eventNamespace, module.event.click)
|
137
|
+
;
|
138
|
+
}
|
139
|
+
},
|
140
|
+
},
|
292
141
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
142
|
+
determineTabs: function () {
|
143
|
+
var
|
144
|
+
$reference
|
145
|
+
;
|
146
|
+
|
147
|
+
// determine tab context
|
148
|
+
if (settings.context === 'parent') {
|
149
|
+
if ($module.closest(selector.ui).length > 0) {
|
150
|
+
$reference = $module.closest(selector.ui);
|
151
|
+
module.verbose('Using closest UI element as parent', $reference);
|
152
|
+
} else {
|
153
|
+
$reference = $module;
|
154
|
+
}
|
155
|
+
$context = $reference.parent();
|
156
|
+
module.verbose('Determined parent element for creating context', $context);
|
157
|
+
} else if (settings.context) {
|
158
|
+
$context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context);
|
159
|
+
module.verbose('Using selector for tab context', settings.context, $context);
|
160
|
+
} else {
|
161
|
+
$context = $('body');
|
162
|
+
}
|
163
|
+
// find tabs
|
164
|
+
if (settings.childrenOnly) {
|
165
|
+
$tabs = $context.children(selector.tabs);
|
166
|
+
module.debug('Searching tab context children for tabs', $context, $tabs);
|
167
|
+
} else {
|
168
|
+
$tabs = $context.find(selector.tabs);
|
169
|
+
module.debug('Searching tab context for tabs', $context, $tabs);
|
170
|
+
}
|
171
|
+
},
|
299
172
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
loading: function(tabPath) {
|
318
|
-
var
|
319
|
-
$tab = module.get.tabElement(tabPath),
|
320
|
-
isLoading = $tab.hasClass(className.loading)
|
321
|
-
;
|
322
|
-
if(!isLoading) {
|
323
|
-
module.verbose('Setting loading state for', $tab);
|
324
|
-
$tab
|
325
|
-
.addClass(className.loading)
|
326
|
-
.siblings($tabs)
|
327
|
-
.removeClass(className.active + ' ' + className.loading)
|
328
|
-
;
|
329
|
-
if($tab.length > 0) {
|
330
|
-
settings.onRequest.call($tab[0], tabPath);
|
331
|
-
}
|
332
|
-
}
|
333
|
-
},
|
334
|
-
state: function(state) {
|
335
|
-
$.address.value(state);
|
336
|
-
}
|
337
|
-
},
|
173
|
+
fix: {
|
174
|
+
callbacks: function () {
|
175
|
+
if ($.isPlainObject(parameters) && (parameters.onTabLoad || parameters.onTabInit)) {
|
176
|
+
if (parameters.onTabLoad) {
|
177
|
+
parameters.onLoad = parameters.onTabLoad;
|
178
|
+
delete parameters.onTabLoad;
|
179
|
+
module.error(error.legacyLoad, parameters.onLoad);
|
180
|
+
}
|
181
|
+
if (parameters.onTabInit) {
|
182
|
+
parameters.onFirstLoad = parameters.onTabInit;
|
183
|
+
delete parameters.onTabInit;
|
184
|
+
module.error(error.legacyInit, parameters.onFirstLoad);
|
185
|
+
}
|
186
|
+
settings = $.extend(true, {}, $.fn.tab.settings, parameters);
|
187
|
+
}
|
188
|
+
},
|
189
|
+
},
|
338
190
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
191
|
+
initializeHistory: function () {
|
192
|
+
module.debug('Initializing page state');
|
193
|
+
if ($.address === undefined) {
|
194
|
+
module.error(error.state);
|
195
|
+
|
196
|
+
return false;
|
197
|
+
} else {
|
198
|
+
if (settings.historyType == 'state') {
|
199
|
+
module.debug('Using HTML5 to manage state');
|
200
|
+
if (settings.path !== false) {
|
201
|
+
$.address
|
202
|
+
.history(true)
|
203
|
+
.state(settings.path)
|
204
|
+
;
|
205
|
+
$(window).trigger('popstate');
|
206
|
+
} else {
|
207
|
+
module.error(error.path);
|
208
|
+
|
209
|
+
return false;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
$.address
|
213
|
+
.bind('change', module.event.history.change)
|
214
|
+
;
|
215
|
+
}
|
216
|
+
},
|
354
217
|
|
355
|
-
|
356
|
-
|
218
|
+
event: {
|
219
|
+
click: function (event) {
|
220
|
+
var
|
221
|
+
tabPath = $(this).data(metadata.tab)
|
222
|
+
;
|
223
|
+
if (tabPath !== undefined) {
|
224
|
+
if (settings.history) {
|
225
|
+
module.verbose('Updating page state', event);
|
226
|
+
$.address.value(tabPath);
|
227
|
+
} else {
|
228
|
+
module.verbose('Changing tab', event);
|
229
|
+
module.changeTab(tabPath);
|
230
|
+
}
|
231
|
+
event.preventDefault();
|
232
|
+
} else {
|
233
|
+
module.debug('No tab specified');
|
234
|
+
}
|
235
|
+
},
|
236
|
+
history: {
|
237
|
+
change: function (event) {
|
238
|
+
var
|
239
|
+
tabPath = event.pathNames.join('/') || module.get.initialPath(),
|
240
|
+
pageTitle = settings.templates.determineTitle(tabPath) || false
|
241
|
+
;
|
242
|
+
module.performance.display();
|
243
|
+
module.debug('History change event', tabPath, event);
|
244
|
+
historyEvent = event;
|
245
|
+
if (tabPath !== undefined) {
|
246
|
+
module.changeTab(tabPath);
|
247
|
+
}
|
248
|
+
if (pageTitle) {
|
249
|
+
$.address.title(pageTitle);
|
250
|
+
}
|
251
|
+
},
|
252
|
+
},
|
253
|
+
},
|
357
254
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
module.verbose('Looking for tab', tab);
|
365
|
-
if(isTab) {
|
366
|
-
module.verbose('Tab was found', tab);
|
367
|
-
// scope up
|
368
|
-
activeTabPath = currentPath;
|
369
|
-
parameterArray = module.utilities.filterArray(pathArray, currentPathArray);
|
370
|
-
|
371
|
-
if(isLastIndex) {
|
372
|
-
isLastTab = true;
|
373
|
-
}
|
374
|
-
else {
|
375
|
-
nextPathArray = pathArray.slice(0, index + 2);
|
376
|
-
nextPath = module.utilities.arrayToPath(nextPathArray);
|
377
|
-
isLastTab = ( !module.is.tab(nextPath) );
|
378
|
-
if(isLastTab) {
|
379
|
-
module.verbose('Tab parameters found', nextPathArray);
|
380
|
-
}
|
381
|
-
}
|
382
|
-
if (settings.onBeforeChange.call(element, currentPath) === false) {
|
383
|
-
module.debug('onBeforeChange returned false, cancelling tab change', $tab);
|
384
|
-
return false;
|
385
|
-
}
|
386
|
-
if(isLastTab && remoteContent) {
|
387
|
-
if(!shouldIgnoreLoad) {
|
388
|
-
module.activate.navigation(currentPath);
|
389
|
-
module.fetch.content(currentPath, tabPath);
|
390
|
-
}
|
391
|
-
else {
|
392
|
-
module.debug('Ignoring remote content on first tab load', currentPath);
|
393
|
-
firstLoad = false;
|
394
|
-
module.cache.add(tabPath, $tab.html());
|
395
|
-
module.activate.all(currentPath);
|
396
|
-
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
397
|
-
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
398
|
-
}
|
399
|
-
return false;
|
400
|
-
}
|
401
|
-
else {
|
402
|
-
module.debug('Opened local tab', currentPath);
|
403
|
-
module.activate.all(currentPath);
|
404
|
-
if( !module.cache.read(currentPath) ) {
|
405
|
-
module.cache.add(currentPath, true);
|
406
|
-
module.debug('First time tab loaded calling tab init');
|
407
|
-
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
408
|
-
}
|
409
|
-
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
410
|
-
}
|
255
|
+
refresh: function () {
|
256
|
+
if (activeTabPath) {
|
257
|
+
module.debug('Refreshing tab', activeTabPath);
|
258
|
+
module.changeTab(activeTabPath);
|
259
|
+
}
|
260
|
+
},
|
411
261
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
}
|
431
|
-
module.activate.all(currentPath);
|
432
|
-
if( !module.cache.read(currentPath) ) {
|
433
|
-
module.cache.add(currentPath, true);
|
434
|
-
module.debug('First time tab loaded calling tab init');
|
435
|
-
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
436
|
-
}
|
437
|
-
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
438
|
-
return false;
|
439
|
-
}
|
440
|
-
}
|
441
|
-
else {
|
442
|
-
module.error(error.missingTab, $module, $context, currentPath);
|
443
|
-
return false;
|
444
|
-
}
|
445
|
-
});
|
446
|
-
},
|
262
|
+
cache: {
|
263
|
+
|
264
|
+
read: function (cacheKey) {
|
265
|
+
return (cacheKey !== undefined)
|
266
|
+
? cache[cacheKey]
|
267
|
+
: false;
|
268
|
+
},
|
269
|
+
add: function (cacheKey, content) {
|
270
|
+
cacheKey = cacheKey || activeTabPath;
|
271
|
+
module.debug('Adding cached content for', cacheKey);
|
272
|
+
cache[cacheKey] = content;
|
273
|
+
},
|
274
|
+
remove: function (cacheKey) {
|
275
|
+
cacheKey = cacheKey || activeTabPath;
|
276
|
+
module.debug('Removing cached content for', cacheKey);
|
277
|
+
delete cache[cacheKey];
|
278
|
+
},
|
279
|
+
},
|
447
280
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
? $element.offset().top
|
452
|
-
: false
|
453
|
-
;
|
454
|
-
if(scrollOffset !== false) {
|
455
|
-
module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element);
|
456
|
-
$document.scrollTop(scrollOffset);
|
457
|
-
}
|
458
|
-
},
|
281
|
+
escape: {
|
282
|
+
string: function (text) {
|
283
|
+
text = String(text);
|
459
284
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
285
|
+
return text.replace(regExp.escape, '\\$&');
|
286
|
+
},
|
287
|
+
},
|
288
|
+
|
289
|
+
set: {
|
290
|
+
auto: function () {
|
291
|
+
var
|
292
|
+
url = (typeof settings.path == 'string')
|
293
|
+
? settings.path.replace(/\/$/, '') + '/{$tab}'
|
294
|
+
: '/{$tab}'
|
295
|
+
;
|
296
|
+
module.verbose('Setting up automatic tab retrieval from server', url);
|
297
|
+
if ($.isPlainObject(settings.apiSettings)) {
|
298
|
+
settings.apiSettings.url = url;
|
299
|
+
} else {
|
300
|
+
settings.apiSettings = {
|
301
|
+
url: url,
|
302
|
+
};
|
303
|
+
}
|
304
|
+
},
|
305
|
+
loading: function (tabPath) {
|
306
|
+
var
|
307
|
+
$tab = module.get.tabElement(tabPath),
|
308
|
+
isLoading = $tab.hasClass(className.loading)
|
309
|
+
;
|
310
|
+
if (!isLoading) {
|
311
|
+
module.verbose('Setting loading state for', $tab);
|
312
|
+
$tab
|
313
|
+
.addClass(className.loading)
|
314
|
+
.siblings($tabs)
|
315
|
+
.removeClass(className.active + ' ' + className.loading)
|
316
|
+
;
|
317
|
+
if ($tab.length > 0) {
|
318
|
+
settings.onRequest.call($tab[0], tabPath);
|
319
|
+
}
|
320
|
+
}
|
321
|
+
},
|
322
|
+
state: function (state) {
|
323
|
+
$.address.value(state);
|
324
|
+
},
|
325
|
+
},
|
488
326
|
|
489
|
-
|
327
|
+
changeTab: function (tabPath) {
|
328
|
+
var
|
329
|
+
pushStateAvailable = (window.history && window.history.pushState),
|
330
|
+
shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad),
|
331
|
+
remoteContent = (settings.auto || $.isPlainObject(settings.apiSettings)),
|
332
|
+
// only add default path if not remote content
|
333
|
+
pathArray = (remoteContent && !shouldIgnoreLoad)
|
334
|
+
? module.utilities.pathToArray(tabPath)
|
335
|
+
: module.get.defaultPathArray(tabPath)
|
336
|
+
;
|
337
|
+
tabPath = module.utilities.arrayToPath(pathArray);
|
338
|
+
$.each(pathArray, function (index, tab) {
|
339
|
+
var
|
340
|
+
currentPathArray = pathArray.slice(0, index + 1),
|
341
|
+
currentPath = module.utilities.arrayToPath(currentPathArray),
|
342
|
+
|
343
|
+
isTab = module.is.tab(currentPath),
|
344
|
+
isLastIndex = (index + 1 == pathArray.length),
|
345
|
+
|
346
|
+
$tab = module.get.tabElement(currentPath),
|
347
|
+
$anchor,
|
348
|
+
nextPathArray,
|
349
|
+
nextPath,
|
350
|
+
isLastTab
|
351
|
+
;
|
352
|
+
module.verbose('Looking for tab', tab);
|
353
|
+
if (isTab) {
|
354
|
+
module.verbose('Tab was found', tab);
|
355
|
+
// scope up
|
356
|
+
activeTabPath = currentPath;
|
357
|
+
parameterArray = module.utilities.filterArray(pathArray, currentPathArray);
|
358
|
+
|
359
|
+
if (isLastIndex) {
|
360
|
+
isLastTab = true;
|
361
|
+
} else {
|
362
|
+
nextPathArray = pathArray.slice(0, index + 2);
|
363
|
+
nextPath = module.utilities.arrayToPath(nextPathArray);
|
364
|
+
isLastTab = (!module.is.tab(nextPath));
|
365
|
+
if (isLastTab) {
|
366
|
+
module.verbose('Tab parameters found', nextPathArray);
|
367
|
+
}
|
368
|
+
}
|
369
|
+
if (settings.onBeforeChange.call(element, currentPath) === false) {
|
370
|
+
module.debug('onBeforeChange returned false, cancelling tab change', $tab);
|
371
|
+
|
372
|
+
return false;
|
373
|
+
}
|
374
|
+
if (isLastTab && remoteContent) {
|
375
|
+
if (!shouldIgnoreLoad) {
|
376
|
+
module.activate.navigation(currentPath);
|
377
|
+
module.fetch.content(currentPath, tabPath);
|
378
|
+
} else {
|
379
|
+
module.debug('Ignoring remote content on first tab load', currentPath);
|
380
|
+
firstLoad = false;
|
381
|
+
module.cache.add(tabPath, $tab.html());
|
382
|
+
module.activate.all(currentPath);
|
383
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
384
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
385
|
+
}
|
386
|
+
|
387
|
+
return false;
|
388
|
+
} else {
|
389
|
+
module.debug('Opened local tab', currentPath);
|
390
|
+
module.activate.all(currentPath);
|
391
|
+
if (!module.cache.read(currentPath)) {
|
392
|
+
module.cache.add(currentPath, true);
|
393
|
+
module.debug('First time tab loaded calling tab init');
|
394
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
395
|
+
}
|
396
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
397
|
+
}
|
398
|
+
} else if (tabPath.search('/') == -1 && tabPath !== '') {
|
399
|
+
// look for in page anchor
|
400
|
+
tabPath = module.escape.string(tabPath);
|
401
|
+
$anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]');
|
402
|
+
currentPath = $anchor.closest('[data-tab]').data(metadata.tab);
|
403
|
+
$tab = module.get.tabElement(currentPath);
|
404
|
+
// if anchor exists use parent tab
|
405
|
+
if ($anchor && $anchor.length > 0 && currentPath) {
|
406
|
+
module.debug('Anchor link used, opening parent tab', $tab, $anchor);
|
407
|
+
if (settings.onBeforeChange.call(element, currentPath) === false) {
|
408
|
+
module.debug('onBeforeChange returned false, cancelling tab change', $tab);
|
409
|
+
|
410
|
+
return false;
|
411
|
+
}
|
412
|
+
if (!$tab.hasClass(className.active)) {
|
413
|
+
setTimeout(function () {
|
414
|
+
module.scrollTo($anchor);
|
415
|
+
}, 0);
|
416
|
+
}
|
417
|
+
module.activate.all(currentPath);
|
418
|
+
if (!module.cache.read(currentPath)) {
|
419
|
+
module.cache.add(currentPath, true);
|
420
|
+
module.debug('First time tab loaded calling tab init');
|
421
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
422
|
+
}
|
423
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
424
|
+
|
425
|
+
return false;
|
426
|
+
}
|
427
|
+
} else {
|
428
|
+
module.error(error.missingTab, $module, $context, currentPath);
|
429
|
+
|
430
|
+
return false;
|
431
|
+
}
|
432
|
+
});
|
433
|
+
},
|
490
434
|
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
435
|
+
scrollTo: function ($element) {
|
436
|
+
var
|
437
|
+
scrollOffset = ($element && $element.length > 0)
|
438
|
+
? $element.offset().top
|
439
|
+
: false
|
440
|
+
;
|
441
|
+
if (scrollOffset !== false) {
|
442
|
+
module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element);
|
443
|
+
$document.scrollTop(scrollOffset);
|
444
|
+
}
|
501
445
|
},
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
}, 0);
|
528
|
-
}
|
529
|
-
else {
|
530
|
-
module.cache.add(fullTabPath, $tab.html());
|
531
|
-
}
|
446
|
+
|
447
|
+
update: {
|
448
|
+
content: function (tabPath, html, evaluateScripts) {
|
449
|
+
var
|
450
|
+
$tab = module.get.tabElement(tabPath),
|
451
|
+
tab = $tab[0]
|
452
|
+
;
|
453
|
+
evaluateScripts = (evaluateScripts !== undefined)
|
454
|
+
? evaluateScripts
|
455
|
+
: settings.evaluateScripts;
|
456
|
+
if (typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && typeof html !== 'string') {
|
457
|
+
$tab
|
458
|
+
.empty()
|
459
|
+
.append($(html).clone(true))
|
460
|
+
;
|
461
|
+
} else {
|
462
|
+
if (evaluateScripts) {
|
463
|
+
module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
|
464
|
+
$tab.html(html);
|
465
|
+
} else {
|
466
|
+
module.debug('Updating HTML', tabPath, html);
|
467
|
+
tab.innerHTML = html;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
},
|
532
471
|
},
|
533
|
-
urlData: {
|
534
|
-
tab: fullTabPath
|
535
|
-
}
|
536
|
-
},
|
537
|
-
request = $tab.api('get request') || false,
|
538
|
-
existingRequest = ( request && request.state() === 'pending' ),
|
539
|
-
requestSettings,
|
540
|
-
cachedContent
|
541
|
-
;
|
542
472
|
|
543
|
-
|
544
|
-
|
473
|
+
fetch: {
|
474
|
+
|
475
|
+
content: function (tabPath, fullTabPath) {
|
476
|
+
var
|
477
|
+
$tab = module.get.tabElement(tabPath),
|
478
|
+
apiSettings = {
|
479
|
+
dataType: 'html',
|
480
|
+
encodeParameters: false,
|
481
|
+
on: 'now',
|
482
|
+
cache: settings.alwaysRefresh,
|
483
|
+
headers: {
|
484
|
+
'X-Remote': true,
|
485
|
+
},
|
486
|
+
onSuccess: function (response) {
|
487
|
+
if (settings.cacheType == 'response') {
|
488
|
+
module.cache.add(fullTabPath, response);
|
489
|
+
}
|
490
|
+
module.update.content(tabPath, response);
|
491
|
+
if (tabPath == activeTabPath) {
|
492
|
+
module.debug('Content loaded', tabPath);
|
493
|
+
module.activate.tab(tabPath);
|
494
|
+
} else {
|
495
|
+
module.debug('Content loaded in background', tabPath);
|
496
|
+
}
|
497
|
+
settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
498
|
+
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
499
|
+
|
500
|
+
if (settings.loadOnce) {
|
501
|
+
module.cache.add(fullTabPath, true);
|
502
|
+
} else if (typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) {
|
503
|
+
setTimeout(function () {
|
504
|
+
var
|
505
|
+
$clone = $tab.children().clone(true)
|
506
|
+
;
|
507
|
+
$clone = $clone.not('script');
|
508
|
+
module.cache.add(fullTabPath, $clone);
|
509
|
+
}, 0);
|
510
|
+
} else {
|
511
|
+
module.cache.add(fullTabPath, $tab.html());
|
512
|
+
}
|
513
|
+
},
|
514
|
+
urlData: {
|
515
|
+
tab: fullTabPath,
|
516
|
+
},
|
517
|
+
},
|
518
|
+
request = $tab.api('get request') || false,
|
519
|
+
existingRequest = (request && request.state() === 'pending'),
|
520
|
+
requestSettings,
|
521
|
+
cachedContent
|
522
|
+
;
|
523
|
+
|
524
|
+
fullTabPath = fullTabPath || tabPath;
|
525
|
+
cachedContent = module.cache.read(fullTabPath);
|
526
|
+
|
527
|
+
if (settings.cache && cachedContent) {
|
528
|
+
module.activate.tab(tabPath);
|
529
|
+
module.debug('Adding cached content', fullTabPath);
|
530
|
+
if (!settings.loadOnce) {
|
531
|
+
if (settings.evaluateScripts == 'once') {
|
532
|
+
module.update.content(tabPath, cachedContent, false);
|
533
|
+
} else {
|
534
|
+
module.update.content(tabPath, cachedContent);
|
535
|
+
}
|
536
|
+
}
|
537
|
+
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
538
|
+
} else if (existingRequest) {
|
539
|
+
module.set.loading(tabPath);
|
540
|
+
module.debug('Content is already loading', fullTabPath);
|
541
|
+
} else if ($.api !== undefined) {
|
542
|
+
requestSettings = $.extend(true, {}, settings.apiSettings, apiSettings);
|
543
|
+
module.debug('Retrieving remote content', fullTabPath, requestSettings);
|
544
|
+
module.set.loading(tabPath);
|
545
|
+
$tab.api(requestSettings);
|
546
|
+
} else {
|
547
|
+
module.error(error.api);
|
548
|
+
}
|
549
|
+
},
|
550
|
+
},
|
545
551
|
|
552
|
+
activate: {
|
553
|
+
all: function (tabPath) {
|
554
|
+
module.activate.tab(tabPath);
|
555
|
+
module.activate.navigation(tabPath);
|
556
|
+
},
|
557
|
+
tab: function (tabPath) {
|
558
|
+
var
|
559
|
+
$tab = module.get.tabElement(tabPath),
|
560
|
+
$deactiveTabs = (settings.deactivate == 'siblings')
|
561
|
+
? $tab.siblings($tabs)
|
562
|
+
: $tabs.not($tab),
|
563
|
+
isActive = $tab.hasClass(className.active)
|
564
|
+
;
|
565
|
+
module.verbose('Showing tab content for', $tab);
|
566
|
+
if (!isActive) {
|
567
|
+
$tab
|
568
|
+
.addClass(className.active)
|
569
|
+
;
|
570
|
+
$deactiveTabs
|
571
|
+
.removeClass(className.active + ' ' + className.loading)
|
572
|
+
;
|
573
|
+
if ($tab.length > 0) {
|
574
|
+
settings.onVisible.call($tab[0], tabPath);
|
575
|
+
}
|
576
|
+
}
|
577
|
+
},
|
578
|
+
navigation: function (tabPath) {
|
579
|
+
var
|
580
|
+
$navigation = module.get.navElement(tabPath),
|
581
|
+
$deactiveNavigation = (settings.deactivate == 'siblings')
|
582
|
+
? $navigation.siblings($allModules)
|
583
|
+
: $allModules.not($navigation),
|
584
|
+
isActive = $navigation.hasClass(className.active)
|
585
|
+
;
|
586
|
+
module.verbose('Activating tab navigation for', $navigation, tabPath);
|
587
|
+
if (!isActive) {
|
588
|
+
$navigation
|
589
|
+
.addClass(className.active)
|
590
|
+
;
|
591
|
+
$deactiveNavigation
|
592
|
+
.removeClass(className.active + ' ' + className.loading)
|
593
|
+
;
|
594
|
+
}
|
595
|
+
},
|
596
|
+
},
|
546
597
|
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
598
|
+
deactivate: {
|
599
|
+
all: function () {
|
600
|
+
module.deactivate.navigation();
|
601
|
+
module.deactivate.tabs();
|
602
|
+
},
|
603
|
+
navigation: function () {
|
604
|
+
$allModules
|
605
|
+
.removeClass(className.active)
|
606
|
+
;
|
607
|
+
},
|
608
|
+
tabs: function () {
|
609
|
+
$tabs
|
610
|
+
.removeClass(className.active + ' ' + className.loading)
|
611
|
+
;
|
612
|
+
},
|
613
|
+
},
|
614
|
+
|
615
|
+
is: {
|
616
|
+
tab: function (tabName) {
|
617
|
+
return (tabName !== undefined)
|
618
|
+
? (module.get.tabElement(tabName).length > 0)
|
619
|
+
: false;
|
620
|
+
},
|
621
|
+
},
|
622
|
+
|
623
|
+
get: {
|
624
|
+
initialPath: function () {
|
625
|
+
return $allModules.eq(0).data(metadata.tab) || $tabs.eq(0).data(metadata.tab);
|
626
|
+
},
|
627
|
+
path: function () {
|
628
|
+
return $.address.value();
|
629
|
+
},
|
630
|
+
// adds default tabs to tab path
|
631
|
+
defaultPathArray: function (tabPath) {
|
632
|
+
return module.utilities.pathToArray(module.get.defaultPath(tabPath));
|
633
|
+
},
|
634
|
+
defaultPath: function (tabPath) {
|
635
|
+
var
|
636
|
+
$defaultNav = $allModules.filter('[data-' + metadata.tab + '^="' + module.escape.string(tabPath) + '/"]').eq(0),
|
637
|
+
defaultTab = $defaultNav.data(metadata.tab) || false
|
638
|
+
;
|
639
|
+
if (defaultTab) {
|
640
|
+
module.debug('Found default tab', defaultTab);
|
641
|
+
if (recursionDepth < settings.maxDepth) {
|
642
|
+
recursionDepth++;
|
643
|
+
|
644
|
+
return module.get.defaultPath(defaultTab);
|
645
|
+
}
|
646
|
+
module.error(error.recursion);
|
647
|
+
} else {
|
648
|
+
module.debug('No default tabs found for', tabPath, $tabs);
|
649
|
+
}
|
650
|
+
recursionDepth = 0;
|
651
|
+
|
652
|
+
return tabPath;
|
653
|
+
},
|
654
|
+
navElement: function (tabPath) {
|
655
|
+
tabPath = tabPath || activeTabPath;
|
656
|
+
|
657
|
+
return $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
|
658
|
+
},
|
659
|
+
tabElement: function (tabPath) {
|
660
|
+
var
|
661
|
+
$fullPathTab,
|
662
|
+
$simplePathTab,
|
663
|
+
tabPathArray,
|
664
|
+
lastTab
|
665
|
+
;
|
666
|
+
tabPath = tabPath || activeTabPath;
|
667
|
+
tabPathArray = module.utilities.pathToArray(tabPath);
|
668
|
+
lastTab = module.utilities.last(tabPathArray);
|
669
|
+
$fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
|
670
|
+
$simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(lastTab) + '"]');
|
671
|
+
|
672
|
+
return ($fullPathTab.length > 0)
|
673
|
+
? $fullPathTab
|
674
|
+
: $simplePathTab;
|
675
|
+
},
|
676
|
+
tab: function () {
|
677
|
+
return activeTabPath;
|
678
|
+
},
|
679
|
+
},
|
680
|
+
|
681
|
+
determine: {
|
682
|
+
activeTab: function () {
|
683
|
+
var activeTab = null;
|
684
|
+
|
685
|
+
$tabs.each(function (_index, tab) {
|
686
|
+
var $tab = $(tab);
|
687
|
+
|
688
|
+
if ($tab.hasClass(className.active)) {
|
689
|
+
var
|
690
|
+
tabPath = $(this).data(metadata.tab),
|
691
|
+
$anchor = $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]')
|
692
|
+
;
|
693
|
+
|
694
|
+
if ($anchor.hasClass(className.active)) {
|
695
|
+
activeTab = tabPath;
|
696
|
+
}
|
697
|
+
}
|
698
|
+
});
|
699
|
+
|
700
|
+
return activeTab;
|
701
|
+
},
|
702
|
+
},
|
703
|
+
|
704
|
+
utilities: {
|
705
|
+
filterArray: function (keepArray, removeArray) {
|
706
|
+
return $.grep(keepArray, function (keepValue) {
|
707
|
+
return ($.inArray(keepValue, removeArray) == -1);
|
708
|
+
});
|
709
|
+
},
|
710
|
+
last: function (array) {
|
711
|
+
return Array.isArray(array)
|
712
|
+
? array[array.length - 1]
|
713
|
+
: false;
|
714
|
+
},
|
715
|
+
pathToArray: function (pathName) {
|
716
|
+
if (pathName === undefined) {
|
717
|
+
pathName = activeTabPath;
|
718
|
+
}
|
719
|
+
|
720
|
+
return typeof pathName == 'string'
|
721
|
+
? pathName.split('/')
|
722
|
+
: [pathName];
|
723
|
+
},
|
724
|
+
arrayToPath: function (pathArray) {
|
725
|
+
return Array.isArray(pathArray)
|
726
|
+
? pathArray.join('/')
|
727
|
+
: false;
|
728
|
+
},
|
729
|
+
},
|
730
|
+
|
731
|
+
setting: function (name, value) {
|
732
|
+
module.debug('Changing setting', name, value);
|
733
|
+
if ($.isPlainObject(name)) {
|
734
|
+
$.extend(true, settings, name);
|
735
|
+
} else if (value !== undefined) {
|
736
|
+
if ($.isPlainObject(settings[name])) {
|
737
|
+
$.extend(true, settings[name], value);
|
738
|
+
} else {
|
739
|
+
settings[name] = value;
|
740
|
+
}
|
741
|
+
} else {
|
742
|
+
return settings[name];
|
743
|
+
}
|
744
|
+
},
|
745
|
+
internal: function (name, value) {
|
746
|
+
if ($.isPlainObject(name)) {
|
747
|
+
$.extend(true, module, name);
|
748
|
+
} else if (value !== undefined) {
|
749
|
+
module[name] = value;
|
750
|
+
} else {
|
751
|
+
return module[name];
|
752
|
+
}
|
753
|
+
},
|
754
|
+
debug: function () {
|
755
|
+
if (!settings.silent && settings.debug) {
|
756
|
+
if (settings.performance) {
|
757
|
+
module.performance.log(arguments);
|
758
|
+
} else {
|
759
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
760
|
+
module.debug.apply(console, arguments);
|
761
|
+
}
|
762
|
+
}
|
763
|
+
},
|
764
|
+
verbose: function () {
|
765
|
+
if (!settings.silent && settings.verbose && settings.debug) {
|
766
|
+
if (settings.performance) {
|
767
|
+
module.performance.log(arguments);
|
768
|
+
} else {
|
769
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
770
|
+
module.verbose.apply(console, arguments);
|
771
|
+
}
|
772
|
+
}
|
773
|
+
},
|
774
|
+
error: function () {
|
775
|
+
if (!settings.silent) {
|
776
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
777
|
+
module.error.apply(console, arguments);
|
778
|
+
}
|
779
|
+
},
|
780
|
+
performance: {
|
781
|
+
log: function (message) {
|
782
|
+
var
|
783
|
+
currentTime,
|
784
|
+
executionTime,
|
785
|
+
previousTime
|
786
|
+
;
|
787
|
+
if (settings.performance) {
|
788
|
+
currentTime = new Date().getTime();
|
789
|
+
previousTime = time || currentTime;
|
790
|
+
executionTime = currentTime - previousTime;
|
791
|
+
time = currentTime;
|
792
|
+
performance.push({
|
793
|
+
Name: message[0],
|
794
|
+
Arguments: [].slice.call(message, 1) || '',
|
795
|
+
Element: element,
|
796
|
+
'Execution Time': executionTime,
|
797
|
+
});
|
798
|
+
}
|
799
|
+
clearTimeout(module.performance.timer);
|
800
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
801
|
+
},
|
802
|
+
display: function () {
|
803
|
+
var
|
804
|
+
title = settings.name + ':',
|
805
|
+
totalTime = 0
|
806
|
+
;
|
807
|
+
time = false;
|
808
|
+
clearTimeout(module.performance.timer);
|
809
|
+
$.each(performance, function (index, data) {
|
810
|
+
totalTime += data['Execution Time'];
|
811
|
+
});
|
812
|
+
title += ' ' + totalTime + 'ms';
|
813
|
+
if (moduleSelector) {
|
814
|
+
title += ' \'' + moduleSelector + '\'';
|
815
|
+
}
|
816
|
+
if ((console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
817
|
+
console.groupCollapsed(title);
|
818
|
+
if (console.table) {
|
819
|
+
console.table(performance);
|
820
|
+
} else {
|
821
|
+
$.each(performance, function (index, data) {
|
822
|
+
console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
|
823
|
+
});
|
824
|
+
}
|
825
|
+
console.groupEnd();
|
826
|
+
}
|
827
|
+
performance = [];
|
828
|
+
},
|
829
|
+
},
|
830
|
+
invoke: function (query, passedArguments, context) {
|
831
|
+
var
|
832
|
+
object = instance,
|
833
|
+
maxDepth,
|
834
|
+
found,
|
835
|
+
response
|
836
|
+
;
|
837
|
+
passedArguments = passedArguments || queryArguments;
|
838
|
+
context = context || element;
|
839
|
+
if (typeof query == 'string' && object !== undefined) {
|
840
|
+
query = query.split(/[\. ]/);
|
841
|
+
maxDepth = query.length - 1;
|
842
|
+
$.each(query, function (depth, value) {
|
843
|
+
var camelCaseValue = (depth != maxDepth)
|
844
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
845
|
+
: query
|
846
|
+
;
|
847
|
+
if ($.isPlainObject(object[camelCaseValue]) && (depth != maxDepth)) {
|
848
|
+
object = object[camelCaseValue];
|
849
|
+
} else if (object[camelCaseValue] !== undefined) {
|
850
|
+
found = object[camelCaseValue];
|
851
|
+
|
852
|
+
return false;
|
853
|
+
} else if ($.isPlainObject(object[value]) && (depth != maxDepth)) {
|
854
|
+
object = object[value];
|
855
|
+
} else if (object[value] !== undefined) {
|
856
|
+
found = object[value];
|
857
|
+
|
858
|
+
return false;
|
859
|
+
} else {
|
860
|
+
module.error(error.method, query);
|
861
|
+
|
862
|
+
return false;
|
863
|
+
}
|
864
|
+
});
|
865
|
+
}
|
866
|
+
if (isFunction(found)) {
|
867
|
+
response = found.apply(context, passedArguments);
|
868
|
+
} else if (found !== undefined) {
|
869
|
+
response = found;
|
870
|
+
}
|
871
|
+
if (Array.isArray(returnedValue)) {
|
872
|
+
returnedValue.push(response);
|
873
|
+
} else if (returnedValue !== undefined) {
|
874
|
+
returnedValue = [returnedValue, response];
|
875
|
+
} else if (response !== undefined) {
|
876
|
+
returnedValue = response;
|
877
|
+
}
|
878
|
+
|
879
|
+
return found;
|
880
|
+
},
|
881
|
+
};
|
882
|
+
if (methodInvoked) {
|
883
|
+
if (instance === undefined) {
|
884
|
+
module.initialize();
|
553
885
|
}
|
554
|
-
|
555
|
-
|
886
|
+
module.invoke(query);
|
887
|
+
} else {
|
888
|
+
if (instance !== undefined) {
|
889
|
+
instance.invoke('destroy');
|
556
890
|
}
|
557
|
-
|
558
|
-
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
559
|
-
}
|
560
|
-
else if(existingRequest) {
|
561
|
-
module.set.loading(tabPath);
|
562
|
-
module.debug('Content is already loading', fullTabPath);
|
563
|
-
}
|
564
|
-
else if($.api !== undefined) {
|
565
|
-
requestSettings = $.extend(true, {}, settings.apiSettings, apiSettings);
|
566
|
-
module.debug('Retrieving remote content', fullTabPath, requestSettings);
|
567
|
-
module.set.loading(tabPath);
|
568
|
-
$tab.api(requestSettings);
|
569
|
-
}
|
570
|
-
else {
|
571
|
-
module.error(error.api);
|
891
|
+
module.initialize();
|
572
892
|
}
|
573
|
-
|
574
|
-
},
|
893
|
+
});
|
575
894
|
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
},
|
581
|
-
tab: function(tabPath) {
|
582
|
-
var
|
583
|
-
$tab = module.get.tabElement(tabPath),
|
584
|
-
$deactiveTabs = (settings.deactivate == 'siblings')
|
585
|
-
? $tab.siblings($tabs)
|
586
|
-
: $tabs.not($tab),
|
587
|
-
isActive = $tab.hasClass(className.active)
|
588
|
-
;
|
589
|
-
module.verbose('Showing tab content for', $tab);
|
590
|
-
if(!isActive) {
|
591
|
-
$tab
|
592
|
-
.addClass(className.active)
|
593
|
-
;
|
594
|
-
$deactiveTabs
|
595
|
-
.removeClass(className.active + ' ' + className.loading)
|
596
|
-
;
|
597
|
-
if($tab.length > 0) {
|
598
|
-
settings.onVisible.call($tab[0], tabPath);
|
599
|
-
}
|
600
|
-
}
|
601
|
-
},
|
602
|
-
navigation: function(tabPath) {
|
603
|
-
var
|
604
|
-
$navigation = module.get.navElement(tabPath),
|
605
|
-
$deactiveNavigation = (settings.deactivate == 'siblings')
|
606
|
-
? $navigation.siblings($allModules)
|
607
|
-
: $allModules.not($navigation),
|
608
|
-
isActive = $navigation.hasClass(className.active)
|
609
|
-
;
|
610
|
-
module.verbose('Activating tab navigation for', $navigation, tabPath);
|
611
|
-
if(!isActive) {
|
612
|
-
$navigation
|
613
|
-
.addClass(className.active)
|
614
|
-
;
|
615
|
-
$deactiveNavigation
|
616
|
-
.removeClass(className.active + ' ' + className.loading)
|
617
|
-
;
|
618
|
-
}
|
619
|
-
}
|
620
|
-
},
|
895
|
+
return (returnedValue !== undefined)
|
896
|
+
? returnedValue
|
897
|
+
: this;
|
898
|
+
};
|
621
899
|
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
},
|
627
|
-
navigation: function() {
|
628
|
-
$allModules
|
629
|
-
.removeClass(className.active)
|
630
|
-
;
|
631
|
-
},
|
632
|
-
tabs: function() {
|
633
|
-
$tabs
|
634
|
-
.removeClass(className.active + ' ' + className.loading)
|
635
|
-
;
|
636
|
-
}
|
637
|
-
},
|
900
|
+
// shortcut for tabbed content with no defined navigation
|
901
|
+
$.tab = function () {
|
902
|
+
$(window).tab.apply(this, arguments);
|
903
|
+
};
|
638
904
|
|
639
|
-
|
640
|
-
tab: function(tabName) {
|
641
|
-
return (tabName !== undefined)
|
642
|
-
? ( module.get.tabElement(tabName).length > 0 )
|
643
|
-
: false
|
644
|
-
;
|
645
|
-
}
|
646
|
-
},
|
905
|
+
$.fn.tab.settings = {
|
647
906
|
|
648
|
-
|
649
|
-
|
650
|
-
return $allModules.eq(0).data(metadata.tab) || $tabs.eq(0).data(metadata.tab);
|
651
|
-
},
|
652
|
-
path: function() {
|
653
|
-
return $.address.value();
|
654
|
-
},
|
655
|
-
// adds default tabs to tab path
|
656
|
-
defaultPathArray: function(tabPath) {
|
657
|
-
return module.utilities.pathToArray( module.get.defaultPath(tabPath) );
|
658
|
-
},
|
659
|
-
defaultPath: function(tabPath) {
|
660
|
-
var
|
661
|
-
$defaultNav = $allModules.filter('[data-' + metadata.tab + '^="' + module.escape.string(tabPath) + '/"]').eq(0),
|
662
|
-
defaultTab = $defaultNav.data(metadata.tab) || false
|
663
|
-
;
|
664
|
-
if( defaultTab ) {
|
665
|
-
module.debug('Found default tab', defaultTab);
|
666
|
-
if(recursionDepth < settings.maxDepth) {
|
667
|
-
recursionDepth++;
|
668
|
-
return module.get.defaultPath(defaultTab);
|
669
|
-
}
|
670
|
-
module.error(error.recursion);
|
671
|
-
}
|
672
|
-
else {
|
673
|
-
module.debug('No default tabs found for', tabPath, $tabs);
|
674
|
-
}
|
675
|
-
recursionDepth = 0;
|
676
|
-
return tabPath;
|
677
|
-
},
|
678
|
-
navElement: function(tabPath) {
|
679
|
-
tabPath = tabPath || activeTabPath;
|
680
|
-
return $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
|
681
|
-
},
|
682
|
-
tabElement: function(tabPath) {
|
683
|
-
var
|
684
|
-
$fullPathTab,
|
685
|
-
$simplePathTab,
|
686
|
-
tabPathArray,
|
687
|
-
lastTab
|
688
|
-
;
|
689
|
-
tabPath = tabPath || activeTabPath;
|
690
|
-
tabPathArray = module.utilities.pathToArray(tabPath);
|
691
|
-
lastTab = module.utilities.last(tabPathArray);
|
692
|
-
$fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]');
|
693
|
-
$simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + module.escape.string(lastTab) + '"]');
|
694
|
-
return ($fullPathTab.length > 0)
|
695
|
-
? $fullPathTab
|
696
|
-
: $simplePathTab
|
697
|
-
;
|
698
|
-
},
|
699
|
-
tab: function() {
|
700
|
-
return activeTabPath;
|
701
|
-
}
|
702
|
-
},
|
907
|
+
name: 'Tab',
|
908
|
+
namespace: 'tab',
|
703
909
|
|
704
|
-
|
705
|
-
|
706
|
-
|
910
|
+
silent: false,
|
911
|
+
debug: false,
|
912
|
+
verbose: false,
|
913
|
+
performance: true,
|
707
914
|
|
708
|
-
|
709
|
-
|
915
|
+
auto: false, // uses pjax style endpoints fetching content from same url with remote-content headers
|
916
|
+
history: false, // use browser history
|
917
|
+
historyType: 'hash', // #/ or html5 state
|
918
|
+
path: false, // base path of url
|
710
919
|
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
$anchor = $allModules.filter('[data-' + metadata.tab + '="' + module.escape.string(tabPath) + '"]')
|
715
|
-
;
|
920
|
+
context: false, // specify a context that tabs must appear inside
|
921
|
+
childrenOnly: false, // use only tabs that are children of context
|
922
|
+
maxDepth: 25, // max depth a tab can be nested
|
716
923
|
|
717
|
-
|
718
|
-
activeTab = tabPath;
|
719
|
-
}
|
720
|
-
}
|
721
|
-
});
|
924
|
+
deactivate: 'siblings', // whether tabs should deactivate sibling menu elements or all elements initialized together
|
722
925
|
|
723
|
-
|
724
|
-
|
725
|
-
|
926
|
+
alwaysRefresh: false, // load tab content new every tab click
|
927
|
+
cache: true, // cache the content requests to pull locally
|
928
|
+
loadOnce: false, // Whether tab data should only be loaded once when using remote content
|
929
|
+
cacheType: 'response', // Whether to cache exact response, or to html cache contents after scripts execute
|
930
|
+
ignoreFirstLoad: false, // don't load remote content on first load
|
726
931
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
return ( $.inArray(keepValue, removeArray) == -1);
|
731
|
-
});
|
732
|
-
},
|
733
|
-
last: function(array) {
|
734
|
-
return Array.isArray(array)
|
735
|
-
? array[ array.length - 1]
|
736
|
-
: false
|
737
|
-
;
|
738
|
-
},
|
739
|
-
pathToArray: function(pathName) {
|
740
|
-
if(pathName === undefined) {
|
741
|
-
pathName = activeTabPath;
|
742
|
-
}
|
743
|
-
return typeof pathName == 'string'
|
744
|
-
? pathName.split('/')
|
745
|
-
: [pathName]
|
746
|
-
;
|
747
|
-
},
|
748
|
-
arrayToPath: function(pathArray) {
|
749
|
-
return Array.isArray(pathArray)
|
750
|
-
? pathArray.join('/')
|
751
|
-
: false
|
752
|
-
;
|
753
|
-
}
|
754
|
-
},
|
932
|
+
apiSettings: false, // settings for api call
|
933
|
+
evaluateScripts: 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content
|
934
|
+
autoTabActivation: true, // whether a non existing active tab will auto activate the first available tab
|
755
935
|
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
}
|
765
|
-
else {
|
766
|
-
settings[name] = value;
|
767
|
-
}
|
768
|
-
}
|
769
|
-
else {
|
770
|
-
return settings[name];
|
771
|
-
}
|
936
|
+
onFirstLoad: function (tabPath, parameterArray, historyEvent) {}, // called first time loaded
|
937
|
+
onLoad: function (tabPath, parameterArray, historyEvent) {}, // called on every load
|
938
|
+
onVisible: function (tabPath, parameterArray, historyEvent) {}, // called every time tab visible
|
939
|
+
onRequest: function (tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content
|
940
|
+
onBeforeChange: function (tabPath) {}, // called before a tab is about to be changed. Returning false will cancel the tab change
|
941
|
+
|
942
|
+
templates: {
|
943
|
+
determineTitle: function (tabArray) {}, // returns page title for path
|
772
944
|
},
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
945
|
+
|
946
|
+
error: {
|
947
|
+
api: 'You attempted to load content without API module',
|
948
|
+
method: 'The method you called is not defined',
|
949
|
+
missingTab: 'Activated tab cannot be found. Tabs are case-sensitive.',
|
950
|
+
noContent: 'The tab you specified is missing a content url.',
|
951
|
+
path: 'History enabled, but no path was specified',
|
952
|
+
recursion: 'Max recursive depth reached',
|
953
|
+
legacyInit: 'onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.',
|
954
|
+
legacyLoad: 'onTabLoad has been renamed to onLoad in 2.0. Please adjust your code',
|
955
|
+
state: 'History requires Asual\'s Address library <https://github.com/asual/jquery-address>',
|
783
956
|
},
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
module.performance.log(arguments);
|
788
|
-
}
|
789
|
-
else {
|
790
|
-
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
791
|
-
module.debug.apply(console, arguments);
|
792
|
-
}
|
793
|
-
}
|
957
|
+
|
958
|
+
regExp: {
|
959
|
+
escape: /[-[\]{}()*+?.,\\^$|#\s:=@]/g,
|
794
960
|
},
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
else {
|
801
|
-
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
802
|
-
module.verbose.apply(console, arguments);
|
803
|
-
}
|
804
|
-
}
|
961
|
+
|
962
|
+
metadata: {
|
963
|
+
tab: 'tab',
|
964
|
+
loaded: 'loaded',
|
965
|
+
promise: 'promise',
|
805
966
|
},
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
}
|
967
|
+
|
968
|
+
className: {
|
969
|
+
loading: 'loading',
|
970
|
+
active: 'active',
|
811
971
|
},
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
executionTime,
|
817
|
-
previousTime
|
818
|
-
;
|
819
|
-
if(settings.performance) {
|
820
|
-
currentTime = new Date().getTime();
|
821
|
-
previousTime = time || currentTime;
|
822
|
-
executionTime = currentTime - previousTime;
|
823
|
-
time = currentTime;
|
824
|
-
performance.push({
|
825
|
-
'Name' : message[0],
|
826
|
-
'Arguments' : [].slice.call(message, 1) || '',
|
827
|
-
'Element' : element,
|
828
|
-
'Execution Time' : executionTime
|
829
|
-
});
|
830
|
-
}
|
831
|
-
clearTimeout(module.performance.timer);
|
832
|
-
module.performance.timer = setTimeout(module.performance.display, 500);
|
833
|
-
},
|
834
|
-
display: function() {
|
835
|
-
var
|
836
|
-
title = settings.name + ':',
|
837
|
-
totalTime = 0
|
838
|
-
;
|
839
|
-
time = false;
|
840
|
-
clearTimeout(module.performance.timer);
|
841
|
-
$.each(performance, function(index, data) {
|
842
|
-
totalTime += data['Execution Time'];
|
843
|
-
});
|
844
|
-
title += ' ' + totalTime + 'ms';
|
845
|
-
if(moduleSelector) {
|
846
|
-
title += ' \'' + moduleSelector + '\'';
|
847
|
-
}
|
848
|
-
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
849
|
-
console.groupCollapsed(title);
|
850
|
-
if(console.table) {
|
851
|
-
console.table(performance);
|
852
|
-
}
|
853
|
-
else {
|
854
|
-
$.each(performance, function(index, data) {
|
855
|
-
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
856
|
-
});
|
857
|
-
}
|
858
|
-
console.groupEnd();
|
859
|
-
}
|
860
|
-
performance = [];
|
861
|
-
}
|
972
|
+
|
973
|
+
selector: {
|
974
|
+
tabs: '.ui.tab',
|
975
|
+
ui: '.ui',
|
862
976
|
},
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
maxDepth,
|
867
|
-
found,
|
868
|
-
response
|
869
|
-
;
|
870
|
-
passedArguments = passedArguments || queryArguments;
|
871
|
-
context = context || element;
|
872
|
-
if(typeof query == 'string' && object !== undefined) {
|
873
|
-
query = query.split(/[\. ]/);
|
874
|
-
maxDepth = query.length - 1;
|
875
|
-
$.each(query, function(depth, value) {
|
876
|
-
var camelCaseValue = (depth != maxDepth)
|
877
|
-
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
878
|
-
: query
|
879
|
-
;
|
880
|
-
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
881
|
-
object = object[camelCaseValue];
|
882
|
-
}
|
883
|
-
else if( object[camelCaseValue] !== undefined ) {
|
884
|
-
found = object[camelCaseValue];
|
885
|
-
return false;
|
886
|
-
}
|
887
|
-
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
888
|
-
object = object[value];
|
889
|
-
}
|
890
|
-
else if( object[value] !== undefined ) {
|
891
|
-
found = object[value];
|
892
|
-
return false;
|
893
|
-
}
|
894
|
-
else {
|
895
|
-
module.error(error.method, query);
|
896
|
-
return false;
|
897
|
-
}
|
898
|
-
});
|
899
|
-
}
|
900
|
-
if ( isFunction( found ) ) {
|
901
|
-
response = found.apply(context, passedArguments);
|
902
|
-
}
|
903
|
-
else if(found !== undefined) {
|
904
|
-
response = found;
|
905
|
-
}
|
906
|
-
if(Array.isArray(returnedValue)) {
|
907
|
-
returnedValue.push(response);
|
908
|
-
}
|
909
|
-
else if(returnedValue !== undefined) {
|
910
|
-
returnedValue = [returnedValue, response];
|
911
|
-
}
|
912
|
-
else if(response !== undefined) {
|
913
|
-
returnedValue = response;
|
914
|
-
}
|
915
|
-
return found;
|
916
|
-
}
|
917
|
-
};
|
918
|
-
if(methodInvoked) {
|
919
|
-
if(instance === undefined) {
|
920
|
-
module.initialize();
|
921
|
-
}
|
922
|
-
module.invoke(query);
|
923
|
-
}
|
924
|
-
else {
|
925
|
-
if(instance !== undefined) {
|
926
|
-
instance.invoke('destroy');
|
927
|
-
}
|
928
|
-
module.initialize();
|
929
|
-
}
|
930
|
-
})
|
931
|
-
;
|
932
|
-
return (returnedValue !== undefined)
|
933
|
-
? returnedValue
|
934
|
-
: this
|
935
|
-
;
|
936
|
-
|
937
|
-
};
|
938
|
-
|
939
|
-
// shortcut for tabbed content with no defined navigation
|
940
|
-
$.tab = function() {
|
941
|
-
$(window).tab.apply(this, arguments);
|
942
|
-
};
|
943
|
-
|
944
|
-
$.fn.tab.settings = {
|
945
|
-
|
946
|
-
name : 'Tab',
|
947
|
-
namespace : 'tab',
|
948
|
-
|
949
|
-
silent : false,
|
950
|
-
debug : false,
|
951
|
-
verbose : false,
|
952
|
-
performance : true,
|
953
|
-
|
954
|
-
auto : false, // uses pjax style endpoints fetching content from same url with remote-content headers
|
955
|
-
history : false, // use browser history
|
956
|
-
historyType : 'hash', // #/ or html5 state
|
957
|
-
path : false, // base path of url
|
958
|
-
|
959
|
-
context : false, // specify a context that tabs must appear inside
|
960
|
-
childrenOnly : false, // use only tabs that are children of context
|
961
|
-
maxDepth : 25, // max depth a tab can be nested
|
962
|
-
|
963
|
-
deactivate : 'siblings', // whether tabs should deactivate sibling menu elements or all elements initialized together
|
964
|
-
|
965
|
-
alwaysRefresh : false, // load tab content new every tab click
|
966
|
-
cache : true, // cache the content requests to pull locally
|
967
|
-
loadOnce : false, // Whether tab data should only be loaded once when using remote content
|
968
|
-
cacheType : 'response', // Whether to cache exact response, or to html cache contents after scripts execute
|
969
|
-
ignoreFirstLoad : false, // don't load remote content on first load
|
970
|
-
|
971
|
-
apiSettings : false, // settings for api call
|
972
|
-
evaluateScripts : 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content
|
973
|
-
autoTabActivation: true, // whether a non existing active tab will auto activate the first available tab
|
974
|
-
|
975
|
-
onFirstLoad : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded
|
976
|
-
onLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load
|
977
|
-
onVisible : function(tabPath, parameterArray, historyEvent) {}, // called every time tab visible
|
978
|
-
onRequest : function(tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content
|
979
|
-
onBeforeChange: function(tabPath) {}, // called before a tab is about to be changed. Returning false will cancel the tab change
|
980
|
-
|
981
|
-
templates : {
|
982
|
-
determineTitle: function(tabArray) {} // returns page title for path
|
983
|
-
},
|
984
|
-
|
985
|
-
error: {
|
986
|
-
api : 'You attempted to load content without API module',
|
987
|
-
method : 'The method you called is not defined',
|
988
|
-
missingTab : 'Activated tab cannot be found. Tabs are case-sensitive.',
|
989
|
-
noContent : 'The tab you specified is missing a content url.',
|
990
|
-
path : 'History enabled, but no path was specified',
|
991
|
-
recursion : 'Max recursive depth reached',
|
992
|
-
legacyInit : 'onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.',
|
993
|
-
legacyLoad : 'onTabLoad has been renamed to onLoad in 2.0. Please adjust your code',
|
994
|
-
state : 'History requires Asual\'s Address library <https://github.com/asual/jquery-address>'
|
995
|
-
},
|
996
|
-
|
997
|
-
regExp : {
|
998
|
-
escape : /[-[\]{}()*+?.,\\^$|#\s:=@]/g
|
999
|
-
},
|
1000
|
-
|
1001
|
-
metadata : {
|
1002
|
-
tab : 'tab',
|
1003
|
-
loaded : 'loaded',
|
1004
|
-
promise: 'promise'
|
1005
|
-
},
|
1006
|
-
|
1007
|
-
className : {
|
1008
|
-
loading : 'loading',
|
1009
|
-
active : 'active'
|
1010
|
-
},
|
1011
|
-
|
1012
|
-
selector : {
|
1013
|
-
tabs : '.ui.tab',
|
1014
|
-
ui : '.ui'
|
1015
|
-
}
|
1016
|
-
|
1017
|
-
};
|
1018
|
-
|
1019
|
-
})( jQuery, window, document );
|
977
|
+
|
978
|
+
};
|
979
|
+
})(jQuery, window, document);
|