function om_search_alter_form in OM Tools 6.2
OM Tools Search Form Alters
File
- tools/
search/ search.inc, line 66 - Search Tools
Code
function om_search_alter_form(&$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_theme_js = 0;
static $search_block_js = 0;
switch ($form_id) {
case "search_form":
if ($search_defaults['search_switch']) {
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']['#title']);
//$form['basic']['inline']['keys']['#default_value'] = $search_label_text;
$search_form_js++;
if ($search_form_js == 1) {
drupal_add_js("\n \$(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']['inline']['keys']['#size'] = $search_size;
$form['basic']['inline']['keys']['#attributes'] = array(
'title' => t($search_hover),
);
$form['basic']['inline']['submit']['#value'] = t($search_button);
}
break;
case "search_theme_form":
if ($search_defaults['search_theme_switch']) {
$search_theme_label = $search_defaults['search_theme_label'];
$search_theme_label_text = $search_defaults['search_theme_label_text'];
$search_theme_size = $search_defaults['search_theme_size'];
$search_theme_hover = $search_defaults['search_theme_hover'];
$search_theme_button = $search_defaults['search_theme_button'];
if ($search_theme_label) {
unset($form['search_theme_form']['#title']);
//$form['search_theme_form']['#default_value'] = $search_theme_label_text;
$search_theme_js++;
if ($search_theme_js == 1) {
drupal_add_js("\n \$(document).ready(function(){\n var searchKeywordText = \$('#search-theme-form input.form-text').val();\n var searchThemeLabelText = '" . $search_theme_label_text . "';\n if(searchKeywordText == '') {\n \$('#search-theme-form input.form-text').val(searchThemeLabelText);\n }\n \$('#search-theme-form input.form-text').click(function() {\n if (\$(this).val() == searchThemeLabelText) { \n \$(this).val(''); \n };\n });\n \$('#search-theme-form input.form-text').blur( function() {\n if ((\$(this).val() == searchThemeLabelText) || (\$(this).val() == '')) {\n \$(this).val(searchThemeLabelText);\n };\n }); \n }); \n // Submit Search Keyword\n \$('#search-theme-form input.form-submit').click(function() {\n\t searchKeywordText = \$('#search-theme-form input.form-text').val();\n\t if(searchKeywordText == searchThemeLabelText) {\n\t \$('#search-theme-form input.form-text').val('');\n\t }\n }); \n ", "inline");
}
}
else {
$form['search_theme_form']['#title'] = $search_theme_label_text;
}
$form['search_theme_form']['#size'] = $search_theme_size;
$form['search_theme_form']['#attributes'] = array(
'title' => t($search_theme_hover),
);
$form['submit']['#value'] = t($search_theme_button);
}
break;
case "search_block_form":
if ($search_defaults['search_block_switch']) {
$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 \$(document).ready(function(){\n var searchKeywordText = \$('form#search-block-form input.form-text').val();\n var searchBlockLabelText = '" . $search_block_label_text . "';\n if (searchKeywordText == '') {\n \$('form#search-block-form input.form-text').val(searchBlockLabelText);\n }\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['submit']['#value'] = t($search_block_button);
}
break;
}
}