Allow wrapping output of addInlineJSVars() with an onload handler.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 9 Sep 2010 13:53:54 +0000 (09:53 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 9 Sep 2010 13:53:54 +0000 (09:53 -0400)
Some values won't be defined before other script files are loaded, make
sure we allow for that.

framework/Core/lib/Horde.php
framework/Core/lib/Horde/Script/Files.php

index fa2d9c9..a6870cc 100644 (file)
@@ -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);
         }
     }
 
index 47bbfb0..d31cf24 100644 (file)
@@ -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] == '/') {