Finer-grained control of script loading order
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 21:02:45 +0000 (15:02 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 21:32:00 +0000 (15:32 -0600)
framework/Core/lib/Horde.php

index fdf9774..11f5aaf 100644 (file)
@@ -2095,8 +2095,10 @@ HTML;
      *                         array also).
      * @param string $onload   Load the script after the page has loaded?
      *                         Either 'dom' (on dom:loaded), 'load'.
+     * @param boolean $top     Add script to top of stack?
      */
-    static public function addInlineScript($script, $onload = null)
+    static public function addInlineScript($script, $onload = null,
+                                           $top = false)
     {
         if (is_array($script)) {
             $script = implode(';', $script);
@@ -2117,7 +2119,11 @@ HTML;
             break;
         }
 
-        self::$_inlineScript[] = $script;
+        if ($top) {
+            array_unshift(self::$_inlineScript, $script);
+        } else {
+            self::$_inlineScript[] = $script;
+        }
 
         // If headers have already been sent, we need to output a
         // <script> tag directly.