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