Commit 78e85e94 authored by Romain Loth's avatar Romain Loth

php topbar: show current filters (exposed whoswho.popfilter and used it in js...

php topbar: show current filters (exposed whoswho.popfilter and used it in js elements for print_directory)
parent 29ff6612
...@@ -5,6 +5,20 @@ ...@@ -5,6 +5,20 @@
* TODO use more eg for charts * TODO use more eg for charts
*/ */
// to autoselect current whoswho filters
// NB: uses global value $data
$auto_popfilters_snippet = '<script type="text/javascript">' ;
foreach ($data as $filter => $array_vals) {
foreach ($array_vals as $val) {
$auto_popfilters_snippet .= '
whoswho.popfilter("'.$filter.'", {"prefill":"'.$val.'"});
';
}
}
$auto_popfilters_snippet .= '</script>';
// exemple snippet this one is to use in html context // exemple snippet this one is to use in html context
$rm_ads_snippet = <<< ENDHTML $rm_ads_snippet = <<< ENDHTML
<script type="text/javascript"> <script type="text/javascript">
......
<?php <?php
include ("php_library/comex_library.php"); include ("php_library/comex_library.php");
include ("php_library/js_elements.php");
include ("php_library/parametres.php"); include ("php_library/parametres.php");
include ("php_library/normalize.php"); include ("php_library/normalize.php");
include ("php_library/baselayout_head_template.php"); include ("php_library/baselayout_head_template.php");
...@@ -8,10 +7,18 @@ include ("php_library/baselayout_topbar_template.php"); ...@@ -8,10 +7,18 @@ include ("php_library/baselayout_topbar_template.php");
include ("php_library/baselayout_tail_template.php"); include ("php_library/baselayout_tail_template.php");
$meta = $html_head_inner; $meta = $html_head_inner;
$meta .= $rm_ads_snippet;
$data = json_decode($_GET['query']); $data = json_decode($_GET['query']);
print_r('query here<br>');
print_r($data);
print_r('/query here<br>');
// this one after we got query data
include ("php_library/js_elements.php");
function objectToArray($d) { function objectToArray($d) {
if (is_object($d)) { if (is_object($d)) {
// Gets the properties of the given object // Gets the properties of the given object
...@@ -473,6 +480,8 @@ echo $footer; ...@@ -473,6 +480,8 @@ echo $footer;
// echo '</div>'; // echo '</div>';
echo '</div>'; echo '</div>';
echo $html_tail_imports; echo $html_tail_imports;
echo $rm_ads_snippet;
echo $auto_popfilters_snippet;
echo '</body> echo '</body>
</html>'; </html>';
exit(0); exit(0);
......
...@@ -8,7 +8,6 @@ include ("php_library/baselayout_topbar_template.php"); ...@@ -8,7 +8,6 @@ include ("php_library/baselayout_topbar_template.php");
include ("php_library/baselayout_tail_template.php"); include ("php_library/baselayout_tail_template.php");
$meta = $html_head_inner; $meta = $html_head_inner;
$meta .= $rm_ads_snippet;
//phpinfo(); //phpinfo();
//echo $_GET['query']."<br/>"; //echo $_GET['query']."<br/>";
...@@ -284,6 +283,7 @@ echo '<h2>Sorry, '.$target_name.' did not mention any keywords ... we cannot pr ...@@ -284,6 +283,7 @@ echo '<h2>Sorry, '.$target_name.' did not mention any keywords ... we cannot pr
// echo '</div>'; // echo '</div>';
echo '</div>'; echo '</div>';
echo $html_tail_imports; echo $html_tail_imports;
echo $rm_ads_snippet;
echo '</body> echo '</body>
</html>'; </html>';
exit(0); exit(0);
......
...@@ -383,7 +383,7 @@ div.ccsection-footer { ...@@ -383,7 +383,7 @@ div.ccsection-footer {
/*in directory view*/ /*in directory view*/
.full-directory { .full-directory {
margin: 0 25; margin: 70 25 0 25;
} }
.container.inner { .container.inner {
width: 100%; width: 100%;
......
...@@ -18,58 +18,51 @@ jQuery.fn.disableTextSelect = function() { ...@@ -18,58 +18,51 @@ jQuery.fn.disableTextSelect = function() {
}); });
}; };
ids = 0; ids = 0;
completion = {}; completion = {};
gexf = ""; gexf = "";
$(document).ready(function() { // module fragment to expose selected functions
var cache, closeBox, collectFilters, loadGraph, popfilter, xhrs; var whoswho = {};
log("document ready.. installing whoswho");
loadGraph = function(g) {
gexf = g;
log("url query: " + g);
log("injecting applet");
if ($('#frame').length === 0) {
return $("#visualization").html("<iframe src=\"tinaframe.html" + (location.search != null ? location.search : '') + "\" class=\"frame\" border=\"0\" frameborder=\"0\" scrolling=\"no\" id=\"frame\" name=\"frame\"></iframe>");
} else {
return log("applet already exists");
}
};
whoswho = (function(ww) {
// small filter closing function // filter type => label
closeThisBox = function() { ww.filters = {
var targetId = this.getAttribute("for") 'countries': "in",
if (targetId) { 'institutions': "from",
var tgtBox = document.getElementById(targetId) 'laboratories': "working at",
// start transition 'keywords': "working on",
tgtBox.style.opacity = 0 'tags': "tagged"
// remove box
setTimeout(function(){tgtBox.remove()}, 500)
return true
} }
else {
console.warn('closeThisBox: no @for attribute!') // autocomplete
return false ww.popfilter = function(type, options) {
var label, footer, header, id, id1, id2, input, closebox, labelization;
if (!options) {
options = {}
} }
if (! options.prefill) {
options['prefill']=''
} }
// autocomplete label = ww.filters[type];
popfilter = function(label, type, options) {
var footer, header, id, id1, id2, input, closebox, labelization;
id = ids++; id = ids++;
id1 = "filter" + id; id1 = "filter" + id;
id2 = "combo" + id; id2 = "combo" + id;
id3 = "close" + id; id3 = "close" + id;
header = "<li id=\"" + id1 + "\" class=\"comex-nav-item filter\" style=\"padding-top: 5px;\">"; header = "<li id=\"" + id1 + "\" class=\"comex-nav-item filter\" style=\"padding-top: 5px;\">";
labelization = "<span style=\"color: #fff;\">&nbsp; " + label + " </span>"; labelization = "<span style=\"color: #fff;\">&nbsp; " + label + " </span>";
input = "<input type=\"text\" id=\"" + id2 + "\" class=\"medium filter" + type + "\" placeholder=\"" + type + "\" />"; input = "<input type=\"text\" id=\"" + id2 + "\" class=\"medium filter" + type + "\" placeholder=\"" + type + "\" / value=\""+options['prefill']+"\">";
closebox = "<div id=\""+id3+"\" for=\""+id1+"\" class=\"filter-close operation-light\">x</div>" closebox = "<div id=\""+id3+"\" for=\""+id1+"\" class=\"filter-close operation-light\">x</div>"
footer = "</li>;"; footer = "</li>;";
$(header + labelization + input + closebox + footer).insertBefore("#refine"); $(header + labelization + input + closebox + footer).insertBefore("#refine");
$('#' + id3).click(closeThisBox) $('#' + id3).click(whoswho.closeThisBox)
// debug // debug
console.log("whoswho.popfilter: adding autocomplete menu", $("#" + id1)) console.log("whoswho.popfilter: adding autocomplete menu", $("#" + id1))
...@@ -106,6 +99,41 @@ $(document).ready(function() { ...@@ -106,6 +99,41 @@ $(document).ready(function() {
$("#" + id2).focus(); $("#" + id2).focus();
return false; return false;
}; };
// small filter closing function
ww.closeThisBox = function() {
var targetId = this.getAttribute("for")
if (targetId) {
var tgtBox = document.getElementById(targetId)
// start transition
tgtBox.style.opacity = 0
// remove box
setTimeout(function(){tgtBox.remove()}, 500)
return true
}
else {
console.warn('closeThisBox: no @for attribute!')
return false
}
}
return ww;
})(whoswho);
$(document).ready(function() {
var cache, closeBox, collectFilters, loadGraph;
log("document ready.. installing whoswho");
loadGraph = function(g) {
gexf = g;
log("url query: " + g);
log("injecting applet");
if ($('#frame').length === 0) {
return $("#visualization").html("<iframe src=\"tinaframe.html" + (location.search != null ? location.search : '') + "\" class=\"frame\" border=\"0\" frameborder=\"0\" scrolling=\"no\" id=\"frame\" name=\"frame\"></iframe>");
} else {
return log("applet already exists");
}
};
// jQuery(".unselectable").disableTextSelect(); // jQuery(".unselectable").disableTextSelect();
jQuery(".unselectable").disableSelection(); jQuery(".unselectable").disableSelection();
$(".unselectable").hover((function() { $(".unselectable").hover((function() {
...@@ -125,26 +153,22 @@ $(document).ready(function() { ...@@ -125,26 +153,22 @@ $(document).ready(function() {
}); });
$("#addfiltercountry").click(function() { $("#addfiltercountry").click(function() {
return popfilter("in", "countries", []); return whoswho.popfilter("countries");
}); });
// $("#addfilterorganization").click(function() { // $("#addfilterorganization").click(function() {
// return popfilter("from", "organizations", []); // return whoswho.popfilter("organizations");
// }); // });
$("#addfilterinstitution").click(function() { $("#addfilterinstitution").click(function() {
return popfilter("from", "institutions", []); return whoswho.popfilter("institutions");
}); });
$("#addfilterlaboratory").click(function() { $("#addfilterlaboratory").click(function() {
var prefix; return whoswho.popfilter("laboratories");
prefix = "working";
return popfilter("" + prefix + " at", "laboratories", []);
}); });
$("#addfilterkeyword").click(function() { $("#addfilterkeyword").click(function() {
var prefix; return whoswho.popfilter("keywords");
prefix = "working";
return popfilter("" + prefix + " on", "keywords", []);
}); });
$("#addfiltertag").click(function() { $("#addfiltertag").click(function() {
return popfilter("tagged", "tags", []); return whoswho.popfilter("tags");
}); });
$("#register").click(function() { $("#register").click(function() {
return window.open("/services/user/register/"); return window.open("/services/user/register/");
......
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