| 1 |
// $Id: livesearch.js,v 1.15 2007/07/21 05:07:00 kourge Exp $ |
// $Id: livesearch.js,v 1.16 2008/01/20 19:49:54 kourge Exp $ |
| 2 |
if (Drupal.jsEnabled) { // global killswitch |
if (Drupal.jsEnabled) { // global killswitch |
| 3 |
(function($) { // Dollar namespace scoping |
(function($) { // Dollar namespace scoping |
| 4 |
Drupal.LiveSearch = { |
Drupal.LiveSearch = { |
| 55 |
return false; |
return false; |
| 56 |
}); |
}); |
| 57 |
// Scroll to the top of the search results. |
// Scroll to the top of the search results. |
| 58 |
if (settings.scrollToResults) {scrollTo(target.get(0));} |
if (settings.scrollToResults) { |
| 59 |
|
scrollTo(target.get(0)); |
| 60 |
|
} |
| 61 |
}); |
}); |
| 62 |
}, |
}, |
| 63 |
|
|
| 77 |
$(document).ready(function() { |
$(document).ready(function() { |
| 78 |
var settings = Drupal.settings.liveSearch; |
var settings = Drupal.settings.liveSearch; |
| 79 |
// User permission killswitch |
// User permission killswitch |
| 80 |
if (!settings.searchAllowed) {return;} |
if (!settings.searchAllowed) { |
| 81 |
|
return; |
| 82 |
|
} |
| 83 |
var type = settings.targetSearchBox || 'auto'; |
var type = settings.targetSearchBox || 'auto'; |
| 84 |
var searchBox = $('#edit-search-' + type + '-form-keys'); |
var searchBox = $('#edit-search-' + type + '-form-keys'); |
| 85 |
var searchForm = $('form#search-' + type + '-form'); |
var searchForm = $('form#search-' + type + '-form'); |
| 86 |
if (type == 'auto') { |
if (type == 'auto') { |
| 87 |
searchBox = $('#edit-search-block-form-keys, #edit-search-theme-form-keys, #search-box, #searchbox'); |
searchBox = $('#edit-search-block-form-keys, #edit-search-theme-form-keys, #search-box, #searchbox'); |
| 88 |
if (searchBox.length == 0) {return;} |
if (searchBox.length == 0) { |
| 89 |
|
return; |
| 90 |
|
} |
| 91 |
searchBox = $(searchBox[0]); |
searchBox = $(searchBox[0]); |
| 92 |
searchForm = $(searchBox).parents('form'); |
searchForm = $(searchBox).parents('form'); |
| 93 |
} |
} |
| 94 |
var localizedTerm; |
var localizedTerm; |
| 95 |
|
|
| 96 |
// Search box killswitch, in case a search block is optionally visible. |
// Search box killswitch, in case a search block is optionally visible. |
| 97 |
if (searchBox.length == 0) {return;} |
if (searchBox.length == 0) { |
| 98 |
|
return; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
Drupal.LiveSearch.localizedTerm = localizedTerm = |
Drupal.LiveSearch.localizedTerm = localizedTerm = |
| 102 |
$('input[@type=submit]', searchForm).val(); |
$('input[@type=submit]', searchForm).val() || "Search"; |
| 103 |
|
|
| 104 |
searchForm.addClass('live-search'); |
searchForm.addClass('live-search'); |
| 105 |
|
|
| 110 |
} |
} |
| 111 |
var target = $('#' + Drupal.LiveSearch.id).hide(); |
var target = $('#' + Drupal.LiveSearch.id).hide(); |
| 112 |
|
|
| 113 |
if (settings.hideSnippets) {target.addClass('hide-snippet');} |
if (settings.hideSnippets) { |
| 114 |
|
target.addClass('hide-snippet'); |
| 115 |
|
} |
| 116 |
target.addClass(settings.showItemInfo ? 'show-item-info' : 'hide-item-info'); |
target.addClass(settings.showItemInfo ? 'show-item-info' : 'hide-item-info'); |
| 117 |
|
|
| 118 |
// Apple HIG fans should appreciate this option. |
// Apple HIG fans should appreciate this option. |
| 131 |
}); |
}); |
| 132 |
} |
} |
| 133 |
|
|
| 134 |
searchBox. |
searchBox.addClass('form-autocomplete'). |
| 135 |
addClass('form-autocomplete'). |
keyup(Drupal.LiveSearch.eventListener). |
| 136 |
keyup(Drupal.LiveSearch.eventListener). |
attr('autocomplete', 'off'); |
|
attr('autocomplete', 'off'); |
|
| 137 |
}); |
}); |
| 138 |
})(jQuery); // End dollar namespace scoping |
})(jQuery); // End dollar namespace scoping |
| 139 |
} // End global killswitch |
} // End global killswitch |