1/** 2 * @file 3 * Main js file for ep_blocks module. 4 */ 5(function ($, Drupal) { 6 Drupal.behaviors.ep_blocks = { 7 attach: function(context, settings) { 8 var homeSearchForm = '#homepage-search-form '; 9 // Default, disable the search button from homepage search form. 10 $(homeSearchForm + '.homepage-search-button ').attr('disabled', 'disabled'); 11 12 $(document).ajaxStart(function() { 13 $(homeSearchForm + '.homepage-search-button ').attr('disabled', 'disabled'); 14 }); 15 $(document).ajaxStop(function() { 16 // If ajax stop, check if user has wrote something in search input, to activate the search button. 17 if (($(homeSearchForm + 'input[name="search_input"]').val().trim()).length > 2) { 18 $(homeSearchForm + '.homepage-search-button ').attr('disabled', false); 19 } 20 }); 21 22 // When return from search, check if search input is not empty, to enable the search button. 23 if (($(homeSearchForm + 'input[name="search_input"]').val().trim()).length > 2) { 24 $(homeSearchForm + '.homepage-search-button').attr('disabled', false); 25 } 26 // Check if user write min 3 char in search input to enable the search button 27 $(homeSearchForm + 'input[name="search_input"]', context).keyup(function (e) { 28 $(homeSearchForm + '.homepage-search-button').attr('disabled', 'disabled'); 29 if (($(this).val().trim()).length > 2) { 30 $(homeSearchForm + '.homepage-search-button').attr('disabled', false); 31 } 32 }); 33 // Check if user paste a text in search input to enable the search button. 34 $(homeSearchForm + 'input[name="search_input"]', context).on('paste', function () { 35 $(homeSearchForm + '.homepage-search-button').attr('disabled', 'disabled'); 36 var that = this; 37 setTimeout(function() { 38 // Gets the copied text after a specified time (100 milliseconds). 39 if (($(that).val().trim()).length > 2) { 40 $(homeSearchForm + '.homepage-search-button').attr('disabled', false); 41 } 42 }, 100); 43 }); 44 } 45 } 46})(jQuery, Drupal);
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.