]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Created autofocus method to give focus to an element (primarily a form
authorSarven Capadisli <csarven@controlyourself.ca>
Thu, 3 Sep 2009 19:42:50 +0000 (19:42 +0000)
committerSarven Capadisli <csarven@controlyourself.ca>
Thu, 3 Sep 2009 19:42:50 +0000 (19:42 +0000)
control) on page onload.

Updated some of the pages to use autofocus.

19 files changed:
actions/avatarsettings.php
actions/editgroup.php
actions/emailsettings.php
actions/grouplogo.php
actions/groupsearch.php
actions/invite.php
actions/login.php
actions/noticesearch.php
actions/openidlogin.php
actions/openidsettings.php
actions/othersettings.php
actions/passwordsettings.php
actions/peoplesearch.php
actions/profilesettings.php
actions/register.php
actions/smssettings.php
actions/subscriptions.php
lib/designsettings.php
lib/htmloutputter.php

index 0bc439ff122a944f653ca8bd7978e38ec77d691a..02a684b38f2649c5e8d45a3d096114e631a8bf6d 100644 (file)
@@ -399,5 +399,7 @@ class AvatarsettingsAction extends AccountSettingsAction
             $this->script('js/jcrop/jquery.Jcrop.min.js');
             $this->script('js/jcrop/jquery.Jcrop.go.js');
         }
+
+        $this->autofocus('avatarfile');
     }
 }
