fomantic-ui-sass 2.9.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/fonts/semantic-ui/Lato-Bold.woff +0 -0
  3. data/app/assets/fonts/semantic-ui/Lato-Bold.woff2 +0 -0
  4. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff +0 -0
  5. data/app/assets/fonts/semantic-ui/Lato-BoldItalic.woff2 +0 -0
  6. data/app/assets/fonts/semantic-ui/Lato-Italic.woff +0 -0
  7. data/app/assets/fonts/semantic-ui/Lato-Italic.woff2 +0 -0
  8. data/app/assets/fonts/semantic-ui/Lato-Regular.woff +0 -0
  9. data/app/assets/fonts/semantic-ui/Lato-Regular.woff2 +0 -0
  10. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff +0 -0
  11. data/app/assets/fonts/semantic-ui/LatoLatin-Bold.woff2 +0 -0
  12. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff +0 -0
  13. data/app/assets/fonts/semantic-ui/LatoLatin-BoldItalic.woff2 +0 -0
  14. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff +0 -0
  15. data/app/assets/fonts/semantic-ui/LatoLatin-Italic.woff2 +0 -0
  16. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff +0 -0
  17. data/app/assets/fonts/semantic-ui/LatoLatin-Regular.woff2 +0 -0
  18. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  19. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  20. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  21. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  22. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  23. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  24. data/app/assets/javascripts/semantic-ui/accordion.js +569 -596
  25. data/app/assets/javascripts/semantic-ui/api.js +1158 -1180
  26. data/app/assets/javascripts/semantic-ui/calendar.js +1935 -1810
  27. data/app/assets/javascripts/semantic-ui/checkbox.js +843 -842
  28. data/app/assets/javascripts/semantic-ui/dimmer.js +707 -738
  29. data/app/assets/javascripts/semantic-ui/dropdown.js +4196 -4237
  30. data/app/assets/javascripts/semantic-ui/embed.js +646 -676
  31. data/app/assets/javascripts/semantic-ui/flyout.js +1515 -1466
  32. data/app/assets/javascripts/semantic-ui/form.js +2023 -2005
  33. data/app/assets/javascripts/semantic-ui/modal.js +1545 -1487
  34. data/app/assets/javascripts/semantic-ui/nag.js +521 -527
  35. data/app/assets/javascripts/semantic-ui/popup.js +1457 -1457
  36. data/app/assets/javascripts/semantic-ui/progress.js +970 -998
  37. data/app/assets/javascripts/semantic-ui/rating.js +508 -524
  38. data/app/assets/javascripts/semantic-ui/search.js +1521 -1535
  39. data/app/assets/javascripts/semantic-ui/shape.js +784 -811
  40. data/app/assets/javascripts/semantic-ui/sidebar.js +1062 -1100
  41. data/app/assets/javascripts/semantic-ui/site.js +437 -477
  42. data/app/assets/javascripts/semantic-ui/slider.js +1311 -1312
  43. data/app/assets/javascripts/semantic-ui/state.js +639 -658
  44. data/app/assets/javascripts/semantic-ui/sticky.js +848 -902
  45. data/app/assets/javascripts/semantic-ui/tab.js +903 -967
  46. data/app/assets/javascripts/semantic-ui/toast.js +911 -885
  47. data/app/assets/javascripts/semantic-ui/transition.js +1049 -1078
  48. data/app/assets/javascripts/semantic-ui/visibility.js +1214 -1246
  49. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +7 -7
  50. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +246 -341
  51. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +185 -331
  52. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +272 -433
  53. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +127 -199
  54. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +549 -776
  55. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +711 -1123
  56. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +9 -8
  57. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +45 -63
  58. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +3556 -3556
  59. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +272 -270
  60. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +120 -144
  61. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +667 -747
  62. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +41 -65
  63. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +358 -276
  64. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +361 -412
  65. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +51 -72
  66. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +69 -157
  67. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +24 -44
  68. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +17 -22
  69. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +46 -85
  70. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +150 -226
  71. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +79 -152
  72. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +33 -33
  73. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +10 -15
  74. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +30 -43
  75. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +37 -55
  76. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +26 -29
  77. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +122 -193
  78. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +55 -174
  79. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +254 -388
  80. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +20 -31
  81. data/app/assets/stylesheets/semantic-ui/modules/_flyout.scss +97 -143
  82. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +122 -156
  83. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +55 -65
  84. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +426 -204
  85. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +108 -213
  86. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +83 -124
  87. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +71 -100
  88. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +16 -32
  89. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +105 -208
  90. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +93 -121
  91. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +3 -7
  92. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +12 -16
  93. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +71 -149
  94. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +371 -1282
  95. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +36 -47
  96. data/app/assets/stylesheets/semantic-ui/views/_card.scss +221 -367
  97. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +43 -61
  98. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +37 -59
  99. data/app/assets/stylesheets/semantic-ui/views/_item.scss +86 -133
  100. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +77 -118
  101. data/lib/fomantic/ui/sass/version.rb +2 -2
  102. data/tasks/converter.rb +1 -1
  103. metadata +17 -1
