$(document).ready(function () { initCommonJS(); }); function initCommonJS() { setScreenSize(); $(document).keydown(function (e) { return disableF5(e); }); $(document).ajaxStart(function () { showLoading(); }); $(document).ajaxStop(function () { hideLoading(); }); $('input[data=digits],input[data-type=digits]').keydown(function (e) { var keycode = e.keyCode ? e.keyCode : e.which; // Allow: backspace, delete, tab, escape, enter || Ctrl+A, Ctrl+C, Ctrl+V, Command+A || home, end, left, right, down, up if ($.inArray(keycode, [46, 8, 9, 27, 13]) !== -1 || (keycode === 65 || keycode === 86 || keycode === 67) && (e.ctrlKey === true || e.metaKey === true) || keycode >= 35 && keycode <= 40) { return true; } // Ensure that it is a number otherwise stop the keypress if ((e.shiftKey || (keycode < 48 || keycode > 57)) && (keycode < 96 || keycode > 105)) { return false; } //if (keycode >= 48 && keycode <= 57) return true; else return false; }); $('input[data=amount],input[data-type=amount]').keydown(function (e) { var keycode = e.keyCode ? e.keyCode : e.which; // Allow: backspace, delete, tab, escape, enter || Ctrl+A, Ctrl+C, Ctrl+V, Command+A || home, end, left, right, down, up if ($.inArray(keycode, [46, 8, 9, 27, 13]) !== -1 || (keycode === 65 || keycode === 86 || keycode === 67) && (e.ctrlKey === true || e.metaKey === true) || keycode >= 35 && keycode <= 40) { return true; } if ((e.which || e.keyCode) >= 48 && (e.which || e.keyCode) <= 57 || (e.which || e.keyCode) === 46) return true; else return false; }); if ($("#capsWarning").length > 0) { CapsLock.addListener(function (status) { if (status) { $("#capsWarning").show().text('Warning: you have turned caps lock on'); } else { $("#capsWarning").hide(); } }); } // Show/ Hide Password $("").insertAfter("input[type=password].toggle-password").parent().css("position", "relative"); $(document).on('click', '.toggle-show-password', function () { $(this).toggleClass("fa-eye fa-eye-slash"); var elem = $(this).prev(); if (!elem.hasClass("toggle-password")) elem = elem.find('input.toggle-password'); if ($(this).hasClass("fa-eye-slash")) { elem.prop("type", "text"); } else { elem.prop("type", "password"); } }); //$(document).click(function (event) { // if (!$(event.target).closest('.toggle-show-password').length) { // var elem = $(this).prev(); if (!elem.hasClass("toggle-password")) elem = elem.find('input.toggle-password'); // elem.toggleProp("type", "text password"); // $(this).toggleClass("fa-eye fa-eye-slash"); // } //}); $(window).resize(function () { setScreenSize(); $("table.dataTable").css("max-width", "100%"); }); $("table.dataTable").css('max-width', '100%'); $('.form-control:visible:enabled:not([readonly]):not([value]):first').focus(); $(document, '.panel-group').on('show.bs.collapse', function (n) { $(n.target).siblings('.panel-heading').find('.panel-title i').toggleClass('fa-minus fa-plus'); }); $(document, '.panel-group').on('hide.bs.collapse', function (n) { $(n.target).siblings('.panel-heading').find('.panel-title i').toggleClass('fa-plus fa-minus'); }); } function showClock(control) { if (control !== undefined) { var today = new Date(); var d = today.getDate(); var M = today.getMonth() + 1; var y = today.getFullYear(); var h = today.getHours(); var m = today.getMinutes(); //var s = today.getSeconds(); var t = h < 12 ? "AM" : "PM"; h = h > 12 ? h % 12 : h; d = d < 10 ? "0" + d : d; M = M < 10 ? "0" + M : M; h = h < 10 ? "0" + h : h; m = m < 10 ? "0" + m : m; //s = s < 10 ? "0" + s : s; if ($(window).width() > 767) control.text("Current Date and Time: " + d + "-" + M + "-" + y + " " + h + ":" + m + " " + t); // + ":" + s; else control.text(d + "-" + M + "-" + y + " " + h + ":" + m + " " + t); // + ":" + s; } } function setScreenSize() { $('#main_content #ls-canvas').css("height", $(window).height() - 78); $('#main_content #ls-canvas .main_content').css("height", $(window).height() - 115); } function setCenter(whichDiv) { $(whichDiv).css({ left: ($(window).width() - $(whichDiv).width()) / 2, top: ($(window).height() - $(whichDiv).height()) / 2 }); } function setGridViewHeight() { $('.gridview').css("max-height", $('#ls-canvas').height() * .70); } function ShowAlert(message) { ShowMessage('Alert', message, null, 'OK', null); } function ShowMessage(title, msg, url, btntext, type) { $('.modal-backdrop').hide(); BootstrapDialog.show({ title: title, type: BootstrapDialog.TYPE_PRIMARY, //size: BootstrapDialog.SIZE_SMALL, draggable: true, closable: false, message: msg, cssClass: 'message-box', onhidden: function (dialog) { $('.form-control:visible:enabled:not([readonly]):first').focus(); }, buttons: [{ label: 'OK', hotkey: 13, // Enter cssClass: 'btn-primary', action: function (dialog) { dialog.close(); if (url !== null && url !== '') { if (top !== self) top.location.href = url; else window.location = url; } } }] }); } function ShowModelPopup(type, content, title, cssClass) { BootstrapDialog.show({ type: BootstrapDialog.TYPE_DEFAULT, //size: BootstrapDialog.SIZE_MEDIUM, cssClass: cssClass, draggable: true, closable: true, closeByBackdrop: type === 'image', closeByKeyboard: type === 'image', title: function (dialog) { if (title === null || title.length === 0) { dialog.getModalHeader().hide(); //dialog.getModalFooter().hide(); } else return title; }, message: function (dialog) { if (type === 'iframe') { var style = ''; if (cssClass === 'modal-iframe') { style = "style='height:" + $(document).innerHeight() * .5 + 'px' + ";max-height:" + $(document).innerHeight() * .5 + 'px' + "'"; } return ""; } else if (type === 'image') { return "" + title + ""; } if (type === 'application/pdf') { return ""; } else { return content; } } }); } function ShowModelDialog(content, title, hideOnEsc, cssClass) { BootstrapDialog.show({ type: BootstrapDialog.TYPE_DEFAULT, //size: BootstrapDialog.SIZE_MEDIUM, cssClass: cssClass, draggable: true, closable: true, closeByBackdrop: hideOnEsc, closeByKeyboard: hideOnEsc, title: function (dialog) { if (title === null || title.length === 0) { dialog.getModalHeader().hide(); //dialog.getModalFooter().hide(); } else return title; }, message: function (dialog) { return $(content).html(); } }); } function ShowAlertBox(message) { BootstrapDialog.show({ title: 'Alert', cssClass: 'message-box', type: BootstrapDialog.TYPE_DEFAULT, //size: BootstrapDialog.SIZE_SMALL, draggable: true, message: message, buttons: [{ label: 'OK', hotkey: 13, // Enter cssClass: 'btn-primary', action: function (dialog) { dialog.close(); } }] }); } function ShowConfirmBox(message, okLabel, cancelLabel, e) { var target = e.srcElement ? e.srcElement : e.target; if (!$(target).hasClass('clicked')) { e.preventDefault(); $(target).addClass('clicked'); BootstrapDialog.configDefaultOptions({ cssClass: 'message-box confirm-box', btnsOrder: BootstrapDialog.BUTTONS_ORDER_OK_CANCEL }); BootstrapDialog.confirm({ title: 'Confirmation', message: message, size: BootstrapDialog.SIZE_SMALL, type: BootstrapDialog.TYPE_PRIMARY, closable: false, draggable: true, btnCancelLabel: cancelLabel, btnCancelClass: 'btn-primary', btnOKLabel: okLabel, callback: function (result) { //if (result) { __doPostBack(target_name, ''); } if (result) { $(target).click(); } else { $(target).removeClass('clicked'); } } }); } } function ShowNotification(type, message) { if ($(".notify").length) $(".notify").remove(); if (!$(".notify").length) { var notify = '
' + '
x
' + '
' + message + '
'; $('body').append(notify); $("#notifycolse").click(function (e) { $(".notify").remove(); }); } } function CloseOnEsc(divPopup) { if (divPopup.is(':visible')) { $(document).on('keydown', function (event) { if (event.keyCode === 13 || event.keyCode === 27) { // ENTER OR ESC CloseModelPopup(divPopup); } }); } } function CloseModelPopup(divPopup) { if (divPopup) { divPopup.css("display", "none"); } else { $('.modelPopup').css("display", "none"); } } function RemoveModelPopup() { $('.modal').remove(); $('.modal-backdrop').remove(); } function showLoading() { var loading = '
Loading...
'; $('body').append(loading); $('.small-loading').show(); } function hideLoading() { $('.small-loading').remove(); } function printDiv(div, css) { var contents = div.html(); var frame1 = $('