You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ah...@apache.org on 2012/02/09 19:35:59 UTC

svn commit: r1242449 - in /oodt/trunk: CHANGES.txt balance/lib/pear/Core/ApplicationResponse.class.php

Author: ahart
Date: Thu Feb  9 18:35:58 2012
New Revision: 1242449

URL: http://svn.apache.org/viewvc?rev=1242449&view=rev
Log:
resolve OODT-375: patch applied to trunk

Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/balance/lib/pear/Core/ApplicationResponse.class.php

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1242449&r1=1242448&r2=1242449&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Thu Feb  9 18:35:58 2012
@@ -3,6 +3,8 @@ Apache OODT Change Log
 
 Release 0.4: Current Development
 --------------------------------------------
+* OODT-375 Improve ApplicationResponse::includeJavascript to support including 
+  JavaScript snippets in addition to static files (ahart)
 
 * OODT-356 Tool to clean Workflow Instance repositories (mattmann, bfoster)
 

Modified: oodt/trunk/balance/lib/pear/Core/ApplicationResponse.class.php
URL: http://svn.apache.org/viewvc/oodt/trunk/balance/lib/pear/Core/ApplicationResponse.class.php?rev=1242449&r1=1242448&r2=1242449&view=diff
==============================================================================
--- oodt/trunk/balance/lib/pear/Core/ApplicationResponse.class.php (original)
+++ oodt/trunk/balance/lib/pear/Core/ApplicationResponse.class.php Thu Feb  9 18:35:58 2012
@@ -276,10 +276,31 @@ class Org_Apache_Oodt_Balance_Core_Appli
 		$this->stylesheets[] = $str;
 	}
 	
-	public function addJavascript($src) {
-		// Build the string for the javascript import
-		$str = "<script type=\"text/javascript\" src=\"{$src}\"></script>";
-		$this->javascripts[] = $str;
+    /**
+     * Add javascript resources to the response
+     *
+     * This function provides a clean way to programmatically include arbitrary
+     * Javascript resources in the response. Depending upon the value
+     * provided for 'isRaw', the contents of 'src' will either be interpreted
+     * as the 'src' attribute or the body content of the generated <script> block. 
+     *
+     * @param string src - Either the url to the resource to include (if 
+     *                     'isRaw' = false) or a string representing the 
+     *                     raw Javascript to include (if 'isRaw' = true)
+     * @param boolean isRaw - Controls how 'src' is interpreted. If set to false 
+     *                     (default), 'src' will be interpreted as a URL to the
+     *                     Javascript resource to include. If set to true, 'src' 
+     *                     will be interpreted as a string of raw Javascript.
+     */
+	public function addJavascript($src, $isRaw = false) {
+        if ($isRaw === true) {
+            // Build a script container for the raw javascript
+            $str = "<script type=\"text/javascript\">{$src}</script>";
+            $this->javascripts[] = $str;
+        } else {
+            // Build the string for the javascript file import
+            $str = "<script type=\"text/javascript\" src=\"{$src}\"></script>";
+            $this->javascripts[] = $str;
+        }
 	}
-	
 }