/* * jQuery File Upload Plugin JS Example 8.0 * 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'; var maxFiles = 48; // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: 'jqUpload.php?sid=itqbdgvpojcf7m215qsvccnd96', autoUpload: true // 選択後すぐに転送開始 }); // 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' || window.location.hostname === 'blueimp.github.io') { // Demo settings: $('#fileupload').fileupload('option', { url: '//jquery-file-upload.appspot.com/', disableImageResize: false, 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 () { $('') .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 (result) { $(this).removeClass('fileupload-processing'); }).done(function (result) { $(this).fileupload('option', 'done') .call(this, null, {result: result}); }); } $('#fileupload').bind('fileuploadstop', function (e, data) { var numOfFiles = $('.files').children().length; if(numOfFiles >= maxFiles){ window.location.href = '/wis/order.php?mode=select'; } }); // 1ファイルごとのアップロード完了イベント $('#fileupload').bind('fileuploaddone', function (e, data) { // これは選択した時点で全部数に入ってしまうのでだめ var numOfFiles = $('.template-download').length; // アップロード完了したアイテムだけ取得したい console.log("fileuploaddone:", numOfFiles); update_loading(numOfFiles + 1); }); $('#progress').progressbar({ value: 0, max: maxFiles }); function update_loading(numOfFiles){ var rest = maxFiles - numOfFiles; $('#loading span').text(rest); $('#progress').progressbar('value', numOfFiles); } update_loading(0); });