/** * サブミット **/ // ネームスペースを設定 window.CmnLib = {}; // HTMLエスケープ CmnLib.escapeHtml = function (str) { if (typeof str !== 'string') { return str; } // エスケープ文字 var escChars = { '&': '&', '"': '"', "'": ''', '<': '<', '>': '>' }; return str.replace(/[&"'<>]/g, function (match) { return escChars[match]; }); }; CmnLib.isSubmit = false; // 2重クリック防止用サブミット(id属性指定) CmnLib.doubleClickSubmit = function (formId) { if(!CmnLib.isSubmit) { CmnLib.isSubmit = true; $('#' + formId).submit(); } } // 画面表示が完了したタイミングで必ず2重クリック防止フラグを戻す。 window.onpageshow = function() { CmnLib.isSubmit = false; } // サブミット(id属性指定) CmnLib.submit = function (formId) { $('#' + formId).submit(); } // CSVダウンロード(id属性指定) CmnLib.csvDownload = function (formId) { $('#' + formId).submit(); } //ファイルダウンロード(ウイルスチェックなし) CmnLib.fileDownload = function (downloadUrl, bucket, filepath, filename) { var _params = $.param({bucket:bucket, filepath:filepath, filename:filename}); $.ajax({ type: 'POST', url: downloadUrl, data: _params, beforeSend: function(request) { request.setRequestHeader($('meta[name="_csrf_token_header"]').attr('content'), $('meta[name="_csrf_token"]').attr('content')); } }).done(function (res, status, xhr) { // ダウンロード用URLにアクセス window.location.href = res.url; }).fail(function (xhr, status, error) { }); } // ファイルダウンロード(ウイルスチェックあり) CmnLib.fileDownloadVirusCheck = function (downloadUrl, bucket, filepath, filename, table) { // バケット/ファイルパス/ファイル名をURLパラメータ化 var _params = $.param({bucket:bucket, filepath:filepath, filename:filename, table:table}); // ダウンロード中表示On処理 $('[data-remodal-id=virusCheckModal]').remodal().open(); $.ajax({ type: 'POST', url: downloadUrl, data: _params, beforeSend: function(request) { request.setRequestHeader($('meta[name="_csrf_token_header"]').attr('content'), $('meta[name="_csrf_token"]').attr('content')); } }).done(function (res, status, xhr) { CmnLib._virusCheckModalClose(); // ダウンロード用URLにアクセス window.location.href = res.url; }).fail(function (xhr, status, error) { CmnLib._virusCheckModalClose(); }); } CmnLib._virusCheckModalClose = function () { var timerid = setInterval(function(){ clearInterval(timerid); // ダウンロード中表示Off処理 $('[data-remodal-id=virusCheckModal]').remodal().close(); }, 300); } // 帳票ダウンロード CmnLib.reportDownload = function (downloadUrl, id) { var _form = $('#' + id).serialize(); $.ajax({ type: 'POST', url: downloadUrl, data: _form, beforeSend: function(request) { request.setRequestHeader($('meta[name="_csrf_token_header"]').attr('content'), $('meta[name="_csrf_token"]').attr('content')); } }).done(function (res, status, xhr) { window.location.href = res.url; }).fail(function (xhr, status, error) { }); } // ファイルアップロード CmnLib.fileUpload = function (uploadUrl) { $.ajax({ type: 'POST', url: uploadUrl, beforeSend: function(request) { request.setRequestHeader($('meta[name="_csrf_token_header"]').attr('content'), $('meta[name="_csrf_token"]').attr('content')); } }).done(function (res, status, xhr) { // 遷移先 window.location.href = res.url; }).fail(function (xhr, status, error) { }); } /** * モーダル **/ // モダール生成 CmnLib.modalCreate = function(id, title, content) { jQuery(function($) { $("." + id).attr("href", "#"); $("." + id).attr("id", ""); $("." + id).attr("onclick", "CmnLib.modalOpen('"+id+"')"); }); document.write( '
' + '
' + '
' + '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
' + '

' + title + '

' + '
' + '

' + ' ' + content + '

' + '
' + '
' + '
' ); } // モーダル表示 CmnLib.modalOpen = function(id) { $('[data-remodal-id=' + id + ']').remodal().open(); } // モーダル非表示 CmnLib.modalClose = function(id) { $('[data-remodal-id=' + id + ']').remodal().close(); } // メンバー閲覧機能利用時 CmnLib.modalMemberImpersonation = function(id) { jQuery(function($) { $("." + id).attr("href", "#"); $("." + id).attr("id", ""); $("." + id).attr("onclick", "CmnLib.modalOpen('"+id+"')"); }); document.write( '
' + '
' + '
' + '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
' + '

メンバー閲覧機能制限

' + '
' + '

メンバー閲覧機能では情報の登録・変更はできません。

' + '
' + '
' + '
' ); } //画像リサイズ(正方形の場合のみ使用) CmnLib.imageReSizeForSquare = function(id) { if(id === undefined || id === null) { return; } var _image = new Image(); _image.onload = function(event) { var orgWidth = _image.width; var orgHeight = _image.height; newWidth = $("#" + id).attr('width'); newHeight = $("#" + id).attr('height'); // 元画像から比率を算出 var scale = 0.0; scale = newWidth / orgWidth; if(scale * orgHeight > newHeight) { scale = newHeight / orgHeight; } // 比率からリサイズ後のサイズ算出 var dstWidth = orgWidth * scale; var dstHeight = orgHeight * scale; $("#" + id).attr('width', dstWidth); $("#" + id).attr('height', dstHeight); }; _image.src = $("#" + id).attr('src'); } $(function () { // Enterキーでのsubmit を抑止 $('form:not([id*=menu])').each(function () { this.addEventListener('submit', function (e) { e.preventDefault(); }) }); });