Added method add_header_js() to template to allow insertion of code to be run immediately after JS init
authorDan
Wed, 29 Jul 2009 10:48:43 -0400
changeset 1060 d3e12f1f9f29
parent 1059 f5d2bca33bb8
child 1061 4ef865b5f497
Added method add_header_js() to template to allow insertion of code to be run immediately after JS init
includes/template.php
--- a/includes/template.php	Wed Jul 29 10:47:26 2009 -0400
+++ b/includes/template.php	Wed Jul 29 10:48:43 2009 -0400
@@ -22,6 +22,7 @@
   var $page_id = false;
   var $namespace = false;
   var $js_preload = array();
+  var $js_append = '';
   
   /**
    * Page action conditions
@@ -470,6 +471,16 @@
   }
   
   /**
+   * Queue some HTML to be inserted after the Javascript runtime.
+   * @param string HTML glob
+   */
+  
+  function add_header_js($html)
+  {
+    $this->js_append .= "$html\n    ";
+  }
+  
+  /**
    * Global, only-called-once init. Goes to all themes.
    */
   
@@ -557,6 +568,7 @@
         window.onload = function(e) {  };
       }
     </script>
+    $this->js_append
 JSEOF;
     }
     else
@@ -604,6 +616,7 @@
         window.onload = function(e) {  };
       }
     //]]></script>
+    $this->js_append
 JSEOF;
     }