init: function(config, parent) { this._id = this._id || utils.uniqueId('c'); this._ready = false; this._readyOnce = false; this.name = this.name || config.name; this.template = this.template || '<div></div>'; this.placeholder = this.placeholder || config.placeholder; this.template_data = this.template_data || { name: this.name }; //make sure placeholder is DOM element if(this.placeholder && !utils.isElement(this.placeholder)) { try { this.placeholder = parent.placeholder.querySelector(this.placeholder); } catch(e) { utils.error('Error finding placeholder \'' + this.placeholder + '\' for component \'' + this.name + '\''); } } this.parent = parent || this; this.root = this.parent.root || this; this.components = this.components || []; this._components_config = this.components.map(function(x) { return utils.clone(x); }); this._frameRate = 10; //define expected models for this component this.model_expects = this.model_expects || []; this.model_binds = this.model_binds || {}; this.ui = this.ui || config.ui; this._super(); //readyOnce alias var _this = this; this.on({ 'readyOnce': function() { if(typeof _this.readyOnce === 'function') { _this.readyOnce(); } }, 'ready': function() { if(typeof _this.ready === 'function') { _this.ready(); } }, 'domReady': function() { if(typeof _this.domReady === 'function') { _this.domReady(); } }, 'resize': function() { if(typeof _this.resize === 'function') { _this.resize(); } } }); this.triggerResize = utils.throttle(this.triggerResize, 100); },
Friend.prototype._initialize = function() { // find our elements and get initial data for them this._findNodes(); // determine if our position function is throttled or regular var positionFn = this.position.bind(this); var throttleSpeed = this._options.throttleSpeed; this._positionFn = this._options.throttle ? utils.throttle(positionFn, throttleSpeed) : positionFn; // auto enable Friend if option is set if (this._options.enabled) { this.enable(); } this.emit(EVENTS.initialized); };
Object.defineProperty(Vue.prototype, '$util', { value: utils, readable: true, writable: __DEV__ }) const {documentElement: docEl} = document const resize = () => { const winHeight = docEl.clientHeight store.dispatch('setSize', {winHeight, winWidth: docEl.clientWidth}) docEl.style.fontSize = store.getters.fontSize + 'px' } on(window, { resize: throttle(resize), click: () => getters.menuOpen && dispatch('toggleMenuOpen', false) }) resize() if (!__PROD__) { utils.logout = () => { store.dispatch('resetRole') location.reload() } } if (module.hot) module.hot.accept() // eslint-disable-next-line no-new