/
home
/
assocoweys
/
comgk
/
wp-content
/
plugins
/
comcharitable
/
assets
/
js
/
Upload File
HOME
/*! 1.6.13 2019-02-06 21:05 */ CHARITABLE=window.CHARITABLE||{},function(t,e){var a=function(e){var o=this,a=e.data("params"),i=new plupload.Uploader(a);this.$dragdrop=e,this.$dropzone=t(i.settings.drop_element),this.$images=t("#"+e.data("images")),this.$loader=this.$dragdrop.find(".charitable-drag-drop-image-loader").first(),this.max_file_uploads=a.multipart_params.max_uploads,this.max_file_size=parseInt(this.$dragdrop.data("max-size"),10),this.uploaded=this.$images.children().length,this.max_uploads_alert_shown=!1,this.max_upload_size_alert_shown=!1,i.init(),i.bind("Init",function(e){o.Init(e)}),i.bind("PostInit",function(e){e.refresh()}),i.bind("FileFiltered",function(e,a){o.FileFiltered(e,a)}),i.bind("FilesAdded",function(e,a){o.FilesAdded(e,a)}),i.bind("Error",function(e,a){console.log(a)}),i.bind("FileUploaded",function(e,a,i){o.FileUploaded(e,a,i)})};a.prototype.Init=function(a){var i=this;this.$dropzone&&(a.features.dragdrop&&!this.$dragdrop.parent().hasClass("mobile")&&(this.$dragdrop.parent().addClass("supports-drag-drop"),this.$dropzone.bind("dragover",function(){i.$dropzone.addClass("drag-over")}),this.$dropzone.bind("dragleave",function(){i.$dropzone.removeClass("drag-over")})),this.$dragdrop.on("click",".remove-image",function(e){return e.preventDefault(),i.remove_image(t(this),a)}))},a.prototype.FileFiltered=function(e,a){return this.max_file_uploads&&this.uploaded>=this.max_file_uploads?(this.max_uploads_alert_shown||alert(this.get_max_uploads_message()),this.max_uploads_alert_shown=!0,e.removeFile(a)):a.size>=this.max_file_size?(this.max_upload_size_alert_shown||alert(a,CHARITABLE_UPLOAD_VARS.max_file_size.replace("%1$s",a.name).replace("%2$s",this.bytes_to_mb(this.max_file_size))),this.max_upload_size_alert_shown=!0,e.removeFile(a)):(this.uploaded+=1,this.uploaded===this.max_file_uploads&&this.hide_dropzone(),void this.add_image_loader(a))},a.prototype.FilesAdded=function(e,a){this.$dropzone.removeClass("drag-over"),this.max_uploads_alert_shown=!1,this.max_upload_size_alert_shown=!1,e.refresh(),e.start()},a.prototype.FileUploaded=function(e,a,i){(i=t.parseJSON(i.response)).success?(this.hide_image_loader(a),this.$images.append(i.data)):this.add_image_error(a,CHARITABLE_UPLOAD_VARS.upload_problem.replace("%s",a.name))},a.prototype.get_max_uploads_message=function(){return(1<this.max_file_uploads?CHARITABLE_UPLOAD_VARS.max_file_uploads_plural:CHARITABLE_UPLOAD_VARS.max_file_uploads_single).replace("%d",this.max_file_uploads)},a.prototype.add_image_loader=function(e){this.$loader.fadeIn(300),this.$loader.children(".images").append('<li data-file-id="'+e.id+'" class="">'+e.name+"</li>")},a.prototype.hide_image_loader=function(e){this.$loader.find("[data-file-id="+e.id+"]").remove(),this.$loader.find(".images li").length||this.$loader.hide()},a.prototype.remove_image=function(e,a){return e.parent().fadeOut(300,function(){this.remove()}),this.$dropzone.fadeIn(300),this.uploaded-=1,a.refresh(),!1},a.prototype.hide_dropzone=function(){this.$dropzone.removeClass("drag-over"),this.$dropzone.hide()},a.prototype.bytes_to_mb=function(e){var a=Math.floor(Math.log(e)/Math.log(1024));return 1*(e/Math.pow(1024,a)).toFixed(2)+" "+["B","kB","MB","GB","TB"][a]},a.prototype.add_image_error=function(e,a){var i=this;i.$dropzone.fadeIn(300),i.$loader.find("[data-file-id="+e.id+"]").addClass("error").text(a).delay(5e3).fadeOut(300,function(){i.hide_image_loader(e)})},e.Uploader=a,t(document).ready(function(){t(".charitable-drag-drop").each(function(){new a(t(this))})})}(jQuery,CHARITABLE);