(function(define){'use strict';define(function(require,exports,module){ /*jshint esnext:true*/ /** * Extend from the `HTMLElement` prototype * * @type {Object} */ var proto = Object.create(HTMLElement.prototype); proto.createdCallback = function() { this.createShadowRoot().innerHTML = template; this.els = { themes: this.shadowRoot.querySelector('.themes'), rtl: this.shadowRoot.querySelector('.toggle-rtl') }; this.els.rtl.addEventListener('click', this.onRtlClick.bind(this)); this.els.themes.addEventListener('click', this.onThemeClick.bind(this)); this.styleHack(); this.set(localStorage.theme || 'settings'); }; proto.styleHack = function() { var style = this.shadowRoot.querySelector('style'); style.setAttribute('scoped', ''); this.appendChild(style.cloneNode(true)); }; proto.onThemeClick = function(e) { var theme = e.target.value; if (theme) { this.set(theme); } }; proto.onRtlClick = function() { document.dir = this.els.rtl.checked ? 'rtl' : 'ltr'; }; proto.set = function(theme) { var radio = this.shadowRoot.querySelector('[value="' + theme + '"]'); document.body.classList.remove('theme-' + this.theme); document.body.classList.add('theme-' + theme); radio.checked = true; this.theme = theme; localStorage.theme = theme; }; var template = `
`; document.registerElement('gaia-theme-selector', { prototype: proto }); });})((function(n,w){'use strict';return typeof define=='function'&&define.amd? define:typeof module=='object'?function(c){c(require,exports,module);}: function(c){var m={exports:{}},r=function(n){return w[n];}; w[n]=c(r,m.exports,m)||m.exports;};})('gaia-theme-selector',this));