search_widget.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. $(document).ready(function() {
  2. /* toggle advanced view */
  3. $('a#tags-toggle').click(function() {
  4. $('#tags').toggle(150);
  5. return false;
  6. });
  7. /* reset terms form */
  8. $('#tags-clean').click(function() {
  9. // clear multiple select
  10. $('select option:selected').each(function () {
  11. $(this).prop('selected', false);
  12. });
  13. return false;
  14. });
  15. /* ajax suggestions */
  16. $('#query').autocomplete({
  17. source: 'search_suggestions.php',
  18. multiple: false,
  19. selectFirst: false,
  20. mustMatch: false,
  21. autoFill: false
  22. });
  23. /* prefilter form */
  24. $('#prefilter').change(function () {
  25. var str = "";
  26. $("#prefilter option:selected").each(function () {
  27. str += $(this).text() + " ";
  28. });
  29. process_terms = function(data) {
  30. $(".sf-select-multiple").html("");
  31. $.each(data, function(i,item) {
  32. $.each(item.terms, function(index, term) {
  33. $('<option />').val(index).text(term).appendTo("#sf-" + item.prefix);
  34. });
  35. });
  36. };
  37. url = "/main/inc/lib/search/get_terms.php";
  38. params = "?term=" + $(this).val() + "&prefix=" + $(this).attr("title") + "&operator=" + $("input[@name=operator]:checked").val();
  39. $.getJSON(url + params, process_terms);
  40. });
  41. });