From 277b464054b24f8d680ddbe762c9e438f6679592 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 3 Sep 2009 19:42:50 +0000 Subject: Created autofocus method to give focus to an element (primarily a form control) on page onload. Updated some of the pages to use autofocus. --- lib/designsettings.php | 2 ++ lib/htmloutputter.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'lib') diff --git a/lib/designsettings.php b/lib/designsettings.php index fe4222597..fdc05562e 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -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'); } /** diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 8ad7dc20f..aa01f6b1d 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -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(' + + '); + $this->elementEnd('script'); + } } -- cgit v1.2.3-54-g00ecf