Changeset 171330 for hello-elementor/2.6.0/assets/js/hello-editor.js
- Timestamp:
- 07/10/2022 06:27:45 AM (3 years ago)
- Location:
- hello-elementor/2.6.0
- Files:
-
- 1 edited
- 1 copied
-
. (copied) (copied from hello-elementor/2.5.0)
-
assets/js/hello-editor.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hello-elementor/2.6.0/assets/js/hello-editor.js
r150465 r171330 219 219 220 220 "use strict"; 221 eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"./node_modules/@babel/runtime/helpers/slicedToArray.js\"));\n\nvar _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\"));\n\nvar _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\"));\n\nvar _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\"));\n\nvar _createSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createSuper */ \"./node_modules/@babel/runtime/helpers/createSuper.js\"));\n\nvar ControlsHook = /*#__PURE__*/function (_$e$modules$hookUI$Af) {\n (0, _inherits2[\"default\"])(ControlsHook, _$e$modules$hookUI$Af);\n\n var _super = (0, _createSuper2[\"default\"])(ControlsHook);\n\n function ControlsHook() {\n (0, _classCallCheck2[\"default\"])(this, ControlsHook);\n return _super.apply(this, arguments);\n }\n\n (0, _createClass2[\"default\"])(ControlsHook, [{\n key: \"getCommand\",\n value: function getCommand() {\n // Command to listen.\n return 'document/elements/settings';\n }\n }, {\n key: \"getId\",\n value: function getId() {\n // Unique id for the hook.\n return 'hello-elementor-editor-controls-handler';\n }\n /**\n * Get Hello Theme Controls\n *\n * Returns an object in which the keys are control IDs, and the values are the selectors of the elements that need\n * to be targeted in the apply() method.\n *\n * Example return value:\n * {\n * hello_elementor_show_logo: '.site-header .site-header-logo',\n * hello_elementor_show_menu: '.site-header .site-header-menu',\n * }\n */\n\n }, {\n key: \"getHelloThemeControls\",\n value: function getHelloThemeControls() {\n var _this = this;\n\n return {\n hello_header_logo_display: {\n selector: '.site-header .site-logo, .site-header .site-title',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_logo_display);\n }\n },\n hello_header_menu_display: {\n selector: '.site-header .site-navigation, .site-header .site-navigation-toggle-holder',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_menu_display);\n }\n },\n hello_header_tagline_display: {\n selector: '.site-header .site-description',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_tagline_display);\n }\n },\n hello_header_logo_type: {\n selector: '.site-header .site-branding',\n callback: function callback($element, args) {\n var classPrefix = 'show-',\n inputOptions = args.container.controls.hello_header_logo_type.options,\n inputValue = args.settings.hello_header_logo_type;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_layout: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'header-',\n inputOptions = args.container.controls.hello_header_layout.options,\n inputValue = args.settings.hello_header_layout;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_width: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'header-',\n inputOptions = args.container.controls.hello_header_width.options,\n inputValue = args.settings.hello_header_width;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_menu_layout: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'menu-layout-',\n inputOptions = args.container.controls.hello_header_menu_layout.options,\n inputValue = args.settings.hello_header_menu_layout; // No matter what, close the mobile menu\n\n $element.find('.site-navigation-toggle-holder').removeClass('elementor-active');\n $element.find('.site-navigation-dropdown').removeClass('show');\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_menu_dropdown: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'menu-dropdown-',\n inputOptions = args.container.controls.hello_header_menu_dropdown.options,\n inputValue = args.settings.hello_header_menu_dropdown;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_logo_display: {\n selector: '.site-footer .site-logo, .site-footer .site-title',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_logo_display);\n }\n },\n hello_footer_tagline_display: {\n selector: '.site-footer .site-description',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_tagline_display);\n }\n },\n hello_footer_menu_display: {\n selector: '.site-footer .site-navigation',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_menu_display);\n }\n },\n hello_footer_copyright_display: {\n selector: '.site-footer .copyright',\n callback: function callback($element, args) {\n var $footerContainer = $element.closest('#site-footer'),\n inputValue = args.settings.hello_footer_copyright_display;\n\n _this.toggleShowHideClass($element, inputValue);\n\n $footerContainer.toggleClass('footer-has-copyright', 'yes' === inputValue);\n }\n },\n hello_footer_logo_type: {\n selector: '.site-footer .site-branding',\n callback: function callback($element, args) {\n var classPrefix = 'show-',\n inputOptions = args.container.controls.hello_footer_logo_type.options,\n inputValue = args.settings.hello_footer_logo_type;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_layout: {\n selector: '.site-footer',\n callback: function callback($element, args) {\n var classPrefix = 'footer-',\n inputOptions = args.container.controls.hello_footer_layout.options,\n inputValue = args.settings.hello_footer_layout;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_width: {\n selector: '.site-footer',\n callback: function callback($element, args) {\n var classPrefix = 'footer-',\n inputOptions = args.container.controls.hello_footer_width.options,\n inputValue = args.settings.hello_footer_width;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_copyright_text: {\n selector: '.site-footer .copyright',\n callback: function callback($element, args) {\n var inputValue = args.settings.hello_footer_copyright_text;\n $element.find('p').text(inputValue);\n }\n }\n };\n }\n /**\n * Toggle show and hide classes on containers\n *\n * This will remove the .show and .hide clases from the element, then apply the new class\n *\n * /\n\n }, {\n key: \"toggleShowHideClass\",\n value: function toggleShowHideClass(element, inputValue) {\n element.removeClass('hide').removeClass('show').addClass(inputValue ? 'show' : 'hide');\n }\n /**\n * Toggle layout classes on containers\n *\n * This will cleanly set classes onto which ever container we want to target, removing the old classes and adding the new one\n *\n */\n\n }, {\n key: \"toggleLayoutClass\",\n value: function toggleLayoutClass(element, classPrefix, inputOptions, inputValue) {\n // Loop through the possible classes and remove the one that's not in use\n Object.entries(inputOptions).forEach(function (_ref) {\n var _ref2 = (0, _slicedToArray2[\"default\"])(_ref, 1),\n key = _ref2[0];\n\n element.removeClass(classPrefix + key);\n }); // Append the class which we want to use onto the element\n\n if ('' !== inputValue) {\n element.addClass(classPrefix + inputValue);\n }\n }\n /**\n * Set the conditions under which the hook will run.\n */\n\n }, {\n key: \"getConditions\",\n value: function getConditions(args) {\n var isKit = 'kit' === elementor.documents.getCurrent().config.type,\n changedControls = Object.keys(args.settings),\n isSingleSetting = 1 === changedControls.length; // If the document is not a kit, or there are no changed settings, or there is more than one single changed\n // setting, don't run the hook.\n\n if (!isKit || !args.settings || !isSingleSetting) {\n return false;\n } // If the changed control is in the list of theme controls, return true to run the hook.\n // Otherwise, return false so the hook doesn't run.\n\n\n return !!Object.keys(this.getHelloThemeControls()).includes(changedControls[0]);\n }\n /**\n * The hook logic.\n */\n\n }, {\n key: \"apply\",\n value: function apply(args) {\n var allThemeControls = this.getHelloThemeControls(),\n // Extract the control ID from the passed args\n controlId = Object.keys(args.settings)[0],\n controlConfig = allThemeControls[controlId],\n // Find the element that needs to be targeted by the control.\n $element = elementor.$previewContents.find(controlConfig.selector);\n controlConfig.callback($element, args);\n }\n }]);\n return ControlsHook;\n}($e.modules.hookUI.After);\n\nexports.default = ControlsHook;\n\n//# sourceURL=././assets/dev/js/editor/hooks/ui/controls-hook.js");221 eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.default = void 0;\n\nvar _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ \"./node_modules/@babel/runtime/helpers/slicedToArray.js\"));\n\nvar _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ \"./node_modules/@babel/runtime/helpers/classCallCheck.js\"));\n\nvar _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ \"./node_modules/@babel/runtime/helpers/createClass.js\"));\n\nvar _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ \"./node_modules/@babel/runtime/helpers/inherits.js\"));\n\nvar _createSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createSuper */ \"./node_modules/@babel/runtime/helpers/createSuper.js\"));\n\nvar ControlsHook = /*#__PURE__*/function (_$e$modules$hookUI$Af) {\n (0, _inherits2[\"default\"])(ControlsHook, _$e$modules$hookUI$Af);\n\n var _super = (0, _createSuper2[\"default\"])(ControlsHook);\n\n function ControlsHook() {\n (0, _classCallCheck2[\"default\"])(this, ControlsHook);\n return _super.apply(this, arguments);\n }\n\n (0, _createClass2[\"default\"])(ControlsHook, [{\n key: \"getCommand\",\n value: function getCommand() {\n // Command to listen.\n return 'document/elements/settings';\n }\n }, {\n key: \"getId\",\n value: function getId() {\n // Unique id for the hook.\n return 'hello-elementor-editor-controls-handler';\n }\n /**\n * Get Hello Theme Controls\n *\n * Returns an object in which the keys are control IDs, and the values are the selectors of the elements that need\n * to be targeted in the apply() method.\n *\n * Example return value:\n * {\n * hello_elementor_show_logo: '.site-header .site-header-logo',\n * hello_elementor_show_menu: '.site-header .site-header-menu',\n * }\n */\n\n }, {\n key: \"getHelloThemeControls\",\n value: function getHelloThemeControls() {\n var _this = this;\n\n return {\n hello_header_logo_display: {\n selector: '.site-header .site-logo, .site-header .site-title',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_logo_display);\n }\n },\n hello_header_menu_display: {\n selector: '.site-header .site-navigation, .site-header .site-navigation-toggle-holder',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_menu_display);\n }\n },\n hello_header_tagline_display: {\n selector: '.site-header .site-description',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_header_tagline_display);\n }\n },\n hello_header_logo_type: {\n selector: '.site-header .site-branding',\n callback: function callback($element, args) {\n var classPrefix = 'show-',\n inputOptions = args.container.controls.hello_header_logo_type.options,\n inputValue = args.settings.hello_header_logo_type;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_layout: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'header-',\n inputOptions = args.container.controls.hello_header_layout.options,\n inputValue = args.settings.hello_header_layout;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_width: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'header-',\n inputOptions = args.container.controls.hello_header_width.options,\n inputValue = args.settings.hello_header_width;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_menu_layout: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'menu-layout-',\n inputOptions = args.container.controls.hello_header_menu_layout.options,\n inputValue = args.settings.hello_header_menu_layout; // No matter what, close the mobile menu\n\n $element.find('.site-navigation-toggle-holder').removeClass('elementor-active');\n $element.find('.site-navigation-dropdown').removeClass('show');\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_header_menu_dropdown: {\n selector: '.site-header',\n callback: function callback($element, args) {\n var classPrefix = 'menu-dropdown-',\n inputOptions = args.container.controls.hello_header_menu_dropdown.options,\n inputValue = args.settings.hello_header_menu_dropdown;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_logo_display: {\n selector: '.site-footer .site-logo, .site-footer .site-title',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_logo_display);\n }\n },\n hello_footer_tagline_display: {\n selector: '.site-footer .site-description',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_tagline_display);\n }\n },\n hello_footer_menu_display: {\n selector: '.site-footer .site-navigation',\n callback: function callback($element, args) {\n _this.toggleShowHideClass($element, args.settings.hello_footer_menu_display);\n }\n },\n hello_footer_copyright_display: {\n selector: '.site-footer .copyright',\n callback: function callback($element, args) {\n var $footerContainer = $element.closest('#site-footer'),\n inputValue = args.settings.hello_footer_copyright_display;\n\n _this.toggleShowHideClass($element, inputValue);\n\n $footerContainer.toggleClass('footer-has-copyright', 'yes' === inputValue);\n }\n },\n hello_footer_logo_type: {\n selector: '.site-footer .site-branding',\n callback: function callback($element, args) {\n var classPrefix = 'show-',\n inputOptions = args.container.controls.hello_footer_logo_type.options,\n inputValue = args.settings.hello_footer_logo_type;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_layout: {\n selector: '.site-footer',\n callback: function callback($element, args) {\n var classPrefix = 'footer-',\n inputOptions = args.container.controls.hello_footer_layout.options,\n inputValue = args.settings.hello_footer_layout;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_width: {\n selector: '.site-footer',\n callback: function callback($element, args) {\n var classPrefix = 'footer-',\n inputOptions = args.container.controls.hello_footer_width.options,\n inputValue = args.settings.hello_footer_width;\n\n _this.toggleLayoutClass($element, classPrefix, inputOptions, inputValue);\n }\n },\n hello_footer_copyright_text: {\n selector: '.site-footer .copyright',\n callback: function callback($element, args) {\n var inputValue = args.settings.hello_footer_copyright_text;\n $element.find('p').text(inputValue);\n }\n }\n };\n }\n /**\n * Toggle show and hide classes on containers\n *\n * This will remove the .show and .hide clases from the element, then apply the new class\n *\n * @param {jQuery} element\n * @param {string} inputValue\n */\n\n }, {\n key: \"toggleShowHideClass\",\n value: function toggleShowHideClass(element, inputValue) {\n element.removeClass('hide').removeClass('show').addClass(inputValue ? 'show' : 'hide');\n }\n /**\n * Toggle layout classes on containers\n *\n * This will cleanly set classes onto which ever container we want to target, removing the old classes and adding the new one\n *\n * @param {jQuery} element\n * @param {string} classPrefix\n * @param {Object} inputOptions\n * @param {string} inputValue\n *\n */\n\n }, {\n key: \"toggleLayoutClass\",\n value: function toggleLayoutClass(element, classPrefix, inputOptions, inputValue) {\n // Loop through the possible classes and remove the one that's not in use\n Object.entries(inputOptions).forEach(function (_ref) {\n var _ref2 = (0, _slicedToArray2[\"default\"])(_ref, 1),\n key = _ref2[0];\n\n element.removeClass(classPrefix + key);\n }); // Append the class which we want to use onto the element\n\n if ('' !== inputValue) {\n element.addClass(classPrefix + inputValue);\n }\n }\n /**\n * Set the conditions under which the hook will run.\n *\n * @param {Object} args\n */\n\n }, {\n key: \"getConditions\",\n value: function getConditions(args) {\n var isKit = 'kit' === elementor.documents.getCurrent().config.type,\n changedControls = Object.keys(args.settings),\n isSingleSetting = 1 === changedControls.length; // If the document is not a kit, or there are no changed settings, or there is more than one single changed\n // setting, don't run the hook.\n\n if (!isKit || !args.settings || !isSingleSetting) {\n return false;\n } // If the changed control is in the list of theme controls, return true to run the hook.\n // Otherwise, return false so the hook doesn't run.\n\n\n return !!Object.keys(this.getHelloThemeControls()).includes(changedControls[0]);\n }\n /**\n * The hook logic.\n *\n * @param {Object} args\n */\n\n }, {\n key: \"apply\",\n value: function apply(args) {\n var allThemeControls = this.getHelloThemeControls(),\n // Extract the control ID from the passed args\n controlId = Object.keys(args.settings)[0],\n controlConfig = allThemeControls[controlId],\n // Find the element that needs to be targeted by the control.\n $element = elementor.$previewContents.find(controlConfig.selector);\n controlConfig.callback($element, args);\n }\n }]);\n return ControlsHook;\n}($e.modules.hookUI.After);\n\nexports.default = ControlsHook;\n\n//# sourceURL=././assets/dev/js/editor/hooks/ui/controls-hook.js"); 222 222 223 223 /***/ })
Note: See TracChangeset
for help on using the changeset viewer.