'use strict'; new ExceptionHandler(); /** * Polymer element to select an HTML element background style * @namespace SettingBackground */ Polymer({ is: 'setting-background', behaviors: [ Chrome.LocalizeBehavior, ], properties: { /** * Local storage key * @memberOf SettingBackground */ name: { type: String, value: 'store', }, /** * Optional group title * @memberOf SettingBackground */ sectionTitle: { type: String, value: '', }, /** * Disabled state of element * @memberOf SettingBackground */ disabled: { type: Boolean, value: false, }, /** * Visibility state of optional divider * @memberOf SettingBackground */ noseparator: { type: Boolean, value: false, }, /** * Element id of currently selected background style * @type {string} * @memberOf SettingBackground */ selected: { type: String, value: 'b1', notify: true, }, /** * Local storage value of currently selected background style * @memberOf SettingBackground */ value: { type: String, value: 'background:linear-gradient(to bottom, #3a3a3a, #b5bdc8)', notify: true, }, /** * Item description * @memberOf SettingBackground */ mainLabel: { type: String, value: '', }, /** * Item secondary description * @memberOf SettingBackground */ secondaryLabel: { type: String, value: '', }, }, /** * Initialize value if it is not in localstorage * @private * @memberOf SettingBackground */ _init: function() { this.set('value', 'background:linear-gradient(to bottom, #3a3a3a, #b5bdc8)'); }, /** * Event: Show dialog on tap * @private * @memberOf SettingBackground */ _onTap: function() { this.$.dialog.open(); }, /** * Event: Set selected background on tap of OK button * @private * @memberOf SettingBackground */ _onOK: function() { const el = document.getElementById(this.selected); this.set('value', 'background:' + el.style.background); Chrome.GA.event(Chrome.GA.EVENT.BUTTON, `SettingBackground.OK: ${this.selected}`); }, });