custom.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. $(document).ready( function () {
  2. $('[data-url]').on('click', function(e) {
  3. window.location.href = $(this).data('url');
  4. });
  5. $('option').mousedown(function(e) {
  6. e.preventDefault();
  7. $(this).prop('selected', !$(this).prop('selected'));
  8. return false;
  9. });
  10. var loc_uri = URI.parse(window.location.href);
  11. var loc_qry = URI.parseQuery(loc_uri.query)
  12. $('.filters-bar').children('select[data-filter]').each(function () {
  13. var filter_name = $(this).data('filter');
  14. if(filter_name in loc_qry) {
  15. $(this).val(loc_qry[filter_name]);
  16. }
  17. });
  18. $('#stories').on('change', 'select[data-filter]', function() {
  19. var filters = [];
  20. var filtersbar = $('#stories > .filters-bar');
  21. filtersbar.children('select').each(function () {
  22. if (this.value.length > 0) {
  23. filters.push($(this).data('filter') + "=" + $(this).val());
  24. }
  25. });
  26. var url = document.URL;
  27. var target = url.split('?')[0];
  28. if (filters.length > 0) {
  29. target = target + '?' + filters.join('&');
  30. }
  31. window.location.href = target;
  32. });
  33. $('#stories').on('click', 'a[data-page]', function() {
  34. var filters = [];
  35. var filtersbar = $('#stories > .filters-bar');
  36. filtersbar.children('select').each(function () {
  37. if (this.value.length > 0) {
  38. filters.push($(this).data('filter') + "=" + $(this).val());
  39. }
  40. });
  41. var url = document.URL;
  42. var target = url.split('?')[0];
  43. if (filters.length > 0) {
  44. target = target + '?' + filters.join('&') + '&page=' + $(this).data('page');
  45. } else {
  46. target = target + '?page=' + $(this).data('page');
  47. }
  48. window.location.href = target;
  49. });
  50. $(document).on('click', function(event) {
  51. if(!$(event.target).closest('#user-panel').length) {
  52. if($('#user-dropdown').is(":visible")) {
  53. $('#user-dropdown').hide();
  54. }
  55. }
  56. if(!$(event.target).closest('#notif-panel').length) {
  57. if($('#notif-dropdown').is(":visible")) {
  58. $('#notif-dropdown').hide();
  59. }
  60. }
  61. });
  62. $(document).on('click', '#user-show-btn', function(event) {
  63. event.preventDefault();
  64. if($('#user-dropdown').is(":visible")) {
  65. $('#user-dropdown').hide();
  66. }
  67. else {
  68. $('#user-dropdown').show();
  69. }
  70. });
  71. $(document).on('click', '#notif-show-btn', function(event) {
  72. event.preventDefault();
  73. if($('#notif-dropdown').is(":visible")) {
  74. $('#notif-dropdown').hide();
  75. }
  76. else {
  77. $('#notif-dropdown').show();
  78. }
  79. });
  80. });