Commit 277b4640 authored by Sarven Capadisli's avatar Sarven Capadisli

Created autofocus method to give focus to an element (primarily a form

control) on page onload.

Updated some of the pages to use autofocus.
parent 0c95734a
......@@ -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');
}
}
......@@ -160,6 +160,12 @@ class EditgroupAction extends GroupDesignAction
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('nickname');
}
function trySave()
{
$cur = common_current_user();
......
......@@ -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
*
......
......@@ -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()
......
......@@ -91,6 +91,12 @@ class GroupsearchAction extends SearchAction
$user_group->free();
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('q');
}
}
class GroupSearchResults extends GroupList
......
......@@ -98,6 +98,12 @@ class InviteAction extends CurrentUserDesignAction
$this->showPage();
}
function showScripts()
{
parent::showScripts();
$this->autofocus('addresses');
}
function title()
{
if ($this->mode == 'sent') {
......
......@@ -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
*
......
......@@ -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 {
......
......@@ -86,6 +86,12 @@ class OpenidloginAction extends Action
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('openid_url');
}
function title()
{
return _('OpenID Login');
......
......@@ -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
*
......
......@@ -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
*
......
......@@ -69,6 +69,12 @@ class PasswordsettingsAction extends AccountSettingsAction
return _('Change your password.');
}
function showScripts()
{
parent::showScripts();
$this->autofocus('oldpassword');
}
/**
* Content area of the page
*
......
......@@ -85,6 +85,12 @@ class PeoplesearchAction extends SearchAction
$profile->free();
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('q');
}
}
/**
......
......@@ -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
*
......
......@@ -140,6 +140,12 @@ class RegisterAction extends Action
}
}
function showScripts()
{
parent::showScripts();
$this->autofocus('nickname');
}
/**
* Try to register a user
*
......
......@@ -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
*
......
......@@ -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()) {
......
......@@ -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');
}
/**
......
......@@ -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');
}
}
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