summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/TJavaScript.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/TJavaScript.php')
-rw-r--r--framework/Web/Javascripts/TJavaScript.php13
1 files changed, 11 insertions, 2 deletions
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))