Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1551 lars 1
/*
2
 * jQuery File Upload Demo
3
 * https://github.com/blueimp/jQuery-File-Upload
4
 *
5
 * Copyright 2010, Sebastian Tschan
6
 * https://blueimp.net
7
 *
8
 * Licensed under the MIT license:
9
 * https://opensource.org/licenses/MIT
10
 */
11
 
12
/* global $ */
13
 
14
$(function () {
15
  'use strict';
16
 
17
  // Initialize the jQuery File Upload widget:
18
  $('#fileupload').fileupload({
19
    // Uncomment the following to send cross-domain cookies:
20
    //xhrFields: {withCredentials: true},
21
    url: 'server/php/'
22
  });
23
 
24
  // Enable iframe cross-domain access via redirect option:
25
  $('#fileupload').fileupload(
26
    'option',
27
    'redirect',
28
    window.location.href.replace(/\/[^/]*$/, '/cors/result.html?%s')
29
  );
30
 
31
  if (window.location.hostname === 'blueimp.github.io') {
32
    // Demo settings:
33
    $('#fileupload').fileupload('option', {
34
      url: '//jquery-file-upload.appspot.com/',
35
      // Enable image resizing, except for Android and Opera,
36
      // which actually support image resizing, but fail to
37
      // send Blob objects via XHR requests:
38
      disableImageResize: /Android(?!.*Chrome)|Opera/.test(
39
        window.navigator.userAgent
40
      ),
41
      maxFileSize: 999000,
42
      acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
43
    });
44
    // Upload server status check for browsers with CORS support:
45
    if ($.support.cors) {
46
      $.ajax({
47
        url: '//jquery-file-upload.appspot.com/',
48
        type: 'HEAD'
49
      }).fail(function () {
50
        $('<div class="alert alert-danger"></div>')
51
          .text('Upload server currently unavailable - ' + new Date())
52
          .appendTo('#fileupload');
53
      });
54
    }
55
  } else {
56
    // Load existing files:
57
    $('#fileupload').addClass('fileupload-processing');
58
    $.ajax({
59
      // Uncomment the following to send cross-domain cookies:
60
      //xhrFields: {withCredentials: true},
61
      url: $('#fileupload').fileupload('option', 'url'),
62
      dataType: 'json',
63
      context: $('#fileupload')[0]
64
    })
65
      .always(function () {
66
        $(this).removeClass('fileupload-processing');
67
      })
68
      .done(function (result) {
69
        $(this)
70
          .fileupload('option', 'done')
71
          // eslint-disable-next-line new-cap
72
          .call(this, $.Event('done'), { result: result });
73
      });
74
  }
75
});