mirror of
https://github.com/Radarr/Radarr
synced 2024-12-27 10:19:41 +00:00
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
|
(function(n){var t,s=n.telerik,k=/\.([^\.]+)$/;s.scripts.push("telerik.upload.js");s.upload=function(w,x){n.extend(this,x);this.element=w;this.name=w.name;var v=n(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:n.proxy(this._onParentFormSubmit,this),reset:n.proxy(this._onParentFormReset,this)});if(this.async.saveUrl!=t){this._module=this._getSupportsFormData()?new o(this):new f(this)}else{this._module=new g(this)}if(this._getSupportsDrop()){this._setupDropZone()}this.wrapper.delegate(".t-upload-action","click",n.proxy(this._onFileAction,this)).delegate(".t-upload-selected","click",n.proxy(this._onUploadSelected,this)).delegate(".t-file","t:progress",n.proxy(this._onFileProgress,this)).delegate(".t-file","t:upload-success",n.proxy(this._onUploadSuccess,this)).delegate(".t-file","t:upload-error",n.proxy(this._onUploadError,this));s.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});s.trigger(this.wrapper,"load")};s.upload.prototype={enable:function(){this.toggle(true)},disable:function(){this.toggle(false)},toggle:function(v){this.wrapper.toggleClass("t-state-disabled",!v)},_addInput:function(v){v.insertAfter(this.element).data("tUpload",this);n(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(n.proxy(this._onInputChange,this))},_onInputChange:function(x){var v=n(x.target),w=s.trigger(this.wrapper,"select",{files:j(v)});if(!w){v.trigger("t:select")}},_onDrop:function(y){var v=y.originalEvent.dataTransfer,x=v.files;d(y);if(x.length>0){var w=s.trigger(this.wrapper,"select",{files:c(x)});if(!w){n(".t-dropzone",this.wrapper).trigger("t:select",[x])}}},_enqueueFile:function(z,w){var x=n(".t-upload-files",this.wrapper);if(x.length==0){x=n("<ul class='t-upload-files t-reset'></ul>").appendTo(this.wrapper);if(!this.showFileList){x.hide()}}var v=n(".t-file",x);var y=n("<li class='t-file'><span class='t-icon'></span><span class='t-filename'>"+z+"</span></li>").appendTo(x).data(w);if(!this.multiple){v.trigger("t:remove")}return y},_removeFileEntry:function(w){var v=w.closest(".t-upload-files");if(n(".t-file",v).length==1){v.remove();this._hideUploadButton()}else{w.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(v,x){var y={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 w=y[x];if(w){var z=v.children(".t-icon").text(w.text);z[0].className="t-icon "+w.cssClass}},_renderAction:function(w,v){if(w!=""){return n("<button type='button' class='t-button t-button-icontext'><span class='t-icon "+w+"'></span>"+v+"</button>")}else{return n("<button type='button' class='t-button'>"+v+"</button>")}},_clearFileAction:function(v){v.find(".t-upload-action").remove()},_onFileAction:function(z){if(!this.wrapper.hasClass("t-state-disabled")){var v=n(z.target).closest(".t-upload-action"),y=v.find(".t-icon"),x=v.closest(".t-file"),w={files:x.data("fileNames")};if(y.hasClass("t-delete")){if(!s.trigger(this.wrapper,"remove",w)){x.trigger("t:remove")}}else{if(y.hasClass("t-cancel")){s.trigger(this.wrapper,"cancel",w);x.trigger("t:cancel")}else{if(y.hasClass("t-retry")){x.trigger("t:retry")}}}}return false},_onUploadSelected:function(){this.wrapper.trigger("t:saveSelected");return false},_onFileProgress:function(x,w){var v=n(".t-progress-status",x.target);if(v.length==0){v=n("
|