Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
1bd331dd3c | |
|
eb1c10511a | |
|
dd6d1a5cf3 | |
|
4560b2ef67 | |
|
b2d0366b29 | |
|
faabdbc2a0 |
10
bower.json
10
bower.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "strolch-wc-debounced-input",
|
"name": "strolch-wc-debounced-input",
|
||||||
"description": "Strolch WebComponent Debounced Input",
|
"description": "Strolch WebComponent Debounced Input",
|
||||||
"version": "0.1.0",
|
"version": "0.1.6",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Robert von Burg"
|
"Robert von Burg"
|
||||||
],
|
],
|
||||||
|
@ -13,13 +13,13 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com:4treesCH/strolch-wc-debounced-input.git"
|
"url": "git@github.com:strolch-li/strolch-wc-debounced-input.git"
|
||||||
},
|
},
|
||||||
"license": "https://github.com/4treesCH/strolch-wc-debounced-input/blob/master/LICENSE",
|
"license": "https://github.com/strolch-li/strolch-wc-debounced-input/blob/master/LICENSE",
|
||||||
"homepage": "https://github.com/4treesCH/strolch-wc-debounced-input",
|
"homepage": "https://github.com/strolch-li/strolch-wc-debounced-input",
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"polymer": "Polymer/polymer#^1.11.3",
|
"polymer": "Polymer/polymer#^1.12.0",
|
||||||
|
|
||||||
"iron-icon": "PolymerElements/iron-icon#^1.0.13",
|
"iron-icon": "PolymerElements/iron-icon#^1.0.13",
|
||||||
"iron-icons": "PolymerElements/iron-icons#^1.2.1",
|
"iron-icons": "PolymerElements/iron-icons#^1.2.1",
|
||||||
|
|
|
@ -8,19 +8,22 @@
|
||||||
<!-- Style -->
|
<!-- Style -->
|
||||||
<style is="custom-style">
|
<style is="custom-style">
|
||||||
:host {
|
:host {
|
||||||
--focus-color: white;
|
--focus-color: var(--primary-color);
|
||||||
--regular-color: lightgrey;
|
--input-color: var(--primary-text-color);
|
||||||
|
--regular-color: var(--secondary-text-color);
|
||||||
--disabled-color: darkgrey;
|
--disabled-color: darkgrey;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
|
--input-padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-input {
|
paper-input {
|
||||||
--paper-input-container-color: var(--regular-color);
|
--paper-input-container-color: var(--regular-color);
|
||||||
--paper-input-container-focus-color: var(--focus-color);
|
--paper-input-container-focus-color: var(--focus-color);
|
||||||
--paper-input-container-input-color: var(--focus-color);
|
--paper-input-container-input-color: var(--input-color);
|
||||||
--paper-input-container-input: {
|
--paper-input-container-input: {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
padding: 4px;
|
padding: var(--input-padding);
|
||||||
};
|
};
|
||||||
--paper-input-container-underline-disabled: {
|
--paper-input-container-underline-disabled: {
|
||||||
border-bottom-style: solid;
|
border-bottom-style: solid;
|
||||||
|
@ -52,7 +55,8 @@
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<paper-input id="inputElement"
|
<paper-input id="inputElement"
|
||||||
no-label-float
|
label="[[label]]"
|
||||||
|
no-label-float="[[noLabelFloat]]"
|
||||||
placeholder="[[placeholder]]"
|
placeholder="[[placeholder]]"
|
||||||
value="{{input}}"
|
value="{{input}}"
|
||||||
disabled$="[[disabled]]"
|
disabled$="[[disabled]]"
|
||||||
|
@ -97,6 +101,13 @@
|
||||||
type: String,
|
type: String,
|
||||||
value: "search"
|
value: "search"
|
||||||
},
|
},
|
||||||
|
label: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
noLabelFloat: {
|
||||||
|
type: Boolean,
|
||||||
|
value: true
|
||||||
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false
|
value: false
|
||||||
|
@ -106,14 +117,7 @@
|
||||||
<!-- Observers -->
|
<!-- Observers -->
|
||||||
observeInput: function (newValue, oldValue) {
|
observeInput: function (newValue, oldValue) {
|
||||||
this.debounce("inputDebounce", function () {
|
this.debounce("inputDebounce", function () {
|
||||||
// save the previous value so it may be reset
|
this._setInput(newValue, false);
|
||||||
this.set("prevDebouncedInput", this.debouncedInput);
|
|
||||||
// set the debounced input after delay
|
|
||||||
this.set("debouncedInput", newValue);
|
|
||||||
this.fire('strolch-wc-debounced-input-changed', {
|
|
||||||
input: newValue,
|
|
||||||
enterPressed: false
|
|
||||||
});
|
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -124,21 +128,27 @@
|
||||||
// if enter was pressed
|
// if enter was pressed
|
||||||
if (event.keyCode === 13) {
|
if (event.keyCode === 13) {
|
||||||
this.debounce("inputDebounce", function () {
|
this.debounce("inputDebounce", function () {
|
||||||
// save the previous value so it may be reset
|
this._setInput(this.input, true);
|
||||||
this.set("prevDebouncedInput", this.debouncedInput);
|
|
||||||
// set the debounced input after delay
|
|
||||||
this.set("debouncedInput", this.input);
|
|
||||||
this.fire('strolch-wc-debounced-input-changed', {
|
|
||||||
input: this.input,
|
|
||||||
enterPressed: true
|
|
||||||
});
|
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setInput: function (newValue, enterPressed) {
|
||||||
|
// save the previous value so it may be reset
|
||||||
|
this.set("prevDebouncedInput", this.debouncedInput);
|
||||||
|
// set the debounced input after delay
|
||||||
|
this.set("debouncedInput", newValue);
|
||||||
|
this.fire('strolch-wc-debounced-input-changed', {
|
||||||
|
input: newValue,
|
||||||
|
enterPressed: enterPressed
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
<!-- Functions -->
|
<!-- Functions -->
|
||||||
onClearTapped: function (event) {
|
onClearTapped: function () {
|
||||||
this.setInputTerm("");
|
this.setInputTerm("");
|
||||||
|
this.cancelDebouncer("inputDebounce");
|
||||||
|
this._setInput("", false);
|
||||||
},
|
},
|
||||||
undoLastInput: function () {
|
undoLastInput: function () {
|
||||||
// apply the last debounced input
|
// apply the last debounced input
|
||||||
|
|
Loading…
Reference in New Issue