less-rails-semantic_ui 1.12.3.0 → 2.0.0.0
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.
- checksums.yaml +4 -4
- data/assets/javascripts/semantic_ui/definitions/behaviors/api.js +394 -188
- data/assets/javascripts/semantic_ui/definitions/behaviors/colorize.js +4 -2
- data/assets/javascripts/semantic_ui/definitions/behaviors/form.js +263 -125
- data/assets/javascripts/semantic_ui/definitions/behaviors/state.js +3 -3
- data/assets/javascripts/semantic_ui/definitions/behaviors/visibility.js +213 -96
- data/assets/javascripts/semantic_ui/definitions/behaviors/visit.js +6 -4
- data/assets/javascripts/semantic_ui/definitions/globals/site.js +4 -4
- data/assets/javascripts/semantic_ui/definitions/modules/accordion.js +66 -52
- data/assets/javascripts/semantic_ui/definitions/modules/checkbox.js +309 -112
- data/assets/javascripts/semantic_ui/definitions/modules/dimmer.js +24 -26
- data/assets/javascripts/semantic_ui/definitions/modules/dropdown.js +2005 -590
- data/assets/javascripts/semantic_ui/definitions/modules/embed.js +662 -0
- data/assets/javascripts/semantic_ui/definitions/modules/modal.js +106 -79
- data/assets/javascripts/semantic_ui/definitions/modules/nag.js +7 -8
- data/assets/javascripts/semantic_ui/definitions/modules/popup.js +323 -194
- data/assets/javascripts/semantic_ui/definitions/modules/progress.js +111 -103
- data/assets/javascripts/semantic_ui/definitions/modules/rating.js +78 -54
- data/assets/javascripts/semantic_ui/definitions/modules/search.js +304 -122
- data/assets/javascripts/semantic_ui/definitions/modules/shape.js +93 -47
- data/assets/javascripts/semantic_ui/definitions/modules/sidebar.js +83 -149
- data/assets/javascripts/semantic_ui/definitions/modules/sticky.js +99 -29
- data/assets/javascripts/semantic_ui/definitions/modules/tab.js +219 -124
- data/assets/javascripts/semantic_ui/definitions/modules/transition.js +202 -171
- data/assets/stylesheets/semantic_ui/definitions/collections/breadcrumb.less +2 -1
- data/assets/stylesheets/semantic_ui/definitions/collections/form.less +135 -58
- data/assets/stylesheets/semantic_ui/definitions/collections/grid.less +366 -383
- data/assets/stylesheets/semantic_ui/definitions/collections/menu.less +838 -631
- data/assets/stylesheets/semantic_ui/definitions/collections/message.less +89 -71
- data/assets/stylesheets/semantic_ui/definitions/collections/table.less +183 -131
- data/assets/stylesheets/semantic_ui/definitions/elements/button.less +1097 -300
- data/assets/stylesheets/semantic_ui/definitions/elements/container.less +135 -0
- data/assets/stylesheets/semantic_ui/definitions/elements/divider.less +31 -30
- data/assets/stylesheets/semantic_ui/definitions/elements/flag.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/elements/header.less +209 -121
- data/assets/stylesheets/semantic_ui/definitions/elements/icon.less +201 -96
- data/assets/stylesheets/semantic_ui/definitions/elements/image.less +26 -11
- data/assets/stylesheets/semantic_ui/definitions/elements/input.less +49 -14
- data/assets/stylesheets/semantic_ui/definitions/elements/label.less +391 -221
- data/assets/stylesheets/semantic_ui/definitions/elements/list.less +107 -68
- data/assets/stylesheets/semantic_ui/definitions/elements/loader.less +3 -1
- data/assets/stylesheets/semantic_ui/definitions/elements/rail.less +34 -25
- data/assets/stylesheets/semantic_ui/definitions/elements/reveal.less +25 -10
- data/assets/stylesheets/semantic_ui/definitions/elements/segment.less +261 -173
- data/assets/stylesheets/semantic_ui/definitions/elements/step.less +169 -70
- data/assets/stylesheets/semantic_ui/definitions/globals/reset.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/globals/site.less +3 -1
- data/assets/stylesheets/semantic_ui/definitions/modules/accordion.less +1 -2
- data/assets/stylesheets/semantic_ui/definitions/modules/checkbox.less +175 -103
- data/assets/stylesheets/semantic_ui/definitions/modules/dimmer.less +26 -15
- data/assets/stylesheets/semantic_ui/definitions/modules/dropdown.less +349 -80
- data/assets/stylesheets/semantic_ui/definitions/modules/embed.less +174 -0
- data/assets/stylesheets/semantic_ui/definitions/modules/modal.less +83 -36
- data/assets/stylesheets/semantic_ui/definitions/modules/nag.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/modules/popup.less +48 -7
- data/assets/stylesheets/semantic_ui/definitions/modules/progress.less +160 -107
- data/assets/stylesheets/semantic_ui/definitions/modules/rating.less +57 -54
- data/assets/stylesheets/semantic_ui/definitions/modules/search.less +55 -10
- data/assets/stylesheets/semantic_ui/definitions/modules/shape.less +5 -6
- data/assets/stylesheets/semantic_ui/definitions/modules/sidebar.less +9 -5
- data/assets/stylesheets/semantic_ui/definitions/modules/sticky.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/modules/tab.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/modules/transition.less +3 -4
- data/assets/stylesheets/semantic_ui/definitions/views/card.less +240 -130
- data/assets/stylesheets/semantic_ui/definitions/views/comment.less +1 -1
- data/assets/stylesheets/semantic_ui/definitions/views/feed.less +15 -8
- data/assets/stylesheets/semantic_ui/definitions/views/item.less +13 -13
- data/assets/stylesheets/semantic_ui/definitions/views/statistic.less +230 -86
- data/assets/stylesheets/semantic_ui/theme.less +22 -15
- data/assets/stylesheets/semantic_ui/themes/amazon/elements/button.overrides +5 -5
- data/assets/stylesheets/semantic_ui/themes/amazon/elements/button.variables +5 -4
- data/assets/stylesheets/semantic_ui/themes/basic/collections/table.variables +1 -0
- data/assets/stylesheets/semantic_ui/themes/basic/views/card.variables +6 -4
- data/assets/stylesheets/semantic_ui/themes/bookish/elements/header.variables +4 -4
- data/assets/stylesheets/semantic_ui/themes/bootstrap3/elements/button.variables +1 -1
- data/assets/stylesheets/semantic_ui/themes/chubby/collections/form.overrides +8 -0
- data/assets/stylesheets/semantic_ui/themes/chubby/collections/menu.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/chubby/collections/menu.variables +40 -0
- data/assets/stylesheets/semantic_ui/themes/classic/modules/progress.variables +1 -0
- data/assets/stylesheets/semantic_ui/themes/classic/views/card.overrides +1 -1
- data/assets/stylesheets/semantic_ui/themes/colored/modules/checkbox.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/colored/modules/checkbox.variables +17 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/breadcrumb.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/breadcrumb.variables +5 -15
- data/assets/stylesheets/semantic_ui/themes/default/collections/form.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/form.variables +31 -35
- data/assets/stylesheets/semantic_ui/themes/default/collections/grid.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/grid.variables +34 -28
- data/assets/stylesheets/semantic_ui/themes/default/collections/menu.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/menu.variables +259 -163
- data/assets/stylesheets/semantic_ui/themes/default/collections/message.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/collections/message.variables +42 -19
- data/assets/stylesheets/semantic_ui/themes/default/collections/table.overrides +0 -3
- data/assets/stylesheets/semantic_ui/themes/default/collections/table.variables +63 -59
- data/assets/stylesheets/semantic_ui/themes/default/elements/button.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/button.variables +90 -50
- data/assets/stylesheets/semantic_ui/themes/default/elements/container.overrides +3 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/container.variables +45 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/divider.overrides +15 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/divider.variables +3 -4
- data/assets/stylesheets/semantic_ui/themes/default/elements/flag.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/header.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/header.variables +40 -36
- data/assets/stylesheets/semantic_ui/themes/default/elements/icon.overrides +4 -3
- data/assets/stylesheets/semantic_ui/themes/default/elements/icon.variables +29 -12
- data/assets/stylesheets/semantic_ui/themes/default/elements/image.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/image.variables +5 -3
- data/assets/stylesheets/semantic_ui/themes/default/elements/input.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/input.variables +10 -24
- data/assets/stylesheets/semantic_ui/themes/default/elements/label.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/label.variables +88 -35
- data/assets/stylesheets/semantic_ui/themes/default/elements/list.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/list.variables +53 -34
- data/assets/stylesheets/semantic_ui/themes/default/elements/loader.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/loader.variables +9 -10
- data/assets/stylesheets/semantic_ui/themes/default/elements/rail.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/rail.variables +13 -5
- data/assets/stylesheets/semantic_ui/themes/default/elements/reveal.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/reveal.variables +6 -4
- data/assets/stylesheets/semantic_ui/themes/default/elements/segment.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/segment.variables +66 -28
- data/assets/stylesheets/semantic_ui/themes/default/elements/step.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/elements/step.variables +60 -31
- data/assets/stylesheets/semantic_ui/themes/default/globals/reset.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/globals/site.variables +477 -303
- data/assets/stylesheets/semantic_ui/themes/default/modules/accordion.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/accordion.variables +6 -7
- data/assets/stylesheets/semantic_ui/themes/default/modules/chatroom.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/checkbox.overrides +19 -16
- data/assets/stylesheets/semantic_ui/themes/default/modules/checkbox.variables +71 -43
- data/assets/stylesheets/semantic_ui/themes/default/modules/dimmer.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/dimmer.variables +12 -9
- data/assets/stylesheets/semantic_ui/themes/default/modules/dropdown.overrides +0 -5
- data/assets/stylesheets/semantic_ui/themes/default/modules/dropdown.variables +146 -64
- data/assets/stylesheets/semantic_ui/themes/default/modules/{video.overrides → embed.overrides} +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/embed.variables +53 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/modal.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/modal.variables +24 -18
- data/assets/stylesheets/semantic_ui/themes/default/modules/nag.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/popup.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/popup.variables +3 -9
- data/assets/stylesheets/semantic_ui/themes/default/modules/progress.variables +13 -7
- data/assets/stylesheets/semantic_ui/themes/default/modules/rating.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/rating.variables +71 -33
- data/assets/stylesheets/semantic_ui/themes/default/modules/search.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/search.variables +36 -34
- data/assets/stylesheets/semantic_ui/themes/default/modules/shape.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/shape.variables +7 -2
- data/assets/stylesheets/semantic_ui/themes/default/modules/sidebar.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/sidebar.variables +2 -5
- data/assets/stylesheets/semantic_ui/themes/default/modules/sticky.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/modules/sticky.variables +2 -7
- data/assets/stylesheets/semantic_ui/themes/default/modules/tab.variables +1 -3
- data/assets/stylesheets/semantic_ui/themes/default/modules/transition.overrides +8 -9
- data/assets/stylesheets/semantic_ui/themes/default/views/ad.variables +2 -2
- data/assets/stylesheets/semantic_ui/themes/default/views/card.variables +33 -23
- data/assets/stylesheets/semantic_ui/themes/default/views/comment.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/views/feed.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/views/feed.variables +15 -23
- data/assets/stylesheets/semantic_ui/themes/default/views/item.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/views/item.variables +12 -11
- data/assets/stylesheets/semantic_ui/themes/default/views/statistic.overrides +0 -0
- data/assets/stylesheets/semantic_ui/themes/default/views/statistic.variables +25 -24
- data/assets/stylesheets/semantic_ui/themes/flat/collections/form.overrides +4 -0
- data/assets/stylesheets/semantic_ui/themes/flat/collections/form.variables +1 -2
- data/assets/stylesheets/semantic_ui/themes/flat/globals/site.variables +1 -0
- data/assets/stylesheets/semantic_ui/themes/github/collections/form.variables +1 -1
- data/assets/stylesheets/semantic_ui/themes/github/collections/menu.variables +10 -15
- data/assets/stylesheets/semantic_ui/themes/github/elements/button.variables +2 -2
- data/assets/stylesheets/semantic_ui/themes/github/elements/step.variables +2 -2
- data/assets/stylesheets/semantic_ui/themes/instagram/views/card.overrides +12 -0
- data/assets/stylesheets/semantic_ui/themes/instagram/views/card.variables +23 -0
- data/assets/stylesheets/semantic_ui/themes/material/collections/menu.overrides +1 -0
- data/assets/stylesheets/semantic_ui/themes/material/collections/menu.variables +10 -0
- data/assets/stylesheets/semantic_ui/themes/material/elements/button.overrides +1 -0
- data/assets/stylesheets/semantic_ui/themes/material/elements/button.variables +14 -6
- data/assets/stylesheets/semantic_ui/themes/material/globals/site.variables +3 -2
- data/assets/stylesheets/semantic_ui/themes/material/modules/dropdown.overrides +5 -0
- data/assets/stylesheets/semantic_ui/themes/material/modules/dropdown.variables +20 -0
- data/assets/stylesheets/semantic_ui/themes/raised/elements/button.variables +5 -5
- data/assets/stylesheets/semantic_ui/themes/round/elements/button.variables +1 -1
- data/assets/stylesheets/semantic_ui/themes/timeline/views/feed.overrides +4 -12
- data/assets/stylesheets/semantic_ui/themes/timeline/views/feed.variables +3 -7
- data/lib/generators/semantic_ui/install/templates/config/elements/container.overrides +3 -0
- data/lib/generators/semantic_ui/install/templates/config/elements/container.variables +3 -0
- data/lib/generators/semantic_ui/install/templates/config/modules/embed.overrides +3 -0
- data/lib/generators/semantic_ui/install/templates/config/modules/embed.variables +0 -0
- data/lib/generators/semantic_ui/install/templates/semantic_ui.css +2 -1
- data/lib/generators/semantic_ui/install/templates/semantic_ui.js +1 -1
- data/lib/generators/semantic_ui/install/templates/theme.config +5 -3
- data/lib/less/rails/semantic_ui/version.rb +1 -1
- data/tasks/update.rake +21 -6
- metadata +23 -7
- data/assets/fonts/semantic_ui/themes/default/assets/fonts/icons.otf +0 -0
- data/assets/javascripts/semantic_ui/definitions/modules/video.js +0 -540
- data/assets/stylesheets/semantic_ui/definitions/modules/video.less +0 -135
- data/assets/stylesheets/semantic_ui/themes/default/modules/video.variables +0 -16
@@ -3,7 +3,7 @@
|
|
3
3
|
* http://github.com/semantic-org/semantic-ui/
|
4
4
|
*
|
5
5
|
*
|
6
|
-
* Copyright
|
6
|
+
* Copyright 2015 Contributors
|
7
7
|
* Released under the MIT license
|
8
8
|
* http://opensource.org/licenses/MIT
|
9
9
|
*
|
@@ -43,8 +43,8 @@ $.fn.sticky = function(parameters) {
|
|
43
43
|
|
44
44
|
$module = $(this),
|
45
45
|
$window = $(window),
|
46
|
-
$container = $module.offsetParent(),
|
47
46
|
$scroll = $(settings.scrollContext),
|
47
|
+
$container,
|
48
48
|
$context,
|
49
49
|
|
50
50
|
selector = $module.selector || '',
|
@@ -65,6 +65,7 @@ $.fn.sticky = function(parameters) {
|
|
65
65
|
|
66
66
|
initialize: function() {
|
67
67
|
|
68
|
+
module.determineContainer();
|
68
69
|
module.determineContext();
|
69
70
|
module.verbose('Initializing sticky', settings, $container);
|
70
71
|
|
@@ -110,7 +111,7 @@ $.fn.sticky = function(parameters) {
|
|
110
111
|
observer = new MutationObserver(function(mutations) {
|
111
112
|
clearTimeout(module.timer);
|
112
113
|
module.timer = setTimeout(function() {
|
113
|
-
module.verbose('DOM tree modified, updating sticky menu');
|
114
|
+
module.verbose('DOM tree modified, updating sticky menu', mutations);
|
114
115
|
module.refresh();
|
115
116
|
}, 100);
|
116
117
|
});
|
@@ -126,6 +127,10 @@ $.fn.sticky = function(parameters) {
|
|
126
127
|
}
|
127
128
|
},
|
128
129
|
|
130
|
+
determineContainer: function() {
|
131
|
+
$container = $module.offsetParent();
|
132
|
+
},
|
133
|
+
|
129
134
|
determineContext: function() {
|
130
135
|
if(settings.context) {
|
131
136
|
$context = $(settings.context);
|
@@ -176,7 +181,7 @@ $.fn.sticky = function(parameters) {
|
|
176
181
|
},
|
177
182
|
scroll: function() {
|
178
183
|
requestAnimationFrame(function() {
|
179
|
-
$scroll.
|
184
|
+
$scroll.triggerHandler('scrollchange' + eventNamespace, $scroll.scrollTop() );
|
180
185
|
});
|
181
186
|
},
|
182
187
|
scrollchange: function(event, scrollPosition) {
|
@@ -187,8 +192,11 @@ $.fn.sticky = function(parameters) {
|
|
187
192
|
|
188
193
|
refresh: function(hardRefresh) {
|
189
194
|
module.reset();
|
195
|
+
if(!settings.context) {
|
196
|
+
module.determineContext();
|
197
|
+
}
|
190
198
|
if(hardRefresh) {
|
191
|
-
|
199
|
+
module.determineContainer();
|
192
200
|
}
|
193
201
|
module.save.positions();
|
194
202
|
module.stick();
|
@@ -199,7 +207,7 @@ $.fn.sticky = function(parameters) {
|
|
199
207
|
sticky: function() {
|
200
208
|
var
|
201
209
|
$element = $('<div/>'),
|
202
|
-
element = $element
|
210
|
+
element = $element[0]
|
203
211
|
;
|
204
212
|
$element.addClass(className.supported);
|
205
213
|
return($element.css('position').match('sticky'));
|
@@ -210,6 +218,9 @@ $.fn.sticky = function(parameters) {
|
|
210
218
|
lastScroll: function(scroll) {
|
211
219
|
module.lastScroll = scroll;
|
212
220
|
},
|
221
|
+
elementScroll: function(scroll) {
|
222
|
+
module.elementScroll = scroll;
|
223
|
+
},
|
213
224
|
positions: function() {
|
214
225
|
var
|
215
226
|
window = {
|
@@ -228,6 +239,9 @@ $.fn.sticky = function(parameters) {
|
|
228
239
|
offset : $context.offset(),
|
229
240
|
height : $context.outerHeight(),
|
230
241
|
bottomPadding : parseInt($context.css('padding-bottom'), 10)
|
242
|
+
},
|
243
|
+
container = {
|
244
|
+
height: $container.outerHeight()
|
231
245
|
}
|
232
246
|
;
|
233
247
|
module.cache = {
|
@@ -281,6 +295,9 @@ $.fn.sticky = function(parameters) {
|
|
281
295
|
;
|
282
296
|
},
|
283
297
|
currentElementScroll: function() {
|
298
|
+
if(module.elementScroll) {
|
299
|
+
return module.elementScroll;
|
300
|
+
}
|
284
301
|
return ( module.is.top() )
|
285
302
|
? Math.abs(parseInt($module.css('top'), 10)) || 0
|
286
303
|
: Math.abs(parseInt($module.css('bottom'), 10)) || 0
|
@@ -295,8 +312,7 @@ $.fn.sticky = function(parameters) {
|
|
295
312
|
delta = module.get.scrollChange(scroll),
|
296
313
|
maxScroll = (element.height - window.height + settings.offset),
|
297
314
|
elementScroll = module.get.currentElementScroll(),
|
298
|
-
possibleScroll = (elementScroll + delta)
|
299
|
-
elementScroll
|
315
|
+
possibleScroll = (elementScroll + delta)
|
300
316
|
;
|
301
317
|
if(module.cache.fits || possibleScroll < 0) {
|
302
318
|
elementScroll = 0;
|
@@ -312,6 +328,12 @@ $.fn.sticky = function(parameters) {
|
|
312
328
|
},
|
313
329
|
|
314
330
|
remove: {
|
331
|
+
lastScroll: function() {
|
332
|
+
delete module.lastScroll;
|
333
|
+
},
|
334
|
+
elementScroll: function(scroll) {
|
335
|
+
delete module.elementScroll;
|
336
|
+
},
|
315
337
|
offset: function() {
|
316
338
|
$module.css('margin-top', '');
|
317
339
|
}
|
@@ -320,7 +342,9 @@ $.fn.sticky = function(parameters) {
|
|
320
342
|
set: {
|
321
343
|
offset: function() {
|
322
344
|
module.verbose('Setting offset on element', settings.offset);
|
323
|
-
$module
|
345
|
+
$module
|
346
|
+
.css('margin-top', settings.offset)
|
347
|
+
;
|
324
348
|
},
|
325
349
|
containerSize: function() {
|
326
350
|
var
|
@@ -329,10 +353,10 @@ $.fn.sticky = function(parameters) {
|
|
329
353
|
if(tagName === 'HTML' || tagName == 'body') {
|
330
354
|
// this can trigger for too many reasons
|
331
355
|
//module.error(error.container, tagName, $module);
|
332
|
-
|
356
|
+
module.determineContainer();
|
333
357
|
}
|
334
358
|
else {
|
335
|
-
if( Math.abs($container.
|
359
|
+
if( Math.abs($container.outerHeight() - module.cache.context.height) > settings.jitter) {
|
336
360
|
module.debug('Context has padding, specifying exact height for container', module.cache.context.height);
|
337
361
|
$container.css({
|
338
362
|
height: module.cache.context.height
|
@@ -340,8 +364,19 @@ $.fn.sticky = function(parameters) {
|
|
340
364
|
}
|
341
365
|
}
|
342
366
|
},
|
367
|
+
minimumSize: function() {
|
368
|
+
var
|
369
|
+
element = module.cache.element
|
370
|
+
;
|
371
|
+
$container
|
372
|
+
.css('min-height', element.height)
|
373
|
+
;
|
374
|
+
},
|
343
375
|
scroll: function(scroll) {
|
344
376
|
module.debug('Setting scroll on element', scroll);
|
377
|
+
if(module.elementScroll == scroll) {
|
378
|
+
return;
|
379
|
+
}
|
345
380
|
if( module.is.top() ) {
|
346
381
|
$module
|
347
382
|
.css('bottom', '')
|
@@ -413,17 +448,14 @@ $.fn.sticky = function(parameters) {
|
|
413
448
|
elementVisible = (element.height !== 0)
|
414
449
|
;
|
415
450
|
|
416
|
-
// save current scroll for next run
|
417
|
-
module.save.lastScroll(scroll.top);
|
418
|
-
|
419
451
|
if(elementVisible) {
|
420
452
|
|
421
453
|
if( module.is.initialPosition() ) {
|
422
|
-
if(scroll.top
|
454
|
+
if(scroll.top > context.bottom) {
|
423
455
|
module.debug('Element bottom of container');
|
424
456
|
module.bindBottom();
|
425
457
|
}
|
426
|
-
else if(scroll.top
|
458
|
+
else if(scroll.top > element.top) {
|
427
459
|
module.debug('Element passed, fixing element to page');
|
428
460
|
module.fixTop();
|
429
461
|
}
|
@@ -481,15 +513,21 @@ $.fn.sticky = function(parameters) {
|
|
481
513
|
}
|
482
514
|
}
|
483
515
|
}
|
516
|
+
|
517
|
+
// save current scroll for next run
|
518
|
+
module.save.lastScroll(scroll.top);
|
519
|
+
module.save.elementScroll(elementScroll);
|
484
520
|
},
|
485
521
|
|
486
522
|
bindTop: function() {
|
487
523
|
module.debug('Binding element to top of parent container');
|
488
524
|
module.remove.offset();
|
489
525
|
$module
|
490
|
-
.css(
|
491
|
-
|
492
|
-
|
526
|
+
.css({
|
527
|
+
left : '',
|
528
|
+
top : '',
|
529
|
+
marginBottom : ''
|
530
|
+
})
|
493
531
|
.removeClass(className.fixed)
|
494
532
|
.removeClass(className.bottom)
|
495
533
|
.addClass(className.bound)
|
@@ -502,9 +540,11 @@ $.fn.sticky = function(parameters) {
|
|
502
540
|
module.debug('Binding element to bottom of parent container');
|
503
541
|
module.remove.offset();
|
504
542
|
$module
|
505
|
-
.css(
|
506
|
-
|
507
|
-
|
543
|
+
.css({
|
544
|
+
left : '',
|
545
|
+
top : '',
|
546
|
+
marginBottom : module.cache.context.bottomPadding
|
547
|
+
})
|
508
548
|
.removeClass(className.fixed)
|
509
549
|
.removeClass(className.top)
|
510
550
|
.addClass(className.bound)
|
@@ -522,10 +562,14 @@ $.fn.sticky = function(parameters) {
|
|
522
562
|
|
523
563
|
fixTop: function() {
|
524
564
|
module.debug('Fixing element to top of page');
|
565
|
+
module.set.minimumSize();
|
525
566
|
module.set.offset();
|
526
567
|
$module
|
527
|
-
.css(
|
528
|
-
|
568
|
+
.css({
|
569
|
+
left : module.cache.element.left,
|
570
|
+
bottom : '',
|
571
|
+
marginBottom : ''
|
572
|
+
})
|
529
573
|
.removeClass(className.bound)
|
530
574
|
.removeClass(className.bottom)
|
531
575
|
.addClass(className.fixed)
|
@@ -536,10 +580,14 @@ $.fn.sticky = function(parameters) {
|
|
536
580
|
|
537
581
|
fixBottom: function() {
|
538
582
|
module.debug('Sticking element to bottom of page');
|
583
|
+
module.set.minimumSize();
|
539
584
|
module.set.offset();
|
540
585
|
$module
|
541
|
-
.css(
|
542
|
-
|
586
|
+
.css({
|
587
|
+
left : module.cache.element.left,
|
588
|
+
bottom : '',
|
589
|
+
marginBottom : ''
|
590
|
+
})
|
543
591
|
.removeClass(className.bound)
|
544
592
|
.removeClass(className.top)
|
545
593
|
.addClass(className.fixed)
|
@@ -575,6 +623,7 @@ $.fn.sticky = function(parameters) {
|
|
575
623
|
module.unfix();
|
576
624
|
module.resetCSS();
|
577
625
|
module.remove.offset();
|
626
|
+
module.remove.lastScroll();
|
578
627
|
},
|
579
628
|
|
580
629
|
resetCSS: function() {
|
@@ -772,23 +821,44 @@ $.fn.sticky.settings = {
|
|
772
821
|
namespace : 'sticky',
|
773
822
|
|
774
823
|
debug : false,
|
775
|
-
verbose :
|
776
|
-
performance :
|
824
|
+
verbose : true,
|
825
|
+
performance : true,
|
777
826
|
|
827
|
+
// whether to stick in the opposite direction on scroll up
|
778
828
|
pushing : false,
|
829
|
+
|
779
830
|
context : false,
|
831
|
+
|
832
|
+
// Context to watch scroll events
|
780
833
|
scrollContext : window,
|
781
834
|
|
835
|
+
// Offset to adjust scroll
|
782
836
|
offset : 0,
|
837
|
+
|
838
|
+
// Offset to adjust scroll when attached to bottom of screen
|
783
839
|
bottomOffset : 0,
|
784
840
|
|
785
|
-
|
841
|
+
jitter : 5, // will only set container height if difference between context and container is larger than this number
|
786
842
|
|
843
|
+
// Whether to automatically observe changes with Mutation Observers
|
844
|
+
observeChanges : false,
|
845
|
+
|
846
|
+
// Called when position is recalculated
|
787
847
|
onReposition : function(){},
|
848
|
+
|
849
|
+
// Called on each scroll
|
788
850
|
onScroll : function(){},
|
851
|
+
|
852
|
+
// Called when element is stuck to viewport
|
789
853
|
onStick : function(){},
|
854
|
+
|
855
|
+
// Called when element is unstuck from viewport
|
790
856
|
onUnstick : function(){},
|
857
|
+
|
858
|
+
// Called when element reaches top of context
|
791
859
|
onTop : function(){},
|
860
|
+
|
861
|
+
// Called when element reaches bottom of context
|
792
862
|
onBottom : function(){},
|
793
863
|
|
794
864
|
error : {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
* http://github.com/semantic-org/semantic-ui/
|
4
4
|
*
|
5
5
|
*
|
6
|
-
* Copyright
|
6
|
+
* Copyright 2015 Contributors
|
7
7
|
* Released under the MIT license
|
8
8
|
* http://opensource.org/licenses/MIT
|
9
9
|
*
|
@@ -21,10 +21,6 @@ $.fn.tab = function(parameters) {
|
|
21
21
|
? $(window)
|
22
22
|
: $(this),
|
23
23
|
|
24
|
-
settings = ( $.isPlainObject(parameters) )
|
25
|
-
? $.extend(true, {}, $.fn.tab.settings, parameters)
|
26
|
-
: $.extend({}, $.fn.tab.settings),
|
27
|
-
|
28
24
|
moduleSelector = $allModules.selector || '',
|
29
25
|
time = new Date().getTime(),
|
30
26
|
performance = [],
|
@@ -33,7 +29,7 @@ $.fn.tab = function(parameters) {
|
|
33
29
|
methodInvoked = (typeof query == 'string'),
|
34
30
|
queryArguments = [].slice.call(arguments, 1),
|
35
31
|
|
36
|
-
|
32
|
+
initializedHistory = false,
|
37
33
|
returnedValue
|
38
34
|
;
|
39
35
|
|
@@ -41,53 +37,86 @@ $.fn.tab = function(parameters) {
|
|
41
37
|
.each(function() {
|
42
38
|
var
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
error = settings.error,
|
48
|
-
|
49
|
-
eventNamespace = '.' + settings.namespace,
|
50
|
-
moduleNamespace = 'module-' + settings.namespace,
|
40
|
+
settings = ( $.isPlainObject(parameters) )
|
41
|
+
? $.extend(true, {}, $.fn.tab.settings, parameters)
|
42
|
+
: $.extend({}, $.fn.tab.settings),
|
51
43
|
|
52
|
-
|
44
|
+
className = settings.className,
|
45
|
+
metadata = settings.metadata,
|
46
|
+
selector = settings.selector,
|
47
|
+
error = settings.error,
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
recursionDepth = 0,
|
49
|
+
eventNamespace = '.' + settings.namespace,
|
50
|
+
moduleNamespace = 'module-' + settings.namespace,
|
57
51
|
|
52
|
+
$module = $(this),
|
58
53
|
$context,
|
59
54
|
$tabs,
|
55
|
+
|
56
|
+
cache = {},
|
57
|
+
firstLoad = true,
|
58
|
+
recursionDepth = 0,
|
59
|
+
element = this,
|
60
|
+
instance = $module.data(moduleNamespace),
|
61
|
+
|
60
62
|
activeTabPath,
|
61
63
|
parameterArray,
|
62
|
-
|
64
|
+
module,
|
65
|
+
|
66
|
+
historyEvent
|
63
67
|
|
64
|
-
element = this,
|
65
|
-
instance = $module.data(moduleNamespace)
|
66
68
|
;
|
67
69
|
|
68
70
|
module = {
|
69
71
|
|
70
72
|
initialize: function() {
|
71
73
|
module.debug('Initializing tab menu item', $module);
|
72
|
-
|
74
|
+
module.fix.callbacks();
|
73
75
|
module.determineTabs();
|
74
|
-
module.debug('Determining tabs', settings.context, $tabs);
|
75
76
|
|
77
|
+
module.debug('Determining tabs', settings.context, $tabs);
|
76
78
|
// set up automatic routing
|
77
79
|
if(settings.auto) {
|
78
80
|
module.set.auto();
|
79
81
|
}
|
82
|
+
module.bind.events();
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
$module
|
85
|
-
.on('click' + eventNamespace, module.event.click)
|
86
|
-
;
|
84
|
+
if(settings.history && !initializedHistory) {
|
85
|
+
module.initializeHistory();
|
86
|
+
initializedHistory = true;
|
87
87
|
}
|
88
|
+
|
88
89
|
module.instantiate();
|
89
90
|
},
|
90
91
|
|
92
|
+
instantiate: function () {
|
93
|
+
module.verbose('Storing instance of module', module);
|
94
|
+
instance = module;
|
95
|
+
$module
|
96
|
+
.data(moduleNamespace, module)
|
97
|
+
;
|
98
|
+
},
|
99
|
+
|
100
|
+
destroy: function() {
|
101
|
+
module.debug('Destroying tabs', $module);
|
102
|
+
$module
|
103
|
+
.removeData(moduleNamespace)
|
104
|
+
.off(eventNamespace)
|
105
|
+
;
|
106
|
+
},
|
107
|
+
|
108
|
+
bind: {
|
109
|
+
events: function() {
|
110
|
+
// if using $.tab dont add events
|
111
|
+
if( !$.isWindow( element ) ) {
|
112
|
+
module.debug('Attaching tab activation events to element', $module);
|
113
|
+
$module
|
114
|
+
.on('click' + eventNamespace, module.event.click)
|
115
|
+
;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
},
|
119
|
+
|
91
120
|
determineTabs: function() {
|
92
121
|
var
|
93
122
|
$reference
|
@@ -97,7 +126,7 @@ $.fn.tab = function(parameters) {
|
|
97
126
|
if(settings.context === 'parent') {
|
98
127
|
if($module.closest(selector.ui).length > 0) {
|
99
128
|
$reference = $module.closest(selector.ui);
|
100
|
-
module.verbose('Using closest UI element
|
129
|
+
module.verbose('Using closest UI element as parent', $reference);
|
101
130
|
}
|
102
131
|
else {
|
103
132
|
$reference = $module;
|
@@ -112,7 +141,6 @@ $.fn.tab = function(parameters) {
|
|
112
141
|
else {
|
113
142
|
$context = $('body');
|
114
143
|
}
|
115
|
-
|
116
144
|
// find tabs
|
117
145
|
if(settings.childrenOnly) {
|
118
146
|
$tabs = $context.children(selector.tabs);
|
@@ -124,48 +152,48 @@ $.fn.tab = function(parameters) {
|
|
124
152
|
}
|
125
153
|
},
|
126
154
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
else {
|
135
|
-
if(settings.historyType == 'state') {
|
136
|
-
module.debug('Using HTML5 to manage state');
|
137
|
-
if(settings.path !== false) {
|
138
|
-
$.address
|
139
|
-
.history(true)
|
140
|
-
.state(settings.path)
|
141
|
-
;
|
142
|
-
}
|
143
|
-
else {
|
144
|
-
module.error(error.path);
|
145
|
-
return false;
|
146
|
-
}
|
155
|
+
fix: {
|
156
|
+
callbacks: function() {
|
157
|
+
if( $.isPlainObject(parameters) && (parameters.onTabLoad || parameters.onTabInit) ) {
|
158
|
+
if(parameters.onTabLoad) {
|
159
|
+
parameters.onLoad = parameters.onTabLoad;
|
160
|
+
delete parameters.onTabLoad;
|
161
|
+
module.error(error.legacyLoad, parameters.onLoad);
|
147
162
|
}
|
148
|
-
|
149
|
-
.
|
150
|
-
|
163
|
+
if(parameters.onTabInit) {
|
164
|
+
parameters.onFirstLoad = parameters.onTabInit;
|
165
|
+
delete parameters.onTabInit;
|
166
|
+
module.error(error.legacyInit, parameters.onFirstLoad);
|
167
|
+
}
|
168
|
+
settings = $.extend(true, {}, $.fn.tab.settings, parameters);
|
151
169
|
}
|
152
170
|
}
|
153
171
|
},
|
154
172
|
|
155
|
-
|
156
|
-
module.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
173
|
+
initializeHistory: function() {
|
174
|
+
module.debug('Initializing page state');
|
175
|
+
if( $.address === undefined ) {
|
176
|
+
module.error(error.state);
|
177
|
+
return false;
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
if(settings.historyType == 'state') {
|
181
|
+
module.debug('Using HTML5 to manage state');
|
182
|
+
if(settings.path !== false) {
|
183
|
+
$.address
|
184
|
+
.history(true)
|
185
|
+
.state(settings.path)
|
186
|
+
;
|
187
|
+
}
|
188
|
+
else {
|
189
|
+
module.error(error.path);
|
190
|
+
return false;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
$.address
|
194
|
+
.bind('change', module.event.history.change)
|
195
|
+
;
|
196
|
+
}
|
169
197
|
},
|
170
198
|
|
171
199
|
event: {
|
@@ -251,6 +279,23 @@ $.fn.tab = function(parameters) {
|
|
251
279
|
};
|
252
280
|
}
|
253
281
|
},
|
282
|
+
loading: function(tabPath) {
|
283
|
+
var
|
284
|
+
$tab = module.get.tabElement(tabPath),
|
285
|
+
isLoading = $tab.hasClass(className.loading)
|
286
|
+
;
|
287
|
+
if(!isLoading) {
|
288
|
+
module.verbose('Setting loading state for', $tab);
|
289
|
+
$tab
|
290
|
+
.addClass(className.loading)
|
291
|
+
.siblings($tabs)
|
292
|
+
.removeClass(className.active + ' ' + className.loading)
|
293
|
+
;
|
294
|
+
if($tab.length > 0) {
|
295
|
+
settings.onRequest.call($tab[0], tabPath);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
},
|
254
299
|
state: function(state) {
|
255
300
|
$.address.value(state);
|
256
301
|
}
|
@@ -261,7 +306,7 @@ $.fn.tab = function(parameters) {
|
|
261
306
|
pushStateAvailable = (window.history && window.history.pushState),
|
262
307
|
shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad),
|
263
308
|
remoteContent = (settings.auto || $.isPlainObject(settings.apiSettings) ),
|
264
|
-
// only
|
309
|
+
// only add default path if not remote content
|
265
310
|
pathArray = (remoteContent && !shouldIgnoreLoad)
|
266
311
|
? module.utilities.pathToArray(tabPath)
|
267
312
|
: module.get.defaultPathArray(tabPath)
|
@@ -283,7 +328,6 @@ $.fn.tab = function(parameters) {
|
|
283
328
|
;
|
284
329
|
module.verbose('Looking for tab', tab);
|
285
330
|
if(isTab) {
|
286
|
-
|
287
331
|
module.verbose('Tab was found', tab);
|
288
332
|
// scope up
|
289
333
|
activeTabPath = currentPath;
|
@@ -303,15 +347,15 @@ $.fn.tab = function(parameters) {
|
|
303
347
|
if(isLastTab && remoteContent) {
|
304
348
|
if(!shouldIgnoreLoad) {
|
305
349
|
module.activate.navigation(currentPath);
|
306
|
-
module.content
|
350
|
+
module.fetch.content(currentPath, tabPath);
|
307
351
|
}
|
308
352
|
else {
|
309
353
|
module.debug('Ignoring remote content on first tab load', currentPath);
|
310
354
|
firstLoad = false;
|
311
355
|
module.cache.add(tabPath, $tab.html());
|
312
356
|
module.activate.all(currentPath);
|
313
|
-
settings.
|
314
|
-
settings.
|
357
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
358
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
315
359
|
}
|
316
360
|
return false;
|
317
361
|
}
|
@@ -321,25 +365,32 @@ $.fn.tab = function(parameters) {
|
|
321
365
|
if( !module.cache.read(currentPath) ) {
|
322
366
|
module.cache.add(currentPath, true);
|
323
367
|
module.debug('First time tab loaded calling tab init');
|
324
|
-
settings.
|
368
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
325
369
|
}
|
326
|
-
settings.
|
370
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
327
371
|
}
|
372
|
+
|
328
373
|
}
|
329
374
|
else if(tabPath.search('/') == -1 && tabPath !== '') {
|
330
375
|
// look for in page anchor
|
331
|
-
$anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]')
|
376
|
+
$anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]');
|
332
377
|
currentPath = $anchor.closest('[data-tab]').data('tab');
|
333
378
|
$tab = module.get.tabElement(currentPath);
|
334
379
|
// if anchor exists use parent tab
|
335
380
|
if($anchor && $anchor.length > 0 && currentPath) {
|
336
|
-
module.debug('
|
381
|
+
module.debug('Anchor link used, opening parent tab', $tab, $anchor);
|
382
|
+
if( !$tab.hasClass(className.active) ) {
|
383
|
+
setTimeout(function() {
|
384
|
+
module.scrollTo($anchor);
|
385
|
+
}, 0);
|
386
|
+
}
|
337
387
|
module.activate.all(currentPath);
|
338
388
|
if( !module.cache.read(currentPath) ) {
|
339
389
|
module.cache.add(currentPath, true);
|
340
390
|
module.debug('First time tab loaded calling tab init');
|
341
|
-
settings.
|
391
|
+
settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
342
392
|
}
|
393
|
+
settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
|
343
394
|
return false;
|
344
395
|
}
|
345
396
|
}
|
@@ -350,17 +401,51 @@ $.fn.tab = function(parameters) {
|
|
350
401
|
});
|
351
402
|
},
|
352
403
|
|
353
|
-
|
404
|
+
scrollTo: function($element) {
|
405
|
+
var
|
406
|
+
scrollOffset = ($element && $element.length > 0)
|
407
|
+
? $element.offset().top
|
408
|
+
: false
|
409
|
+
;
|
410
|
+
if(scrollOffset !== false) {
|
411
|
+
module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element);
|
412
|
+
$(document).scrollTop(scrollOffset);
|
413
|
+
}
|
414
|
+
},
|
415
|
+
|
416
|
+
update: {
|
417
|
+
content: function(tabPath, html, evaluateScripts) {
|
418
|
+
var
|
419
|
+
$tab = module.get.tabElement(tabPath),
|
420
|
+
tab = $tab[0]
|
421
|
+
;
|
422
|
+
evaluateScripts = (evaluateScripts !== undefined)
|
423
|
+
? evaluateScripts
|
424
|
+
: settings.evaluateScripts
|
425
|
+
;
|
426
|
+
if(evaluateScripts) {
|
427
|
+
module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
|
428
|
+
$tab.html(html);
|
429
|
+
}
|
430
|
+
else {
|
431
|
+
module.debug('Updating HTML', tabPath, html);
|
432
|
+
tab.innerHTML = html;
|
433
|
+
}
|
434
|
+
}
|
435
|
+
},
|
436
|
+
|
437
|
+
fetch: {
|
354
438
|
|
355
|
-
|
439
|
+
content: function(tabPath, fullTabPath) {
|
356
440
|
var
|
357
441
|
$tab = module.get.tabElement(tabPath),
|
358
442
|
apiSettings = {
|
359
|
-
dataType
|
360
|
-
on
|
361
|
-
|
443
|
+
dataType : 'html',
|
444
|
+
on : 'now',
|
445
|
+
cache : 'local',
|
446
|
+
onSuccess : function(response) {
|
362
447
|
module.cache.add(fullTabPath, response);
|
363
|
-
module.content
|
448
|
+
module.update.content(tabPath, response);
|
364
449
|
if(tabPath == activeTabPath) {
|
365
450
|
module.debug('Content loaded', tabPath);
|
366
451
|
module.activate.tab(tabPath);
|
@@ -368,10 +453,12 @@ $.fn.tab = function(parameters) {
|
|
368
453
|
else {
|
369
454
|
module.debug('Content loaded in background', tabPath);
|
370
455
|
}
|
371
|
-
settings.
|
372
|
-
settings.
|
456
|
+
settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
457
|
+
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
373
458
|
},
|
374
|
-
urlData: {
|
459
|
+
urlData: {
|
460
|
+
tab: fullTabPath
|
461
|
+
}
|
375
462
|
},
|
376
463
|
request = $tab.api('get request') || false,
|
377
464
|
existingRequest = ( request && request.state() === 'pending' ),
|
@@ -383,37 +470,33 @@ $.fn.tab = function(parameters) {
|
|
383
470
|
cachedContent = module.cache.read(fullTabPath);
|
384
471
|
|
385
472
|
|
386
|
-
module.activate.tab(tabPath);
|
387
|
-
|
388
473
|
if(settings.cache && cachedContent) {
|
389
|
-
module.
|
390
|
-
module.content
|
391
|
-
settings.
|
474
|
+
module.activate.tab(tabPath);
|
475
|
+
module.debug('Adding cached content', fullTabPath);
|
476
|
+
if(settings.evaluateScripts == 'once') {
|
477
|
+
module.update.content(tabPath, cachedContent, false);
|
478
|
+
}
|
479
|
+
else {
|
480
|
+
module.update.content(tabPath, cachedContent);
|
481
|
+
}
|
482
|
+
settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
|
392
483
|
}
|
393
484
|
else if(existingRequest) {
|
485
|
+
module.set.loading(tabPath);
|
394
486
|
module.debug('Content is already loading', fullTabPath);
|
395
|
-
$tab.addClass(className.loading);
|
396
487
|
}
|
397
488
|
else if($.api !== undefined) {
|
398
489
|
requestSettings = $.extend(true, {
|
399
|
-
headers: {
|
490
|
+
headers: {
|
491
|
+
'X-Remote': true
|
492
|
+
}
|
400
493
|
}, settings.apiSettings, apiSettings);
|
401
494
|
module.debug('Retrieving remote content', fullTabPath, requestSettings);
|
402
|
-
$tab.api(
|
495
|
+
$tab.api(requestSettings);
|
403
496
|
}
|
404
497
|
else {
|
405
498
|
module.error(error.api);
|
406
499
|
}
|
407
|
-
},
|
408
|
-
|
409
|
-
update: function(tabPath, html) {
|
410
|
-
module.debug('Updating html for', tabPath);
|
411
|
-
var
|
412
|
-
$tab = module.get.tabElement(tabPath)
|
413
|
-
;
|
414
|
-
$tab
|
415
|
-
.html(html)
|
416
|
-
;
|
417
500
|
}
|
418
501
|
},
|
419
502
|
|
@@ -424,25 +507,34 @@ $.fn.tab = function(parameters) {
|
|
424
507
|
},
|
425
508
|
tab: function(tabPath) {
|
426
509
|
var
|
427
|
-
$tab
|
510
|
+
$tab = module.get.tabElement(tabPath),
|
511
|
+
isActive = $tab.hasClass(className.active)
|
428
512
|
;
|
429
513
|
module.verbose('Showing tab content for', $tab);
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
.
|
434
|
-
|
514
|
+
if(!isActive) {
|
515
|
+
$tab
|
516
|
+
.addClass(className.active)
|
517
|
+
.siblings($tabs)
|
518
|
+
.removeClass(className.active + ' ' + className.loading)
|
519
|
+
;
|
520
|
+
if($tab.length > 0) {
|
521
|
+
settings.onVisible.call($tab[0], tabPath);
|
522
|
+
}
|
523
|
+
}
|
435
524
|
},
|
436
525
|
navigation: function(tabPath) {
|
437
526
|
var
|
438
|
-
$navigation = module.get.navElement(tabPath)
|
527
|
+
$navigation = module.get.navElement(tabPath),
|
528
|
+
isActive = $navigation.hasClass(className.active)
|
439
529
|
;
|
440
530
|
module.verbose('Activating tab navigation for', $navigation, tabPath);
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
.
|
445
|
-
|
531
|
+
if(!isActive) {
|
532
|
+
$navigation
|
533
|
+
.addClass(className.active)
|
534
|
+
.siblings($allModules)
|
535
|
+
.removeClass(className.active + ' ' + className.loading)
|
536
|
+
;
|
537
|
+
}
|
446
538
|
}
|
447
539
|
},
|
448
540
|
|
@@ -626,7 +718,7 @@ $.fn.tab = function(parameters) {
|
|
626
718
|
});
|
627
719
|
}
|
628
720
|
clearTimeout(module.performance.timer);
|
629
|
-
module.performance.timer = setTimeout(module.performance.display,
|
721
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
630
722
|
},
|
631
723
|
display: function() {
|
632
724
|
var
|
@@ -726,9 +818,6 @@ $.fn.tab = function(parameters) {
|
|
726
818
|
}
|
727
819
|
})
|
728
820
|
;
|
729
|
-
if(module && !methodInvoked) {
|
730
|
-
module.initializeHistory();
|
731
|
-
}
|
732
821
|
return (returnedValue !== undefined)
|
733
822
|
? returnedValue
|
734
823
|
: this
|
@@ -747,7 +836,7 @@ $.fn.tab.settings = {
|
|
747
836
|
namespace : 'tab',
|
748
837
|
|
749
838
|
debug : false,
|
750
|
-
verbose :
|
839
|
+
verbose : false,
|
751
840
|
performance : true,
|
752
841
|
|
753
842
|
auto : false, // uses pjax style endpoints fetching content from same url with remote-content headers
|
@@ -762,10 +851,14 @@ $.fn.tab.settings = {
|
|
762
851
|
alwaysRefresh : false, // load tab content new every tab click
|
763
852
|
cache : true, // cache the content requests to pull locally
|
764
853
|
ignoreFirstLoad : false, // don't load remote content on first load
|
854
|
+
|
765
855
|
apiSettings : false, // settings for api call
|
856
|
+
evaluateScripts : 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content
|
766
857
|
|
767
|
-
|
768
|
-
|
858
|
+
onFirstLoad : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded
|
859
|
+
onLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load
|
860
|
+
onVisible : function(tabPath, parameterArray, historyEvent) {}, // called every time tab visible
|
861
|
+
onRequest : function(tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content
|
769
862
|
|
770
863
|
templates : {
|
771
864
|
determineTitle: function(tabArray) {} // returns page title for path
|
@@ -774,10 +867,12 @@ $.fn.tab.settings = {
|
|
774
867
|
error: {
|
775
868
|
api : 'You attempted to load content without API module',
|
776
869
|
method : 'The method you called is not defined',
|
777
|
-
missingTab : 'Activated tab cannot be found
|
870
|
+
missingTab : 'Activated tab cannot be found. Tabs are case-sensitive.',
|
778
871
|
noContent : 'The tab you specified is missing a content url.',
|
779
872
|
path : 'History enabled, but no path was specified',
|
780
873
|
recursion : 'Max recursive depth reached',
|
874
|
+
legacyInit : 'onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.',
|
875
|
+
legacyLoad : 'onTabLoad has been renamed to onLoad in 2.0. Please adjust your code',
|
781
876
|
state : 'History requires Asual\'s Address library <https://github.com/asual/jquery-address>'
|
782
877
|
},
|
783
878
|
|