webshims-rails 1.14.6 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +145 -139
- data/vendor/assets/javascripts/webshims/shims/canvas-blob.js +97 -0
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +13 -15
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +29 -28
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +22 -10
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +22 -10
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +28 -43
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +41 -44
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +98 -71
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +9 -9
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +13 -1
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +141 -51
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +66 -12
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +1 -2
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/34.js +36 -36
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +27 -27
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +29 -28
- data/vendor/assets/javascripts/webshims/shims/combos/98.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/combos/99.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +27 -27
- data/vendor/assets/javascripts/webshims/shims/es6.js +23 -29
- data/vendor/assets/javascripts/webshims/shims/{filereader.js → filereader-xhr.js} +66 -12
- data/vendor/assets/javascripts/webshims/shims/form-core.js +0 -14
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1 -2
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +18 -5
- data/vendor/assets/javascripts/webshims/shims/form-validators.js +15 -14
- data/vendor/assets/javascripts/webshims/shims/geolocation.js +41 -50
- data/vendor/assets/javascripts/webshims/shims/jme/controls.css +4 -4
- data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +2 -1
- data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/mediacapture-picker.js +42 -0
- data/vendor/assets/javascripts/webshims/shims/mediacapture.js +159 -0
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +13 -1
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +48 -12
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +20 -8
- data/vendor/assets/javascripts/webshims/shims/{combos/26.js → moxie/js/moxie-html4.js} +2121 -1257
- data/vendor/assets/javascripts/webshims/shims/moxie/js/{moxie.js → moxie-swf.js} +1125 -1741
- data/vendor/assets/javascripts/webshims/shims/sticky.js +585 -0
- data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +20 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +23 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +74 -34
- data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +78 -31
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +78 -31
- data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +214 -111
- data/vendor/assets/javascripts/webshims/shims/track.js +9 -9
- data/vendor/assets/javascripts/webshims/shims/usermedia-core.js +27 -0
- data/vendor/assets/javascripts/webshims/shims/usermedia-shim.js +34 -37
- metadata +9 -8
- data/vendor/assets/javascripts/webshims/shims/jajax.js +0 -1262
- data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.cdn.xap +0 -0
- data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.min.xap +0 -0
@@ -0,0 +1,585 @@
|
|
1
|
+
webshim.register('sticky', function($, webshim, window, document, undefined, featureOptions){
|
2
|
+
|
3
|
+
"use strict";
|
4
|
+
|
5
|
+
var uid = 0;
|
6
|
+
var stickys = 0;
|
7
|
+
var $window = $(window);
|
8
|
+
|
9
|
+
function getCssValue(property, value, noPrefixes) {
|
10
|
+
var prop = property + ':',
|
11
|
+
el = document.createElement('test'),
|
12
|
+
mStyle = el.style;
|
13
|
+
|
14
|
+
if (!noPrefixes) {
|
15
|
+
mStyle.cssText = prop + [ '-webkit-', '-moz-', '-ms-', '-o-', '' ].join(value + ';' + prop) + value + ';';
|
16
|
+
} else {
|
17
|
+
mStyle.cssText = prop + value;
|
18
|
+
}
|
19
|
+
|
20
|
+
return mStyle[ property ];
|
21
|
+
}
|
22
|
+
|
23
|
+
function getPos() {
|
24
|
+
return {
|
25
|
+
top: $.css(this, 'top'),
|
26
|
+
bottom: $.css(this, 'bottom')
|
27
|
+
};
|
28
|
+
}
|
29
|
+
|
30
|
+
var getWinScroll = (function () {
|
31
|
+
var docElem;
|
32
|
+
var prop = 'pageYOffset';
|
33
|
+
|
34
|
+
return (prop in window) ?
|
35
|
+
function () {
|
36
|
+
return window[ prop ];
|
37
|
+
} :
|
38
|
+
((docElem = document.documentElement), function () {
|
39
|
+
return docElem.scrollTop;
|
40
|
+
})
|
41
|
+
;
|
42
|
+
})();
|
43
|
+
var isTouch = 'ontouchstart' in window || window.matchMedia('(max-device-width: 721px)').matches;
|
44
|
+
var support = {
|
45
|
+
fixed: getCssValue('position', 'fixed', true),
|
46
|
+
sticky: getCssValue('position', 'sticky')
|
47
|
+
};
|
48
|
+
|
49
|
+
var stickyMixin = {
|
50
|
+
getPosition: function () {
|
51
|
+
|
52
|
+
if(!this.isSticky){
|
53
|
+
this.position = {
|
54
|
+
top: this.$el.css('top'),
|
55
|
+
bottom: this.$el.css('bottom')
|
56
|
+
};
|
57
|
+
|
58
|
+
if (((
|
59
|
+
(this.position.top != 'auto' && this.position.bottom != 'auto') ||
|
60
|
+
this.position.top == 'auto' && this.position.bottom == 'auto')) && this.$el.css('position') == 'static') {
|
61
|
+
this.position = $.swap(this.$el[0], {position: 'absolute'}, getPos);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (this.position.top !== 'auto') {
|
65
|
+
this.ankered = 'top';
|
66
|
+
} else if (this.position.bottom !== 'auto') {
|
67
|
+
this.ankered = 'bottom';
|
68
|
+
}
|
69
|
+
|
70
|
+
if(this.ankered == 'top'){
|
71
|
+
this.position.top = parseFloat(this.position.top, 10) || 0;
|
72
|
+
} else if(this.ankered == 'bottom'){
|
73
|
+
this.position.bottom = parseFloat(this.position.bottom, 10) || 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
}
|
77
|
+
},
|
78
|
+
update: function (full) {
|
79
|
+
if (!this.disabled && this.$el[0].offsetWidth) {
|
80
|
+
if (full) {
|
81
|
+
if(this.isSticky){
|
82
|
+
this.removeSticky();
|
83
|
+
}
|
84
|
+
this.getPosition();
|
85
|
+
}
|
86
|
+
this.updateDimension();
|
87
|
+
}
|
88
|
+
},
|
89
|
+
setTdWidth: function(){
|
90
|
+
if(this.isTable){
|
91
|
+
this.$el.find('td, th').each(this._setInlineWidth);
|
92
|
+
}
|
93
|
+
},
|
94
|
+
_setInlineWidth: function(){
|
95
|
+
$.data(this, 'inlineWidth', this.style.width);
|
96
|
+
$(this).innerWidth($(this).innerWidth());
|
97
|
+
},
|
98
|
+
_restoreInlineWidth: function(){
|
99
|
+
this.style.width = $.data(this, 'inlineWidth') || '';
|
100
|
+
$.removeData(this, 'inlineWidth');
|
101
|
+
},
|
102
|
+
removeSticky: function(){
|
103
|
+
this.$el.removeClass('ws-sticky-on');
|
104
|
+
this.$el.css(this.stickyData.inline);
|
105
|
+
this.$placeholder.detach();
|
106
|
+
this.isSticky = false;
|
107
|
+
|
108
|
+
if(this.isTable){
|
109
|
+
this.$el.find('td, th').each(this._restoreInlineWidth);
|
110
|
+
}
|
111
|
+
},
|
112
|
+
commonAddEvents: function(){
|
113
|
+
var enableDisable;
|
114
|
+
var that = this;
|
115
|
+
var update = function() {
|
116
|
+
that.update();
|
117
|
+
};
|
118
|
+
|
119
|
+
var stickyMedia = this.$el.data('stickymedia');
|
120
|
+
var media = window.matchMedia && stickyMedia ? matchMedia(stickyMedia) : false;
|
121
|
+
$window.one('load', update);
|
122
|
+
$(document).on('updateshadowdom' + this.evtid, update);
|
123
|
+
|
124
|
+
|
125
|
+
this.$el.on('updatesticky'+ this.evtid, function(e){
|
126
|
+
that.update(true);
|
127
|
+
e.stopPropagation();
|
128
|
+
});
|
129
|
+
|
130
|
+
this.$el.on('disablesticky'+ this.evtid, function(e){
|
131
|
+
that.disable(true);
|
132
|
+
e.stopPropagation();
|
133
|
+
});
|
134
|
+
|
135
|
+
this.$el.on('enablesticky'+ this.evtid, function(e){
|
136
|
+
that.disable(false);
|
137
|
+
e.stopPropagation();
|
138
|
+
});
|
139
|
+
|
140
|
+
this.$el.on('remove'+ this.evtid+' destroysticky'+ this.evtid, function(e) {
|
141
|
+
|
142
|
+
$window.off(that.evtid);
|
143
|
+
$(document).off(that.evtid);
|
144
|
+
that.$el.off(that.evtid);
|
145
|
+
that.$parent.off(that.evtid);
|
146
|
+
that.$el.removeData('wsSticky').removeClass('ws-sticky');
|
147
|
+
if (that.$placeholder) {
|
148
|
+
that.$el.removeClass('ws-sticky-on');
|
149
|
+
that.$placeholder.remove();
|
150
|
+
}
|
151
|
+
stickys--;
|
152
|
+
e.stopPropagation();
|
153
|
+
});
|
154
|
+
|
155
|
+
if(media && media.addListener){
|
156
|
+
enableDisable = function(){
|
157
|
+
that.disable(!media.matches);
|
158
|
+
};
|
159
|
+
media.addListener(enableDisable);
|
160
|
+
enableDisable();
|
161
|
+
}
|
162
|
+
},
|
163
|
+
disable: function(disable){
|
164
|
+
if(!arguments.length){
|
165
|
+
return this.disabled;
|
166
|
+
}
|
167
|
+
if(this.disabled != disable){
|
168
|
+
this.disabled = !!disable;
|
169
|
+
if(this.disabled){
|
170
|
+
if(this.isSticky){
|
171
|
+
this.removeSticky();
|
172
|
+
}
|
173
|
+
} else {
|
174
|
+
this.update(true);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
},
|
178
|
+
setSticky: function(){
|
179
|
+
|
180
|
+
if (!this.$placeholder) {
|
181
|
+
this.$placeholder = this.isTable ? $(this.$el[0].cloneNode(true)) : $(document.createElement(this.$el[0].nodeName || 'div'));
|
182
|
+
this.$placeholder.addClass('ws-fixedsticky-placeholder').removeClass('ws-sticky');
|
183
|
+
}
|
184
|
+
|
185
|
+
this.setTdWidth();
|
186
|
+
|
187
|
+
this.$placeholder
|
188
|
+
.insertAfter(this.$el)
|
189
|
+
.outerHeight(this.stickyData.outerHeight, true)
|
190
|
+
.outerWidth(this.stickyData.outerWidth)
|
191
|
+
;
|
192
|
+
|
193
|
+
this.isSticky = true;
|
194
|
+
this.$el.addClass('ws-sticky-on');
|
195
|
+
|
196
|
+
if(!this.isTable){
|
197
|
+
if( this.stickyData.width != this.$el.width()){
|
198
|
+
this.$el.width(this.stickyData.width);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
},
|
202
|
+
getCommonStickyData: function(){
|
203
|
+
var marginTop = (parseFloat(this.$el.css('marginTop'), 10) || 0);
|
204
|
+
|
205
|
+
this.stickyData.scrollTop = this.stickyData.top - marginTop;
|
206
|
+
|
207
|
+
this.stickyData.outerHeight = this.$el.outerHeight(true);
|
208
|
+
|
209
|
+
this.stickyData.bottom = this.stickyData.top + this.stickyData.outerHeight - marginTop;
|
210
|
+
|
211
|
+
this.stickyData.width = this.$el.width();
|
212
|
+
this.stickyData.outerWidth = this.$el.outerWidth();
|
213
|
+
|
214
|
+
this.stickyData.marginLeft = parseFloat(this.$el.css('marginLeft'), 10) || 0;
|
215
|
+
this.stickyData.offsetLeft = this.$el[0].offsetLeft;
|
216
|
+
|
217
|
+
this.stickyData.inline.width = this.elStyle.width;
|
218
|
+
this.stickyData.inline.marginLeft = this.elStyle.marginLeft;
|
219
|
+
|
220
|
+
if(this.ankered == 'top'){
|
221
|
+
this.stickyData.inline.top = this.elStyle.top;
|
222
|
+
} else if(this.ankered == 'bottom'){
|
223
|
+
this.stickyData.inline.bottom = this.elStyle.bottom;
|
224
|
+
}
|
225
|
+
},
|
226
|
+
getCommonParentData: function(){
|
227
|
+
this.parentData.paddingTop = (parseFloat(this.$parent.css('paddingTop'), 10) || 0);
|
228
|
+
|
229
|
+
this.parentData.offsetTop = this.$parent.offset().top;
|
230
|
+
this.parentData.top = this.parentData.offsetTop + (parseFloat(this.$parent.css('borderTopWidth'), 10) || 0) + this.parentData.paddingTop;
|
231
|
+
|
232
|
+
this.parentData.height = this.$parent.height();
|
233
|
+
this.parentData.bottom = this.parentData.top + this.parentData.height;
|
234
|
+
}
|
235
|
+
};
|
236
|
+
|
237
|
+
if(isTouch && featureOptions.touchStrategy == 'disable'){return;}
|
238
|
+
|
239
|
+
|
240
|
+
function Sticky(dom) {
|
241
|
+
|
242
|
+
uid++;
|
243
|
+
stickys++;
|
244
|
+
|
245
|
+
this.evtid = '.wsstickyid' + uid;
|
246
|
+
this.$el = $(dom).data('wsSticky', this);
|
247
|
+
this.isTable = this.$el.is('thead, tbody, tfoot');
|
248
|
+
this.$parent = this.$el.parent();
|
249
|
+
this.elStyle = dom.style;
|
250
|
+
|
251
|
+
|
252
|
+
this.ankered = '';
|
253
|
+
this.isSticky = false;
|
254
|
+
this.$placeholder = null;
|
255
|
+
|
256
|
+
this.stickyData = {inline: {}};
|
257
|
+
this.parentData = {};
|
258
|
+
|
259
|
+
this.getParentData = this.getCommonParentData;
|
260
|
+
|
261
|
+
|
262
|
+
this.addEvents();
|
263
|
+
this.update(true);
|
264
|
+
}
|
265
|
+
|
266
|
+
$.extend(Sticky.prototype, stickyMixin, {
|
267
|
+
addEvents: function () {
|
268
|
+
var that = this;
|
269
|
+
|
270
|
+
this.commonAddEvents();
|
271
|
+
|
272
|
+
$window
|
273
|
+
.on('scroll' + this.evtid, function () {
|
274
|
+
if (!that.disabled && that.ankered && that.$el[0].offsetWidth) {
|
275
|
+
that.updatePos();
|
276
|
+
}
|
277
|
+
})
|
278
|
+
;
|
279
|
+
},
|
280
|
+
|
281
|
+
getStickyData: function(){
|
282
|
+
this.stickyData.top = this.$el.offset().top;
|
283
|
+
|
284
|
+
this.getCommonStickyData();
|
285
|
+
},
|
286
|
+
|
287
|
+
updateDimension: function(fromPos){
|
288
|
+
if(this.isSticky){
|
289
|
+
this.removeSticky();
|
290
|
+
}
|
291
|
+
this.getParentData();
|
292
|
+
this.getStickyData();
|
293
|
+
|
294
|
+
if (this.ankered == 'bottom') {
|
295
|
+
this.viewportBottomAnker = $window.height() - this.position.bottom;
|
296
|
+
}
|
297
|
+
|
298
|
+
if(!fromPos && this.ankered){
|
299
|
+
this.updatePos(true);
|
300
|
+
}
|
301
|
+
},
|
302
|
+
updatePos: function(fromDimension){
|
303
|
+
var offset, shouldSticky, shouldMoveWith;
|
304
|
+
var scroll = getWinScroll();
|
305
|
+
|
306
|
+
if (this.ankered == 'top') {
|
307
|
+
offset = scroll + this.position.top;
|
308
|
+
if(this.stickyData.scrollTop < offset && scroll - 9 <= this.parentData.bottom){
|
309
|
+
shouldMoveWith = ((offset + this.stickyData.outerHeight) - this.parentData.bottom) * -1;
|
310
|
+
|
311
|
+
shouldSticky = true;
|
312
|
+
}
|
313
|
+
} else if (this.ankered == 'bottom') {
|
314
|
+
offset = scroll + this.viewportBottomAnker;
|
315
|
+
|
316
|
+
if(this.stickyData.bottom > offset &&
|
317
|
+
offset + 9 >= this.parentData.top){
|
318
|
+
shouldSticky = true;
|
319
|
+
|
320
|
+
shouldMoveWith = offset - this.parentData.top - this.stickyData.outerHeight;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
if (shouldSticky) {
|
325
|
+
if (!this.isSticky) {
|
326
|
+
|
327
|
+
//updateDimension before layout trashing
|
328
|
+
if(!fromDimension){
|
329
|
+
this.updateDimension(true);
|
330
|
+
}
|
331
|
+
|
332
|
+
this.setSticky();
|
333
|
+
}
|
334
|
+
|
335
|
+
|
336
|
+
if(shouldMoveWith < 0){
|
337
|
+
if(this.ankered == 'top'){
|
338
|
+
this.elStyle.top = this.position.top + shouldMoveWith +'px';
|
339
|
+
} else if(this.ankered == 'bottom'){
|
340
|
+
this.elStyle.bottom = this.position.bottom + shouldMoveWith +'px';
|
341
|
+
}
|
342
|
+
}
|
343
|
+
} else if (this.isSticky) {
|
344
|
+
this.removeSticky();
|
345
|
+
}
|
346
|
+
}
|
347
|
+
});
|
348
|
+
|
349
|
+
|
350
|
+
function StickyParent(dom) {
|
351
|
+
|
352
|
+
uid++;
|
353
|
+
stickys++;
|
354
|
+
|
355
|
+
this.evtid = '.wsstickyid' + uid;
|
356
|
+
this.$el = $(dom).data('wsSticky', this);
|
357
|
+
this.isTable = this.$el.is('thead, tbody, tfoot');
|
358
|
+
this.$parent = this.$el.parent();
|
359
|
+
this.elStyle = dom.style;
|
360
|
+
|
361
|
+
|
362
|
+
this.ankered = '';
|
363
|
+
this.isSticky = false;
|
364
|
+
this.$placeholder = null;
|
365
|
+
|
366
|
+
this.stickyData = {inline: {}};
|
367
|
+
this.parentData = {};
|
368
|
+
|
369
|
+
if(this.$parent.css('position') == 'static'){
|
370
|
+
this.$parent.css('position', 'relative');
|
371
|
+
}
|
372
|
+
|
373
|
+
this.updatePos2 = this.updatePos2.bind(this);
|
374
|
+
|
375
|
+
this.addEvents();
|
376
|
+
this.update(true);
|
377
|
+
|
378
|
+
}
|
379
|
+
|
380
|
+
$.extend(StickyParent.prototype, stickyMixin, {
|
381
|
+
addEvents: function () {
|
382
|
+
var that = this;
|
383
|
+
|
384
|
+
this.commonAddEvents();
|
385
|
+
|
386
|
+
this.$parent
|
387
|
+
.on('scroll' + this.evtid, function () {
|
388
|
+
if (that.ankered && that.$el[0].offsetWidth) {
|
389
|
+
that.updatePos();
|
390
|
+
}
|
391
|
+
})
|
392
|
+
;
|
393
|
+
},
|
394
|
+
getStickyData: function(){
|
395
|
+
this.stickyData.top = this.$el[0].offsetTop;
|
396
|
+
|
397
|
+
this.getCommonStickyData();
|
398
|
+
},
|
399
|
+
getParentData: function(){
|
400
|
+
this.getCommonParentData();
|
401
|
+
|
402
|
+
this.parentData.offsetBottom = this.parentData.top + this.$parent.outerHeight();
|
403
|
+
},
|
404
|
+
updateDimension: function(fromPos){
|
405
|
+
var add;
|
406
|
+
if(this.isSticky){
|
407
|
+
this.removeSticky();
|
408
|
+
}
|
409
|
+
this.getParentData();
|
410
|
+
this.getStickyData();
|
411
|
+
|
412
|
+
this.viewport = $window.height();
|
413
|
+
|
414
|
+
if(this.ankered == 'top'){
|
415
|
+
add = Math.abs(this.position.top) + 9;
|
416
|
+
} else if(this.ankered == 'bottom') {
|
417
|
+
add = Math.abs(this.position.bottom) + 9;
|
418
|
+
this.viewportBottomAnker = this.viewport - this.parentData.bottom;
|
419
|
+
this.compareBottom = this.stickyData.bottom + this.position.bottom;
|
420
|
+
|
421
|
+
this.addBottom = (this.parentData.bottom - this.parentData.paddingTop) - this.viewport;
|
422
|
+
}
|
423
|
+
|
424
|
+
this.viewPortMax = this.parentData.offsetBottom + add + 10;
|
425
|
+
this.viewPortMin = this.parentData.offsetTop - add - this.viewport;
|
426
|
+
|
427
|
+
if(!fromPos){
|
428
|
+
this.updatePos(true);
|
429
|
+
}
|
430
|
+
},
|
431
|
+
updatePos: function(fromDimension){
|
432
|
+
var offset, shouldSticky;
|
433
|
+
var scroll = this.$parent[0].scrollTop;
|
434
|
+
|
435
|
+
if (this.ankered == 'top') {
|
436
|
+
offset = scroll + this.position.top ;
|
437
|
+
if(this.stickyData.scrollTop - this.parentData.paddingTop < offset){
|
438
|
+
shouldSticky = true;
|
439
|
+
}
|
440
|
+
} else if (this.ankered == 'bottom') {
|
441
|
+
if(scroll + this.parentData.height < this.compareBottom){
|
442
|
+
shouldSticky = true;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
|
446
|
+
if (shouldSticky) {
|
447
|
+
if (!this.isSticky) {
|
448
|
+
|
449
|
+
//updateDimension before layout trashing
|
450
|
+
if(!fromDimension){
|
451
|
+
this.updateDimension(true);
|
452
|
+
}
|
453
|
+
|
454
|
+
this.setSticky();
|
455
|
+
|
456
|
+
$window
|
457
|
+
.off('scroll' + this.evtid, this.updatePos2)
|
458
|
+
.on('scroll' + this.evtid, this.updatePos2)
|
459
|
+
;
|
460
|
+
this.updatePos2(true);
|
461
|
+
}
|
462
|
+
} else if (this.isSticky) {
|
463
|
+
this.removeSticky();
|
464
|
+
$window.off('scroll' + this.evtid, this.updatePos2);
|
465
|
+
}
|
466
|
+
},
|
467
|
+
updatePos2: function(init){
|
468
|
+
var scrollTop = getWinScroll();
|
469
|
+
|
470
|
+
if(init === true || (this.viewPortMax > scrollTop && scrollTop > this.viewPortMin)){
|
471
|
+
|
472
|
+
if(this.ankered == 'top'){
|
473
|
+
if(init === true || (this.viewPortMax > scrollTop && scrollTop > this.viewPortMin)){
|
474
|
+
this.elStyle.top = this.position.top + this.parentData.top - scrollTop +'px';
|
475
|
+
}
|
476
|
+
} else if(this.ankered == 'bottom'){
|
477
|
+
this.elStyle.bottom = this.position.bottom + (scrollTop - this.addBottom) +'px';
|
478
|
+
}
|
479
|
+
}
|
480
|
+
}
|
481
|
+
});
|
482
|
+
|
483
|
+
var loadDomSupport = function(){
|
484
|
+
loadDomSupport = $.noop;
|
485
|
+
webshim.ready('WINDOWLOAD', function(){
|
486
|
+
webshim.loader.loadList(['dom-extend']);
|
487
|
+
webshim.ready('dom-extend', function(){
|
488
|
+
webshim.addShadowDom();
|
489
|
+
});
|
490
|
+
});
|
491
|
+
};
|
492
|
+
|
493
|
+
var addSticky = function(){
|
494
|
+
var stickyData = $.data(this, 'wsSticky');
|
495
|
+
if(!stickyData){
|
496
|
+
var $parent = $(this).parent();
|
497
|
+
$(this).addClass('ws-sticky');
|
498
|
+
if(($parent.css('overflowY') || $parent.css('overflow') || 'visible') == 'visible'){
|
499
|
+
new Sticky(this);
|
500
|
+
} else {
|
501
|
+
//webshim.warn('currently not supported');
|
502
|
+
new StickyParent(this);
|
503
|
+
}
|
504
|
+
loadDomSupport();
|
505
|
+
} else if(stickyData.disable) {
|
506
|
+
stickyData.disable(false);
|
507
|
+
}
|
508
|
+
};
|
509
|
+
|
510
|
+
if (!support.sticky && support.fixed) {
|
511
|
+
var selectors = {};
|
512
|
+
var createUpdateDomSearch = function(media, sels){
|
513
|
+
var i, created, elems;
|
514
|
+
|
515
|
+
var updated = [];
|
516
|
+
|
517
|
+
if(!selectors[media]){
|
518
|
+
selectors[media] = {sels: {}, string: '',
|
519
|
+
fn: function(context, insertedElement){
|
520
|
+
var elems = $(selectors[media].string, context).add(insertedElement.filter(selectors[media].string));
|
521
|
+
if(media){
|
522
|
+
elems.data('stickymedia', media);
|
523
|
+
}
|
524
|
+
elems.each(addSticky);
|
525
|
+
}
|
526
|
+
};
|
527
|
+
created = true;
|
528
|
+
}
|
529
|
+
|
530
|
+
for(i = 0; i < sels.length; i++){
|
531
|
+
if(!selectors[media].sels[sels[i]]){
|
532
|
+
selectors[media].sels[sels[i]] = true;
|
533
|
+
updated.push(sels[i]);
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
if(!created && !updated.length){return;}
|
538
|
+
|
539
|
+
selectors[media].string = Object.keys(selectors[media].sels).join(', ');
|
540
|
+
|
541
|
+
if(created){
|
542
|
+
$(function(){
|
543
|
+
webshim.addReady(selectors[media].fn);
|
544
|
+
});
|
545
|
+
} else if($.isReady){
|
546
|
+
elems = $(updated.join(', '));
|
547
|
+
if(media){
|
548
|
+
elems.data('stickymedia', media);
|
549
|
+
}
|
550
|
+
elems.each(addSticky);
|
551
|
+
}
|
552
|
+
};
|
553
|
+
createUpdateDomSearch('', ['.ws-sticky']);
|
554
|
+
|
555
|
+
$(function(){
|
556
|
+
$(document).on('wssticky', function(e){
|
557
|
+
addSticky.call(e.target);
|
558
|
+
});
|
559
|
+
});
|
560
|
+
|
561
|
+
|
562
|
+
if(featureOptions.parseCSS){
|
563
|
+
if(window.Polyfill && Polyfill.prototype && Polyfill.prototype.doMatched){
|
564
|
+
var onEnableRule = function(rule){
|
565
|
+
var curSelectors = rule.getSelectors().split(/\,\s*/g);
|
566
|
+
var media = (!rule._rule.media || !rule._rule.media.length) ? '' : rule.getMedia();
|
567
|
+
createUpdateDomSearch(media || '', curSelectors);
|
568
|
+
};
|
569
|
+
|
570
|
+
Polyfill({declarations:["position:sticky"]})
|
571
|
+
.doMatched(function(rules){
|
572
|
+
rules.each(onEnableRule);
|
573
|
+
})
|
574
|
+
;
|
575
|
+
|
576
|
+
} else {
|
577
|
+
webshim.warn('Polyfill for CSS polyfilling made easy has to be included');
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
if(document.readyState == 'complete'){
|
583
|
+
webshim.isReady('WINDOWLOAD', true);
|
584
|
+
}
|
585
|
+
});
|