index cac910e9bc56d96ca17580ed3a2494ee343ad19a..e7ba836a0153dfe79531c46fcb926d2655c6dc3a 100644 (file)
@@ -160,6 +160,12 @@ class EditgroupAction extends GroupDesignAction
         }
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('nickname');
+    }
+
     function trySave()
     {
         $cur = common_current_user();
index af528a892ef877556b02dc05b173a1171f612d2e..6eff06c0d667b66fc6056ed706a83a7141efb89a 100644 (file)
@@ -71,6 +71,12 @@ class EmailsettingsAction extends AccountSettingsAction
         return _('Manage how you get email from %%site.name%%.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('email');
+    }
+
     /**
      * Content area of the page
      *
index c6f376915ef2e44ef2c0696c2fe549c59da30bc1..63ba769c7a61feb5a2e5eb71d513859496123cdf 100644 (file)
@@ -445,6 +445,8 @@ class GrouplogoAction extends GroupDesignAction
             $this->script('js/jcrop/jquery.Jcrop.min.js');
             $this->script('js/jcrop/jquery.Jcrop.go.js');
         }
+
+        $this->autofocus('avatarfile');
     }
 
     function showLocalNav()
index bbd4c3a74aa89a471be744cf1331701aba11856c..be15efc47cea5c0be163b3095db9264b53328840 100644 (file)
@@ -91,6 +91,12 @@ class GroupsearchAction extends SearchAction
             $user_group->free();
         }
     }
+
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('q');
+    }
 }
 
 class GroupSearchResults extends GroupList
index ab43a2491d581edfb17120d50cbb32f02eb2b65c..9fa6a76f671f471a83b13b590db846401fd6b039 100644 (file)
@@ -98,6 +98,12 @@ class InviteAction extends CurrentUserDesignAction
         $this->showPage();
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('addresses');
+    }
+
     function title()
     {
         if ($this->mode == 'sent') {
index 37f3c54ffb95b770195cc94033a482ddaa65e46d..ac8c40c3e5f60e97cf98393204ff96ca79fc6fef 100644 (file)
@@ -22,6 +22,7 @@
  * @category  Login
  * @package   StatusNet
  * @author    Evan Prodromou <evan@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
  * @copyright 2008-2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
@@ -37,6 +38,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  * @category Personal
  * @package  StatusNet
  * @author   Evan Prodromou <evan@status.net>
+ * @author   Sarven Capadisli <csarven@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
@@ -162,6 +164,12 @@ class LoginAction extends Action
         $this->showPage();
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('nickname');
+    }
+
     /**
      * Title of the page
      *
index 1188e7e10fb3f881876e5e9eb37bcf0a9c230800..1cd987df39736be5a0638bbd851291d27958f056 100644 (file)
@@ -137,6 +137,12 @@ class NoticesearchAction extends SearchAction
         $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE,
                           $page, 'noticesearch', array('q' => $q));
     }
+
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('q');
+    }
 }
 
 class SearchNoticeList extends NoticeList {
index 4b53386943044c3d01b37d11cf9c0df0f86408d6..9b7deefb6366f7548035f78c405e8606c28e239f 100644 (file)
@@ -86,6 +86,12 @@ class OpenidloginAction extends Action
         }
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('openid_url');
+    }
+
     function title()
     {
         return _('OpenID Login');
index 13da64a4f650a6663287a1b0e6f4a575f8330b24..30725fc1bff7b6fa847d4619a893816f2de8854c 100644 (file)
@@ -72,6 +72,12 @@ class OpenidsettingsAction extends AccountSettingsAction
                  ' Manage your associated OpenIDs from here.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('openid_url');
+    }
+
     /**
      * Show the form for OpenID management
      *
index 8b674161a89bb1a28408e4e91b158083a5492167..f898e220794e3c2c7bad536df3831f0fe6916681 100644 (file)
@@ -71,6 +71,12 @@ class OthersettingsAction extends AccountSettingsAction
         return _('Manage various other options.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('urlshorteningservice');
+    }
+
     /**
      * Content area of the page
      *
index ec842600f6c1c252206aa7a1a5f117e93140c99f..cd4beac3f2120a9c83a81f4ddc8a4e98c8573777 100644 (file)
@@ -69,6 +69,12 @@ class PasswordsettingsAction extends AccountSettingsAction
         return _('Change your password.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('oldpassword');
+    }
+
     /**
      * Content area of the page
      *
index ba0f71e392165acb4fa9d55d99ab6765ebe2187d..38135ecbdeac6076ad1207e27705c5fab658bcfe 100644 (file)
@@ -85,6 +85,12 @@ class PeoplesearchAction extends SearchAction
             $profile->free();
         }
     }
+
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('q');
+    }
 }
 
 /**
index f9c16351d36eb15e4b27566229662a67c261dc6d..2d66e99469cf7692141724185669fdc7f742e027 100644 (file)
@@ -23,6 +23,7 @@
  * @package   StatusNet
  * @author    Evan Prodromou <evan@status.net>
  * @author    Zach Copley <zach@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
  * @copyright 2008-2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
@@ -41,6 +42,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
  * @package  StatusNet
  * @author   Evan Prodromou <evan@status.net>
  * @author   Zach Copley <zach@status.net>
+ * @author   Sarven Capadisli <csarven@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
@@ -70,6 +72,12 @@ class ProfilesettingsAction extends AccountSettingsAction
                   'so people know more about you.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('nickname');
+    }
+
     /**
      * Content area of the page
      *
index c431aeee3e356fd01002fd70e93f56ef57ecb01b..eefbc340a1f427f5484ff5a3f5978f007edf6e5e 100644 (file)
@@ -140,6 +140,12 @@ class RegisterAction extends Action
         }
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('nickname');
+    }
+
     /**
      * Try to register a user
      *
index b956ccebaaa178773fa8c05459535ab91ce03576..672abcef8c15587e0eda8e089578e4bbea496c0a 100644 (file)
@@ -69,6 +69,12 @@ class SmssettingsAction extends ConnectSettingsAction
         return _('You can receive SMS messages through email from %%site.name%%.');
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('sms');
+    }
+
     /**
      * Content area of the page
      *
index b1c6682283c2ab1473219cfb077d2fb7f43b206c..cc7b38ee461f21d21f44408d6b645a70d086db00 100644 (file)
@@ -107,6 +107,12 @@ class SubscriptionsAction extends GalleryAction
                           array('nickname' => $this->user->nickname));
     }
 
+    function showScripts()
+    {
+        parent::showScripts();
+        $this->autofocus('tag');
+    }
+
     function showEmptyListMessage()
     {
         if (common_logged_in()) {
index fe42225974ff8c9d797ac83b7b3c9eb0b2a245a3..fdc05562e08fbfafd13ef12223ce626fba000288 100644 (file)
@@ -327,6 +327,8 @@ class DesignSettingsAction extends AccountSettingsAction
         $this->script('js/farbtastic/farbtastic.js');
         $this->script('js/farbtastic/farbtastic.go.js');
         $this->script('js/userdesign.go.js');
+
+        $this->autofocus('design_background-image_file');
     }
 
     /**
index 8ad7dc20fa3645e4e731387b96b8014614ba8643..aa01f6b1d9d268e5855864efe428027cf4aa5916 100644 (file)
@@ -412,4 +412,29 @@ class HTMLOutputter extends XMLOutputter
             $this->element('p', 'form_guide', $instructions);
         }
     }
+
+
+    /**
+    * Internal script to autofocus the given element on page onload.
+    *
+    * @param string $id element ID, must refer to an existing element
+    *
+    * @return void
+    *
+    */
+    function autofocus($id)
+    {
+        $this->elementStart('script', array('type' => 'text/javascript'));
+        $this->raw('
+        <!--
+        $(document).ready(function() {
+            var el = $("#' . $id . '");
+            if (el.length) {
+                el.focus();
+            }
+        });
+        -->
+        ');
+        $this->elementEnd('script');
+    }
 }