diff options
author | Sem <sembrestels@riseup.net> | 2012-08-02 21:44:44 +0200 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-08-02 21:44:44 +0200 |
commit | dad0209bbd7994b623bc0126e3e37b1f521d2977 (patch) | |
tree | 1e954b32439cbfc2acbbd63ed62dc372a260f37e /vendors/jquery-file-upload/js/main.js | |
parent | fa81c487488064f684649272a6579079d3a88e2c (diff) | |
parent | 28b1669c4b1afaed7429da2cc9580340dcb13b6e (diff) | |
download | elgg-dad0209bbd7994b623bc0126e3e37b1f521d2977.tar.gz elgg-dad0209bbd7994b623bc0126e3e37b1f521d2977.tar.bz2 |
Merge branch 'jquery-uploader' of git://github.com/sembrestels/Tidypics
Conflicts:
start.php
views/default/photos/css.php
Diffstat (limited to 'vendors/jquery-file-upload/js/main.js')
-rw-r--r-- | vendors/jquery-file-upload/js/main.js | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/vendors/jquery-file-upload/js/main.js b/vendors/jquery-file-upload/js/main.js new file mode 100644 index 000000000..67109588d --- /dev/null +++ b/vendors/jquery-file-upload/js/main.js @@ -0,0 +1,93 @@ +/* + * jQuery File Upload Plugin JS Example 6.7 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2010, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ + +/*jslint nomen: true, unparam: true, regexp: true */ +/*global $, window, document */ + +$(function () { + 'use strict'; + + // Initialize the jQuery File Upload widget: + $('#fileupload').fileupload(); + + // Enable iframe cross-domain access via redirect option: + $('#fileupload').fileupload( + 'option', + 'redirect', + window.location.href.replace( + /\/[^\/]*$/, + '/cors/result.html?%s' + ) + ); + + if (window.location.hostname === 'blueimp.github.com') { + // Demo settings: + $('#fileupload').fileupload('option', { + url: '//jquery-file-upload.appspot.com/', + maxFileSize: 5000000, + acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, + process: [ + { + action: 'load', + fileTypes: /^image\/(gif|jpeg|png)$/, + maxFileSize: 20000000 // 20MB + }, + { + action: 'resize', + maxWidth: 1440, + maxHeight: 900 + }, + { + action: 'save' + } + ] + }); + // Upload server status check for browsers with CORS support: + if ($.support.cors) { + $.ajax({ + url: '//jquery-file-upload.appspot.com/', + type: 'HEAD' + }).fail(function () { + $('<span class="alert alert-error"/>') + .text('Upload server currently unavailable - ' + + new Date()) + .appendTo('#fileupload'); + }); + } + } else { + // Load existing files: + $('#fileupload').each(function () { + var that = this; + $.getJSON(this.action, function (result) { + if (result && result.length) { + $(that).fileupload('option', 'done') + .call(that, null, {result: result}); + } + }); + }); + } + + // Initialize the Image Gallery widget: + $('#fileupload .files').imagegallery(); + + // Initialize the theme switcher: + $('#theme-switcher').change(function () { + var theme = $('#theme'); + theme.prop( + 'href', + theme.prop('href').replace( + /[\w\-]+\/jquery-ui.css/, + $(this).val() + '/jquery-ui.css' + ) + ); + }); + +}); |