mirror of https://github.com/Sonarr/Sonarr
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
|
(function(n){var s,r=n.telerik,k=/\.([^\.]+)$/;r.upload=function(v,w){n.extend(this,w);this.element=v;this.name=v.name;var u=n(v);this.wrapper=u.closest(".t-upload");if(this.wrapper.length==0){this.wrapper=this._wrapInput(u)}this._setActiveInput(u);this.toggle(this.enabled);u.closest("form").bind({submit:n.proxy(this._onParentFormSubmit,this),reset:n.proxy(this._onParentFormReset,this)});if(this.async.saveUrl!=s){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));r.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});r.trigger(this.wrapper,"load")};r.upload.prototype={enable:function(){this.toggle(true)},disable:function(){this.toggle(false)},toggle:function(u){this.wrapper.toggleClass("t-state-disabled",!u)},_addInput:function(u){u.insertAfter(this.element).data("tUpload",this);n(this.element).hide().removeAttr("id");this._setActiveInput(u)},_setActiveInput:function(u){var v=this.wrapper;this.element=u;u.attr("multiple",this._getSupportsMultiple()?this.multiple:false).attr("autocomplete","off").click(function(w){if(v.hasClass("t-state-disabled")){w.preventDefault()}}).change(n.proxy(this._onInputChange,this))},_onInputChange:function(w){var u=n(w.target),v=r.trigger(this.wrapper,"select",{files:j(u)});if(!v){u.trigger("t:select")}},_enqueueFile:function(y,v){var w=n(".t-upload-files",this.wrapper);if(w.length==0){w=n("<ul class='t-upload-files t-reset'></ul>").appendTo(this.wrapper);if(!this.showFileList){w.hide()}}var u=n(".t-file",w);var x=n("<li class='t-file'><span class='t-icon'></span><span class='t-filename'>"+y+"</span></li>").appendTo(w).data(v);if(!this.multiple){u.trigger("t:remove")}return x},_removeFileEntry:function(v){var u=v.closest(".t-upload-files");if(n(".t-file",u).length==1){u.remove();this._hideUploadButton()}else{v.remove()}},_setFileAction:function(w,u){var v={remove:"t-delete",cancel:"t-cancel",retry:"t-retry"};if(!v.hasOwnProperty(u)){return}this._clearFileAction(w);w.append(this._renderAction(v[u],this.localization[u]).addClass("t-upload-action"))},_setFileState:function(u,w){var x={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=x[w];if(v){var y=u.children(".t-icon").text(v.text);y[0].className="t-icon "+v.cssClass}},_renderAction:function(v,u){if(v!=""){return n("<button type='button' class='t-button t-button-icontext'><span class='t-icon "+v+"'></span>"+u+"</button>")}else{return n("<button type='button' class='t-button'>"+u+"</button>")}},_clearFileAction:function(u){u.find(".t-upload-action").remove()},_onFileAction:function(y){if(!this.wrapper.hasClass("t-state-disabled")){var u=n(y.target).closest(".t-upload-action"),x=u.find(".t-icon"),w=u.closest(".t-file"),v={files:w.data("fileNames")};if(x.hasClass("t-delete")){if(!r.trigger(this.wrapper,"remove",v)){w.trigger("t:remove")}}else{if(x.hasClass("t-cancel")){r.trigger(this.wrapper,"cancel",v);w.trigger("t:cancel")}else{if(x.hasClass("t-retry")){w.trigger("t:retry")}}}}return false},_onUploadSelected:function(){this.wrapper.trigger("t:saveSelected");return false},_onFileProgress:function(w,v){var u=n(".t-progress-status",w.target);if(u.length==0){u=n("<span class='t-progress'><span class='t-progress-status' style='width: 0;'></span></span>").appendTo(n(".t-filename",w.target)).find(".t-progress-status")}u.width(v+"%")},_onUploadSuccess:function(x,w,u){var v=q(x);this._setFileState(v,"
|