[Rt-commit] rt branch, 4.2/focus-new-cf-value, created. rt-4.1.13-17-g640217b

Thomas Sibley trs at bestpractical.com
Mon Jun 17 17:41:52 EDT 2013


The branch, 4.2/focus-new-cf-value has been created
        at  640217ba9c6c859d0889436299d6d1b38c039ace (commit)

- Log -----------------------------------------------------------------
commit 7b3a7ef7781e463d3e7f52eae0f8e94556122e88
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Jun 17 14:35:42 2013 -0700

    Focus on page load using the full power of CSS selectors
    
    Limiting only to ids is annoying for elements without an id.
    
    Heuristics could be added to support the old style id-sans-leading-hash,
    but few extensions seem to use the Focus parameter or focusElementById()
    directly.  Dropping support and moving to standard selector notation is
    cleaner.

diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index caeed04..41efb8c 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -61,7 +61,7 @@ $onload => undef
 <script type="text/javascript"><!--
 jQuery( loadTitleBoxStates );
 % if ( $focus ) {
-    jQuery(function () { focusElementById(<% $focus |n,j%>) });
+    jQuery(function () { jQuery(<% $focus |n,j%>).focus() });
 % }
 % if ( $onload ) {
     jQuery( <% $onload |n %> );
diff --git a/share/html/Elements/Login b/share/html/Elements/Login
index c1b3588..faa0f29 100644
--- a/share/html/Elements/Login
+++ b/share/html/Elements/Login
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 % $m->callback( %ARGS, CallbackName => 'Header' );
-<& /Elements/Header, Title => loc('Login'), Focus => 'user', RichText => 0 &>
+<& /Elements/Header, Title => loc('Login'), Focus => '#user', RichText => 0 &>
 
 <div id="body" class="login-body">
 
diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index 91dc015..8debf79 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => loc('User Search'), Focus => 'autocomplete-UserString' &>
+<& /Elements/Header, Title => loc('User Search'), Focus => '#autocomplete-UserString' &>
 <& /Elements/Tabs &>
     
 <& /Elements/GotoUser, Default => $UserString||'' &>
diff --git a/share/static/js/util.js b/share/static/js/util.js
index bac04d1..8b91092 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -75,11 +75,6 @@ function set_rollup_state(e,e2,state) {
 
 /* other utils */
 
-function focusElementById(id) {
-    var e = jQuery('#'+id);
-    if (e) e.focus();
-}
-
 function setCheckbox(input, name, val) {
     if (val == null) val = input.checked;
 

commit 640217ba9c6c859d0889436299d6d1b38c039ace
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Jun 17 14:40:19 2013 -0700

    Refocus the new CF value name input after adding one
    
    This helps greatly when adding multiple values in a row.
    
    I thought we had this tiny feature in a previous version, but either it
    was removed or I was simply dreaming.

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 09ae729..e88a966 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -45,7 +45,12 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/Header,
+    Title => $title,
+    Focus => (($added_cfv or $ARGS{FocusAddValue})
+        ? "input[name=CustomField-$id-Value-new-Name]"
+        : undef),
+    &>
 <& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@results &>
 
@@ -152,7 +157,7 @@
 
 </form>
 <%INIT>
-my ($title, @results);
+my ($title, @results, $added_cfv);
 
 my $CustomFieldObj = RT::CustomField->new( $session{'CurrentUser'} );
 
@@ -273,6 +278,7 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
                 $_ => $ARGS{ $paramtag ."-new-$_" } } qw/ Name Description SortOrder Category/
         );
         push (@results, $msg);
+        $added_cfv = 1 if $id;
 
         my $cfv = RT::CustomFieldValue->new( $session{CurrentUser} );
         $cfv->Load($id);
@@ -301,7 +307,7 @@ $id = $CustomFieldObj->id if $CustomFieldObj->id;
 # This code does automatic redirection if any updates happen.
 MaybeRedirectForResults(
     Actions     => \@results,
-    Arguments   => { id => $id },
+    Arguments   => { id => $id, FocusAddValue => ($added_cfv ? 1 : 0) },
 ) if $CustomFieldObj->id;
 
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list