plupload-2.1.8/000077500000000000000000000000001255343340300133445ustar00rootroot00000000000000plupload-2.1.8/examples/000077500000000000000000000000001255343340300151625ustar00rootroot00000000000000plupload-2.1.8/examples/custom.html000066400000000000000000000042631255343340300173670ustar00rootroot00000000000000 Plupload - Custom example

Custom example

Shows you how to use the core plupload API.

Your browser doesn't have Flash, Silverlight or HTML5 support.

[Select files] [Upload files]







plupload-2.1.8/examples/dump.php000066400000000000000000000012211255343340300166340ustar00rootroot00000000000000



Plupload - Form dump


	

Post dump

Shows the form items posted.

$value) { ?>
Name Value
plupload-2.1.8/examples/events.html000066400000000000000000000204511255343340300173560ustar00rootroot00000000000000 Plupload - Events example

Events example

[Select files] [Upload files]


 


plupload-2.1.8/examples/jquery/000077500000000000000000000000001255343340300165015ustar00rootroot00000000000000plupload-2.1.8/examples/jquery/all_runtimes.html000066400000000000000000000072421255343340300220720ustar00rootroot00000000000000




Plupload - Queue widget example














Queue widget example

Shows the jQuery Plupload Queue widget and under different runtimes.

Flash runtime

Your browser doesn't have Flash installed.

Silverlight runtime

Your browser doesn't have Silverlight installed.

HTML 4 runtime

Your browser doesn't have HTML 4 support.

HTML 5 runtime

Your browser doesn't support native upload.

plupload-2.1.8/examples/jquery/jquery_ui_widget.html000066400000000000000000000062511255343340300227520ustar00rootroot00000000000000 Plupload - jQuery UI Widget

jQuery UI Widget

You can see this example with different themes on the www.plupload.com website.

Your browser doesn't have Flash, Silverlight or HTML5 support.


plupload-2.1.8/examples/jquery/queue_widget.html000066400000000000000000000034561255343340300220660ustar00rootroot00000000000000 Plupload - Queue widget example

Your browser doesn't have Flash, Silverlight or HTML5 support.

plupload-2.1.8/examples/jquery/s3.php000066400000000000000000000104331255343340300175400ustar00rootroot00000000000000 In our tests SilverLight didn't require anything special and worked with this configuration just fine. It may fail back to the same crossdomain.xml as last resort. !!!Important!!! Plupload UI Widget here, is used only for demo purposes and is not required for uploading to S3. */ // important variables that will be used throughout this example $bucket = 'BUCKET'; // these can be found on your Account page, under Security Credentials > Access Keys $accessKeyId = 'ACCESS_KEY_ID'; $secret = 'SECRET_ACCESS_KEY'; // prepare policy $policy = base64_encode(json_encode(array( // ISO 8601 - date('c'); generates uncompatible date, so better do it manually 'expiration' => date('Y-m-d\TH:i:s.000\Z', strtotime('+1 day')), 'conditions' => array( array('bucket' => $bucket), array('acl' => 'public-read'), array('starts-with', '$key', ''), // for demo purposes we are accepting only images array('starts-with', '$Content-Type', 'image/'), // Plupload internally adds name field, so we need to mention it here array('starts-with', '$name', ''), // One more field to take into account: Filename - gets silently sent by FileReference.upload() in Flash // http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTFlash.html array('starts-with', '$Filename', ''), ) ))); // sign policy $signature = base64_encode(hash_hmac('sha1', $policy, $secret, true)); ?> Plupload to Amazon S3 Example

Plupload to Amazon S3 Example

Your browser doesn't have Flash, Silverlight or HTML5 support.

plupload-2.1.8/examples/upload.php000066400000000000000000000070441255343340300171640ustar00rootroot00000000000000:<@;>A=@DAE?BFADHBEJAEI*,.DGK.13358025+-0147-/2EHLCFK^ae_bfacg`bf]ad]`c\^bY\_[]aX[]Z\`WY\VX[UWZTVXFJNَx{~X[_UY]oqu]`dgjn쏑;=@TW[؃HLPIMQOSW뢣[^b񩪫[_cΧ`cgLOQ\`cRVZKNRSVZTVYSUXHKObei;=AY[_PSVGJMLPTFHJdgkNPTSUYDGLPSUQTXRUXNQS58;LOSBEIORTOQSCFI=@CBEHIKNWZ^KMPcfjvx|ɧwz}ehl_cgfimz|x{ߤ{}]ae\_cUX\猎GJNnptEIMEIM!,Pm H*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8sɳϟ@ Jѣi(]ʴӧPJJUiXjʵׯ`^AٳhӪ]˶[ʝKݻx߿ LÈzX̸ǐ#KL3k̹ϠC̡ӨS^ͺץ5ȞM۸s[ NȓУKNukνËӫ_Ͼ[OϿ (h& 4F(Vh v ($j(É(,0x" 4h8<#()DiH&APF)TViX:Ö\v`)dehlp)'ix|矀*蠄j衈&袌6裐F*餔Vj饘f馜v駠*ꨤjꩨꪬ꫰*무j뭸뮼+k&6F+Vkfv+k覫;k,l$ 7G,Wlgw# $l(,0,4ל8<@-DmH'?/PG-TWmXg\w`]dmhlp-i'`x|߀.n'7G.WngwG 褗n騧ꬷ~n/o+7G/Wogw}/o觯/o) H3:'HA̠7z @(L W0 g8̡w@! H"HL&PH*ZX̢؀.z` H2hLF1pH:xE> IB+H"F:򑐌$'HX̤&7Nz򓠴FIRL*WV,gIZ̥.a)^ 0IbL2La:Ќ4IjZ̦6nz8IrL:v4gIz̧>~ @JЂTHBІ:D'JъZu(6юz HGJҒ(MJWҖTLgJӚ8ͩNwӞ@ PJԢHMR$Lp)a| RXJVJ gXHWB\p-+@ jA\Z!w– [-H` &ceBbX$8,AK*J6fH֮Bp@JB v[(B}k0YȲlXr\Uniπ m,x׻kZ ֻ^^V (+)$պbȯbEYM¼`;Xvp'zMc{ \Z (vCVR"0\): x 8^vQ@lJM݂]ȁWI܊`S8@2(x `3MW`Y["@;*͠'ʼ)5iVs*te/(5ec2(1m^k:'MH7M'͈MaG jL7Ԩu68Pհ5U@k#֯C#6GoPk# ~6`Ў]i[[{6H@2b6J坆za7!(M&@>p4 OaMfB'.7X xAMGGN~@p6LT"0gNWTw!@ΉAtgS ;O%س)lA(ַ؂~6-$GHמvK$b $LBp#"Cd"Ф;plupload-2.1.8/js/jquery.plupload.queue/img/buttons-disabled.png000066400000000000000000000024141255343340300247670ustar00rootroot00000000000000PNG  IHDRixn<tEXtSoftwareAdobe ImageReadyqe<IPLTEpYw`ƲӼs\NjG>̇oXrd٥Ջ|kZQɖԋˁH>ڪWEۨlZ{ߐ}x~i}ۛӊ|dusyDž}ʵ߬ݩɶݬynq_̊|eV~ozkhS௸ыE>äm}kߥ̨ˆ}gnXʱue}f䶑~̄}jڦΔܯdWj[eUOHoY{Ԝupr[uߦ̩yC:ݪơD:Ҵɯt\t[B6ЖȮϖ|||Ž҃Ӊ;4aTPAݯٕzC8٥ۨmԝٖpcğ|kXPIŀxdyd˲\SؒԊE>mcS̅~i͈tRNSN IDATxcsQMMAӤm۶m۶m۶˺M= 0*JD_QWy[Vk*р%/CtW`H }+%H:DٞtGC#!I?W='fa3OI9xvqi1~jsQnb BYtD=[*h L^$ەA{> 1 HgH)Yp<:[zH"kH;-Ĝ5Ό+Ңe\UE;O e#U[FctA8A:y;l)Fi&ҙ=H—RǼE1X^{R14?HGyQֈFI40a!)Cmz1WQIENDB`plupload-2.1.8/js/jquery.plupload.queue/img/buttons.png000066400000000000000000000026371255343340300232310ustar00rootroot00000000000000PNG  IHDRixn<tEXtSoftwareAdobe ImageReadyqe<PLTEpYw`Ӽˑs\͔|3 }f\St\٥tOٕ~i) |kݯydj[Z~o}pcdWô̩k}6NJuuDsːjy4pmۛȍo=گߥn8̅yߦɀaϫԜơՋi9WEЖD:C8r[W(zkΔPI߬ƒc1_CtH>ɝؒueܨğe1ݩxq?hSˆOHٖE>ڦԝnXʱ‚7 oẊ͈ȮrdݪJˁzxd(kXۨhF|dcSq_f؁m|̊mG>R"ň|U3\{}jDžbF{}gΖ[)aT~k7uыʐh5ɯ<ԋeUF٥}k})+tRNS7 IDATxb ChH i!09G ]LC 2M֘gh4/o*^؜̩m+ CpB@xY9tu);m_p i]쵇PH8Vj^L d긙w{Lã#"uq \ +c[pDk(;,,,VB1ªI,@B:;pMߌj\C&e޶)C!!`ʫCBzҖHp8=B.Kor"`z~V0+B%?`җ9}b)E+7..LJ!]Y']pcP8Xsή7 ޘP LC@BٻhBѐqH-0!FC^ 6BIENDB`plupload-2.1.8/js/jquery.plupload.queue/img/delete.gif000066400000000000000000000002641255343340300227500ustar00rootroot00000000000000GIF89a̙ffffff3!,aIkh#ETa lP@wix ظ[apHhr9|7t$Sp%0A|ey@pbah}Ex;plupload-2.1.8/js/jquery.plupload.queue/img/done.gif000066400000000000000000000020001255343340300224210ustar00rootroot00000000000000GIF89aܥؒrhw᯵zmnbB3I'?;D3lVLJˆѵˆڦ}fߛiʇ\;peܦזӛ΋еrוQ.yk?;p|d;'ydԍq[w`~o͈㶺۵&#֕ב&#pWiJodjPݪ̇㸇yuss\td}gthۨdL?;ۨ51oauhҐٵoaoYmW٥nXoXsflK߬\=51}fᰙ͊?,i*ƋpL H pI0G%v@0 h(@.$rѧJ(: AF`6qT'2=!pE8y:u $wtl$!*<ِpeS(NaE%"'8h 4$?Vqc 5R XHPʓI@DG"1  ;plupload-2.1.8/js/jquery.plupload.queue/img/error.gif000066400000000000000000000017421255343340300226410ustar00rootroot00000000000000GIF89aա=֣>X\բ>l}\UӏҌ]NԅW؍w 1WTZ[Xq٘#:RυZ^忈ΆߩΫ*ÇW-֓ XVW\TғDߤ+E{q Dbם]Զܞ'עؔ٠Ub~ݤ;т֝]^h\dӌQCtܲPݱGyhڛ%]ݡ)ъh7H!, HA@ Qp  `4x" kL&hLtL?<"# y;= j"<0{S2 u#!! ,$&$trtTRT􄂄\Z\w$JƣQb0cdJ2]@ T A(1hMҠ94T$5V2A n :Ղ`-4?cXtTQ "_ #>>@R"yh>{S gu"!;plupload-2.1.8/js/jquery.plupload.queue/img/transp50.png000066400000000000000000000006171255343340300232030ustar00rootroot00000000000000PNG  IHDR<qgAMA7tEXtSoftwareAdobe ImageReadyqe<!IDATxұ0İYRJ} 0X`,X c0ca,X 0 ca,0X`,X c0ca,X 0 ca,0X`,X c0ca,X 0 ca,0X`,X c0ca,X c0ca,X 0 ca,0X`,X c0ca,X 0 ca,0X`,X c0ca,X v#g"C&IENDB`plupload-2.1.8/js/jquery.plupload.queue/jquery.plupload.queue.js000066400000000000000000000364651255343340300250760ustar00rootroot00000000000000/** * jquery.plupload.queue.js * * Copyright 2009, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /* global jQuery:true, alert:true */ /** jQuery based implementation of the Plupload API - multi-runtime file uploading API. To use the widget you must include _jQuery_. It is not meant to be extended in any way and is provided to be used as it is. @example

Your browser doesn't have Flash, Silverlight or HTML5 support.

@example // Retrieving a reference to plupload.Uploader object var uploader = $('#uploader').pluploadQueue(); uploader.bind('FilesAdded', function() { // Autostart setTimeout(uploader.start, 1); // "detach" from the main thread }); @class pluploadQueue @constructor @param {Object} settings For detailed information about each option check documentation. @param {String} settings.url URL of the server-side upload handler. @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled. @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. @param {Array} [settings.filters=[]] Set of file type filters, each one defined by hash of title and extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` @param {String} [settings.flash_swf_url] URL of the Flash swf. @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. @param {Number|String} [settings.max_file_size] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`. @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. @param {Boolean} [settings.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. @param {Object} [settings.resize] Enable resizng of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}` @param {Number} [settings.resize.width] If image is bigger, it will be resized. @param {Number} [settings.resize.height] If image is bigger, it will be resized. @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. @param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. @param {Boolean} [settings.dragdrop=true] Enable ability to add file to the queue by drag'n'dropping them from the desktop. @param {Boolean} [settings.rename=false] Enable ability to rename files in the queue. @param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure. */ ;(function($, o) { var uploaders = {}; function _(str) { return plupload.translate(str) || str; } function renderUI(id, target) { // Remove all existing non plupload items target.contents().each(function(i, node) { node = $(node); if (!node.is('.plupload')) { node.remove(); } }); target.prepend( '
' + '
' + '
' + '
' + '
' + '
' + _('Select files') + '
' + '
' + _('Add files to the upload queue and click the start button.') + '
' + '
' + '
' + '
' + '
' + '
' + _('Filename') + '
' + '
 
' + '
' + _('Status') + '
' + '
' + _('Size') + '
' + '
 
' + '
' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '' + '
    ' ); } $.fn.pluploadQueue = function(settings) { if (settings) { this.each(function() { var uploader, target, id, contents_bak; target = $(this); id = target.attr('id'); if (!id) { id = plupload.guid(); target.attr('id', id); } contents_bak = target.html(); renderUI(id, target); settings = $.extend({ dragdrop : true, browse_button : id + '_browse', container : id }, settings); // Enable drag/drop (see PostInit handler as well) if (settings.dragdrop) { settings.drop_element = id + '_filelist'; } uploader = new plupload.Uploader(settings); uploaders[id] = uploader; function handleStatus(file) { var actionClass; if (file.status == plupload.DONE) { actionClass = 'plupload_done'; } if (file.status == plupload.FAILED) { actionClass = 'plupload_failed'; } if (file.status == plupload.QUEUED) { actionClass = 'plupload_delete'; } if (file.status == plupload.UPLOADING) { actionClass = 'plupload_uploading'; } var icon = $('#' + file.id).attr('class', actionClass).find('a').css('display', 'block'); if (file.hint) { icon.attr('title', file.hint); } } function updateTotalProgress() { $('span.plupload_total_status', target).html(uploader.total.percent + '%'); $('div.plupload_progress_bar', target).css('width', uploader.total.percent + '%'); $('span.plupload_upload_status', target).html( o.sprintf(_('Uploaded %d/%d files'), uploader.total.uploaded, uploader.files.length) ); } function updateList() { var fileList = $('ul.plupload_filelist', target).html(''), inputCount = 0, inputHTML; $.each(uploader.files, function(i, file) { inputHTML = ''; if (file.status == plupload.DONE) { if (file.target_name) { inputHTML += ''; } inputHTML += ''; inputHTML += ''; inputCount++; $('#' + id + '_count').val(inputCount); } fileList.append( '
  • ' + '
    ' + file.name + '
    ' + '
    ' + '
    ' + file.percent + '%
    ' + '
    ' + plupload.formatSize(file.size) + '
    ' + '
     
    ' + inputHTML + '
  • ' ); handleStatus(file); $('#' + file.id + '.plupload_delete a').click(function(e) { $('#' + file.id).remove(); uploader.removeFile(file); e.preventDefault(); }); }); $('span.plupload_total_file_size', target).html(plupload.formatSize(uploader.total.size)); if (uploader.total.queued === 0) { $('span.plupload_add_text', target).html(_('Add Files')); } else { $('span.plupload_add_text', target).html(o.sprintf(_('%d files queued'), uploader.total.queued)); } $('a.plupload_start', target).toggleClass('plupload_disabled', uploader.files.length == (uploader.total.uploaded + uploader.total.failed)); // Scroll to end of file list fileList[0].scrollTop = fileList[0].scrollHeight; updateTotalProgress(); // Re-add drag message if there is no files if (!uploader.files.length && uploader.features.dragdrop && uploader.settings.dragdrop) { $('#' + id + '_filelist').append('
  • ' + _("Drag files here.") + '
  • '); } } function destroy() { delete uploaders[id]; uploader.destroy(); target.html(contents_bak); uploader = target = contents_bak = null; } uploader.bind("UploadFile", function(up, file) { $('#' + file.id).addClass('plupload_current_file'); }); uploader.bind('Init', function(up, res) { // Enable rename support if (!settings.unique_names && settings.rename) { target.on('click', '#' + id + '_filelist div.plupload_file_name span', function(e) { var targetSpan = $(e.target), file, parts, name, ext = ""; // Get file name and split out name and extension file = up.getFile(targetSpan.parents('li')[0].id); name = file.name; parts = /^(.+)(\.[^.]+)$/.exec(name); if (parts) { name = parts[1]; ext = parts[2]; } // Display input element targetSpan.hide().after(''); targetSpan.next().val(name).focus().blur(function() { targetSpan.show().next().remove(); }).keydown(function(e) { var targetInput = $(this); if (e.keyCode == 13) { e.preventDefault(); // Rename file and glue extension back on file.name = targetInput.val() + ext; targetSpan.html(file.name); targetInput.blur(); } }); }); } $('#' + id + '_container').attr('title', 'Using runtime: ' + res.runtime); $('a.plupload_start', target).click(function(e) { if (!$(this).hasClass('plupload_disabled')) { uploader.start(); } e.preventDefault(); }); $('a.plupload_stop', target).click(function(e) { e.preventDefault(); uploader.stop(); }); $('a.plupload_start', target).addClass('plupload_disabled'); }); uploader.bind("Error", function(up, err) { var file = err.file, message; if (file) { message = err.message; if (err.details) { message += " (" + err.details + ")"; } if (err.code == plupload.FILE_SIZE_ERROR) { alert(_("Error: File too large:") + " " + file.name); } if (err.code == plupload.FILE_EXTENSION_ERROR) { alert(_("Error: Invalid file extension:") + " " + file.name); } file.hint = message; $('#' + file.id).attr('class', 'plupload_failed').find('a').css('display', 'block').attr('title', message); } if (err.code === plupload.INIT_ERROR) { setTimeout(function() { destroy(); }, 1); } }); uploader.bind("PostInit", function(up) { // features are populated only after input components are fully instantiated if (up.settings.dragdrop && up.features.dragdrop) { $('#' + id + '_filelist').append('
  • ' + _("Drag files here.") + '
  • '); } }); uploader.init(); uploader.bind('StateChanged', function() { if (uploader.state === plupload.STARTED) { $('li.plupload_delete a,div.plupload_buttons', target).hide(); uploader.disableBrowse(true); $('span.plupload_upload_status,div.plupload_progress,a.plupload_stop', target).css('display', 'block'); $('span.plupload_upload_status', target).html('Uploaded ' + uploader.total.uploaded + '/' + uploader.files.length + ' files'); if (settings.multiple_queues) { $('span.plupload_total_status,span.plupload_total_file_size', target).show(); } } else { updateList(); $('a.plupload_stop,div.plupload_progress', target).hide(); $('a.plupload_delete', target).css('display', 'block'); if (settings.multiple_queues && uploader.total.uploaded + uploader.total.failed == uploader.files.length) { $(".plupload_buttons,.plupload_upload_status", target).css("display", "inline"); uploader.disableBrowse(false); $(".plupload_start", target).addClass("plupload_disabled"); $('span.plupload_total_status,span.plupload_total_file_size', target).hide(); } } }); uploader.bind('FilesAdded', updateList); uploader.bind('FilesRemoved', function() { // since the whole file list is redrawn for every change in the queue // we need to scroll back to the file removal point to avoid annoying // scrolling to the bottom bug (see #926) var scrollTop = $('#' + id + '_filelist').scrollTop(); updateList(); $('#' + id + '_filelist').scrollTop(scrollTop); }); uploader.bind('FileUploaded', function(up, file) { handleStatus(file); }); uploader.bind("UploadProgress", function(up, file) { // Set file specific progress $('#' + file.id + ' div.plupload_file_status', target).html(file.percent + '%'); handleStatus(file); updateTotalProgress(); }); // Call setup function if (settings.setup) { settings.setup(uploader); } }); return this; } else { // Get uploader instance for specified element return uploaders[$(this[0]).attr('id')]; } }; })(jQuery, mOxie); plupload-2.1.8/js/jquery.ui.plupload/000077500000000000000000000000001255343340300175325ustar00rootroot00000000000000plupload-2.1.8/js/jquery.ui.plupload/css/000077500000000000000000000000001255343340300203225ustar00rootroot00000000000000plupload-2.1.8/js/jquery.ui.plupload/css/jquery.ui.plupload.css000066400000000000000000000142671255343340300246200ustar00rootroot00000000000000/* Plupload ------------------------------------------------------------------- */ .plupload_wrapper * { box-sizing: content-box; } .plupload_button { cursor: pointer; outline: none; } .plupload_wrapper { font: normal 11px Verdana,sans-serif; width: 100%; min-width: 520px; line-height: 12px; } .plupload_container { _height: 300px; min-height: 300px; position: relative; } .plupload_filelist_footer {border-width: 1px 0 0 0} .plupload_file {border-width: 0 0 1px 0} .plupload_container .plupload_header {border-width: 0 0 1px 0; position: relative;} .plupload_delete .ui-icon, .plupload_done .ui-icon, .plupload_failed .ui-icon { cursor:pointer; } .plupload_header_content { height: 56px; padding: 0 160px 0 60px; position: relative; } .plupload_logo { width: 40px; height: 40px; background: url('../img/plupload.png') no-repeat 0 0; position: absolute; top: 8px; left: 8px; } .plupload_header_content_bw .plupload_logo { background-position: -40px 0; } .plupload_header_title { font: normal 18px sans-serif; line-height: 19px; padding: 6px 0 3px; } .plupload_header_text { font: normal 12px sans-serif; } .plupload_view_switch { position: absolute; right: 16px; bottom: 8px; margin: 0; display: none; } .plupload_view_switch .ui-button { margin-right: -0.31em; } .plupload_content { position: absolute; top: 86px; bottom: 44px; left: 0; right: 0; overflow-y: auto; width: 100%; } .plupload_filelist { border-collapse: collapse; border-left: none; border-right: none; margin: 0; padding: 0; width: 100%; -moz-user-select: none; -webkit-user-select: none; user-select: none; } .plupload_filelist_content { padding: 0; margin: 0; } .plupload_cell {padding: 8px 6px;} .plupload_file { list-style: none; display: block; position: relative; overflow: hidden; line-height: 12px; } .plupload_file_thumb { position: relative; background-image: none; background-color: #eee; } .plupload_thumb_loading { background: #eee url(../img/loading.gif) center no-repeat; } .plupload_thumb_loading .plupload_file_dummy, .plupload_thumb_embedded .plupload_file_dummy { display: none; } .plupload_file_name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .plupload_filelist_header { border-top: none; } .plupload_filelist_footer { position: absolute; bottom: 0; left: 0; right: 0; } .plupload_buttons { position: relative; } /* list view */ .plupload_view_list .plupload_file { border-left: none; border-right: none; border-top: none; height: 29px; width: 100% !important; /* fix IE6 vertical white-space bug */ _float: left; _clear: left; } .plupload_view_list div.plupload_file_size, .plupload_view_list div.plupload_file_status, .plupload_view_list div.plupload_file_action { padding: 8px 6px; position: absolute; top: 0; right: 0; } .plupload_view_list div.plupload_file_name { margin-right: 156px; padding: 8px 6px; _width: 75%; } .plupload_view_list div.plupload_file_size { right: 28px; } .plupload_view_list div.plupload_file_status { right: 82px; } .plupload_view_list .plupload_file_rename { margin-left: -2px; } .plupload_view_list .plupload_file_size, .plupload_view_list .plupload_file_status, .plupload_filelist_footer .plupload_file_size, .plupload_filelist_footer .plupload_file_status { text-align: right; width: 52px; } .plupload_view_list .plupload_file_thumb { position: absolute; top: -999px; } .plupload_view_list .plupload_file_progress { display: none; } /* thumbs view */ .plupload_view_thumbs .plupload_content { top: 57px; } .plupload_view_thumbs .plupload_filelist_header { display: none; } .plupload_view_thumbs .plupload_file { padding: 6px; margin: 10px; border: 1px solid #fff; float: left; } .plupload_view_thumbs .plupload_file_thumb, .plupload_view_thumbs .plupload_file_dummy { text-align: center; overflow: hidden; } .plupload_view_thumbs .plupload_file_dummy { font-size: 21px; font-weight: bold; text-transform: lowercase; overflow: hidden; border: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .plupload_view_thumbs div.plupload_file_action { position: absolute; top: 0; right: 0; } .plupload_view_thumbs div.plupload_file_name { padding: 0; font-weight: bold; } .plupload_view_thumbs .plupload_file_rename { padding: 1px 0; width: 100% !important; } .plupload_view_thumbs div.plupload_file_size { font-size: 0.8em; font-weight: normal; } .plupload_view_thumbs div.plupload_file_status { position: relative; height: 3px; overflow: hidden; text-indent: -999px; margin-bottom: 3px; } .plupload_view_thumbs div.plupload_file_progress { border: none; height: 100%; } .plupload .ui-sortable-helper, .plupload .ui-sortable .plupload_file { cursor:move; } .plupload_file_action {width: 16px;} .plupload_file_name { overflow: hidden; padding-left: 10px; } .plupload_file_rename { border: none; font: normal 11px Verdana, sans-serif; padding: 1px 2px; line-height: 11px; height: 11px; } .plupload_progress {width: 60px;} .plupload_progress_container {padding: 1px;} /* Floats */ .plupload_right {float: right;} .plupload_left {float: left;} .plupload_clear,.plupload_clearer {clear: both;} .plupload_clearer, .plupload_progress_bar { display: block; font-size: 0; line-height: 0; } .plupload_clearer {height: 0;} /* Misc */ .plupload_hidden {display: none !important;} .plupload_droptext { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: transparent; text-align: center; vertical-align: middle; border: 0; line-height: 160px; display: none; } .plupload_dropbox .plupload_droptext { display: block; } .plupload_buttons, .plupload_upload_status {float: left} .plupload_message { position: absolute; top: -1px; left: -1px; height: 100%; width: 100%; } .plupload_message p { padding:0.7em; margin:0; } .plupload_message strong { font-weight: bold; } .plupload_message i { font-style: italic; } .plupload_message p span.ui-icon { float: left; margin-right: 0.3em; } .plupload_header_content .ui-state-error, .plupload_header_content .ui-state-highlight { border:none; } .plupload_message_close { position:absolute; top:5px; right:5px; cursor:pointer; } .plupload .ui-sortable-placeholder { height:35px; } plupload-2.1.8/js/jquery.ui.plupload/img/000077500000000000000000000000001255343340300203065ustar00rootroot00000000000000plupload-2.1.8/js/jquery.ui.plupload/img/loading.gif000066400000000000000000000076671255343340300224320ustar00rootroot00000000000000GIF89alnlܜ줦䴶|z|䤢쬪! NETSCAPE2.0! ,'meZ&&jQŬz fL"Kp%0x aQd8@De ـEB)mP$O03Mh r~.zP]$  7y_7 }#  6S5}EiQySE)@*" qƲz$ qڲ^aa^xDx~3QOQ}F.5Sj(?$vD!! ,lnlܔ줢tvttrt䜞줦`'dXeZ&K&&v 8tNF^Qpv"hрLTQ2B *f@p(P28" 4. $'m*` 8 + 3To"  AG / S*%#Щ)#nn3"oG$Uw D|Ѫ؈RB! ,lnlܔ􄆄줦tvt䌎trt䤢􌊌`'dweZ"B&fIv.BQǠ71].7cd?a2BD2 å);Bpp0&TZ(4rA 4.h2$ o)  a#l)$3R#/`* F $)8ɱ#*%"δ ⿼"I'"sR,U=) ! ,lnlܜ䤦|z|䤢`'dWUeZj&jvږcR bNA2hJ V(۱#(40HpB/9`'QdgBs p. $ q4Xb*R*$ #aS97 G 8 "£=+ 8"*#B֬# b֭ڒa۪BBSqW-WPH,! ,lnlܔ줢tvttrt䜞줦`'d'Ief䲌c1E͹иL6 (v]&b!2ml,[Bpp8 Vfy #PD3ɶ K"fg4 ;) |*%YLM,z @ y@ "'0)7%% {} K h8g|gM?)YL||+'`^W!GJB! ,lnlܔ􄆄줦tvt䌎trt䤢􌊌`'deZfec XlˈP5fz:J\ Qnj"Px7 6( 2\ȹSGSqt@*r[hH8Ldw5r" -* _)jA1gCzV   veA(",5 @%Z*x" Xe(79"'Ctn)vO ZY(EW['&( 1UY! ,'g1eZjudL'6Wi' xzf9>DS]UmAf"C+H-1Mi{%W ׂ)YL6kuh30# ZG]Kǎ[& b%/Nȑ[ )kiU3`@ ,D|;9Nwe|e|#qD ޓJ`] `[U֨"}M6(I&a=7ё&^7:T#jM.ڔ,G_"lٲeWi>j lާm%˦M{paa-wv Pz%񁍃K^j[AAZL0# JlƐv9POJbHy D$wB}{<9 oL% 3|A'_h3t mLehYjUh687'£O0C P[7lɎPIw <]K6B<[*_lJ/Vs yMhz".is/}*Y} Zv ZL ov=yUրiv)mŋCvϡ7f+] T@'l؃Gmܣdm,[YK%n0C%Tj-{ wRx)1Rp`i;Νb2Ik3$Ne{6n`MPy:}ݎzg-WՃJ&FVИ`O{pìLS/8y[ǝ-?PNj腹qr2xq%|[uMp10 &9{5LE?& γwF} 2{wwmi Dʐ:5+cV&L55(߷*1jU@5(y+Mq;0By.J6Sd\_D]>M9wĐ!u{W3`UVS )̅o s;w`ph3j=}]Gu%CXU `A &H|&JWX ,. ,( eNAMwa4)u6ڹi\5`K禦4c VbV_6Zx Z4k@pNst%os*V R\%$ MJkX[YUbmkv2v6re1¶554l;4ih@5ê= "VL~>_^ԩSz"!4U`P~f5,[AhЁ/g "1pAL%^X)ݑWl%;A*0- q|<[V;e[1v;P00٧/g6yzHػF3Ks>̋mHTˆ$U ԃr+3}b@Am&>ecef7FȸF@­'zvPjg Cfg378tXf y?U6OQ{0 Õ &젓ɭd=9Ԍ5q7sY Jj@P6 ,+10s8T6EWntXA3f=>J*xq"7h<7Zp+$a;Pq.CVa@x[.B,l֮A"I? pfgq_Cj҃JR`1[*?L5;gji2pr, 6R6c08V"2*`V2zMnUsmue.a\C輭0E<Hg8Tݕү+ M5x뭷cw}} OvƑ^,&qDu告z_ Fi- uPդn8"v;´q\R. !%bM- S9>pc<`0<(c3P'wa/bZU%72y%zr mwx);;CR)sT9Y. pcn:[mCԓ.R??9 /+s1[|/:'ՄI6JJ-۶!vf)GÑ"ltf$ƳCaf'zzxc8[d1mJ g |K#@~WKtP7jP<֖وpRdҰeQEn8R/Y! wP6K,&j=8S{ѱ=Ǵ0S6޲Pʰ5=rsj_& (|65p$k "G#p>1/4-.p,䍫'H3XT om 3\kzamJ`K??ڥWfԋ8 vÈuAMA+(j%UҢsi5ce A5E&,.b`3hPꋽU޻1U9Qzώ*†žd{(wF8}U6 jU@4oh|Pհx]( ۃ+!j uFf©*C⼗ӱ]э\xeLhYð`W6mZ<ȉs^1^&_α@8p̙6oli{fgMt+1ac:|V_;Roj :b?>kM66Un !Yc$$\>.3eA#ZAD,Y(qNdvzf׾i#hk333*0fN4j3U6qJk&N{wn:=! \"ܫ?d=ˌ9[8iW`zAe;N7 XI'2c=bbd___NEU3_ 篦 "k=DЄ:W d/RF* !it6&1 @8.|,,@WDf^+qbD IN2MN3:j`L/l4M6p%\Yg20TzQ}9<78Ia%fؖqbJ@8>;1~ =2Dž`V0\CRh|4=?D;{ǹnkf+l48\0Y+MUٳ̾s>ZhEn~ηO'SUY@ {SS~zgo!C I߳qxVKjl: tfԅ;Èq=.y ^9t4jSeXIeu2s*| O6>k+~o n @l"S9 b@plG•iO,eWx.Yh,\iE:s;S_z.eVcnnnftfa: ]0& Ĺy^iC@z=7ᷫx]{6Pg6R- BCXg/X0f8Ū LópcHwESE9zb/=/m*{oOh9ddqrom"|Q E߮PW*S'WHx +C=rȁ[<Ν׹pVǓaWRнrQ5 K%<{v9%lJ7&:-8@9ݓekTq'TM}۟ueSm$2lO!оbK]ai%FGG]=x;ۓxG_{4uv(D({h9 .gT~B\eroڵkld (xxB.}yp"7y=r1?-gz:XrNo תt׻ BSt̥ }ž+>ᯮ Z]RϓOÛo9B/boEpHGFFF[````Rp*߬` X[mSG[ȉD[HGFFF[`XZAEM`*]@ៗ2B+:+qzP00W__ 3AI 0泙tf`RYEBkk r1;UFK /|uzυWa{prj_j++{Dym?p/J_'X_VD!鯩qZK`=I"Rd$u෹tX62՚KS;AأZbTPr? 63IENDB`plupload-2.1.8/js/jquery.ui.plupload/jquery.ui.plupload.js000066400000000000000000001142071255343340300236470ustar00rootroot00000000000000/** * jquery.ui.plupload.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing * * Depends: * jquery.ui.core.js * jquery.ui.widget.js * jquery.ui.button.js * jquery.ui.progressbar.js * * Optionally: * jquery.ui.sortable.js */ /* global jQuery:true */ /** jQuery UI based implementation of the Plupload API - multi-runtime file uploading API. To use the widget you must include _jQuery_ and _jQuery UI_ bundle (including `ui.core`, `ui.widget`, `ui.button`, `ui.progressbar` and `ui.sortable`). In general the widget is designed the way that you do not usually need to do anything to it after you instantiate it. But! You still can intervenue, to some extent, in case you need to. Although, due to the fact that widget is based on _jQuery UI_ widget factory, there are some specifics. See examples below for more details. @example

    Your browser doesn't have Flash, Silverlight or HTML5 support.

    @example // Invoking methods: $('#uploader').plupload(options); // Display welcome message in the notification area $('#uploader').plupload('notify', 'info', "This might be obvious, but you need to click 'Add Files' to add some files."); @example // Subscribing to the events... // ... on initialization: $('#uploader').plupload({ ... viewchanged: function(event, args) { // stuff ... } }); // ... or after initialization $('#uploader').on("viewchanged", function(event, args) { // stuff ... }); @class UI.Plupload @constructor @param {Object} settings For detailed information about each option check documentation. @param {String} settings.url URL of the server-side upload handler. @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled. @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. @param {Object} [settings.filters={}] Set of file type filters. @param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` @param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`. @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. @param {Number} [settings.filters.max_file_count=0] Limit the number of files that can reside in the queue at the same time (default is 0 - no limit). @param {String} [settings.flash_swf_url] URL of the Flash swf. @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. @param {Number|String} [settings.max_file_size] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`. @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. @param {Boolean} [settings.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. @param {Object} [settings.resize] Enable resizng of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}` @param {Number} [settings.resize.width] If image is bigger, it will be resized. @param {Number} [settings.resize.height] If image is bigger, it will be resized. @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. @param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. @param {Boolean} [settings.autostart=false] Whether to auto start uploading right after file selection. @param {Boolean} [settings.dragdrop=true] Enable ability to add file to the queue by drag'n'dropping them from the desktop. @param {Boolean} [settings.rename=false] Enable ability to rename files in the queue. @param {Boolean} [settings.sortable=false] Enable ability to sort files in the queue, changing their uploading priority. @param {Object} [settings.buttons] Control the visibility of functional buttons. @param {Boolean} [settings.buttons.browse=true] Display browse button. @param {Boolean} [settings.buttons.start=true] Display start button. @param {Boolean} [settings.buttons.stop=true] Display stop button. @param {Object} [settings.views] Control various views of the file queue. @param {Boolean} [settings.views.list=true] Enable list view. @param {Boolean} [settings.views.thumbs=false] Enable thumbs view. @param {String} [settings.views.default='list'] Default view. @param {Boolean} [settings.views.remember=true] Whether to remember the current view (requires jQuery Cookie plugin). @param {Boolean} [settings.multiple_queues=true] Re-activate the widget after each upload procedure. */ ;(function(window, document, plupload, o, $) { /** Dispatched when the widget is initialized and ready. @event ready @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Dispatched when file dialog is closed. @event selected @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of selected files represented by plupload.File objects */ /** Dispatched when file dialog is closed. @event removed @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of removed files represented by plupload.File objects */ /** Dispatched when upload is started. @event started @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Dispatched when upload is stopped. @event stopped @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Dispatched during the upload process. @event progress @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File that is being uploaded (includes loaded and percent properties among others). @param {Number} size Total file size in bytes. @param {Number} loaded Number of bytes uploaded of the files total size. @param {Number} percent Number of percentage uploaded of the file. */ /** Dispatched when file is uploaded. @event uploaded @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File that was uploaded. @param {Enum} status Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE. */ /** Dispatched when upload of the whole queue is complete. @event complete @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of uploaded files represented by plupload.File objects */ /** Dispatched when the view is changed, e.g. from `list` to `thumbs` or vice versa. @event viewchanged @param {plupload.Uploader} uploader Uploader instance sending the event. @param {String} type Current view type. */ /** Dispatched when error of some kind is detected. @event error @param {plupload.Uploader} uploader Uploader instance sending the event. @param {String} error Error message. @param {plupload.File} file File that was uploaded. @param {Enum} status Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE. */ var uploaders = {}; function _(str) { return plupload.translate(str) || str; } function renderUI(obj) { obj.id = obj.attr('id'); obj.html( '
    ' + '
    ' + '
    ' + '
    ' + '' + '
    ' + _("Select files") + '
    ' + '
    ' + _("Add files to the upload queue and click the start button.") + '
    ' + '
    ' + '' + '' + '
    ' + '
    ' + '
    ' + '' + '' + '' + '' + '' + '' + '' + '
    ' + _('Filename') + '' + _('Status') + '' + _('Size') + ' 
    ' + '
    ' + '
    ' + _("Drag files here.") + '
    ' + '
    ' + '
     
    ' + '
    ' + '' + '' + '' + '' + '' + '' + '' + '' + '
    ' + '' + '
    ' ); } $.widget("ui.plupload", { widgetEventPrefix: '', contents_bak: '', options: { browse_button_hover: 'ui-state-hover', browse_button_active: 'ui-state-active', filters: {}, // widget specific buttons: { browse: true, start: true, stop: true }, views: { list: true, thumbs: false, active: 'list', remember: true // requires: https://github.com/carhartl/jquery-cookie, otherwise disabled even if set to true }, thumb_width: 100, thumb_height: 60, multiple_queues: true, // re-use widget by default dragdrop : true, autostart: false, sortable: false, rename: false }, FILE_COUNT_ERROR: -9001, _create: function() { var id = this.element.attr('id'); if (!id) { id = plupload.guid(); this.element.attr('id', id); } this.id = id; // backup the elements initial state this.contents_bak = this.element.html(); renderUI(this.element); // container, just in case this.container = $('.plupload_container', this.element).attr('id', id + '_container'); this.content = $('.plupload_content', this.element); if ($.fn.resizable) { this.container.resizable({ handles: 's', minHeight: 300 }); } // list of files, may become sortable this.filelist = $('.plupload_filelist_content', this.container) .attr({ id: id + '_filelist', unselectable: 'on' }); // buttons this.browse_button = $('.plupload_add', this.container).attr('id', id + '_browse'); this.start_button = $('.plupload_start', this.container).attr('id', id + '_start'); this.stop_button = $('.plupload_stop', this.container).attr('id', id + '_stop'); this.thumbs_switcher = $('#' + id + '_view_thumbs'); this.list_switcher = $('#' + id + '_view_list'); if ($.ui.button) { this.browse_button.button({ icons: { primary: 'ui-icon-circle-plus' }, disabled: true }); this.start_button.button({ icons: { primary: 'ui-icon-circle-arrow-e' }, disabled: true }); this.stop_button.button({ icons: { primary: 'ui-icon-circle-close' } }); this.list_switcher.button({ text: false, icons: { secondary: "ui-icon-grip-dotted-horizontal" } }); this.thumbs_switcher.button({ text: false, icons: { secondary: "ui-icon-image" } }); } // progressbar this.progressbar = $('.plupload_progress_container', this.container); if ($.ui.progressbar) { this.progressbar.progressbar(); } // counter this.counter = $('.plupload_count', this.element) .attr({ id: id + '_count', name: id + '_count' }); // initialize uploader instance this._initUploader(); }, _initUploader: function() { var self = this , id = this.id , uploader , options = { container: id + '_buttons', browse_button: id + '_browse' } ; $('.plupload_buttons', this.element).attr('id', id + '_buttons'); if (self.options.dragdrop) { this.filelist.parent().attr('id', this.id + '_dropbox'); options.drop_element = this.id + '_dropbox'; } this.filelist.on('click', function(e) { if ($(e.target).hasClass('plupload_action_icon')) { self.removeFile($(e.target).closest('.plupload_file').attr('id')); e.preventDefault(); } }); uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend(this.options, options)); // retrieve full normalized set of options this.options = uploader.getOption(); if (self.options.views.thumbs) { uploader.settings.required_features.display_media = true; } // for backward compatibility if (self.options.max_file_count) { plupload.extend(uploader.getOption('filters'), { max_file_count: self.options.max_file_count }); } plupload.addFileFilter('max_file_count', function(maxCount, file, cb) { if (maxCount <= this.files.length - (this.total.uploaded + this.total.failed)) { self.browse_button.button('disable'); this.disableBrowse(); this.trigger('Error', { code : self.FILE_COUNT_ERROR, message : _("File count error."), file : file }); cb(false); } else { cb(true); } }); uploader.bind('Error', function(up, err) { var message, details = ""; message = '' + err.message + ''; switch (err.code) { case plupload.FILE_EXTENSION_ERROR: details = o.sprintf(_("File: %s"), err.file.name); break; case plupload.FILE_SIZE_ERROR: details = o.sprintf(_("File: %s, size: %d, max file size: %d"), err.file.name, plupload.formatSize(err.file.size), plupload.formatSize(plupload.parseSize(up.getOption('filters').max_file_size))); break; case plupload.FILE_DUPLICATE_ERROR: details = o.sprintf(_("%s already present in the queue."), err.file.name); break; case self.FILE_COUNT_ERROR: details = o.sprintf(_("Upload element accepts only %d file(s) at a time. Extra files were stripped."), up.getOption('filters').max_file_count || 0); break; case plupload.IMAGE_FORMAT_ERROR : details = _("Image format either wrong or not supported."); break; case plupload.IMAGE_MEMORY_ERROR : details = _("Runtime ran out of available memory."); break; /* // This needs a review case plupload.IMAGE_DIMENSIONS_ERROR : details = o.sprintf(_('Resoultion out of boundaries! %s runtime supports images only up to %wx%hpx.'), up.runtime, up.features.maxWidth, up.features.maxHeight); break; */ case plupload.HTTP_ERROR: details = _("Upload URL might be wrong or doesn't exist."); break; } message += "
    " + details + ""; self._trigger('error', null, { up: up, error: err } ); // do not show UI if no runtime can be initialized if (err.code === plupload.INIT_ERROR) { setTimeout(function() { self.destroy(); }, 1); } else { self.notify('error', message); } }); uploader.bind('PostInit', function(up) { // all buttons are optional, so they can be disabled and hidden if (!self.options.buttons.browse) { self.browse_button.button('disable').hide(); up.disableBrowse(true); } else { self.browse_button.button('enable'); } if (!self.options.buttons.start) { self.start_button.button('disable').hide(); } if (!self.options.buttons.stop) { self.stop_button.button('disable').hide(); } if (!self.options.unique_names && self.options.rename) { self._enableRenaming(); } if (self.options.dragdrop && up.features.dragdrop) { self.filelist.parent().addClass('plupload_dropbox'); } self._enableViewSwitcher(); self.start_button.click(function(e) { if (!$(this).button('option', 'disabled')) { self.start(); } e.preventDefault(); }); self.stop_button.click(function(e) { self.stop(); e.preventDefault(); }); self._trigger('ready', null, { up: up }); }); // uploader internal events must run first uploader.init(); uploader.bind('FileFiltered', function(up, file) { self._addFiles(file); }); uploader.bind('FilesAdded', function(up, files) { self._trigger('selected', null, { up: up, files: files } ); // re-enable sortable if (self.options.sortable && $.ui.sortable) { self._enableSortingList(); } self._trigger('updatelist', null, { filelist: self.filelist }); if (self.options.autostart) { // set a little delay to make sure that QueueChanged triggered by the core has time to complete setTimeout(function() { self.start(); }, 10); } }); uploader.bind('FilesRemoved', function(up, files) { // destroy sortable if enabled if ($.ui.sortable && self.options.sortable) { $('tbody', self.filelist).sortable('destroy'); } $.each(files, function(i, file) { $('#' + file.id).toggle("highlight", function() { $(this).remove(); }); }); if (up.files.length) { // re-initialize sortable if (self.options.sortable && $.ui.sortable) { self._enableSortingList(); } } self._trigger('updatelist', null, { filelist: self.filelist }); self._trigger('removed', null, { up: up, files: files } ); }); uploader.bind('QueueChanged', function() { self._handleState(); }); uploader.bind('StateChanged', function(up) { self._handleState(); if (plupload.STARTED === up.state) { self._trigger('started', null, { up: this.uploader }); } else if (plupload.STOPPED === up.state) { self._trigger('stopped', null, { up: this.uploader }); } }); uploader.bind('UploadFile', function(up, file) { self._handleFileStatus(file); }); uploader.bind('FileUploaded', function(up, file, result) { self._handleFileStatus(file); self._trigger('uploaded', null, { up: up, file: file, result: result } ); }); uploader.bind('UploadProgress', function(up, file) { self._handleFileStatus(file); self._updateTotalProgress(); self._trigger('progress', null, { up: up, file: file } ); }); uploader.bind('UploadComplete', function(up, files) { self._addFormFields(); self._trigger('complete', null, { up: up, files: files } ); }); }, _setOption: function(key, value) { var self = this; if (key == 'buttons' && typeof(value) == 'object') { value = $.extend(self.options.buttons, value); if (!value.browse) { self.browse_button.button('disable').hide(); self.uploader.disableBrowse(true); } else { self.browse_button.button('enable').show(); self.uploader.disableBrowse(false); } if (!value.start) { self.start_button.button('disable').hide(); } else { self.start_button.button('enable').show(); } if (!value.stop) { self.stop_button.button('disable').hide(); } else { self.start_button.button('enable').show(); } } self.uploader.setOption(key, value); }, /** Start upload. Triggers `start` event. @method start */ start: function() { this.uploader.start(); }, /** Stop upload. Triggers `stop` event. @method stop */ stop: function() { this.uploader.stop(); }, /** Enable browse button. @method enable */ enable: function() { this.browse_button.button('enable'); this.uploader.disableBrowse(false); }, /** Disable browse button. @method disable */ disable: function() { this.browse_button.button('disable'); this.uploader.disableBrowse(true); }, /** Retrieve file by its unique id. @method getFile @param {String} id Unique id of the file @return {plupload.File} */ getFile: function(id) { var file; if (typeof id === 'number') { file = this.uploader.files[id]; } else { file = this.uploader.getFile(id); } return file; }, /** Return array of files currently in the queue. @method getFiles @return {Array} Array of files in the queue represented by plupload.File objects */ getFiles: function() { return this.uploader.files; }, /** Remove the file from the queue. @method removeFile @param {plupload.File|String} file File to remove, might be specified directly or by its unique id */ removeFile: function(file) { if (plupload.typeOf(file) === 'string') { file = this.getFile(file); } this.uploader.removeFile(file); }, /** Clear the file queue. @method clearQueue */ clearQueue: function() { this.uploader.splice(); }, /** Retrieve internal plupload.Uploader object (usually not required). @method getUploader @return {plupload.Uploader} */ getUploader: function() { return this.uploader; }, /** Trigger refresh procedure, specifically browse_button re-measure and re-position operations. Might get handy, when UI Widget is placed within the popup, that is constantly hidden and shown again - without calling this method after each show operation, dialog trigger might get displaced and disfunctional. @method refresh */ refresh: function() { this.uploader.refresh(); }, /** Display a message in notification area. @method notify @param {Enum} type Type of the message, either `error` or `info` @param {String} message The text message to display. */ notify: function(type, message) { var popup = $( '
    ' + '' + '

    ' + message + '

    ' + '
    ' ); popup .addClass('ui-state-' + (type === 'error' ? 'error' : 'highlight')) .find('p .ui-icon') .addClass('ui-icon-' + (type === 'error' ? 'alert' : 'info')) .end() .find('.plupload_message_close') .click(function() { popup.remove(); }) .end(); $('.plupload_header', this.container).append(popup); }, /** Destroy the widget, the uploader, free associated resources and bring back original html. @method destroy */ destroy: function() { // destroy uploader instance this.uploader.destroy(); // unbind all button events $('.plupload_button', this.element).unbind(); // destroy buttons if ($.ui.button) { $('.plupload_add, .plupload_start, .plupload_stop', this.container) .button('destroy'); } // destroy progressbar if ($.ui.progressbar) { this.progressbar.progressbar('destroy'); } // destroy sortable behavior if ($.ui.sortable && this.options.sortable) { $('tbody', this.filelist).sortable('destroy'); } // restore the elements initial state this.element .empty() .html(this.contents_bak); this.contents_bak = ''; $.Widget.prototype.destroy.apply(this); }, _handleState: function() { var up = this.uploader , filesPending = up.files.length - (up.total.uploaded + up.total.failed) , maxCount = up.getOption('filters').max_file_count || 0 ; if (plupload.STARTED === up.state) { $([]) .add(this.stop_button) .add('.plupload_started') .removeClass('plupload_hidden'); this.start_button.button('disable'); if (!this.options.multiple_queues) { this.browse_button.button('disable'); up.disableBrowse(); } $('.plupload_upload_status', this.element).html(o.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); $('.plupload_header_content', this.element).addClass('plupload_header_content_bw'); } else if (plupload.STOPPED === up.state) { $([]) .add(this.stop_button) .add('.plupload_started') .addClass('plupload_hidden'); if (filesPending) { this.start_button.button('enable'); } else { this.start_button.button('disable'); } if (this.options.multiple_queues) { $('.plupload_header_content', this.element).removeClass('plupload_header_content_bw'); } // if max_file_count defined, only that many files can be queued at once if (this.options.multiple_queues && maxCount && maxCount > filesPending) { this.browse_button.button('enable'); up.disableBrowse(false); } this._updateTotalProgress(); } if (up.total.queued === 0) { $('.ui-button-text', this.browse_button).html(_('Add Files')); } else { $('.ui-button-text', this.browse_button).html(o.sprintf(_('%d files queued'), up.total.queued)); } up.refresh(); }, _handleFileStatus: function(file) { var $file = $('#' + file.id), actionClass, iconClass; // since this method might be called asynchronously, file row might not yet be rendered if (!$file.length) { return; } switch (file.status) { case plupload.DONE: actionClass = 'plupload_done'; iconClass = 'plupload_action_icon ui-icon ui-icon-circle-check'; break; case plupload.FAILED: actionClass = 'ui-state-error plupload_failed'; iconClass = 'plupload_action_icon ui-icon ui-icon-alert'; break; case plupload.QUEUED: actionClass = 'plupload_delete'; iconClass = 'plupload_action_icon ui-icon ui-icon-circle-minus'; break; case plupload.UPLOADING: actionClass = 'ui-state-highlight plupload_uploading'; iconClass = 'plupload_action_icon ui-icon ui-icon-circle-arrow-w'; // scroll uploading file into the view if its bottom boundary is out of it var scroller = $('.plupload_scroll', this.container) , scrollTop = scroller.scrollTop() , scrollerHeight = scroller.height() , rowOffset = $file.position().top + $file.height() ; if (scrollerHeight < rowOffset) { scroller.scrollTop(scrollTop + rowOffset - scrollerHeight); } // Set file specific progress $file .find('.plupload_file_percent') .html(file.percent + '%') .end() .find('.plupload_file_progress') .css('width', file.percent + '%') .end() .find('.plupload_file_size') .html(plupload.formatSize(file.size)); break; } actionClass += ' ui-state-default plupload_file'; $file .attr('class', actionClass) .find('.plupload_action_icon') .attr('class', iconClass); }, _updateTotalProgress: function() { var up = this.uploader; // Scroll to end of file list this.filelist[0].scrollTop = this.filelist[0].scrollHeight; this.progressbar.progressbar('value', up.total.percent); this.element .find('.plupload_total_status') .html(up.total.percent + '%') .end() .find('.plupload_total_file_size') .html(plupload.formatSize(up.total.size)) .end() .find('.plupload_upload_status') .html(o.sprintf(_('Uploaded %d/%d files'), up.total.uploaded, up.files.length)); }, _displayThumbs: function() { var self = this , tw, th // thumb width/height , cols , num = 0 // number of simultaneously visible thumbs , thumbs = [] // array of thumbs to preload at any given moment , loading = false ; if (!this.options.views.thumbs) { return; } function onLast(el, eventName, cb) { var timer; el.on(eventName, function() { clearTimeout(timer); timer = setTimeout(function() { clearTimeout(timer); cb(); }, 300); }); } // calculate number of simultaneously visible thumbs function measure() { if (!tw || !th) { var wrapper = $('.plupload_file:eq(0)', self.filelist); tw = wrapper.outerWidth(true); th = wrapper.outerHeight(true); } var aw = self.content.width(), ah = self.content.height(); cols = Math.floor(aw / tw); num = cols * (Math.ceil(ah / th) + 1); } function pickThumbsToLoad() { // calculate index of virst visible thumb var startIdx = Math.floor(self.content.scrollTop() / th) * cols; // get potentially visible thumbs that are not yet visible thumbs = $('.plupload_file .plupload_file_thumb', self.filelist) .slice(startIdx, startIdx + num) .filter('.plupload_thumb_toload') .get(); } function init() { function mpl() { // measure, pick, load if (self.view_mode !== 'thumbs') { return; } measure(); pickThumbsToLoad(); lazyLoad(); } if ($.fn.resizable) { onLast(self.container, 'resize', mpl); } onLast(self.window, 'resize', mpl); onLast(self.content, 'scroll', mpl); self.element.on('viewchanged selected', mpl); mpl(); } function preloadThumb(file, cb) { var img = new o.Image(); img.onload = function() { var thumb = $('#' + file.id + ' .plupload_file_thumb', self.filelist); this.embed(thumb[0], { width: self.options.thumb_width, height: self.options.thumb_height, crop: true, preserveHeaders: false, swf_url: o.resolveUrl(self.options.flash_swf_url), xap_url: o.resolveUrl(self.options.silverlight_xap_url) }); }; img.bind("embedded error", function(e) { $('#' + file.id, self.filelist) .find('.plupload_file_thumb') .removeClass('plupload_thumb_loading') .addClass('plupload_thumb_' + e.type) ; this.destroy(); setTimeout(cb, 1); // detach, otherwise ui might hang (in SilverLight for example) }); $('#' + file.id, self.filelist) .find('.plupload_file_thumb') .removeClass('plupload_thumb_toload') .addClass('plupload_thumb_loading') ; img.load(file.getSource()); } function lazyLoad() { if (self.view_mode !== 'thumbs' || loading) { return; } pickThumbsToLoad(); if (!thumbs.length) { return; } loading = true; preloadThumb(self.getFile($(thumbs.shift()).closest('.plupload_file').attr('id')), function() { loading = false; lazyLoad(); }); } // this has to run only once to measure structures and bind listeners this.element.on('selected', function onselected() { self.element.off('selected', onselected); init(); }); }, _addFiles: function(files) { var self = this, file_html, html = ''; file_html = '
  • ' + '
    ' + '
    {ext}
    ' + '
    ' + '
    ' + '
    ' + '{percent} ' + '
    ' + '
    ' + '{name} ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    {size}
    ' + '
    ' + '
  • '; if (plupload.typeOf(files) !== 'array') { files = [files]; } $.each(files, function(i, file) { var ext = o.Mime.getFileExtension(file.name) || 'none'; html += file_html.replace(/\{(\w+)\}/g, function($0, $1) { switch ($1) { case 'thumb_width': case 'thumb_height': return self.options[$1]; case 'size': return plupload.formatSize(file.size); case 'ext': return ext; default: return file[$1] || ''; } }); }); self.filelist.append(html); }, _addFormFields: function() { var self = this; // re-add from fresh $('.plupload_file_fields', this.filelist).html(''); plupload.each(this.uploader.files, function(file, count) { var fields = '' , id = self.id + '_' + count ; if (file.target_name) { fields += ''; } fields += ''; fields += ''; $('#' + file.id).find('.plupload_file_fields').html(fields); }); this.counter.val(this.uploader.files.length); }, _viewChanged: function(view) { // update or write a new cookie if (this.options.views.remember && $.cookie) { $.cookie('plupload_ui_view', view, { expires: 7, path: '/' }); } // ugly fix for IE6 - make content area stretchable if (o.Env.browser === 'IE' && o.Env.version < 7) { this.content.attr('style', 'height:expression(document.getElementById("' + this.id + '_container' + '").clientHeight - ' + (view === 'list' ? 132 : 102) + ')'); } this.container.removeClass('plupload_view_list plupload_view_thumbs').addClass('plupload_view_' + view); this.view_mode = view; this._trigger('viewchanged', null, { view: view }); }, _enableViewSwitcher: function() { var self = this , view , switcher = $('.plupload_view_switch', this.container) , buttons , button ; plupload.each(['list', 'thumbs'], function(view) { if (!self.options.views[view]) { switcher.find('[for="' + self.id + '_view_' + view + '"], #'+ self.id +'_view_' + view).remove(); } }); // check if any visible left buttons = switcher.find('.plupload_button'); if (buttons.length === 1) { switcher.hide(); view = buttons.eq(0).data('view'); this._viewChanged(view); } else if ($.ui.button && buttons.length > 1) { if (this.options.views.remember && $.cookie) { view = $.cookie('plupload_ui_view'); } // if wierd case, bail out to default if (!~plupload.inArray(view, ['list', 'thumbs'])) { view = this.options.views.active; } switcher .show() .buttonset() .find('.ui-button') .click(function(e) { view = $(this).data('view'); self._viewChanged(view); e.preventDefault(); // avoid auto scrolling to widget in IE and FF (see #850) }); // if view not active - happens when switcher wasn't clicked manually button = switcher.find('[for="' + self.id + '_view_'+view+'"]'); if (button.length) { button.trigger('click'); } } else { switcher.show(); this._viewChanged(this.options.views.active); } // initialize thumb viewer if requested if (this.options.views.thumbs) { this._displayThumbs(); } }, _enableRenaming: function() { var self = this; this.filelist.dblclick(function(e) { var nameSpan = $(e.target), nameInput, file, parts, name, ext = ""; if (!nameSpan.hasClass('plupload_file_name_wrapper')) { return; } // Get file name and split out name and extension file = self.uploader.getFile(nameSpan.closest('.plupload_file')[0].id); name = file.name; parts = /^(.+)(\.[^.]+)$/.exec(name); if (parts) { name = parts[1]; ext = parts[2]; } // Display input element nameInput = $('').width(nameSpan.width()).insertAfter(nameSpan.hide()); nameInput.val(name).blur(function() { nameSpan.show().parent().scrollLeft(0).end().next().remove(); }).keydown(function(e) { var nameInput = $(this); if ($.inArray(e.keyCode, [13, 27]) !== -1) { e.preventDefault(); // Rename file and glue extension back on if (e.keyCode === 13) { file.name = nameInput.val() + ext; nameSpan.html(file.name); } nameInput.blur(); } })[0].focus(); }); }, _enableSortingList: function() { var self = this; if ($('.plupload_file', this.filelist).length < 2) { return; } // destroy sortable if enabled $('tbody', this.filelist).sortable('destroy'); // enable this.filelist.sortable({ items: '.plupload_delete', cancel: 'object, .plupload_clearer', stop: function() { var files = []; $.each($(this).sortable('toArray'), function(i, id) { files[files.length] = self.uploader.getFile(id); }); files.unshift(files.length); files.unshift(0); // re-populate files array Array.prototype.splice.apply(self.uploader.files, files); } }); } }); } (window, document, plupload, mOxie, jQuery)); plupload-2.1.8/js/plupload.dev.js000066400000000000000000001643541255343340300167300ustar00rootroot00000000000000/** * Plupload - multi-runtime File Uploader * v2.1.8 * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing * * Date: 2015-07-21 */ /** * Plupload.js * * Copyright 2013, Moxiecode Systems AB * Released under GPL License. * * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ /*global mOxie:true */ ;(function(window, o, undef) { var delay = window.setTimeout , fileFilters = {} ; // convert plupload features to caps acceptable by mOxie function normalizeCaps(settings) { var features = settings.required_features, caps = {}; function resolve(feature, value, strict) { // Feature notation is deprecated, use caps (this thing here is required for backward compatibility) var map = { chunks: 'slice_blob', jpgresize: 'send_binary_string', pngresize: 'send_binary_string', progress: 'report_upload_progress', multi_selection: 'select_multiple', dragdrop: 'drag_and_drop', drop_element: 'drag_and_drop', headers: 'send_custom_headers', urlstream_upload: 'send_binary_string', canSendBinary: 'send_binary', triggerDialog: 'summon_file_dialog' }; if (map[feature]) { caps[map[feature]] = value; } else if (!strict) { caps[feature] = value; } } if (typeof(features) === 'string') { plupload.each(features.split(/\s*,\s*/), function(feature) { resolve(feature, true); }); } else if (typeof(features) === 'object') { plupload.each(features, function(value, feature) { resolve(feature, value); }); } else if (features === true) { // check settings for required features if (settings.chunk_size > 0) { caps.slice_blob = true; } if (settings.resize.enabled || !settings.multipart) { caps.send_binary_string = true; } plupload.each(settings, function(value, feature) { resolve(feature, !!value, true); // strict check }); } return caps; } /** * @module plupload * @static */ var plupload = { /** * Plupload version will be replaced on build. * * @property VERSION * @for Plupload * @static * @final */ VERSION : '2.1.8', /** * The state of the queue before it has started and after it has finished * * @property STOPPED * @static * @final */ STOPPED : 1, /** * Upload process is running * * @property STARTED * @static * @final */ STARTED : 2, /** * File is queued for upload * * @property QUEUED * @static * @final */ QUEUED : 1, /** * File is being uploaded * * @property UPLOADING * @static * @final */ UPLOADING : 2, /** * File has failed to be uploaded * * @property FAILED * @static * @final */ FAILED : 4, /** * File has been uploaded successfully * * @property DONE * @static * @final */ DONE : 5, // Error constants used by the Error event /** * Generic error for example if an exception is thrown inside Silverlight. * * @property GENERIC_ERROR * @static * @final */ GENERIC_ERROR : -100, /** * HTTP transport error. For example if the server produces a HTTP status other than 200. * * @property HTTP_ERROR * @static * @final */ HTTP_ERROR : -200, /** * Generic I/O error. For example if it wasn't possible to open the file stream on local machine. * * @property IO_ERROR * @static * @final */ IO_ERROR : -300, /** * @property SECURITY_ERROR * @static * @final */ SECURITY_ERROR : -400, /** * Initialization error. Will be triggered if no runtime was initialized. * * @property INIT_ERROR * @static * @final */ INIT_ERROR : -500, /** * File size error. If the user selects a file that is too large it will be blocked and an error of this type will be triggered. * * @property FILE_SIZE_ERROR * @static * @final */ FILE_SIZE_ERROR : -600, /** * File extension error. If the user selects a file that isn't valid according to the filters setting. * * @property FILE_EXTENSION_ERROR * @static * @final */ FILE_EXTENSION_ERROR : -601, /** * Duplicate file error. If prevent_duplicates is set to true and user selects the same file again. * * @property FILE_DUPLICATE_ERROR * @static * @final */ FILE_DUPLICATE_ERROR : -602, /** * Runtime will try to detect if image is proper one. Otherwise will throw this error. * * @property IMAGE_FORMAT_ERROR * @static * @final */ IMAGE_FORMAT_ERROR : -700, /** * While working on files runtime may run out of memory and will throw this error. * * @since 2.1.2 * @property MEMORY_ERROR * @static * @final */ MEMORY_ERROR : -701, /** * Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error. * * @property IMAGE_DIMENSIONS_ERROR * @static * @final */ IMAGE_DIMENSIONS_ERROR : -702, /** * Mime type lookup table. * * @property mimeTypes * @type Object * @final */ mimeTypes : o.mimes, /** * In some cases sniffing is the only way around :( */ ua: o.ua, /** * Gets the true type of the built-in object (better version of typeof). * @credits Angus Croll (http://javascriptweblog.wordpress.com/) * * @method typeOf * @static * @param {Object} o Object to check. * @return {String} Object [[Class]] */ typeOf: o.typeOf, /** * Extends the specified object with another object. * * @method extend * @static * @param {Object} target Object to extend. * @param {Object..} obj Multiple objects to extend with. * @return {Object} Same as target, the extended object. */ extend : o.extend, /** * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers. * The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manages * to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique. * It's more probable for the earth to be hit with an asteriod. You can also if you want to be 100% sure set the plupload.guidPrefix property * to an user unique key. * * @method guid * @static * @return {String} Virtually unique id. */ guid : o.guid, /** * Get array of DOM Elements by their ids. * * @method get * @for Utils * @param {String} id Identifier of the DOM Element * @return {Array} */ get : function get(ids) { var els = [], el; if (o.typeOf(ids) !== 'array') { ids = [ids]; } var i = ids.length; while (i--) { el = o.get(ids[i]); if (el) { els.push(el); } } return els.length ? els : null; }, /** * Executes the callback function for each item in array/object. If you return false in the * callback it will break the loop. * * @method each * @static * @param {Object} obj Object to iterate. * @param {function} callback Callback function to execute for each item. */ each : o.each, /** * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields. * * @method getPos * @static * @param {Element} node HTML element or element id to get x, y position from. * @param {Element} root Optional root element to stop calculations at. * @return {object} Absolute position of the specified element object with x, y fields. */ getPos : o.getPos, /** * Returns the size of the specified node in pixels. * * @method getSize * @static * @param {Node} node Node to get the size of. * @return {Object} Object with a w and h property. */ getSize : o.getSize, /** * Encodes the specified string. * * @method xmlEncode * @static * @param {String} s String to encode. * @return {String} Encoded string. */ xmlEncode : function(str) { var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g; return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) { return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr; }) : str; }, /** * Forces anything into an array. * * @method toArray * @static * @param {Object} obj Object with length field. * @return {Array} Array object containing all items. */ toArray : o.toArray, /** * Find an element in array and return its index if present, otherwise return -1. * * @method inArray * @static * @param {mixed} needle Element to find * @param {Array} array * @return {Int} Index of the element, or -1 if not found */ inArray : o.inArray, /** * Extends the language pack object with new items. * * @method addI18n * @static * @param {Object} pack Language pack items to add. * @return {Object} Extended language pack object. */ addI18n : o.addI18n, /** * Translates the specified string by checking for the english string in the language pack lookup. * * @method translate * @static * @param {String} str String to look for. * @return {String} Translated string or the input string if it wasn't found. */ translate : o.translate, /** * Checks if object is empty. * * @method isEmptyObj * @static * @param {Object} obj Object to check. * @return {Boolean} */ isEmptyObj : o.isEmptyObj, /** * Checks if specified DOM element has specified class. * * @method hasClass * @static * @param {Object} obj DOM element like object to add handler to. * @param {String} name Class name */ hasClass : o.hasClass, /** * Adds specified className to specified DOM element. * * @method addClass * @static * @param {Object} obj DOM element like object to add handler to. * @param {String} name Class name */ addClass : o.addClass, /** * Removes specified className from specified DOM element. * * @method removeClass * @static * @param {Object} obj DOM element like object to add handler to. * @param {String} name Class name */ removeClass : o.removeClass, /** * Returns a given computed style of a DOM element. * * @method getStyle * @static * @param {Object} obj DOM element like object. * @param {String} name Style you want to get from the DOM element */ getStyle : o.getStyle, /** * Adds an event handler to the specified object and store reference to the handler * in objects internal Plupload registry (@see removeEvent). * * @method addEvent * @static * @param {Object} obj DOM element like object to add handler to. * @param {String} name Name to add event listener to. * @param {Function} callback Function to call when event occurs. * @param {String} (optional) key that might be used to add specifity to the event record. */ addEvent : o.addEvent, /** * Remove event handler from the specified object. If third argument (callback) * is not specified remove all events with the specified name. * * @method removeEvent * @static * @param {Object} obj DOM element to remove event listener(s) from. * @param {String} name Name of event listener to remove. * @param {Function|String} (optional) might be a callback or unique key to match. */ removeEvent: o.removeEvent, /** * Remove all kind of events from the specified object * * @method removeAllEvents * @static * @param {Object} obj DOM element to remove event listeners from. * @param {String} (optional) unique key to match, when removing events. */ removeAllEvents: o.removeAllEvents, /** * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _. * * @method cleanName * @static * @param {String} s String to clean up. * @return {String} Cleaned string. */ cleanName : function(name) { var i, lookup; // Replace diacritics lookup = [ /[\300-\306]/g, 'A', /[\340-\346]/g, 'a', /\307/g, 'C', /\347/g, 'c', /[\310-\313]/g, 'E', /[\350-\353]/g, 'e', /[\314-\317]/g, 'I', /[\354-\357]/g, 'i', /\321/g, 'N', /\361/g, 'n', /[\322-\330]/g, 'O', /[\362-\370]/g, 'o', /[\331-\334]/g, 'U', /[\371-\374]/g, 'u' ]; for (i = 0; i < lookup.length; i += 2) { name = name.replace(lookup[i], lookup[i + 1]); } // Replace whitespace name = name.replace(/\s+/g, '_'); // Remove anything else name = name.replace(/[^a-z0-9_\-\.]+/gi, ''); return name; }, /** * Builds a full url out of a base URL and an object with items to append as query string items. * * @method buildUrl * @static * @param {String} url Base URL to append query string items to. * @param {Object} items Name/value object to serialize as a querystring. * @return {String} String with url + serialized query string items. */ buildUrl : function(url, items) { var query = ''; plupload.each(items, function(value, name) { query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value); }); if (query) { url += (url.indexOf('?') > 0 ? '&' : '?') + query; } return url; }, /** * Formats the specified number as a size string for example 1024 becomes 1 KB. * * @method formatSize * @static * @param {Number} size Size to format as string. * @return {String} Formatted size string. */ formatSize : function(size) { if (size === undef || /\D/.test(size)) { return plupload.translate('N/A'); } function round(num, precision) { return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision); } var boundary = Math.pow(1024, 4); // TB if (size > boundary) { return round(size / boundary, 1) + " " + plupload.translate('tb'); } // GB if (size > (boundary/=1024)) { return round(size / boundary, 1) + " " + plupload.translate('gb'); } // MB if (size > (boundary/=1024)) { return round(size / boundary, 1) + " " + plupload.translate('mb'); } // KB if (size > 1024) { return Math.round(size / 1024) + " " + plupload.translate('kb'); } return size + " " + plupload.translate('b'); }, /** * Parses the specified size string into a byte value. For example 10kb becomes 10240. * * @method parseSize * @static * @param {String|Number} size String to parse or number to just pass through. * @return {Number} Size in bytes. */ parseSize : o.parseSizeStr, /** * A way to predict what runtime will be choosen in the current environment with the * specified settings. * * @method predictRuntime * @static * @param {Object|String} config Plupload settings to check * @param {String} [runtimes] Comma-separated list of runtimes to check against * @return {String} Type of compatible runtime */ predictRuntime : function(config, runtimes) { var up, runtime; up = new plupload.Uploader(config); runtime = o.Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes); up.destroy(); return runtime; }, /** * Registers a filter that will be executed for each file added to the queue. * If callback returns false, file will not be added. * * Callback receives two arguments: a value for the filter as it was specified in settings.filters * and a file to be filtered. Callback is executed in the context of uploader instance. * * @method addFileFilter * @static * @param {String} name Name of the filter by which it can be referenced in settings.filters * @param {String} cb Callback - the actual routine that every added file must pass */ addFileFilter: function(name, cb) { fileFilters[name] = cb; } }; plupload.addFileFilter('mime_types', function(filters, file, cb) { if (filters.length && !filters.regexp.test(file.name)) { this.trigger('Error', { code : plupload.FILE_EXTENSION_ERROR, message : plupload.translate('File extension error.'), file : file }); cb(false); } else { cb(true); } }); plupload.addFileFilter('max_file_size', function(maxSize, file, cb) { var undef; maxSize = plupload.parseSize(maxSize); // Invalid file size if (file.size !== undef && maxSize && file.size > maxSize) { this.trigger('Error', { code : plupload.FILE_SIZE_ERROR, message : plupload.translate('File size error.'), file : file }); cb(false); } else { cb(true); } }); plupload.addFileFilter('prevent_duplicates', function(value, file, cb) { if (value) { var ii = this.files.length; while (ii--) { // Compare by name and size (size might be 0 or undefined, but still equivalent for both) if (file.name === this.files[ii].name && file.size === this.files[ii].size) { this.trigger('Error', { code : plupload.FILE_DUPLICATE_ERROR, message : plupload.translate('Duplicate file error.'), file : file }); cb(false); return; } } } cb(true); }); /** @class Uploader @constructor @param {Object} settings For detailed information about each option check documentation. @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger. @param {String} settings.url URL of the server-side upload handler. @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled. @param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes. @param {String|DOMElement} [settings.container] id of the DOM element or DOM element itself that will be used to wrap uploader structures. Defaults to immediate parent of the `browse_button` element. @param {String|DOMElement} [settings.drop_element] id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop. @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. @param {Object} [settings.filters={}] Set of file type filters. @param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` @param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`. @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. @param {String} [settings.flash_swf_url] URL of the Flash swf. @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. @param {Boolean} [settings.multi_selection=true] Enable ability to select multiple files at once in file dialog. @param {String|Object} [settings.required_features] Either comma-separated list or hash of required features that chosen runtime should absolutely possess. @param {Object} [settings.resize] Enable resizng of images on client-side. Applies to `image/jpeg` and `image/png` only. `e.g. {width : 200, height : 200, quality : 90, crop: true}` @param {Number} [settings.resize.width] If image is bigger, it will be resized. @param {Number} [settings.resize.height] If image is bigger, it will be resized. @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. @param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. @param {Boolean} [settings.send_file_name=true] Whether to send file name as additional argument - 'name' (required for chunked uploads and some other cases where file name cannot be sent via normal ways). */ plupload.Uploader = function(options) { /** Fires when the current RunTime has been initialized. @event Init @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires after the init event incase you need to perform actions there. @event PostInit @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires when the option is changed in via uploader.setOption(). @event OptionChanged @since 2.1 @param {plupload.Uploader} uploader Uploader instance sending the event. @param {String} name Name of the option that was changed @param {Mixed} value New value for the specified option @param {Mixed} oldValue Previous value of the option */ /** Fires when the silverlight/flash or other shim needs to move. @event Refresh @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires when the overall state is being changed for the upload queue. @event StateChanged @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires when browse_button is clicked and browse dialog shows. @event Browse @since 2.1.2 @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires for every filtered file before it is added to the queue. @event FileFiltered @since 2.1 @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file Another file that has to be added to the queue. */ /** Fires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance. @event QueueChanged @param {plupload.Uploader} uploader Uploader instance sending the event. */ /** Fires after files were filtered and added to the queue. @event FilesAdded @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of file objects that were added to queue by the user. */ /** Fires when file is removed from the queue. @event FilesRemoved @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of files that got removed. */ /** Fires just before a file is uploaded. Can be used to cancel the upload for the specified file by returning false from the handler. @event BeforeUpload @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File to be uploaded. */ /** Fires when a file is to be uploaded by the runtime. @event UploadFile @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File to be uploaded. */ /** Fires while a file is being uploaded. Use this event to update the current file upload progress. @event UploadProgress @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File that is currently being uploaded. */ /** Fires when file chunk is uploaded. @event ChunkUploaded @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File that the chunk was uploaded for. @param {Object} result Object with response properties. @param {Number} result.offset The amount of bytes the server has received so far, including this chunk. @param {Number} result.total The size of the file. @param {String} result.response The response body sent by the server. @param {Number} result.status The HTTP status code sent by the server. @param {String} result.responseHeaders All the response headers as a single string. */ /** Fires when a file is successfully uploaded. @event FileUploaded @param {plupload.Uploader} uploader Uploader instance sending the event. @param {plupload.File} file File that was uploaded. @param {Object} result Object with response properties. @param {String} result.response The response body sent by the server. @param {Number} result.status The HTTP status code sent by the server. @param {String} result.responseHeaders All the response headers as a single string. */ /** Fires when all files in a queue are uploaded. @event UploadComplete @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Array} files Array of file objects that was added to queue/selected by the user. */ /** Fires when a error occurs. @event Error @param {plupload.Uploader} uploader Uploader instance sending the event. @param {Object} error Contains code, message and sometimes file and other details. @param {Number} error.code The plupload error code. @param {String} error.message Description of the error (uses i18n). */ /** Fires when destroy method is called. @event Destroy @param {plupload.Uploader} uploader Uploader instance sending the event. */ var uid = plupload.guid() , settings , files = [] , preferred_caps = {} , fileInputs = [] , fileDrops = [] , startTime , total , disabled = false , xhr ; // Private methods function uploadNext() { var file, count = 0, i; if (this.state == plupload.STARTED) { // Find first QUEUED file for (i = 0; i < files.length; i++) { if (!file && files[i].status == plupload.QUEUED) { file = files[i]; if (this.trigger("BeforeUpload", file)) { file.status = plupload.UPLOADING; this.trigger("UploadFile", file); } } else { count++; } } // All files are DONE or FAILED if (count == files.length) { if (this.state !== plupload.STOPPED) { this.state = plupload.STOPPED; this.trigger("StateChanged"); } this.trigger("UploadComplete", files); } } } function calcFile(file) { file.percent = file.size > 0 ? Math.ceil(file.loaded / file.size * 100) : 100; calc(); } function calc() { var i, file; // Reset stats total.reset(); // Check status, size, loaded etc on all files for (i = 0; i < files.length; i++) { file = files[i]; if (file.size !== undef) { // We calculate totals based on original file size total.size += file.origSize; // Since we cannot predict file size after resize, we do opposite and // interpolate loaded amount to match magnitude of total total.loaded += file.loaded * file.origSize / file.size; } else { total.size = undef; } if (file.status == plupload.DONE) { total.uploaded++; } else if (file.status == plupload.FAILED) { total.failed++; } else { total.queued++; } } // If we couldn't calculate a total file size then use the number of files to calc percent if (total.size === undef) { total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0; } else { total.bytesPerSec = Math.ceil(total.loaded / ((+new Date() - startTime || 1) / 1000.0)); total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0; } } function getRUID() { var ctrl = fileInputs[0] || fileDrops[0]; if (ctrl) { return ctrl.getRuntime().uid; } return false; } function runtimeCan(file, cap) { if (file.ruid) { var info = o.Runtime.getInfo(file.ruid); if (info) { return info.can(cap); } } return false; } function bindEventListeners() { this.bind('FilesAdded FilesRemoved', function(up) { up.trigger('QueueChanged'); up.refresh(); }); this.bind('CancelUpload', onCancelUpload); this.bind('BeforeUpload', onBeforeUpload); this.bind('UploadFile', onUploadFile); this.bind('UploadProgress', onUploadProgress); this.bind('StateChanged', onStateChanged); this.bind('QueueChanged', calc); this.bind('Error', onError); this.bind('FileUploaded', onFileUploaded); this.bind('Destroy', onDestroy); } function initControls(settings, cb) { var self = this, inited = 0, queue = []; // common settings var options = { runtime_order: settings.runtimes, required_caps: settings.required_features, preferred_caps: preferred_caps, swf_url: settings.flash_swf_url, xap_url: settings.silverlight_xap_url }; // add runtime specific options if any plupload.each(settings.runtimes.split(/\s*,\s*/), function(runtime) { if (settings[runtime]) { options[runtime] = settings[runtime]; } }); // initialize file pickers - there can be many if (settings.browse_button) { plupload.each(settings.browse_button, function(el) { queue.push(function(cb) { var fileInput = new o.FileInput(plupload.extend({}, options, { accept: settings.filters.mime_types, name: settings.file_data_name, multiple: settings.multi_selection, container: settings.container, browse_button: el })); fileInput.onready = function() { var info = o.Runtime.getInfo(this.ruid); // for backward compatibility o.extend(self.features, { chunks: info.can('slice_blob'), multipart: info.can('send_multipart'), multi_selection: info.can('select_multiple') }); inited++; fileInputs.push(this); cb(); }; fileInput.onchange = function() { self.addFile(this.files); }; fileInput.bind('mouseenter mouseleave mousedown mouseup', function(e) { if (!disabled) { if (settings.browse_button_hover) { if ('mouseenter' === e.type) { o.addClass(el, settings.browse_button_hover); } else if ('mouseleave' === e.type) { o.removeClass(el, settings.browse_button_hover); } } if (settings.browse_button_active) { if ('mousedown' === e.type) { o.addClass(el, settings.browse_button_active); } else if ('mouseup' === e.type) { o.removeClass(el, settings.browse_button_active); } } } }); fileInput.bind('mousedown', function() { self.trigger('Browse'); }); fileInput.bind('error runtimeerror', function() { fileInput = null; cb(); }); fileInput.init(); }); }); } // initialize drop zones if (settings.drop_element) { plupload.each(settings.drop_element, function(el) { queue.push(function(cb) { var fileDrop = new o.FileDrop(plupload.extend({}, options, { drop_zone: el })); fileDrop.onready = function() { var info = o.Runtime.getInfo(this.ruid); self.features.dragdrop = info.can('drag_and_drop'); // for backward compatibility inited++; fileDrops.push(this); cb(); }; fileDrop.ondrop = function() { self.addFile(this.files); }; fileDrop.bind('error runtimeerror', function() { fileDrop = null; cb(); }); fileDrop.init(); }); }); } o.inSeries(queue, function() { if (typeof(cb) === 'function') { cb(inited); } }); } function resizeImage(blob, params, cb) { var img = new o.Image(); try { img.onload = function() { // no manipulation required if... if (params.width > this.width && params.height > this.height && params.quality === undef && params.preserve_headers && !params.crop ) { this.destroy(); return cb(blob); } // otherwise downsize img.downsize(params.width, params.height, params.crop, params.preserve_headers); }; img.onresize = function() { cb(this.getAsBlob(blob.type, params.quality)); this.destroy(); }; img.onerror = function() { cb(blob); }; img.load(blob); } catch(ex) { cb(blob); } } function setOption(option, value, init) { var self = this, reinitRequired = false; function _setOption(option, value, init) { var oldValue = settings[option]; switch (option) { case 'max_file_size': if (option === 'max_file_size') { settings.max_file_size = settings.filters.max_file_size = value; } break; case 'chunk_size': if (value = plupload.parseSize(value)) { settings[option] = value; settings.send_file_name = true; } break; case 'multipart': settings[option] = value; if (!value) { settings.send_file_name = true; } break; case 'unique_names': settings[option] = value; if (value) { settings.send_file_name = true; } break; case 'filters': // for sake of backward compatibility if (plupload.typeOf(value) === 'array') { value = { mime_types: value }; } if (init) { plupload.extend(settings.filters, value); } else { settings.filters = value; } // if file format filters are being updated, regenerate the matching expressions if (value.mime_types) { settings.filters.mime_types.regexp = (function(filters) { var extensionsRegExp = []; plupload.each(filters, function(filter) { plupload.each(filter.extensions.split(/,/), function(ext) { if (/^\s*\*\s*$/.test(ext)) { extensionsRegExp.push('\\.*'); } else { extensionsRegExp.push('\\.' + ext.replace(new RegExp('[' + ('/^$.*+?|()[]{}\\'.replace(/./g, '\\$&')) + ']', 'g'), '\\$&')); } }); }); return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i'); }(settings.filters.mime_types)); } break; case 'resize': if (init) { plupload.extend(settings.resize, value, { enabled: true }); } else { settings.resize = value; } break; case 'prevent_duplicates': settings.prevent_duplicates = settings.filters.prevent_duplicates = !!value; break; case 'browse_button': case 'drop_element': value = plupload.get(value); case 'container': case 'runtimes': case 'multi_selection': case 'flash_swf_url': case 'silverlight_xap_url': settings[option] = value; if (!init) { reinitRequired = true; } break; default: settings[option] = value; } if (!init) { self.trigger('OptionChanged', option, value, oldValue); } } if (typeof(option) === 'object') { plupload.each(option, function(value, option) { _setOption(option, value, init); }); } else { _setOption(option, value, init); } if (init) { // Normalize the list of required capabilities settings.required_features = normalizeCaps(plupload.extend({}, settings)); // Come up with the list of capabilities that can affect default mode in a multi-mode runtimes preferred_caps = normalizeCaps(plupload.extend({}, settings, { required_features: true })); } else if (reinitRequired) { self.trigger('Destroy'); initControls.call(self, settings, function(inited) { if (inited) { self.runtime = o.Runtime.getInfo(getRUID()).type; self.trigger('Init', { runtime: self.runtime }); self.trigger('PostInit'); } else { self.trigger('Error', { code : plupload.INIT_ERROR, message : plupload.translate('Init error.') }); } }); } } // Internal event handlers function onBeforeUpload(up, file) { // Generate unique target filenames if (up.settings.unique_names) { var matches = file.name.match(/\.([^.]+)$/), ext = "part"; if (matches) { ext = matches[1]; } file.target_name = file.id + '.' + ext; } } function onUploadFile(up, file) { var url = up.settings.url , chunkSize = up.settings.chunk_size , retries = up.settings.max_retries , features = up.features , offset = 0 , blob ; // make sure we start at a predictable offset if (file.loaded) { offset = file.loaded = chunkSize ? chunkSize * Math.floor(file.loaded / chunkSize) : 0; } function handleError() { if (retries-- > 0) { delay(uploadNextChunk, 1000); } else { file.loaded = offset; // reset all progress up.trigger('Error', { code : plupload.HTTP_ERROR, message : plupload.translate('HTTP Error.'), file : file, response : xhr.responseText, status : xhr.status, responseHeaders: xhr.getAllResponseHeaders() }); } } function uploadNextChunk() { var chunkBlob, formData, args = {}, curChunkSize; // make sure that file wasn't cancelled and upload is not stopped in general if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) { return; } // send additional 'name' parameter only if required if (up.settings.send_file_name) { args.name = file.target_name || file.name; } if (chunkSize && features.chunks && blob.size > chunkSize) { // blob will be of type string if it was loaded in memory curChunkSize = Math.min(chunkSize, blob.size - offset); chunkBlob = blob.slice(offset, offset + curChunkSize); } else { curChunkSize = blob.size; chunkBlob = blob; } // If chunking is enabled add corresponding args, no matter if file is bigger than chunk or smaller if (chunkSize && features.chunks) { // Setup query string arguments if (up.settings.send_chunk_number) { args.chunk = Math.ceil(offset / chunkSize); args.chunks = Math.ceil(blob.size / chunkSize); } else { // keep support for experimental chunk format, just in case args.offset = offset; args.total = blob.size; } } xhr = new o.XMLHttpRequest(); // Do we have upload progress support if (xhr.upload) { xhr.upload.onprogress = function(e) { file.loaded = Math.min(file.size, offset + e.loaded); up.trigger('UploadProgress', file); }; } xhr.onload = function() { // check if upload made itself through if (xhr.status >= 400) { handleError(); return; } retries = up.settings.max_retries; // reset the counter // Handle chunk response if (curChunkSize < blob.size) { chunkBlob.destroy(); offset += curChunkSize; file.loaded = Math.min(offset, blob.size); up.trigger('ChunkUploaded', file, { offset : file.loaded, total : blob.size, response : xhr.responseText, status : xhr.status, responseHeaders: xhr.getAllResponseHeaders() }); // stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them if (o.Env.browser === 'Android Browser') { // doesn't harm in general, but is not required anywhere else up.trigger('UploadProgress', file); } } else { file.loaded = file.size; } chunkBlob = formData = null; // Free memory // Check if file is uploaded if (!offset || offset >= blob.size) { // If file was modified, destory the copy if (file.size != file.origSize) { blob.destroy(); blob = null; } up.trigger('UploadProgress', file); file.status = plupload.DONE; up.trigger('FileUploaded', file, { response : xhr.responseText, status : xhr.status, responseHeaders: xhr.getAllResponseHeaders() }); } else { // Still chunks left delay(uploadNextChunk, 1); // run detached, otherwise event handlers interfere } }; xhr.onerror = function() { handleError(); }; xhr.onloadend = function() { this.destroy(); xhr = null; }; // Build multipart request if (up.settings.multipart && features.multipart) { xhr.open("post", url, true); // Set custom headers plupload.each(up.settings.headers, function(value, name) { xhr.setRequestHeader(name, value); }); formData = new o.FormData(); // Add multipart params plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) { formData.append(name, value); }); // Add file and send it formData.append(up.settings.file_data_name, chunkBlob); xhr.send(formData, { runtime_order: up.settings.runtimes, required_caps: up.settings.required_features, preferred_caps: preferred_caps, swf_url: up.settings.flash_swf_url, xap_url: up.settings.silverlight_xap_url }); } else { // if no multipart, send as binary stream url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params)); xhr.open("post", url, true); xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header // Set custom headers plupload.each(up.settings.headers, function(value, name) { xhr.setRequestHeader(name, value); }); xhr.send(chunkBlob, { runtime_order: up.settings.runtimes, required_caps: up.settings.required_features, preferred_caps: preferred_caps, swf_url: up.settings.flash_swf_url, xap_url: up.settings.silverlight_xap_url }); } } blob = file.getSource(); // Start uploading chunks if (up.settings.resize.enabled && runtimeCan(blob, 'send_binary_string') && !!~o.inArray(blob.type, ['image/jpeg', 'image/png'])) { // Resize if required resizeImage.call(this, blob, up.settings.resize, function(resizedBlob) { blob = resizedBlob; file.size = resizedBlob.size; uploadNextChunk(); }); } else { uploadNextChunk(); } } function onUploadProgress(up, file) { calcFile(file); } function onStateChanged(up) { if (up.state == plupload.STARTED) { // Get start time to calculate bps startTime = (+new Date()); } else if (up.state == plupload.STOPPED) { // Reset currently uploading files for (var i = up.files.length - 1; i >= 0; i--) { if (up.files[i].status == plupload.UPLOADING) { up.files[i].status = plupload.QUEUED; calc(); } } } } function onCancelUpload() { if (xhr) { xhr.abort(); } } function onFileUploaded(up) { calc(); // Upload next file but detach it from the error event // since other custom listeners might want to stop the queue delay(function() { uploadNext.call(up); }, 1); } function onError(up, err) { if (err.code === plupload.INIT_ERROR) { up.destroy(); } // Set failed status if an error occured on a file else if (err.code === plupload.HTTP_ERROR) { err.file.status = plupload.FAILED; calcFile(err.file); // Upload next file but detach it from the error event // since other custom listeners might want to stop the queue if (up.state == plupload.STARTED) { // upload in progress up.trigger('CancelUpload'); delay(function() { uploadNext.call(up); }, 1); } } } function onDestroy(up) { up.stop(); // Purge the queue plupload.each(files, function(file) { file.destroy(); }); files = []; if (fileInputs.length) { plupload.each(fileInputs, function(fileInput) { fileInput.destroy(); }); fileInputs = []; } if (fileDrops.length) { plupload.each(fileDrops, function(fileDrop) { fileDrop.destroy(); }); fileDrops = []; } preferred_caps = {}; disabled = false; startTime = xhr = null; total.reset(); } // Default settings settings = { runtimes: o.Runtime.order, max_retries: 0, chunk_size: 0, multipart: true, multi_selection: true, file_data_name: 'file', flash_swf_url: 'js/Moxie.swf', silverlight_xap_url: 'js/Moxie.xap', filters: { mime_types: [], prevent_duplicates: false, max_file_size: 0 }, resize: { enabled: false, preserve_headers: true, crop: false }, send_file_name: true, send_chunk_number: true }; setOption.call(this, options, null, true); // Inital total state total = new plupload.QueueProgress(); // Add public methods plupload.extend(this, { /** * Unique id for the Uploader instance. * * @property id * @type String */ id : uid, uid : uid, // mOxie uses this to differentiate between event targets /** * Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED. * These states are controlled by the stop/start methods. The default value is STOPPED. * * @property state * @type Number */ state : plupload.STOPPED, /** * Map of features that are available for the uploader runtime. Features will be filled * before the init event is called, these features can then be used to alter the UI for the end user. * Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize. * * @property features * @type Object */ features : {}, /** * Current runtime name. * * @property runtime * @type String */ runtime : null, /** * Current upload queue, an array of File instances. * * @property files * @type Array * @see plupload.File */ files : files, /** * Object with name/value settings. * * @property settings * @type Object */ settings : settings, /** * Total progess information. How many files has been uploaded, total percent etc. * * @property total * @type plupload.QueueProgress */ total : total, /** * Initializes the Uploader instance and adds internal event listeners. * * @method init */ init : function() { var self = this; if (typeof(settings.preinit) == "function") { settings.preinit(self); } else { plupload.each(settings.preinit, function(func, name) { self.bind(name, func); }); } bindEventListeners.call(this); // Check for required options if (!settings.browse_button || !settings.url) { this.trigger('Error', { code : plupload.INIT_ERROR, message : plupload.translate('Init error.') }); return; } initControls.call(this, settings, function(inited) { if (typeof(settings.init) == "function") { settings.init(self); } else { plupload.each(settings.init, function(func, name) { self.bind(name, func); }); } if (inited) { self.runtime = o.Runtime.getInfo(getRUID()).type; self.trigger('Init', { runtime: self.runtime }); self.trigger('PostInit'); } else { self.trigger('Error', { code : plupload.INIT_ERROR, message : plupload.translate('Init error.') }); } }); }, /** * Set the value for the specified option(s). * * @method setOption * @since 2.1 * @param {String|Object} option Name of the option to change or the set of key/value pairs * @param {Mixed} [value] Value for the option (is ignored, if first argument is object) */ setOption: function(option, value) { setOption.call(this, option, value, !this.runtime); // until runtime not set we do not need to reinitialize }, /** * Get the value for the specified option or the whole configuration, if not specified. * * @method getOption * @since 2.1 * @param {String} [option] Name of the option to get * @return {Mixed} Value for the option or the whole set */ getOption: function(option) { if (!option) { return settings; } return settings[option]; }, /** * Refreshes the upload instance by dispatching out a refresh event to all runtimes. * This would for example reposition flash/silverlight shims on the page. * * @method refresh */ refresh : function() { if (fileInputs.length) { plupload.each(fileInputs, function(fileInput) { fileInput.trigger('Refresh'); }); } this.trigger('Refresh'); }, /** * Starts uploading the queued files. * * @method start */ start : function() { if (this.state != plupload.STARTED) { this.state = plupload.STARTED; this.trigger('StateChanged'); uploadNext.call(this); } }, /** * Stops the upload of the queued files. * * @method stop */ stop : function() { if (this.state != plupload.STOPPED) { this.state = plupload.STOPPED; this.trigger('StateChanged'); this.trigger('CancelUpload'); } }, /** * Disables/enables browse button on request. * * @method disableBrowse * @param {Boolean} disable Whether to disable or enable (default: true) */ disableBrowse : function() { disabled = arguments[0] !== undef ? arguments[0] : true; if (fileInputs.length) { plupload.each(fileInputs, function(fileInput) { fileInput.disable(disabled); }); } this.trigger('DisableBrowse', disabled); }, /** * Returns the specified file object by id. * * @method getFile * @param {String} id File id to look for. * @return {plupload.File} File object or undefined if it wasn't found; */ getFile : function(id) { var i; for (i = files.length - 1; i >= 0; i--) { if (files[i].id === id) { return files[i]; } } }, /** * Adds file to the queue programmatically. Can be native file, instance of Plupload.File, * instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded, * if any files were added to the queue. Otherwise nothing happens. * * @method addFile * @since 2.0 * @param {plupload.File|mOxie.File|File|Node|Array} file File or files to add to the queue. * @param {String} [fileName] If specified, will be used as a name for the file */ addFile : function(file, fileName) { var self = this , queue = [] , filesAdded = [] , ruid ; function filterFile(file, cb) { var queue = []; o.each(self.settings.filters, function(rule, name) { if (fileFilters[name]) { queue.push(function(cb) { fileFilters[name].call(self, rule, file, function(res) { cb(!res); }); }); } }); o.inSeries(queue, cb); } /** * @method resolveFile * @private * @param {o.File|o.Blob|plupload.File|File|Blob|input[type="file"]} file */ function resolveFile(file) { var type = o.typeOf(file); // o.File if (file instanceof o.File) { if (!file.ruid && !file.isDetached()) { if (!ruid) { // weird case return false; } file.ruid = ruid; file.connectRuntime(ruid); } resolveFile(new plupload.File(file)); } // o.Blob else if (file instanceof o.Blob) { resolveFile(file.getSource()); file.destroy(); } // plupload.File - final step for other branches else if (file instanceof plupload.File) { if (fileName) { file.name = fileName; } queue.push(function(cb) { // run through the internal and user-defined filters, if any filterFile(file, function(err) { if (!err) { // make files available for the filters by updating the main queue directly files.push(file); // collect the files that will be passed to FilesAdded event filesAdded.push(file); self.trigger("FileFiltered", file); } delay(cb, 1); // do not build up recursions or eventually we might hit the limits }); }); } // native File or blob else if (o.inArray(type, ['file', 'blob']) !== -1) { resolveFile(new o.File(null, file)); } // input[type="file"] else if (type === 'node' && o.typeOf(file.files) === 'filelist') { // if we are dealing with input[type="file"] o.each(file.files, resolveFile); } // mixed array of any supported types (see above) else if (type === 'array') { fileName = null; // should never happen, but unset anyway to avoid funny situations o.each(file, resolveFile); } } ruid = getRUID(); resolveFile(file); if (queue.length) { o.inSeries(queue, function() { // if any files left after filtration, trigger FilesAdded if (filesAdded.length) { self.trigger("FilesAdded", filesAdded); } }); } }, /** * Removes a specific file. * * @method removeFile * @param {plupload.File|String} file File to remove from queue. */ removeFile : function(file) { var id = typeof(file) === 'string' ? file : file.id; for (var i = files.length - 1; i >= 0; i--) { if (files[i].id === id) { return this.splice(i, 1)[0]; } } }, /** * Removes part of the queue and returns the files removed. This will also trigger the FilesRemoved and QueueChanged events. * * @method splice * @param {Number} start (Optional) Start index to remove from. * @param {Number} length (Optional) Lengh of items to remove. * @return {Array} Array of files that was removed. */ splice : function(start, length) { // Splice and trigger events var removed = files.splice(start === undef ? 0 : start, length === undef ? files.length : length); // if upload is in progress we need to stop it and restart after files are removed var restartRequired = false; if (this.state == plupload.STARTED) { // upload in progress plupload.each(removed, function(file) { if (file.status === plupload.UPLOADING) { restartRequired = true; // do not restart, unless file that is being removed is uploading return false; } }); if (restartRequired) { this.stop(); } } this.trigger("FilesRemoved", removed); // Dispose any resources allocated by those files plupload.each(removed, function(file) { file.destroy(); }); if (restartRequired) { this.start(); } return removed; }, /** Dispatches the specified event name and its arguments to all listeners. @method trigger @param {String} name Event name to fire. @param {Object..} Multiple arguments to pass along to the listener functions. */ // override the parent method to match Plupload-like event logic dispatchEvent: function(type) { var list, args, result; type = type.toLowerCase(); list = this.hasEventListener(type); if (list) { // sort event list by prority list.sort(function(a, b) { return b.priority - a.priority; }); // first argument should be current plupload.Uploader instance args = [].slice.call(arguments); args.shift(); args.unshift(this); for (var i = 0; i < list.length; i++) { // Fire event, break chain if false is returned if (list[i].fn.apply(list[i].scope, args) === false) { return false; } } } return true; }, /** Check whether uploader has any listeners to the specified event. @method hasEventListener @param {String} name Event name to check for. */ /** Adds an event listener by name. @method bind @param {String} name Event name to listen for. @param {function} fn Function to call ones the event gets fired. @param {Object} [scope] Optional scope to execute the specified function in. @param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first */ bind: function(name, fn, scope, priority) { // adapt moxie EventTarget style to Plupload-like plupload.Uploader.prototype.bind.call(this, name, fn, priority, scope); }, /** Removes the specified event listener. @method unbind @param {String} name Name of event to remove. @param {function} fn Function to remove from listener. */ /** Removes all event listeners. @method unbindAll */ /** * Destroys Plupload instance and cleans after itself. * * @method destroy */ destroy : function() { this.trigger('Destroy'); settings = total = null; // purge these exclusively this.unbindAll(); } }); }; plupload.Uploader.prototype = o.EventTarget.instance; /** * Constructs a new file instance. * * @class File * @constructor * * @param {Object} file Object containing file properties * @param {String} file.name Name of the file. * @param {Number} file.size File size. */ plupload.File = (function() { var filepool = {}; function PluploadFile(file) { plupload.extend(this, { /** * File id this is a globally unique id for the specific file. * * @property id * @type String */ id: plupload.guid(), /** * File name for example "myfile.gif". * * @property name * @type String */ name: file.name || file.fileName, /** * File type, `e.g image/jpeg` * * @property type * @type String */ type: file.type || '', /** * File size in bytes (may change after client-side manupilation). * * @property size * @type Number */ size: file.size || file.fileSize, /** * Original file size in bytes. * * @property origSize * @type Number */ origSize: file.size || file.fileSize, /** * Number of bytes uploaded of the files total size. * * @property loaded * @type Number */ loaded: 0, /** * Number of percentage uploaded of the file. * * @property percent * @type Number */ percent: 0, /** * Status constant matching the plupload states QUEUED, UPLOADING, FAILED, DONE. * * @property status * @type Number * @see plupload */ status: plupload.QUEUED, /** * Date of last modification. * * @property lastModifiedDate * @type {String} */ lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET) /** * Returns native window.File object, when it's available. * * @method getNative * @return {window.File} or null, if plupload.File is of different origin */ getNative: function() { var file = this.getSource().getSource(); return o.inArray(o.typeOf(file), ['blob', 'file']) !== -1 ? file : null; }, /** * Returns mOxie.File - unified wrapper object that can be used across runtimes. * * @method getSource * @return {mOxie.File} or null */ getSource: function() { if (!filepool[this.id]) { return null; } return filepool[this.id]; }, /** * Destroys plupload.File object. * * @method destroy */ destroy: function() { var src = this.getSource(); if (src) { src.destroy(); delete filepool[this.id]; } } }); filepool[this.id] = file; } return PluploadFile; }()); /** * Constructs a queue progress. * * @class QueueProgress * @constructor */ plupload.QueueProgress = function() { var self = this; // Setup alias for self to reduce code size when it's compressed /** * Total queue file size. * * @property size * @type Number */ self.size = 0; /** * Total bytes uploaded. * * @property loaded * @type Number */ self.loaded = 0; /** * Number of files uploaded. * * @property uploaded * @type Number */ self.uploaded = 0; /** * Number of files failed to upload. * * @property failed * @type Number */ self.failed = 0; /** * Number of files yet to be uploaded. * * @property queued * @type Number */ self.queued = 0; /** * Total percent of the uploaded bytes. * * @property percent * @type Number */ self.percent = 0; /** * Bytes uploaded per second. * * @property bytesPerSec * @type Number */ self.bytesPerSec = 0; /** * Resets the progress to its initial values. * * @method reset */ self.reset = function() { self.size = self.loaded = self.uploaded = self.failed = self.queued = self.percent = self.bytesPerSec = 0; }; }; window.plupload = plupload; }(window, mOxie)); plupload-2.1.8/license.txt000066400000000000000000000431031255343340300155300ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. plupload-2.1.8/readme.md000066400000000000000000000217741255343340300151360ustar00rootroot00000000000000# Plupload Plupload is a cross-browser multi-runtime file uploading API. Basically, a set of tools that will help you to build a reliable and visually appealing file uploader in minutes. Historically, Plupload comes from a dark and hostile age of no HTML5, hence all the alternative fallbacks, like Flash, Silverlight and Java (still in development). It is meant to provide an API, that will work anywhere and in any case, in one way or another. While having very solid fallbacks, Plupload is built with the future of HTML5 in mind. ### Table of Contents * [Backstory](https://github.com/moxiecode/plupload/blob/master/readme.md#backstory) * [Structure](https://github.com/moxiecode/plupload/blob/master/readme.md#structure) * [File API and XHR L2 pollyfills](https://github.com/moxiecode/moxie/blob/master/README.md) * [Plupload API](https://github.com/moxiecode/plupload/wiki/API) * [UI Widget](https://github.com/moxiecode/plupload/wiki/UI.Plupload) * [Queue Widget](https://github.com/moxiecode/plupload/wiki/pluploadQueue) * [Demos](https://github.com/jayarjo/plupload-demos/blob/master/README.md) * [Building Instructions](https://github.com/moxiecode/plupload/blob/master/readme.md#build) * [Getting Started](https://github.com/moxiecode/plupload/wiki/Getting-Started) * [Options](https://github.com/moxiecode/plupload/wiki/Options) * [Events](https://github.com/moxiecode/plupload/wiki/Uploader#wiki-events) * [Methods](https://github.com/moxiecode/plupload/wiki/Uploader#wiki-methods) * [Plupload in Your Language](https://github.com/moxiecode/plupload/wiki/Plupload-in-Your-Language) * [File Filters](https://github.com/moxiecode/plupload/wiki/File-Filters) * [Image Resizing on Client-Side](https://github.com/moxiecode/plupload/wiki/Image-Resizing-on-Client-Side) * [Chunking](https://github.com/moxiecode/plupload/wiki/Chunking) * [Upload to Amazon S3](https://github.com/moxiecode/plupload/wiki/Upload-to-Amazon-S3) * [FAQ](https://github.com/moxiecode/plupload/wiki/Frequently-Asked-Questions) * [Support](https://github.com/moxiecode/plupload/blob/master/readme.md##support) * [Create a Fiddle](https://github.com/moxiecode/plupload/wiki/Create-a-Fiddle) * [Contributing](https://github.com/moxiecode/plupload/blob/master/readme.md#contribute) * [License](https://github.com/moxiecode/plupload/blob/master/readme.md#license) * [Contact Us](http://www.moxiecode.com/contact.php) ### Backstory Plupload started in a time when uploading a file in a responsive and customizable manner was a real pain. Internally, browsers only had the `input[type="file"]` element. It was ugly and clunky at the same time. One couldn't even change it's visuals, without hiding it and coding another one on top of it from scratch. And then there was no progress indication for the upload process... Sounds pretty crazy today. It was very logical for developers to look for alternatives and writing their own implementations, using Flash and Java, in order to somehow extend limited browser capabilities. And so did we, in our search for a reliable and flexible file uploader for our [TinyMCE](http://www.tinymce.com/index.php)'s [MCImageManager](http://www.tinymce.com/enterprise/mcimagemanager.php). Quickly enough though, Plupload grew big. It easily split into a standalone project. With major *version 2.0* it underwent another huge reconstruction, basically [from the ground up](http://blog.moxiecode.com/2012/11/28/first-public-beta-plupload-2/), as all the low-level runtime logic has been extracted into separate [File API](http://www.w3.org/TR/FileAPI/) and [XHR L2](http://www.w3.org/TR/XMLHttpRequest/) pollyfills (currently known under combined name of [mOxie](https://github.com/moxiecode/moxie)), giving Plupload a chance to evolve further. ### Structure Currently, Plupload may be considered as consisting of three parts: low-level pollyfills, Plupload API and Widgets (UI and Queue). Initially, Widgets were meant only to serve as examples of the API, but quickly formed into fully-functional API implementations that now come bundled with the Plupload API. This has been a source for multiple misconceptions about the API as Widgets were easily mistaken for the Plupload itself. They are only implementations, such as any of you can build by yourself out of the API. * [Low-level pollyfills (mOxie)](https://github.com/moxiecode/moxie) - have their own [code base](https://github.com/moxiecode/moxie) and [documentation](https://github.com/moxiecode/moxie/wiki) on GitHub. * [Plupload API](https://github.com/moxiecode/plupload/wiki/API) * [UI Widget](https://github.com/moxiecode/plupload/wiki/UI.Plupload) * [Queue Widget](https://github.com/moxiecode/plupload/wiki/pluploadQueue) ### Building instructions Plupload depends on File API and XHR2 L2 pollyfills that currently have their [own repository](https://github.com/moxiecode/moxie) on GitHub. However, in most cases you shouldn't care as we bundle the latest build of mOxie, including full and minified JavaScript source and pre-compiled `SWF` and `XAP` components, with [every release](https://github.com/moxiecode/plupload/releases). You can find everything you may need under `js/` folder. There are cases where you might need a custom build, for example free of unnecessary runtimes, half the original size, etc. The difficult part of this task comes from mOxie and its set of additional runtimes that require special tools on your workstation in order to compile. Consider [build instructions for mOxie](https://github.com/moxiecode/moxie#build-instructions) - everything applies to Plupload as well. First of all, if you want to build custom Plupload packages you will require [Node.js](http://nodejs.org/), as this is our build environment of choice. Node.js binaries (as well as Source) [are available](http://nodejs.org/download/) for all major operating systems. Plupload includes _mOxie_ as a submodule, it also depends on some other repositories for building up it's dev environment - to avoid necessity of downloading them one by one, we recommended you to simply clone Plupload with [git](http://git-scm.com/) recursively (you will require git installed on your system for this operation to succeed): ``` git clone --recursive https://github.com/moxiecode/plupload.git ``` And finalize the preparation stage with: `npm install` - this will install all additional modules, including those required by dev and test environments. In case you would rather keep it minimal, add a `--production` flag. *Note:* Currently, for an unknown reason, locally installed Node.js modules on Windows, may not be automatically added to the system PATH. So, if `jake` commands below are not recognized you will need to add them manually: ``` set PATH=%PATH%;%CD%\node_modules\.bin\ ``` ### Support We are actively standing behind the Plupload and now that we are done with major rewrites and refactoring, the only real goal that we have ahead is making it as reliable and bulletproof as possible. We are open to all the suggestions and feature requests. We ask you to file bug reports if you encounter any. We may not react to them instantly, but we constantly bear them in my mind as we extend the code base. In addition to dedicated support for those who dare to buy our OEM licenses, we got [discussion boards](http://www.plupload.com/punbb/index.php), which is like an enormous FAQ, covering every possible application case. Of course, you are welcome to file a bug report or feature request, here on [GitHub](https://github.com/moxiecode/plupload/issues). Sometimes it is easier to notice the problem when bug report is accompained by the actual code. Consider providing [a Plupload fiddle](https://github.com/moxiecode/plupload/wiki/Create-a-Fiddle) for the troublesome code. ### Contributing We are open to suggestions and code revisions, however there are some rules and limitations that you might want to consider first. * Code that you contribute will automatically be licensed under the LGPL, but will not be limited to LGPL. * Although all contributors will get the credit for their work, copyright notices will be changed to [Moxiecode Systems AB](http://www.moxiecode.com/). * Third party code will be reviewed, tested and possibly modified before being released. These basic rules help us earn a living and ensure that code remains Open Source and compatible with LGPL license. All contributions will be added to the changelog and appear in every release and on the site. An easy place to start is to [translate Plupload to your language](https://github.com/moxiecode/plupload/wiki/Plupload-in-Your-Language#contribute). You can read more about how to contribute at: [http://www.plupload.com/contributing](http://www.plupload.com/contributing) ### License Copyright 2013, [Moxiecode Systems AB](http://www.moxiecode.com/) Released under [GPLv2 License](https://github.com/moxiecode/plupload/blob/master/license.txt). We also provide [commercial license](http://www.plupload.com/commercial.php).