/* * 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 selectedFiles = 0; // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: '/jqUp/uploadPc50.php?sid=ivj175lodaeql4g3pav0b55n57', autoUpload: true // 選択後すぐに転送開始 }); // Enable iframe cross-domain access via redirect option: $('#fileupload').fileupload( 'option', 'redirect', window.location.href.replace( /\/[^\/]*$/, '/cors/result.html?%s' ) ); // 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) { window.location.href = '/wis/order50.php?mode=select'; }) // 画像選択イベント:選択枚数をカウントしプログレスバーを初期化 // fileuploadstartイベントはリストが揃うまで発生しないため、選択数が多いと表示に時間がかかるので、このイベントで初期化してる $('#fileupload').bind('fileuploadchange', function (e, data) { selectedFiles += data.files.length; $('#progress').progressbar({ value: 0, max: selectedFiles }); update_loading(0); $('#progress').show(); if(selectedFiles >= 31){ $('#tap-info').show(); } }); // 1ファイルごとのアップロード完了イベント $('#fileupload').bind('fileuploaddone', function (e, data) { var numOfFiles = $('.template-download').length; update_loading(numOfFiles + 1); console.log('fileuploadchange'); }); function update_loading(numOfFiles){ var rest = selectedFiles - numOfFiles; $('#loading span').text(rest); $('#progress').progressbar('value', numOfFiles); } $('#progress').hide(); $('#tap-info').hide(); });