logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git

element_modifiers.js (3733B)


  1. /**
  2. * searx is free software: you can redistribute it and/or modify
  3. * it under the terms of the GNU Affero General Public License as published by
  4. * the Free Software Foundation, either version 3 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * searx is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU Affero General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Affero General Public License
  13. * along with searx. If not, see < http://www.gnu.org/licenses/ >.
  14. *
  15. * (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
  16. */
  17. $(document).ready(function(){
  18. /**
  19. * focus element if class="autofocus" and id="q"
  20. */
  21. $('#q.autofocus').focus();
  22. /**
  23. * select full content on click if class="select-all-on-click"
  24. */
  25. $(".select-all-on-click").click(function () {
  26. $(this).select();
  27. });
  28. /**
  29. * change text during btn-collapse click if possible
  30. */
  31. $('.btn-collapse').click(function() {
  32. var btnTextCollapsed = $(this).data('btn-text-collapsed');
  33. var btnTextNotCollapsed = $(this).data('btn-text-not-collapsed');
  34. if(btnTextCollapsed !== '' && btnTextNotCollapsed !== '') {
  35. if($(this).hasClass('collapsed')) {
  36. new_html = $(this).html().replace(btnTextCollapsed, btnTextNotCollapsed);
  37. } else {
  38. new_html = $(this).html().replace(btnTextNotCollapsed, btnTextCollapsed);
  39. }
  40. $(this).html(new_html);
  41. }
  42. });
  43. /**
  44. * change text during btn-toggle click if possible
  45. */
  46. $('.btn-toggle .btn').click(function() {
  47. var btnClass = 'btn-' + $(this).data('btn-class');
  48. var btnLabelDefault = $(this).data('btn-label-default');
  49. var btnLabelToggled = $(this).data('btn-label-toggled');
  50. if(btnLabelToggled !== '') {
  51. if($(this).hasClass('btn-default')) {
  52. new_html = $(this).html().replace(btnLabelDefault, btnLabelToggled);
  53. } else {
  54. new_html = $(this).html().replace(btnLabelToggled, btnLabelDefault);
  55. }
  56. $(this).html(new_html);
  57. }
  58. $(this).toggleClass(btnClass);
  59. $(this).toggleClass('btn-default');
  60. });
  61. /**
  62. * change text during btn-toggle click if possible
  63. */
  64. $('.media-loader').click(function() {
  65. var target = $(this).data('target');
  66. var iframe_load = $(target + ' > iframe');
  67. var srctest = iframe_load.attr('src');
  68. if(srctest === undefined || srctest === false){
  69. iframe_load.attr('src', iframe_load.data('src'));
  70. }
  71. });
  72. /**
  73. * Select or deselect every categories on double clic
  74. */
  75. $(".btn-sm").dblclick(function() {
  76. var btnClass = 'btn-' + $(this).data('btn-class'); // primary
  77. if($(this).hasClass('btn-default')) {
  78. $(".btn-sm > input").attr('checked', 'checked');
  79. $(".btn-sm > input").prop("checked", true);
  80. $(".btn-sm").addClass(btnClass);
  81. $(".btn-sm").addClass('active');
  82. $(".btn-sm").removeClass('btn-default');
  83. } else {
  84. $(".btn-sm > input").attr('checked', '');
  85. $(".btn-sm > input").removeAttr('checked');
  86. $(".btn-sm > input").checked = false;
  87. $(".btn-sm").removeClass(btnClass);
  88. $(".btn-sm").removeClass('active');
  89. $(".btn-sm").addClass('btn-default');
  90. }
  91. });
  92. });