Merge pull request #967 from solgenomics/topic/expression_atlas_export
[sgn.git] / js / jqueryfileupload / main.js
blob7178ec31958dc50d6c48a488e2fe2cb11dd17c65
1 /*
2 * jQuery File Upload Plugin JS Example 7.0
3 * https://github.com/blueimp/jQuery-File-Upload
5 * Copyright 2010, Sebastian Tschan
6 * https://blueimp.net
8 * Licensed under the MIT license:
9 * http://www.opensource.org/licenses/MIT
12 /*jslint nomen: true, unparam: true, regexp: true */
13 /*global $, window, document */
15 $(function () {
16 'use strict';
18 // Initialize the jQuery File Upload widget:
19 $('#fileupload').fileupload({
20 // Uncomment the following to send cross-domain cookies:
21 //xhrFields: {withCredentials: true},
22 // url: 'server/php/'
23 url: '/solgs/upload/prediction/genotypes/'
24 });
26 // Enable iframe cross-domain access via redirect option:
27 $('#fileupload').fileupload(
28 'option',
29 'redirect',
30 window.location.href.replace(
31 /\/[^\/]*$/,
32 '/cors/result.html?%s'
36 if (window.location.hostname === 'blueimp.github.com') {
37 // Demo settings:
38 $('#fileupload').fileupload('option', {
39 url: '//jquery-file-upload.appspot.com/',
40 maxFileSize: 5000000,
41 acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
42 process: [
44 action: 'load',
45 fileTypes: /^image\/(gif|jpeg|png)$/,
46 maxFileSize: 20000000 // 20MB
49 action: 'resize',
50 maxWidth: 1440,
51 maxHeight: 900
54 action: 'save'
57 });
58 // Upload server status check for browsers with CORS support:
59 if ($.support.cors) {
60 $.ajax({
61 url: '//jquery-file-upload.appspot.com/',
62 type: 'HEAD'
63 }).fail(function () {
64 $('<span class="alert alert-error"/>')
65 .text('Upload server currently unavailable - ' +
66 new Date())
67 .appendTo('#fileupload');
68 });
70 } else {
71 // Load existing files:
72 $.ajax({
73 // Uncomment the following to send cross-domain cookies:
74 //xhrFields: {withCredentials: true},
75 url: $('#fileupload').fileupload('option', 'url'),
76 dataType: 'json',
77 context: $('#fileupload')[0]
78 }).done(function (result) {
79 $(this).fileupload('option', 'done')
80 .call(this, null, {result: result});
81 });
84 // Initialize the Image Gallery widget:
85 $('#fileupload .files').imagegallery();
87 // Initialize the theme switcher:
88 $('#theme-switcher').change(function () {
89 var theme = $('#theme');
90 theme.prop(
91 'href',
92 theme.prop('href').replace(
93 /[\w\-]+\/jquery-ui.css/,
94 $(this).val() + '/jquery-ui.css'
97 });
99 });