@northdata/fomantic-ui 2.8.722 → 2.9.401

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