mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-08 15:43:24 +00:00
Ajoute un bouton de réinitialisation du champ
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<form action="index.html" method="post">
|
||||
<label for="filter">Filtrer les sons</label>
|
||||
<input type="text" name="s" value="" id="filter" placeholder="Ex. : Perceval">
|
||||
<input type="reset" value="Réinitialiser" class="btn-reset invisible">
|
||||
<input type="submit" name="submit" value="Filtrer" class="btn">
|
||||
</form>
|
||||
|
||||
@@ -10,19 +10,35 @@ define("views/filter", function(require) {
|
||||
template: SoundsFilterTemplate,
|
||||
ui: {
|
||||
searchForm: "form",
|
||||
searchField: "form input[name='s']"
|
||||
searchField: "form input[name='s']",
|
||||
btnReset: ".btn-reset"
|
||||
},
|
||||
events: {
|
||||
"submit @ui.searchForm": "filterSounds",
|
||||
"keyup @ui.searchField": "filterSounds"
|
||||
"keyup @ui.searchField": "filterSounds",
|
||||
"click @ui.btnReset": "resetFilter"
|
||||
},
|
||||
initialize: function() {
|
||||
this.channel = Radio.channel("Sounds");
|
||||
},
|
||||
filterSounds: function(e) {
|
||||
var value = this.$el.find(this.ui.searchField).val();
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
this.channel.trigger("sounds:filter", $(this.ui.searchField).val());
|
||||
if( value !== "" ) {
|
||||
this.$el.find(this.ui.btnReset).removeClass('invisible');
|
||||
} else {
|
||||
this.$el.find(this.ui.btnReset).addClass('invisible');
|
||||
}
|
||||
|
||||
this.channel.trigger("sounds:filter", value);
|
||||
},
|
||||
resetFilter: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.$el.find(this.ui.searchField).val('');
|
||||
this.$el.find(this.ui.searchForm).submit();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user