Commit 821299ff authored by Romain Loth's avatar Romain Loth

whoswho: replace old filtercomplete by forward compatible classic jquery...

whoswho: replace old filtercomplete by forward compatible classic jquery autocomplete + make paths more portable
parent 9d4af125
/*!
* Ensure jq-ui.autocomplete menus are over the topbar
*/
.topbar .ui-menu {
z-index:11 !important;
}
/*! /*!
* Excerpt from Bootstrap v1.4.0 Copyright 2011 Twitter, Inc * Excerpt from Bootstrap v1.4.0 Copyright 2011 Twitter, Inc
* with all top toolbar elements' css as they were back then... * with all top toolbar elements' css as they were back then...
...@@ -9,7 +18,7 @@ ...@@ -9,7 +18,7 @@
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
z-index: 10000; z-index: 10;
overflow: visible; overflow: visible;
} }
.topbar a { .topbar a {
......
...@@ -37,6 +37,8 @@ $(document).ready(function() { ...@@ -37,6 +37,8 @@ $(document).ready(function() {
return log("applet already exists"); return log("applet already exists");
} }
}; };
// autocomplete
popfilter = function(label, type, options) { popfilter = function(label, type, options) {
var footer, header, id, id1, id2, input, labelization; var footer, header, id, id1, id2, input, labelization;
id = ids++; id = ids++;
...@@ -47,17 +49,30 @@ $(document).ready(function() { ...@@ -47,17 +49,30 @@ $(document).ready(function() {
input = "<input type=\"text\" id=\"" + id2 + "\" class=\"medium filter" + type + "\" placeholder=\"" + type + "\" />"; input = "<input type=\"text\" id=\"" + id2 + "\" class=\"medium filter" + type + "\" placeholder=\"" + type + "\" />";
footer = "</li>;"; footer = "</li>;";
$(header + labelization + input + footer).insertBefore("#refine"); $(header + labelization + input + footer).insertBefore("#refine");
$("#" + id2).filtercomplete({
minLength: 2, console.log("whoswho.popfilter: adding autocomplete menu", $("#" + id1))
source: function(request, response) {
return $.getJSON("search_filter.php", { $("#" + id2).autocomplete({
category: type, source: function (req, resp) {
term: request.term $.ajax({
}, function(data, status, xhr) { dataType: "json",
return response(data.results); type: "GET",
}); url: "/search_filter.php",
data: {
"category": type,
"term": req.term,
},
success: function(data){
resp(data.results)
},
error: function(response) {
console.log("ERROR from search_filter AJAX", response)
} }
}); }) ;
},
minLength: 2
})
$("" + id1).hide(); $("" + id1).hide();
show("#" + id1); show("#" + id1);
$("#" + id2).focus(); $("#" + id2).focus();
...@@ -80,34 +95,8 @@ $(document).ready(function() { ...@@ -80,34 +95,8 @@ $(document).ready(function() {
opacity: 0.93 opacity: 0.93
}, "fast"); }, "fast");
}); });
$.widget("custom.filtercomplete", $.ui.autocomplete, {
_renderMenu: function(ul, items) {
var categories, self;
self = this;
categories = _.groupBy(items, function(o) {
return o.category;
});
return _.each(categories, function(data, category) {
var size, term, total;
size = 0;
total = 0;
term = "";
_.each(data, function(item) {
var myRender;
size = item.size;
total = item.total;
term = item.term;
myRender = function(a, b) {
return $("<li></li>").data("item.autocomplete", b).append($("<a></a>").text(b.label)).appendTo(a);
};
return myRender(ul, item);
});
ul.append("<li class='ui-autocomplete-category'>" + size + "/" + total + " results</li>");
log(term);
return ul.highlight(term);
});
}
});
$.widget("custom.scholarcomplete", $.ui.autocomplete, { $.widget("custom.scholarcomplete", $.ui.autocomplete, {
_renderMenu: function(ul, items) { _renderMenu: function(ul, items) {
var categories, self; var categories, self;
...@@ -183,13 +172,13 @@ $(document).ready(function() { ...@@ -183,13 +172,13 @@ $(document).ready(function() {
$("#searchname").attr("placeholder", ""); $("#searchname").attr("placeholder", "");
$("#print2").click(function() { $("#print2").click(function() {
console.log("clicked on print"); console.log("clicked on print");
return window.open("print_scholar_directory.php?query=" + ui.item.id, "Scholar's list"); return window.open("/print_scholar_directory.php?query=" + ui.item.id, "Scholar's list");
}); });
$("#generate2").click(function() { $("#generate2").click(function() {
hide(".hero-unit"); hide(".hero-unit");
return $("#welcome").fadeOut("slow", function() { return $("#welcome").fadeOut("slow", function() {
show("#loading", "fast"); show("#loading", "fast");
return window.location.href='explorerjs.html?type="uid"&nodeidparam="' + ui.item.id + '"'; return window.location.href='/explorerjs.html?type="uid"&nodeidparam="' + ui.item.id + '"';
//return loadGraph("get_scholar_graph.php?login=" + ui.item.id); //return loadGraph("get_scholar_graph.php?login=" + ui.item.id);
}); });
}); });
...@@ -256,23 +245,23 @@ $(document).ready(function() { ...@@ -256,23 +245,23 @@ $(document).ready(function() {
}; };
// refine filters => tinawebjs graphexplorer // refine filters => tinawebjs graphexplorer
$("#generate").click(function() { $("#generate").click(function() {
console.log("clicked on generate")
hide(".hero-unit"); hide(".hero-unit");
return $("#welcome").fadeOut("slow", function() { $("#welcome").fadeOut("slow");
console.log("initiating graphexplorer")
show("#loading", "fast"); show("#loading", "fast");
return collectFilters(function(query) { return collectFilters(function(query) {
return window.location.href='explorerjs.html?type="filter"&nodeidparam="' + escape(query) +'"'; return window.location.href='/explorerjs.html?type="filter"&nodeidparam="' + escape(query) +'"';
//return loadGraph("getgraph.php?query=" + query); //return loadGraph("getgraph.php?query=" + query);
}); });
}); });
});
$("#print").click(function() { $("#print").click(function() {
console.log("clicked on print"); console.log("clicked on print");
return collectFilters(function(query) { return collectFilters(function(query) {
console.log("collected filters: " + query); console.log("collected filters: " + query);
return window.open("print_directory.php?query=" + query, "Scholar's list"); return window.open("/print_directory.php?query=" + query, "Scholar's list");
}); });
}); });
hide("#loading"); hide("#loading");
......
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