Commit 74f366a7 authored by Sven Franck's avatar Sven Franck

refactor searchbar gadget (not done)

parent a2a5ea79
......@@ -50,7 +50,18 @@
<div id="searchbar"
data-gadget="modules/searchbar/searchbar.html"
data-gadget-module="searchbar"
class="searchbar_wrap search_element">
class="searchbar_wrap search_element"
data-gadget-property='{
"state": [
{
"searchbar": {
"_elements": [
["searchbar_filter", "attr", "data-selector", "items_listview"]
]
}
}
]
}'>
</div>
<!-- sorting -->
......
......@@ -7,7 +7,6 @@
<body>
<div data-filter="true"
class="searchbar_filter"
data-selector="items_listview"
data-filter-placeholder="Search">
</div>
</body>
......
......@@ -9,7 +9,17 @@ define([
response.data = source;
response.callback = function (self) {
var filter = self.dom.find(".searchbar_filter"),
value;
value, runSearch;
runSearch = function (value) {
// only go to search.html, if we are currently not on it, else only trigger hashchange
$.mobile.changePage( "search.html", {
"transition": "slide",
"data": {
"search": value
}
});
};
filter.on("filterbarbeforefilter", function (e, data) {
value = data.input.value;
......@@ -35,17 +45,21 @@ define([
})
.on( "filterbarcreate", function( e, ui ) {
var uuid = $(e.target).data("mobileFilterbar").uuid,
target = $("#ui-filter-"+uuid).find(".ui-input-action");
target = $("#ui-filter-"+uuid),
action = target.find(".ui-input-action"),
input = target.find("input");
target.on("click", function(e) {
value = $("#ui-filter-"+uuid).find("input").val();
// TODO: search should be run here and results should be passed to
// items or ?. Otherwise items has to listen for ... something, grab
// data from somewhere and query. This makes more sense here.
action.on("click", function(e) {
runSearch(input.val());
});
$.mobile.changePage( "search.html", {
"transition": "slide",
"data": {
"search": value
}
});
input.on("keypress", function (e) {
if (e.which == 13) {
runSearch(input.val());
}
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment