(window["webpackJsonp_name_"] = window["webpackJsonp_name_"] || []).push([[47,7],{ /***/ 174: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); exports.getProperty = getProperty; exports.setVideoBg = setVideoBg; var _global = __webpack_require__(52); var _global2 = _interopRequireDefault(_global); var _index = __webpack_require__(69); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* * Navbar Container */ var NavbarBehaviour = function () { function NavbarBehaviour(args) { _classCallCheck(this, NavbarBehaviour); this.defaultTop = 0; this.scrollTop = 0; this.isSticked = false; this._args = Object.assign({}, args); this.setPosition(); setVideoBg(this.wrapper.elem, this.wrapperSettings, 'default', getProperty(this.wrapperSettings, 'default', 'visible')); // setVideoBg(this.content.elem, this.contentSettings, 'default'); // if (this.position === 'bottom') { // this.onScroll = this.onBottomScroll; // } this._onScroll = this.onScroll.bind(this); this.onScroll(); NavbarBehaviour.scrollBox && NavbarBehaviour.scrollBox.addEventListener('scroll', this._onScroll); this._resize(); } _createClass(NavbarBehaviour, [{ key: 'setPosition', value: function setPosition() { var defaultTop = this.wrapper.elem.getBoundingClientRect(); var scrollTop = getProperty(this.wrapperSettings, 'scroll', 'position'); if (typeof scrollTop === 'string') { try { scrollTop = scrollTop.decode().toJSON().top; if (scrollTop && scrollTop['units'] === '%') { console.warn("Use 'px' instead '%'"); } scrollTop = +scrollTop['number']; } catch (err) { scrollTop = ''; } } if (!scrollTop) { scrollTop = 0; } scrollTop = +scrollTop; this.wrapperClone = this.positionType === 'relative' ? this.wrapper.elem.cloneNode() : null; var currentTop = _global2.default.scrollBox && _global2.default.scrollBox instanceof Document && _global2.default.scrollBox.documentElement.scrollTop || _global2.default.scrollBox && _global2.default.scrollBox instanceof HTMLElement && _global2.default.scrollBox.scrollTop || 0; this.defaultTop = defaultTop.top + currentTop - scrollTop; } }, { key: 'onScroll', value: function onScroll(event) { var target = event && event.target || _global2.default.scrollBox; // let scrollTop = (target instanceof Document && target.documentElement.scrollTop) || target.scrollTop || 0; var scrollTop = target.documentElement && target.documentElement.scrollTop || target.scrollTop || 0; if (!this.isSticked && scrollTop + NavbarBehaviour._adminPanelHeight >= this.defaultTop + 1) { this.setScrollState(); } else if (this.isSticked && scrollTop + NavbarBehaviour._adminPanelHeight < this.defaultTop + 1) { this.clearScrollState(); } } }, { key: 'onAsideScroll', value: function onAsideScroll(event) {} // private onBottomScroll(event?) { // const target = (event && event.target) || GlobalVariables.scrollBox; // let scrollTop = (target instanceof Document && target.documentElement.scrollTop) || target.scrollTop || 0; // if (!this.isSticked && scrollTop >= this.defaultTop + 1) { // this.clearScrollState(); // } else if (this.isSticked && scrollTop < this.defaultTop + 1) { // this.setScrollState(); // } // } }, { key: 'setScrollState', value: function setScrollState() { this.wrapper.elem.classList.add('scroll-state'); this.wrapperClone && this.wrapper.elem.insertAdjacentElement('afterend', this.wrapperClone); setVideoBg(this.wrapper.elem, this.wrapperSettings, 'scroll', getProperty(this.wrapperSettings, 'default', 'visible')); this.isSticked = true; } }, { key: 'clearScrollState', value: function clearScrollState() { this.wrapper.elem.classList.remove('scroll-state'); if (this.wrapperClone) { var parent = this.wrapperClone.parentNode; parent && parent.removeChild(this.wrapperClone); } if (checkBgUrlExist(this.wrapperSettings['scroll'])) { setVideoBg(this.wrapper.elem, this.wrapperSettings, 'default', getProperty(this.wrapperSettings, 'scroll', 'visible')); } this.isSticked = false; } }, { key: '_resize', value: function _resize() { var _this = this; var time = void 0; window.addEventListener('resize', function (event) { clearInterval(time); time = setTimeout(function () { _this.clearScrollState(); _this.setPosition(); _this.onScroll(); _index.getSize; NavbarBehaviour.scrollBox && NavbarBehaviour.scrollBox.removeEventListener('scroll', _this._onScroll); NavbarBehaviour.scrollBox = _global2.default.scrollBox; NavbarBehaviour.scrollBox && NavbarBehaviour.scrollBox.addEventListener('scroll', _this._onScroll); }, 200); }); } }, { key: 'wrapper', get: function get() { return this._args.wrapper; } }, { key: 'content', get: function get() { return this._args.content; } }, { key: 'wrapperSettings', get: function get() { return this.wrapper.settings; } }, { key: 'contentSettings', get: function get() { return this.content.settings; } }, { key: 'position', get: function get() { return this._args.position; } }, { key: 'positionType', get: function get() { return this._args.positionType; } }]); return NavbarBehaviour; }(); exports.default = NavbarBehaviour; NavbarBehaviour.scrollBox = _global2.default.scrollBox; NavbarBehaviour._adminPanelHeight = getAdminPanel() instanceof HTMLElement ? 32 : 0; // function getSize(): string { // let ww = window.innerWidth; // return ww >= 992 ? 'md' : ww >= 768 ? 'sm' : 'xs'; // } /** * * @param config * @param type - default | scroll * @param name - propery key */ function getProperty(config, type, name) { if (!['default', 'scroll'].includes(type) || !config || !name) { return false; } var sizes = ['md', 'sm', 'xs']; var size = (0, _index.getSize)(); var index = sizes.indexOf(size); if (index < 0) { return false; } do { if (config[type][size] && config[type][size].has(name)) { return config[type][size].get(name); } index--; } while (index > 0); return false; } /** * * @param elem - wrapper of video * @param settings - navbar wrapper setting * @param type - defalult | scroll * @param isVisible - on | off, is navbar visible */ function setVideoBg(elem, settings, type) { var isVisible = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'on'; var bgWrapper = elem.querySelector('.background > .video-layer'); if (!bgWrapper) { return false; } if (isVisible === 'off') { bgWrapper.innerHTML = ''; return false; } // if(checkBgUrlExist(settings[type])) { // return false; // } var mp4 = settings[type].videoBg.get('mp4') || null; var ogg = settings[type].videoBg.get('ogg') || null; var webm = settings[type].videoBg.get('webm') || null; if (!mp4 && !ogg && !webm) { return false; } bgWrapper.innerHTML = '\n \n '; } function checkBgUrlExist(setting) { return ['mp3', 'ogg', 'webm'].some(function (key) { return setting.videoBg.get(key); }); } function getAdminPanel() { return document.getElementById('wpadminbar'); } /***/ }), /***/ 69: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSize = getSize; function getSize() { var ww = window.innerWidth; return ww >= 992 ? 'md' : ww >= 768 ? 'sm' : 'xs'; } /***/ }) }]);