aboutsummaryrefslogtreecommitdiffstats
path: root/library/blueimp_upload/js/main.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-10-05 01:18:50 -0700
committerfriendica <info@friendica.com>2014-10-05 01:18:50 -0700
commit82ba42586cc9427b8a118c30462fc66d92cffecd (patch)
tree6b8866b0f357a4e7cff3b6c80f42c56ad44376c9 /library/blueimp_upload/js/main.js
parent191ef124cf6f6ec3978eededba13bd13463140a1 (diff)
downloadvolse-hubzilla-82ba42586cc9427b8a118c30462fc66d92cffecd.tar.gz
volse-hubzilla-82ba42586cc9427b8a118c30462fc66d92cffecd.tar.bz2
volse-hubzilla-82ba42586cc9427b8a118c30462fc66d92cffecd.zip
add blueimp-jquery-file-upload library
Diffstat (limited to 'library/blueimp_upload/js/main.js')
-rw-r--r--library/blueimp_upload/js/main.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/library/blueimp_upload/js/main.js b/library/blueimp_upload/js/main.js
new file mode 100644
index 000000000..8f57967a3
--- /dev/null
+++ b/library/blueimp_upload/js/main.js
@@ -0,0 +1,75 @@
+/*
+ * jQuery File Upload Plugin JS Example 8.9.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2010, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/* global $, window */
+
+$(function () {
+ 'use strict';
+
+ // Initialize the jQuery File Upload widget:
+ $('#fileupload').fileupload({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: 'server/php/'
+ });
+
+ // 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.io') {
+ // Demo settings:
+ $('#fileupload').fileupload('option', {
+ url: '//jquery-file-upload.appspot.com/',
+ // Enable image resizing, except for Android and Opera,
+ // which actually support image resizing, but fail to
+ // send Blob objects via XHR requests:
+ disableImageResize: /Android(?!.*Chrome)|Opera/
+ .test(window.navigator.userAgent),
+ maxFileSize: 5000000,
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
+ });
+ // Upload server status check for browsers with CORS support:
+ if ($.support.cors) {
+ $.ajax({
+ url: '//jquery-file-upload.appspot.com/',
+ type: 'HEAD'
+ }).fail(function () {
+ $('<div class="alert alert-danger"/>')
+ .text('Upload server currently unavailable - ' +
+ new Date())
+ .appendTo('#fileupload');
+ });
+ }
+ } else {
+ // Load existing files:
+ $('#fileupload').addClass('fileupload-processing');
+ $.ajax({
+ // Uncomment the following to send cross-domain cookies:
+ //xhrFields: {withCredentials: true},
+ url: $('#fileupload').fileupload('option', 'url'),
+ dataType: 'json',
+ context: $('#fileupload')[0]
+ }).always(function () {
+ $(this).removeClass('fileupload-processing');
+ }).done(function (result) {
+ $(this).fileupload('option', 'done')
+ .call(this, $.Event('done'), {result: result});
+ });
+ }
+
+});