var dateformat = "MM/dd/yyyy"; var timeformat = "hh:mm tt"; var datepickerformat = "mm/dd/yy"; var env_portal_mode = "window"; var handheldmode = false; $(document).ready(function () { if (!bgSize) location.href = "/Layout/Messages/Legacy"; // set focus to the element that has a class name of .focus $('.focus').focus(); }); function SwitchElementViews(showview, hideview, isBlock) { var block = true; if (isBlock === false) block = false; // show the view if (showview) { $(showview).removeClass('hide'); $(showview).addClass(block ? 'show' : 'show-ib'); } // hide the view if (hideview) { $(hideview).removeClass(block ? 'show' : 'show-ib'); $(hideview).addClass('hide'); } } function ToggleElementViews(view1, view2, forcedirective) { // 'forcedirective', if true, means we want to force the position hide/show elements var force = forcedirective || false; // view 1 if (view1 !== null) { if (force) $(view1).addClass("hide"); else { if (view1.is(":visible")) { $(view1).addClass("hide"); } else { $(view1).removeClass("hide"); } } } // view 2 if (view2 !== null) { if (force) $(view2).removeClass("hide"); else { if (view2.is(":visible")) { $(view2).addClass("hide"); } else { $(view2).removeClass("hide"); } } } } function ToggleHide(div) { // show hide if it isn't there if ($('#' + div).hasClass('hide')) $('#' + div).removeClass('hide'); else $('#' + div).addClass('hide'); } function ToggleDisable(ele, sel) { // show hide if it isn't there if ($('#' + ele).attr('disabled')) $('#' + ele).removeAttr('disabled'); else { if (sel !== null) $('#' + ele + ' option').eq(sel).prop('selected', true); $('#' + ele).attr('disabled', 'disabled'); } } function AjaxDropDown(sourceid, destinationid, posturl, empty_message) { var source_val = $("#" + sourceid).val(); if (source_val === null || source_val === "") source_val = "-1"; var ddl_destination = $('#' + destinationid); ddl_destination.empty(); $.ajax({ type: "POST", url: posturl, data: { id: source_val }, success: function (returndata) { if (returndata.ok) { if (returndata.data.length === 0) { ddl_destination.attr("disabled", true); ddl_destination.addClass("disabled"); ddl_destination.append($('').val("").html(empty_message)); } else { if (empty_message !== null) ddl_destination.append($('').val("").html(empty_message)); ddl_destination.attr("disabled", false); ddl_destination.removeClass("disabled"); $.each(returndata.data, function (index, itemData) { ddl_destination.append($('').val(itemData.ID).html(itemData.Name)); }); } ddl_destination.show('slow'); } else window.alert(' error : ' + returndata.message); } }); } function DisplayNotifyMessage(message, duration) { var d = duration || 0; var m = message || "There is no message associated with this trigger. Please use DisplayNotifyMessage(\"My Message\")"; $("#env-notify p").html(m); $("#env-notify").addClass("open"); if (d) { if (typeof notifyto !== "undefined") clearTimeout(notifyto); notifyto = setTimeout(function () { $("#env-notify").removeClass("open"); }, d); } } function DisplayWarningMessage(message, duration) { var d = duration || 0; var m = message || "There is no message associated with this trigger. Please use DisplayNotifyMessage(\"My Message\")"; $("#env-warning p").html(m); $("#env-warning").addClass("open"); if (d) { if (typeof warningto !== "undefined") clearTimeout(warningto); warningto = setTimeout(function () { $("#env-warning").removeClass("open"); }, d); } } function PagerClick(partial, url, page) { $(partial).load(url, { index: page }); } function AddLoadingMessage(container, message) { var m = message || "LOADING"; if (container instanceof jQuery) container.html("
" + m + "
"); } function PopupLoadingMessage(a, hideLoading) { var hideloader = hideLoading || false; var parent = $(a).closest("footer"); var buttons = $(parent).children("div.portal-popup-footer-buttons"); var status = $(parent).children("div.portal-popup-footer-status"); hideloader ? SwitchElementViews(buttons, status) : SwitchElementViews(status, buttons); } function ToggleDragCursorIcons() { var container = $("#env-dashboard-scroll-container"); if (container.length > 0) { if ($(container).get(0).scrollWidth > $(container).innerWidth()) { $(container).addClass("drag_icons"); } else { $(container).removeClass("drag_icons"); } } } function PopupGenericMessage(title, msg) { $.colorbox({ inline: true, href: "#popup_GenericMessage", title: title, overlayClose: false, width: 400, scrolling: false, onLoad: function () { $("div p.portal-popup-generic-message").empty().html(msg); } }); } var jQueryScriptOutputted = false; function initJQuery() { // if the jQuery object isn't available if (typeof jQuery === 'undefined') { if (!jQueryScriptOutputted) { //only output the script once.. jQueryScriptOutputted = true; //output the script (load it from google api) document.write(""); } setTimeout("initJQuery()", 50); } } Date.prototype.AddDays = function (days) { var dat = new Date(this.valueOf()); dat.setDate(dat.getDate() + days); return dat; }; function ConvertDate(date, format) { var rawdate = new Date(date); var formatdate = format || datepickerformat; return $.datepicker.formatDate(formatdate, rawdate); } function ConvertDate_DDMMtoMMDD(date) { var chunks = date.split('-'); var formattedDate = chunks[1] + '-' + chunks[0] + '-' + chunks[2]; return formattedDate; } function ConvertToJQueryObject(obj) { if (obj) { if (obj.jquery) return obj; //Already a jquery object, nothing to see here else if (obj.nodeType) return $(obj); //DOM object, convert to JQuery else if (obj.indexOf("#") === 0 || obj.indexOf(".") === 0) return $(obj); //ID or Class specified, convert to JQuery else return $("#" + obj); //Assume it's an ID and hopefully returns a JQuery object } } function HtmlEscape(str) { return String(str) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(//g, '>'); } function HtmlUnescape(str) { return String(str) .replace(/"/g, '"') .replace(/'/g, "'") .replace(/</g, '<') .replace(/>/g, '>') .replace(/&/g, '&'); } var MobileColorbox = function (wp, hp) { if (handheldmode) { var $cbc = $(".portal-popup-container"); var ww = $(window).width(); var wh = $(window).height(); var w = $cbc.innerWidth() > ww ? parseInt(ww * (wp || 0.96)) : 0; var h = $cbc.innerHeight() > wh ? parseInt(wh * (hp || 0.94)) : 0; if (w && !h) return { width: w }; else if (!w && h) return { height: h }; else if (w && h) return { width: w, height: h }; else return {}; } else { return {}; } };