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).attr('selected', '');
  12. });
  13. return false;
  14. });
  15. /* ajax suggestions */
  16. $('#query').autocomplete('search_suggestions.php', {
  17. multiple: false,
  18. selectFirst: false,
  19. mustMatch: false,
  20. autoFill: false
  21. });
  22. /* prefilter form */
  23. $('#prefilter').change(function () {
  24. var str = "";
  25. $("#prefilter option:selected").each(function () {
  26. str += $(this).text() + " ";
  27. });
  28. process_terms = function(data) {
  29. $(".sf-select-multiple").html("");
  30. $.each(data, function(i,item) {
  31. $.each(item.terms, function(index, term) {
  32. $('<option />').val(index).text(term).appendTo("#sf-" + item.prefix);
  33. });
  34. });
  35. };
  36. url = "/main/inc/lib/search/get_terms.php";
  37. params = "?term=" + $(this).val() + "&prefix=" + $(this).attr("title") + "&operator=" + $("input[@name=operator]:checked").val();
  38. $.getJSON(url + params, process_terms);
  39. });
  40. });