From c84f3e19b54cf54f525f4b2d158696ae32d1bf60 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Tue, 25 Apr 2006 01:00:08 +0000
Subject: Add TListControlValidator. Update client-side validators,
 datepicker.js, colorpicker.js.

---
 framework/Web/Javascripts/TJavaScript.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'framework/Web/Javascripts/TJavaScript.php')

diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php
index 4066565b..a3848201 100644
--- a/framework/Web/Javascripts/TJavaScript.php
+++ b/framework/Web/Javascripts/TJavaScript.php
@@ -96,9 +96,16 @@ class TJavaScript
 	 * //expects the following javascript code
 	 * // {'onLoading':'doit','onComplete':'more'}
 	 * </code>
+	 * 
+	 * To pass raw javascript statements start strings with 
+	 * <tt>javascript:</tt>. E.g. 
+	 * <code>
+	 * $options['onLoading'] = "javascript:function(){ alert('hello'); }";
+	 * //outputs {'onLoading':function(){ alert('hello'); }}
+	 * </code>
 	 *
-	 * For higher complexity data structures use {@link jsonEncode} and {@link jsonDecode}
-	 * to serialize and unserialize.
+	 * For higher complexity data structures use {@link jsonEncode} and {@link
+	 * jsonDecode} to serialize and unserialize.
 	 *
 	 * @param mixed PHP variable to be encoded
 	 * @param boolean whether the output is a map or a list.
@@ -115,6 +122,8 @@ class TJavaScript
 				if(($first==='[' && $last===']') || ($first==='{' && $last==='}'))
 					return $value;
 			}
+			else if(strpos($value, 'javascript:')===0)
+				return substr($value,11);
 			return "'".self::quoteString($value)."'";
 		}
 		else if(is_bool($value))
-- 
cgit v1.2.3