1 2Drupal.behaviors.custom_search = function (context) { 3 4 if (!Drupal.settings.custom_search.solr) { 5 6 // Check if the search box is not empty on submit 7 $('form.search-form', context).submit(function(e){ 8 9 var box = $(this).find('input.custom-search-box'); 10 if (box.val() != undefined && (box.val() == '' || box.val() == $(this).find('input.default-text').val())) { 11 //$(this).find('input.custom-search-box').addClass('error'); 12 13 // This has been added by Dilendra 14 box.val('recipes'); 15 16 //return false; 17 } 18 // If basic search is hidden, copy or value to the keys 19 if ($(this).find('#edit-keys').parents('div.element-invisible').attr('class') == 'element-invisible') { 20 $(this).find('#edit-keys').val($(this).find('#edit-or').val()); 21 $(this).find('#edit-or').val(''); 22 } 23 return true; 24 25 }); 26 27 28 29 } 30 31 // Search from target 32 $('form.search-form').attr('target', Drupal.settings.custom_search.form_target); 33 34 // Clear default text on focus, and put it back on blur. Also displays Popup. 35 $('input.custom-search-box', context) 36 .blur(function(e){ 37 $this = $(this); 38 $parentForm = $this.parents('form'); 39 if ($this.val() == '') { 40 $this.addClass('custom-search-default-value'); 41 $this.val($parentForm.find('input.default-text').val()); 42 } 43 }) 44 .bind('click focus', function(e){ 45 $this = $(this); 46 $parentForm = $this.parents('form'); 47 if ($this.val() == $parentForm.find('input.default-text').val()) $this.val(''); 48 $this.removeClass('custom-search-default-value'); 49 // check if there's something in the popup and displays it 50 var popup = $parentForm.find('fieldset.custom_search-popup'); 51 if (popup.find('input,select').length && !popup.hasClass('opened')){ //popup.fadeIn().addClass('opened'); 52 } 53 e.stopPropagation(); 54 } 55 ); 56 $(document).bind('click focus', function(){ 57 //$('fieldset.custom_search-popup').hide().removeClass('opened'); 58 }); 59 60 // Handle checkboxes 61 $('.custom-search-selector input:checkbox', context).each(function(){ 62 var el = $(this); 63 if (el.val() == 'c-all') { 64 el.change(function(){ 65 $(this).parents('.custom-search-selector').find('input:checkbox[value!=c-all]').attr('checked', false); 66 }); 67 } 68 else { 69 if (el.val().substr(0,2) == 'c-') { 70 el.change(function(){ 71 $('.custom-search-selector input:checkbox').each(function(){ 72 if ($(this).val().substr(0,2) == 'o-') $(this).attr('checked', false); 73 }); 74 $(this).parents('.custom-search-selector').find('input:checkbox[value=c-all]').attr('checked', false); 75 }); 76 } else { 77 el.change(function(){ 78 $(this).parents('.custom-search-selector').find('input:checkbox[value!='+el.val()+']').attr('checked', false); 79 }); 80 } 81 } 82 }); 83 84 // Reselect types and terms in advanced search 85 var edit_keys = $('#edit-keys').val(); 86 if(edit_keys) { 87 // types 88 var pos = edit_keys.indexOf('type:'); 89 if (pos) { 90 var pos2 = edit_keys.indexOf(' ',pos); 91 if (pos2==-1) pos2 = edit_keys.length; 92 var types = edit_keys.substring(pos+5,pos2); 93 types = types.split(','); 94 for (var i=0; i<types.length; i++) { 95 $('.search-form input:checkbox[value='+types[i]+']').attr('checked', true); 96 } 97 } 98 // terms 99 var pos = edit_keys.indexOf('category:'); 100 if (pos) { 101 var pos2 = edit_keys.indexOf(' ',pos); 102 if (pos2==-1) pos2 = edit_keys.length; 103 var terms = edit_keys.substring(pos+9,pos2); 104 terms = terms.split(','); 105 for (var i=0; i<terms.length; i++) { 106 $('.search-form option[value='+terms[i]+']').attr('selected', true); 107 } 108 } 109 } 110 111 var popup = $('fieldset.custom_search-popup:not(.custom_search-processed)', context).addClass("custom_search-processed"); 112 popup.click(function(e){ 113 e.stopPropagation(); 114 }) 115 popup.append('<a class="custom_search-popup-close" href="#">' + Drupal.t('Close') + '</a>'); 116 $('a.custom_search-popup-close').click(function(e){ 117 $('fieldset.custom_search-popup.opened').hide().removeClass('opened'); 118 e.preventDefault(); 119 }); 120 121} 122 123 124function displayPopup() 125{ 126 127 128 var ad_button = $('#advanced_search'); 129 $(ad_button).bind('click',function() { 130 131 var popup = $('#custom_search_blocks-4 fieldset.custom_search-popup'); 132 133 134 var popup_display_style = $(popup).attr('style').replace(' ',''); 135 popup_display_style = popup_display_style.replace(';',''); 136 137 if(popup_display_style == 'display:none') 138 { 139 $(popup).attr('style','display:block'); 140 } 141 else 142 {
143 $(popup).attr('style','display:none'); 144 } 145 146 147 //} 148 //$(popup).attr('style','display:block'); 149 150 151 }); 152 153 154 155 156 157 $('#custom_search_blocks-4 a.custom_search-popup-close').bind('click',function() { 158 var popup = $('#custom_search_blocks-4 fieldset.custom_search-popup'); 159 $(popup).attr('style','display:none'); 160 }); 161 162} 163 164function displayPopupSmall() 165{ 166 var ad_button_small = $('#advanced_search_small'); 167 $(ad_button_small).bind('click',function() { 168 169 var popup = $('#custom_search_blocks-5 fieldset.custom_search-popup'); 170 171 172 var popup_display_style = $(popup).attr('style').replace(' ',''); 173 popup_display_style = popup_display_style.replace(';',''); 174 175 if(popup_display_style == 'display:none') 176 { 177 $(popup).attr('style','display:block'); 178 } 179 else 180 { 181 $(popup).attr('style','display:none'); 182 } 183 184 185 186 187 }); 188 189 $('#custom_search_blocks-5 a.custom_search-popup-close').bind('click',function() { 190 var popup = $('#custom_search_blocks-5 fieldset.custom_search-popup'); 191 $(popup).attr('style','display:none'); 192 }); 193} 194 195$(document).ready(function() { 196 var popup = $('#custom_search_blocks-4 fieldset.custom_search-popup'); 197 $(popup).attr('style','display:none'); 198 displayPopup(); 199 200 var popup_small = $('#custom_search_blocks-5 fieldset.custom_search-popup'); 201 $(popup_small).attr('style','display:none'); 202 displayPopupSmall(); 203});
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.