From 8e211adb01bd6145eb250edabff38db449f34d92 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Wed, 21 Apr 2010 04:21:33 -0400 Subject: [PATCH] - Add images pre-loading on login page (#1451160) --- program/include/rcube_template.php | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index ad498c9..c622380 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -80,6 +80,7 @@ // register common UI objects $this->add_handlers(array( 'loginform' => array($this, 'login_form'), + 'preloader' => array($this, 'preloader'), 'username' => array($this, 'current_username'), 'message' => array($this, 'message_container'), 'charsetselector' => array($this, 'charset_selector'), @@ -1073,6 +1074,30 @@ /** + * GUI object 'preloader' + * Loads javascript code for images preloading + * + * @param array Named parameters + * @return void + */ + private function preloader($attrib) + { + $images = preg_split('/[\s\t\n,]+/', $attrib['images'], -1, PREG_SPLIT_NO_EMPTY); + $images = array_map(array($this, 'abs_url'), $images); + + if (empty($images) || $this->app->task == 'logout') + return; + + $this->add_script('$(document).ready(function(){ + var images = ' . json_serialize($images) .'; + for (var i=0; i<images.length; i++) { + img = new Image(); + img.src = images[i]; + }});', 'foot'); + } + + + /** * GUI object 'searchform' * Returns code for search function * -- Gitblit v1.9.1