var mainSystem = {}; mainSystem.showModalForm = function(ac,t,b,a) { jQuery('#modal-form-label').html(t); jQuery('#modal-form-body').html(b); jQuery('#modal-form-action').html(a); jQuery('#modal-form-close').bind("click",ac.close); jQuery('#modal-form-action').unbind(); jQuery('#modal-form-action').bind("click",ac.action); jQuery('#modal-form .close').bind("click",ac.close); jQuery('#modal-form').modal({show:true,backdrop:'static',width:'1200'}); }; mainSystem.showModalConfirm = function(ac,t,b,a) { jQuery('modal-confirm-label').html(t); jQuery('#modal-confirm-body').html(b); jQuery('#modal-confirm-action').html(a); jQuery('#modal-confirm-close').bind("click",ac.close); jQuery('#modal-confirm-action').unbind(); jQuery('#modal-confirm-action').bind("click",ac.action); jQuery('#modal-confirm .close').bind("click",ac.close); jQuery('#modal-confirm').modal({show:true,backdrop:'static'}); }; mainSystem.showModalError = function(ac,t,b) { jQuery('modal-error-label').html(t); jQuery('#modal-error-body').html(b); jQuery('#modal-error-action').unbind(); jQuery('#modal-error-close').bind("click",ac.close); if ("function" == typeof(ac.action)) { jQuery('#modal-error-action').html('More Info'); jQuery('#modal-error-action').bind("click",ac.action); jQuery('#modal-error-action').show(); }else{ jQuery('#modal-error-action').hide(); } jQuery('#modal-error').modal({show:true,backdrop:'static'}); }; mainSystem.showModalErrorAlert = function(b) { mainSystem.showModalError({"close":function(){},"action":null},"Error",b); }; mainSystem.TextAreaInsert = function(tid,text) { tid = document.getElementById(tid); var scrollPos = tid.scrollTop; var strPos = 0; var br = ((tid.selectionStart || tid.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { tid.focus(); var range = document.selection.createRange(); range.moveStart ('character', -tid.value.length); strPos = range.text.length; } else if (br == "ff") strPos = tid.selectionStart; var front = (tid.value).substring(0,strPos); var back = (tid.value).substring(strPos,tid.value.length); tid.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { tid.focus(); var range = document.selection.createRange(); range.moveStart ('character', -tid.value.length); range.moveStart ('character', strPos); range.moveEnd ('character', 0); range.select(); } else if (br == "ff") { tid.selectionStart = strPos; tid.selectionEnd = strPos; tid.focus(); } tid.scrollTop = scrollPos; }; // jQuery plugin to prevent double submission of forms jQuery.fn.preventDoubleSubmission = function() { $(this).on('submit',function(e){ var $form = $(this); if ($form.data('submitted') === true) { // Previously submitted - don't submit again e.preventDefault(); } else { // Mark it so that the next submit can be ignored $form.data('submitted', true); } }); // Keep chainability return this; };