Version Description
Version 6.0.0 is a full rewrite of the frontend script. It fixes many edge cases like jumping, reloading, or resizing widgets. The rewrite also resolves bad Cumulative Layout Shifts.
Most changes are available when you enable "Test new version" under Appearance > Fixed Widget Options.
Please test and let us know if you discover any issues.
- added new (and optional) script version that uses
position: sticky
instead ofposition: fixed
- the frontend script does not need jQuery anymore
- removed unneeded options that previously helped resolving edge cases
- "Stop Elements" and "Custom Fixed Elements" now accept any selector, including IDs, Class, and Type selectors.
- fixed blocks in sidebars as introduced in WordPress 5.8
- define stop blocks in sidebars that move up fixed blocks on scrolling
- improved option descriptions on the admin page
- improved behavior for elements higher than the screen they first stick at the top and scroll to the bottom later
- removed duplicating widget code
Download this release
Release Info
Developer | webzunft |
Plugin | Q2W3 Fixed Widget |
Version | 6.0.0 |
Comparing to | |
See all releases |
Code changes from version 6.0.0-beta-3 to 6.0.0
- js/frontend.js +57 -52
- js/frontend.min.js +1 -1
- q2w3-fixed-widget.php +2 -2
- readme.txt +22 -24
js/frontend.js
CHANGED
@@ -44,36 +44,39 @@ var __assign = function() {
|
|
44 |
|
45 |
var StopWidgetClassName = 'FixedWidget__stop_widget';
|
46 |
var FixedWidgetClassName = 'FixedWidget__fixed_widget';
|
|
|
47 |
var Widget = /** @class */ (function () {
|
48 |
function Widget(el) {
|
49 |
this.el = el;
|
50 |
this.top_offset = 0;
|
51 |
this.root_offset = 0;
|
52 |
this.need_to_calc_el_offset = function (_) { return false; };
|
|
|
|
|
|
|
53 |
}
|
54 |
Widget.prototype.render = function () { };
|
55 |
Widget.prototype.mount = function (user_margins, layer, _max_top_offset) {
|
56 |
if (!this.el || !this.el.parentElement) {
|
57 |
return;
|
58 |
}
|
59 |
-
this.el.style.zIndex = ""
|
60 |
this.top_offset = this.get_total_top_offset(user_margins);
|
61 |
-
this.root_offset =
|
62 |
};
|
63 |
Widget.prototype.getElement = function () {
|
64 |
return this.el;
|
65 |
};
|
66 |
Widget.prototype.toString = function () {
|
67 |
var _a;
|
68 |
-
return ""
|
69 |
};
|
70 |
Widget.prototype.get_total_top_offset = function (margins) {
|
71 |
-
|
72 |
-
return get_sibilings_offset(next, this.need_to_calc_el_offset, next(this.el), margins.margin_top);
|
73 |
};
|
74 |
Widget.queryAllWidgetsContainers = function (className) {
|
75 |
return []
|
76 |
-
.concat(Array.from(document.querySelectorAll("."
|
77 |
.map(function (el) {
|
78 |
el.classList.remove(className);
|
79 |
el.removeAttribute('data-fixed_widget');
|
@@ -85,7 +88,7 @@ var Widget = /** @class */ (function () {
|
|
85 |
};
|
86 |
Widget.from = function (root, className) {
|
87 |
var _this = this;
|
88 |
-
return Array.from(root.querySelectorAll("."
|
89 |
.filter(function (el) { return el !== null; })
|
90 |
.map(function (e) { return new _this(e); });
|
91 |
};
|
@@ -118,20 +121,6 @@ var get_sibilings_offset = function (next, need_to_calc_el_offset, el, offset) {
|
|
118 |
var _a = getComputedStyle(el), marginTop = _a.marginTop, marginBottom = _a.marginBottom;
|
119 |
return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset + el.offsetHeight + parseInt(marginTop || '0') + parseInt(marginBottom || '0'));
|
120 |
};
|
121 |
-
/**
|
122 |
-
* Calc total offset from current element to root parent
|
123 |
-
* @param el
|
124 |
-
* @param top_parent
|
125 |
-
* @param offset
|
126 |
-
* @returns
|
127 |
-
*/
|
128 |
-
var get_root_offset = function (el, top_parent, offset) {
|
129 |
-
if (offset === void 0) { offset = 0; }
|
130 |
-
if (!el || el === top_parent) {
|
131 |
-
return offset;
|
132 |
-
}
|
133 |
-
return offset + get_root_offset(el.offsetParent, top_parent, el.offsetTop);
|
134 |
-
};
|
135 |
|
136 |
var PositionWidget = /** @class */ (function (_super) {
|
137 |
__extends(PositionWidget, _super);
|
@@ -139,14 +128,21 @@ var PositionWidget = /** @class */ (function (_super) {
|
|
139 |
var _this = _super !== null && _super.apply(this, arguments) || this;
|
140 |
_this.bottom_offset = 0;
|
141 |
_this.top_margin = 0;
|
|
|
142 |
/** Top offset of StopWidget */
|
143 |
_this.max_top_offset = 0;
|
144 |
_this.bottom_margin = 0;
|
145 |
_this.user_margins = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
return _this;
|
147 |
}
|
148 |
PositionWidget.prototype.mount = function (user_margins, layer, max_top_offset) {
|
149 |
-
_super.prototype.mount.call(this, user_margins, layer
|
150 |
if (!this.el || !this.el.parentElement) {
|
151 |
return;
|
152 |
}
|
@@ -155,16 +151,14 @@ var PositionWidget = /** @class */ (function (_super) {
|
|
155 |
this.bottom_margin = parseInt(marginBottom);
|
156 |
this.top_margin = parseInt(marginTop);
|
157 |
this.bottom_offset = this.get_total_bottom_offset(user_margins);
|
158 |
-
|
159 |
-
|
160 |
-
this.max_top_offset = max_top_offset;
|
161 |
-
}
|
162 |
};
|
163 |
PositionWidget.prototype.render = function () {
|
164 |
if (!this.el || !this.el.parentElement) {
|
165 |
return;
|
166 |
}
|
167 |
-
var scrollTop =
|
168 |
this.onScroll(scrollTop);
|
169 |
};
|
170 |
PositionWidget.from = function (root) {
|
@@ -184,7 +178,7 @@ var FixedWidget = /** @class */ (function (_super) {
|
|
184 |
var _this = _super.call(this, el) || this;
|
185 |
_this.is_pinned = false;
|
186 |
_this.relative_top = 0;
|
187 |
-
_this.init_style = { position: 'static',
|
188 |
_this.need_to_calc_el_offset = function (el) {
|
189 |
return el.classList.contains(FixedWidgetClassName);
|
190 |
};
|
@@ -199,36 +193,39 @@ var FixedWidget = /** @class */ (function (_super) {
|
|
199 |
if (!this.el) {
|
200 |
return;
|
201 |
}
|
|
|
|
|
|
|
|
|
202 |
this.relative_top =
|
203 |
this.max_top_offset
|
204 |
- this.top_offset
|
205 |
-
- this.
|
206 |
-
- this.bottom_offset
|
207 |
-
- this.bottom_margin
|
208 |
-
- this.top_margin;
|
209 |
-
this.clone();
|
210 |
this.store_style(getComputedStyle(this.el));
|
|
|
211 |
};
|
212 |
FixedWidget.prototype.clone = function () {
|
213 |
var _this = this;
|
214 |
-
|
215 |
-
if (!this.el) {
|
216 |
return;
|
217 |
}
|
218 |
this.clone_el = this.el.cloneNode(false);
|
219 |
this.clone_el.getAttributeNames().forEach(function (attr) {
|
220 |
_this.clone_el.removeAttribute(attr);
|
221 |
});
|
222 |
-
|
223 |
-
|
|
|
224 |
this.clone_el.style.display = 'none';
|
225 |
-
|
226 |
};
|
227 |
FixedWidget.prototype.store_style = function (style) {
|
228 |
this.init_style.position = style.position;
|
229 |
-
this.init_style.
|
|
|
230 |
this.init_style.width = style.width;
|
231 |
-
this.init_style.height = style.
|
232 |
};
|
233 |
FixedWidget.prototype.restore_style = function (style) {
|
234 |
if (!this.is_pinned) {
|
@@ -236,7 +233,6 @@ var FixedWidget = /** @class */ (function (_super) {
|
|
236 |
}
|
237 |
this.is_pinned = false;
|
238 |
style.position = this.init_style.position;
|
239 |
-
style.top = this.init_style.top;
|
240 |
if (this.clone_el) {
|
241 |
this.clone_el.style.display = 'none';
|
242 |
}
|
@@ -256,7 +252,7 @@ var FixedWidget = /** @class */ (function (_super) {
|
|
256 |
if (!this.el) {
|
257 |
return;
|
258 |
}
|
259 |
-
this.el.style.top = top
|
260 |
if (this.is_pinned) {
|
261 |
return;
|
262 |
}
|
@@ -285,7 +281,6 @@ var StickyWidget = /** @class */ (function (_super) {
|
|
285 |
function StickyWidget(el) {
|
286 |
var _this = _super.call(this, el) || this;
|
287 |
_this.margins = 0;
|
288 |
-
_this.borderBox = 0; /** cleintHeight+ top & bottom margins */
|
289 |
_this.need_to_calc_el_offset = function (el) {
|
290 |
return el.classList.contains(FixedWidgetClassName);
|
291 |
};
|
@@ -300,13 +295,16 @@ var StickyWidget = /** @class */ (function (_super) {
|
|
300 |
if (!this.el || !this.el.parentElement) {
|
301 |
return;
|
302 |
}
|
303 |
-
|
|
|
|
|
|
|
304 |
this.margins = this.el.parentElement.clientHeight - this.borderBox;
|
305 |
this.el.style.position = 'sticky';
|
306 |
this.el.style.position = '-webkit-sticky';
|
307 |
this.el.style.transition = 'transform 0s';
|
308 |
this.el.style.boxSizing = 'border-box';
|
309 |
-
this.el.style.top = this.top_offset
|
310 |
};
|
311 |
StickyWidget.prototype.onScroll = function () {
|
312 |
if (!this.el || !this.el.parentElement) {
|
@@ -315,12 +313,12 @@ var StickyWidget = /** @class */ (function (_super) {
|
|
315 |
var bottom_margin = this.max_top_offset ?
|
316 |
Math.min(this.max_top_offset - this.el.offsetTop - this.borderBox, this.margins - this.el.offsetTop)
|
317 |
: this.margins - this.el.offsetTop;
|
318 |
-
if (bottom_margin
|
|
|
319 |
return;
|
320 |
}
|
321 |
-
this.el.style.transform = "translateY("
|
322 |
};
|
323 |
-
// || el.classList.contains(StopWidget.CLASSNAME);
|
324 |
StickyWidget.new = function (selector) {
|
325 |
return new StickyWidget(document.querySelector(selector));
|
326 |
};
|
@@ -367,6 +365,12 @@ var findIntersections = function (arr1, arr2) {
|
|
367 |
arr1.filter(function (e) { return arr2.includes(e); }),
|
368 |
];
|
369 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
var initSidebars = function (options) {
|
372 |
var fixedWidgetsContainers = Array.from(new Set(// use Set to remove duplicates
|
@@ -378,11 +382,11 @@ var initSidebars = function (options) {
|
|
378 |
Widget
|
379 |
.queryAllWidgetsContainers(StopWidgetClassName) // widgets by classNames from editor's plugin;
|
380 |
.concat(options.stop_elements_selectors ?
|
381 |
-
queryElements(options.stop_elements_selectors
|
382 |
: [])));
|
383 |
var _a = findIntersections(fixedWidgetsContainers, stopWidgetsContainers), stopWidgetsUniqContainers = _a[0], duplicates = _a[1];
|
384 |
duplicates.forEach(function (w) {
|
385 |
-
console.error("The Widget is detected as fixed block and stop block!\n"
|
386 |
});
|
387 |
fixedWidgetsContainers.forEach(function (c) { c.classList.add(FixedWidgetClassName); });
|
388 |
stopWidgetsUniqContainers.forEach(function (c) { c.classList.add(StopWidgetClassName); });
|
@@ -414,7 +418,7 @@ var Sidebar = /** @class */ (function () {
|
|
414 |
}
|
415 |
Sidebar.prototype.mount = function () {
|
416 |
var _this = this;
|
417 |
-
this.stop_widgets.forEach(function (widget, i) { return widget.mount(
|
418 |
this.min_top_offset = this.stop_widgets.length !== 0 ? Math.min.apply(Math, this.stop_widgets.map(this.use_sticky_position ?
|
419 |
function (w) { return w.top_offset; } :
|
420 |
function (w) { return w.root_offset; })) :
|
@@ -436,7 +440,8 @@ var Sidebar = /** @class */ (function () {
|
|
436 |
var queryElements = function (selectors) {
|
437 |
if (selectors === void 0) { selectors = []; }
|
438 |
return Array.from((selectors)
|
439 |
-
.map(function (selector) { return document.
|
|
|
440 |
.filter(function (e) { return e instanceof HTMLElement; });
|
441 |
};
|
442 |
|
44 |
|
45 |
var StopWidgetClassName = 'FixedWidget__stop_widget';
|
46 |
var FixedWidgetClassName = 'FixedWidget__fixed_widget';
|
47 |
+
// TODO export offset values, calculations in separate class Offsets
|
48 |
var Widget = /** @class */ (function () {
|
49 |
function Widget(el) {
|
50 |
this.el = el;
|
51 |
this.top_offset = 0;
|
52 |
this.root_offset = 0;
|
53 |
this.need_to_calc_el_offset = function (_) { return false; };
|
54 |
+
this.prevSibling = function (el) {
|
55 |
+
return el && el.previousElementSibling;
|
56 |
+
};
|
57 |
}
|
58 |
Widget.prototype.render = function () { };
|
59 |
Widget.prototype.mount = function (user_margins, layer, _max_top_offset) {
|
60 |
if (!this.el || !this.el.parentElement) {
|
61 |
return;
|
62 |
}
|
63 |
+
this.el.style.zIndex = "".concat(layer);
|
64 |
this.top_offset = this.get_total_top_offset(user_margins);
|
65 |
+
this.root_offset = scrollY + this.el.getBoundingClientRect().y;
|
66 |
};
|
67 |
Widget.prototype.getElement = function () {
|
68 |
return this.el;
|
69 |
};
|
70 |
Widget.prototype.toString = function () {
|
71 |
var _a;
|
72 |
+
return "".concat((_a = this.el) === null || _a === void 0 ? void 0 : _a.innerHTML);
|
73 |
};
|
74 |
Widget.prototype.get_total_top_offset = function (margins) {
|
75 |
+
return get_sibilings_offset(this.prevSibling, this.need_to_calc_el_offset, this.prevSibling(this.el), margins.margin_top);
|
|
|
76 |
};
|
77 |
Widget.queryAllWidgetsContainers = function (className) {
|
78 |
return []
|
79 |
+
.concat(Array.from(document.querySelectorAll(".".concat(className))), Array.from(document.querySelectorAll("[data-fixed_widget=".concat(className))))
|
80 |
.map(function (el) {
|
81 |
el.classList.remove(className);
|
82 |
el.removeAttribute('data-fixed_widget');
|
88 |
};
|
89 |
Widget.from = function (root, className) {
|
90 |
var _this = this;
|
91 |
+
return Array.from(root.querySelectorAll(".".concat(className)))
|
92 |
.filter(function (el) { return el !== null; })
|
93 |
.map(function (e) { return new _this(e); });
|
94 |
};
|
121 |
var _a = getComputedStyle(el), marginTop = _a.marginTop, marginBottom = _a.marginBottom;
|
122 |
return get_sibilings_offset(next, need_to_calc_el_offset, next(el), offset + el.offsetHeight + parseInt(marginTop || '0') + parseInt(marginBottom || '0'));
|
123 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
var PositionWidget = /** @class */ (function (_super) {
|
126 |
__extends(PositionWidget, _super);
|
128 |
var _this = _super !== null && _super.apply(this, arguments) || this;
|
129 |
_this.bottom_offset = 0;
|
130 |
_this.top_margin = 0;
|
131 |
+
_this.borderBox = 0; /** cleintHeight+ top & bottom margins */
|
132 |
/** Top offset of StopWidget */
|
133 |
_this.max_top_offset = 0;
|
134 |
_this.bottom_margin = 0;
|
135 |
_this.user_margins = {};
|
136 |
+
_this.prevSibling = function (el) {
|
137 |
+
return el
|
138 |
+
&& !el.classList.contains(StopWidgetClassName)
|
139 |
+
&& el.previousElementSibling
|
140 |
+
|| null;
|
141 |
+
};
|
142 |
return _this;
|
143 |
}
|
144 |
PositionWidget.prototype.mount = function (user_margins, layer, max_top_offset) {
|
145 |
+
_super.prototype.mount.call(this, user_margins, layer);
|
146 |
if (!this.el || !this.el.parentElement) {
|
147 |
return;
|
148 |
}
|
151 |
this.bottom_margin = parseInt(marginBottom);
|
152 |
this.top_margin = parseInt(marginTop);
|
153 |
this.bottom_offset = this.get_total_bottom_offset(user_margins);
|
154 |
+
this.max_top_offset = max_top_offset;
|
155 |
+
this.borderBox = this.el.clientHeight + this.top_margin + this.bottom_margin;
|
|
|
|
|
156 |
};
|
157 |
PositionWidget.prototype.render = function () {
|
158 |
if (!this.el || !this.el.parentElement) {
|
159 |
return;
|
160 |
}
|
161 |
+
var scrollTop = scrollY;
|
162 |
this.onScroll(scrollTop);
|
163 |
};
|
164 |
PositionWidget.from = function (root) {
|
178 |
var _this = _super.call(this, el) || this;
|
179 |
_this.is_pinned = false;
|
180 |
_this.relative_top = 0;
|
181 |
+
_this.init_style = { position: 'static', marginTop: '', marginBottom: '', width: '', height: '' };
|
182 |
_this.need_to_calc_el_offset = function (el) {
|
183 |
return el.classList.contains(FixedWidgetClassName);
|
184 |
};
|
193 |
if (!this.el) {
|
194 |
return;
|
195 |
}
|
196 |
+
/** StopWidget can limit top offset if it is placed only after widget*/
|
197 |
+
if (max_top_offset < this.root_offset) {
|
198 |
+
this.max_top_offset = 0;
|
199 |
+
}
|
200 |
this.relative_top =
|
201 |
this.max_top_offset
|
202 |
- this.top_offset
|
203 |
+
- this.borderBox
|
204 |
+
- this.bottom_offset;
|
|
|
|
|
|
|
205 |
this.store_style(getComputedStyle(this.el));
|
206 |
+
this.clone();
|
207 |
};
|
208 |
FixedWidget.prototype.clone = function () {
|
209 |
var _this = this;
|
210 |
+
if (!this.el || !this.el.parentElement) {
|
|
|
211 |
return;
|
212 |
}
|
213 |
this.clone_el = this.el.cloneNode(false);
|
214 |
this.clone_el.getAttributeNames().forEach(function (attr) {
|
215 |
_this.clone_el.removeAttribute(attr);
|
216 |
});
|
217 |
+
for (var prop in this.init_style) {
|
218 |
+
this.clone_el.style[prop] = this.init_style[prop];
|
219 |
+
}
|
220 |
this.clone_el.style.display = 'none';
|
221 |
+
this.el.parentElement.insertBefore(this.clone_el, this.el);
|
222 |
};
|
223 |
FixedWidget.prototype.store_style = function (style) {
|
224 |
this.init_style.position = style.position;
|
225 |
+
this.init_style.marginTop = style.marginTop;
|
226 |
+
this.init_style.marginBottom = style.marginBottom;
|
227 |
this.init_style.width = style.width;
|
228 |
+
this.init_style.height = style.height;
|
229 |
};
|
230 |
FixedWidget.prototype.restore_style = function (style) {
|
231 |
if (!this.is_pinned) {
|
233 |
}
|
234 |
this.is_pinned = false;
|
235 |
style.position = this.init_style.position;
|
|
|
236 |
if (this.clone_el) {
|
237 |
this.clone_el.style.display = 'none';
|
238 |
}
|
252 |
if (!this.el) {
|
253 |
return;
|
254 |
}
|
255 |
+
this.el.style.top = "".concat(top, "px");
|
256 |
if (this.is_pinned) {
|
257 |
return;
|
258 |
}
|
281 |
function StickyWidget(el) {
|
282 |
var _this = _super.call(this, el) || this;
|
283 |
_this.margins = 0;
|
|
|
284 |
_this.need_to_calc_el_offset = function (el) {
|
285 |
return el.classList.contains(FixedWidgetClassName);
|
286 |
};
|
295 |
if (!this.el || !this.el.parentElement) {
|
296 |
return;
|
297 |
}
|
298 |
+
/** StopWidget can limit top offset if it is placed only after widget*/
|
299 |
+
if (max_top_offset < this.el.offsetTop) {
|
300 |
+
this.max_top_offset = 0;
|
301 |
+
}
|
302 |
this.margins = this.el.parentElement.clientHeight - this.borderBox;
|
303 |
this.el.style.position = 'sticky';
|
304 |
this.el.style.position = '-webkit-sticky';
|
305 |
this.el.style.transition = 'transform 0s';
|
306 |
this.el.style.boxSizing = 'border-box';
|
307 |
+
this.el.style.top = "".concat(this.top_offset, "px");
|
308 |
};
|
309 |
StickyWidget.prototype.onScroll = function () {
|
310 |
if (!this.el || !this.el.parentElement) {
|
313 |
var bottom_margin = this.max_top_offset ?
|
314 |
Math.min(this.max_top_offset - this.el.offsetTop - this.borderBox, this.margins - this.el.offsetTop)
|
315 |
: this.margins - this.el.offsetTop;
|
316 |
+
if (bottom_margin >= this.bottom_offset) {
|
317 |
+
this.el.style.transform = "translateY(0px)";
|
318 |
return;
|
319 |
}
|
320 |
+
this.el.style.transform = "translateY(".concat(bottom_margin - this.bottom_offset, "px)");
|
321 |
};
|
|
|
322 |
StickyWidget.new = function (selector) {
|
323 |
return new StickyWidget(document.querySelector(selector));
|
324 |
};
|
365 |
arr1.filter(function (e) { return arr2.includes(e); }),
|
366 |
];
|
367 |
};
|
368 |
+
var splitSelectors = function (s) {
|
369 |
+
return s.replace(/[\r\n]|[\r]/gi, '\n')
|
370 |
+
.split('\n')
|
371 |
+
.map(function (s) { return s.trim(); })
|
372 |
+
.filter(function (s) { return s !== ''; });
|
373 |
+
};
|
374 |
|
375 |
var initSidebars = function (options) {
|
376 |
var fixedWidgetsContainers = Array.from(new Set(// use Set to remove duplicates
|
382 |
Widget
|
383 |
.queryAllWidgetsContainers(StopWidgetClassName) // widgets by classNames from editor's plugin;
|
384 |
.concat(options.stop_elements_selectors ?
|
385 |
+
queryElements(splitSelectors(options.stop_elements_selectors)) // widgets from option's custom selectors
|
386 |
: [])));
|
387 |
var _a = findIntersections(fixedWidgetsContainers, stopWidgetsContainers), stopWidgetsUniqContainers = _a[0], duplicates = _a[1];
|
388 |
duplicates.forEach(function (w) {
|
389 |
+
console.error("The Widget is detected as fixed block and stop block!\n".concat(w.innerHTML));
|
390 |
});
|
391 |
fixedWidgetsContainers.forEach(function (c) { c.classList.add(FixedWidgetClassName); });
|
392 |
stopWidgetsUniqContainers.forEach(function (c) { c.classList.add(StopWidgetClassName); });
|
418 |
}
|
419 |
Sidebar.prototype.mount = function () {
|
420 |
var _this = this;
|
421 |
+
this.stop_widgets.forEach(function (widget, i) { return widget.mount({}, 0, 0); });
|
422 |
this.min_top_offset = this.stop_widgets.length !== 0 ? Math.min.apply(Math, this.stop_widgets.map(this.use_sticky_position ?
|
423 |
function (w) { return w.top_offset; } :
|
424 |
function (w) { return w.root_offset; })) :
|
440 |
var queryElements = function (selectors) {
|
441 |
if (selectors === void 0) { selectors = []; }
|
442 |
return Array.from((selectors)
|
443 |
+
.map(function (selector) { return Array.from(document.querySelectorAll(selector)); }))
|
444 |
+
.reduce(function (all, elements) { return all.concat(elements); }, [])
|
445 |
.filter(function (e) { return e instanceof HTMLElement; });
|
446 |
};
|
447 |
|
js/frontend.min.js
CHANGED
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
13 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
14 |
PERFORMANCE OF THIS SOFTWARE.
|
15 |
-
***************************************************************************** */var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t},__assign.apply(this,arguments)},StopWidgetClassName="FixedWidget__stop_widget",FixedWidgetClassName="FixedWidget__fixed_widget",Widget=function(){function Widget(el){this.el=el,this.top_offset=0,this.root_offset=0,this.need_to_calc_el_offset=function(_){return!1}}return Widget.prototype.render=function(){},Widget.prototype.mount=function(user_margins,layer,_max_top_offset){this.el&&this.el.parentElement&&(this.el.style.zIndex=""+layer,this.top_offset=this.get_total_top_offset(user_margins),this.root_offset=get_root_offset(this.el,document.body))},Widget.prototype.getElement=function(){return this.el},Widget.prototype.toString=function(){var _a;return""+(null===(_a=this.el)||void 0===_a?void 0:_a.innerHTML)},Widget.prototype.get_total_top_offset=function(margins){var next=function(el){return el&&el.previousElementSibling};return get_sibilings_offset(next,this.need_to_calc_el_offset,next(this.el),margins.margin_top)},Widget.queryAllWidgetsContainers=function(className){return[].concat(Array.from(document.querySelectorAll("."+className)),Array.from(document.querySelectorAll("[data-fixed_widget="+className))).map((function(el){el.classList.remove(className),el.removeAttribute("data-fixed_widget");var container=getWidgetContainer(el);return container.classList.remove(FixedWidgetClassName),container.classList.remove(StopWidgetClassName),container}))},Widget.from=function(root,className){var _this=this;return Array.from(root.querySelectorAll("."+className)).filter((function(el){return null!==el})).map((function(e){return new _this(e)}))},Widget}(),getWidgetContainer=function(el){return el.parentElement&&(1===el.parentElement.childElementCount||el.parentElement.classList.toString().includes("wp-block-group")||el.parentElement.classList.toString().includes("wp-block-column")||el.parentElement.classList.contains("widget"))?getWidgetContainer(el.parentElement):el},get_sibilings_offset=function(next,need_to_calc_el_offset,el,offset){if(void 0===offset&&(offset=0),!el)return offset;if(!need_to_calc_el_offset(el))return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset);var _a=getComputedStyle(el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset+el.offsetHeight+parseInt(marginTop||"0")+parseInt(marginBottom||"0"))},get_root_offset=function(el,top_parent,offset){return void 0===offset&&(offset=0),el&&el!==top_parent?offset+get_root_offset(el.offsetParent,top_parent,el.offsetTop):offset},PositionWidget=function(_super){function PositionWidget(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.bottom_offset=0,_this.top_margin=0,_this.max_top_offset=0,_this.bottom_margin=0,_this.user_margins={},_this}return __extends(PositionWidget,_super),PositionWidget.prototype.mount=function(user_margins,layer,max_top_offset){if(_super.prototype.mount.call(this,user_margins,layer,max_top_offset),this.el&&this.el.parentElement){this.user_margins=user_margins;var _a=getComputedStyle(this.el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;this.bottom_margin=parseInt(marginBottom),this.top_margin=parseInt(marginTop),this.bottom_offset=this.get_total_bottom_offset(user_margins),max_top_offset>this.el.offsetTop&&(this.max_top_offset=max_top_offset)}},PositionWidget.prototype.render=function(){if(this.el&&this.el.parentElement){var scrollTop=document.documentElement.scrollTop;this.onScroll(scrollTop)}},PositionWidget.from=function(root){return _super.from.call(this,root,FixedWidgetClassName)},PositionWidget.prototype.onScroll=function(_scrollTop){},PositionWidget.prototype.get_total_bottom_offset=function(margins){var next=function(el){return el&&!el.classList.contains(StopWidgetClassName)?el.nextElementSibling:null};return get_sibilings_offset(next,this.need_to_calc_el_offset,next(this.el),margins.margin_bottom)},PositionWidget}(Widget),FixedWidget=function(_super){function FixedWidget(el){var _this=_super.call(this,el)||this;return _this.is_pinned=!1,_this.relative_top=0,_this.init_style={position:"static",top:"",bottom:"",width:"",height:""},_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(FixedWidget,_super),FixedWidget.prototype.mount=function(margins,layer,max_top_offset){_super.prototype.mount.call(this,margins,layer,max_top_offset),this.el&&(this.relative_top=this.max_top_offset-this.top_offset-this.el.clientHeight-this.bottom_offset-this.bottom_margin-this.top_margin,this.clone(),this.store_style(getComputedStyle(this.el)))},FixedWidget.prototype.clone=function(){var _a,_this=this;this.el&&(this.clone_el=this.el.cloneNode(!1),this.clone_el.getAttributeNames().forEach((function(attr){_this.clone_el.removeAttribute(attr)})),this.clone_el.style.height=this.el.clientHeight+"px",this.clone_el.style.width=this.el.clientWidth+"px",this.clone_el.style.display="none",null===(_a=this.el.parentElement)||void 0===_a||_a.insertBefore(this.clone_el,this.el))},FixedWidget.prototype.store_style=function(style){this.init_style.position=style.position,this.init_style.top=style.top,this.init_style.width=style.width,this.init_style.height=style.top},FixedWidget.prototype.restore_style=function(style){this.is_pinned&&(this.is_pinned=!1,style.position=this.init_style.position,style.top=this.init_style.top,this.clone_el&&(this.clone_el.style.display="none"))},FixedWidget.prototype.onScroll=function(scrollTop){if(this.el){var need_to_fix=scrollTop>this.root_offset-this.top_offset,top=0!==this.max_top_offset&&scrollTop>this.relative_top?this.relative_top-scrollTop+this.top_offset:this.top_offset;need_to_fix?this.fix(top):this.restore_style(this.el.style)}},FixedWidget.prototype.fix=function(top){this.el&&(this.el.style.top=top+"px",this.is_pinned||(this.is_pinned=!0,this.el.style.position="fixed",this.el.style.transition="transform 0.5s",this.el.style.width=this.init_style.width,this.el.style.height=this.init_style.height,this.clone_el&&(this.clone_el.style.display="block")))},FixedWidget.new=function(selector){return new FixedWidget(document.querySelector(selector))},FixedWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},FixedWidget}(PositionWidget),StickyWidget=function(_super){function StickyWidget(el){var _this=_super.call(this,el)||this;return _this.margins=0,_this.borderBox=0,_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(StickyWidget,_super),StickyWidget.prototype.mount=function(margins,layer,max_top_offset){_super.prototype.mount.call(this,margins,layer,max_top_offset),this.el&&this.el.parentElement&&(this.borderBox=this.el.clientHeight+this.top_margin+this.bottom_margin,this.margins=this.el.parentElement.clientHeight-this.borderBox,this.el.style.position="sticky",this.el.style.position="-webkit-sticky",this.el.style.transition="transform 0s",this.el.style.boxSizing="border-box",this.el.style.top=this.top_offset+"px")},StickyWidget.prototype.onScroll=function(){if(this.el&&this.el.parentElement){var bottom_margin=this.max_top_offset?Math.min(this.max_top_offset-this.el.offsetTop-this.borderBox,this.margins-this.el.offsetTop):this.margins-this.el.offsetTop;bottom_margin>this.bottom_offset||(this.el.style.transform="translateY("+(bottom_margin-this.bottom_offset)+"px)")}},StickyWidget.new=function(selector){return new StickyWidget(document.querySelector(selector))},StickyWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},StickyWidget}(PositionWidget),StopWidget=function(_super){function StopWidget(el){var _this=_super.call(this,el)||this;return _this.need_to_calc_el_offset=function(){return!0},_this.el&&_this.el.parentElement?(_this.el.classList.add(StopWidgetClassName),_this):_this}return __extends(StopWidget,_super),StopWidget.new=function(selector){return new StopWidget(document.querySelector(selector))},StopWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(StopWidgetClassName)},StopWidget.from=function(root){return _super.from.call(this,root,StopWidgetClassName)},StopWidget}(Widget),Sidebar=function(){function Sidebar(el,margins,use_sticky_position){this.el=el,this.margins=margins,this.use_sticky_position=use_sticky_position,this.widgets=[],this.stop_widgets=[],this.min_top_offset=0,this.stop_widgets=StopWidget.from(this.el);var WidgetContructor=void 0===use_sticky_position||use_sticky_position?StickyWidget:FixedWidget;this.widgets=WidgetContructor.from(this.el),use_sticky_position&&(this.el.style.position="relative",0===this.stop_widgets.length&&(this.el.style.height="100%"))}return Sidebar.prototype.mount=function(){var _this=this;this.stop_widgets.forEach((function(widget,i){return widget.mount(_this.margins,0,0)})),this.min_top_offset=0!==this.stop_widgets.length?Math.min.apply(Math,this.stop_widgets.map(this.use_sticky_position?function(w){return w.top_offset}:function(w){return w.root_offset})):0,this.widgets.forEach((function(widget,i){return widget.mount(_this.margins,i,_this.min_top_offset)}))},Sidebar.prototype.render=function(){this.widgets.forEach((function(widget){return widget.render()}))},Sidebar.create=function(elements,options){return Array.from(new Set(elements.map((function(widget){return widget.parentElement})))).filter((function(sidebar_el){return null!==sidebar_el})).map((function(sidebar_el){return new Sidebar(sidebar_el,options,void 0===options.use_sticky_position||options.use_sticky_position)}))},Sidebar}(),queryElements=function(selectors){return void 0===selectors&&(selectors=[]),Array.from(selectors.map((function(selector){return document.querySelector(selector)}))).filter((function(e){return e instanceof HTMLElement}))},initPlugin=function(options){void 0===options&&(options=[]),function(options){var arr1,arr2,fixedWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(FixedWidgetClassName).concat(queryElements(options.widgets)))),stopWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(StopWidgetClassName).concat(options.stop_elements_selectors?queryElements(options.stop_elements_selectors.split("/n")):[]))),_a=(arr1=fixedWidgetsContainers,[(arr2=stopWidgetsContainers).filter((function(e){return!arr1.includes(e)})),arr1.filter((function(e){return arr2.includes(e)}))]),stopWidgetsUniqContainers=_a[0];_a[1].forEach((function(w){console.error("The Widget is detected as fixed block and stop block!\n"+w.innerHTML)})),fixedWidgetsContainers.forEach((function(c){c.classList.add(FixedWidgetClassName)})),stopWidgetsUniqContainers.forEach((function(c){c.classList.add(StopWidgetClassName)}));var sidebars=Sidebar.create(fixedWidgetsContainers.concat(stopWidgetsUniqContainers),options);sidebars.forEach((function(sidebar){sidebar.mount()})),document.addEventListener("scroll",(function(){sidebars.forEach((function(sidebar){return sidebar.render()}))}))}(options.reduce((function(prev,cur){return __assign(__assign(__assign({},prev),cur),{widgets:prev.widgets.concat(cur.widgets||[])})}),{widgets:[]}))};function onDocumentLoaded(){var admin_panel=document.querySelector("#wpadminbar"),options=(window.q2w3_sidebar_options||[{}]).map((function(option){return option.margin_top=(option.margin_top||0)+((null==admin_panel?void 0:admin_panel.clientHeight)||0),option}));options.some((function(option){return window.innerWidth<option.screen_max_width||window.innerHeight<option.screen_max_height}))||initPlugin(options)}window.addEventListener("load",onDocumentLoaded),"complete"===document.readyState&&onDocumentLoaded();
|
12 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
13 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
14 |
PERFORMANCE OF THIS SOFTWARE.
|
15 |
+
***************************************************************************** */var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};function __extends(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t},__assign.apply(this,arguments)},StopWidgetClassName="FixedWidget__stop_widget",FixedWidgetClassName="FixedWidget__fixed_widget",Widget=function(){function Widget(el){this.el=el,this.top_offset=0,this.root_offset=0,this.need_to_calc_el_offset=function(_){return!1},this.prevSibling=function(el){return el&&el.previousElementSibling}}return Widget.prototype.render=function(){},Widget.prototype.mount=function(user_margins,layer,_max_top_offset){this.el&&this.el.parentElement&&(this.el.style.zIndex="".concat(layer),this.top_offset=this.get_total_top_offset(user_margins),this.root_offset=scrollY+this.el.getBoundingClientRect().y)},Widget.prototype.getElement=function(){return this.el},Widget.prototype.toString=function(){var _a;return"".concat(null===(_a=this.el)||void 0===_a?void 0:_a.innerHTML)},Widget.prototype.get_total_top_offset=function(margins){return get_sibilings_offset(this.prevSibling,this.need_to_calc_el_offset,this.prevSibling(this.el),margins.margin_top)},Widget.queryAllWidgetsContainers=function(className){return[].concat(Array.from(document.querySelectorAll(".".concat(className))),Array.from(document.querySelectorAll("[data-fixed_widget=".concat(className)))).map((function(el){el.classList.remove(className),el.removeAttribute("data-fixed_widget");var container=getWidgetContainer(el);return container.classList.remove(FixedWidgetClassName),container.classList.remove(StopWidgetClassName),container}))},Widget.from=function(root,className){var _this=this;return Array.from(root.querySelectorAll(".".concat(className))).filter((function(el){return null!==el})).map((function(e){return new _this(e)}))},Widget}(),getWidgetContainer=function(el){return el.parentElement&&(1===el.parentElement.childElementCount||el.parentElement.classList.toString().includes("wp-block-group")||el.parentElement.classList.toString().includes("wp-block-column")||el.parentElement.classList.contains("widget"))?getWidgetContainer(el.parentElement):el},get_sibilings_offset=function(next,need_to_calc_el_offset,el,offset){if(void 0===offset&&(offset=0),!el)return offset;if(!need_to_calc_el_offset(el))return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset);var _a=getComputedStyle(el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;return get_sibilings_offset(next,need_to_calc_el_offset,next(el),offset+el.offsetHeight+parseInt(marginTop||"0")+parseInt(marginBottom||"0"))},PositionWidget=function(_super){function PositionWidget(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.bottom_offset=0,_this.top_margin=0,_this.borderBox=0,_this.max_top_offset=0,_this.bottom_margin=0,_this.user_margins={},_this.prevSibling=function(el){return el&&!el.classList.contains(StopWidgetClassName)&&el.previousElementSibling||null},_this}return __extends(PositionWidget,_super),PositionWidget.prototype.mount=function(user_margins,layer,max_top_offset){if(_super.prototype.mount.call(this,user_margins,layer),this.el&&this.el.parentElement){this.user_margins=user_margins;var _a=getComputedStyle(this.el),marginTop=_a.marginTop,marginBottom=_a.marginBottom;this.bottom_margin=parseInt(marginBottom),this.top_margin=parseInt(marginTop),this.bottom_offset=this.get_total_bottom_offset(user_margins),this.max_top_offset=max_top_offset,this.borderBox=this.el.clientHeight+this.top_margin+this.bottom_margin}},PositionWidget.prototype.render=function(){if(this.el&&this.el.parentElement){var scrollTop=scrollY;this.onScroll(scrollTop)}},PositionWidget.from=function(root){return _super.from.call(this,root,FixedWidgetClassName)},PositionWidget.prototype.onScroll=function(_scrollTop){},PositionWidget.prototype.get_total_bottom_offset=function(margins){var next=function(el){return el&&!el.classList.contains(StopWidgetClassName)?el.nextElementSibling:null};return get_sibilings_offset(next,this.need_to_calc_el_offset,next(this.el),margins.margin_bottom)},PositionWidget}(Widget),FixedWidget=function(_super){function FixedWidget(el){var _this=_super.call(this,el)||this;return _this.is_pinned=!1,_this.relative_top=0,_this.init_style={position:"static",marginTop:"",marginBottom:"",width:"",height:""},_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(FixedWidget,_super),FixedWidget.prototype.mount=function(margins,layer,max_top_offset){_super.prototype.mount.call(this,margins,layer,max_top_offset),this.el&&(max_top_offset<this.root_offset&&(this.max_top_offset=0),this.relative_top=this.max_top_offset-this.top_offset-this.borderBox-this.bottom_offset,this.store_style(getComputedStyle(this.el)),this.clone())},FixedWidget.prototype.clone=function(){var _this=this;if(this.el&&this.el.parentElement){for(var prop in this.clone_el=this.el.cloneNode(!1),this.clone_el.getAttributeNames().forEach((function(attr){_this.clone_el.removeAttribute(attr)})),this.init_style)this.clone_el.style[prop]=this.init_style[prop];this.clone_el.style.display="none",this.el.parentElement.insertBefore(this.clone_el,this.el)}},FixedWidget.prototype.store_style=function(style){this.init_style.position=style.position,this.init_style.marginTop=style.marginTop,this.init_style.marginBottom=style.marginBottom,this.init_style.width=style.width,this.init_style.height=style.height},FixedWidget.prototype.restore_style=function(style){this.is_pinned&&(this.is_pinned=!1,style.position=this.init_style.position,this.clone_el&&(this.clone_el.style.display="none"))},FixedWidget.prototype.onScroll=function(scrollTop){if(this.el){var need_to_fix=scrollTop>this.root_offset-this.top_offset,top=0!==this.max_top_offset&&scrollTop>this.relative_top?this.relative_top-scrollTop+this.top_offset:this.top_offset;need_to_fix?this.fix(top):this.restore_style(this.el.style)}},FixedWidget.prototype.fix=function(top){this.el&&(this.el.style.top="".concat(top,"px"),this.is_pinned||(this.is_pinned=!0,this.el.style.position="fixed",this.el.style.transition="transform 0.5s",this.el.style.width=this.init_style.width,this.el.style.height=this.init_style.height,this.clone_el&&(this.clone_el.style.display="block")))},FixedWidget.new=function(selector){return new FixedWidget(document.querySelector(selector))},FixedWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},FixedWidget}(PositionWidget),StickyWidget=function(_super){function StickyWidget(el){var _this=_super.call(this,el)||this;return _this.margins=0,_this.need_to_calc_el_offset=function(el){return el.classList.contains(FixedWidgetClassName)},_this.el&&_this.el.parentElement?(_this.el.classList.add(FixedWidgetClassName),_this):_this}return __extends(StickyWidget,_super),StickyWidget.prototype.mount=function(margins,layer,max_top_offset){_super.prototype.mount.call(this,margins,layer,max_top_offset),this.el&&this.el.parentElement&&(max_top_offset<this.el.offsetTop&&(this.max_top_offset=0),this.margins=this.el.parentElement.clientHeight-this.borderBox,this.el.style.position="sticky",this.el.style.position="-webkit-sticky",this.el.style.transition="transform 0s",this.el.style.boxSizing="border-box",this.el.style.top="".concat(this.top_offset,"px"))},StickyWidget.prototype.onScroll=function(){if(this.el&&this.el.parentElement){var bottom_margin=this.max_top_offset?Math.min(this.max_top_offset-this.el.offsetTop-this.borderBox,this.margins-this.el.offsetTop):this.margins-this.el.offsetTop;bottom_margin>=this.bottom_offset?this.el.style.transform="translateY(0px)":this.el.style.transform="translateY(".concat(bottom_margin-this.bottom_offset,"px)")}},StickyWidget.new=function(selector){return new StickyWidget(document.querySelector(selector))},StickyWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(FixedWidgetClassName)},StickyWidget}(PositionWidget),StopWidget=function(_super){function StopWidget(el){var _this=_super.call(this,el)||this;return _this.need_to_calc_el_offset=function(){return!0},_this.el&&_this.el.parentElement?(_this.el.classList.add(StopWidgetClassName),_this):_this}return __extends(StopWidget,_super),StopWidget.new=function(selector){return new StopWidget(document.querySelector(selector))},StopWidget.is=function(selector){var el=document.querySelector(selector);return!!el&&el.classList.contains(StopWidgetClassName)},StopWidget.from=function(root){return _super.from.call(this,root,StopWidgetClassName)},StopWidget}(Widget),Sidebar=function(){function Sidebar(el,margins,use_sticky_position){this.el=el,this.margins=margins,this.use_sticky_position=use_sticky_position,this.widgets=[],this.stop_widgets=[],this.min_top_offset=0,this.stop_widgets=StopWidget.from(this.el);var WidgetContructor=void 0===use_sticky_position||use_sticky_position?StickyWidget:FixedWidget;this.widgets=WidgetContructor.from(this.el),use_sticky_position&&(this.el.style.position="relative",0===this.stop_widgets.length&&(this.el.style.minHeight="100%"))}return Sidebar.prototype.mount=function(){var _this=this;this.stop_widgets.forEach((function(widget,i){return widget.mount({},0,0)})),this.min_top_offset=0!==this.stop_widgets.length?Math.min.apply(Math,this.stop_widgets.map(this.use_sticky_position?function(w){return w.top_offset}:function(w){return w.root_offset})):0,this.widgets.forEach((function(widget,i){return widget.mount(_this.margins,i,_this.min_top_offset)}))},Sidebar.prototype.render=function(){this.widgets.forEach((function(widget){return widget.render()}))},Sidebar.create=function(elements,options){return Array.from(new Set(elements.map((function(widget){return widget.parentElement})))).filter((function(sidebar_el){return null!==sidebar_el})).map((function(sidebar_el){return new Sidebar(sidebar_el,options,void 0===options.use_sticky_position||options.use_sticky_position)}))},Sidebar}(),queryElements=function(selectors){return void 0===selectors&&(selectors=[]),Array.from(selectors.map((function(selector){return Array.from(document.querySelectorAll(selector))}))).reduce((function(all,elements){return all.concat(elements)}),[]).filter((function(e){return e instanceof HTMLElement}))},initPlugin=function(options){void 0===options&&(options=[]),function(options){var arr1,arr2,fixedWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(FixedWidgetClassName).concat(queryElements(options.widgets)))),stopWidgetsContainers=Array.from(new Set(Widget.queryAllWidgetsContainers(StopWidgetClassName).concat(options.stop_elements_selectors?queryElements(options.stop_elements_selectors.replace(/[\r\n]|[\r]/gi,"\n").split("\n").map((function(s){return s.trim()})).filter((function(s){return""!==s}))):[]))),_a=(arr1=fixedWidgetsContainers,[(arr2=stopWidgetsContainers).filter((function(e){return!arr1.includes(e)})),arr1.filter((function(e){return arr2.includes(e)}))]),stopWidgetsUniqContainers=_a[0];_a[1].forEach((function(w){console.error("The Widget is detected as fixed block and stop block!\n".concat(w.innerHTML))})),fixedWidgetsContainers.forEach((function(c){c.classList.add(FixedWidgetClassName)})),stopWidgetsUniqContainers.forEach((function(c){c.classList.add(StopWidgetClassName)}));var sidebars=Sidebar.create(fixedWidgetsContainers.concat(stopWidgetsUniqContainers),options);sidebars.forEach((function(sidebar){sidebar.mount()})),document.addEventListener("scroll",(function(){sidebars.forEach((function(sidebar){return sidebar.render()}))}))}(options.reduce((function(prev,cur){return __assign(__assign(__assign({},prev),cur),{widgets:prev.widgets.concat(cur.widgets||[])})}),{widgets:[]}))};function onDocumentLoaded(){var admin_panel=document.querySelector("#wpadminbar"),options=(window.q2w3_sidebar_options||[{}]).map((function(option){return option.margin_top=(option.margin_top||0)+((null==admin_panel?void 0:admin_panel.clientHeight)||0),option}));options.some((function(option){return window.innerWidth<option.screen_max_width||window.innerHeight<option.screen_max_height}))||initPlugin(options)}window.addEventListener("load",onDocumentLoaded),"complete"===document.readyState&&onDocumentLoaded();
|
q2w3-fixed-widget.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://wpadvancedads.com/fixed-widget-wordpress/
|
|
5 |
Description: Use the fixed widget plugin to create sticky widgets that stay in the visible screen area when the page is scrolled up or down and boost your conversions.
|
6 |
Text Domain: q2w3-fixed-widget
|
7 |
Author: Thomas Maier, Max Bond
|
8 |
-
Version: 6.0.0
|
9 |
Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
|
10 |
*/
|
11 |
|
@@ -23,7 +23,7 @@ class q2w3_fixed_widget {
|
|
23 |
|
24 |
const ID = 'q2w3_fixed_widget';
|
25 |
|
26 |
-
const VERSION = '6.0.0
|
27 |
|
28 |
protected static $sidebars_widgets;
|
29 |
|
5 |
Description: Use the fixed widget plugin to create sticky widgets that stay in the visible screen area when the page is scrolled up or down and boost your conversions.
|
6 |
Text Domain: q2w3-fixed-widget
|
7 |
Author: Thomas Maier, Max Bond
|
8 |
+
Version: 6.0.0
|
9 |
Author URI: https://wpadvancedads.com/fixed-widget-wordpress/
|
10 |
*/
|
11 |
|
23 |
|
24 |
const ID = 'q2w3_fixed_widget';
|
25 |
|
26 |
+
const VERSION = '6.0.0';
|
27 |
|
28 |
protected static $sidebars_widgets;
|
29 |
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: webzunft, max-bond, advancedads
|
3 |
Tags: fixed widget, sticky widget, sidebar, ads, widget
|
4 |
Requires at least: 5.0
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag:
|
7 |
|
8 |
More attention and a higher ad performance with fixed sticky widgets.
|
9 |
|
@@ -17,13 +17,18 @@ That's why this option is worthwhile for ads or other elements that visitors sho
|
|
17 |
|
18 |
* [Manual and demo](https://wpadvancedads.com/fixed-widget-wordpress/)
|
19 |
|
20 |
-
=
|
21 |
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-widget/) if you discover any issues.
|
29 |
|
@@ -31,11 +36,12 @@ Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-wi
|
|
31 |
|
32 |
All the features are free.
|
33 |
|
34 |
-
* **Sticky Widgets** Use the Fixed Widget option on any widget in
|
35 |
* **Sticky Elements** Choose any element on your site and make it sticky
|
36 |
* **Margin Top** allows you to stop sticky elements to cover sticky menu bars
|
37 |
* **Margin Bottom** pushes sticky elements up before they reach a certain distance towards the bottom window
|
38 |
* **Stop Elements** push sticky elements up when they are scrolling into view
|
|
|
39 |
* **Minimum Screen Width** and **Minimum Screen Height** allow you to disable sticky behavior on small screens
|
40 |
|
41 |
= Compatibility =
|
@@ -43,11 +49,7 @@ All the features are free.
|
|
43 |
Theme requirements:
|
44 |
|
45 |
* `wp_head()` and `wp_footer()` functions in `header.php` and `footer.php` files
|
46 |
-
* Sticky widgets must have an ID attribute
|
47 |
* JavaScript errors could break sticky widgets
|
48 |
-
* jQuery is no longer required
|
49 |
-
|
50 |
-
In some themes, fixed widgets „jump“ during scrolling, etc. Some CSS changes at your theme will be required in this case.
|
51 |
|
52 |
== Installation ==
|
53 |
|
@@ -56,7 +58,6 @@ In some themes, fixed widgets „jump“ during scrolling, etc. Some CSS changes
|
|
56 |
3. Go to Appearance -> Widgets, enable the "Fixed Widget" option on any active widget
|
57 |
4. Fine tune plugin parameters on Appearance -> Fixed Widget Options page
|
58 |
|
59 |
-
|
60 |
== Frequently Asked Questions ==
|
61 |
|
62 |
= Why is the Fixed Widget plugin not working? =
|
@@ -72,14 +73,6 @@ There are several reasons:
|
|
72 |
|
73 |
Yes, it is possible to fix more than one widget even if they are located in different sidebars.
|
74 |
|
75 |
-
= Why is the plugin not working in Chrome (and other Webkit based browsers)? =
|
76 |
-
|
77 |
-
Check your CSS files for these two instructions:
|
78 |
-
`-webkit-backface-visibility:hidden;
|
79 |
-
-webkit-transform: translate3d(0,0,0);`
|
80 |
-
|
81 |
-
If found, disable them and see the result.
|
82 |
-
|
83 |
= How to prevent overlapping with the footer? =
|
84 |
|
85 |
Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define the top and bottom margins. Set bottom margin value >= footer height. Check the result, please.
|
@@ -91,16 +84,19 @@ Use the options `Minimum Screen Width` and `Minimum Screen Height` to disable st
|
|
91 |
|
92 |
== Screenshots ==
|
93 |
|
94 |
-
1.
|
|
|
|
|
|
|
95 |
|
96 |
== Changelog ==
|
97 |
|
98 |
-
= 6.0.0
|
99 |
|
100 |
Version 6.0.0 is a full rewrite of the frontend script. It fixes many edge cases like jumping, reloading, or resizing widgets.
|
101 |
The rewrite also resolves bad Cumulative Layout Shifts.
|
102 |
|
103 |
-
Most changes are available when you
|
104 |
|
105 |
Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-widget/) if you discover any issues.
|
106 |
|
@@ -108,6 +104,8 @@ Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-wi
|
|
108 |
- the frontend script does not need jQuery anymore
|
109 |
- removed unneeded options that previously helped resolving edge cases
|
110 |
- "Stop Elements" and "Custom Fixed Elements" now accept any selector, including IDs, Class, and Type selectors.
|
|
|
|
|
111 |
- improved option descriptions on the admin page
|
112 |
- improved behavior for elements higher than the screen – they first stick at the top and scroll to the bottom later
|
113 |
- removed duplicating widget code
|
@@ -266,4 +264,4 @@ Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-wi
|
|
266 |
|
267 |
= 6.0.0 =
|
268 |
|
269 |
-
Major rewrite of the frontend JavaScript with fixes for a lot of edge cases. Does not need jQuery anymore. See more details in the Changelog.
|
2 |
Contributors: webzunft, max-bond, advancedads
|
3 |
Tags: fixed widget, sticky widget, sidebar, ads, widget
|
4 |
Requires at least: 5.0
|
5 |
+
Tested up to: 5.9
|
6 |
+
Stable tag: 6.0.0
|
7 |
|
8 |
More attention and a higher ad performance with fixed sticky widgets.
|
9 |
|
17 |
|
18 |
* [Manual and demo](https://wpadvancedads.com/fixed-widget-wordpress/)
|
19 |
|
20 |
+
= Changes in version 6.0.0 =
|
21 |
|
22 |
+
Version 6.0.0 is a full rewrite of the frontend script. It fixes many edge cases like jumping, reloading, or resizing widgets.
|
23 |
+
The rewrite also resolves bad Cumulative Layout Shifts.
|
24 |
|
25 |
+
Enable "Test new version" under Appearance > Fixed Widget Options.
|
26 |
|
27 |
+
- the frontend script does not need jQuery anymore
|
28 |
+
- removed unneeded options that previously helped resolving edge cases
|
29 |
+
- "Stop Elements" and "Custom Fixed Elements" now accept any selector, including IDs, Class, and Type selectors.
|
30 |
+
- works with the widget block editor introduced in WordPress 5.8
|
31 |
+
- added "stop" option to widget blocks
|
32 |
|
33 |
Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-widget/) if you discover any issues.
|
34 |
|
36 |
|
37 |
All the features are free.
|
38 |
|
39 |
+
* **Sticky Widgets** Use the Fixed Widget option on any widget and blocks in the sidebar
|
40 |
* **Sticky Elements** Choose any element on your site and make it sticky
|
41 |
* **Margin Top** allows you to stop sticky elements to cover sticky menu bars
|
42 |
* **Margin Bottom** pushes sticky elements up before they reach a certain distance towards the bottom window
|
43 |
* **Stop Elements** push sticky elements up when they are scrolling into view
|
44 |
+
* **Stop Blocks** defines blocks in your sidebar that push fixed blocks out of the page
|
45 |
* **Minimum Screen Width** and **Minimum Screen Height** allow you to disable sticky behavior on small screens
|
46 |
|
47 |
= Compatibility =
|
49 |
Theme requirements:
|
50 |
|
51 |
* `wp_head()` and `wp_footer()` functions in `header.php` and `footer.php` files
|
|
|
52 |
* JavaScript errors could break sticky widgets
|
|
|
|
|
|
|
53 |
|
54 |
== Installation ==
|
55 |
|
58 |
3. Go to Appearance -> Widgets, enable the "Fixed Widget" option on any active widget
|
59 |
4. Fine tune plugin parameters on Appearance -> Fixed Widget Options page
|
60 |
|
|
|
61 |
== Frequently Asked Questions ==
|
62 |
|
63 |
= Why is the Fixed Widget plugin not working? =
|
73 |
|
74 |
Yes, it is possible to fix more than one widget even if they are located in different sidebars.
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
= How to prevent overlapping with the footer? =
|
77 |
|
78 |
Go to WP admin area, Appearance -> Fixed Widget Options. Here you can define the top and bottom margins. Set bottom margin value >= footer height. Check the result, please.
|
84 |
|
85 |
== Screenshots ==
|
86 |
|
87 |
+
1. A fixed widget and a stop widget in action
|
88 |
+
2. Fixed Widget plugin options
|
89 |
+
3. Fixed Widget options for blocks in the widget editor
|
90 |
+
3. Fixed Widget option for legacy widgets
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 6.0.0 =
|
95 |
|
96 |
Version 6.0.0 is a full rewrite of the frontend script. It fixes many edge cases like jumping, reloading, or resizing widgets.
|
97 |
The rewrite also resolves bad Cumulative Layout Shifts.
|
98 |
|
99 |
+
Most changes are available when you enable "Test new version" under Appearance > Fixed Widget Options.
|
100 |
|
101 |
Please test and [let us know](https://wordpress.org/support/plugin/q2w3-fixed-widget/) if you discover any issues.
|
102 |
|
104 |
- the frontend script does not need jQuery anymore
|
105 |
- removed unneeded options that previously helped resolving edge cases
|
106 |
- "Stop Elements" and "Custom Fixed Elements" now accept any selector, including IDs, Class, and Type selectors.
|
107 |
+
- fixed blocks in sidebars as introduced in WordPress 5.8
|
108 |
+
- define stop blocks in sidebars that move up fixed blocks on scrolling
|
109 |
- improved option descriptions on the admin page
|
110 |
- improved behavior for elements higher than the screen – they first stick at the top and scroll to the bottom later
|
111 |
- removed duplicating widget code
|
264 |
|
265 |
= 6.0.0 =
|
266 |
|
267 |
+
Major rewrite of the frontend JavaScript with fixes for a lot of edge cases. Does not need jQuery anymore. See more details in the Changelog.
|