sonarr-repo-only/NzbDrone.Web/Scripts/2011.3.1115/telerik.upload.min.js

1 line
16 KiB
JavaScript
Raw Normal View History

2011-11-23 01:51:44 +00:00
(function(a){var u,b=a.telerik,p=/\.([^\.]+)$/;b.scripts.push("telerik.upload.js");b.upload=function(w,x){a.extend(this,x);this.element=w;this.name=w.name;var v=a(w);this.wrapper=v.closest(".t-upload");if(this.wrapper.length==0){this.wrapper=this._wrapInput(v)}this._setActiveInput(v);this.toggle(this.enabled);v.closest("form").bind({submit:a.proxy(this._onParentFormSubmit,this),reset:a.proxy(this._onParentFormReset,this)});if(this.async.saveUrl!=u){this._module=this._getSupportsFormData()?new d(this):new l(this)}else{this._module=new s(this)}if(this._getSupportsDrop()){this._setupDropZone()}this.wrapper.delegate(".t-upload-action","click",a.proxy(this._onFileAction,this)).delegate(".t-upload-selected","click",a.proxy(this._onUploadSelected,this)).delegate(".t-file","t:progress",a.proxy(this._onFileProgress,this)).delegate(".t-file","t:upload-success",a.proxy(this._onUploadSuccess,this)).delegate(".t-file","t:upload-error",a.proxy(this._onUploadError,this));b.bind(this.wrapper,{load:this.onLoad,select:this.onSelect,upload:this.onUpload,success:this.onSuccess,error:this.onError,complete:this.onComplete,cancel:this.onCancel,remove:this.onRemove});var y=a(this.wrapper).data("tUpload",this);a(w).bind("load",function(){b.trigger(y,"load")})};b.upload.prototype={enable:function(){this.toggle(true)},disable:function(){this.toggle(false)},toggle:function(v){v=typeof v==="undefined"?v:!v;this.wrapper.toggleClass("t-state-disabled",v)},_addInput:function(v){v.insertAfter(this.element).data("tUpload",this);a(this.element).hide().removeAttr("id");this._setActiveInput(v)},_setActiveInput:function(v){var w=this.wrapper;this.element=v;v.attr("multiple",this._getSupportsMultiple()?this.multiple:false).attr("autocomplete","off").click(function(x){if(w.hasClass("t-state-disabled")){x.preventDefault()}}).change(a.proxy(this._onInputChange,this))},_onInputChange:function(v){var w=a(v.target),x=b.trigger(this.wrapper,"select",{files:k(w)});if(!x){w.trigger("t:select")}},_onDrop:function(x){var w=x.originalEvent.dataTransfer,v=w.files;q(x);if(v.length>0){var y=b.trigger(this.wrapper,"select",{files:e(v)});if(!y){a(".t-dropzone",this.wrapper).trigger("t:select",[v])}}},_enqueueFile:function(z,v){var y=a(".t-upload-files",this.wrapper);if(y.length==0){y=a("<ul class='t-upload-files t-reset'></ul>").appendTo(this.wrapper);if(!this.showFileList){y.hide()}}var w=a(".t-file",y);var x=a("<li class='t-file'><span class='t-icon'></span><span class='t-filename' title='"+z+"'>"+z+"</span></li>").appendTo(y).data(v);if(!this.multiple){w.trigger("t:remove")}return x},_removeFileEntry:function(v){var w=v.closest(".t-upload-files");if(a(".t-file",w).length==1){w.remove();this._hideUploadButton()}else{v.remove()}},_setFileAction:function(x,v){var w={remove:"t-delete",cancel:"t-cancel",retry:"t-retry"};if(!w.hasOwnProperty(v)){return}this._clearFileAction(x);x.append(this._renderAction(w[v],this.localization[v]).addClass("t-upload-action"))},_setFileState:function(w,y){var z={uploading:{cssClass:"t-loading",text:this.localization.statusUploading},uploaded:{cssClass:"t-success",text:this.localization.statusUploaded},failed:{cssClass:"t-fail",text:this.localization.statusFailed}};var v=z[y];if(v){var x=w.children(".t-icon").text(v.text);x[0].className="t-icon "+v.cssClass}},_renderAction:function(v,w){if(v!=""){return a("<button type='button' class='t-button t-button-icontext'><span class='t-icon "+v+"'></span>"+w+"</button>")}else{return a("<button type='button' class='t-button'>"+w+"</button>")}},_clearFileAction:function(v){v.find(".t-upload-action").remove()},_onFileAction:function(w){if(!this.wrapper.hasClass("t-state-disabled")){var v=a(w.target).closest(".t-upload-action"),z=v.find(".t-icon"),y=v.closest(".t-file"),x={files:y.data("fileNames")};if(z.hasClass("t-delete")){if(!b.trigger(this.wrapper,"remove",x)){y.trigger("t:remove",x.data)}}else{if(z.hasClass("t-cancel")){b.trigger(this.wrapper,"cancel",x);y.trigger("t:cancel")}else{if(z.hasClass("t-retry")){y.trigger("t:retry")}}}}return false},_onUploadSelected:function(){this.wrapper.trigger("t:saveSel