semantic-ui-sass 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +5 -0
- data/app/assets/fonts/semantic-ui/basic.icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/basic.icons.svg +450 -0
- data/app/assets/fonts/semantic-ui/basic.icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/basic.icons.woff +0 -0
- data/app/assets/fonts/semantic-ui/icons.eot +0 -0
- data/app/assets/fonts/semantic-ui/icons.otf +0 -0
- data/app/assets/fonts/semantic-ui/icons.svg +399 -0
- data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
- data/app/assets/fonts/semantic-ui/icons.woff +0 -0
- data/app/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-large.gif +0 -0
- data/app/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-medium.gif +0 -0
- data/app/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-mini.gif +0 -0
- data/app/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
- data/app/assets/images/semantic-ui/loader-small.gif +0 -0
- data/app/assets/javascripts/semantic-ui.js +20 -0
- data/app/assets/javascripts/semantic-ui/accordion.js +419 -0
- data/app/assets/javascripts/semantic-ui/behavior/api.js +638 -0
- data/app/assets/javascripts/semantic-ui/behavior/colorize.js +270 -0
- data/app/assets/javascripts/semantic-ui/behavior/form.js +702 -0
- data/app/assets/javascripts/semantic-ui/behavior/state.js +725 -0
- data/app/assets/javascripts/semantic-ui/chatroom.js +769 -0
- data/app/assets/javascripts/semantic-ui/checkbox.js +344 -0
- data/app/assets/javascripts/semantic-ui/dimmer.js +564 -0
- data/app/assets/javascripts/semantic-ui/dropdown.js +724 -0
- data/app/assets/javascripts/semantic-ui/modal.js +553 -0
- data/app/assets/javascripts/semantic-ui/nag.js +545 -0
- data/app/assets/javascripts/semantic-ui/popup.js +727 -0
- data/app/assets/javascripts/semantic-ui/rating.js +403 -0
- data/app/assets/javascripts/semantic-ui/search.js +772 -0
- data/app/assets/javascripts/semantic-ui/shape.js +778 -0
- data/app/assets/javascripts/semantic-ui/sidebar.js +490 -0
- data/app/assets/javascripts/semantic-ui/tab.js +689 -0
- data/app/assets/javascripts/semantic-ui/transition.js +654 -0
- data/app/assets/javascripts/semantic-ui/video.js +457 -0
- data/app/assets/stylesheets/semantic-ui.scss +4 -0
- data/app/assets/stylesheets/semantic-ui/collections/_all.scss +6 -0
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +77 -0
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +569 -0
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +643 -0
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +1767 -0
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +347 -0
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +524 -0
- data/app/assets/stylesheets/semantic-ui/elements/_all.scss +12 -0
- data/app/assets/stylesheets/semantic-ui/elements/_basic.icon.scss +479 -0
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +1187 -0
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +199 -0
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +342 -0
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +772 -0
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +181 -0
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +338 -0
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +827 -0
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +185 -0
- data/app/assets/stylesheets/semantic-ui/elements/_progress.scss +352 -0
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +464 -0
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +293 -0
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +199 -0
- data/app/assets/stylesheets/semantic-ui/modules/_all.scss +16 -0
- data/app/assets/stylesheets/semantic-ui/modules/_chatroom.scss +281 -0
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +481 -0
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +236 -0
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +548 -0
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +217 -0
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +173 -0
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +255 -0
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +179 -0
- data/app/assets/stylesheets/semantic-ui/modules/_reveal.scss +365 -0
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +273 -0
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +113 -0
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +150 -0
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +63 -0
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +1096 -0
- data/app/assets/stylesheets/semantic-ui/modules/_video.scss +98 -0
- data/app/assets/stylesheets/semantic-ui/views/_all.scss +5 -0
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +221 -0
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +152 -0
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +651 -0
- data/app/assets/stylesheets/semantic-ui/views/_list.scss +555 -0
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +27 -0
- data/lib/semantic/ui/sass.rb +10 -0
- data/lib/semantic/ui/sass/engine.rb +13 -0
- data/lib/semantic/ui/sass/version.rb +8 -0
- data/semantic-ui-sass.gemspec +24 -0
- data/tasks/converter.rb +237 -0
- metadata +177 -0
@@ -0,0 +1,689 @@
|
|
1
|
+
/*
|
2
|
+
* # Semantic - Tab
|
3
|
+
* http://github.com/jlukic/semantic-ui/
|
4
|
+
*
|
5
|
+
* Copyright 2013 Contributors
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
;(function ($, window, document, undefined) {
|
13
|
+
|
14
|
+
$.fn.tab = function(parameters) {
|
15
|
+
|
16
|
+
var
|
17
|
+
settings = $.extend(true, {}, $.fn.tab.settings, parameters),
|
18
|
+
|
19
|
+
$module = $(this),
|
20
|
+
$tabs = $(settings.context).find(settings.selector.tabs),
|
21
|
+
|
22
|
+
moduleSelector = $module.selector || '',
|
23
|
+
|
24
|
+
cache = {},
|
25
|
+
firstLoad = true,
|
26
|
+
recursionDepth = 0,
|
27
|
+
|
28
|
+
activeTabPath,
|
29
|
+
parameterArray,
|
30
|
+
historyEvent,
|
31
|
+
|
32
|
+
element = this,
|
33
|
+
time = new Date().getTime(),
|
34
|
+
performance = [],
|
35
|
+
|
36
|
+
className = settings.className,
|
37
|
+
metadata = settings.metadata,
|
38
|
+
error = settings.error,
|
39
|
+
|
40
|
+
eventNamespace = '.' + settings.namespace,
|
41
|
+
moduleNamespace = settings.namespace + '-module',
|
42
|
+
|
43
|
+
instance = $module.data(moduleNamespace),
|
44
|
+
|
45
|
+
query = arguments[0],
|
46
|
+
methodInvoked = (instance !== undefined && typeof query == 'string'),
|
47
|
+
queryArguments = [].slice.call(arguments, 1),
|
48
|
+
|
49
|
+
module,
|
50
|
+
invokedResponse
|
51
|
+
;
|
52
|
+
|
53
|
+
module = {
|
54
|
+
|
55
|
+
initialize: function() {
|
56
|
+
module.debug('Initializing Tabs', $module);
|
57
|
+
|
58
|
+
// set up automatic routing
|
59
|
+
if(settings.auto) {
|
60
|
+
module.verbose('Setting up automatic tab retrieval from server');
|
61
|
+
settings.apiSettings = {
|
62
|
+
url: settings.path + '/{$tab}'
|
63
|
+
};
|
64
|
+
}
|
65
|
+
|
66
|
+
// attach history events
|
67
|
+
if(settings.history) {
|
68
|
+
if( $.address === undefined ) {
|
69
|
+
module.error(error.state);
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
else if(settings.path === false) {
|
73
|
+
module.error(error.path);
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
module.verbose('Address library found adding state change event');
|
78
|
+
$.address
|
79
|
+
.state(settings.path)
|
80
|
+
.unbind('change')
|
81
|
+
.bind('change', module.event.history.change)
|
82
|
+
;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
// attach events if navigation wasn't set to window
|
87
|
+
if( !$.isWindow( element ) ) {
|
88
|
+
module.debug('Attaching tab activation events to element', $module);
|
89
|
+
$module
|
90
|
+
.on('click' + eventNamespace, module.event.click)
|
91
|
+
;
|
92
|
+
}
|
93
|
+
module.instantiate();
|
94
|
+
},
|
95
|
+
|
96
|
+
instantiate: function () {
|
97
|
+
module.verbose('Storing instance of module', module);
|
98
|
+
$module
|
99
|
+
.data(moduleNamespace, module)
|
100
|
+
;
|
101
|
+
},
|
102
|
+
|
103
|
+
destroy: function() {
|
104
|
+
module.debug('Destroying tabs', $module);
|
105
|
+
$module
|
106
|
+
.off(eventNamespace)
|
107
|
+
;
|
108
|
+
},
|
109
|
+
|
110
|
+
event: {
|
111
|
+
click: function(event) {
|
112
|
+
module.debug('Navigation clicked');
|
113
|
+
var
|
114
|
+
tabPath = $(this).data(metadata.tab)
|
115
|
+
;
|
116
|
+
if(tabPath !== undefined) {
|
117
|
+
if(settings.history) {
|
118
|
+
$.address.value(tabPath);
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
module.changeTab(tabPath);
|
122
|
+
}
|
123
|
+
event.preventDefault();
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
module.debug('No tab specified');
|
127
|
+
}
|
128
|
+
},
|
129
|
+
history: {
|
130
|
+
change: function(event) {
|
131
|
+
var
|
132
|
+
tabPath = event.pathNames.join('/') || module.get.initialPath(),
|
133
|
+
pageTitle = settings.templates.determineTitle(tabPath) || false
|
134
|
+
;
|
135
|
+
module.debug('History change event', tabPath, event);
|
136
|
+
historyEvent = event;
|
137
|
+
if(tabPath !== undefined) {
|
138
|
+
module.changeTab(tabPath);
|
139
|
+
}
|
140
|
+
if(pageTitle) {
|
141
|
+
$.address.title(pageTitle);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
},
|
146
|
+
|
147
|
+
refresh: function() {
|
148
|
+
if(activeTabPath) {
|
149
|
+
module.debug('Refreshing tab', activeTabPath);
|
150
|
+
module.changeTab(activeTabPath);
|
151
|
+
}
|
152
|
+
},
|
153
|
+
|
154
|
+
cache: {
|
155
|
+
|
156
|
+
read: function(cacheKey) {
|
157
|
+
return (cacheKey !== undefined)
|
158
|
+
? cache[cacheKey]
|
159
|
+
: false
|
160
|
+
;
|
161
|
+
},
|
162
|
+
add: function(cacheKey, content) {
|
163
|
+
cacheKey = cacheKey || activeTabPath;
|
164
|
+
module.debug('Adding cached content for', cacheKey);
|
165
|
+
cache[cacheKey] = content;
|
166
|
+
},
|
167
|
+
remove: function(cacheKey) {
|
168
|
+
cacheKey = cacheKey || activeTabPath;
|
169
|
+
module.debug('Removing cached content for', cacheKey);
|
170
|
+
delete cache[cacheKey];
|
171
|
+
}
|
172
|
+
},
|
173
|
+
|
174
|
+
changeTab: function(tabPath) {
|
175
|
+
var
|
176
|
+
pushStateAvailable = (window.history && window.history.pushState),
|
177
|
+
shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad),
|
178
|
+
remoteContent = (settings.auto || $.isPlainObject(settings.apiSettings) ),
|
179
|
+
// only get default path if not remote content
|
180
|
+
pathArray = (remoteContent && !shouldIgnoreLoad)
|
181
|
+
? module.utilities.pathToArray(tabPath)
|
182
|
+
: module.get.defaultPathArray(tabPath)
|
183
|
+
;
|
184
|
+
tabPath = module.utilities.arrayToPath(pathArray);
|
185
|
+
module.deactivate.all();
|
186
|
+
$.each(pathArray, function(index, tab) {
|
187
|
+
var
|
188
|
+
currentPathArray = pathArray.slice(0, index + 1),
|
189
|
+
currentPath = module.utilities.arrayToPath(currentPathArray),
|
190
|
+
|
191
|
+
isTab = module.is.tab(currentPath),
|
192
|
+
isLastIndex = (index + 1 == pathArray.length),
|
193
|
+
|
194
|
+
$tab = module.get.tabElement(currentPath),
|
195
|
+
nextPathArray,
|
196
|
+
nextPath,
|
197
|
+
isLastTab
|
198
|
+
;
|
199
|
+
module.verbose('Looking for tab', tab);
|
200
|
+
if(isTab) {
|
201
|
+
module.verbose('Tab was found', tab);
|
202
|
+
|
203
|
+
// scope up
|
204
|
+
activeTabPath = currentPath;
|
205
|
+
parameterArray = module.utilities.filterArray(pathArray, currentPathArray);
|
206
|
+
|
207
|
+
if(isLastIndex) {
|
208
|
+
isLastTab = true;
|
209
|
+
}
|
210
|
+
else {
|
211
|
+
nextPathArray = pathArray.slice(0, index + 2);
|
212
|
+
nextPath = module.utilities.arrayToPath(nextPathArray);
|
213
|
+
isLastTab = ( !module.is.tab(nextPath) );
|
214
|
+
if(isLastTab) {
|
215
|
+
module.verbose('Tab parameters found', nextPathArray);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
if(isLastTab && remoteContent) {
|
219
|
+
if(!shouldIgnoreLoad) {
|
220
|
+
module.activate.navigation(currentPath);
|
221
|
+
module.content.fetch(currentPath, tabPath);
|
222
|
+
}
|
223
|
+
else {
|
224
|
+
module.debug('Ignoring remote content on first tab load', currentPath);
|
225
|
+
firstLoad = false;
|
226
|
+
module.cache.add(tabPath, $tab.html());
|
227
|
+
module.activate.all(currentPath);
|
228
|
+
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
|
229
|
+
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
|
230
|
+
}
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
module.debug('Opened local tab', currentPath);
|
235
|
+
module.activate.all(currentPath);
|
236
|
+
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
else {
|
240
|
+
module.error(error.missingTab, tab);
|
241
|
+
return false;
|
242
|
+
}
|
243
|
+
});
|
244
|
+
},
|
245
|
+
|
246
|
+
content: {
|
247
|
+
|
248
|
+
fetch: function(tabPath, fullTabPath) {
|
249
|
+
var
|
250
|
+
$tab = module.get.tabElement(tabPath),
|
251
|
+
apiSettings = {
|
252
|
+
dataType : 'html',
|
253
|
+
stateContext : $tab,
|
254
|
+
success : function(response) {
|
255
|
+
module.cache.add(fullTabPath, response);
|
256
|
+
module.content.update(tabPath, response);
|
257
|
+
if(tabPath == activeTabPath) {
|
258
|
+
module.debug('Content loaded', tabPath);
|
259
|
+
module.activate.tab(tabPath);
|
260
|
+
}
|
261
|
+
else {
|
262
|
+
module.debug('Content loaded in background', tabPath);
|
263
|
+
}
|
264
|
+
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
|
265
|
+
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
|
266
|
+
},
|
267
|
+
urlData: { tab: fullTabPath }
|
268
|
+
},
|
269
|
+
request = $tab.data(metadata.promise) || false,
|
270
|
+
existingRequest = ( request && request.state() === 'pending' ),
|
271
|
+
requestSettings,
|
272
|
+
cachedContent
|
273
|
+
;
|
274
|
+
|
275
|
+
fullTabPath = fullTabPath || tabPath;
|
276
|
+
cachedContent = module.cache.read(fullTabPath);
|
277
|
+
|
278
|
+
if(settings.cache && cachedContent) {
|
279
|
+
module.debug('Showing existing content', fullTabPath);
|
280
|
+
module.content.update(tabPath, cachedContent);
|
281
|
+
module.activate.tab(tabPath);
|
282
|
+
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
|
283
|
+
}
|
284
|
+
else if(existingRequest) {
|
285
|
+
module.debug('Content is already loading', fullTabPath);
|
286
|
+
$tab
|
287
|
+
.addClass(className.loading)
|
288
|
+
;
|
289
|
+
}
|
290
|
+
else if($.api !== undefined) {
|
291
|
+
console.log(settings.apiSettings);
|
292
|
+
requestSettings = $.extend(true, { headers: { 'X-Remote': true } }, settings.apiSettings, apiSettings);
|
293
|
+
module.debug('Retrieving remote content', fullTabPath, requestSettings);
|
294
|
+
$.api( requestSettings );
|
295
|
+
}
|
296
|
+
else {
|
297
|
+
module.error(error.api);
|
298
|
+
}
|
299
|
+
},
|
300
|
+
|
301
|
+
update: function(tabPath, html) {
|
302
|
+
module.debug('Updating html for', tabPath);
|
303
|
+
var
|
304
|
+
$tab = module.get.tabElement(tabPath)
|
305
|
+
;
|
306
|
+
$tab
|
307
|
+
.html(html)
|
308
|
+
;
|
309
|
+
}
|
310
|
+
},
|
311
|
+
|
312
|
+
activate: {
|
313
|
+
all: function(tabPath) {
|
314
|
+
module.activate.tab(tabPath);
|
315
|
+
module.activate.navigation(tabPath);
|
316
|
+
},
|
317
|
+
tab: function(tabPath) {
|
318
|
+
var
|
319
|
+
$tab = module.get.tabElement(tabPath)
|
320
|
+
;
|
321
|
+
module.verbose('Showing tab content for', $tab);
|
322
|
+
$tab.addClass(className.active);
|
323
|
+
},
|
324
|
+
navigation: function(tabPath) {
|
325
|
+
var
|
326
|
+
$navigation = module.get.navElement(tabPath)
|
327
|
+
;
|
328
|
+
module.verbose('Activating tab navigation for', $navigation, tabPath);
|
329
|
+
$navigation.addClass(className.active);
|
330
|
+
}
|
331
|
+
},
|
332
|
+
|
333
|
+
deactivate: {
|
334
|
+
all: function() {
|
335
|
+
module.deactivate.navigation();
|
336
|
+
module.deactivate.tabs();
|
337
|
+
},
|
338
|
+
navigation: function() {
|
339
|
+
$module
|
340
|
+
.removeClass(className.active)
|
341
|
+
;
|
342
|
+
},
|
343
|
+
tabs: function() {
|
344
|
+
$tabs
|
345
|
+
.removeClass(className.active + ' ' + className.loading)
|
346
|
+
;
|
347
|
+
}
|
348
|
+
},
|
349
|
+
|
350
|
+
is: {
|
351
|
+
tab: function(tabName) {
|
352
|
+
return (tabName !== undefined)
|
353
|
+
? ( module.get.tabElement(tabName).size() > 0 )
|
354
|
+
: false
|
355
|
+
;
|
356
|
+
}
|
357
|
+
},
|
358
|
+
|
359
|
+
get: {
|
360
|
+
initialPath: function() {
|
361
|
+
return $module.eq(0).data(metadata.tab) || $tabs.eq(0).data(metadata.tab);
|
362
|
+
},
|
363
|
+
path: function() {
|
364
|
+
return $.address.value();
|
365
|
+
},
|
366
|
+
// adds default tabs to tab path
|
367
|
+
defaultPathArray: function(tabPath) {
|
368
|
+
return module.utilities.pathToArray( module.get.defaultPath(tabPath) );
|
369
|
+
},
|
370
|
+
defaultPath: function(tabPath) {
|
371
|
+
var
|
372
|
+
$defaultNav = $module.filter('[data-' + metadata.tab + '^="' + tabPath + '/"]').eq(0),
|
373
|
+
defaultTab = $defaultNav.data(metadata.tab) || false
|
374
|
+
;
|
375
|
+
if( defaultTab ) {
|
376
|
+
module.debug('Found default tab', defaultTab);
|
377
|
+
if(recursionDepth < settings.maxDepth) {
|
378
|
+
recursionDepth++;
|
379
|
+
return module.get.defaultPath(defaultTab);
|
380
|
+
}
|
381
|
+
module.error(error.recursion);
|
382
|
+
}
|
383
|
+
else {
|
384
|
+
module.debug('No default tabs found for', tabPath, $tabs);
|
385
|
+
}
|
386
|
+
recursionDepth = 0;
|
387
|
+
return tabPath;
|
388
|
+
},
|
389
|
+
navElement: function(tabPath) {
|
390
|
+
tabPath = tabPath || activeTabPath;
|
391
|
+
return $module.filter('[data-' + metadata.tab + '="' + tabPath + '"]');
|
392
|
+
},
|
393
|
+
tabElement: function(tabPath) {
|
394
|
+
var
|
395
|
+
$fullPathTab,
|
396
|
+
$simplePathTab,
|
397
|
+
tabPathArray,
|
398
|
+
lastTab
|
399
|
+
;
|
400
|
+
tabPath = tabPath || activeTabPath;
|
401
|
+
tabPathArray = module.utilities.pathToArray(tabPath);
|
402
|
+
lastTab = module.utilities.last(tabPathArray);
|
403
|
+
$fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + lastTab + '"]');
|
404
|
+
$simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + tabPath + '"]');
|
405
|
+
return ($fullPathTab.size() > 0)
|
406
|
+
? $fullPathTab
|
407
|
+
: $simplePathTab
|
408
|
+
;
|
409
|
+
},
|
410
|
+
tab: function() {
|
411
|
+
return activeTabPath;
|
412
|
+
}
|
413
|
+
},
|
414
|
+
|
415
|
+
utilities: {
|
416
|
+
filterArray: function(keepArray, removeArray) {
|
417
|
+
return $.grep(keepArray, function(keepValue) {
|
418
|
+
return ( $.inArray(keepValue, removeArray) == -1);
|
419
|
+
});
|
420
|
+
},
|
421
|
+
last: function(array) {
|
422
|
+
return $.isArray(array)
|
423
|
+
? array[ array.length - 1]
|
424
|
+
: false
|
425
|
+
;
|
426
|
+
},
|
427
|
+
pathToArray: function(pathName) {
|
428
|
+
if(pathName === undefined) {
|
429
|
+
pathName = activeTabPath;
|
430
|
+
}
|
431
|
+
return typeof pathName == 'string'
|
432
|
+
? pathName.split('/')
|
433
|
+
: [pathName]
|
434
|
+
;
|
435
|
+
},
|
436
|
+
arrayToPath: function(pathArray) {
|
437
|
+
return $.isArray(pathArray)
|
438
|
+
? pathArray.join('/')
|
439
|
+
: false
|
440
|
+
;
|
441
|
+
}
|
442
|
+
},
|
443
|
+
|
444
|
+
setting: function(name, value) {
|
445
|
+
if(value !== undefined) {
|
446
|
+
if( $.isPlainObject(name) ) {
|
447
|
+
$.extend(true, settings, name);
|
448
|
+
}
|
449
|
+
else {
|
450
|
+
settings[name] = value;
|
451
|
+
}
|
452
|
+
}
|
453
|
+
else {
|
454
|
+
return settings[name];
|
455
|
+
}
|
456
|
+
},
|
457
|
+
internal: function(name, value) {
|
458
|
+
if(value !== undefined) {
|
459
|
+
if( $.isPlainObject(name) ) {
|
460
|
+
$.extend(true, module, name);
|
461
|
+
}
|
462
|
+
else {
|
463
|
+
module[name] = value;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
else {
|
467
|
+
return module[name];
|
468
|
+
}
|
469
|
+
},
|
470
|
+
debug: function() {
|
471
|
+
if(settings.debug) {
|
472
|
+
if(settings.performance) {
|
473
|
+
module.performance.log(arguments);
|
474
|
+
}
|
475
|
+
else {
|
476
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
477
|
+
module.debug.apply(console, arguments);
|
478
|
+
}
|
479
|
+
}
|
480
|
+
},
|
481
|
+
verbose: function() {
|
482
|
+
if(settings.verbose && settings.debug) {
|
483
|
+
if(settings.performance) {
|
484
|
+
module.performance.log(arguments);
|
485
|
+
}
|
486
|
+
else {
|
487
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
488
|
+
module.verbose.apply(console, arguments);
|
489
|
+
}
|
490
|
+
}
|
491
|
+
},
|
492
|
+
error: function() {
|
493
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
494
|
+
module.error.apply(console, arguments);
|
495
|
+
},
|
496
|
+
performance: {
|
497
|
+
log: function(message) {
|
498
|
+
var
|
499
|
+
currentTime,
|
500
|
+
executionTime,
|
501
|
+
previousTime
|
502
|
+
;
|
503
|
+
if(settings.performance) {
|
504
|
+
currentTime = new Date().getTime();
|
505
|
+
previousTime = time || currentTime;
|
506
|
+
executionTime = currentTime - previousTime;
|
507
|
+
time = currentTime;
|
508
|
+
performance.push({
|
509
|
+
'Element' : element,
|
510
|
+
'Name' : message[0],
|
511
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
512
|
+
'Execution Time' : executionTime
|
513
|
+
});
|
514
|
+
}
|
515
|
+
clearTimeout(module.performance.timer);
|
516
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
517
|
+
},
|
518
|
+
display: function() {
|
519
|
+
var
|
520
|
+
title = settings.name + ':',
|
521
|
+
totalTime = 0
|
522
|
+
;
|
523
|
+
time = false;
|
524
|
+
clearTimeout(module.performance.timer);
|
525
|
+
$.each(performance, function(index, data) {
|
526
|
+
totalTime += data['Execution Time'];
|
527
|
+
});
|
528
|
+
title += ' ' + totalTime + 'ms';
|
529
|
+
if(moduleSelector) {
|
530
|
+
title += ' \'' + moduleSelector + '\'';
|
531
|
+
}
|
532
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
533
|
+
console.groupCollapsed(title);
|
534
|
+
if(console.table) {
|
535
|
+
console.table(performance);
|
536
|
+
}
|
537
|
+
else {
|
538
|
+
$.each(performance, function(index, data) {
|
539
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
540
|
+
});
|
541
|
+
}
|
542
|
+
console.groupEnd();
|
543
|
+
}
|
544
|
+
performance = [];
|
545
|
+
}
|
546
|
+
},
|
547
|
+
invoke: function(query, passedArguments, context) {
|
548
|
+
var
|
549
|
+
maxDepth,
|
550
|
+
found,
|
551
|
+
response
|
552
|
+
;
|
553
|
+
passedArguments = passedArguments || queryArguments;
|
554
|
+
context = element || context;
|
555
|
+
if(typeof query == 'string' && instance !== undefined) {
|
556
|
+
query = query.split(/[\. ]/);
|
557
|
+
maxDepth = query.length - 1;
|
558
|
+
$.each(query, function(depth, value) {
|
559
|
+
var camelCaseValue = (depth != maxDepth)
|
560
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
561
|
+
: query
|
562
|
+
;
|
563
|
+
if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
|
564
|
+
instance = instance[value];
|
565
|
+
}
|
566
|
+
else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
|
567
|
+
instance = instance[camelCaseValue];
|
568
|
+
}
|
569
|
+
else if( instance[value] !== undefined ) {
|
570
|
+
found = instance[value];
|
571
|
+
return false;
|
572
|
+
}
|
573
|
+
else if( instance[camelCaseValue] !== undefined ) {
|
574
|
+
found = instance[camelCaseValue];
|
575
|
+
return false;
|
576
|
+
}
|
577
|
+
else {
|
578
|
+
module.error(error.method);
|
579
|
+
return false;
|
580
|
+
}
|
581
|
+
});
|
582
|
+
}
|
583
|
+
if ( $.isFunction( found ) ) {
|
584
|
+
response = found.apply(context, passedArguments);
|
585
|
+
}
|
586
|
+
else if(found !== undefined) {
|
587
|
+
response = found;
|
588
|
+
}
|
589
|
+
if($.isArray(invokedResponse)) {
|
590
|
+
invokedResponse.push(response);
|
591
|
+
}
|
592
|
+
else if(typeof invokedResponse == 'string') {
|
593
|
+
invokedResponse = [invokedResponse, response];
|
594
|
+
}
|
595
|
+
else if(response !== undefined) {
|
596
|
+
invokedResponse = response;
|
597
|
+
}
|
598
|
+
return found;
|
599
|
+
}
|
600
|
+
};
|
601
|
+
|
602
|
+
if(methodInvoked) {
|
603
|
+
if(instance === undefined) {
|
604
|
+
module.initialize();
|
605
|
+
}
|
606
|
+
module.invoke(query);
|
607
|
+
}
|
608
|
+
else {
|
609
|
+
if(instance !== undefined) {
|
610
|
+
module.destroy();
|
611
|
+
}
|
612
|
+
module.initialize();
|
613
|
+
}
|
614
|
+
|
615
|
+
return (invokedResponse !== undefined)
|
616
|
+
? invokedResponse
|
617
|
+
: this
|
618
|
+
;
|
619
|
+
|
620
|
+
};
|
621
|
+
|
622
|
+
// shortcut for tabbed content with no defined navigation
|
623
|
+
$.tab = function(settings) {
|
624
|
+
$(window).tab(settings);
|
625
|
+
};
|
626
|
+
|
627
|
+
$.fn.tab.settings = {
|
628
|
+
|
629
|
+
name : 'Tab',
|
630
|
+
verbose : true,
|
631
|
+
debug : true,
|
632
|
+
performance : true,
|
633
|
+
namespace : 'tab',
|
634
|
+
|
635
|
+
// only called first time a tab's content is loaded (when remote source)
|
636
|
+
onTabInit : function(tabPath, parameterArray, historyEvent) {},
|
637
|
+
// called on every load
|
638
|
+
onTabLoad : function(tabPath, parameterArray, historyEvent) {},
|
639
|
+
|
640
|
+
templates : {
|
641
|
+
determineTitle: function(tabArray) {}
|
642
|
+
},
|
643
|
+
|
644
|
+
// uses pjax style endpoints fetching content from same url with remote-content headers
|
645
|
+
auto : false,
|
646
|
+
history : false,
|
647
|
+
path : false,
|
648
|
+
|
649
|
+
context : 'body',
|
650
|
+
|
651
|
+
// max depth a tab can be nested
|
652
|
+
maxDepth : 25,
|
653
|
+
// dont load content on first load
|
654
|
+
ignoreFirstLoad : false,
|
655
|
+
// load tab content new every tab click
|
656
|
+
alwaysRefresh : false,
|
657
|
+
// cache the content requests to pull locally
|
658
|
+
cache : true,
|
659
|
+
// settings for api call
|
660
|
+
apiSettings : false,
|
661
|
+
|
662
|
+
error: {
|
663
|
+
api : 'You attempted to load content without API module',
|
664
|
+
method : 'The method you called is not defined',
|
665
|
+
missingTab : 'Tab cannot be found',
|
666
|
+
noContent : 'The tab you specified is missing a content url.',
|
667
|
+
path : 'History enabled, but no path was specified',
|
668
|
+
recursion : 'Max recursive depth reached',
|
669
|
+
state : 'The state library has not been initialized'
|
670
|
+
},
|
671
|
+
|
672
|
+
metadata : {
|
673
|
+
tab : 'tab',
|
674
|
+
loaded : 'loaded',
|
675
|
+
promise: 'promise'
|
676
|
+
},
|
677
|
+
|
678
|
+
className : {
|
679
|
+
loading : 'loading',
|
680
|
+
active : 'active'
|
681
|
+
},
|
682
|
+
|
683
|
+
selector : {
|
684
|
+
tabs : '.ui.tab'
|
685
|
+
}
|
686
|
+
|
687
|
+
};
|
688
|
+
|
689
|
+
})( jQuery, window , document );
|