| 1 |
(function(e){var t=Object.defineProperty,__name=(e,n)=>t(e,`name`,{value:n,configurable:!0});function _classCallCheck(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function _typeof(e){"@babel/helpers - typeof";return _typeof=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_typeof(e)}function toPrimitive(e,t){if(_typeof(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(_typeof(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function toPropertyKey(e){var t=toPrimitive(e,`string`);return _typeof(t)==`symbol`?t:t+``}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,toPropertyKey(r.key),r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _assertThisInitialized(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function _possibleConstructorReturn(e,t){if(t&&(_typeof(t)==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return _assertThisInitialized(e)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _inherits(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _callSuper$1(e,t,n){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct$1()?Reflect.construct(t,n||[],_getPrototypeOf(e).constructor):t.apply(e,n))}__name(_callSuper$1,`_callSuper`);function _isNativeReflectConstruct$1(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct$1=function _isNativeReflectConstruct(){return!!e})()}__name(_isNativeReflectConstruct$1,`_isNativeReflectConstruct`);var n=function(t){function View(){return _classCallCheck(this,View),_callSuper$1(this,View,arguments)}return _inherits(View,t),_createClass(View,[{key:`getTemplate`,value:function getTemplate(){return`#tmpl-elementor-templates-responsive-bar`}},{key:`id`,value:function id(){return`e-responsive-bar`}},{key:`ui`,value:function ui(){var e=`#`+this.id();return{switcherInput:`.e-responsive-bar-switcher__option input`,switcherLabel:`.e-responsive-bar-switcher__option`,switcher:e+`-switcher`,sizeInputWidth:e+`__input-width`,sizeInputHeight:e+`__input-height`,scaleValue:e+`-scale__value`,scalePlusButton:e+`-scale__plus`,scaleMinusButton:e+`-scale__minus`,scaleResetButton:e+`-scale__reset`,closeButton:e+`__close-button`,breakpointSettingsButton:e+`__settings-button`}}},{key:`events`,value:function events(){return{"change @ui.switcherInput":`onBreakpointSelected`,"input @ui.sizeInputWidth":`onSizeInputChange`,"input @ui.sizeInputHeight":`onSizeInputChange`,"click @ui.scalePlusButton":`onScalePlusButtonClick`,"click @ui.scaleMinusButton":`onScaleMinusButtonClick`,"click @ui.scaleResetButton":`onScaleResetButtonClick`,"click @ui.closeButton":`onCloseButtonClick`,"click @ui.breakpointSettingsButton":`onBreakpointSettingsOpen`}}},{key:`initialize`,value:function initialize(){this.listenTo(elementor.channels.deviceMode,`change`,this.onDeviceModeChange),this.listenTo(elementor.channels.responsivePreview,`resize`,this.onPreviewResize),this.listenTo(elementor.channels.responsivePreview,`open`,this.onPreviewOpen),this.listenTo(elementor.channels.deviceMode,`close`,this.resetScale)}},{key:`addTipsyToIconButtons`,value:function addTipsyToIconButtons(){this.ui.switcherLabel.add(this.ui.closeButton).add(this.ui.breakpointSettingsButton).tipsy({html:!0,gravity:`n`,title:function title(){return jQuery(this).data(`tooltip`)}})}},{key:`restoreLastValidPreviewSize`,value:function restoreLastValidPreviewSize(){var t=elementor.channels.responsivePreview.request(`size`);this.ui.sizeInputWidth.val(t.width).tipsy({html:!0,trigger:`manual`,gravity:`n`,title:function title(){return(0,e.__)(`The value inserted isn't in the breakpoint boundaries`,`elementor`)}});var n=this.ui.sizeInputWidth.data(`tipsy`);n.show(),setTimeout(function(){return n.hide()},3e3)}},{key:`autoScale`,value:function autoScale(){var e=40*this.scalePercentage/100,t=elementor.$previewWrapper.width()-e,n=parseInt(elementor.$preview.css(`--e-editor-preview-width`));if(n*this.scalePercentage/100>t){var r=t/n*100;this.setScalePercentage(r)}else this.setScalePercentage();this.scalePreview()}},{key:`scalePreview`,value:function scalePreview(){var e=this.scalePercentage/100;elementor.$previewWrapper.css(`--e-preview-scale`,e)}},{key:`resetScale`,value:function resetScale(){this.setScalePercentage(),this.scalePreview()}},{key:`setScalePercentage`,value:function setScalePercentage(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;this.scalePercentage=e,this.ui.scaleValue.text(parseInt(this.scalePercentage))}},{key:`onRender`,value:function onRender(){this.addTipsyToIconButtons(),this.setScalePercentage()}},{key:`onDeviceModeChange`,value:function onDeviceModeChange(){var e=elementor.channels.deviceMode.request(`currentMode`),t=this.ui.switcherInput.filter(`[value=`+e+`]`);this.setWidthHeightInputsEditableState(),this.ui.switcherLabel.attr(`aria-selected`,!1),t.closest(`label`).attr(`aria-selected`,!0),t.prop(`checked`)||t.prop(`checked`,!0)}},{key:`onBreakpointSelected`,value:function onBreakpointSelected(e){var t=e.target.value;elementor.changeDeviceMode(t,!1),this.autoScale()}},{key:`onBreakpointSettingsOpen`,value:function onBreakpointSettingsOpen(){if(elementorCommon.elements.$body.hasClass(`elementor-editor-preview`)&&elementor.exitPreviewMode(),elementor.documents.currentDocument.config.panel.default_route===`panel/global/menu`){$e.run(`panel/global/close`);return}$e.run(`editor/documents/switch`,{id:elementor.config.kit_id,mode:`autosave`}).then(function(){return $e.route(`panel/global/settings-layout`)}).then(function(){return jQuery(`.elementor-control-section_breakpoints`).trigger(`click`)})}},{key:`onPreviewResize`,value:function onPreviewResize(){if(!this.updatingPreviewSize){var e=elementor.channels.responsivePreview.request(`size`);this.ui.sizeInputWidth.val(Math.round(e.width)),this.ui.sizeInputHeight.val(Math.round(e.height))}}},{key:`onPreviewOpen`,value:function onPreviewOpen(){this.setWidthHeightInputsEditableState()}},{key:`setWidthHeightInputsEditableState`,value:function setWidthHeightInputsEditableState(){elementor.channels.deviceMode.request(`currentMode`)===`desktop`?(this.ui.sizeInputWidth.attr(`disabled`,`disabled`),this.ui.sizeInputHeight.attr(`disabled`,`disabled`)):(this.ui.sizeInputWidth.removeAttr(`disabled`),this.ui.sizeInputHeight.removeAttr(`disabled`))}},{key:`onCloseButtonClick`,value:function onCloseButtonClick(){elementor.changeDeviceMode(`desktop`),elementor.exitDeviceMode()}},{key:`onSizeInputChange`,value:function onSizeInputChange(){var e=this;clearTimeout(this.restorePreviewSizeTimeout);var t={width:this.ui.sizeInputWidth.val(),height:this.ui.sizeInputHeight.val()},n=elementor.getCurrentDeviceConstrains();if(t.width<n.minWidth||t.width>n.maxWidth){this.restorePreviewSizeTimeout=setTimeout(function(){return e.restoreLastValidPreviewSize()},1500);return}this.updatingPreviewSize=!0,setTimeout(function(){return e.updatingPreviewSize=!1},300),elementor.updatePreviewSize(t),this.autoScale()}},{key:`onScalePlusButtonClick`,value:function onScalePlusButtonClick(){var e=this.scalePercentage%10==0?this.scalePercentage+10:Math.ceil(this.scalePercentage/10)*10;e>200||(this.setScalePercentage(e),this.scalePreview())}},{key:`onScaleMinusButtonClick`,value:function onScaleMinusButtonClick(){var e=this.scalePercentage%10==0?this.scalePercentage-10:Math.floor(this.scalePercentage/10)*10;e<50||(this.setScalePercentage(e),this.scalePreview())}},{key:`onScaleResetButtonClick`,value:function onScaleResetButtonClick(){this.resetScale()}}])}(Marionette.ItemView);function _callSuper(e,t,n){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,n||[],_getPrototypeOf(e).constructor):t.apply(e,n))}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!e})()}var r=function(e){function _default(){return _classCallCheck(this,_default),_callSuper(this,_default,arguments)}return _inherits(_default,e),_createClass(_default,[{key:`initialize`,value:function initialize(){var e=this;this.show(new n),elementor.panel.$el.on({resizestart:function resizestart(){return e.onPanelResizeStart()},resizestop:function resizestop(){return e.onPanelResizeStop()}})}},{key:`onPanelResizeStart`,value:function onPanelResizeStart(){this.$el.addClass(`ui-resizable-resizing`)}},{key:`onPanelResizeStop`,value:function onPanelResizeStop(){this.$el.removeClass(`ui-resizable-resizing`)}}])}(Marionette.Region);elementor.on(`preview:loaded`,function(e){e&&(elementor.addRegions({responsiveBar:{el:`#elementor-responsive-bar`,regionClass:r}}),elementor.trigger(`responsiveBar:init`))})})(wp.i18n); |