Commit 1ad1fb58 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Preselect title text in edit view form for new views


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 6dce0dc4
......@@ -445,6 +445,11 @@ class Pieform {/*{{{*/
$element['autofocus'] = true;
}
if (!empty($element['autofocus']) && $element['type'] == 'text' && !empty($this->data['autoselect'])
&& $name == $this->data['autoselect']) {
$element['autoselect'] = true;
}
// All elements inherit the form tabindex
$element['tabindex'] = $this->data['tabindex'];
}
......@@ -1049,6 +1054,9 @@ EOF;
if ($this->data['elementclasses']) {
$classes[] = $element['type'];
}
if (!empty($element['autoselect'])) {
$classes[] = 'autoselect';
}
// Please make sure that 'autofocus' is the last class added in this
// method. Otherwise, improve the logic for removing 'autofocus' from
// the element class string in pieform_render_element
......
......@@ -51,6 +51,10 @@ function PieformManager() {//{{{
var element = getFirstElementByTagAndClassName(null, 'autofocus', form);
if (element && (typeof(element.focus) == 'function' || (element.focus && element.focus.call))) {
element.focus();
if (hasElementClass(element, 'autoselect')
&& (typeof(element.select) == 'function' || (element.focus && element.select.call))) {
element.select();
}
throw MochiKit.Iter.StopIteration;
}
});
......
......@@ -85,6 +85,7 @@ $editview = array(
'name' => 'editview',
'method' => 'post',
'autofocus' => 'title',
'autoselect' => $new ? 'title' : null,
'plugintype' => 'core',
'pluginname' => 'view',
'elements' => 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