PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / assets / js / responsive-bar.js

responsive-bar.js in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at assets/js/responsive-bar.js

437 lines 14.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(_wordpress_i18n) {
2
3 //#region \0rolldown/runtime.js
4 var __defProp = Object.defineProperty;
5 var __name = (target, value) => __defProp(target, "name", {
6 value,
7 configurable: true
8 });
9
10 //#endregion
11
12 //#region node_modules/@babel/runtime/helpers/esm/classCallCheck.js
13 function _classCallCheck(a, n) {
14 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
15 }
16
17 //#endregion
18 //#region node_modules/@babel/runtime/helpers/esm/typeof.js
19 function _typeof(o) {
20 "@babel/helpers - typeof";
21 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
22 return typeof o;
23 } : function(o) {
24 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
25 }, _typeof(o);
26 }
27
28 //#endregion
29 //#region node_modules/@babel/runtime/helpers/esm/toPrimitive.js
30 function toPrimitive(t, r) {
31 if ("object" != _typeof(t) || !t) return t;
32 var e = t[Symbol.toPrimitive];
33 if (void 0 !== e) {
34 var i = e.call(t, r || "default");
35 if ("object" != _typeof(i)) return i;
36 throw new TypeError("@@toPrimitive must return a primitive value.");
37 }
38 return ("string" === r ? String : Number)(t);
39 }
40
41 //#endregion
42 //#region node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
43 function toPropertyKey(t) {
44 var i = toPrimitive(t, "string");
45 return "symbol" == _typeof(i) ? i : i + "";
46 }
47
48 //#endregion
49 //#region node_modules/@babel/runtime/helpers/esm/createClass.js
50 function _defineProperties(e, r) {
51 for (var t = 0; t < r.length; t++) {
52 var o = r[t];
53 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
54 }
55 }
56 function _createClass(e, r, t) {
57 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
58 }
59
60 //#endregion
61 //#region node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
62 function _assertThisInitialized(e) {
63 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
64 return e;
65 }
66
67 //#endregion
68 //#region node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
69 function _possibleConstructorReturn(t, e) {
70 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
71 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
72 return _assertThisInitialized(t);
73 }
74
75 //#endregion
76 //#region node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
77 function _getPrototypeOf(t) {
78 return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
79 return t.__proto__ || Object.getPrototypeOf(t);
80 }, _getPrototypeOf(t);
81 }
82
83 //#endregion
84 //#region node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
85 function _setPrototypeOf(t, e) {
86 return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
87 return t.__proto__ = e, t;
88 }, _setPrototypeOf(t, e);
89 }
90
91 //#endregion
92 //#region node_modules/@babel/runtime/helpers/esm/inherits.js
93 function _inherits(t, e) {
94 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
95 t.prototype = Object.create(e && e.prototype, { constructor: {
96 value: t,
97 writable: !0,
98 configurable: !0
99 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e);
100 }
101
102 //#endregion
103 //#region assets/dev/js/editor/regions/responsive-bar/view.js
104 function _callSuper$1(t, o, e) {
105 return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
106 }
107 __name(_callSuper$1, "_callSuper");
108 function _isNativeReflectConstruct$1() {
109 try {
110 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
111 } catch (t) {}
112 return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() {
113 return !!t;
114 })();
115 }
116 __name(_isNativeReflectConstruct$1, "_isNativeReflectConstruct");
117 var View = /*#__PURE__*/ function(_Marionette$ItemView) {
118 function View() {
119 _classCallCheck(this, View);
120 return _callSuper$1(this, View, arguments);
121 }
122 _inherits(View, _Marionette$ItemView);
123 return _createClass(View, [
124 {
125 key: "getTemplate",
126 value: function getTemplate() {
127 return "#tmpl-elementor-templates-responsive-bar";
128 }
129 },
130 {
131 key: "id",
132 value: function id() {
133 return "e-responsive-bar";
134 }
135 },
136 {
137 key: "ui",
138 value: function ui() {
139 var prefix = "#" + this.id();
140 return {
141 switcherInput: ".e-responsive-bar-switcher__option input",
142 switcherLabel: ".e-responsive-bar-switcher__option",
143 switcher: prefix + "-switcher",
144 sizeInputWidth: prefix + "__input-width",
145 sizeInputHeight: prefix + "__input-height",
146 scaleValue: prefix + "-scale__value",
147 scalePlusButton: prefix + "-scale__plus",
148 scaleMinusButton: prefix + "-scale__minus",
149 scaleResetButton: prefix + "-scale__reset",
150 closeButton: prefix + "__close-button",
151 breakpointSettingsButton: prefix + "__settings-button"
152 };
153 }
154 },
155 {
156 key: "events",
157 value: function events() {
158 return {
159 "change @ui.switcherInput": "onBreakpointSelected",
160 "input @ui.sizeInputWidth": "onSizeInputChange",
161 "input @ui.sizeInputHeight": "onSizeInputChange",
162 "click @ui.scalePlusButton": "onScalePlusButtonClick",
163 "click @ui.scaleMinusButton": "onScaleMinusButtonClick",
164 "click @ui.scaleResetButton": "onScaleResetButtonClick",
165 "click @ui.closeButton": "onCloseButtonClick",
166 "click @ui.breakpointSettingsButton": "onBreakpointSettingsOpen"
167 };
168 }
169 },
170 {
171 key: "initialize",
172 value: function initialize() {
173 this.listenTo(elementor.channels.deviceMode, "change", this.onDeviceModeChange);
174 this.listenTo(elementor.channels.responsivePreview, "resize", this.onPreviewResize);
175 this.listenTo(elementor.channels.responsivePreview, "open", this.onPreviewOpen);
176 this.listenTo(elementor.channels.deviceMode, "close", this.resetScale);
177 }
178 },
179 {
180 key: "addTipsyToIconButtons",
181 value: function addTipsyToIconButtons() {
182 this.ui.switcherLabel.add(this.ui.closeButton).add(this.ui.breakpointSettingsButton).tipsy({
183 html: true,
184 gravity: "n",
185 title: function title() {
186 return jQuery(this).data("tooltip");
187 }
188 });
189 }
190 },
191 {
192 key: "restoreLastValidPreviewSize",
193 value: function restoreLastValidPreviewSize() {
194 var lastSize = elementor.channels.responsivePreview.request("size");
195 this.ui.sizeInputWidth.val(lastSize.width).tipsy({
196 html: true,
197 trigger: "manual",
198 gravity: "n",
199 title: function title() {
200 return (0, _wordpress_i18n.__)("The value inserted isn't in the breakpoint boundaries", "elementor");
201 }
202 });
203 var tipsy = this.ui.sizeInputWidth.data("tipsy");
204 tipsy.show();
205 setTimeout(function() {
206 return tipsy.hide();
207 }, 3e3);
208 }
209 },
210 {
211 key: "autoScale",
212 value: function autoScale() {
213 var handlesWidth = 40 * this.scalePercentage / 100;
214 var previewWidth = elementor.$previewWrapper.width() - handlesWidth;
215 var iframeWidth = parseInt(elementor.$preview.css("--e-editor-preview-width"));
216 if (iframeWidth * this.scalePercentage / 100 > previewWidth) {
217 var scalePercentage = previewWidth / iframeWidth * 100;
218 this.setScalePercentage(scalePercentage);
219 } else this.setScalePercentage();
220 this.scalePreview();
221 }
222 },
223 {
224 key: "scalePreview",
225 value: function scalePreview() {
226 var scale = this.scalePercentage / 100;
227 elementor.$previewWrapper.css("--e-preview-scale", scale);
228 }
229 },
230 {
231 key: "resetScale",
232 value: function resetScale() {
233 this.setScalePercentage();
234 this.scalePreview();
235 }
236 },
237 {
238 key: "setScalePercentage",
239 value: function setScalePercentage() {
240 var scalePercentage = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 100;
241 this.scalePercentage = scalePercentage;
242 this.ui.scaleValue.text(parseInt(this.scalePercentage));
243 }
244 },
245 {
246 key: "onRender",
247 value: function onRender() {
248 this.addTipsyToIconButtons();
249 this.setScalePercentage();
250 }
251 },
252 {
253 key: "onDeviceModeChange",
254 value: function onDeviceModeChange() {
255 var currentDeviceMode = elementor.channels.deviceMode.request("currentMode");
256 var $currentDeviceSwitcherInput = this.ui.switcherInput.filter("[value=" + currentDeviceMode + "]");
257 this.setWidthHeightInputsEditableState();
258 this.ui.switcherLabel.attr("aria-selected", false);
259 $currentDeviceSwitcherInput.closest("label").attr("aria-selected", true);
260 if (!$currentDeviceSwitcherInput.prop("checked")) $currentDeviceSwitcherInput.prop("checked", true);
261 }
262 },
263 {
264 key: "onBreakpointSelected",
265 value: function onBreakpointSelected(e) {
266 var selectedDeviceMode = e.target.value;
267 elementor.changeDeviceMode(selectedDeviceMode, false);
268 this.autoScale();
269 }
270 },
271 {
272 key: "onBreakpointSettingsOpen",
273 value: function onBreakpointSettingsOpen() {
274 if (elementorCommon.elements.$body.hasClass("elementor-editor-preview")) elementor.exitPreviewMode();
275 if ("panel/global/menu" === elementor.documents.currentDocument.config.panel.default_route) {
276 $e.run("panel/global/close");
277 return;
278 }
279 $e.run("editor/documents/switch", {
280 id: elementor.config.kit_id,
281 mode: "autosave"
282 }).then(function() {
283 return $e.route("panel/global/settings-layout");
284 }).then(function() {
285 return jQuery(".elementor-control-section_breakpoints").trigger("click");
286 });
287 }
288 },
289 {
290 key: "onPreviewResize",
291 value: function onPreviewResize() {
292 if (this.updatingPreviewSize) return;
293 var size = elementor.channels.responsivePreview.request("size");
294 this.ui.sizeInputWidth.val(Math.round(size.width));
295 this.ui.sizeInputHeight.val(Math.round(size.height));
296 }
297 },
298 {
299 key: "onPreviewOpen",
300 value: function onPreviewOpen() {
301 this.setWidthHeightInputsEditableState();
302 }
303 },
304 {
305 key: "setWidthHeightInputsEditableState",
306 value: function setWidthHeightInputsEditableState() {
307 if ("desktop" === elementor.channels.deviceMode.request("currentMode")) {
308 this.ui.sizeInputWidth.attr("disabled", "disabled");
309 this.ui.sizeInputHeight.attr("disabled", "disabled");
310 } else {
311 this.ui.sizeInputWidth.removeAttr("disabled");
312 this.ui.sizeInputHeight.removeAttr("disabled");
313 }
314 }
315 },
316 {
317 key: "onCloseButtonClick",
318 value: function onCloseButtonClick() {
319 elementor.changeDeviceMode("desktop");
320 elementor.exitDeviceMode();
321 }
322 },
323 {
324 key: "onSizeInputChange",
325 value: function onSizeInputChange() {
326 var _this = this;
327 clearTimeout(this.restorePreviewSizeTimeout);
328 var size = {
329 width: this.ui.sizeInputWidth.val(),
330 height: this.ui.sizeInputHeight.val()
331 };
332 var currentDeviceConstrains = elementor.getCurrentDeviceConstrains();
333 if (size.width < currentDeviceConstrains.minWidth || size.width > currentDeviceConstrains.maxWidth) {
334 this.restorePreviewSizeTimeout = setTimeout(function() {
335 return _this.restoreLastValidPreviewSize();
336 }, 1500);
337 return;
338 }
339 this.updatingPreviewSize = true;
340 setTimeout(function() {
341 return _this.updatingPreviewSize = false;
342 }, 300);
343 elementor.updatePreviewSize(size);
344 this.autoScale();
345 }
346 },
347 {
348 key: "onScalePlusButtonClick",
349 value: function onScalePlusButtonClick() {
350 var scaleUp = 0 === this.scalePercentage % 10 ? this.scalePercentage + 10 : Math.ceil(this.scalePercentage / 10) * 10;
351 if (scaleUp > 200) return;
352 this.setScalePercentage(scaleUp);
353 this.scalePreview();
354 }
355 },
356 {
357 key: "onScaleMinusButtonClick",
358 value: function onScaleMinusButtonClick() {
359 var scaleDown = 0 === this.scalePercentage % 10 ? this.scalePercentage - 10 : Math.floor(this.scalePercentage / 10) * 10;
360 if (scaleDown < 50) return;
361 this.setScalePercentage(scaleDown);
362 this.scalePreview();
363 }
364 },
365 {
366 key: "onScaleResetButtonClick",
367 value: function onScaleResetButtonClick() {
368 this.resetScale();
369 }
370 }
371 ]);
372 }(Marionette.ItemView);
373
374 //#endregion
375 //#region assets/dev/js/editor/regions/responsive-bar/responsive-bar.js
376 function _callSuper(t, o, e) {
377 return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
378 }
379 function _isNativeReflectConstruct() {
380 try {
381 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
382 } catch (t) {}
383 return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
384 return !!t;
385 })();
386 }
387 var _default = /*#__PURE__*/ function(_Marionette$Region) {
388 function _default() {
389 _classCallCheck(this, _default);
390 return _callSuper(this, _default, arguments);
391 }
392 _inherits(_default, _Marionette$Region);
393 return _createClass(_default, [
394 {
395 key: "initialize",
396 value: function initialize() {
397 var _this = this;
398 this.show(new View());
399 elementor.panel.$el.on({
400 resizestart: function resizestart() {
401 return _this.onPanelResizeStart();
402 },
403 resizestop: function resizestop() {
404 return _this.onPanelResizeStop();
405 }
406 });
407 }
408 },
409 {
410 key: "onPanelResizeStart",
411 value: function onPanelResizeStart() {
412 this.$el.addClass("ui-resizable-resizing");
413 }
414 },
415 {
416 key: "onPanelResizeStop",
417 value: function onPanelResizeStop() {
418 this.$el.removeClass("ui-resizable-resizing");
419 }
420 }
421 ]);
422 }(Marionette.Region);
423
424 //#endregion
425 //#region assets/dev/js/editor/regions/responsive-bar/index.js
426 elementor.on("preview:loaded", function(isFirstLoad) {
427 if (!isFirstLoad) return;
428 elementor.addRegions({ responsiveBar: {
429 el: "#elementor-responsive-bar",
430 regionClass: _default
431 } });
432 elementor.trigger("responsiveBar:init");
433 });
434
435 //#endregion
436 })(wp.i18n);
437 //# sourceMappingURL=responsive-bar.js.map