-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonsai-embed-0.1.min.js
37 lines (37 loc) · 5.36 KB
/
bonsai-embed-0.1.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* (The MIT License)
*
* Copyright 2012 uxebu Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Used external libraries:
*
* - SWFObject v2.2 <http://code.google.com/p/swfobject/> (MIT)
*/
var embed=function(){function p(a){var b;if(b=!(l.wk&&312>l.wk))if(b=0<l.pv[0])b=l.pv,a=a.swfVersion.split("."),a[0]=parseInt(a[0],10),a[1]=parseInt(a[1],10)||0,a[2]=parseInt(a[2],10)||0,b=b[0]>a[0]||b[0]==a[0]&&b[1]>a[1]||b[0]==a[0]&&b[1]==a[1]&&b[2]>=a[2]?!0:!1;return b}function e(a){a=q.createElement("div");a.innerHTML="<svg/>";var b="http://www.w3.org/2000/svg"==(a.firstChild&&a.firstChild.namespaceURI);a.innerHTML="";if(a=b)a={}.toString,b=Object,a="[object Function]"==a.call(b.create)&&"[object Function]"==
a.call(b.defineProperties);return a}function w(a){return p(a)?"flash":e(a)?"bonsai":"custom"}var y=window,q=document,g=navigator,l=function(){var a=g.userAgent.toLowerCase(),b=g.platform.toLowerCase(),z=b?/win/.test(b):/win/.test(a),b=b?/mac/.test(b):/mac/.test(a),l=/(ipod|ipad|iphone)/.test(a),a=/webkit/.test(a)?parseFloat(a.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,e=!+"\v1",c=[0,0,0],d=null;if("undefined"!=typeof g.plugins&&"object"==typeof g.plugins["Shockwave Flash"]){if((d=g.plugins["Shockwave Flash"].description)&&
!("undefined"!=typeof g.mimeTypes&&g.mimeTypes["application/x-shockwave-flash"]&&!g.mimeTypes["application/x-shockwave-flash"].enabledPlugin))e=!1,d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),c[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10),c[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10),c[2]=/[a-zA-Z]/.test(d)?parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}else if("undefined"!=typeof y.ActiveXObject)try{var r=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(r&&(d=r.GetVariable("$version")))e=
!0,d=d.split(" ")[1].split(","),c=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)]}catch(q){}return{pv:c,wk:a,ios:l,ie:e,win:z,mac:b}}(),s=function(a){switch((a.strategy||w)(a).toLowerCase()){case "flash":var b=a.swfUrl,e=a.domNodeId,g=a.width,p=a.height,c=a.swfVersion,d=a.flashvarsObj,r=a.parObj,t=a.attObj;a=a.callbackFn;var m={success:!1,id:e};if(b&&e&&g&&p&&c){c={};if(t&&"object"===typeof t)for(var s in t)c[s]=t[s];c.data=b;c.width=g+"";c.height=p+"";b={};if(r&&"object"===typeof r)for(var x in r)b[x]=
r[x];if(d&&"object"===typeof d)for(var u in d)b.flashvars="undefined"!=typeof b.flashvars?b.flashvars+("&"+u+"="+d[u]):u+"="+d[u];var v;if(d=q.getElementById(e))if("undefined"==typeof c.id&&(c.id=e),l.ie&&l.win){var h="",f;for(f in c)c[f]!=Object.prototype[f]&&("data"==f.toLowerCase()?b.movie=c[f]:"styleclass"==f.toLowerCase()?h+=' class="'+c[f]+'"':"classid"!=f.toLowerCase()&&(h+=" "+f+'="'+c[f]+'"'));f="";for(var k in b)b[k]!=Object.prototype[k]&&(f+='<param name="'+k+'" value="'+b[k]+'" />');d.outerHTML=
'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+h+">"+f+"</object>";v=q.getElementById(c.id)}else{k=q.createElement("object");k.setAttribute("type","application/x-shockwave-flash");for(var n in c)c[n]!=Object.prototype[n]&&("styleclass"==n.toLowerCase()?k.setAttribute("class",c[n]):"classid"!=n.toLowerCase()&&k.setAttribute(n,c[n]));for(h in b)b[h]!=Object.prototype[h]&&"movie"!=h.toLowerCase()&&(c=k,f=h,n=b[h],e=q.createElement("param"),e.setAttribute("name",f),e.setAttribute("value",
n),c.appendChild(e));d.parentNode.replaceChild(k,d);v=k}m.success=!0;m.ref=v;a&&a(m)}break;case "bonsai":m=q.getElementById(a.domNodeId);m.innerHTML="";m.style.width=a.width+"px";m.style.height=a.height+"px";m=bonsai.setup({runnerUrl:a.runnerUrl,runnerContext:"worker"==a.runnerContext?bonsai.WorkerRunnerContext:bonsai.IframeRunnerContext}).run(m,a.bonsaiUrl,{plugins:a.bonsaiPlugins,pluginDebug:!1,width:a.width,height:a.height,flashConfig:{params:a.parObj,flashVars:a.flashvarsObj},allowEventDefaults:a.allowEventDefaults||
!1,assetBaseUrl:a.assetBaseUrl||"./"});if(a.bonsaiStartCallback)m.on("start",a.bonsaiStartCallback);break;case "image":throw Error("Not implemented.");default:a.display&&a.display(a)}};s.strategies={useFlashIfAvailable:w,useBonsaiOnlyIfIOS:function(a){return l.ios&&e(a)?"bonsai":p(a)?"flash":"custom"},preferBonsaiIfIOS:function(a){var b=e(a);return l.ios&&b?"bonsai":p(a)?"flash":b?"bonsai":"custom"},useBonsaiIfPossible:function(a){return e(a)?"bonsai":p(a)?"flash":"custom"},neverUseFlash:function(a){return e(a)?
"bonsai":"custom"}};s.capabilities={canUseFlash:p,canUseBonsai:e,canUseImage:function(a){return!1}};return s}();