script.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @version 7.10 [rev.7.10.01]
  3. */
  4. $(document).ready(function () {
  5. /* ADMIN SEARCH AUTOCOMPLETE BOX */
  6. $("[name='admin_quick_nav']").autocomplete({
  7. source: function (request, response) {
  8. $.ajax({
  9. url: paths.quickNavigation,
  10. dataType: "json",
  11. data: {
  12. input: request.term
  13. },
  14. success: function (data) {
  15. //map the data into a response that will be understood by the autocomplete widget
  16. response($.map(data, function (item) {
  17. return {
  18. label: item.label,
  19. path: item.path
  20. }
  21. }));
  22. $(".ui-helper-hidden-accessible").hide();
  23. }
  24. });
  25. },
  26. //start looking at 2 characters
  27. minLength: 2,
  28. //when you have selected something
  29. select: function (event, ui) {
  30. if (ui.item.path != '') {
  31. window.location.href = ui.item.path;
  32. }
  33. },
  34. //show the drop down
  35. open: function () {
  36. $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
  37. },
  38. //close the drop down
  39. close: function () {
  40. $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
  41. }
  42. });
  43. $("[name='init_category_counters']").on('click', function (e) {
  44. e.preventDefault();
  45. var total = $('#category-total-listings').text(); // need to get this from somewhere.
  46. var limit = 100;
  47. var offset = (-1) * limit;
  48. var button = $(this);
  49. var buttonValue = button.html();
  50. var progress = 0;
  51. button.html('Please wait..').attr('disabled', true);
  52. function countListingsByCategory() {
  53. offset += limit;
  54. if (offset > total) {
  55. button.attr('disabled', false).html(buttonValue);
  56. $('#category-counters-progress').html(total + ' listings counted.');
  57. return;
  58. }
  59. $.ajax({
  60. url: paths.initCategoryCounters,
  61. dataType: "json",
  62. data: {
  63. limit: limit,
  64. offset: offset
  65. },
  66. cache: false,
  67. success: function (data) {
  68. progress += data.counter;
  69. $('#category-counters-progress').html(progress + '/' + total + ' listings counted.');
  70. countListingsByCategory();
  71. }
  72. });
  73. }
  74. countListingsByCategory();
  75. });
  76. });