2014-08-26 03:36:43 +00:00
// tmpl.min.js
( function ( a ) { "use strict" ; var b = function ( a , c ) { var d = /[^\w\-\.:]/ . test ( a ) ? new Function ( b . arg + ",tmpl" , "var _e=tmpl.encode" + b . helper + ",_s='" + a . replace ( b . regexp , b . func ) + "';return _s;" ) : b . cache [ a ] = b . cache [ a ] || b ( b . load ( a ) ) ; return c ? d ( c , b ) : function ( a ) { return d ( a , b ) } } ; b . cache = { } , b . load = function ( a ) { return document . getElementById ( a ) . innerHTML } , b . regexp = /([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g , b . func = function ( a , b , c , d , e , f ) { if ( b ) return { "\n" : "\\n" , "\r" : "\\r" , "\t" : "\\t" , " " : " " } [ a ] || "\\" + a ; if ( c ) return c === "=" ? "'+_e(" + d + ")+'" : "'+(" + d + "||'')+'" ; if ( e ) return "';" ; if ( f ) return "_s+='" } , b . encReg = /[<>&"'\x00]/g , b . encMap = { "<" : "<" , ">" : ">" , "&" : "&" , '"' : """ , "'" : "'" } , b . encode = function ( a ) { return String ( a || "" ) . replace ( b . encReg , function ( a ) { return b . encMap [ a ] || "" } ) } , b . arg = "o" , b . helper = ",print=function(s,e){_s+=e&&(s||'')||_e(s);},include=function(s,d){_s+=tmpl(s,d);}" , typeof define == "function" && define . amd ? define ( function ( ) { return b } ) : a . tmpl = b } ) ( this ) ;
/ *
* jQuery Iframe Transport Plugin 1.4
* https : //github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
( function ( factory ) { if ( typeof define === "function" && define . amd ) { define ( [ "jquery" ] , factory ) ; } else { factory ( window . jQuery ) ; } } ( function ( $ ) { var counter = 0 ; $ . ajaxTransport ( "iframe" , function ( options ) { if ( options . async && ( options . type === "POST" || options . type === "GET" ) ) { var form , iframe ; return { send : function ( _ , completeCallback ) { form = $ ( '<form style="display:none;"></form>' ) ; iframe = $ ( '<iframe src="javascript:false;" name="iframe-transport-' + ( counter += 1 ) + '"></iframe>' ) . bind ( "load" , function ( ) { var fileInputClones , paramNames = $ . isArray ( options . paramName ) ? options . paramName : [ options . paramName ] ; iframe . unbind ( "load" ) . bind ( "load" , function ( ) { var response ; try { response = iframe . contents ( ) ; if ( ! response . length || ! response [ 0 ] . firstChild ) { throw new Error ( ) ; } } catch ( e ) { response = undefined ; } completeCallback ( 200 , "success" , { "iframe" : response } ) ; $ ( '<iframe src="javascript:false;"></iframe>' ) . appendTo ( form ) ; form . remove ( ) ; } ) ; form . prop ( "target" , iframe . prop ( "name" ) ) . prop ( "action" , options . url ) . prop ( "method" , options . type ) ; if ( options . formData ) { $ . each ( options . formData , function ( index , field ) { $ ( '<input type="hidden"/>' ) . prop ( "name" , field . name ) . val ( field . value ) . appendTo ( form ) ; } ) ; } if ( options . fileInput && options . fileInput . length && options . type === "POST" ) { fileInputClones = options . fileInput . clone ( ) ; options . fileInput . after ( function ( index ) { return fileInputClones [ index ] ; } ) ; if ( options . paramName ) { options . fileInput . each ( function ( index ) { $ ( this ) . prop ( "name" , paramNames [ index ] || options . paramName ) ; } ) ; } form . append ( options . fileInput ) . prop ( "enctype" , "multipart/form-data" ) . prop ( "encoding" , "multipart/form-data" ) ; } form . submit ( ) ; if ( fileInputClones && fileInputClones . length ) { options . fileInput . each ( function ( index , input ) { var clone = $ ( fileInputClones [ index ] ) ; $ ( input ) . prop ( "name" , clone . prop ( "name" ) ) ; clone . replaceWith ( input ) ; } ) ; } } ) ; form . append ( iframe ) . appendTo ( document . body ) ; } , abort : function ( ) { if ( iframe ) { iframe . unbind ( "load" ) . prop ( "src" , "javascript" . concat ( ":false;" ) ) ; } if ( form ) { form . remove ( ) ; } } } ; } } ) ; $ . ajaxSetup ( { converters : { "iframe text" : function ( iframe ) { return $ ( iframe [ 0 ] . body ) . text ( ) ; } , "iframe json" : function ( iframe ) { return $ . parseJSON ( $ ( iframe [ 0 ] . body ) . text ( ) ) ; } , "iframe html" : function ( iframe ) { return $ ( iframe [ 0 ] . body ) . html ( ) ; } , "iframe script" : function ( iframe ) { return $ . globalEval ( $ ( iframe [ 0 ] . body ) . text ( ) ) ; } } } ) ; } ) ) ;
/ *
* jQuery File Upload Plugin 5.11 . 2
* https : //github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
( function ( factory ) { if ( typeof define === "function" && define . amd ) { define ( [ "jquery" , "jquery.ui.widget" ] , factory ) ; } else { factory ( window . jQuery ) ; } } ( function ( $ ) { $ . support . xhrFileUpload = ! ! ( window . XMLHttpRequestUpload && window . FileReader ) ; $ . support . xhrFormDataFileUpload = ! ! window . FormData ; $ . widget ( "blueimp.fileupload" , { options : { namespace : undefined , dropZone : $ ( document ) , fileInput : undefined , replaceFileInput : true , paramName : undefined , singleFileUploads : true , limitMultiFileUploads : undefined , sequentialUploads : false , limitConcurrentUploads : undefined , forceIframeTransport : false , redirect : undefined , redirectParamName : undefined , postMessage : undefined , multipart : true , maxChunkSize : undefined , uploadedBytes : undefined , recalculateProgress : true , progressInterval : 100 , bitrateInterval : 500 , formData : function ( form ) { return form . serializeArray ( ) ; } , add : function ( e , data ) { data . submit ( ) ; } , processData : false , contentType : false , cache : false } , _refreshOptionsList : [ "namespace" , "dropZone" , "fileInput" , "multipart" , "forceIframeTransport" ] , _BitrateTimer : function ( ) { this . timestamp = + ( new Date ( ) ) ; this . loaded = 0 ; this . bitrate = 0 ; this . getBitrate = function ( now , loaded , interval ) { var timeDiff = now - this . timestamp ; if ( ! this . bitrate || ! interval || timeDiff > interval ) { this . bitrate = ( loaded - this . loaded ) * ( 1000 / timeDiff ) * 8 ; this . loaded = loaded ; this . timestamp = now ; } return this . bitrate ; } ; } , _isXHRUpload : function ( options ) { return ! options . forceIframeTransport && ( ( ! options . multipart && $ . support . xhrFileUpload ) || $ . support . xhrFormDataFileUpload ) ; } , _getFormData : function ( options ) { var formData ; if ( typeof options . formData === "function" ) { return options . formData ( options . form ) ; } if ( $ . isArray ( options . formData ) ) { return options . formData ; } if ( options . formData ) { formData = [ ] ; $ . each ( options . formData , function ( name , value ) { formData . push ( { name : name , value : value } ) ; } ) ; return formData ; } return [ ] ; } , _getTotal : function ( files ) { var total = 0 ; $ . each ( files , function ( index , file ) { total += file . size || 1 ; } ) ; return total ; } , _onProgress : function ( e , data ) { if ( e . lengthComputable ) { var now = + ( new Date ( ) ) , total , loaded ; if ( data . _time && data . progressInterval && ( now - data . _time < data . progressInterval ) && e . loaded !== e . total ) { return ; } data . _time = now ; total = data . total || this . _getTotal ( data . files ) ; loaded = parseInt ( e . loaded / e . total * ( data . chunkSize || total ) , 10 ) + ( data . uploadedBytes || 0 ) ; this . _loaded += loaded - ( data . loaded || data . uploadedBytes || 0 ) ; data . lengthComputable = true ; data . loaded = loaded ; data . total = total ; data . bitrate = data . _bitrateTimer . getBitrate ( now , loaded , data . bitrateInterval ) ; this . _trigger ( "progress" , e , data ) ; this . _trigger ( "progressall" , e , { lengthComputable : true , loaded : this . _loaded , total : this . _total , bitrate : this . _bitrateTimer . getBitrate ( now , this . _loaded , data . bitrateInterval ) } ) ; } } , _initProgressListener : function ( options ) { var that = this , xhr = options . xhr ? options . xhr ( ) : $ . ajaxSettings . xhr ( ) ; if ( xhr . upload ) { $ ( xhr . upload ) . bind ( "progress" , function ( e ) { var oe = e . originalEvent ; e . lengthComputable = oe . lengthComputable ; e . loaded = oe . loaded ; e . total = oe . total ; that . _onProgress ( e , options ) ; } ) ; options . xhr = function ( ) { return xhr ; } ; } } , _initXHRData : function ( options ) { var formData , file = options . files [ 0 ] , multipart = options . multipart || ! $ . support . xhrFileUpload , paramName = options . paramName [ 0 ] ; if ( ! multipart || options . blob ) { options . headers = $ . extend ( options . headers , { "X-File-Name" : file . name , "X-File-Type" : file . type , "X-File-Size" : file . size } ) ; if ( ! options . blob ) { options . contentType = file . type ; options . data = file ; } else { if ( ! multipart ) { options . contentType = "application/octet-stream" ; options . data = options . blob ; } } } if ( multipart && $ . support . xhrFormDataFileUpload ) { if ( options . postMessage ) { formData = this . _getFormData ( options ) ; if ( options . blob ) { formData . push ( { name : paramName , value : options . blob } ) ; } else { $ . each ( options . files , function ( index , file ) { formData . push ( { name : options . paramName [ index ] || paramName , value : file } ) ; } ) ; } } else { if ( options . formData instanceof FormData ) { formData = options . formData ; } else { formData = new FormData ( ) ; $ . each ( this . _getFormData ( options ) , function ( index , field ) { formData . append ( field . name , field . value ) ; } ) ; } if ( options . blob ) { formData . append ( paramName , options . blob , file . name ) ; } else { $ . each ( options . files , function ( index , file ) { if ( file instanceof Blob ) { formData . append ( option
/ *
* jQuery File Upload File Processing Plugin 1.0
* https : //github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
( function ( factory ) { if ( typeof define === "function" && define . amd ) { define ( [ "jquery" , "load-image" , "canvas-to-blob" , "./jquery.fileupload" ] , factory ) ; } else { factory ( window . jQuery , window . loadImage ) ; } } ( function ( $ , loadImage ) { $ . widget ( "blueimpFP.fileupload" , $ . blueimp . fileupload , { options : { process : [ ] , add : function ( e , data ) { $ ( this ) . fileupload ( "process" , data ) . done ( function ( ) { data . submit ( ) ; } ) ; } } , processActions : { load : function ( data , options ) { var that = this , file = data . files [ data . index ] , dfd = $ . Deferred ( ) ; if ( window . HTMLCanvasElement && window . HTMLCanvasElement . prototype . toBlob && ( $ . type ( options . maxFileSize ) !== "number" || file . size < options . maxFileSize ) && ( ! options . fileTypes || options . fileTypes . test ( file . type ) ) ) { loadImage ( file , function ( canvas ) { data . canvas = canvas ; dfd . resolveWith ( that , [ data ] ) ; } , { canvas : true } ) ; } else { dfd . rejectWith ( that , [ data ] ) ; } return dfd . promise ( ) ; } , resize : function ( data , options ) { if ( data . canvas ) { var canvas = loadImage . scale ( data . canvas , options ) ; if ( canvas . width !== data . canvas . width || canvas . height !== data . canvas . height ) { data . canvas = canvas ; data . processed = true ; } } return data ; } , save : function ( data , options ) { if ( ! data . canvas || ! data . processed ) { return data ; } var that = this , file = data . files [ data . index ] , name = file . name , dfd = $ . Deferred ( ) , callback = function ( blob ) { if ( ! blob . name ) { if ( file . type === blob . type ) { blob . name = file . name ; } else { if ( file . name ) { blob . name = file . name . replace ( /\..+$/ , "." + blob . type . substr ( 6 ) ) ; } } } data . files [ data . index ] = blob ; dfd . resolveWith ( that , [ data ] ) ; } ; if ( data . canvas . mozGetAsFile ) { callback ( data . canvas . mozGetAsFile ( ( /^image\/(jpeg|png)$/ . test ( file . type ) && name ) || ( ( name && name . replace ( /\..+$/ , "" ) ) || "blob" ) + ".png" , file . type ) ) ; } else { data . canvas . toBlob ( callback , file . type ) ; } return dfd . promise ( ) ; } } , _processFile : function ( files , index , options ) { var that = this , dfd = $ . Deferred ( ) . resolveWith ( that , [ { files : files , index : index } ] ) , chain = dfd . promise ( ) ; that . _processing += 1 ; $ . each ( options . process , function ( i , settings ) { chain = chain . pipe ( function ( data ) { return that . processActions [ settings . action ] . call ( this , data , settings ) ; } ) ; } ) ; chain . always ( function ( ) { that . _processing -= 1 ; if ( that . _processing === 0 ) { that . element . removeClass ( "fileupload-processing" ) ; } } ) ; if ( that . _processing === 1 ) { that . element . addClass ( "fileupload-processing" ) ; } return chain ; } , process : function ( data ) { var that = this , options = $ . extend ( { } , this . options , data ) ; if ( options . process && options . process . length && this . _isXHRUpload ( options ) ) { $ . each ( data . files , function ( index , file ) { that . _processingQueue = that . _processingQueue . pipe ( function ( ) { var dfd = $ . Deferred ( ) ; that . _processFile ( data . files , index , options ) . always ( function ( ) { dfd . resolveWith ( that ) ; } ) ; return dfd . promise ( ) ; } ) ; } ) ; } return this . _processingQueue ; } , _create : function ( ) { $ . blueimp . fileupload . prototype . _create . call ( this ) ; this . _processing = 0 ; this . _processingQueue = $ . Deferred ( ) . resolveWith ( this ) . promise ( ) ; } } ) ; } ) ) ;
/ *
* jQuery File Upload User Interface Plugin 6.8 . 1
* https : //github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
2014-11-14 03:23:58 +00:00
( function ( factory ) { if ( typeof define === "function" && define . amd ) { define ( [ "jquery" , "tmpl" , "load-image" , "./jquery.fileupload-fp" ] , factory ) ; } else { factory ( window . jQuery , window . tmpl , window . loadImage ) ; } } ( function ( $ , tmpl , loadImage ) { var parentWidget = ( $ . blueimpFP || $ . blueimp ) . fileupload ; $ . widget ( "blueimpUI.fileupload" , parentWidget , { options : { autoUpload : false , maxNumberOfFiles : undefined , maxFileSize : undefined , minFileSize : undefined , acceptFileTypes : /.+$/i , previewSourceFileTypes : /^image\/(gif|jpeg|png)$/ , previewSourceMaxFileSize : 5000000 , previewMaxWidth : 80 , previewMaxHeight : 80 , previewAsCanvas : true , uploadTemplateId : "template-upload" , downloadTemplateId : "template-download" , filesContainer : undefined , prependFiles : false , dataType : "json" , add : function ( e , data ) { var that = $ ( this ) . data ( "fileupload" ) , options = that . options , files = data . files ; $ ( this ) . fileupload ( "process" , data ) . done ( function ( ) { that . _adjustMaxNumberOfFiles ( - files . length ) ; data . isAdjusted = true ; data . files . valid = data . isValidated = that . _validate ( files ) ; data . context = that . _renderUpload ( files ) . data ( "data" , data ) ; options . filesContainer [ options . prependFiles ? "prepend" : "append" ] ( data . context ) ; that . _renderPreviews ( files , data . context ) ; that . _forceReflow ( data . context ) ; that . _transition ( data . context ) . done ( function ( ) { if ( ( that . _trigger ( "added" , e , data ) !== false ) && ( options . autoUpload || data . autoUpload ) && data . autoUpload !== false && data . isValidated ) { data . submit ( ) ; } } ) ; } ) ; } , send : function ( e , data ) { var that = $ ( this ) . data ( "fileupload" ) ; if ( ! data . isValidated ) { if ( ! data . isAdjusted ) { that . _adjustMaxNumberOfFiles ( - data . files . length ) ; } if ( ! that . _validate ( data . files ) ) { return false ; } } if ( data . context && data . dataType && data . dataType . substr ( 0 , 6 ) === "iframe" ) { data . context . find ( ".progress" ) . addClass ( ! $ . support . transition && "progress-animated" ) . find ( ".bar" ) . css ( "width" , parseInt ( 100 , 10 ) + "%" ) ; } return that . _trigger ( "sent" , e , data ) ; } , done : function ( e , data ) { _this = $ ( this ) ; $ ( ".saving-tip" , $ ( this ) ) . addClass ( "hide" ) ; var that = $ ( this ) . data ( "fileupload" ) , template ; if ( data . context ) { data . context . each ( function ( index ) { var file = ( $ . isArray ( data . result ) && data . result [ index ] ) || { error : "emptyResult" } ; file . size = data . files [ index ] . size ; if ( file . error ) { file . error = data . result . error || "emptyResult" ; file . name = data . files [ index ] . name ; that . _adjustMaxNumberOfFiles ( 1 ) ; } that . _transition ( $ ( this ) ) . done ( function ( ) { var node = $ ( this ) ; template = that . _renderDownload ( [ file ] ) . css ( "height" , node . height ( ) ) . replaceAll ( node ) ; that . _forceReflow ( template ) ; that . _transition ( template ) . done ( function ( ) {
if ( _this . find ( '.files .cancel' ) . length == 0 ) {
_this . find ( '.total-progress, .fileupload-buttonbar .cancel' ) . addClass ( 'hide' ) ;
var fu _status = _this . find ( '.status' ) ;
fu _status . html ( fu _status . data ( 'complete_status' ) ) ;
_this . find ( '.close' ) . removeClass ( 'hide' ) ;
}
data . context = $ ( this ) ; that . _trigger ( "completed" , e , data ) ; } ) ; } ) ; } ) ; } else { template = that . _renderDownload ( data . result ) . appendTo ( that . options . filesContainer ) ; that . _forceReflow ( template ) ; that . _transition ( template ) . done ( function ( ) { data . context = $ ( this ) ; that . _trigger ( "completed" , e , data ) ; } ) ; } } , fail : function ( e , data ) { var _this = $ ( this ) ; $ ( ".saving-tip" , $ ( this ) ) . addClass ( "hide" ) ; var that = $ ( this ) . data ( "fileupload" ) , template ; that . _adjustMaxNumberOfFiles ( data . files . length ) ; if ( data . context ) { data . context . each ( function ( index ) { if ( data . errorThrown !== "abort" ) { var file = data . files [ index ] ; var r _error ; if ( data . jqXHR . responseText ) { try { r _error = $ . parseJSON ( data . jqXHR . responseText ) . error ; } catch ( e ) { r _error = "" ; } } if ( data . dataType == "iframe json" ) { data . errorThrown = "" ; } file . error = r _error || file . error || data . errorThrown || "can not connect the file server" ; that . _transition ( $ ( this ) ) . done ( function ( ) { var node = $ ( this ) ; template = that . _renderDownload ( [ file ] ) . replaceAll ( node ) ; that . _forceReflow ( template ) ; that . _transition ( template ) . done ( function ( ) { data . context = $ ( this ) ; that . _trigger ( "failed" , e , data ) ; } ) ; } ) ; } else { that . _transition ( $ ( this ) ) . done ( function ( ) {
//$(this).remove();
//that._trigger("failed",e,data);
var file = data . files [ index ] ;
file . canceled = true ;
var node = $ ( this ) ;
template = that . _renderDownload ( [ file ] ) . replaceAll ( node ) ;
that . _forceReflow ( template ) ;
that . _transition ( template ) . done ( function ( ) {
data . context = $ ( this ) ;
that . _trigger ( 'failed' , e , data ) ;
} ) ;
if ( that . options . filesContainer . find ( '.cancel' ) . length == 0 ) {
// for '#upload-file-dialog': hide 'total-progress' & 'cancel all', update 'status'
_this . find ( '.total-progress, .fileupload-buttonbar .cancel' ) . addClass ( 'hide' ) ;
var fu _status = _this . find ( '.status' ) ;
fu _status . html ( fu _status . data ( 'cancel_status' ) ) ;
_this . find ( '.close' ) . removeClass ( 'hide' ) ;
}
} ) ; } } ) ; } else { if ( data . errorThrown !== "abort" ) { that . _adjustMaxNumberOfFiles ( - data . files . length ) ; data . context = that . _renderUpload ( data . files ) . appendTo ( that . options . filesContainer ) . data ( "data" , data ) ; that . _forceReflow ( data . context ) ; that . _transition ( data . context ) . done ( function ( ) { data . context = $ ( this ) ; that . _trigger ( "failed" , e , data ) ; } ) ; } else { that . _trigger ( "failed" , e , data ) ; } } } , progress : function ( e , data ) { if ( data . context ) { data . context . find ( ".bar" ) . css ( "width" , parseInt ( data . loaded / data . total * 100 , 10 ) + "%" ) ; } } , progressall : function ( e , data ) { var $this = $ ( this ) ; $this . find ( ".fileupload-progress" ) . find ( ".bar" ) . css ( "width" , parseInt ( data . loaded / data . total * 100 , 10 ) + "%" ) . end ( ) . find ( ".progress-extended" ) . each ( function ( ) { $ ( this ) . html ( $this . data ( "fileupload" ) . _renderExtendedProgress ( data ) ) ; } ) ; if ( data . loaded > 0 && data . loaded == data . total ) { $this . find ( ".saving-tip" ) . removeClass ( "hide" ) ; } } , start : function ( e ) { var that = $ ( this ) . data ( "fileupload" ) ; that . _transition ( $ ( this ) . find ( ".fileupload-progress" ) ) . done ( function ( ) { that . _trigger ( "started" , e ) ; } ) ; } , stop : function ( e ) { var that = $ ( this ) . data ( "fileupload" ) ; that . _transition ( $ ( this ) . find ( ".fileupload-progress" ) ) . done ( function ( ) { $ ( this ) . find ( ".bar" ) . css ( "width" , "0%" ) ; $ ( this ) . find ( ".progress-extended" ) . html ( " " ) ; that . _trigger ( "stopped" , e ) ; } ) ; } , destroy : function ( e , data ) { var that = $ ( this ) . data ( "fileupload" ) ; if ( data . url ) { $ . ajax ( data ) ; } that . _adjustMaxNumberOfFiles ( 1 ) ; that . _transition ( data . context ) . done ( function ( ) { $ ( this ) . remove ( ) ; that . _trigger ( "destroyed" , e , data ) ; } ) ; } } , _enableDragToDesktop : function ( ) { var link = $ ( this ) , url = link . prop ( "href" ) , name = link . prop ( "download" ) , type = "application/octet-stream" ; link . bind ( "dragstart" , function ( e ) { try { e . originalEvent . dataTransfer . setData ( "DownloadURL" , [ type , name , url ] . join ( ":" ) ) ; } catch ( err ) { } } ) ; } , _adjustMaxNumberOfFiles : function ( operand ) { if ( typeof this . options . maxNumberOfFiles === "number" ) { this . options . maxNumberOfFiles += operand ; if ( this . options . maxNumberOfFiles < 1 ) { this . _disableFileInputButton ( ) ; } else { this . _enableFileInputButton ( ) ; } } } , _formatFileSize : function ( bytes ) { if ( typeof bytes !== "number" ) { return "" ; } if ( bytes >= 1000000000 ) { return ( bytes / 1000000000 ) . toFixed ( 2 ) + " GB" ; } if ( bytes >= 1000000 ) { return ( bytes / 1000000 ) . toFixed ( 2 ) + " MB" ; } return ( bytes / 1000 ) . toFixed ( 2 ) + " KB" ; } , _formatBitrate : function ( bits ) { if ( typeof bits !== "number" ) { return "" ; } else { var Bs = ( bits / 8 ) . toFixed ( 0 ) ; } if ( Bs >= 1000000000 ) { return ( Bs / 1000000000 ) . toFixed ( 1 ) + " GB/s" ; } if ( Bs >= 1000000 ) { return ( Bs / 1000000 ) . toFixed ( 1 ) + " MB/s" ; } if ( Bs >= 1000 ) { return ( Bs / 1000 ) . toFixed ( 0 ) + " KB/s" ; } return Bs + " B/s" ; } , _formatTime : function ( seconds ) { var date = new Date ( seconds * 1000 ) , days = parseInt ( seconds / 86400 , 10 ) ; days = days ? days + "d " : "" ; return days + ( "0" + date . getUTCHours ( ) ) . slice ( - 2 ) + ":" + ( "0" + date . getUTCMinutes ( ) ) . slice ( - 2 ) + ":" + ( "0" + date . getUTCSeconds ( ) ) . slice ( - 2 ) ; } , _formatPercentage : function ( floatValue ) { return ( floatValue * 100 ) . toFixed ( 2 ) + " %" ; } , _renderExtendedProgress : function ( data ) { return this . _formatBitrate ( data . bitrate ) + " | " + this . _formatTime ( ( data . total - data . loaded ) * 8 / data . bitrate ) + " | " + this . _formatPercentage ( data . loaded / data . total ) + " | " + this . _formatFileSize ( data . loaded ) + " / " + this . _formatFileSize ( data . total ) ; } , _hasError : function ( file ) { if ( file . error ) { return file . error ; } if ( this . options . maxNumberOfFiles < 0 ) { return "maxNumberOfFiles" ; } if ( ! ( this . options . acceptFileTypes . test ( file . type ) || this . options . acceptFileTypes . test ( file . name ) ) ) { return "acceptFileTypes" ; } if ( this . options . maxFileSize && file . size > this . options . maxFileSize ) { return "maxFileSize" ; } if ( typeof file . size === "number" && file . size < this . options . minFileSize ) { return "minFileSize" ; } return null ; } , _validate : function ( files ) { var that = this , valid = ! ! files . length ; $ . each ( files , function ( index , file ) { file . error = that . _hasError ( file ) ; if ( file . error ) { valid = false ; } } ) ; return valid ; } , _renderTemplate : function ( func , files ) { if ( ! func ) { return $ ( ) ; } var result = func ( { files : files , formatFileSize : this . _formatFileSize , options : this . options } ) ; if ( result instanceof $ ) { return result ; } return $ ( this . options . templatesContainer ) . html ( result ) . children ( ) ; } , _renderPreview : function ( file , node ) { var that = this , options = this . options , dfd = $ . Deferred ( ) ; return ( ( loadImage && loadImage ( file ,