window.GaiaTextinput = (function(win) { 'use strict'; // Extend from the HTMLElement prototype var proto = Object.create(HTMLElement.prototype); // Allow baseurl to be overridden (used for demo page) var baseurl = window.GaiaTextinputBaseurl || '/shared/elements/gaia-textinput/'; proto.createdCallback = function() { var shadow = this.createShadowRoot(); this._template = template.content.cloneNode(true); this._input = this._template.getElementById('input'); if (this.getAttribute('value') !== null) { this._input.value = this.getAttribute('value'); } if (this.getAttribute('placeholder') !== null) { this._input.placeholder = this.getAttribute('placeholder'); } if (this.getAttribute('required')) { this._input.required = ''; } if (this.getAttribute('reset') !== null) { var reset = document.createElement('button'); reset.id = 'input-reset'; reset.type = 'reset'; reset.textContent = 'Clear'; this._template.getElementById('gaia-text-input').appendChild(reset); // Don't take focus from the input field reset.addEventListener('mousedown', function(e) { e.preventDefault(); }); reset.addEventListener('click', this.resetInput.bind(this)); } shadow.appendChild(this._template); }; proto.resetInput = function(e) { e.target.previousElementSibling.value = ''; e.preventDefault(); }; // HACK: Create a