You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
8.1 KiB
25 lines
8.1 KiB
/*
|
|
Uploadify v2.1.4
|
|
Release Date: November 8, 2010
|
|
|
|
Copyright (c) 2010 Ronnie Garcia, Travis Nickels
|
|
|
|
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.
|
|
*/
|
|
jQuery&&function(a){a.extend(a.fn,{uploadify:function(b){a(this).each(function(){var c=a.extend({id:a(this).attr("id"),uploader:"uploadify.swf",script:"uploadify.php",expressInstall:null,folder:"",height:30,width:120,cancelImg:"cancel.png",wmode:"opaque",scriptAccess:"sameDomain",fileDataName:"Filedata",method:"POST",queueSizeLimit:999,simUploadLimit:1,queueID:!1,displayData:"percentage",removeCompleted:!0,onInit:function(){},onSelect:function(){},onSelectOnce:function(){},onQueueFull:function(){},onCheck:function(){},onCancel:function(){},onClearQueue:function(){},onError:function(){},onProgress:function(){},onComplete:function(){},onAllComplete:function(){}},b);a(this).data("settings",c);var d=location.pathname;d=d.split("/"),d.pop(),d=d.join("/")+"/";var e={};e.uploadifyID=c.id,e.pagepath=d,c.buttonImg&&(e.buttonImg=escape(c.buttonImg)),c.buttonText&&(e.buttonText=escape(c.buttonText)),c.rollover&&(e.rollover=!0),e.script=c.script,e.folder=escape(c.folder);if(c.scriptData){var f="";for(var g in c.scriptData)f+="&"+g+"="+c.scriptData[g];e.scriptData=escape(f.substr(1))}e.width=c.width,e.height=c.height,e.wmode=c.wmode,e.method=c.method,e.queueSizeLimit=c.queueSizeLimit,e.simUploadLimit=c.simUploadLimit,c.hideButton&&(e.hideButton=!0),c.fileDesc&&(e.fileDesc=c.fileDesc),c.fileExt&&(e.fileExt=c.fileExt),c.multi&&(e.multi=!0),c.auto&&(e.auto=!0),c.sizeLimit&&(e.sizeLimit=c.sizeLimit),c.checkScript&&(e.checkScript=c.checkScript),c.fileDataName&&(e.fileDataName=c.fileDataName),c.queueID&&(e.queueID=c.queueID),c.onInit()!==!1&&(a(this).css("display","none"),a(this).after('<div id="'+a(this).attr("id")+'Uploader"></div>'),swfobject.embedSWF(c.uploader,c.id+"Uploader",c.width,c.height,"9.0.24",c.expressInstall,e,{quality:"high",wmode:c.wmode,allowScriptAccess:c.scriptAccess},{},function(a){typeof c.onSWFReady=="function"&&a.success&&c.onSWFReady()}),c.queueID==!1?a("#"+a(this).attr("id")+"Uploader").after('<div id="'+a(this).attr("id")+'Queue" class="uploadifyQueue"></div>'):a("#"+c.queueID).addClass("uploadifyQueue")),typeof c.onOpen=="function"&&a(this).bind("uploadifyOpen",c.onOpen),a(this).bind("uploadifySelect",{action:c.onSelect,queueID:c.queueID},function(b,d,e){if(b.data.action(b,d,e)!==!1){var f=Math.round(e.size/1024*100)*.01,g="KB";f>1e3&&(f=Math.round(f*.001*100)*.01,g="MB");var h=f.toString().split(".");h.length>1?f=h[0]+"."+h[1].substr(0,2):f=h[0],e.name.length>20?fileName=e.name.substr(0,20)+"...":fileName=e.name,queue="#"+a(this).attr("id")+"Queue",b.data.queueID&&(queue="#"+b.data.queueID),a(queue).append('<div id="'+a(this).attr("id")+d+'" class="uploadifyQueueItem">\n\t\t\t\t\t\t\t\t<div class="cancel">\n\t\t\t\t\t\t\t\t\t<a href="javascript:jQuery(\'#'+a(this).attr("id")+"').uploadifyCancel('"+d+'\')"><img src="'+c.cancelImg+'" border="0" /></a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<span class="fileName">'+fileName+" ("+f+g+')</span><span class="percentage"></span>\n\t\t\t\t\t\t\t\t<div class="uploadifyProgress">\n\t\t\t\t\t\t\t\t\t<div id="'+a(this).attr("id")+d+'ProgressBar" class="uploadifyProgressBar"><!--Progress Bar--></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>')}}),a(this).bind("uploadifySelectOnce",{action:c.onSelectOnce},function(b,d){b.data.action(b,d),c.auto&&(c.checkScript?a(this).uploadifyUpload(null,!1):a(this).uploadifyUpload(null,!0))}),a(this).bind("uploadifyQueueFull",{action:c.onQueueFull},function(a,b){a.data.action(a,b)!==!1&&alert("The queue is full. The max size is "+b+".")}),a(this).bind("uploadifyCheckExist",{action:c.onCheck},function(b,c,e,f,g){var h=new Object;h=e,h.folder=f.substr(0,1)=="/"?f:d+f;if(g)for(var i in e)var j=i;a.post(c,h,function(c){for(var d in c)if(b.data.action(b,c,d)!==!1){var e=confirm("Do you want to replace the file "+c[d]+"?");e||document.getElementById(a(b.target).attr("id")+"Uploader").cancelFileUpload(d,!0,!0)}g?document.getElementById(a(b.target).attr("id")+"Uploader").startFileUpload(j,!0):document.getElementById(a(b.target).attr("id")+"Uploader").startFileUpload(null,!0)},"json")}),a(this).bind("uploadifyCancel",{action:c.onCancel},function(b,c,d,e,f,g){if(b.data.action(b,c,d,e,g)!==!1&&f){var h=g==!0?0:250;a("#"+a(this).attr("id")+c).fadeOut(h,function(){a(this).remove()})}}),a(this).bind("uploadifyClearQueue",{action:c.onClearQueue},function(b,d){var e=c.queueID?c.queueID:a(this).attr("id")+"Queue";d&&a("#"+e).find(".uploadifyQueueItem").remove(),b.data.action(b,d)!==!1&&a("#"+e).find(".uploadifyQueueItem").each(function(){var b=a(".uploadifyQueueItem").index(this);a(this).delay(b*100).fadeOut(250,function(){a(this).remove()})})});var h=[];a(this).bind("uploadifyError",{action:c.onError},function(b,c,d,e){if(b.data.action(b,c,d,e)!==!1){var f=[c,d,e];h.push(f),a("#"+a(this).attr("id")+c).find(".percentage").text(" - "+e.type+" Error"),a("#"+a(this).attr("id")+c).find(".uploadifyProgress").hide(),a("#"+a(this).attr("id")+c).addClass("uploadifyError")}}),typeof c.onUpload=="function"&&a(this).bind("uploadifyUpload",c.onUpload),a(this).bind("uploadifyProgress",{action:c.onProgress,toDisplay:c.displayData},function(b,c,d,e){b.data.action(b,c,d,e)!==!1&&(a("#"+a(this).attr("id")+c+"ProgressBar").animate({width:e.percentage+"%"},250,function(){e.percentage==100&&a(this).closest(".uploadifyProgress").fadeOut(250,function(){a(this).remove()})}),b.data.toDisplay=="percentage"&&(displayData=" - "+e.percentage+"%"),b.data.toDisplay=="speed"&&(displayData=" - "+e.speed+"KB/s"),b.data.toDisplay==null&&(displayData=" "),a("#"+a(this).attr("id")+c).find(".percentage").text(displayData))}),a(this).bind("uploadifyComplete",{action:c.onComplete},function(b,d,e,f,g){b.data.action(b,d,e,unescape(f),g)!==!1&&(a("#"+a(this).attr("id")+d).find(".percentage").text(" - Completed"),c.removeCompleted&&a("#"+a(b.target).attr("id")+d).fadeOut(250,function(){a(this).remove()}),a("#"+a(b.target).attr("id")+d).addClass("completed"))}),typeof c.onAllComplete=="function"&&a(this).bind("uploadifyAllComplete",{action:c.onAllComplete},function(a,b){a.data.action(a,b)!==!1&&(h=[])})})},uploadifySettings:function(b,c,d){var e=!1;a(this).each(function(){if(b=="scriptData"&&c!=null){if(d)var f=c;else var f=a.extend(a(this).data("settings").scriptData,c);var g="";for(var h in f)g+="&"+h+"="+f[h];c=escape(g.substr(1))}e=document.getElementById(a(this).attr("id")+"Uploader").updateSettings(b,c)});if(c==null&&b=="scriptData"){var f=unescape(e).split("&"),g=new Object;for(var h=0;h<f.length;h++){var i=f[h].split("=");g[i[0]]=i[1]}e=g}return e},uploadifyUpload:function(b,c){a(this).each(function(){c||(c=!1),document.getElementById(a(this).attr("id")+"Uploader").startFileUpload(b,c)})},uploadifyCancel:function(b){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").cancelFileUpload(b,!0,!0,!1)})},uploadifyClearQueue:function(){a(this).each(function(){document.getElementById(a(this).attr("id")+"Uploader").clearFileUploadQueue(!1)})},uploadifyImportCheckboxToggle:function(b){a('input[name="ImportFiles[]"]').each(function(c){b=="toggle"?a(this).attr("checked",!a(this).attr("checked")):a(this).attr("checked",b)})}})}(jQuery)
|