function showErrorModal(title, message) { var modal = $("#modal-error"); if (modal != null) { var divTitle = $("#modal-error .modal-title"); if (divTitle != null) divTitle.text(title); var divMessage = $("#modal-error .modal-body"); if (divMessage != null) { divMessage.text($.trim(message)); if (divMessage.text().length > 0) { $("#modal-error").modal(); } } } } function enableElement(obj, enable) { if (enable) { $(obj).removeAttr('disabled'); } else { $(obj).attr('disabled', 'disabled'); } } function blockUI() { $.blockUI({ message: "
Loading...
"}); } function unblockUI() { $.unblockUI(); } (function ($) { $.validator.unobtrusive.parseDynamicContent = function (selector) { //use the normal unobstrusive.parse method $.validator.unobtrusive.parse(selector); //get the relevant form var form = $(selector).first().closest('form'); //get the collections of unobstrusive validators, and jquery validators //and compare the two var unobtrusiveValidation = form.data('unobtrusiveValidation'); var validator = form.validate(); $.each(unobtrusiveValidation.options.rules, function (elname, elrules) { if (validator.settings.rules[elname] == undefined) { var args = {}; $.extend(args, elrules); args.messages = unobtrusiveValidation.options.messages[elname]; //edit:use quoted strings for the name selector $("[name='" + elname + "']").rules("add", args); } else { $.each(elrules, function (rulename, data) { if (validator.settings.rules[elname][rulename] == undefined) { var args = {}; args[rulename] = data; args.messages = unobtrusiveValidation.options.messages[elname][rulename]; //edit:use quoted strings for the name selector $("[name='" + elname + "']").rules("add", args); } }); } }); }; })($); (function ($) { $.QueryString = (function (a) { if (a == "") return {}; var b = {}; for (var i = 0; i < a.length; ++i) { var p = a[i].split('='); if (p.length != 2) continue; b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); } return b; })(window.location.search.substr(1).split('&')); })($); Number.prototype.formatNumber = function (c, d, t) { var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); }; Number.prototype.formatDuration = function () { var result = this; if (this > 0) { // get years } if (this > 0) { // get days } if (this > 0) { // get hours } return result; };