tupali/upload/Simple-Ajax-Uploader-master/SimpleAjaxUploader.min.js

3 lines
25 KiB
JavaScript
Raw Normal View History

/** Simple Ajax Uploader v2.6.2 Copyright 2012-2017 LPology, LLC MIT license https://github.com/LPology/Simple-Ajax-Uploader */
!function(e,t){"function"==typeof define&&define.amd?define(function(){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(e):e.ss=t(e)}("undefined"!=typeof window?window:this,function(e){var t,s=e.ss||{},n=/^\s+/,i=/\s+$/,o=/[xy]/g,r=/.*(\/|\\)/,a=/.*[.]/,u=/[\t\r\n]/g,l=Object.prototype.toString.call(e.HTMLElement).indexOf("Constructor")>0,d=-1!==navigator.userAgent.indexOf("MSIE")&&-1===navigator.userAgent.indexOf("MSIE 1"),c=-1!==navigator.userAgent.indexOf("MSIE 7"),p=document.createElement("input");p.type="file",t="multiple"in p&&"undefined"!=typeof File&&"undefined"!=typeof(new XMLHttpRequest).upload,s.obj2string=function(e,t){"use strict";var n=[];for(var i in e)if(e.hasOwnProperty(i)){var o=t?t+"["+i+"]":i,r=e[i];n.push("object"==typeof r?s.obj2string(r,o):encodeURIComponent(o)+"="+encodeURIComponent(r))}return n.join("&")},s.extendObj=function(e,t){"use strict";for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])},s.addEvent=function(e,t,n){"use strict";return e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n),function(){s.removeEvent(e,t,n)}},s.removeEvent=document.removeEventListener?function(e,t,s){e.removeEventListener&&e.removeEventListener(t,s,!1)}:function(e,t,s){var n="on"+t;"undefined"==typeof e[n]&&(e[n]=null),e.detachEvent(n,s)},s.newXHR=function(){"use strict";if("undefined"!=typeof XMLHttpRequest)return new e.XMLHttpRequest;if(e.ActiveXObject)try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){return!1}},s.encodeUTF8=function(e){"use strict";return unescape(encodeURIComponent(e))},s.getIFrame=function(){"use strict";var e,t=s.getUID();return c?e=document.createElement('<iframe src="javascript:false;" name="'+t+'">'):(e=document.createElement("iframe"),e.src="javascript:false;",e.name=t),e.style.display="none",e.id=t,e},s.getForm=function(e){"use strict";var t=document.createElement("form");t.encoding="multipart/form-data",t.enctype="multipart/form-data",t.style.display="none";for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t},s.getHidden=function(e,t){"use strict";var s=document.createElement("input");return s.type="hidden",s.name=e,s.value=t,s},s.parseJSON=function(t){"use strict";if(!t)return!1;if(t=s.trim(t+""),e.JSON&&e.JSON.parse)try{return e.JSON.parse(t+"")}catch(n){return!1}var i,o=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g,r=null;return t&&!s.trim(t.replace(o,function(e,t,s,n){return i&&t&&(r=0),0===r?e:(i=s||t,r+=!n-!s,"")}))?Function("return "+t)():!1},s.getBox=function(t){"use strict";var s,n,i=0,o=0;if(t.getBoundingClientRect)s=t.getBoundingClientRect(),n=document.documentElement,i=s.top+(e.pageYOffset||n.scrollTop)-(n.clientTop||0),o=s.left+(e.pageXOffset||n.scrollLeft)-(n.clientLeft||0);else do o+=t.offsetLeft,i+=t.offsetTop;while(t=t.offsetParent);return{top:Math.round(i),left:Math.round(o)}},s.addStyles=function(e,t){"use strict";for(var s in t)t.hasOwnProperty(s)&&(e.style[s]=t[s])},s.copyLayout=function(e,t){"use strict";var n=s.getBox(e);s.addStyles(t,{position:"absolute",left:n.left+"px",top:n.top+"px",width:e.offsetWidth+"px",height:e.offsetHeight+"px"})},s.getUID=function(){"use strict";return"axxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(o,function(e){var t=16*Math.random()|0,s="x"==e?t:3&t|8;return s.toString(16)})};var h="".trim;s.trim=h&&!h.call("\ufeff ")?function(e){return null===e?"":h.call(e)}:function(e){return null===e?"":e.toString().replace(n,"").replace(i,"")};var f=[];return s.indexOf=f.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){for(var s=0,n=e.length;n>s;s++)if(e[s]===t)return s;return-1},s.arrayDelete=function(e,t){var n=s.indexOf(e,t);n>-1&&e.splice(n,1)},s.getFilename=function(e){"use strict";return e.replace(r,"")},s.getExt=function(e){"use strict";return-1!==e.indexOf(".")?e.replace(a,""):""},s.isVisible=function(e){"use strict";return e?1!==e.nodeType||e==document.body?(e=null,!0):e.parentNode&&(e.offsetWidth>0||e.offsetHeight>0||"none"!=s.getStyle(e,"display").toLowerCase())?s.isVisible(e.parentNode):(e