@@ -1,968 +1,914 @@
1
1
  /*!
2
2
  * # Fomantic-UI - Sticky
3
- * http://github.com/fomantic/Fomantic-UI/
3
+ * https://github.com/fomantic/Fomantic-UI/
4
4
  *
5
5
  *
6
6
  * Released under the MIT license
7
- * http://opensource.org/licenses/MIT
7
+ * https://opensource.org/licenses/MIT
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
11
+ (function ($, window, document) {
12
+ 'use strict';
12
13
 
13
- 'use strict';
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
14
17
 
15
- $.isFunction = $.isFunction || function(obj) {
16
- return typeof obj === "function" && typeof obj.nodeType !== "number";
17
- };
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
18
21
 
19
- window = (typeof window != 'undefined' && window.Math == Math)
20
- ? window
21
- : (typeof self != 'undefined' && self.Math == Math)
22
- ? self
23
- : Function('return this')()
24
- ;
22
+ $.fn.sticky = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $document = $(document),
26
+ moduleSelector = $allModules.selector || '',
25
27
 
26
- $.fn.sticky = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- moduleSelector = $allModules.selector || '',
28
+ time = Date.now(),
29
+ performance = [],
30
30
 
31
- time = new Date().getTime(),
32
- performance = [],
31
+ query = arguments[0],
32
+ methodInvoked = typeof query === 'string',
33
+ queryArguments = [].slice.call(arguments, 1),
34
+ returnedValue
35
+ ;
33
36
 
34
- query = arguments[0],
35
- methodInvoked = (typeof query == 'string'),
36
- queryArguments = [].slice.call(arguments, 1),
37
- returnedValue
38
- ;
39
-
40
- $allModules
41
- .each(function() {
42
- var
43
- settings = ( $.isPlainObject(parameters) )
44
- ? $.extend(true, {}, $.fn.sticky.settings, parameters)
45
- : $.extend({}, $.fn.sticky.settings),
37
+ $allModules.each(function () {
38
+ var
39
+ settings = $.isPlainObject(parameters)
40
+ ? $.extend(true, {}, $.fn.sticky.settings, parameters)
41
+ : $.extend({}, $.fn.sticky.settings),
46
42
 
47
- className = settings.className,
48
- namespace = settings.namespace,
49
- error = settings.error,
43
+ className = settings.className,
44
+ namespace = settings.namespace,
45
+ error = settings.error,
50
46
 
51
- eventNamespace = '.' + namespace,
52
- moduleNamespace = 'module-' + namespace,
47
+ eventNamespace = '.' + namespace,
48
+ moduleNamespace = 'module-' + namespace,
53
49
 
54
- $module = $(this),
55
- $window = $(window),
56
- $scroll = [window,document].indexOf(settings.scrollContext) < 0 ? $(document).find(settings.scrollContext) : $(settings.scrollContext),
57
- $container,
58
- $context,
50
+ $module = $(this),
51
+ $window = $(window),
52
+ $scroll = [window, document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext),
53
+ $container,
54
+ $context,
59
55
 
60
- instance = $module.data(moduleNamespace),
56
+ instance = $module.data(moduleNamespace),
61
57
 
62
- requestAnimationFrame = window.requestAnimationFrame
63
- || window.mozRequestAnimationFrame
64
- || window.webkitRequestAnimationFrame
65
- || window.msRequestAnimationFrame
66
- || function(callback) { setTimeout(callback, 0); },
58
+ element = this,
67
59
 
68
- element = this,
60
+ documentObserver,
61
+ observer,
62
+ module
63
+ ;
69
64
 
70
- documentObserver,
71
- observer,
72
- module
73
- ;
65
+ module = {
74
66
 
75
- module = {
67
+ initialize: function () {
68
+ module.determineContainer();
69
+ module.determineContext();
70
+ module.verbose('Initializing sticky', settings, $container);
76
71
 
77
- initialize: function() {
72
+ module.save.positions();
73
+ module.checkErrors();
74
+ module.bind.events();
78
75
 
79
- module.determineContainer();
80
- module.determineContext();
81
- module.verbose('Initializing sticky', settings, $container);
76
+ if (settings.observeChanges) {
77
+ module.observeChanges();
78
+ }
79
+ module.instantiate();
80
+ },
82
81
 
83
- module.save.positions();
84
- module.checkErrors();
85
- module.bind.events();
82
+ instantiate: function () {
83
+ module.verbose('Storing instance of module', module);
84
+ instance = module;
85
+ $module
86
+ .data(moduleNamespace, module)
87
+ ;
88
+ },
86
89
 
87
- if(settings.observeChanges) {
88
- module.observeChanges();
89
- }
90
- module.instantiate();
91
- },
90
+ destroy: function () {
91
+ module.verbose('Destroying previous instance');
92
+ module.reset();
93
+ if (documentObserver) {
94
+ documentObserver.disconnect();
95
+ }
96
+ if (observer) {
97
+ observer.disconnect();
98
+ }
99
+ $window
100
+ .off('load' + eventNamespace, module.event.load)
101
+ .off('resize' + eventNamespace, module.event.resize)
102
+ ;
103
+ $scroll
104
+ .off('scrollchange' + eventNamespace, module.event.scrollchange)
105
+ ;
106
+ $module.removeData(moduleNamespace);
107
+ },
92
108
 
93
- instantiate: function() {
94
- module.verbose('Storing instance of module', module);
95
- instance = module;
96
- $module
97
- .data(moduleNamespace, module)
98
- ;
99
- },
109
+ observeChanges: function () {
110
+ if ('MutationObserver' in window) {
111
+ documentObserver = new MutationObserver(module.event.documentChanged);
112
+ observer = new MutationObserver(module.event.changed);
113
+ documentObserver.observe(document, {
114
+ childList: true,
115
+ subtree: true,
116
+ });
117
+ observer.observe(element, {
118
+ childList: true,
119
+ subtree: true,
120
+ });
121
+ observer.observe($context[0], {
122
+ childList: true,
123
+ subtree: true,
124
+ });
125
+ module.debug('Setting up mutation observer', observer);
126
+ }
127
+ },
100
128
 
101
- destroy: function() {
102
- module.verbose('Destroying previous instance');
103
- module.reset();
104
- if(documentObserver) {
105
- documentObserver.disconnect();
106
- }
107
- if(observer) {
108
- observer.disconnect();
109
- }
110
- $window
111
- .off('load' + eventNamespace, module.event.load)
112
- .off('resize' + eventNamespace, module.event.resize)
113
- ;
114
- $scroll
115
- .off('scrollchange' + eventNamespace, module.event.scrollchange)
116
- ;
117
- $module.removeData(moduleNamespace);
118
- },
129
+ determineContainer: function () {
130
+ if (settings.container) {
131
+ $container = [window, document].indexOf(settings.container) < 0 ? $document.find(settings.container) : $(settings.container);
132
+ } else {
133
+ $container = $module.offsetParent();
134
+ }
135
+ },
119
136
 
120
- observeChanges: function() {
121
- if('MutationObserver' in window) {
122
- documentObserver = new MutationObserver(module.event.documentChanged);
123
- observer = new MutationObserver(module.event.changed);
124
- documentObserver.observe(document, {
125
- childList : true,
126
- subtree : true
127
- });
128
- observer.observe(element, {
129
- childList : true,
130
- subtree : true
131
- });
132
- observer.observe($context[0], {
133
- childList : true,
134
- subtree : true
135
- });
136
- module.debug('Setting up mutation observer', observer);
137
- }
138
- },
137
+ determineContext: function () {
138
+ if (settings.context) {
139
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context);
140
+ } else {
141
+ $context = $container;
142
+ }
143
+ if ($context.length === 0) {
144
+ module.error(error.invalidContext, settings.context, $module);
145
+ }
146
+ },
139
147
 
140
- determineContainer: function() {
141
- if(settings.container) {
142
- $container = [window,document].indexOf(settings.container) < 0 ? $(document).find(settings.container) : $(settings.container);
143
- }
144
- else {
145
- $container = $module.offsetParent();
146
- }
147
- },
148
+ checkErrors: function () {
149
+ if (module.is.hidden()) {
150
+ module.error(error.visible, $module);
151
+ }
152
+ if (module.cache.element.height > module.cache.context.height) {
153
+ module.reset();
154
+ module.error(error.elementSize, $module);
155
+ }
156
+ },
148
157
 
149
- determineContext: function() {
150
- if(settings.context) {
151
- $context = [window,document].indexOf(settings.context) < 0 ? $(document).find(settings.context) : $(settings.context);
152
- }
153
- else {
154
- $context = $container;
155
- }
156
- if($context.length === 0) {
157
- module.error(error.invalidContext, settings.context, $module);
158
- }
159
- },
158
+ bind: {
159
+ events: function () {
160
+ $window
161
+ .on('load' + eventNamespace, module.event.load)
162
+ .on('resize' + eventNamespace, module.event.resize)
163
+ ;
164
+ // pub/sub pattern
165
+ $scroll
166
+ .off('scroll' + eventNamespace)
167
+ .on('scroll' + eventNamespace, module.event.scroll)
168
+ .on('scrollchange' + eventNamespace, module.event.scrollchange)
169
+ ;
170
+ },
171
+ },
160
172
 
161
- checkErrors: function() {
162
- if( module.is.hidden() ) {
163
- module.error(error.visible, $module);
164
- }
165
- if(module.cache.element.height > module.cache.context.height) {
166
- module.reset();
167
- module.error(error.elementSize, $module);
168
- }
169
- },
173
+ event: {
174
+ changed: function (mutations) {
175
+ clearTimeout(module.timer);
176
+ module.timer = setTimeout(function () {
177
+ module.verbose('DOM tree modified, updating sticky menu', mutations);
178
+ module.refresh();
179
+ }, 100);
180
+ },
181
+ documentChanged: function (mutations) {
182
+ [].forEach.call(mutations, function (mutation) {
183
+ if (mutation.removedNodes) {
184
+ [].forEach.call(mutation.removedNodes, function (node) {
185
+ if (node === element || $(node).find(element).length > 0) {
186
+ module.debug('Element removed from DOM, tearing down events');
187
+ module.destroy();
188
+ }
189
+ });
190
+ }
191
+ });
192
+ },
193
+ load: function () {
194
+ module.verbose('Page contents finished loading');
195
+ requestAnimationFrame(module.refresh);
196
+ },
197
+ resize: function () {
198
+ module.verbose('Window resized');
199
+ requestAnimationFrame(module.refresh);
200
+ },
201
+ scroll: function () {
202
+ requestAnimationFrame(function () {
203
+ $scroll.triggerHandler('scrollchange' + eventNamespace, $scroll.scrollTop());
204
+ });
205
+ },
206
+ scrollchange: function (event, scrollPosition) {
207
+ module.stick(scrollPosition);
208
+ settings.onScroll.call(element);
209
+ },
210
+ },
170
211
 
171
- bind: {
172
- events: function() {
173
- $window
174
- .on('load' + eventNamespace, module.event.load)
175
- .on('resize' + eventNamespace, module.event.resize)
176
- ;
177
- // pub/sub pattern
178
- $scroll
179
- .off('scroll' + eventNamespace)
180
- .on('scroll' + eventNamespace, module.event.scroll)
181
- .on('scrollchange' + eventNamespace, module.event.scrollchange)
182
- ;
183
- }
184
- },
212
+ refresh: function (hardRefresh) {
213
+ module.reset();
214
+ if (!settings.context) {
215
+ module.determineContext();
216
+ }
217
+ if (hardRefresh) {
218
+ module.determineContainer();
219
+ }
220
+ module.save.positions();
221
+ module.stick();
222
+ settings.onReposition.call(element);
223
+ },
185
224
 
186
- event: {
187
- changed: function(mutations) {
188
- clearTimeout(module.timer);
189
- module.timer = setTimeout(function() {
190
- module.verbose('DOM tree modified, updating sticky menu', mutations);
191
- module.refresh();
192
- }, 100);
193
- },
194
- documentChanged: function(mutations) {
195
- [].forEach.call(mutations, function(mutation) {
196
- if(mutation.removedNodes) {
197
- [].forEach.call(mutation.removedNodes, function(node) {
198
- if(node == element || $(node).find(element).length > 0) {
199
- module.debug('Element removed from DOM, tearing down events');
200
- module.destroy();
201
- }
202
- });
203
- }
204
- });
205
- },
206
- load: function() {
207
- module.verbose('Page contents finished loading');
208
- requestAnimationFrame(module.refresh);
209
- },
210
- resize: function() {
211
- module.verbose('Window resized');
212
- requestAnimationFrame(module.refresh);
213
- },
214
- scroll: function() {
215
- requestAnimationFrame(function() {
216
- $scroll.triggerHandler('scrollchange' + eventNamespace, $scroll.scrollTop() );
217
- });
218
- },
219
- scrollchange: function(event, scrollPosition) {
220
- module.stick(scrollPosition);
221
- settings.onScroll.call(element);
222
- }
223
- },
225
+ supports: {
226
+ sticky: function () {
227
+ var
228
+ $element = $('<div/>')
229
+ ;
230
+ $element.addClass(className.supported);
224
231
 
225
- refresh: function(hardRefresh) {
226
- module.reset();
227
- if(!settings.context) {
228
- module.determineContext();
229
- }
230
- if(hardRefresh) {
231
- module.determineContainer();
232
- }
233
- module.save.positions();
234
- module.stick();
235
- settings.onReposition.call(element);
236
- },
232
+ return $element.css('position').match('sticky');
233
+ },
234
+ },
237
235
 
238
- supports: {
239
- sticky: function() {
240
- var
241
- $element = $('<div/>')
242
- ;
243
- $element.addClass(className.supported);
244
- return($element.css('position').match('sticky'));
245
- }
246
- },
236
+ save: {
237
+ lastScroll: function (scroll) {
238
+ module.lastScroll = scroll;
239
+ },
240
+ elementScroll: function (scroll) {
241
+ module.elementScroll = scroll;
242
+ },
243
+ positions: function () {
244
+ var
245
+ scrollContext = {
246
+ height: $scroll.height(),
247
+ },
248
+ element = {
249
+ margin: {
250
+ top: parseInt($module.css('margin-top'), 10),
251
+ bottom: parseInt($module.css('margin-bottom'), 10),
252
+ },
253
+ offset: $module.offset(),
254
+ width: $module.outerWidth(),
255
+ height: $module.outerHeight(),
256
+ },
257
+ context = {
258
+ offset: $context.offset(),
259
+ height: $context.outerHeight(),
260
+ }
261
+ ;
262
+ if (!module.is.standardScroll()) {
263
+ module.debug('Non-standard scroll. Removing scroll offset from element offset');
264
+
265
+ scrollContext.top = $scroll.scrollTop();
266
+ scrollContext.left = $scroll.scrollLeft();
267
+
268
+ element.offset.top += scrollContext.top;
269
+ context.offset.top += scrollContext.top;
270
+ element.offset.left += scrollContext.left;
271
+ context.offset.left += scrollContext.left;
272
+ }
273
+ module.cache = {
274
+ fits: (element.height + settings.offset) <= scrollContext.height,
275
+ sameHeight: element.height === context.height,
276
+ scrollContext: {
277
+ height: scrollContext.height,
278
+ },
279
+ element: {
280
+ margin: element.margin,
281
+ top: element.offset.top - element.margin.top,
282
+ left: element.offset.left,
283
+ width: element.width,
284
+ height: element.height,
285
+ bottom: element.offset.top + element.height,
286
+ },
287
+ context: {
288
+ top: context.offset.top,
289
+ height: context.height,
290
+ bottom: context.offset.top + context.height,
291
+ },
292
+ };
293
+ module.set.containerSize();
294
+
295
+ module.stick();
296
+ module.debug('Caching element positions', module.cache);
297
+ },
298
+ },
247
299
 
248
- save: {
249
- lastScroll: function(scroll) {
250
- module.lastScroll = scroll;
251
- },
252
- elementScroll: function(scroll) {
253
- module.elementScroll = scroll;
254
- },
255
- positions: function() {
256
- var
257
- scrollContext = {
258
- height : $scroll.height()
259
- },
260
- element = {
261
- margin: {
262
- top : parseInt($module.css('margin-top'), 10),
263
- bottom : parseInt($module.css('margin-bottom'), 10),
264
- },
265
- offset : $module.offset(),
266
- width : $module.outerWidth(),
267
- height : $module.outerHeight()
268
- },
269
- context = {
270
- offset : $context.offset(),
271
- height : $context.outerHeight()
272
- }
273
- ;
274
- if( !module.is.standardScroll() ) {
275
- module.debug('Non-standard scroll. Removing scroll offset from element offset');
300
+ get: {
301
+ direction: function (scroll) {
302
+ var
303
+ direction = 'down'
304
+ ;
305
+ scroll = scroll || $scroll.scrollTop();
306
+ if (module.lastScroll && module.lastScroll > scroll) {
307
+ direction = 'up';
308
+ }
309
+
310
+ return direction;
311
+ },
312
+ scrollChange: function (scroll) {
313
+ scroll = scroll || $scroll.scrollTop();
314
+
315
+ return module.lastScroll
316
+ ? scroll - module.lastScroll
317
+ : 0;
318
+ },
319
+ currentElementScroll: function () {
320
+ if (module.elementScroll) {
321
+ return module.elementScroll;
322
+ }
323
+
324
+ return module.is.top()
325
+ ? Math.abs(parseInt($module.css('top'), 10)) || 0
326
+ : Math.abs(parseInt($module.css('bottom'), 10)) || 0;
327
+ },
328
+
329
+ elementScroll: function (scroll) {
330
+ scroll = scroll || $scroll.scrollTop();
331
+ var
332
+ element = module.cache.element,
333
+ scrollContext = module.cache.scrollContext,
334
+ delta = module.get.scrollChange(scroll),
335
+ maxScroll = element.height - scrollContext.height + settings.offset,
336
+ elementScroll = module.get.currentElementScroll(),
337
+ possibleScroll = elementScroll + delta
338
+ ;
339
+ if (module.cache.fits || possibleScroll < 0) {
340
+ elementScroll = 0;
341
+ } else if (possibleScroll > maxScroll) {
342
+ elementScroll = maxScroll;
343
+ } else {
344
+ elementScroll = possibleScroll;
345
+ }
346
+
347
+ return elementScroll;
348
+ },
349
+ },
276
350
 
277
- scrollContext.top = $scroll.scrollTop();
278
- scrollContext.left = $scroll.scrollLeft();
351
+ remove: {
352
+ lastScroll: function () {
353
+ delete module.lastScroll;
354
+ },
355
+ elementScroll: function () {
356
+ delete module.elementScroll;
357
+ },
358
+ minimumSize: function () {
359
+ $container
360
+ .css('min-height', '')
361
+ ;
362
+ },
363
+ offset: function () {
364
+ $module.css('margin-top', '');
365
+ },
366
+ },
279
367
 
280
- element.offset.top += scrollContext.top;
281
- context.offset.top += scrollContext.top;
282
- element.offset.left += scrollContext.left;
283
- context.offset.left += scrollContext.left;
284
- }
285
- module.cache = {
286
- fits : ( (element.height + settings.offset) <= scrollContext.height),
287
- sameHeight : (element.height == context.height),
288
- scrollContext : {
289
- height : scrollContext.height
290
- },
291
- element: {
292
- margin : element.margin,
293
- top : element.offset.top - element.margin.top,
294
- left : element.offset.left,
295
- width : element.width,
296
- height : element.height,
297
- bottom : element.offset.top + element.height
298
- },
299
- context: {
300
- top : context.offset.top,
301
- height : context.height,
302
- bottom : context.offset.top + context.height
303
- }
304
- };
305
- module.set.containerSize();
368
+ set: {
369
+ offset: function () {
370
+ module.verbose('Setting offset on element', settings.offset);
371
+ $module
372
+ .css('margin-top', settings.offset)
373
+ ;
374
+ },
375
+ containerSize: function () {
376
+ var
377
+ tagName = $container[0].tagName
378
+ ;
379
+ if (tagName === 'HTML' || tagName === 'body') {
380
+ module.determineContainer();
381
+ } else {
382
+ var tallestHeight = Math.max(module.cache.context.height, module.cache.element.height);
383
+ if (tallestHeight - $container.outerHeight() > settings.jitter) {
384
+ module.debug('Context is taller than container. Specifying exact height for container', module.cache.context.height);
385
+ $container.css({
386
+ height: tallestHeight,
387
+ });
388
+ } else {
389
+ $container.css({
390
+ height: '',
391
+ });
392
+ }
393
+ if (Math.abs($container.outerHeight() - module.cache.context.height) > settings.jitter) {
394
+ module.debug('Context has padding, specifying exact height for container', module.cache.context.height);
395
+ $container.css({
396
+ height: module.cache.context.height,
397
+ });
398
+ }
399
+ }
400
+ },
401
+ minimumSize: function () {
402
+ var
403
+ element = module.cache.element
404
+ ;
405
+ $container
406
+ .css('min-height', element.height)
407
+ ;
408
+ },
409
+ scroll: function (scroll) {
410
+ module.debug('Setting scroll on element', scroll);
411
+ if (module.elementScroll === scroll) {
412
+ return;
413
+ }
414
+ if (module.is.top()) {
415
+ $module
416
+ .css('bottom', '')
417
+ .css('top', -scroll + 'px')
418
+ ;
419
+ }
420
+ if (module.is.bottom()) {
421
+ $module
422
+ .css('top', '')
423
+ .css('bottom', scroll + 'px')
424
+ ;
425
+ }
426
+ },
427
+ size: function () {
428
+ if (module.cache.element.height !== 0 && module.cache.element.width !== 0) {
429
+ element.style.setProperty('width', module.cache.element.width + 'px', 'important');
430
+ element.style.setProperty('height', module.cache.element.height + 'px', 'important');
431
+ }
432
+ },
433
+ },
306
434
 
307
- module.stick();
308
- module.debug('Caching element positions', module.cache);
309
- }
310
- },
435
+ is: {
436
+ standardScroll: function () {
437
+ return $scroll[0] === window;
438
+ },
439
+ top: function () {
440
+ return $module.hasClass(className.top);
441
+ },
442
+ bottom: function () {
443
+ return $module.hasClass(className.bottom);
444
+ },
445
+ initialPosition: function () {
446
+ return !module.is.fixed() && !module.is.bound();
447
+ },
448
+ hidden: function () {
449
+ return !$module.is(':visible');
450
+ },
451
+ bound: function () {
452
+ return $module.hasClass(className.bound);
453
+ },
454
+ fixed: function () {
455
+ return $module.hasClass(className.fixed);
456
+ },
457
+ },
311
458
 
312
- get: {
313
- direction: function(scroll) {
314
- var
315
- direction = 'down'
316
- ;
317
- scroll = scroll || $scroll.scrollTop();
318
- if(module.lastScroll && module.lastScroll > scroll) {
319
- direction = 'up';
320
- }
321
- return direction;
322
- },
323
- scrollChange: function(scroll) {
324
- scroll = scroll || $scroll.scrollTop();
325
- return (module.lastScroll)
326
- ? (scroll - module.lastScroll)
327
- : 0
328
- ;
329
- },
330
- currentElementScroll: function() {
331
- if(module.elementScroll) {
332
- return module.elementScroll;
333
- }
334
- return ( module.is.top() )
335
- ? Math.abs(parseInt($module.css('top'), 10)) || 0
336
- : Math.abs(parseInt($module.css('bottom'), 10)) || 0
337
- ;
338
- },
459
+ stick: function (scrollPosition) {
460
+ var
461
+ cachedPosition = scrollPosition || $scroll.scrollTop(),
462
+ cache = module.cache,
463
+ fits = cache.fits,
464
+ sameHeight = cache.sameHeight,
465
+ element = cache.element,
466
+ scrollContext = cache.scrollContext,
467
+ context = cache.context,
468
+ offset = module.is.bottom() && settings.pushing
469
+ ? settings.bottomOffset
470
+ : settings.offset,
471
+ scroll = {
472
+ top: cachedPosition + offset,
473
+ bottom: cachedPosition + offset + scrollContext.height,
474
+ },
475
+ elementScroll = fits
476
+ ? 0
477
+ : module.get.elementScroll(scroll.top),
478
+
479
+ // shorthand
480
+ doesntFit = !fits,
481
+ elementVisible = element.height !== 0
482
+ ;
483
+ if (elementVisible && !sameHeight) {
484
+ if (module.is.initialPosition()) {
485
+ if (scroll.top >= context.bottom) {
486
+ module.debug('Initial element position is bottom of container');
487
+ module.bindBottom();
488
+ } else if (scroll.top > element.top) {
489
+ if ((element.height + scroll.top - elementScroll) >= context.bottom && element.height < context.height) {
490
+ module.debug('Initial element position is bottom of container');
491
+ module.bindBottom();
492
+ } else {
493
+ module.debug('Initial element position is fixed');
494
+ module.fixTop();
495
+ }
496
+ }
497
+ } else if (module.is.fixed()) {
498
+ if (module.is.top()) {
499
+ if (scroll.top <= element.top) {
500
+ module.debug('Fixed element reached top of container');
501
+ module.setInitialPosition();
502
+ } else if ((element.height + scroll.top - elementScroll) >= context.bottom) {
503
+ module.debug('Fixed element reached bottom of container');
504
+ module.bindBottom();
505
+ } else if (doesntFit) { // scroll element if larger than screen
506
+ module.set.scroll(elementScroll);
507
+ module.save.lastScroll(scroll.top);
508
+ module.save.elementScroll(elementScroll);
509
+ }
510
+ } else if (module.is.bottom()) {
511
+ if ((scroll.bottom - element.height) <= element.top) { // top edge
512
+ module.debug('Bottom fixed rail has reached top of container');
513
+ module.setInitialPosition();
514
+ } else if (scroll.bottom >= context.bottom) { // bottom edge
515
+ module.debug('Bottom fixed rail has reached bottom of container');
516
+ module.bindBottom();
517
+ } else if (doesntFit) { // scroll element if larger than screen
518
+ module.set.scroll(elementScroll);
519
+ module.save.lastScroll(scroll.top);
520
+ module.save.elementScroll(elementScroll);
521
+ }
522
+ }
523
+ } else if (module.is.bottom()) {
524
+ if (scroll.top <= element.top) {
525
+ module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button');
526
+ module.setInitialPosition();
527
+ } else {
528
+ if (settings.pushing) {
529
+ if (module.is.bound() && scroll.bottom <= context.bottom) {
530
+ module.debug('Fixing bottom attached element to bottom of browser.');
531
+ module.fixBottom();
532
+ }
533
+ } else {
534
+ if (module.is.bound() && (scroll.top <= context.bottom - element.height)) {
535
+ module.debug('Fixing bottom attached element to top of browser.');
536
+ module.fixTop();
537
+ }
538
+ }
539
+ }
540
+ }
541
+ }
542
+ },
339
543
 
340
- elementScroll: function(scroll) {
341
- scroll = scroll || $scroll.scrollTop();
342
- var
343
- element = module.cache.element,
344
- scrollContext = module.cache.scrollContext,
345
- delta = module.get.scrollChange(scroll),
346
- maxScroll = (element.height - scrollContext.height + settings.offset),
347
- elementScroll = module.get.currentElementScroll(),
348
- possibleScroll = (elementScroll + delta)
349
- ;
350
- if(module.cache.fits || possibleScroll < 0) {
351
- elementScroll = 0;
352
- }
353
- else if(possibleScroll > maxScroll ) {
354
- elementScroll = maxScroll;
355
- }
356
- else {
357
- elementScroll = possibleScroll;
358
- }
359
- return elementScroll;
360
- }
361
- },
544
+ bindTop: function () {
545
+ module.debug('Binding element to top of parent container');
546
+ module.remove.offset();
547
+ if (settings.setSize) {
548
+ module.set.size();
549
+ }
550
+ $module
551
+ .css({
552
+ left: '',
553
+ top: '',
554
+ marginBottom: '',
555
+ })
556
+ .removeClass(className.fixed)
557
+ .removeClass(className.bottom)
558
+ .addClass(className.bound)
559
+ .addClass(className.top)
560
+ ;
561
+ settings.onTop.call(element);
562
+ settings.onUnstick.call(element);
563
+ },
564
+ bindBottom: function () {
565
+ module.debug('Binding element to bottom of parent container');
566
+ module.remove.offset();
567
+ if (settings.setSize) {
568
+ module.set.size();
569
+ }
570
+ $module
571
+ .css({
572
+ left: '',
573
+ top: '',
574
+ })
575
+ .removeClass(className.fixed)
576
+ .removeClass(className.top)
577
+ .addClass(className.bound)
578
+ .addClass(className.bottom)
579
+ ;
580
+ settings.onBottom.call(element);
581
+ settings.onUnstick.call(element);
582
+ },
362
583
 
363
- remove: {
364
- lastScroll: function() {
365
- delete module.lastScroll;
366
- },
367
- elementScroll: function() {
368
- delete module.elementScroll;
369
- },
370
- minimumSize: function() {
371
- $container
372
- .css('min-height', '')
373
- ;
374
- },
375
- offset: function() {
376
- $module.css('margin-top', '');
377
- }
378
- },
584
+ setInitialPosition: function () {
585
+ module.debug('Returning to initial position');
586
+ module.unfix();
587
+ module.unbind();
588
+ },
379
589
 
380
- set: {
381
- offset: function() {
382
- module.verbose('Setting offset on element', settings.offset);
383
- $module
384
- .css('margin-top', settings.offset)
385
- ;
386
- },
387
- containerSize: function() {
388
- var
389
- tagName = $container[0].tagName
390
- ;
391
- if(tagName === 'HTML' || tagName === 'body') {
392
- // this can trigger for too many reasons
393
- //module.error(error.container, tagName, $module);
394
- module.determineContainer();
395
- }
396
- else {
397
- var tallestHeight = Math.max(module.cache.context.height, module.cache.element.height);
398
- if(tallestHeight - $container.outerHeight() > settings.jitter) {
399
- module.debug('Context is taller than container. Specifying exact height for container', module.cache.context.height);
400
- $container.css({
401
- height: tallestHeight,
402
- });
403
- }
404
- else {
405
- $container.css({
406
- height: '',
407
- });
408
- }
409
- if( Math.abs($container.outerHeight() - module.cache.context.height) > settings.jitter) {
410
- module.debug('Context has padding, specifying exact height for container', module.cache.context.height);
411
- $container.css({
412
- height: module.cache.context.height
413
- });
414
- }
415
- }
416
- },
417
- minimumSize: function() {
418
- var
419
- element = module.cache.element
420
- ;
421
- $container
422
- .css('min-height', element.height)
423
- ;
424
- },
425
- scroll: function(scroll) {
426
- module.debug('Setting scroll on element', scroll);
427
- if(module.elementScroll == scroll) {
428
- return;
429
- }
430
- if( module.is.top() ) {
431
- $module
432
- .css('bottom', '')
433
- .css('top', -scroll)
434
- ;
435
- }
436
- if( module.is.bottom() ) {
437
- $module
438
- .css('top', '')
439
- .css('bottom', scroll)
440
- ;
441
- }
442
- },
443
- size: function() {
444
- if(module.cache.element.height !== 0 && module.cache.element.width !== 0) {
445
- element.style.setProperty('width', module.cache.element.width + 'px', 'important');
446
- element.style.setProperty('height', module.cache.element.height + 'px', 'important');
447
- }
448
- }
449
- },
590
+ fixTop: function () {
591
+ module.debug('Fixing element to top of page');
592
+ if (settings.setSize) {
593
+ module.set.size();
594
+ }
595
+ module.set.minimumSize();
596
+ module.set.offset();
597
+ $module
598
+ .css({
599
+ left: module.cache.element.left,
600
+ bottom: '',
601
+ marginBottom: '',
602
+ })
603
+ .removeClass(className.bound)
604
+ .removeClass(className.bottom)
605
+ .addClass(className.fixed)
606
+ .addClass(className.top)
607
+ ;
608
+ settings.onStick.call(element);
609
+ },
450
610
 
451
- is: {
452
- standardScroll: function() {
453
- return ($scroll[0] == window);
454
- },
455
- top: function() {
456
- return $module.hasClass(className.top);
457
- },
458
- bottom: function() {
459
- return $module.hasClass(className.bottom);
460
- },
461
- initialPosition: function() {
462
- return (!module.is.fixed() && !module.is.bound());
463
- },
464
- hidden: function() {
465
- return (!$module.is(':visible'));
466
- },
467
- bound: function() {
468
- return $module.hasClass(className.bound);
469
- },
470
- fixed: function() {
471
- return $module.hasClass(className.fixed);
472
- }
473
- },
611
+ fixBottom: function () {
612
+ module.debug('Sticking element to bottom of page');
613
+ if (settings.setSize) {
614
+ module.set.size();
615
+ }
616
+ module.set.minimumSize();
617
+ module.set.offset();
618
+ $module
619
+ .css({
620
+ left: module.cache.element.left,
621
+ bottom: '',
622
+ marginBottom: '',
623
+ })
624
+ .removeClass(className.bound)
625
+ .removeClass(className.top)
626
+ .addClass(className.fixed)
627
+ .addClass(className.bottom)
628
+ ;
629
+ settings.onStick.call(element);
630
+ },
474
631
 
475
- stick: function(scrollPosition) {
476
- var
477
- cachedPosition = scrollPosition || $scroll.scrollTop(),
478
- cache = module.cache,
479
- fits = cache.fits,
480
- sameHeight = cache.sameHeight,
481
- element = cache.element,
482
- scrollContext = cache.scrollContext,
483
- context = cache.context,
484
- offset = (module.is.bottom() && settings.pushing)
485
- ? settings.bottomOffset
486
- : settings.offset,
487
- scroll = {
488
- top : cachedPosition + offset,
489
- bottom : cachedPosition + offset + scrollContext.height
490
- },
491
- elementScroll = (fits)
492
- ? 0
493
- : module.get.elementScroll(scroll.top),
494
-
495
- // shorthand
496
- doesntFit = !fits,
497
- elementVisible = (element.height !== 0)
498
- ;
499
- if(elementVisible && !sameHeight) {
500
-
501
- if( module.is.initialPosition() ) {
502
- if(scroll.top >= context.bottom) {
503
- module.debug('Initial element position is bottom of container');
504
- module.bindBottom();
505
- }
506
- else if(scroll.top > element.top) {
507
- if( (element.height + scroll.top - elementScroll) >= context.bottom && element.height < context.height) {
508
- module.debug('Initial element position is bottom of container');
509
- module.bindBottom();
510
- }
511
- else {
512
- module.debug('Initial element position is fixed');
513
- module.fixTop();
514
- }
515
- }
632
+ unbind: function () {
633
+ if (module.is.bound()) {
634
+ module.debug('Removing container bound position on element');
635
+ module.remove.offset();
636
+ $module
637
+ .removeClass(className.bound)
638
+ .removeClass(className.top)
639
+ .removeClass(className.bottom)
640
+ ;
641
+ }
642
+ },
516
643
 
517
- }
518
- else if( module.is.fixed() ) {
644
+ unfix: function () {
645
+ if (module.is.fixed()) {
646
+ module.debug('Removing fixed position on element');
647
+ module.remove.minimumSize();
648
+ module.remove.offset();
649
+ $module
650
+ .removeClass(className.fixed)
651
+ .removeClass(className.top)
652
+ .removeClass(className.bottom)
653
+ ;
654
+ settings.onUnstick.call(element);
655
+ }
656
+ },
519
657
 
520
- // currently fixed top
521
- if( module.is.top() ) {
522
- if( scroll.top <= element.top ) {
523
- module.debug('Fixed element reached top of container');
524
- module.setInitialPosition();
525
- }
526
- else if( (element.height + scroll.top - elementScroll) >= context.bottom ) {
527
- module.debug('Fixed element reached bottom of container');
528
- module.bindBottom();
529
- }
530
- // scroll element if larger than screen
531
- else if(doesntFit) {
532
- module.set.scroll(elementScroll);
533
- module.save.lastScroll(scroll.top);
534
- module.save.elementScroll(elementScroll);
535
- }
536
- }
658
+ reset: function () {
659
+ module.debug('Resetting elements position');
660
+ module.unbind();
661
+ module.unfix();
662
+ module.resetCSS();
663
+ module.remove.offset();
664
+ module.remove.lastScroll();
665
+ },
537
666
 
538
- // currently fixed bottom
539
- else if(module.is.bottom() ) {
667
+ resetCSS: function () {
668
+ $module
669
+ .css({
670
+ width: '',
671
+ height: '',
672
+ })
673
+ ;
674
+ $container
675
+ .css({
676
+ height: '',
677
+ })
678
+ ;
679
+ },
540
680
 
541
- // top edge
542
- if( (scroll.bottom - element.height) <= element.top) {
543
- module.debug('Bottom fixed rail has reached top of container');
544
- module.setInitialPosition();
545
- }
546
- // bottom edge
547
- else if(scroll.bottom >= context.bottom) {
548
- module.debug('Bottom fixed rail has reached bottom of container');
549
- module.bindBottom();
550
- }
551
- // scroll element if larger than screen
552
- else if(doesntFit) {
553
- module.set.scroll(elementScroll);
554
- module.save.lastScroll(scroll.top);
555
- module.save.elementScroll(elementScroll);
556
- }
681
+ setting: function (name, value) {
682
+ if ($.isPlainObject(name)) {
683
+ $.extend(true, settings, name);
684
+ } else if (value !== undefined) {
685
+ settings[name] = value;
686
+ } else {
687
+ return settings[name];
688
+ }
689
+ },
690
+ internal: function (name, value) {
691
+ if ($.isPlainObject(name)) {
692
+ $.extend(true, module, name);
693
+ } else if (value !== undefined) {
694
+ module[name] = value;
695
+ } else {
696
+ return module[name];
697
+ }
698
+ },
699
+ debug: function () {
700
+ if (!settings.silent && settings.debug) {
701
+ if (settings.performance) {
702
+ module.performance.log(arguments);
703
+ } else {
704
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
705
+ module.debug.apply(console, arguments);
706
+ }
707
+ }
708
+ },
709
+ verbose: function () {
710
+ if (!settings.silent && settings.verbose && settings.debug) {
711
+ if (settings.performance) {
712
+ module.performance.log(arguments);
713
+ } else {
714
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
715
+ module.verbose.apply(console, arguments);
716
+ }
717
+ }
718
+ },
719
+ error: function () {
720
+ if (!settings.silent) {
721
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
722
+ module.error.apply(console, arguments);
723
+ }
724
+ },
725
+ performance: {
726
+ log: function (message) {
727
+ var
728
+ currentTime,
729
+ executionTime,
730
+ previousTime
731
+ ;
732
+ if (settings.performance) {
733
+ currentTime = Date.now();
734
+ previousTime = time || currentTime;
735
+ executionTime = currentTime - previousTime;
736
+ time = currentTime;
737
+ performance.push({
738
+ Name: message[0],
739
+ Arguments: [].slice.call(message, 1) || '',
740
+ Element: element,
741
+ 'Execution Time': executionTime,
742
+ });
743
+ }
744
+ clearTimeout(module.performance.timer);
745
+ module.performance.timer = setTimeout(module.performance.display, 0);
746
+ },
747
+ display: function () {
748
+ var
749
+ title = settings.name + ':',
750
+ totalTime = 0
751
+ ;
752
+ time = false;
753
+ clearTimeout(module.performance.timer);
754
+ $.each(performance, function (index, data) {
755
+ totalTime += data['Execution Time'];
756
+ });
757
+ title += ' ' + totalTime + 'ms';
758
+ if (moduleSelector) {
759
+ title += ' \'' + moduleSelector + '\'';
760
+ }
761
+ if (performance.length > 0) {
762
+ console.groupCollapsed(title);
763
+ if (console.table) {
764
+ console.table(performance);
765
+ } else {
766
+ $.each(performance, function (index, data) {
767
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
768
+ });
769
+ }
770
+ console.groupEnd();
771
+ }
772
+ performance = [];
773
+ },
774
+ },
775
+ invoke: function (query, passedArguments, context) {
776
+ var
777
+ object = instance,
778
+ maxDepth,
779
+ found,
780
+ response
781
+ ;
782
+ passedArguments = passedArguments || queryArguments;
783
+ context = context || element;
784
+ if (typeof query === 'string' && object !== undefined) {
785
+ query = query.split(/[ .]/);
786
+ maxDepth = query.length - 1;
787
+ $.each(query, function (depth, value) {
788
+ var camelCaseValue = depth !== maxDepth
789
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
790
+ : query
791
+ ;
792
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
793
+ object = object[camelCaseValue];
794
+ } else if (object[camelCaseValue] !== undefined) {
795
+ found = object[camelCaseValue];
796
+
797
+ return false;
798
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
799
+ object = object[value];
800
+ } else if (object[value] !== undefined) {
801
+ found = object[value];
802
+
803
+ return false;
804
+ } else {
805
+ module.error(error.method, query);
806
+
807
+ return false;
808
+ }
809
+ });
810
+ }
811
+ if (isFunction(found)) {
812
+ response = found.apply(context, passedArguments);
813
+ } else if (found !== undefined) {
814
+ response = found;
815
+ }
816
+ if (Array.isArray(returnedValue)) {
817
+ returnedValue.push(response);
818
+ } else if (returnedValue !== undefined) {
819
+ returnedValue = [returnedValue, response];
820
+ } else if (response !== undefined) {
821
+ returnedValue = response;
822
+ }
823
+
824
+ return found;
825
+ },
826
+ };
557
827
 
558
- }
559
- }
560
- else if( module.is.bottom() ) {
561
- if( scroll.top <= element.top ) {
562
- module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button');
563
- module.setInitialPosition();
564
- }
565
- else {
566
- if(settings.pushing) {
567
- if(module.is.bound() && scroll.bottom <= context.bottom ) {
568
- module.debug('Fixing bottom attached element to bottom of browser.');
569
- module.fixBottom();
570
- }
828
+ if (methodInvoked) {
829
+ if (instance === undefined) {
830
+ module.initialize();
571
831
  }
572
- else {
573
- if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
574
- module.debug('Fixing bottom attached element to top of browser.');
575
- module.fixTop();
576
- }
832
+ module.invoke(query);
833
+ } else {
834
+ if (instance !== undefined) {
835
+ instance.invoke('destroy');
577
836
  }
578
- }
837
+ module.initialize();
579
838
  }
580
- }
581
- },
839
+ });
582
840
 
583
- bindTop: function() {
584
- module.debug('Binding element to top of parent container');
585
- module.remove.offset();
586
- if(settings.setSize) {
587
- module.set.size();
588
- }
589
- $module
590
- .css({
591
- left : '',
592
- top : '',
593
- marginBottom : ''
594
- })
595
- .removeClass(className.fixed)
596
- .removeClass(className.bottom)
597
- .addClass(className.bound)
598
- .addClass(className.top)
599
- ;
600
- settings.onTop.call(element);
601
- settings.onUnstick.call(element);
602
- },
603
- bindBottom: function() {
604
- module.debug('Binding element to bottom of parent container');
605
- module.remove.offset();
606
- if(settings.setSize) {
607
- module.set.size();
608
- }
609
- $module
610
- .css({
611
- left : '',
612
- top : ''
613
- })
614
- .removeClass(className.fixed)
615
- .removeClass(className.top)
616
- .addClass(className.bound)
617
- .addClass(className.bottom)
618
- ;
619
- settings.onBottom.call(element);
620
- settings.onUnstick.call(element);
621
- },
841
+ return returnedValue !== undefined
842
+ ? returnedValue
843
+ : this;
844
+ };
622
845
 
623
- setInitialPosition: function() {
624
- module.debug('Returning to initial position');
625
- module.unfix();
626
- module.unbind();
627
- },
846
+ $.fn.sticky.settings = {
628
847
 
848
+ name: 'Sticky',
849
+ namespace: 'sticky',
629
850
 
630
- fixTop: function() {
631
- module.debug('Fixing element to top of page');
632
- if(settings.setSize) {
633
- module.set.size();
634
- }
635
- module.set.minimumSize();
636
- module.set.offset();
637
- $module
638
- .css({
639
- left : module.cache.element.left,
640
- bottom : '',
641
- marginBottom : ''
642
- })
643
- .removeClass(className.bound)
644
- .removeClass(className.bottom)
645
- .addClass(className.fixed)
646
- .addClass(className.top)
647
- ;
648
- settings.onStick.call(element);
649
- },
851
+ silent: false,
852
+ debug: false,
853
+ verbose: true,
854
+ performance: true,
650
855
 
651
- fixBottom: function() {
652
- module.debug('Sticking element to bottom of page');
653
- if(settings.setSize) {
654
- module.set.size();
655
- }
656
- module.set.minimumSize();
657
- module.set.offset();
658
- $module
659
- .css({
660
- left : module.cache.element.left,
661
- bottom : '',
662
- marginBottom : ''
663
- })
664
- .removeClass(className.bound)
665
- .removeClass(className.top)
666
- .addClass(className.fixed)
667
- .addClass(className.bottom)
668
- ;
669
- settings.onStick.call(element);
670
- },
856
+ // whether to stick in the opposite direction on scroll up
857
+ pushing: false,
671
858
 
672
- unbind: function() {
673
- if( module.is.bound() ) {
674
- module.debug('Removing container bound position on element');
675
- module.remove.offset();
676
- $module
677
- .removeClass(className.bound)
678
- .removeClass(className.top)
679
- .removeClass(className.bottom)
680
- ;
681
- }
682
- },
859
+ context: false,
860
+ container: false,
683
861
 
684
- unfix: function() {
685
- if( module.is.fixed() ) {
686
- module.debug('Removing fixed position on element');
687
- module.remove.minimumSize();
688
- module.remove.offset();
689
- $module
690
- .removeClass(className.fixed)
691
- .removeClass(className.top)
692
- .removeClass(className.bottom)
693
- ;
694
- settings.onUnstick.call(element);
695
- }
696
- },
862
+ // Context to watch scroll events
863
+ scrollContext: window,
697
864
 
698
- reset: function() {
699
- module.debug('Resetting elements position');
700
- module.unbind();
701
- module.unfix();
702
- module.resetCSS();
703
- module.remove.offset();
704
- module.remove.lastScroll();
705
- },
865
+ // Offset to adjust scroll
866
+ offset: 0,
706
867
 
707
- resetCSS: function() {
708
- $module
709
- .css({
710
- width : '',
711
- height : ''
712
- })
713
- ;
714
- $container
715
- .css({
716
- height: ''
717
- })
718
- ;
719
- },
868
+ // Offset to adjust scroll when attached to bottom of screen
869
+ bottomOffset: 0,
720
870
 
721
- setting: function(name, value) {
722
- if( $.isPlainObject(name) ) {
723
- $.extend(true, settings, name);
724
- }
725
- else if(value !== undefined) {
726
- settings[name] = value;
727
- }
728
- else {
729
- return settings[name];
730
- }
731
- },
732
- internal: function(name, value) {
733
- if( $.isPlainObject(name) ) {
734
- $.extend(true, module, name);
735
- }
736
- else if(value !== undefined) {
737
- module[name] = value;
738
- }
739
- else {
740
- return module[name];
741
- }
742
- },
743
- debug: function() {
744
- if(!settings.silent && settings.debug) {
745
- if(settings.performance) {
746
- module.performance.log(arguments);
747
- }
748
- else {
749
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
750
- module.debug.apply(console, arguments);
751
- }
752
- }
753
- },
754
- verbose: function() {
755
- if(!settings.silent && settings.verbose && settings.debug) {
756
- if(settings.performance) {
757
- module.performance.log(arguments);
758
- }
759
- else {
760
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
761
- module.verbose.apply(console, arguments);
762
- }
763
- }
764
- },
765
- error: function() {
766
- if(!settings.silent) {
767
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
768
- module.error.apply(console, arguments);
769
- }
871
+ // will only set container height if difference between context and container is larger than this number
872
+ jitter: 5,
873
+
874
+ // set width of sticky element when it is fixed to page (used to make sure 100% width is maintained if no fixed size set)
875
+ setSize: true,
876
+
877
+ // Whether to automatically observe changes with Mutation Observers
878
+ observeChanges: false,
879
+
880
+ // Called when position is recalculated
881
+ onReposition: function () {},
882
+
883
+ // Called on each scroll
884
+ onScroll: function () {},
885
+
886
+ // Called when element is stuck to viewport
887
+ onStick: function () {},
888
+
889
+ // Called when element is unstuck from viewport
890
+ onUnstick: function () {},
891
+
892
+ // Called when element reaches top of context
893
+ onTop: function () {},
894
+
895
+ // Called when element reaches bottom of context
896
+ onBottom: function () {},
897
+
898
+ error: {
899
+ visible: 'Element is hidden, you must call refresh after element becomes visible. Use silent setting to suppress this warning in production.',
900
+ method: 'The method you called is not defined.',
901
+ invalidContext: 'Context specified does not exist',
902
+ elementSize: 'Sticky element is larger than its container, cannot create sticky.',
770
903
  },
771
- performance: {
772
- log: function(message) {
773
- var
774
- currentTime,
775
- executionTime,
776
- previousTime
777
- ;
778
- if(settings.performance) {
779
- currentTime = new Date().getTime();
780
- previousTime = time || currentTime;
781
- executionTime = currentTime - previousTime;
782
- time = currentTime;
783
- performance.push({
784
- 'Name' : message[0],
785
- 'Arguments' : [].slice.call(message, 1) || '',
786
- 'Element' : element,
787
- 'Execution Time' : executionTime
788
- });
789
- }
790
- clearTimeout(module.performance.timer);
791
- module.performance.timer = setTimeout(module.performance.display, 0);
792
- },
793
- display: function() {
794
- var
795
- title = settings.name + ':',
796
- totalTime = 0
797
- ;
798
- time = false;
799
- clearTimeout(module.performance.timer);
800
- $.each(performance, function(index, data) {
801
- totalTime += data['Execution Time'];
802
- });
803
- title += ' ' + totalTime + 'ms';
804
- if(moduleSelector) {
805
- title += ' \'' + moduleSelector + '\'';
806
- }
807
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
808
- console.groupCollapsed(title);
809
- if(console.table) {
810
- console.table(performance);
811
- }
812
- else {
813
- $.each(performance, function(index, data) {
814
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
815
- });
816
- }
817
- console.groupEnd();
818
- }
819
- performance = [];
820
- }
904
+
905
+ className: {
906
+ bound: 'bound',
907
+ fixed: 'fixed',
908
+ supported: 'native',
909
+ top: 'top',
910
+ bottom: 'bottom',
821
911
  },
822
- invoke: function(query, passedArguments, context) {
823
- var
824
- object = instance,
825
- maxDepth,
826
- found,
827
- response
828
- ;
829
- passedArguments = passedArguments || queryArguments;
830
- context = context || element;
831
- if(typeof query == 'string' && object !== undefined) {
832
- query = query.split(/[\. ]/);
833
- maxDepth = query.length - 1;
834
- $.each(query, function(depth, value) {
835
- var camelCaseValue = (depth != maxDepth)
836
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
837
- : query
838
- ;
839
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
840
- object = object[camelCaseValue];
841
- }
842
- else if( object[camelCaseValue] !== undefined ) {
843
- found = object[camelCaseValue];
844
- return false;
845
- }
846
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
847
- object = object[value];
848
- }
849
- else if( object[value] !== undefined ) {
850
- found = object[value];
851
- return false;
852
- }
853
- else {
854
- return false;
855
- }
856
- });
857
- }
858
- if ( $.isFunction( found ) ) {
859
- response = found.apply(context, passedArguments);
860
- }
861
- else if(found !== undefined) {
862
- response = found;
863
- }
864
- if(Array.isArray(returnedValue)) {
865
- returnedValue.push(response);
866
- }
867
- else if(returnedValue !== undefined) {
868
- returnedValue = [returnedValue, response];
869
- }
870
- else if(response !== undefined) {
871
- returnedValue = response;
872
- }
873
- return found;
874
- }
875
- };
876
-
877
- if(methodInvoked) {
878
- if(instance === undefined) {
879
- module.initialize();
880
- }
881
- module.invoke(query);
882
- }
883
- else {
884
- if(instance !== undefined) {
885
- instance.invoke('destroy');
886
- }
887
- module.initialize();
888
- }
889
- })
890
- ;
891
-
892
- return (returnedValue !== undefined)
893
- ? returnedValue
894
- : this
895
- ;
896
- };
897
-
898
- $.fn.sticky.settings = {
899
-
900
- name : 'Sticky',
901
- namespace : 'sticky',
902
-
903
- silent : false,
904
- debug : false,
905
- verbose : true,
906
- performance : true,
907
-
908
- // whether to stick in the opposite direction on scroll up
909
- pushing : false,
910
-
911
- context : false,
912
- container : false,
913
-
914
- // Context to watch scroll events
915
- scrollContext : window,
916
-
917
- // Offset to adjust scroll
918
- offset : 0,
919
-
920
- // Offset to adjust scroll when attached to bottom of screen
921
- bottomOffset : 0,
922
-
923
- // will only set container height if difference between context and container is larger than this number
924
- jitter : 5,
925
-
926
- // set width of sticky element when it is fixed to page (used to make sure 100% width is maintained if no fixed size set)
927
- setSize : true,
928
-
929
- // Whether to automatically observe changes with Mutation Observers
930
- observeChanges : false,
931
-
932
- // Called when position is recalculated
933
- onReposition : function(){},
934
-
935
- // Called on each scroll
936
- onScroll : function(){},
937
-
938
- // Called when element is stuck to viewport
939
- onStick : function(){},
940
-
941
- // Called when element is unstuck from viewport
942
- onUnstick : function(){},
943
-
944
- // Called when element reaches top of context
945
- onTop : function(){},
946
-
947
- // Called when element reaches bottom of context
948
- onBottom : function(){},
949
-
950
- error : {
951
- container : 'Sticky element must be inside a relative container',
952
- visible : 'Element is hidden, you must call refresh after element becomes visible. Use silent setting to suppress this warning in production.',
953
- method : 'The method you called is not defined.',
954
- invalidContext : 'Context specified does not exist',
955
- elementSize : 'Sticky element is larger than its container, cannot create sticky.'
956
- },
957
-
958
- className : {
959
- bound : 'bound',
960
- fixed : 'fixed',
961
- supported : 'native',
962
- top : 'top',
963
- bottom : 'bottom'
964
- }
965
-
966
- };
967
-
968
- })( jQuery, window, document );
912
+
913
+ };
914
+ })(jQuery, window, document);