Commit d48226c7 authored by Ghada El-Zoghbi's avatar Ghada El-Zoghbi Committed by Kristina Hoeppner

bug#1605067: improve accessibility by adding text placeholders for:

1. search text at the top menu
2. search text for users
3. search text for elasticsearch
4. search text for institutions

Thus, eliminating the need for the emptyonfocus class and its
related jquery code to hide the default text.

behatnotneeded

Change-Id: I57b9fcac4f9fd758b7048b8567101f28dcc48cff
parent f802140f
......@@ -618,8 +618,8 @@ else {
'type' => 'text',
'defaultvalue' => $query,
'hiddenlabel' => true,
'value' => get_string('search'),
'class' => 'emptyonfocus',
'value' => '',
'placeholder' => get_string('search'),
'title' => get_string('search'),
),
'submit' => array(
......
......@@ -439,20 +439,12 @@ function basename(path) {
// Autofocus the first element with a class of 'autofocus' on page load (@todo: move this to pieforms.js)
// Also, connect input elements with the 'emptyonfocus' class to work properly
addLoadEvent(function() {
var element = getFirstElementByTagAndClassName(null, 'autofocus', document.body);
if ( element && typeof(element.focus) == 'function' ) {
element.focus();
}
forEach(getElementsByTagAndClassName('input', 'emptyonfocus'), function(elem) {
elem.emptyonfocusSignal = connect(elem, 'onfocus', function(e) { elem.value = ''; e.stop(); if (elem.emptyonfocusSignal) { disconnect(elem.emptyonfocusSignal); } if (elem.emptyonfocusSignalForm) { disconnect(elem.emptyonfocusSignalForm); } });
if (elem.form) {
elem.emptyonfocusSignalForm = connect(elem.form, 'onsubmit', function(e) { elem.value = ''; if (elem.emptyonfocusSignal) { disconnect(elem.emptyonfocusSignal); } if (elem.emptyonfocusSignalForm) { disconnect(elem.emptyonfocusSignalForm); } });
}
});
});
// Contextual Help
......
......@@ -134,9 +134,9 @@ class PluginSearchElasticsearch extends PluginSearch {
'elements' => array(
'query' => array(
'type' => 'text',
'defaultvalue' => get_string('pagetitle', 'search.elasticsearch'),
'defaultvalue' => '',
'title' => get_string('pagetitle', 'search.elasticsearch'),
'class' => 'emptyonfocus',
'placeholder' => get_string('pagetitle', 'search.elasticsearch'),
'hiddenlabel' => true,
),
'submit' => array(
......
......@@ -237,9 +237,9 @@ abstract class PluginSearch extends Plugin implements IPluginSearch {
'elements' => array(
'query' => array(
'type' => 'text',
'defaultvalue' => get_string('searchusers'),
'defaultvalue' => '',
'title' => get_string('searchusers'),
'class' => 'emptyonfocus',
'placeholder' => get_string('searchusers'),
'hiddenlabel' => true,
),
'submit' => array(
......
......@@ -70,6 +70,7 @@ $searchform['elements']['inputgroup']['elements']['query'] = array(
'title' => get_string('search'),
'hiddenlabel' => true,
'defaultvalue' => $query,
'placeholder' => get_string('searchusers'),
);
$searchform['elements']['inputgroup']['elements']['submit'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment