From f46a1ce431f92d9c50be3fd24fc85b1dfe83d799 Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Tue, 2 Jun 2015 17:31:55 +0200 Subject: [PATCH] added some javascript for input forms --- resources/js/smufl-scripts.js | 47 +++++++++++++++++++++-------------- templates/page.html | 17 +------------ 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/resources/js/smufl-scripts.js b/resources/js/smufl-scripts.js index b28284f..a742ba0 100644 --- a/resources/js/smufl-scripts.js +++ b/resources/js/smufl-scripts.js @@ -1,22 +1,31 @@ /* - * Some Javscript functions for SMuFL-Browser + * Some Javascript functions for SMuFL-Browser */ -function gotoPage(page) { -/* var data = $("#fun-query-form").serialize();*/ - /*$.ajax({ - type: "POST", - url: "ajax.html", - data: data + "&action=search", - success: function (data) { - $("#results").fadeOut(100, function() { - $(this).html(data); - $(this).fadeIn(100, function() { - $(".signature").highlight(); - }); - timeout = null; - }); - } - });*/ - console.log(page); -} \ No newline at end of file +$.fn.facets = function () +{ + this.selectize({ + plugins: ['remove_button'], + hideSelected: true, + onDropdownClose: function(e){ + var params = []; + /* Set filters */ + $('option:selected').each(function() { + var facet = $(this).parent().attr('name'); + var value = $(this).attr('value'); + /*console.log(facet + '=' + value);*/ + params.push(facet + '=' + encodeURI(value)) + }) + + /* Refresh page */ + self.location='?'+params.join('&') + } + }) +}; + +/* Initialize selectize plugin for the input forms */ +$(document).ready(function() { + $("#ranges-list").facets(); + $("#glyphnames-list").facets(); + $("#classes-list").facets(); +}); \ No newline at end of file diff --git a/templates/page.html b/templates/page.html index a527d5b..1a787da 100755 --- a/templates/page.html +++ b/templates/page.html @@ -26,22 +26,7 @@ \ No newline at end of file