From b4f326026899abb5b6f6a83422d72420f4c7801a Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Thu, 9 Sep 2010 09:53:54 -0400 Subject: [PATCH] Allow wrapping output of addInlineJSVars() with an onload handler. Some values won't be defined before other script files are loaded, make sure we allow for that. --- framework/Core/lib/Horde.php | 16 +++++++++------- framework/Core/lib/Horde/Script/Files.php | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index fa2d9c93d..a6870cc46 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -1768,13 +1768,15 @@ HTML; /** * Add inline javascript variable definitions to the output buffer. * - * @param array $data Keys are the variable names, values are the data - * to JSON encode. If the key begins with a '-', the - * data will be added to the output as-is. - * @param boolean $ret If true, will return the list of variable - * definitions instead of outputting to page. + * @param array $data Keys are the variable names, values are the data + * to JSON encode. If the key begins with a '-', the + * data will be added to the output as-is. + * @param boolean $ret If true, will return the list of variable + * definitions instead of outputting to page. + * @param string $onload Wrap the definition in an onload handler? + * Either 'dom' (on dom:loaded), 'load'. */ - static public function addInlineJsVars($data, $ret = false) + static public function addInlineJsVars($data, $ret = false, $onload = null) { $charset = $GLOBALS['registry']->getCharset(); $out = array(); @@ -1792,7 +1794,7 @@ HTML; if ($ret) { return $out; } else { - self::addInlineScript($out); + self::addInlineScript($out, $onload); } } diff --git a/framework/Core/lib/Horde/Script/Files.php b/framework/Core/lib/Horde/Script/Files.php index 47bbfb0a9..d31cf24bf 100644 --- a/framework/Core/lib/Horde/Script/Files.php +++ b/framework/Core/lib/Horde/Script/Files.php @@ -111,7 +111,7 @@ class Horde_Script_Files if (($file == 'popup.js') && ($app == 'horde')) { Horde::addInlineJsVars(array( 'Horde.popup_block_text' => _("A popup window could not be opened. Your browser may be blocking popups.") - )); + ), 'dom'); } if ($file[0] == '/') { -- 2.11.0