PageSourceSearch

https://oszk.hu/sites/default/modules/custom_search/js/custom_search.js?X

js oszk.hu collected 2026-09-24 08:39:57 UTC 4,377 bytes, 113 lines download raw bytes

1;(function($) {
2
3  Drupal.behaviors.custom_search = function (context) {
4
5    if (!Drupal.settings.custom_search.solr) {
6      // Check if the search box is not empty on submit
7      $('form.search-form', context).submit(function(){
8        var box = $(this).find('input.custom-search-box');
9        if (box.val() != undefined && (box.val() == '' || box.val() == $(this).find('input.default-text').val())) {
10          $(this).find('input.custom-search-box').addClass('error');
11          return false;
12        }
13        // If basic search is hidden, copy or value to the keys
14        if ($(this).find('#edit-keys').parents('div.element-invisible').attr('class') == 'element-invisible') {
15          $(this).find('#edit-keys').val($(this).find('#edit-or').val());
16          $(this).find('#edit-or').val('');
17        }
18        return true;
19      });
20    }
21
22    // Search from target
23    $('form.search-form').attr('target', Drupal.settings.custom_search.form_target);
24
25    // Clear default text on focus, and put it back on blur. Also displays Popup.
26    $('input.custom-search-box', context)
27      .blur(function(e){
28        var $this = $(this);
29        var $parentForm = $this.parents('form');
30        if ($this.val() == '') {
31          $this.addClass('custom-search-default-value');
32          $this.val($parentForm.find('input.default-text').val());
33        }
34      })
35      .bind('click focus', function(e){
36        var $this = $(this);
37        var $parentForm = $this.parents('form');
38        if ($this.val() == $parentForm.find('input.default-text').val()) $this.val('');
39        $this.removeClass('custom-search-default-value');
40        // check if there's something in the popup and displays it
41        var popup = $parentForm.find('fieldset.custom_search-popup');
42        if (popup.find('input,select').length && !popup.hasClass('opened')) popup.fadeIn().addClass('opened');
43        e.stopPropagation();
44      }
45    );
46    $(document).bind('click focus', function(){
47      $('fieldset.custom_search-popup').hide().removeClass('opened');
48    });
49
50    // Handle checkboxes
51    $('.custom-search-selector input:checkbox', context).each(function(){
52      var el = $(this);
53      if (el.val() == 'c-all') {
54        el.change(function(){
55          $(this).parents('.custom-search-selector').find('input:checkbox[value!=c-all]').attr('checked', false);
56        });
57      }
58      else {
59        if (el.val().substr(0,2) == 'c-') {
60          el.change(function(){
61            $('.custom-search-selector input:checkbox').each(function(){
62              if ($(this).val().substr(0,2) == 'o-') $(this).attr('checked', false);
63            });
64            $(this).parents('.custom-search-selector').find('input:checkbox[value=c-all]').attr('checked', false);
65          });
66        } else {
67          el.change(function(){
68            $(this).parents('.custom-search-selector').find('input:checkbox[value!='+el.val()+']').attr('checked', false);
69          });
70        }
71      }
72    });
73
74    // Reselect types and terms in advanced search
75    var edit_keys = $('#edit-keys').val();
76    if(edit_keys) {
77      // types
78      var pos = edit_keys.indexOf('type:');
79      if (pos) {
80        var pos2 = edit_keys.indexOf(' ',pos);
81        if (pos2==-1) pos2 = edit_keys.length;
82        var types = edit_keys.substring(pos+5,pos2);
83        types = types.split(',');
84        for (var i=0; i<types.length; i++) {
85          $('.search-form input:checkbox[value='+types[i]+']').attr('checked', true);
86        }
87      }
88      // terms
89      var pos = edit_keys.indexOf('category:');
90      if (pos) {
91        var pos2 = edit_keys.indexOf(' ',pos);
92        if (pos2==-1) pos2 = edit_keys.length;
93        var terms = edit_keys.substring(pos+9,pos2);
94        terms = terms.split(',');
95        for (var i=0; i<terms.length; i++) {
96          $('.search-form option[value='+terms[i]+']').attr('selected', true);
97        }
98      }
99    }
100
101    var popup = $('fieldset.custom_search-popup:not(.custom_search-processed)', context).addClass("custom_search-processed");
102    popup.click(function(e){
103      e.stopPropagation();
104    })
105    popup.append('<a class="custom_search-popup-close" href="#">
105' + Drupal.t('Close') + '</a>');
106    $('a.custom_search-popup-close').click(function(e){
107      $('fieldset.custom_search-popup.opened').hide().removeClass('opened');
108      e.preventDefault();
109    });
110
111  }
112
113}(jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.