1/** 2 * @file 3 * better_exposed_filters.js 4 * 5 * Provides some client-side functionality for the Better Exposed Filters module. 6 */ 7 8(function ($, Drupal, drupalSettings) { 9 Drupal.behaviors.betterExposedFilters = { 10 attach: function (context, settings) { 11 // Add highlight class to checked checkboxes for better theming. 12 $('.bef-tree input[type=checkbox], .bef-checkboxes input[type=checkbox]') 13 // Highlight newly selected checkboxes. 14 .change(function () { 15 _bef_highlight(this, context); 16 }) 17 .filter(':checked').closest('.form-item', context).addClass('highlight'); 18 } 19 }; 20 21 /* 22 * Helper functions 23 */ 24 25 /** 26 * Adds/Removes the highlight class from the form-item div as appropriate. 27 */ 28 function _bef_highlight(elem, context) { 29 $elem = $(elem, context); 30 $elem.attr('checked') 31 ? $elem.closest('.form-item', context).addClass('highlight') 32 : $elem.closest('.form-item', context).removeClass('highlight'); 33 } 34 35})(jQuery, Drupal, drupalSettings); 36; 37/** 38* DO NOT EDIT THIS FILE. 39* See the following change record for more information, 40* https://www.drupal.org/node/2815083 41* @preserve 42**/ 43 44Drupal.debounce = function (func, wait, immediate) { 45 var timeout = void 0; 46 var result = void 0; 47 return function () { 48 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 49 args[_key] = arguments[_key]; 50 } 51 52 var context = this; 53 var later = function later() { 54 timeout = null; 55 if (!immediate) { 56 result = func.apply(context, args); 57 } 58 }; 59 var callNow = immediate && !timeout; 60 clearTimeout(timeout); 61 timeout = setTimeout(later, wait); 62 if (callNow) { 63 result = func.apply(context, args); 64 } 65 return result; 66 }; 67};; 68/** 69 * @file 70 * auto_submit.js 71 * 72 * Provides a "form auto-submit" feature for the Better Exposed Filters module. 73 */ 74 75(function ($, Drupal) { 76 77 /** 78 * To make a form auto submit, all you have to do is 3 things:. 79 * 80 * Use the "better_exposed_filters/auto_submit" js library. 81 * 82 * On gadgets you want to auto-submit when changed, add the 83 * data-bef-auto-submit attribute. With FAPI, add: 84 * @code 85 * '#attributes' => array('data-bef-auto-submit' => ''), 86 * @endcode 87 * 88 * If you want to have auto-submit for every form element, add the 89 * data-bef-auto-submit-full-form to the form. With FAPI, add: 90 * @code 91 * '#attributes' => array('data-bef-auto-submit-full-form' => ''), 92 * @endcode 93 * 94 * If you want to exclude a field from the bef-auto-submit-full-form auto 95 * submission, add an attribute of data-bef-auto-submit-exclude to the form 96 * element. With FAPI, add: 97 * @code 98 * '#attributes' => array('data-bef-auto-submit-exclude' => ''), 99 * @endcode 100 * 101 * Finally, you have to identify which button you want clicked for autosubmit. 102 * The behavior of this button will be honored if it's ajaxy or not: 103 * @code 104 * '#attributes' => array('data-bef-auto-submit-click' => ''), 105 * @endcode 106 * 107 * Currently only 'select', 'radio', 'checkbox' and 'textfield' types are 108 * supported. We probably could use additional support for HTML5 input types. 109 */ 110 Drupal.behaviors.betterExposedFiltersAutoSubmit = { 111 attach: function (context) { 112 // When exposed as a block, the form #attributes are moved from the form 113 // to the block element, thus the second selector. 114 // @see \Drupal\block\BlockViewBuilder::preRender 115 var selectors = 'form[data-bef-auto-submit-full-form], [data-bef-auto-submit-full-form] form, [data-bef-auto-submit]'; 116 117 // The change event bubbles so we only need to bind it to the outer form 118 // in case of a full form, or a single element when specified explicitly. 119 $(selectors, context).addBack(selectors).each(function (i, e) { 120 // Store the current form. 121 var $form = $(e); 122 123 // Retrieve the autosubmit delay for this particular form.
124 var autoSubmitDelay = $form.data('bef-auto-submit-delay') || 500; 125 126 // Attach event listeners. 127 $form.once('bef-auto-submit') 128 // On change, trigger the submit immediately. 129 .on('change', triggerSubmit) 130 // On keyup, wait for a specified number of milliseconds before 131 // triggering autosubmit. Each new keyup event resets the timer. 132 .on('keyup', Drupal.debounce(triggerSubmit, autoSubmitDelay)); 133 }); 134 135 /** 136 * Triggers form autosubmit when conditions are right. 137 * 138 * - Checks first that the element that was the target of the triggering 139 * event is `:text` or `textarea`, but is not `.hasDatePicker`. 140 * - Checks that the keycode of the keyup was not in the list of ignored 141 * keys (navigation keys etc). 142 * 143 * @param {object} e - The triggering event. 144 */ 145 function triggerSubmit(e) { 146 // e.keyCode: key. 147 var ignoredKeyCodes = [ 148 16, // Shift. 149 17, // Ctrl. 150 18, // Alt. 151 20, // Caps lock. 152 33, // Page up. 153 34, // Page down. 154 35, // End. 155 36, // Home. 156 37, // Left arrow. 157 38, // Up arrow. 158 39, // Right arrow. 159 40, // Down arrow. 160 9, // Tab. 161 13, // Enter. 162 27 // Esc. 163 ]; 164 165 // Triggering element. 166 var $target = $(e.target); 167 var $submit = $target.closest('form').find('[data-bef-auto-submit-click]'); 168 169 // Don't submit on changes to excluded elements or a submit element. 170 if ($target.is('[data-bef-auto-submit-exclude], :submit') || ($target.attr('autocomplete') == 'off' && !$target.hasClass('bef-datepicker'))) { 171 return true; 172 } 173 174 // Submit only if this is a non-datepicker textfield and if the 175 // incoming keycode is not one of the excluded values. 176 if ( 177 $target.is(':text:not(.hasDatepicker), textarea') 178 && $.inArray(e.keyCode, ignoredKeyCodes) === -1 179 ) { 180 $submit.click(); 181 } 182 // Only trigger submit if a change was the trigger (no keyup). 183 else if (e.type === 'change') { 184 $submit.click(); 185 } 186 } 187 } 188 } 189 190}(jQuery, Drupal)); 191; 192/** 193 * @file 194 * Adds Google Custom Search Watermark. 195 */ 196 197(function ($, Drupal, drupalSettings) { 198 'use strict'; 199 200 Drupal.behaviors.googleCSECustomSearch = { 201 attach: function (context, settings) { 202 var getWatermarkBackground = function (value) { 203 var googleCSEBaseUrl = 'https://www.google.com/cse/intl/'; 204 var googleCSEImageUrl = 'images/google_custom_search_watermark.gif'; 205 var language = drupalSettings.googleCSE.language + '/'; 206 return value ? '' : ' url(' + googleCSEBaseUrl + language + googleCSEImageUrl + ') left no-repeat'; 207 }; 208 var onFocus = function (e) { 209 $(e.target).css('background', '#ffffff'); 210 }; 211 var onBlur = function (e) { 212 $(e.target).css('background', '#ffffff' + getWatermarkBackground($(e.target).val())); 213 }; 214 var googleCSEWatermark = function (context, query) { 215 var form = jQuery(context); 216 var searchInputs = $('[data-drupal-selector="' + query + '"]', form); 217 if (navigator.platform === 'Win32') { 218 searchInputs.css('style', 'border: 1px solid #7e9db9; padding: 2px;'); 219 } 220 searchInputs.blur(onBlur); 221 searchInputs.focus(onFocus); 222 searchInputs.each(function () { 223 var event = {}; 224 event.target = this; 225 onBlur(event); 226 }); 227 }; 228 229 googleCSEWatermark('[data-drupal-selector="search-block-form"] [data-drupal-form-fields="edit-keys--2"]', 'edit-keys'); 230 googleCSEWatermark('[data-drupal-selector="search-block-form"] [data-drupal-form-fields="edit-keys"]', 'edit-keys'); 231 googleCSEWatermark('[data-drupal-selector="search-form"]', 'edit-keys'); 232 googleCSEWatermark('[data-drupal-selector="google-cse-search-box-form"]', 'edit-query'); 233 } 234 }; 235})(jQuery, Drupal, drupalSettings); 236;
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.