ENHANCEMENT Allow opt-out of autofocus in CMS editor form, to avoid browser "auto scrolling" to bring the focused element into view (fixes #7242)

This commit is contained in:
Ingo Schommer 2012-05-02 18:27:45 +02:00
parent 8c1053968c
commit e29bb3c390
2 changed files with 6 additions and 3 deletions

View File

@ -64,8 +64,11 @@
// in order to avoid changing the menu state if the action is cancelled by the user // in order to avoid changing the menu state if the action is cancelled by the user
// $('.cms-menu') // $('.cms-menu')
// focus input on first form element // focus input on first form element. Exclude elements which
this.find(':input:visible:not(:submit):first').focus(); // specifically opt-out of this behaviour via "data-skip-autofocus".
// This opt-out is useful if the first visible field is shown far down a scrollable area,
// for example for the pagination input field after a long GridField listing.
this.find(':input:visible:not(:submit)[data-skip-autofocus!="true"]:first').focus();
// Optionally get the form attributes from embedded fields, see Form->formHtmlContent() // Optionally get the form attributes from embedded fields, see Form->formHtmlContent()
for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) { for(var overrideAttr in {'action':true,'method':true,'enctype':true,'name':true}) {

View File

@ -1,7 +1,7 @@
<tr> <tr>
<td class="bottom-all" colspan="$Colspan"> <td class="bottom-all" colspan="$Colspan">
<div class="datagrid-pagination"> <div class="datagrid-pagination">
$FirstPage $PreviousPage <span class="pagination-page-number">Page <input class="text" value="$CurrentPageNum"/> of $NumPages</span> $NextPage $LastPage $FirstPage $PreviousPage <span class="pagination-page-number">Page <input class="text" value="$CurrentPageNum" data-skip-autofocus="true" /> of $NumPages</span> $NextPage $LastPage
</div> </div>
<span class="pagination-records-number">View $FirstShownRecord - $LastShownRecord of $NumRecords</span> <span class="pagination-records-number">View $FirstShownRecord - $LastShownRecord of $NumRecords</span>