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

refactor searchbar gadget (not done)

parent a2a5ea79
...@@ -50,7 +50,18 @@ ...@@ -50,7 +50,18 @@
<div id="searchbar" <div id="searchbar"
data-gadget="modules/searchbar/searchbar.html" data-gadget="modules/searchbar/searchbar.html"
data-gadget-module="searchbar" 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> </div>
<!-- sorting --> <!-- sorting -->
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<body> <body>
<div data-filter="true" <div data-filter="true"
class="searchbar_filter" class="searchbar_filter"
data-selector="items_listview"
data-filter-placeholder="Search"> data-filter-placeholder="Search">
</div> </div>
</body> </body>
......
...@@ -9,7 +9,17 @@ define([ ...@@ -9,7 +9,17 @@ define([
response.data = source; response.data = source;
response.callback = function (self) { response.callback = function (self) {
var filter = self.dom.find(".searchbar_filter"), 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) { filter.on("filterbarbeforefilter", function (e, data) {
value = data.input.value; value = data.input.value;
...@@ -35,17 +45,21 @@ define([ ...@@ -35,17 +45,21 @@ define([
}) })
.on( "filterbarcreate", function( e, ui ) { .on( "filterbarcreate", function( e, ui ) {
var uuid = $(e.target).data("mobileFilterbar").uuid, 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) { // TODO: search should be run here and results should be passed to
value = $("#ui-filter-"+uuid).find("input").val(); // 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", { input.on("keypress", function (e) {
"transition": "slide", if (e.which == 13) {
"data": { runSearch(input.val());
"search": value }
}
});
}); });
}); });
......
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