function om_search_alter in OM Tools 8.2
Same name and namespace in other branches
- 8 tools/search/search.inc \om_search_alter()
- 6 tools/search/search.inc \om_search_alter()
- 7.2 tools/search/search.inc \om_search_alter()
- 7 tools/search/search.inc \om_search_alter()
OM Tools Search Form Alters
File
- tools/
search/ search.inc, line 56 - Search Tools
Code
function om_search_alter(&$form, &$form_state, $form_id) {
$search_defaults = $form['om_search_tools_values']['#value'];
// Make sure the js are added only once
static $search_form_js = 0;
static $search_block_js = 0;
switch ($form_id) {
case "search_form":
if (isset($search_defaults['search_switch']) && $search_defaults['search_switch'] == 1) {
drupal_set_title(t($search_defaults['search_title']));
$search_label = $search_defaults['search_label'];
$search_label_text = $search_defaults['search_label_text'];
$search_size = $search_defaults['search_size'];
$search_hover = $search_defaults['search_hover'];
$search_button = $search_defaults['search_button'];
if ($search_label) {
unset($form['basic']['keys']['#title']);
//$form['basic']['keys']['#default_value'] = $search_label_text;
$search_form_js++;
if ($search_form_js == 1) {
drupal_add_js("\n jQuery(document).ready(function(\$){\n var searchKeywordText = \$('form#search-form input#edit-keys').val();\n var searchLabelText = '" . $search_label_text . "';\n if(searchKeywordText == '') {\n \$('form#search-form input#edit-keys').val(searchLabelText);\n }\n \$('form#search-form input#edit-keys').click(function() {\n if (\$(this).val() == searchLabelText) { \n \$(this).val(''); \n };\n });\n \$('form#search-form input#edit-keys').blur( function() {\n if ((\$(this).val() == searchLabelText) || (\$(this).val() == '')) {\n \$(this).val(searchLabelText);\n };\n });\n // Submit Search Keyword\n \$('form#search-form #edit-basic input.form-submit').click(function() {\n\t searchKeywordText = \$('form#search-form input#edit-keys').val();\n\t if(searchKeywordText == searchLabelText) {\n\t \$('form#search-form input#edit-keys').val('');\n\t }\n }); \n }); \n ", "inline");
}
}
else {
$form['basic']['#title'] = $search_label_text;
}
$form['basic']['keys']['#size'] = $search_size;
$form['basic']['keys']['#attributes'] = array(
'title' => t($search_hover),
);
$form['basic']['submit']['#value'] = t($search_button);
}
break;
case "search_block_form":
if (isset($search_defaults['search_block_switch']) && $search_defaults['search_block_switch'] == 1) {
$search_block_label = $search_defaults['search_block_label'];
$search_block_label_text = $search_defaults['search_block_label_text'];
$search_block_size = $search_defaults['search_block_size'];
$search_block_hover = $search_defaults['search_block_hover'];
$search_block_button = $search_defaults['search_block_button'];
if ($search_block_label) {
unset($form['search_block_form']['#title']);
//$form['search_block_form']['#default_value'] = $search_block_label_text;
$search_block_js++;
if ($search_block_js == 1) {
drupal_add_js("\n jQuery(document).ready(function(\$){\n var searchKeywordText = \$('form#search-block-form input.form-text').val();\n var searchBlockLabelText = '" . $search_block_label_text . "';\n \$('form#search-block-form input.form-text').val(searchBlockLabelText);\n \$('form#search-block-form input.form-text').click(function() {\n if (\$(this).val() == searchBlockLabelText) { \n \$(this).val(''); \n };\n });\n \$('form#search-block-form input.form-text').blur( function() {\n if ((\$(this).val() == searchBlockLabelText) || (\$(this).val() == '')) {\n \$(this).val(searchBlockLabelText);\n };\n }); \n // Submit Search Keyword\n \$('form#search-block-form input.form-submit').click(function() {\n\t searchKeywordText = \$('form#search-block-form input.form-text').val();\n\t if(searchKeywordText == searchBlockLabelText) {\n\t \$('form#search-block-form input.form-text').val('');\n\t }\n }); \n }); \n ", "inline");
}
}
else {
$form['search_block_form']['#title'] = $search_block_label_text;
}
$form['search_block_form']['#size'] = $search_block_size;
$form['search_block_form']['#attributes'] = array(
'title' => t($search_block_hover),
);
$form['actions']['submit']['#value'] = t($search_block_button);
}
break;
}
}