atreides 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/app/assets/javascripts/atreides/admin_base.js.erb +11 -16
- data/app/assets/stylesheets/atreides/admin_base.css.erb +2 -3
- data/app/controllers/atreides/admin_controller.rb +14 -0
- data/app/models/atreides/{preferences.rb → preference.rb} +1 -1
- data/app/views/admin/atreides/common/_sidebar_publish.html.haml +16 -0
- data/app/views/admin/atreides/features/_form.html.haml +11 -18
- data/app/views/admin/atreides/pages/_form.html.haml +1 -4
- data/app/views/admin/atreides/posts/_form_sidebar.html.haml +1 -8
- data/app/views/admin/common/_list_table.html.haml +30 -0
- data/app/views/admin/common/_list_table_row.html.haml +11 -0
- data/app/views/admin/common/_pagination.html.haml +1 -0
- data/app/views/admin/common/_search_form.html.haml +4 -0
- data/lib/assets/flash/atreides/player.swf +0 -0
- data/lib/assets/flash/atreides/slideshowpro.swf +0 -0
- data/lib/assets/flash/atreides/swfupload.swf +0 -0
- data/lib/assets/images/atreides/share/aim_16.png +0 -0
- data/lib/assets/images/atreides/share/apple_16.png +0 -0
- data/lib/assets/images/atreides/share/bebo_16.png +0 -0
- data/lib/assets/images/atreides/share/blogger_16.png +0 -0
- data/lib/assets/images/atreides/share/brightkite_16.png +0 -0
- data/lib/assets/images/atreides/share/cargo_16.png +0 -0
- data/lib/assets/images/atreides/share/delicious_16.png +0 -0
- data/lib/assets/images/atreides/share/designfloat_16.png +0 -0
- data/lib/assets/images/atreides/share/designmoo_16.png +0 -0
- data/lib/assets/images/atreides/share/deviantart_16.png +0 -0
- data/lib/assets/images/atreides/share/digg_16.png +0 -0
- data/lib/assets/images/atreides/share/digg_alt_16.png +0 -0
- data/lib/assets/images/atreides/share/dopplr_16.png +0 -0
- data/lib/assets/images/atreides/share/dribbble_16.png +0 -0
- data/lib/assets/images/atreides/share/email_16.png +0 -0
- data/lib/assets/images/atreides/share/ember_16.png +0 -0
- data/lib/assets/images/atreides/share/evernote_16.png +0 -0
- data/lib/assets/images/atreides/share/facebook_16.png +0 -0
- data/lib/assets/images/atreides/share/flickr_16.png +0 -0
- data/lib/assets/images/atreides/share/friendfeed_16.png +0 -0
- data/lib/assets/images/atreides/share/gamespot_16.png +0 -0
- data/lib/assets/images/atreides/share/google_16.png +0 -0
- data/lib/assets/images/atreides/share/google_voice_16.png +0 -0
- data/lib/assets/images/atreides/share/google_wave_16.png +0 -0
- data/lib/assets/images/atreides/share/googletalk_16.png +0 -0
- data/lib/assets/images/atreides/share/gowalla_16.png +0 -0
- data/lib/assets/images/atreides/share/grooveshark_16.png +0 -0
- data/lib/assets/images/atreides/share/ilike_16.png +0 -0
- data/lib/assets/images/atreides/share/komodomedia_azure_16.png +0 -0
- data/lib/assets/images/atreides/share/komodomedia_wood_16.png +0 -0
- data/lib/assets/images/atreides/share/lastfm_16.png +0 -0
- data/lib/assets/images/atreides/share/license.txt +9 -0
- data/lib/assets/images/atreides/share/linkedin_16.png +0 -0
- data/lib/assets/images/atreides/share/mixx_16.png +0 -0
- data/lib/assets/images/atreides/share/mobileme_16.png +0 -0
- data/lib/assets/images/atreides/share/mynameise_16.png +0 -0
- data/lib/assets/images/atreides/share/myspace_16.png +0 -0
- data/lib/assets/images/atreides/share/netvibes_16.png +0 -0
- data/lib/assets/images/atreides/share/newsvine_16.png +0 -0
- data/lib/assets/images/atreides/share/openid_16.png +0 -0
- data/lib/assets/images/atreides/share/orkut_16.png +0 -0
- data/lib/assets/images/atreides/share/pandora_16.png +0 -0
- data/lib/assets/images/atreides/share/paypal_16.png +0 -0
- data/lib/assets/images/atreides/share/picasa_16.png +0 -0
- data/lib/assets/images/atreides/share/plurk_16.png +0 -0
- data/lib/assets/images/atreides/share/posterous_16.png +0 -0
- data/lib/assets/images/atreides/share/qik_16.png +0 -0
- data/lib/assets/images/atreides/share/readernaut_16.png +0 -0
- data/lib/assets/images/atreides/share/reddit_16.png +0 -0
- data/lib/assets/images/atreides/share/roboto_16.png +0 -0
- data/lib/assets/images/atreides/share/rss_16.png +0 -0
- data/lib/assets/images/atreides/share/sharethis_16.png +0 -0
- data/lib/assets/images/atreides/share/skype_16.png +0 -0
- data/lib/assets/images/atreides/share/stumbleupon_16.png +0 -0
- data/lib/assets/images/atreides/share/technorati_16.png +0 -0
- data/lib/assets/images/atreides/share/tumblr_16.png +0 -0
- data/lib/assets/images/atreides/share/twitter_16.png +0 -0
- data/lib/assets/images/atreides/share/viddler_16.png +0 -0
- data/lib/assets/images/atreides/share/vimeo_16.png +0 -0
- data/lib/assets/images/atreides/share/virb_16.png +0 -0
- data/lib/assets/images/atreides/share/windows_16.png +0 -0
- data/lib/assets/images/atreides/share/wordpress_16.png +0 -0
- data/lib/assets/images/atreides/share/xing_16.png +0 -0
- data/lib/assets/images/atreides/share/yahoo_16.png +0 -0
- data/lib/assets/images/atreides/share/yahoobuzz_16.png +0 -0
- data/lib/assets/images/atreides/share/yelp_16.png +0 -0
- data/lib/assets/images/atreides/share/youtube_16.png +0 -0
- data/lib/assets/javascripts/atreides/facebox.js +309 -0
- data/lib/assets/javascripts/atreides/fileuploader.js +1250 -0
- data/lib/assets/javascripts/atreides/galleria.js +2 -0
- data/lib/assets/javascripts/atreides/galleria/src/galleria.js +3816 -0
- data/lib/assets/javascripts/atreides/galleria/src/plugins/galleria.flickr.js +221 -0
- data/lib/assets/javascripts/atreides/galleria/src/plugins/galleria.history.js +602 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/classic/classic-loader.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/classic/classic-map.png +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/classic/galleria.classic.css +202 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/classic/galleria.classic.js +92 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/b.png +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/down.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/fix.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/fullscreen-demo.html +34 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/galleria.fullscreen.css +46 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/galleria.fullscreen.js +193 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/i.png +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/l.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/l2.png +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/loader.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/n.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/p.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/r.gif +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/r2.png +0 -0
- data/lib/assets/javascripts/atreides/galleria/src/themes/fullscreen/up.gif +0 -0
- data/lib/assets/javascripts/atreides/jquery.autogrow.js +132 -0
- data/lib/assets/javascripts/atreides/jquery.cookie.js +96 -0
- data/lib/assets/javascripts/atreides/jquery.countdown.js +759 -0
- data/lib/assets/javascripts/atreides/jquery.cycle.js +918 -0
- data/lib/assets/javascripts/atreides/jquery.easing.1.3.js +205 -0
- data/lib/assets/javascripts/atreides/jquery.flash.js +288 -0
- data/lib/assets/javascripts/atreides/jquery.iphone-checkboxes.js +214 -0
- data/lib/assets/javascripts/atreides/jquery.jBreadCrumb.1.1.js +240 -0
- data/lib/assets/javascripts/atreides/jquery.multipleselectbox-min.js +15 -0
- data/lib/assets/javascripts/atreides/jquery.multipleselectbox.js +446 -0
- data/lib/assets/javascripts/atreides/jquery.swfupload.js +64 -0
- data/lib/assets/javascripts/atreides/jquery.tipsy.js +104 -0
- data/lib/assets/javascripts/atreides/jquery.uniform.js +461 -0
- data/lib/assets/javascripts/atreides/jtags.js +125 -0
- data/lib/assets/javascripts/atreides/raphael-min.js +7 -0
- data/lib/assets/javascripts/atreides/raphael.analytics.js +205 -0
- data/lib/assets/javascripts/atreides/raphael.path.methods.js +53 -0
- data/lib/assets/javascripts/atreides/raphael.pie.js +44 -0
- data/lib/assets/javascripts/atreides/sifr.js +18 -0
- data/lib/assets/javascripts/atreides/swfobject.js +4 -0
- data/lib/assets/javascripts/atreides/swfupload/handlers.js +290 -0
- data/lib/assets/javascripts/atreides/swfupload/swfupload.cookies.js +53 -0
- data/lib/assets/javascripts/atreides/swfupload/swfupload.js +980 -0
- data/lib/assets/javascripts/atreides/swfupload/swfupload.queue.js +98 -0
- data/lib/assets/javascripts/atreides/swfupload/swfupload.speed.js +342 -0
- data/lib/assets/javascripts/atreides/swfupload/swfupload.swfobject.js +111 -0
- data/lib/assets/javascripts/atreides/underscore-1.1.6.js +807 -0
- data/lib/assets/stylesheets/atreides/admin_grid.css +258 -0
- data/lib/assets/stylesheets/atreides/facebox.css +80 -0
- data/lib/assets/stylesheets/atreides/formtastic.css +144 -0
- data/lib/assets/stylesheets/atreides/galleria.css +24 -0
- data/lib/assets/stylesheets/atreides/ie.css +35 -0
- data/lib/assets/stylesheets/atreides/images/bg_fallback.png +0 -0
- data/lib/assets/stylesheets/atreides/images/icon_sprite.png +0 -0
- data/lib/assets/stylesheets/atreides/images/progress_bar.gif +0 -0
- data/lib/assets/stylesheets/atreides/images/slider_handles.png +0 -0
- data/lib/assets/stylesheets/atreides/images/ui-icons_222222_256x240.png +0 -0
- data/lib/assets/stylesheets/atreides/images/ui-icons_454545_256x240.png +0 -0
- data/lib/assets/stylesheets/atreides/jquery-ui.css +738 -0
- data/lib/assets/stylesheets/atreides/multipleselectbox.css +33 -0
- data/lib/assets/stylesheets/atreides/print.css +29 -0
- data/lib/assets/stylesheets/atreides/public_grid.css +258 -0
- data/lib/assets/stylesheets/atreides/tipsy.css +7 -0
- data/lib/assets/stylesheets/atreides/uniform.default.css +476 -0
- data/lib/atreides.rb +4 -0
- data/lib/atreides/schema.rb +53 -0
- data/lib/atreides/time_zone.rb +6 -0
- data/lib/atreides/version.rb +1 -1
- data/lib/generators/templates/create_pages.rb +1 -2
- data/lib/generators/templates/create_posts.rb +1 -2
- metadata +155 -13
- data/app/views/admin/common/_list_table.html.erb +0 -37
- data/app/views/admin/common/_list_table_row.html.erb +0 -18
- data/app/views/admin/common/_pagination.html.erb +0 -1
- data/app/views/admin/common/_search_form.html.erb +0 -6
@@ -0,0 +1,4 @@
|
|
1
|
+
/* SWFObject v2.2 <http://code.google.com/p/swfobject/>
|
2
|
+
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
3
|
+
*/
|
4
|
+
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
|
@@ -0,0 +1,290 @@
|
|
1
|
+
function fileQueueError(file, errorCode, message) {
|
2
|
+
try {
|
3
|
+
var imageName = "error.gif";
|
4
|
+
var errorName = "";
|
5
|
+
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
|
6
|
+
errorName = "You have attempted to queue too many files.";
|
7
|
+
}
|
8
|
+
|
9
|
+
if (errorName !== "") {
|
10
|
+
alert(errorName);
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
switch (errorCode) {
|
15
|
+
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
16
|
+
imageName = "zerobyte.gif";
|
17
|
+
break;
|
18
|
+
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
19
|
+
imageName = "toobig.gif";
|
20
|
+
break;
|
21
|
+
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
22
|
+
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
23
|
+
default:
|
24
|
+
alert(message);
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
|
28
|
+
addImage("images/swfupload/" + imageName);
|
29
|
+
|
30
|
+
} catch (ex) {
|
31
|
+
this.debug(ex);
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
function fileDialogComplete(numFilesSelected, numFilesQueued) {
|
37
|
+
try {
|
38
|
+
if (numFilesQueued > 0) {
|
39
|
+
this.startUpload();
|
40
|
+
}
|
41
|
+
} catch (ex) {
|
42
|
+
this.debug(ex);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
function uploadProgress(file, bytesLoaded) {
|
47
|
+
|
48
|
+
try {
|
49
|
+
var percent = Math.ceil((bytesLoaded / file.size) * 100);
|
50
|
+
|
51
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
52
|
+
progress.setProgress(percent);
|
53
|
+
if (percent === 100) {
|
54
|
+
progress.setStatus("Processing file...");
|
55
|
+
progress.toggleCancel(false, this);
|
56
|
+
} else {
|
57
|
+
progress.setStatus("Uploading...");
|
58
|
+
progress.toggleCancel(true, this);
|
59
|
+
}
|
60
|
+
} catch (ex) {
|
61
|
+
this.debug(ex);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function uploadSuccess(file, serverData) {
|
66
|
+
try {
|
67
|
+
$('#mp3info').append("<p>"+serverData+"</p>");
|
68
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
69
|
+
|
70
|
+
if (serverData.substring(0, 2) === "OK") {
|
71
|
+
//addImage("thumbnail.php?id=" + serverData.substring(7));
|
72
|
+
|
73
|
+
progress.setStatus("Upload Successfull.");
|
74
|
+
progress.toggleCancel(false);
|
75
|
+
} else {
|
76
|
+
addImage("/images/swfupload/error.gif");
|
77
|
+
progress.setStatus("Error.");
|
78
|
+
progress.toggleCancel(false);
|
79
|
+
alert(serverData);
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
} catch (ex) {
|
85
|
+
this.debug(ex);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
function uploadComplete(file) {
|
90
|
+
try {
|
91
|
+
/* I want the next upload to continue automatically so I'll call startUpload here */
|
92
|
+
if (this.getStats().files_queued > 0) {
|
93
|
+
this.startUpload();
|
94
|
+
} else {
|
95
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
96
|
+
progress.setComplete();
|
97
|
+
progress.setStatus("All files received.");
|
98
|
+
progress.toggleCancel(false);
|
99
|
+
}
|
100
|
+
} catch (ex) {
|
101
|
+
this.debug(ex);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function uploadError(file, errorCode, message) {
|
106
|
+
var imageName = "error.gif";
|
107
|
+
var progress;
|
108
|
+
try {
|
109
|
+
switch (errorCode) {
|
110
|
+
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
|
111
|
+
try {
|
112
|
+
progress = new FileProgress(file, this.customSettings.upload_target);
|
113
|
+
progress.setCancelled();
|
114
|
+
progress.setStatus("Cancelled");
|
115
|
+
progress.toggleCancel(false);
|
116
|
+
}
|
117
|
+
catch (ex1) {
|
118
|
+
this.debug(ex1);
|
119
|
+
}
|
120
|
+
break;
|
121
|
+
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
122
|
+
try {
|
123
|
+
progress = new FileProgress(file, this.customSettings.upload_target);
|
124
|
+
progress.setCancelled();
|
125
|
+
progress.setStatus("Stopped");
|
126
|
+
progress.toggleCancel(true);
|
127
|
+
}
|
128
|
+
catch (ex2) {
|
129
|
+
this.debug(ex2);
|
130
|
+
}
|
131
|
+
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
132
|
+
imageName = "uploadlimit.gif";
|
133
|
+
break;
|
134
|
+
default:
|
135
|
+
alert(message);
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
|
139
|
+
addImage("/images/swfupload/" + imageName);
|
140
|
+
|
141
|
+
} catch (ex3) {
|
142
|
+
this.debug(ex3);
|
143
|
+
}
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
function addImage(src) {
|
149
|
+
var newImg = document.createElement("img");
|
150
|
+
newImg.style.margin = "5px";
|
151
|
+
|
152
|
+
document.getElementById("thumbnails").appendChild(newImg);
|
153
|
+
if (newImg.filters) {
|
154
|
+
try {
|
155
|
+
newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
|
156
|
+
} catch (e) {
|
157
|
+
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
158
|
+
newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
|
159
|
+
}
|
160
|
+
} else {
|
161
|
+
newImg.style.opacity = 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
newImg.onload = function () {
|
165
|
+
fadeIn(newImg, 0);
|
166
|
+
};
|
167
|
+
newImg.src = src;
|
168
|
+
}
|
169
|
+
|
170
|
+
function fadeIn(element, opacity) {
|
171
|
+
var reduceOpacityBy = 5;
|
172
|
+
var rate = 30; // 15 fps
|
173
|
+
|
174
|
+
|
175
|
+
if (opacity < 100) {
|
176
|
+
opacity += reduceOpacityBy;
|
177
|
+
if (opacity > 100) {
|
178
|
+
opacity = 100;
|
179
|
+
}
|
180
|
+
|
181
|
+
if (element.filters) {
|
182
|
+
try {
|
183
|
+
element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
184
|
+
} catch (e) {
|
185
|
+
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
186
|
+
element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
|
187
|
+
}
|
188
|
+
} else {
|
189
|
+
element.style.opacity = opacity / 100;
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
if (opacity < 100) {
|
194
|
+
setTimeout(function () {
|
195
|
+
fadeIn(element, opacity);
|
196
|
+
}, rate);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
/* ******************************************
|
203
|
+
* FileProgress Object
|
204
|
+
* Control object for displaying file info
|
205
|
+
* ****************************************** */
|
206
|
+
|
207
|
+
function FileProgress(file, targetID) {
|
208
|
+
this.fileProgressID = "divFileProgress";
|
209
|
+
|
210
|
+
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
|
211
|
+
if (!this.fileProgressWrapper) {
|
212
|
+
this.fileProgressWrapper = document.createElement("div");
|
213
|
+
this.fileProgressWrapper.className = "progressWrapper";
|
214
|
+
this.fileProgressWrapper.id = this.fileProgressID;
|
215
|
+
|
216
|
+
this.fileProgressElement = document.createElement("div");
|
217
|
+
this.fileProgressElement.className = "progressContainer";
|
218
|
+
|
219
|
+
var progressCancel = document.createElement("a");
|
220
|
+
progressCancel.className = "progressCancel";
|
221
|
+
progressCancel.href = "#";
|
222
|
+
progressCancel.style.visibility = "hidden";
|
223
|
+
progressCancel.appendChild(document.createTextNode(" "));
|
224
|
+
|
225
|
+
var progressText = document.createElement("div");
|
226
|
+
progressText.className = "progressName";
|
227
|
+
progressText.appendChild(document.createTextNode(file.name));
|
228
|
+
|
229
|
+
var progressBar = document.createElement("div");
|
230
|
+
progressBar.className = "progressBarInProgress";
|
231
|
+
|
232
|
+
var progressStatus = document.createElement("div");
|
233
|
+
progressStatus.className = "progressBarStatus";
|
234
|
+
progressStatus.innerHTML = " ";
|
235
|
+
|
236
|
+
this.fileProgressElement.appendChild(progressCancel);
|
237
|
+
this.fileProgressElement.appendChild(progressText);
|
238
|
+
this.fileProgressElement.appendChild(progressStatus);
|
239
|
+
this.fileProgressElement.appendChild(progressBar);
|
240
|
+
|
241
|
+
this.fileProgressWrapper.appendChild(this.fileProgressElement);
|
242
|
+
|
243
|
+
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
|
244
|
+
fadeIn(this.fileProgressWrapper, 0);
|
245
|
+
|
246
|
+
} else {
|
247
|
+
this.fileProgressElement = this.fileProgressWrapper.firstChild;
|
248
|
+
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
|
249
|
+
}
|
250
|
+
|
251
|
+
this.height = this.fileProgressWrapper.offsetHeight;
|
252
|
+
|
253
|
+
}
|
254
|
+
FileProgress.prototype.setProgress = function (percentage) {
|
255
|
+
this.fileProgressElement.className = "progressContainer green";
|
256
|
+
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
257
|
+
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
|
258
|
+
};
|
259
|
+
FileProgress.prototype.setComplete = function () {
|
260
|
+
this.fileProgressElement.className = "progressContainer blue";
|
261
|
+
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
|
262
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
263
|
+
|
264
|
+
};
|
265
|
+
FileProgress.prototype.setError = function () {
|
266
|
+
this.fileProgressElement.className = "progressContainer red";
|
267
|
+
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
268
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
269
|
+
|
270
|
+
};
|
271
|
+
FileProgress.prototype.setCancelled = function () {
|
272
|
+
this.fileProgressElement.className = "progressContainer";
|
273
|
+
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
274
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
275
|
+
|
276
|
+
};
|
277
|
+
FileProgress.prototype.setStatus = function (status) {
|
278
|
+
this.fileProgressElement.childNodes[2].innerHTML = status;
|
279
|
+
};
|
280
|
+
|
281
|
+
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
|
282
|
+
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
|
283
|
+
if (swfuploadInstance) {
|
284
|
+
var fileID = this.fileProgressID;
|
285
|
+
this.fileProgressElement.childNodes[0].onclick = function () {
|
286
|
+
swfuploadInstance.cancelUpload(fileID);
|
287
|
+
return false;
|
288
|
+
};
|
289
|
+
}
|
290
|
+
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
Cookie Plug-in
|
3
|
+
|
4
|
+
This plug in automatically gets all the cookies for this site and adds them to the post_params.
|
5
|
+
Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
|
6
|
+
The cookies will override any other post params with the same name.
|
7
|
+
*/
|
8
|
+
|
9
|
+
var SWFUpload;
|
10
|
+
if (typeof(SWFUpload) === "function") {
|
11
|
+
SWFUpload.prototype.initSettings = function (oldInitSettings) {
|
12
|
+
return function () {
|
13
|
+
if (typeof(oldInitSettings) === "function") {
|
14
|
+
oldInitSettings.call(this);
|
15
|
+
}
|
16
|
+
|
17
|
+
this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
|
18
|
+
};
|
19
|
+
}(SWFUpload.prototype.initSettings);
|
20
|
+
|
21
|
+
// refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
|
22
|
+
SWFUpload.prototype.refreshCookies = function (sendToFlash) {
|
23
|
+
if (sendToFlash === undefined) {
|
24
|
+
sendToFlash = true;
|
25
|
+
}
|
26
|
+
sendToFlash = !!sendToFlash;
|
27
|
+
|
28
|
+
// Get the post_params object
|
29
|
+
var postParams = this.settings.post_params;
|
30
|
+
|
31
|
+
// Get the cookies
|
32
|
+
var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
|
33
|
+
for (i = 0; i < caLength; i++) {
|
34
|
+
c = cookieArray[i];
|
35
|
+
|
36
|
+
// Left Trim spaces
|
37
|
+
while (c.charAt(0) === " ") {
|
38
|
+
c = c.substring(1, c.length);
|
39
|
+
}
|
40
|
+
eqIndex = c.indexOf("=");
|
41
|
+
if (eqIndex > 0) {
|
42
|
+
name = c.substring(0, eqIndex);
|
43
|
+
value = c.substring(eqIndex + 1);
|
44
|
+
postParams[name] = value;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
if (sendToFlash) {
|
49
|
+
this.setPostParams(postParams);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
}
|
@@ -0,0 +1,980 @@
|
|
1
|
+
/**
|
2
|
+
* SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
|
3
|
+
*
|
4
|
+
* mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
|
5
|
+
*
|
6
|
+
* SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*
|
9
|
+
* SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
|
10
|
+
* http://www.opensource.org/licenses/mit-license.php
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
|
15
|
+
/* ******************* */
|
16
|
+
/* Constructor & Init */
|
17
|
+
/* ******************* */
|
18
|
+
var SWFUpload;
|
19
|
+
|
20
|
+
if (SWFUpload == undefined) {
|
21
|
+
SWFUpload = function (settings) {
|
22
|
+
this.initSWFUpload(settings);
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
SWFUpload.prototype.initSWFUpload = function (settings) {
|
27
|
+
try {
|
28
|
+
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
|
29
|
+
this.settings = settings;
|
30
|
+
this.eventQueue = [];
|
31
|
+
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
|
32
|
+
this.movieElement = null;
|
33
|
+
|
34
|
+
|
35
|
+
// Setup global control tracking
|
36
|
+
SWFUpload.instances[this.movieName] = this;
|
37
|
+
|
38
|
+
// Load the settings. Load the Flash movie.
|
39
|
+
this.initSettings();
|
40
|
+
this.loadFlash();
|
41
|
+
this.displayDebugInfo();
|
42
|
+
} catch (ex) {
|
43
|
+
delete SWFUpload.instances[this.movieName];
|
44
|
+
throw ex;
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
/* *************** */
|
49
|
+
/* Static Members */
|
50
|
+
/* *************** */
|
51
|
+
SWFUpload.instances = {};
|
52
|
+
SWFUpload.movieCount = 0;
|
53
|
+
SWFUpload.version = "2.2.0 2009-03-25";
|
54
|
+
SWFUpload.QUEUE_ERROR = {
|
55
|
+
QUEUE_LIMIT_EXCEEDED : -100,
|
56
|
+
FILE_EXCEEDS_SIZE_LIMIT : -110,
|
57
|
+
ZERO_BYTE_FILE : -120,
|
58
|
+
INVALID_FILETYPE : -130
|
59
|
+
};
|
60
|
+
SWFUpload.UPLOAD_ERROR = {
|
61
|
+
HTTP_ERROR : -200,
|
62
|
+
MISSING_UPLOAD_URL : -210,
|
63
|
+
IO_ERROR : -220,
|
64
|
+
SECURITY_ERROR : -230,
|
65
|
+
UPLOAD_LIMIT_EXCEEDED : -240,
|
66
|
+
UPLOAD_FAILED : -250,
|
67
|
+
SPECIFIED_FILE_ID_NOT_FOUND : -260,
|
68
|
+
FILE_VALIDATION_FAILED : -270,
|
69
|
+
FILE_CANCELLED : -280,
|
70
|
+
UPLOAD_STOPPED : -290
|
71
|
+
};
|
72
|
+
SWFUpload.FILE_STATUS = {
|
73
|
+
QUEUED : -1,
|
74
|
+
IN_PROGRESS : -2,
|
75
|
+
ERROR : -3,
|
76
|
+
COMPLETE : -4,
|
77
|
+
CANCELLED : -5
|
78
|
+
};
|
79
|
+
SWFUpload.BUTTON_ACTION = {
|
80
|
+
SELECT_FILE : -100,
|
81
|
+
SELECT_FILES : -110,
|
82
|
+
START_UPLOAD : -120
|
83
|
+
};
|
84
|
+
SWFUpload.CURSOR = {
|
85
|
+
ARROW : -1,
|
86
|
+
HAND : -2
|
87
|
+
};
|
88
|
+
SWFUpload.WINDOW_MODE = {
|
89
|
+
WINDOW : "window",
|
90
|
+
TRANSPARENT : "transparent",
|
91
|
+
OPAQUE : "opaque"
|
92
|
+
};
|
93
|
+
|
94
|
+
// Private: takes a URL, determines if it is relative and converts to an absolute URL
|
95
|
+
// using the current site. Only processes the URL if it can, otherwise returns the URL untouched
|
96
|
+
SWFUpload.completeURL = function(url) {
|
97
|
+
if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
|
98
|
+
return url;
|
99
|
+
}
|
100
|
+
|
101
|
+
var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
|
102
|
+
|
103
|
+
var indexSlash = window.location.pathname.lastIndexOf("/");
|
104
|
+
if (indexSlash <= 0) {
|
105
|
+
path = "/";
|
106
|
+
} else {
|
107
|
+
path = window.location.pathname.substr(0, indexSlash) + "/";
|
108
|
+
}
|
109
|
+
|
110
|
+
return /*currentURL +*/ path + url;
|
111
|
+
|
112
|
+
};
|
113
|
+
|
114
|
+
|
115
|
+
/* ******************** */
|
116
|
+
/* Instance Members */
|
117
|
+
/* ******************** */
|
118
|
+
|
119
|
+
// Private: initSettings ensures that all the
|
120
|
+
// settings are set, getting a default value if one was not assigned.
|
121
|
+
SWFUpload.prototype.initSettings = function () {
|
122
|
+
this.ensureDefault = function (settingName, defaultValue) {
|
123
|
+
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
124
|
+
};
|
125
|
+
|
126
|
+
// Upload backend settings
|
127
|
+
this.ensureDefault("upload_url", "");
|
128
|
+
this.ensureDefault("preserve_relative_urls", false);
|
129
|
+
this.ensureDefault("file_post_name", "Filedata");
|
130
|
+
this.ensureDefault("post_params", {});
|
131
|
+
this.ensureDefault("use_query_string", false);
|
132
|
+
this.ensureDefault("requeue_on_error", false);
|
133
|
+
this.ensureDefault("http_success", []);
|
134
|
+
this.ensureDefault("assume_success_timeout", 0);
|
135
|
+
|
136
|
+
// File Settings
|
137
|
+
this.ensureDefault("file_types", "*.*");
|
138
|
+
this.ensureDefault("file_types_description", "All Files");
|
139
|
+
this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
|
140
|
+
this.ensureDefault("file_upload_limit", 0);
|
141
|
+
this.ensureDefault("file_queue_limit", 0);
|
142
|
+
|
143
|
+
// Flash Settings
|
144
|
+
this.ensureDefault("flash_url", "swfupload.swf");
|
145
|
+
this.ensureDefault("prevent_swf_caching", true);
|
146
|
+
|
147
|
+
// Button Settings
|
148
|
+
this.ensureDefault("button_image_url", "");
|
149
|
+
this.ensureDefault("button_width", 1);
|
150
|
+
this.ensureDefault("button_height", 1);
|
151
|
+
this.ensureDefault("button_text", "");
|
152
|
+
this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
|
153
|
+
this.ensureDefault("button_text_top_padding", 0);
|
154
|
+
this.ensureDefault("button_text_left_padding", 0);
|
155
|
+
this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
|
156
|
+
this.ensureDefault("button_disabled", false);
|
157
|
+
this.ensureDefault("button_placeholder_id", "");
|
158
|
+
this.ensureDefault("button_placeholder", null);
|
159
|
+
this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
|
160
|
+
this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
|
161
|
+
|
162
|
+
// Debug Settings
|
163
|
+
this.ensureDefault("debug", false);
|
164
|
+
this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
|
165
|
+
|
166
|
+
// Event Handlers
|
167
|
+
this.settings.return_upload_start_handler = this.returnUploadStart;
|
168
|
+
this.ensureDefault("swfupload_loaded_handler", null);
|
169
|
+
this.ensureDefault("file_dialog_start_handler", null);
|
170
|
+
this.ensureDefault("file_queued_handler", null);
|
171
|
+
this.ensureDefault("file_queue_error_handler", null);
|
172
|
+
this.ensureDefault("file_dialog_complete_handler", null);
|
173
|
+
|
174
|
+
this.ensureDefault("upload_start_handler", null);
|
175
|
+
this.ensureDefault("upload_progress_handler", null);
|
176
|
+
this.ensureDefault("upload_error_handler", null);
|
177
|
+
this.ensureDefault("upload_success_handler", null);
|
178
|
+
this.ensureDefault("upload_complete_handler", null);
|
179
|
+
|
180
|
+
this.ensureDefault("debug_handler", this.debugMessage);
|
181
|
+
|
182
|
+
this.ensureDefault("custom_settings", {});
|
183
|
+
|
184
|
+
// Other settings
|
185
|
+
this.customSettings = this.settings.custom_settings;
|
186
|
+
|
187
|
+
// Update the flash url if needed
|
188
|
+
if (!!this.settings.prevent_swf_caching) {
|
189
|
+
this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
|
190
|
+
}
|
191
|
+
|
192
|
+
if (!this.settings.preserve_relative_urls) {
|
193
|
+
//this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
|
194
|
+
this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
|
195
|
+
this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
|
196
|
+
}
|
197
|
+
|
198
|
+
delete this.ensureDefault;
|
199
|
+
};
|
200
|
+
|
201
|
+
// Private: loadFlash replaces the button_placeholder element with the flash movie.
|
202
|
+
SWFUpload.prototype.loadFlash = function () {
|
203
|
+
var targetElement, tempParent;
|
204
|
+
|
205
|
+
// Make sure an element with the ID we are going to use doesn't already exist
|
206
|
+
if (document.getElementById(this.movieName) !== null) {
|
207
|
+
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
|
208
|
+
}
|
209
|
+
|
210
|
+
// Get the element where we will be placing the flash movie
|
211
|
+
targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
|
212
|
+
|
213
|
+
if (targetElement == undefined) {
|
214
|
+
throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
|
215
|
+
}
|
216
|
+
|
217
|
+
// Append the container and load the flash
|
218
|
+
tempParent = document.createElement("div");
|
219
|
+
tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
|
220
|
+
targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
|
221
|
+
|
222
|
+
// Fix IE Flash/Form bug
|
223
|
+
if (window[this.movieName] == undefined) {
|
224
|
+
window[this.movieName] = this.getMovieElement();
|
225
|
+
}
|
226
|
+
|
227
|
+
};
|
228
|
+
|
229
|
+
// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
|
230
|
+
SWFUpload.prototype.getFlashHTML = function () {
|
231
|
+
// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
|
232
|
+
return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
|
233
|
+
'<param name="wmode" value="', this.settings.button_window_mode, '" />',
|
234
|
+
'<param name="movie" value="', this.settings.flash_url, '" />',
|
235
|
+
'<param name="quality" value="high" />',
|
236
|
+
'<param name="menu" value="false" />',
|
237
|
+
'<param name="allowScriptAccess" value="always" />',
|
238
|
+
'<param name="flashvars" value="' + this.getFlashVars() + '" />',
|
239
|
+
'</object>'].join("");
|
240
|
+
};
|
241
|
+
|
242
|
+
// Private: getFlashVars builds the parameter string that will be passed
|
243
|
+
// to flash in the flashvars param.
|
244
|
+
SWFUpload.prototype.getFlashVars = function () {
|
245
|
+
// Build a string from the post param object
|
246
|
+
var paramString = this.buildParamString();
|
247
|
+
var httpSuccessString = this.settings.http_success.join(",");
|
248
|
+
|
249
|
+
// Build the parameter string
|
250
|
+
return ["movieName=", encodeURIComponent(this.movieName),
|
251
|
+
"&uploadURL=", encodeURIComponent(this.settings.upload_url),
|
252
|
+
"&useQueryString=", encodeURIComponent(this.settings.use_query_string),
|
253
|
+
"&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
|
254
|
+
"&httpSuccess=", encodeURIComponent(httpSuccessString),
|
255
|
+
"&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
|
256
|
+
"&params=", encodeURIComponent(paramString),
|
257
|
+
"&filePostName=", encodeURIComponent(this.settings.file_post_name),
|
258
|
+
"&fileTypes=", encodeURIComponent(this.settings.file_types),
|
259
|
+
"&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
|
260
|
+
"&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
|
261
|
+
"&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
|
262
|
+
"&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
|
263
|
+
"&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
|
264
|
+
"&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
|
265
|
+
"&buttonWidth=", encodeURIComponent(this.settings.button_width),
|
266
|
+
"&buttonHeight=", encodeURIComponent(this.settings.button_height),
|
267
|
+
"&buttonText=", encodeURIComponent(this.settings.button_text),
|
268
|
+
"&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
|
269
|
+
"&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
|
270
|
+
"&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
|
271
|
+
"&buttonAction=", encodeURIComponent(this.settings.button_action),
|
272
|
+
"&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
|
273
|
+
"&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
|
274
|
+
].join("");
|
275
|
+
};
|
276
|
+
|
277
|
+
// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
|
278
|
+
// The element is cached after the first lookup
|
279
|
+
SWFUpload.prototype.getMovieElement = function () {
|
280
|
+
if (this.movieElement == undefined) {
|
281
|
+
this.movieElement = document.getElementById(this.movieName);
|
282
|
+
}
|
283
|
+
|
284
|
+
if (this.movieElement === null) {
|
285
|
+
throw "Could not find Flash element";
|
286
|
+
}
|
287
|
+
|
288
|
+
return this.movieElement;
|
289
|
+
};
|
290
|
+
|
291
|
+
// Private: buildParamString takes the name/value pairs in the post_params setting object
|
292
|
+
// and joins them up in to a string formatted "name=value&name=value"
|
293
|
+
SWFUpload.prototype.buildParamString = function () {
|
294
|
+
var postParams = this.settings.post_params;
|
295
|
+
var paramStringPairs = [];
|
296
|
+
|
297
|
+
if (typeof(postParams) === "object") {
|
298
|
+
for (var name in postParams) {
|
299
|
+
if (postParams.hasOwnProperty(name)) {
|
300
|
+
paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
return paramStringPairs.join("&");
|
306
|
+
};
|
307
|
+
|
308
|
+
// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
|
309
|
+
// all references to the SWF, and other objects so memory is properly freed.
|
310
|
+
// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
|
311
|
+
// Credits: Major improvements provided by steffen
|
312
|
+
SWFUpload.prototype.destroy = function () {
|
313
|
+
try {
|
314
|
+
// Make sure Flash is done before we try to remove it
|
315
|
+
this.cancelUpload(null, false);
|
316
|
+
|
317
|
+
|
318
|
+
// Remove the SWFUpload DOM nodes
|
319
|
+
var movieElement = null;
|
320
|
+
movieElement = this.getMovieElement();
|
321
|
+
|
322
|
+
if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
|
323
|
+
// Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
|
324
|
+
for (var i in movieElement) {
|
325
|
+
try {
|
326
|
+
if (typeof(movieElement[i]) === "function") {
|
327
|
+
movieElement[i] = null;
|
328
|
+
}
|
329
|
+
} catch (ex1) {}
|
330
|
+
}
|
331
|
+
|
332
|
+
// Remove the Movie Element from the page
|
333
|
+
try {
|
334
|
+
movieElement.parentNode.removeChild(movieElement);
|
335
|
+
} catch (ex) {}
|
336
|
+
}
|
337
|
+
|
338
|
+
// Remove IE form fix reference
|
339
|
+
window[this.movieName] = null;
|
340
|
+
|
341
|
+
// Destroy other references
|
342
|
+
SWFUpload.instances[this.movieName] = null;
|
343
|
+
delete SWFUpload.instances[this.movieName];
|
344
|
+
|
345
|
+
this.movieElement = null;
|
346
|
+
this.settings = null;
|
347
|
+
this.customSettings = null;
|
348
|
+
this.eventQueue = null;
|
349
|
+
this.movieName = null;
|
350
|
+
|
351
|
+
|
352
|
+
return true;
|
353
|
+
} catch (ex2) {
|
354
|
+
return false;
|
355
|
+
}
|
356
|
+
};
|
357
|
+
|
358
|
+
|
359
|
+
// Public: displayDebugInfo prints out settings and configuration
|
360
|
+
// information about this SWFUpload instance.
|
361
|
+
// This function (and any references to it) can be deleted when placing
|
362
|
+
// SWFUpload in production.
|
363
|
+
SWFUpload.prototype.displayDebugInfo = function () {
|
364
|
+
this.debug(
|
365
|
+
[
|
366
|
+
"---SWFUpload Instance Info---\n",
|
367
|
+
"Version: ", SWFUpload.version, "\n",
|
368
|
+
"Movie Name: ", this.movieName, "\n",
|
369
|
+
"Settings:\n",
|
370
|
+
"\t", "upload_url: ", this.settings.upload_url, "\n",
|
371
|
+
"\t", "flash_url: ", this.settings.flash_url, "\n",
|
372
|
+
"\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
|
373
|
+
"\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
|
374
|
+
"\t", "http_success: ", this.settings.http_success.join(", "), "\n",
|
375
|
+
"\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
|
376
|
+
"\t", "file_post_name: ", this.settings.file_post_name, "\n",
|
377
|
+
"\t", "post_params: ", this.settings.post_params.toString(), "\n",
|
378
|
+
"\t", "file_types: ", this.settings.file_types, "\n",
|
379
|
+
"\t", "file_types_description: ", this.settings.file_types_description, "\n",
|
380
|
+
"\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
|
381
|
+
"\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
|
382
|
+
"\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
|
383
|
+
"\t", "debug: ", this.settings.debug.toString(), "\n",
|
384
|
+
|
385
|
+
"\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
|
386
|
+
|
387
|
+
"\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
|
388
|
+
"\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
|
389
|
+
"\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
|
390
|
+
"\t", "button_width: ", this.settings.button_width.toString(), "\n",
|
391
|
+
"\t", "button_height: ", this.settings.button_height.toString(), "\n",
|
392
|
+
"\t", "button_text: ", this.settings.button_text.toString(), "\n",
|
393
|
+
"\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
|
394
|
+
"\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
|
395
|
+
"\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
|
396
|
+
"\t", "button_action: ", this.settings.button_action.toString(), "\n",
|
397
|
+
"\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
|
398
|
+
|
399
|
+
"\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
|
400
|
+
"Event Handlers:\n",
|
401
|
+
"\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
|
402
|
+
"\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
|
403
|
+
"\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
|
404
|
+
"\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
|
405
|
+
"\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
|
406
|
+
"\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
|
407
|
+
"\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
|
408
|
+
"\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
|
409
|
+
"\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
|
410
|
+
"\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
|
411
|
+
].join("")
|
412
|
+
);
|
413
|
+
};
|
414
|
+
|
415
|
+
/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
|
416
|
+
the maintain v2 API compatibility
|
417
|
+
*/
|
418
|
+
// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
|
419
|
+
SWFUpload.prototype.addSetting = function (name, value, default_value) {
|
420
|
+
if (value == undefined) {
|
421
|
+
return (this.settings[name] = default_value);
|
422
|
+
} else {
|
423
|
+
return (this.settings[name] = value);
|
424
|
+
}
|
425
|
+
};
|
426
|
+
|
427
|
+
// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
|
428
|
+
SWFUpload.prototype.getSetting = function (name) {
|
429
|
+
if (this.settings[name] != undefined) {
|
430
|
+
return this.settings[name];
|
431
|
+
}
|
432
|
+
|
433
|
+
return "";
|
434
|
+
};
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
// Private: callFlash handles function calls made to the Flash element.
|
439
|
+
// Calls are made with a setTimeout for some functions to work around
|
440
|
+
// bugs in the ExternalInterface library.
|
441
|
+
SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
|
442
|
+
argumentArray = argumentArray || [];
|
443
|
+
|
444
|
+
var movieElement = this.getMovieElement();
|
445
|
+
var returnValue, returnString;
|
446
|
+
|
447
|
+
// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
|
448
|
+
try {
|
449
|
+
returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
|
450
|
+
returnValue = eval(returnString);
|
451
|
+
} catch (ex) {
|
452
|
+
throw "Call to " + functionName + " failed";
|
453
|
+
}
|
454
|
+
|
455
|
+
// Unescape file post param values
|
456
|
+
if (returnValue != undefined && typeof returnValue.post === "object") {
|
457
|
+
returnValue = this.unescapeFilePostParams(returnValue);
|
458
|
+
}
|
459
|
+
|
460
|
+
return returnValue;
|
461
|
+
};
|
462
|
+
|
463
|
+
/* *****************************
|
464
|
+
-- Flash control methods --
|
465
|
+
Your UI should use these
|
466
|
+
to operate SWFUpload
|
467
|
+
***************************** */
|
468
|
+
|
469
|
+
// WARNING: this function does not work in Flash Player 10
|
470
|
+
// Public: selectFile causes a File Selection Dialog window to appear. This
|
471
|
+
// dialog only allows 1 file to be selected.
|
472
|
+
SWFUpload.prototype.selectFile = function () {
|
473
|
+
this.callFlash("SelectFile");
|
474
|
+
};
|
475
|
+
|
476
|
+
// WARNING: this function does not work in Flash Player 10
|
477
|
+
// Public: selectFiles causes a File Selection Dialog window to appear/ This
|
478
|
+
// dialog allows the user to select any number of files
|
479
|
+
// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
|
480
|
+
// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
|
481
|
+
// for this bug.
|
482
|
+
SWFUpload.prototype.selectFiles = function () {
|
483
|
+
this.callFlash("SelectFiles");
|
484
|
+
};
|
485
|
+
|
486
|
+
|
487
|
+
// Public: startUpload starts uploading the first file in the queue unless
|
488
|
+
// the optional parameter 'fileID' specifies the ID
|
489
|
+
SWFUpload.prototype.startUpload = function (fileID) {
|
490
|
+
this.callFlash("StartUpload", [fileID]);
|
491
|
+
};
|
492
|
+
|
493
|
+
// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
|
494
|
+
// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
|
495
|
+
// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
|
496
|
+
SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
|
497
|
+
if (triggerErrorEvent !== false) {
|
498
|
+
triggerErrorEvent = true;
|
499
|
+
}
|
500
|
+
this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
|
501
|
+
};
|
502
|
+
|
503
|
+
// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
|
504
|
+
// If nothing is currently uploading then nothing happens.
|
505
|
+
SWFUpload.prototype.stopUpload = function () {
|
506
|
+
this.callFlash("StopUpload");
|
507
|
+
};
|
508
|
+
|
509
|
+
/* ************************
|
510
|
+
* Settings methods
|
511
|
+
* These methods change the SWFUpload settings.
|
512
|
+
* SWFUpload settings should not be changed directly on the settings object
|
513
|
+
* since many of the settings need to be passed to Flash in order to take
|
514
|
+
* effect.
|
515
|
+
* *********************** */
|
516
|
+
|
517
|
+
// Public: getStats gets the file statistics object.
|
518
|
+
SWFUpload.prototype.getStats = function () {
|
519
|
+
return this.callFlash("GetStats");
|
520
|
+
};
|
521
|
+
|
522
|
+
// Public: setStats changes the SWFUpload statistics. You shouldn't need to
|
523
|
+
// change the statistics but you can. Changing the statistics does not
|
524
|
+
// affect SWFUpload accept for the successful_uploads count which is used
|
525
|
+
// by the upload_limit setting to determine how many files the user may upload.
|
526
|
+
SWFUpload.prototype.setStats = function (statsObject) {
|
527
|
+
this.callFlash("SetStats", [statsObject]);
|
528
|
+
};
|
529
|
+
|
530
|
+
// Public: getFile retrieves a File object by ID or Index. If the file is
|
531
|
+
// not found then 'null' is returned.
|
532
|
+
SWFUpload.prototype.getFile = function (fileID) {
|
533
|
+
if (typeof(fileID) === "number") {
|
534
|
+
return this.callFlash("GetFileByIndex", [fileID]);
|
535
|
+
} else {
|
536
|
+
return this.callFlash("GetFile", [fileID]);
|
537
|
+
}
|
538
|
+
};
|
539
|
+
|
540
|
+
// Public: addFileParam sets a name/value pair that will be posted with the
|
541
|
+
// file specified by the Files ID. If the name already exists then the
|
542
|
+
// exiting value will be overwritten.
|
543
|
+
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
|
544
|
+
return this.callFlash("AddFileParam", [fileID, name, value]);
|
545
|
+
};
|
546
|
+
|
547
|
+
// Public: removeFileParam removes a previously set (by addFileParam) name/value
|
548
|
+
// pair from the specified file.
|
549
|
+
SWFUpload.prototype.removeFileParam = function (fileID, name) {
|
550
|
+
this.callFlash("RemoveFileParam", [fileID, name]);
|
551
|
+
};
|
552
|
+
|
553
|
+
// Public: setUploadUrl changes the upload_url setting.
|
554
|
+
SWFUpload.prototype.setUploadURL = function (url) {
|
555
|
+
this.settings.upload_url = url.toString();
|
556
|
+
this.callFlash("SetUploadURL", [url]);
|
557
|
+
};
|
558
|
+
|
559
|
+
// Public: setPostParams changes the post_params setting
|
560
|
+
SWFUpload.prototype.setPostParams = function (paramsObject) {
|
561
|
+
this.settings.post_params = paramsObject;
|
562
|
+
this.callFlash("SetPostParams", [paramsObject]);
|
563
|
+
};
|
564
|
+
|
565
|
+
// Public: addPostParam adds post name/value pair. Each name can have only one value.
|
566
|
+
SWFUpload.prototype.addPostParam = function (name, value) {
|
567
|
+
this.settings.post_params[name] = value;
|
568
|
+
this.callFlash("SetPostParams", [this.settings.post_params]);
|
569
|
+
};
|
570
|
+
|
571
|
+
// Public: removePostParam deletes post name/value pair.
|
572
|
+
SWFUpload.prototype.removePostParam = function (name) {
|
573
|
+
delete this.settings.post_params[name];
|
574
|
+
this.callFlash("SetPostParams", [this.settings.post_params]);
|
575
|
+
};
|
576
|
+
|
577
|
+
// Public: setFileTypes changes the file_types setting and the file_types_description setting
|
578
|
+
SWFUpload.prototype.setFileTypes = function (types, description) {
|
579
|
+
this.settings.file_types = types;
|
580
|
+
this.settings.file_types_description = description;
|
581
|
+
this.callFlash("SetFileTypes", [types, description]);
|
582
|
+
};
|
583
|
+
|
584
|
+
// Public: setFileSizeLimit changes the file_size_limit setting
|
585
|
+
SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
|
586
|
+
this.settings.file_size_limit = fileSizeLimit;
|
587
|
+
this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
|
588
|
+
};
|
589
|
+
|
590
|
+
// Public: setFileUploadLimit changes the file_upload_limit setting
|
591
|
+
SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
|
592
|
+
this.settings.file_upload_limit = fileUploadLimit;
|
593
|
+
this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
|
594
|
+
};
|
595
|
+
|
596
|
+
// Public: setFileQueueLimit changes the file_queue_limit setting
|
597
|
+
SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
|
598
|
+
this.settings.file_queue_limit = fileQueueLimit;
|
599
|
+
this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
|
600
|
+
};
|
601
|
+
|
602
|
+
// Public: setFilePostName changes the file_post_name setting
|
603
|
+
SWFUpload.prototype.setFilePostName = function (filePostName) {
|
604
|
+
this.settings.file_post_name = filePostName;
|
605
|
+
this.callFlash("SetFilePostName", [filePostName]);
|
606
|
+
};
|
607
|
+
|
608
|
+
// Public: setUseQueryString changes the use_query_string setting
|
609
|
+
SWFUpload.prototype.setUseQueryString = function (useQueryString) {
|
610
|
+
this.settings.use_query_string = useQueryString;
|
611
|
+
this.callFlash("SetUseQueryString", [useQueryString]);
|
612
|
+
};
|
613
|
+
|
614
|
+
// Public: setRequeueOnError changes the requeue_on_error setting
|
615
|
+
SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
|
616
|
+
this.settings.requeue_on_error = requeueOnError;
|
617
|
+
this.callFlash("SetRequeueOnError", [requeueOnError]);
|
618
|
+
};
|
619
|
+
|
620
|
+
// Public: setHTTPSuccess changes the http_success setting
|
621
|
+
SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
|
622
|
+
if (typeof http_status_codes === "string") {
|
623
|
+
http_status_codes = http_status_codes.replace(" ", "").split(",");
|
624
|
+
}
|
625
|
+
|
626
|
+
this.settings.http_success = http_status_codes;
|
627
|
+
this.callFlash("SetHTTPSuccess", [http_status_codes]);
|
628
|
+
};
|
629
|
+
|
630
|
+
// Public: setHTTPSuccess changes the http_success setting
|
631
|
+
SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
|
632
|
+
this.settings.assume_success_timeout = timeout_seconds;
|
633
|
+
this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
|
634
|
+
};
|
635
|
+
|
636
|
+
// Public: setDebugEnabled changes the debug_enabled setting
|
637
|
+
SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
|
638
|
+
this.settings.debug_enabled = debugEnabled;
|
639
|
+
this.callFlash("SetDebugEnabled", [debugEnabled]);
|
640
|
+
};
|
641
|
+
|
642
|
+
// Public: setButtonImageURL loads a button image sprite
|
643
|
+
SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
|
644
|
+
if (buttonImageURL == undefined) {
|
645
|
+
buttonImageURL = "";
|
646
|
+
}
|
647
|
+
|
648
|
+
this.settings.button_image_url = buttonImageURL;
|
649
|
+
this.callFlash("SetButtonImageURL", [buttonImageURL]);
|
650
|
+
};
|
651
|
+
|
652
|
+
// Public: setButtonDimensions resizes the Flash Movie and button
|
653
|
+
SWFUpload.prototype.setButtonDimensions = function (width, height) {
|
654
|
+
this.settings.button_width = width;
|
655
|
+
this.settings.button_height = height;
|
656
|
+
|
657
|
+
var movie = this.getMovieElement();
|
658
|
+
if (movie != undefined) {
|
659
|
+
movie.style.width = width + "px";
|
660
|
+
movie.style.height = height + "px";
|
661
|
+
}
|
662
|
+
|
663
|
+
this.callFlash("SetButtonDimensions", [width, height]);
|
664
|
+
};
|
665
|
+
// Public: setButtonText Changes the text overlaid on the button
|
666
|
+
SWFUpload.prototype.setButtonText = function (html) {
|
667
|
+
this.settings.button_text = html;
|
668
|
+
this.callFlash("SetButtonText", [html]);
|
669
|
+
};
|
670
|
+
// Public: setButtonTextPadding changes the top and left padding of the text overlay
|
671
|
+
SWFUpload.prototype.setButtonTextPadding = function (left, top) {
|
672
|
+
this.settings.button_text_top_padding = top;
|
673
|
+
this.settings.button_text_left_padding = left;
|
674
|
+
this.callFlash("SetButtonTextPadding", [left, top]);
|
675
|
+
};
|
676
|
+
|
677
|
+
// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
|
678
|
+
SWFUpload.prototype.setButtonTextStyle = function (css) {
|
679
|
+
this.settings.button_text_style = css;
|
680
|
+
this.callFlash("SetButtonTextStyle", [css]);
|
681
|
+
};
|
682
|
+
// Public: setButtonDisabled disables/enables the button
|
683
|
+
SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
|
684
|
+
this.settings.button_disabled = isDisabled;
|
685
|
+
this.callFlash("SetButtonDisabled", [isDisabled]);
|
686
|
+
};
|
687
|
+
// Public: setButtonAction sets the action that occurs when the button is clicked
|
688
|
+
SWFUpload.prototype.setButtonAction = function (buttonAction) {
|
689
|
+
this.settings.button_action = buttonAction;
|
690
|
+
this.callFlash("SetButtonAction", [buttonAction]);
|
691
|
+
};
|
692
|
+
|
693
|
+
// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
|
694
|
+
SWFUpload.prototype.setButtonCursor = function (cursor) {
|
695
|
+
this.settings.button_cursor = cursor;
|
696
|
+
this.callFlash("SetButtonCursor", [cursor]);
|
697
|
+
};
|
698
|
+
|
699
|
+
/* *******************************
|
700
|
+
Flash Event Interfaces
|
701
|
+
These functions are used by Flash to trigger the various
|
702
|
+
events.
|
703
|
+
|
704
|
+
All these functions a Private.
|
705
|
+
|
706
|
+
Because the ExternalInterface library is buggy the event calls
|
707
|
+
are added to a queue and the queue then executed by a setTimeout.
|
708
|
+
This ensures that events are executed in a determinate order and that
|
709
|
+
the ExternalInterface bugs are avoided.
|
710
|
+
******************************* */
|
711
|
+
|
712
|
+
SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
|
713
|
+
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
714
|
+
|
715
|
+
if (argumentArray == undefined) {
|
716
|
+
argumentArray = [];
|
717
|
+
} else if (!(argumentArray instanceof Array)) {
|
718
|
+
argumentArray = [argumentArray];
|
719
|
+
}
|
720
|
+
|
721
|
+
var self = this;
|
722
|
+
if (typeof this.settings[handlerName] === "function") {
|
723
|
+
// Queue the event
|
724
|
+
this.eventQueue.push(function () {
|
725
|
+
this.settings[handlerName].apply(this, argumentArray);
|
726
|
+
});
|
727
|
+
|
728
|
+
// Execute the next queued event
|
729
|
+
setTimeout(function () {
|
730
|
+
self.executeNextEvent();
|
731
|
+
}, 0);
|
732
|
+
|
733
|
+
} else if (this.settings[handlerName] !== null) {
|
734
|
+
throw "Event handler " + handlerName + " is unknown or is not a function";
|
735
|
+
}
|
736
|
+
};
|
737
|
+
|
738
|
+
// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
|
739
|
+
// we must queue them in order to garentee that they are executed in order.
|
740
|
+
SWFUpload.prototype.executeNextEvent = function () {
|
741
|
+
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
742
|
+
|
743
|
+
var f = this.eventQueue ? this.eventQueue.shift() : null;
|
744
|
+
if (typeof(f) === "function") {
|
745
|
+
f.apply(this);
|
746
|
+
}
|
747
|
+
};
|
748
|
+
|
749
|
+
// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
|
750
|
+
// properties that contain characters that are not valid for JavaScript identifiers. To work around this
|
751
|
+
// the Flash Component escapes the parameter names and we must unescape again before passing them along.
|
752
|
+
SWFUpload.prototype.unescapeFilePostParams = function (file) {
|
753
|
+
var reg = /[$]([0-9a-f]{4})/i;
|
754
|
+
var unescapedPost = {};
|
755
|
+
var uk;
|
756
|
+
|
757
|
+
if (file != undefined) {
|
758
|
+
for (var k in file.post) {
|
759
|
+
if (file.post.hasOwnProperty(k)) {
|
760
|
+
uk = k;
|
761
|
+
var match;
|
762
|
+
while ((match = reg.exec(uk)) !== null) {
|
763
|
+
uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
|
764
|
+
}
|
765
|
+
unescapedPost[uk] = file.post[k];
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
file.post = unescapedPost;
|
770
|
+
}
|
771
|
+
|
772
|
+
return file;
|
773
|
+
};
|
774
|
+
|
775
|
+
// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
|
776
|
+
SWFUpload.prototype.testExternalInterface = function () {
|
777
|
+
try {
|
778
|
+
return this.callFlash("TestExternalInterface");
|
779
|
+
} catch (ex) {
|
780
|
+
return false;
|
781
|
+
}
|
782
|
+
};
|
783
|
+
|
784
|
+
// Private: This event is called by Flash when it has finished loading. Don't modify this.
|
785
|
+
// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
|
786
|
+
SWFUpload.prototype.flashReady = function () {
|
787
|
+
// Check that the movie element is loaded correctly with its ExternalInterface methods defined
|
788
|
+
var movieElement = this.getMovieElement();
|
789
|
+
|
790
|
+
if (!movieElement) {
|
791
|
+
this.debug("Flash called back ready but the flash movie can't be found.");
|
792
|
+
return;
|
793
|
+
}
|
794
|
+
|
795
|
+
this.cleanUp(movieElement);
|
796
|
+
|
797
|
+
this.queueEvent("swfupload_loaded_handler");
|
798
|
+
};
|
799
|
+
|
800
|
+
// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
|
801
|
+
// This function is called by Flash each time the ExternalInterface functions are created.
|
802
|
+
SWFUpload.prototype.cleanUp = function (movieElement) {
|
803
|
+
// Pro-actively unhook all the Flash functions
|
804
|
+
try {
|
805
|
+
if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
|
806
|
+
this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
|
807
|
+
for (var key in movieElement) {
|
808
|
+
try {
|
809
|
+
if (typeof(movieElement[key]) === "function") {
|
810
|
+
movieElement[key] = null;
|
811
|
+
}
|
812
|
+
} catch (ex) {
|
813
|
+
}
|
814
|
+
}
|
815
|
+
}
|
816
|
+
} catch (ex1) {
|
817
|
+
|
818
|
+
}
|
819
|
+
|
820
|
+
// Fix Flashes own cleanup code so if the SWFMovie was removed from the page
|
821
|
+
// it doesn't display errors.
|
822
|
+
window["__flash__removeCallback"] = function (instance, name) {
|
823
|
+
try {
|
824
|
+
if (instance) {
|
825
|
+
instance[name] = null;
|
826
|
+
}
|
827
|
+
} catch (flashEx) {
|
828
|
+
|
829
|
+
}
|
830
|
+
};
|
831
|
+
|
832
|
+
};
|
833
|
+
|
834
|
+
|
835
|
+
/* This is a chance to do something before the browse window opens */
|
836
|
+
SWFUpload.prototype.fileDialogStart = function () {
|
837
|
+
this.queueEvent("file_dialog_start_handler");
|
838
|
+
};
|
839
|
+
|
840
|
+
|
841
|
+
/* Called when a file is successfully added to the queue. */
|
842
|
+
SWFUpload.prototype.fileQueued = function (file) {
|
843
|
+
file = this.unescapeFilePostParams(file);
|
844
|
+
this.queueEvent("file_queued_handler", file);
|
845
|
+
};
|
846
|
+
|
847
|
+
|
848
|
+
/* Handle errors that occur when an attempt to queue a file fails. */
|
849
|
+
SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
|
850
|
+
file = this.unescapeFilePostParams(file);
|
851
|
+
this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
|
852
|
+
};
|
853
|
+
|
854
|
+
/* Called after the file dialog has closed and the selected files have been queued.
|
855
|
+
You could call startUpload here if you want the queued files to begin uploading immediately. */
|
856
|
+
SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
|
857
|
+
this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
|
858
|
+
};
|
859
|
+
|
860
|
+
SWFUpload.prototype.uploadStart = function (file) {
|
861
|
+
file = this.unescapeFilePostParams(file);
|
862
|
+
this.queueEvent("return_upload_start_handler", file);
|
863
|
+
};
|
864
|
+
|
865
|
+
SWFUpload.prototype.returnUploadStart = function (file) {
|
866
|
+
var returnValue;
|
867
|
+
if (typeof this.settings.upload_start_handler === "function") {
|
868
|
+
file = this.unescapeFilePostParams(file);
|
869
|
+
returnValue = this.settings.upload_start_handler.call(this, file);
|
870
|
+
} else if (this.settings.upload_start_handler != undefined) {
|
871
|
+
throw "upload_start_handler must be a function";
|
872
|
+
}
|
873
|
+
|
874
|
+
// Convert undefined to true so if nothing is returned from the upload_start_handler it is
|
875
|
+
// interpretted as 'true'.
|
876
|
+
if (returnValue === undefined) {
|
877
|
+
returnValue = true;
|
878
|
+
}
|
879
|
+
|
880
|
+
returnValue = !!returnValue;
|
881
|
+
|
882
|
+
this.callFlash("ReturnUploadStart", [returnValue]);
|
883
|
+
};
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
|
888
|
+
file = this.unescapeFilePostParams(file);
|
889
|
+
this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
|
890
|
+
};
|
891
|
+
|
892
|
+
SWFUpload.prototype.uploadError = function (file, errorCode, message) {
|
893
|
+
file = this.unescapeFilePostParams(file);
|
894
|
+
this.queueEvent("upload_error_handler", [file, errorCode, message]);
|
895
|
+
};
|
896
|
+
|
897
|
+
SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
|
898
|
+
file = this.unescapeFilePostParams(file);
|
899
|
+
this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
|
900
|
+
};
|
901
|
+
|
902
|
+
SWFUpload.prototype.uploadComplete = function (file) {
|
903
|
+
file = this.unescapeFilePostParams(file);
|
904
|
+
this.queueEvent("upload_complete_handler", file);
|
905
|
+
};
|
906
|
+
|
907
|
+
/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
|
908
|
+
internal debug console. You can override this event and have messages written where you want. */
|
909
|
+
SWFUpload.prototype.debug = function (message) {
|
910
|
+
this.queueEvent("debug_handler", message);
|
911
|
+
};
|
912
|
+
|
913
|
+
|
914
|
+
/* **********************************
|
915
|
+
Debug Console
|
916
|
+
The debug console is a self contained, in page location
|
917
|
+
for debug message to be sent. The Debug Console adds
|
918
|
+
itself to the body if necessary.
|
919
|
+
|
920
|
+
The console is automatically scrolled as messages appear.
|
921
|
+
|
922
|
+
If you are using your own debug handler or when you deploy to production and
|
923
|
+
have debug disabled you can remove these functions to reduce the file size
|
924
|
+
and complexity.
|
925
|
+
********************************** */
|
926
|
+
|
927
|
+
// Private: debugMessage is the default debug_handler. If you want to print debug messages
|
928
|
+
// call the debug() function. When overriding the function your own function should
|
929
|
+
// check to see if the debug setting is true before outputting debug information.
|
930
|
+
SWFUpload.prototype.debugMessage = function (message) {
|
931
|
+
if (this.settings.debug) {
|
932
|
+
var exceptionMessage, exceptionValues = [];
|
933
|
+
|
934
|
+
// Check for an exception object and print it nicely
|
935
|
+
if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
|
936
|
+
for (var key in message) {
|
937
|
+
if (message.hasOwnProperty(key)) {
|
938
|
+
exceptionValues.push(key + ": " + message[key]);
|
939
|
+
}
|
940
|
+
}
|
941
|
+
exceptionMessage = exceptionValues.join("\n") || "";
|
942
|
+
exceptionValues = exceptionMessage.split("\n");
|
943
|
+
exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
|
944
|
+
SWFUpload.Console.writeLine(exceptionMessage);
|
945
|
+
} else {
|
946
|
+
SWFUpload.Console.writeLine(message);
|
947
|
+
}
|
948
|
+
}
|
949
|
+
};
|
950
|
+
|
951
|
+
SWFUpload.Console = {};
|
952
|
+
SWFUpload.Console.writeLine = function (message) {
|
953
|
+
var console, documentForm;
|
954
|
+
|
955
|
+
try {
|
956
|
+
console = document.getElementById("SWFUpload_Console");
|
957
|
+
|
958
|
+
if (!console) {
|
959
|
+
documentForm = document.createElement("form");
|
960
|
+
document.getElementsByTagName("body")[0].appendChild(documentForm);
|
961
|
+
|
962
|
+
console = document.createElement("textarea");
|
963
|
+
console.id = "SWFUpload_Console";
|
964
|
+
console.style.fontFamily = "monospace";
|
965
|
+
console.setAttribute("wrap", "off");
|
966
|
+
console.wrap = "off";
|
967
|
+
console.style.overflow = "auto";
|
968
|
+
console.style.width = "700px";
|
969
|
+
console.style.height = "350px";
|
970
|
+
console.style.margin = "5px";
|
971
|
+
documentForm.appendChild(console);
|
972
|
+
}
|
973
|
+
|
974
|
+
console.value += message + "\n";
|
975
|
+
|
976
|
+
console.scrollTop = console.scrollHeight - console.clientHeight;
|
977
|
+
} catch (ex) {
|
978
|
+
alert("Exception: " + ex.name + " Message: " + ex.message);
|
979
|
+
}
|
980
|
+
};
|