blob: 091a5d48e3c7d6cd3867b558fe0292d0fbebf37a [file] [log] [blame]
<!-- The <query2-count-sk> custom element declaration.
Reports the number of matches for a given query.
Attributes:
current_query - The current query to count against.
url - The URL to POST the query to.
Events:
None.
Methods:
None.
-->
<dom-module id="query2-count-sk">
<style>
</style>
<template>
<div id=matches></div>
</template>
</dom-module>
<script>
Polymer({
is: "query2-count-sk",
properties: {
current_query: {
type: String,
value: "",
reflectToAttribute: true,
observer: "_currentQueryChange",
},
url: {
type: String,
value: "/_/count/",
reflectToAttribute: true,
},
_countInProgress: {
type: Boolean,
value: false,
reflectToAttribute: true,
},
},
_currentQueryChange: function() {
if (this._countInProgress === true) {
return
}
this._countInProgress = true;
sk.post(this.url, this.current_query, "application/x-www-form-urlencoded").then(JSON.parse).then(function(json) {
this._countInProgress = false;
this.$.matches.textContent = json.count;
}.bind(this)).catch(function() {
this._countInProgress = false;
});
},
});
</script>