fomantic-ui-sass 2.8.8.1 → 2.9.1

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