/** * Simple Ajax Uploader * Version 2.6.2 * https://github.com/LPology/Simple-Ajax-Uploader * * Copyright 2012-2017 LPology, LLC * Released under the MIT license */ ;(function( global, factory ) { /*globals define, module */ if ( typeof define === 'function' && define.amd ) { define( function() { return factory( global ); }); } else if ( typeof module === 'object' && module.exports ) { module.exports = factory( global ); } else { global.ss = factory( global ); } }( typeof window !== 'undefined' ? window : this, function( window ) { var ss = window.ss || {}, // ss.trim() rLWhitespace = /^\s+/, rTWhitespace = /\s+$/, // ss.getUID uidReplace = /[xy]/g, // ss.getFilename() rPath = /.*(\/|\\)/, // ss.getExt() rExt = /.*[.]/, // ss.hasClass() rHasClass = /[\t\r\n]/g, // Check for Safari -- it doesn't like multi file uploading. At all. // http://stackoverflow.com/a/9851769/1091949 isSafari = Object.prototype.toString.call( window.HTMLElement ).indexOf( 'Constructor' ) > 0, // Detect IE7-9 isIE7to9 = ( navigator.userAgent.indexOf('MSIE') !== -1 && navigator.userAgent.indexOf('MSIE 1') === -1 ), isIE7 = ( navigator.userAgent.indexOf('MSIE 7') !== -1 ), // Check whether XHR uploads are supported input = document.createElement( 'input' ), XhrOk; input.type = 'file'; XhrOk = ( 'multiple' in input && typeof File !== 'undefined' && typeof ( new XMLHttpRequest() ).upload !== 'undefined' ); /** * Converts object to query string */ ss.obj2string = function( obj, prefix ) { "use strict"; var str = []; for ( var prop in obj ) { if ( obj.hasOwnProperty( prop ) ) { var k = prefix ? prefix + '[' + prop + ']' : prop, v = obj[prop]; str.push( typeof v === 'object' ? ss.obj2string( v, k ) : encodeURIComponent( k ) + '=' + encodeURIComponent( v ) ); } } return str.join( '&' ); }; /** * Copies all missing properties from second object to first object */ ss.extendObj = function( first, second ) { "use strict"; for ( var prop in second ) { if ( second.hasOwnProperty( prop ) ) { first[prop] = second[prop]; } } }; ss.addEvent = function( elem, type, fn ) { "use strict"; if ( elem.addEventListener ) { elem.addEventListener( type, fn, false ); } else { elem.attachEvent( 'on' + type, fn ); } return function() { ss.removeEvent( elem, type, fn ); }; }; ss.removeEvent = document.removeEventListener ? function( elem, type, fn ) { if ( elem.removeEventListener ) { elem.removeEventListener( type, fn, false ); } } : function( elem, type, fn ) { var name = 'on' + type; if ( typeof elem[ name ] === 'undefined' ) { elem[ name ] = null; } elem.detachEvent( name, fn ); }; ss.newXHR = function() { "use strict"; if ( typeof XMLHttpRequest !== 'undefined' ) { return new window.XMLHttpRequest(); } else if ( window.ActiveXObject ) { try { return new window.ActiveXObject( 'Microsoft.XMLHTTP' ); } catch ( err ) { return false; } } }; ss.encodeUTF8 = function( str ) { "use strict"; /*jshint nonstandard:true*/ return unescape( encodeURIComponent( str ) ); }; ss.getIFrame = function() { "use strict"; var id = ss.getUID(), iframe; // IE7 can only create an iframe this way, all others are the other way if ( isIE7 ) { iframe = document.createElement('