summaryrefslogtreecommitdiff
path: root/js/dojo-1.6/dojox/embed/flashVars.xd.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/dojo-1.6/dojox/embed/flashVars.xd.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/embed/flashVars.xd.js b/js/dojo-1.6/dojox/embed/flashVars.xd.js
new file mode 100644
index 0000000..b449504
--- /dev/null
+++ b/js/dojo-1.6/dojox/embed/flashVars.xd.js
@@ -0,0 +1,70 @@
+/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.embed.flashVars"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.embed.flashVars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.embed.flashVars"] = true;
+dojo.provide("dojox.embed.flashVars");
+
+dojo.mixin(dojox.embed.flashVars, {
+ // summary
+ // Handles flashvar serialization
+ // Converting complex objects into a simple, clear string that can be appended
+ // to the swf as a query: myMovie.swf?flashvars=foo.
+ // Note this needs to work with the SWF, which must know what variables to expect.
+ // Therefore this is something of an "internal" class - unless you know how to
+ // modify or create SWFs.
+ //
+ // description:
+ // JSON could be done, but Deft does not yet have a JSON parser, and quotes are
+ // very problematic since Flash cannot use eval(); JSON parsing was successful
+ // when it was fully escaped, but that made it very large anyway. flashvar
+ // serialization at most is 200% larger than JSON.
+ //
+ // See:
+ // Deft/common/flashVars.as
+ //
+ serialize: function(/* String */n, /*Object*/o){
+ // summary:
+ // Key method. Serializes an object.
+ // n:String
+ // The name for the object, such as: "button"
+ // o:Object
+ // The object to serialize
+ //
+ var esc = function(val){
+ // have to encode certain characters that indicate an object
+ if(typeof val=="string"){
+ val = val.replace(/;/g,"_sc_");
+ val = val.replace(/\./g,"_pr_");
+ val = val.replace(/\:/g,"_cl_");
+ //val = escape(val);
+ }
+ return val;
+ };
+ var df = dojox.embed.flashVars.serialize;
+ var txt = "";
+ if(dojo.isArray(o)){
+ for(var i=0;i<o.length;i++){
+ txt += df(n+"."+i, esc(o[i]))+";";
+ }
+ return txt.replace(/;{2,}/g,";");
+ }else if(dojo.isObject(o)){
+ for(var nm in o){
+ txt += df(n+"."+nm, esc(o[nm]))+";";
+ }
+ return txt.replace(/;{2,}/g,";");
+ }
+ // Dev note: important that there is no double semi-colons
+ return n+":"+o; // String
+ }
+});
+
+}
+
+}};});