View file upload/js/xenforo/file_uploader.js

File size: 2.93Kb
/*
 * XenForo file_uploader.min.js
 * Copyright 2010-2019 XenForo Ltd.
 * Released under the XenForo License Agreement: http://xenforo.com/license-agreement
 */
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,c,e){a instanceof String&&(a=String(a));for(var d=a.length,b=0;b<d;b++){var m=a[b];if(c.call(e,m,b,a))return{i:b,v:m}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,e){a!=Array.prototype&&a!=Object.prototype&&(a[c]=e.value)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,c,e,d){if(c){e=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var b=a[d];b in e||(e[b]={});e=e[b]}a=a[a.length-1];d=e[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(e,a,{configurable:!0,writable:!0,value:c})}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,e){return $jscomp.findInternal(this,a,e).v}},"es6","es3");
!function(a,c,e,d){XenForo.FileUploader=function(b){var e=XenForo.AttachmentUploader(b),c=a(b.data("result")),d=c.find(".Progress"),n=d.find(".Meter"),h=c.find(".Filename"),f=c.find(".Delete"),k=0,l=function(){b.css({overflow:"",height:"",width:"",position:""})},p=function(){b.css({overflow:"hidden",height:"1px",width:"1px",position:"relative"})},q=function(g){setTimeout(function(){if(!h.is(":visible")){var b="";g.ajaxData&&a.each(g.ajaxData.error,function(a,g){b+=g+"\n"});var d=g.file,f=d.uniqueIdentifier||
d.id;e.swfAlert(d,g.errorCode,b);a("#"+f).xfRemove();c.hide();l()}},1E3);"AttachmentUploadError"==g.type&&k--};b.bind({AttachmentQueueValidation:function(a){1<=k&&a.preventDefault()},AttachmentQueued:function(a){k++;console.log("Queued: %s (%d bytes)",a.file.name,a.file.size);p();h.hide();n.css("width",0);d.show();c.fadeIn(XenForo.speed.fast);f.data("attach-queue-event",a)},AttachmentUploadProgress:function(a){console.log("Uploaded %d/%d bytes.",a.bytes,a.file.size);n.css("width",Math.min(100,Math.ceil(100*
a.bytes/a.file.size))+"%")},AttachmentQueueError:q,AttachmentUploadError:q,AttachmentUploaded:function(a){var b=a.ajaxData.filename||a.file.name;console.info("Upload of %s completed!",b);p();c.show();d.hide();h.text(b);h.show();f.data("href",a.ajaxData.deleteUrl);a.file&&k--;f.removeData("attach-queue-event")}});f.bind("click",function(a){a.preventDefault();f.data("href")?XenForo.ajax(f.data("href"),{},function(a,b){f.removeData("href");c.fadeOut(XenForo.speed.fast,function(){l()})}):((a=f.data("attach-queue-event"))&&
(a.swfUpload?a.swfUpload.cancelUpload(a.file.id):a.file.flowObj&&a.file.cancel()),c.fadeOut(XenForo.speed.fast,function(){l()}))})};"function"==typeof XenForo.AttachmentUploader&&XenForo.register(".FileUploader","XenForo.FileUploader")}(jQuery,this,document);