if (!String.prototype.startsWith) {
String.prototype.startsWith = function (searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
var pcr_menu_help;
var CURRENT_PAGE_ID = 0;
(function ($) {
var actionSliding = false;
//handlebar helper calculate tile
Handlebars.registerHelper('tileindex', function (index, navIndex) {
navIndex = typeof (navIndex) == "undefined" ? 0 : navIndex;
if (navIndex > 0) {
return "tile" + String(navIndex)
}
return "tile" + ((index % 6) + 1);
});
Handlebars.registerHelper('sysindex', function (index) {
return "systile" + (Math.floor(Math.random() * 5) + 1);
});
Handlebars.registerHelper('breadcrumbseparator', function (index) {
if (index >= 1) {
return new Handlebars.SafeString("/
");
}
return "";
});
Handlebars.registerHelper('ifCond', function (v1, v2, v3, options) {
if (v1 === undefined && v2 === undefined && v3 === undefined) {
return options.inverse(this);
}
return options.fn(this);
});
Handlebars.registerHelper('actionLink', function (href, menuId) {
if (href.indexOf('javascript:') > -1) {
return 'href="javascript:void(0)" onclick="' + href.replace('javascript:', '') + ';' + (($.isNumeric(menuId)) ? 'TrackActionClick(' + menuId + ');' : '') + 'return false;"';
} else {
return 'href="' + href + '"';
}
});
//handlebar helper choose pin or check class
Handlebars.registerHelper('pinclass', function (pinorder) {
if (pinorder < 0) {
return "icon-Pin pin";
}
return "icon-Check check";
});
Handlebars.registerHelper('actionIsPinned', function (val, options) {
var fnTrue = options.fn;
var fnFalse = options.inverse;
return val >= 0 ? fnTrue(this) : fnFalse(this);
});
//processees some menu stuff after it is drawn,
//and sets up all the event bindings
function SetupMenu(context, isMain, sectionid, baseurl, sessionid, pageId) {
try {
var ulClass = ".mainmenu";
if (!isMain) {
ulClass = ".submenu";
}
//filter and order the pinned items
var li = $(".menuLeft " + ulClass + " li", context).filter(function () {
return $(this).attr("data-pin") >= 0;
});
li.sort(function (a, b) {
if (parseInt($(a).attr("data-pin")) > parseInt($(b).attr("data-pin"))) {
return 1;
}
else {
return -1;
}
});
$(".menuLeft " + ulClass, context).empty().html(li);
//filter and order the pinned items
var li = $(".actionSubmenu" + " li", context).filter(function () {
return $(this).attr("data-pin") >= 0;
});
li.sort(function (a, b) {
if (parseInt($(a).attr("data-pin")) > parseInt($(b).attr("data-pin"))) {
return 1;
}
else {
return -1;
}
});
//set up hovering for drop bar
$(".menudropbar", context).hover(
function () { },
function (e) {
var topFirst = $(this).position().top;
var topLast = topFirst + $(this).height();
var left = $(this).position().left;
var leftLast = left + $(this).width();
if ($.browser.msie) {
if (e.pageY > topLast || e.pageY < topFirst || e.pageX > leftLast || e.pageX < left) {
$(this).hide();
}
}
else {
$(this).hide();
$("#submenu").css("z-index", "10000");
}
}
);
if (!isMain) {
var item = $(".menudropbar", context)
var newpos = item.prev().prev().position();
item.css("top", newpos.top);
item.css("left", "0px");
item.css("width", $(window).width() - 50);
}
//disable menu if no items are available
if (!isMain) {
if ($(".menudropbar ul").children().length == 0) {
$(".droplink").hide();
}
}
$(".droplink", context).click(function (e) {
$(".menudropbar", context).stop();
var currentHeight = $(".menudropbar", context).height();
$(".menudropbar", context).height(1);
$("#submenu").css("z-index", "13000");
$(".menudropbar", context).show();
$(".menudropbar", context).animate({
height: currentHeight
}, 200);
return false;
});
//pinning and unpinning actions
$(".actionsContextMenu", context).click(
function (e) {
var pinLink = e.target;
//hide menu after selecting an action
if ($(pinLink).closest(".arrows").length < 1) {
window.setTimeout(function () {
$(".actionsContextMenu").fadeOut();
}, 500);
}
//confirm('add pinned');
if ($(pinLink).hasClass("pin")) {
//want to pin this item
var parentLi = $(pinLink);
var menuId = $(pinLink).parents(".inlineFirst").attr("data-menuid");
var lastId = parseInt($(".inlineFirst " + " li", context).last().attr("data-pin"));
if (isNaN(lastId)) {
lastId = 0;
}
else {
lastId = lastId + 1;
}
var clonedItem = $(pinLink).parents(".inlineFirst").clone();
$(clonedItem).children(".actionPin").remove();
if (!isMain) {
$(clonedItem).removeClass();
$(clonedItem).addClass("actionIcon");
$(clonedItem).css('display', '');
$(clonedItem).css('margin-right', '7px;');
$(".actionMoreText", clonedItem).remove();
$(".arrows", clonedItem).remove();
}
$(".actionSubmenu ", context).append(clonedItem);
$(pinLink).removeClass("pin").removeClass("icon-Pin");
$(pinLink).addClass("check").addClass("icon-Check");
var pinData = {};
pinData.Pin = true;
pinData.MenuItemId = menuId;
pinData.SectionId = pageId;
pinData.ActionMode = true;
var url = baseurl + "?sessionid=" + urlencode(sessionid);
$.post(url, pinData);
DoScrolling(context, isMain);
$('.actionsContextMenu').getNiceScroll().resize();
return false;
}
else if ($(pinLink).hasClass("check")) {
//want to unpin this item
var menuId = $(pinLink).parents(".inlineFirst").attr("data-menuid");
$(".actionsOverflow" + " li[data-menuid='" + menuId + "']", context).remove();
$(pinLink).removeClass("check").removeClass("icon-Check");
$(pinLink).addClass("pin").addClass("icon-Pin");
var pinData = {};
pinData.Pin = false;
pinData.MenuItemId = menuId;
pinData.SectionId = pageId;
pinData.ActionMode = true;
var url = baseurl + "?sessionid=" + urlencode(sessionid);
$.post(url, pinData);
DoScrolling(context, isMain);
$('.actionsContextMenu').getNiceScroll().resize();
return false;
}
else {
//do nothing
}
return true;
}
);
//All code for pinning and unpinning menu drop bar
$(".menudropbar", context).click(
function (e) {
var pinLink = e.target;
if ($(pinLink).hasClass("pin")) {
//want to pin this item
var parentLi = $(pinLink).parent();
var menuId = $(pinLink).parent().attr("data-menuid");
var lastId = parseInt($(".menuLeft " + ulClass + " li", context).last().attr("data-pin"));
if (isNaN(lastId)) {
lastId = 0;
}
else {
lastId = lastId + 1;
}
var clonedItem = $(parentLi).clone();
$(clonedItem).children(".pinbar").remove();
if (!isMain) {
//
//
//confirm(clonedItem[0].tagName);
clonedItem.find('.menuIcon').remove();
//
//
$(clonedItem).removeClass();
var divImg = $(clonedItem).children("a").children("div").first();
var linkItem = $(clonedItem).children("a").first();
linkItem.removeClass("wf");
divImg.children("i").removeClass("icon-inverse").removeClass("icon-large").addClass("icon-med");
//var currentClass = divImg.attr("class");
//currentClass = currentClass.replace("White", "");
//divImg.removeClass();
//divImg.addClass(currentClass);
}
$(".menuLeft " + ulClass, context).append(clonedItem);
$(pinLink).removeClass("pin").removeClass("icon-Pin");
$(pinLink).addClass("check").addClass("icon-Check");
var pinData = {};
pinData.Pin = true;
pinData.MenuItemId = menuId;
pinData.SectionId = sectionid;
var url = baseurl + "?sessionid=" + urlencode(sessionid);
$.post(url, pinData);
DoScrolling(context, isMain);
return false;
}
else if ($(pinLink).hasClass("check")) {
//want to unpin this item
var menuId = $(pinLink).parent().attr("data-menuid");
$(".menuLeft " + ulClass + " li[data-menuid='" + menuId + "']", context).remove();
$(pinLink).removeClass("check").removeClass("icon-Check");
$(pinLink).addClass("pin").addClass("icon-Pin");
var unpinData = {};
unpinData.Pin = false;
unpinData.MenuItemId = menuId;
unpinData.SectionId = sectionid;
var url = baseurl + "?sessionid=" + urlencode(sessionid);
$.post(url, unpinData);
DoScrolling(context, isMain);
return false;
}
else {
//just want to hide the drop bar
$(this).hide();
}
return true;
}
);
//set widths for scrolling
$(ulClass, context).show();
$(window).resize(function () {
ResizeMenu(context);
});
$(document).ready(function () {
ResizeMenu(context, isMain);
if ($.browser.msie) {
$(".mainmenu li a.item, .submenu li a.item").each(function () {
var zindex = 2;
var cloned = $(this).clone().empty();
$(cloned).addClass("cloneditem");
var offset = 0;
if ($(this).parent().children(".pinbar").length > 0) {
zindex = 12;
}
$(cloned).css("position", "absolute");
$(cloned).css("width", $(this).width());
$(cloned).css("height", $(this).height());
$(cloned).css("top", ($(this).position().top) + "px");
// todo KR $(this).position().left
$(cloned).css("left", $(this).position().left + "px");
$(cloned).css("z-index", zindex);
$(cloned).css("display", "block");
$(this).parent().append(cloned);
});
}
});
//actions More
$(".actionsMoreLink").click(function () {
//confirm("dropped actions");
var menuActionBarHeight = 42;
var actionBarNegativeOffset = 10;
menuActionBarHeight += actionBarNegativeOffset;
var menuActionBarBottomPadding = 20;
var contextWidth = 350;
var menuItemHeight = 42;
var menuTopOffset = 0;
var $contextMenu = $(this).parent().nextAll(".actionsContextMenu");
if ($contextMenu.is(":visible")) {
$contextMenu.slideUp(400, function () {
});
}
else {
//confirm($('body').hasClass('globalActionsL'));
if($('body').hasClass('globalActionsL')){
$('.actionsContextMenu').css('right','-320px');
} else {
$('.actionsContextMenu').css('left','unset');
$('.actionsContextMenu').css('right','39px');
}
$(this).addClass("actionsMoreLinkActive");
var maxHeight = $(window).height() - menuActionBarHeight - menuActionBarBottomPadding - 20;
$contextMenu.css("max-height", maxHeight + "px");
$contextMenu.height("");
var left = 0;
var top = ($(this).position().top + $(this).height() + menuTopOffset);
$contextMenu.css("top", top + "px");
actionSliding = true;
var allItems = $contextMenu.children().first().children().length;
var totalDropdownHeight = (allItems - $contextMenu.children().first().children('li[style*="display: none"]').length) * menuItemHeight;
$contextMenu.slideDown(350, function () {
if ($(this).getNiceScroll().length == 0) {
$(this).niceScroll({ zindex: 100001, autohidemode: false, horizrailenabled: false, preservenativescrolling: false });
$(this).getNiceScroll().resize().hide();
} else {
$(this).getNiceScroll().resize().show();
}
if (totalDropdownHeight > maxHeight) { //menu is larger than the viewport
$(this).height($(window).height() - $(this).position().top - 6);
$(this).getNiceScroll().resize().show();
}
else {
$(this).getNiceScroll().resize().hide();
}
actionSliding = false;
if ($(".actionsContextMenuClone").length == 0) {
$(".menuRight").append($(".actionsContextMenu").clone().
addClass("actionsContextMenuClone").css("border", "none").css("backgroundColor", "transparent").css("padding", "40px 25px 20px 20px").
empty().removeClass("actionsContextMenu").css("height", $(".actionsContextMenu").height() + 20).css("zIndex", 1));
//$(".actionsHeader").css("zIndex", 100);
}
$(".actionsContextMenuClone").css("left", $(".actionsContextMenu").position().left - 20).css("height", $(".actionsContextMenu").height() + 20).css("top", $(".actionsContextMenu").position().top - 40).show();
});
}
});
$(".menuRight").on("mouseenter", ".actionsContextMenuClone", function () {
//do nothing
}).on('mouseleave', ".actionsContextMenuClone", function (eventobj) {
if (actionSliding) {
return;
}
if ($(eventobj.relatedTarget).parents(".nicescroll-rails").length == 0 && !$(eventobj.relatedTarget).hasClass('nicescroll-rails')
&& $(eventobj.relatedTarget).parents(".actionsHeader").length == 0 && !$(eventobj.relatedTarget).hasClass('actionsHeader')
&& $(eventobj.relatedTarget).parents(".actionsContextMenu").length == 0 && !$(eventobj.relatedTarget).hasClass('actionsContextMenu')) {
$(".actionsContextMenu").getNiceScroll().hide();
$(".actionsContextMenu").slideUp(350, function () { $(".actionsHeader").hide() });
$(".actionsContextMenu").prev().find(".actionsMoreLink").removeClass("actionsMoreLinkActive");
$(".actionsContextMenu").css("overflow-y", "hidden");
$(".actionsContextMenuClone").css("overflow-y", "hidden");
$(".actionsContextMenuClone").hide();
}
});
//next and previous links for scrolling
var pnl = $(".scrollablePanel", context);
$(".prev", context).click(function () {
var scrollOffset = CalculateScrollOffset(this, true);
//confirm("scroll offset = " + scrollOffset);
$(this).siblings("ul").animate(
{
marginLeft: scrollOffset + "px"
}, 600, function () {
var ulMargin = parseInt(pnl.find("ul").css("marginLeft").replace("px", ""));
var ulWidth = pnl.find("ul").width();
if (ulMargin == 0) {
$(".prev").hide();
}
else {
$(".prev").show();
}
if (ulWidth > pnl.width()) {
$(".next").show();
//$("#scrollDropLink").show();
}
else {
$(".next").hide();
//$("#scrollDropLink").hide();
}
});
$(".menuLeft").find(".submenu").children("li").css("visibility", "visible");
});
$(".next", context).click(function () {
var scrollOffset = CalculateScrollOffset(this, false);
$(this).siblings("ul").animate(
{
marginLeft: scrollOffset + "px"
}, 600, function () {
var ulWidth = pnl.find("ul").width();
var ulMargin = parseInt(pnl.find("ul").css("marginLeft").replace("px", ""));
if ((ulWidth + ulMargin) < pnl.width()) {
$(".next", context).hide();
//$("#scrollDropLink").hide();
$(".prev").show();
}
else {
$(".next", context).show();
//$("#scrollDropLink").show();
$(".prev").show();
}
ToggleHiddenMenuTiles();
});
});
//detail frame breaccrumb must be offset to match with splitter
if (CheckInDetailFrame()) {
$(".breadcrumbBar").addClass("breadcrumbBarDetail");
}
//click off menu
$('body').on('mouseup touchend', function (e) {
if (!e) e = window.event;
var ele = $(e.target);
if (ele.closest('.menuRight').length > 0) {
return;
} else {
$(".actionsContextMenu").fadeOut();
}
});
ResizeMenu(context, isMain);
} catch (e) { alert('Error setting menu: ' + e); }
}
function ToggleHiddenMenuTiles() {
var ct = $(".menuLeft").find(".submenu").children("li").length;
for (var i = 0; i < ct; i++) {
if ($(".menuLeft").find(".submenu").children("li").eq(i).position().left < 0) {
$(".menuLeft").find(".submenu").children("li").eq(i).css("visibility", "hidden");
} else {
$(".menuLeft").find(".submenu").children("li").eq(i).css("visibility", "visible");
}
}
}
function CheckInDetailFrame() {
if (window.frameElement == null) {
return false;
}
if (parent.list != undefined) {
if (parent.detail != undefined) {
if (window.frameElement.name == "detail") {
return true;
}
}
}
return false;
}
function GetMoveClass(cls) {
if (cls.indexOf("moveup") >= 0) {
return "moveup";
}
else if (cls.indexOf("movedown") >= 0) {
return "movedown";
}
else if (cls.indexOf("movetop") >= 0) {
return "movetop";
}
else if (cls.indexOf("movebottom") >= 0) {
return "movebottom";
}
}
function AnimateActionMove(itemToMove, movement) {
var menuid = $(itemToMove).attr("data-menuid");
var circleLink = $(".actionsOverflow").find("a[data-menuid='" + menuid + "']").first();
var circleLinkSwap;
var itemToMoveSwap;
if (movement == "up") {
circleLinkSwap = $(circleLink).prev();
itemToMoveSwap = $(itemToMove).prev();
}
else if (movement == "down") {
circleLinkSwap = $(circleLink).next();
itemToMoveSwap = $(itemToMove).next();
}
if (movement == "up" || movement == "down") {
$(itemToMove).css("position", "relative");
$(itemToMoveSwap).css("position", "relative");
$(circleLink).css("position", "relative");
$(circleLinkSwap).css("position", "relative");
var top1 = $(itemToMove).position().top;
var top2 = $(itemToMoveSwap).position().top;
var left1 = $(circleLink).position().left;
var left2 = $(circleLinkSwap).position().left;
$(itemToMove).animate({
top: "-=" + (top1 - top2)
}, 1000, function () {
});
$(itemToMoveSwap).animate({
top: "+=" + (top1 - top2)
}, 1000, function () {
if (movement == "up") {
$(itemToMove).insertBefore($(itemToMoveSwap));
}
else {
$(itemToMove).insertAfter($(itemToMoveSwap));
}
$(itemToMove).css("position", "");
$(itemToMoveSwap).css("position", "");
$(itemToMove).css("top", "");
$(itemToMoveSwap).css("top", "");
});
$(circleLink).animate({
left: "-=" + (left1 - left2)
}, 1000, function () {
});
$(circleLinkSwap).animate({
left: "+=" + (left1 - left2)
}, 1000, function () {
if (movement == "up") {
$(circleLink).insertBefore($(circleLinkSwap));
}
else {
$(circleLink).insertAfter($(circleLinkSwap));
}
$(circleLink).css("position", "").css("left", "");
$(circleLinkSwap).css("position", "").css("left", "");
});
}
else {
$(itemToMove).parent().children().css("position", "relative");
$(circleLink).parent().children().css("position", "relative");
var itemHeight = $(itemToMove).height();
var itemWidth = 37;
if (movement == "top") {
$(itemToMove).prevAll().each(function () {
$(this).animate({
//top: "-=" + ($(this).position().top - $(this).next().position().top),
top: "+=" + (itemHeight)
}, 1000, function () {
});
});
$(itemToMove).animate({
//top: "-=" + ($(itemToMove).position().top),
top: "-=" + ($(itemToMove).prevAll().length * itemHeight)
}, 1000, function () {
$(itemToMove).insertBefore($(itemToMove).parent().children().first());
$(itemToMove).parent().children().css("position", "relative").css("top", "");
});
$(circleLink).prevAll().each(function () {
$(this).animate({
left: "+=" + (itemWidth)
}, 1000, function () {
});
});
$(circleLink).animate({
left: "-=" + ($(circleLink).prevAll().length * itemWidth)
}, 1000, function () {
$(circleLink).insertBefore($(circleLink).parent().children().first());
$(circleLink).parent().children().css("position", "relative").css("left", "");
});
}
else {
$(itemToMove).nextAll().each(function () {
$(this).animate({
top: "-=" + (itemHeight)
}, 1000, function () {
});
});
$(itemToMove).animate({
top: "+=" + ($(itemToMove).nextAll().length * itemHeight)
}, 1000, function () {
$(itemToMove).insertAfter($(itemToMove).parent().children().last());
$(itemToMove).parent().children().css("position", "relative").css("top", "");
});
$(circleLink).nextAll().each(function () {
$(this).animate({
left: "-=" + (itemWidth)
}, 1000, function () {
});
});
$(circleLink).animate({
left: "+=" + ($(circleLink).nextAll().length * itemWidth)
}, 1000, function () {
$(circleLink).insertAfter($(circleLink).parent().children().last());
$(circleLink).parent().children().css("position", "relative").css("left", "");
});
}
}
}
function ResizeMenu(context, isMain) {
var width = $(".menuLeft", context).width() - $(".leftcol", context).width();
width = width - 50;
var pnl = $(".scrollablePanel", context);
pnl.width(width);
//set up scrollbars
DoScrolling(context, isMain);
}
function PositionDropLink(showScroll, context, isMain) {
var pnl = $(".scrollablePanel", context);
var dropdownOffset = 0;
var dropLinkPosition = 0;
if (showScroll) {
dropdownOffset = 35;
dropLinkPosition = pnl.position().left + pnl.width();
}
else {
dropdownOffset = 13;
if (!isMain) {
dropdownOffset = 20;
}
var $ul = pnl.children("ul");
dropLinkPosition = $ul.position().left + $ul.width();
}
$("#scrollDropLink").css("left", dropLinkPosition + dropdownOffset + 'px');
}
function DoScrolling(context, isMain) {
try {
var pnl = $(".scrollablePanel", context);
pnl.removeClass("nopins")
var lastItem = pnl.children("ul").children("li").last();
var showScroll = false;
try {
if (lastItem.position().left + lastItem.width() > pnl.position().left + pnl.width()) {
showScroll = true;
}
} catch (ex) { }
var nextOffset = 11;
var dropdownOffset = 41;
var prevButtonOffset = -4;
var topOffset = -4;
if (showScroll) {
$(".prev", context).css("left", pnl.position().left + prevButtonOffset);
var nextLeftPosition = pnl.position().left + pnl.width();
PositionDropLink(true, context, isMain);
$(".next", context).css("left", nextLeftPosition + nextOffset).show();
}
else {
$(".prev", context).click();
$(".next", context).hide();
//$("#scrollDropLink").hide();
PositionDropLink(false, context, isMain);
if (lastItem.length == 0) {
//no items pinned, special class for scrollable panel
pnl.addClass("nopins")
}
}
if (pnl.position().left == 0) { $(".prev", context).hide(); }
}
catch (ex) { }
}
function CalculateScrollOffset(item, isPrevious) {
var marginLeft = parseInt($(item).siblings("ul").css("margin-left").replace("px", ""));
var width = parseInt($(item).parent().width());
var defaultOffset = 0;
var itemMargin = -10;
//previuos clicked
if (isPrevious) {
defaultOffset = marginLeft + width;
var cutoffLine = $(item).parent().position().left;
if (defaultOffset > 0) {
defaultOffset = 0;
}
else {
$(item).siblings("ul").children("li").each(function () {
var left = $(this).offset().left;
if (left < cutoffLine && $(this).width() + itemMargin > cutoffLine) {
defaultOffset = cutoffLine - left + marginLeft;
}
});
}
return 0;
return defaultOffset;
}
//next clicked
else {
defaultOffset = marginLeft - width;
var cutoffLine = $(item).parent().position().left + width;
$(item).siblings("ul").children("li").each(function () {
var left = $(this).offset().left;
//find first item that is cut off or over the line
if ((left > cutoffLine) || (left < cutoffLine && left + $(this).width() + itemMargin > cutoffLine)) {
defaultOffset = left - (cutoffLine - width) + itemMargin - marginLeft;
defaultOffset = defaultOffset * -1;
return false;
}
else if ($(this).next().length == 0) {
defaultOffset = marginLeft;
return false;
}
});
return defaultOffset;
}
}
function SetupSystemMenu(jqItem, baseurl, sessionid) {
//add onclick handler for system menu
$(".sysmenu li").on("click", function () {
//navigate the list frame
if ($(this).attr("data-href").indexOf("##") != 0) {
if ($(this).attr("data-target") == "list") {
document.location.href = $(this).attr("data-href");
}
else {
navigateDetail($(this).attr("data-href"));
}
}
});
$("#menuFilter").on("keypress", function (event) {
alert(String.fromCharCode(event.which));
});
}
function SetupHeadMenu(sessionid) {
$('#qaddN').click(function () { openIFrameMin('addCand', 'Add Candidate Wizard', '/pcrbin/name.exe?user=&DoAction=QuickAdd&pcr-id=' + urlencode(sessionid)); });
$('#qaddC').click(function () { openIFrameMin('addCom', 'Add Company Wizard', '/pcrbin/company.exe?user=&DoAction=QuickAdd&pcr-id=' + urlencode(sessionid)); });
$('#qaddP').click(function () { openIFrameMin('addPos', 'Add Position Wizard', '/pcrbin/position.exe?user=&DoAction=QuickAdd&pcr-id=' + urlencode(sessionid)); });
$('#qaddI').click(function () { openIFrameMin('addInt', 'Add Interview Wizard', '/pcrbin/sendout.exe?user=&DoAction=QuickAdd&pcr-id=' + urlencode(sessionid)); });
$('.menufy').menufy();
// setup head menu
window.instantLoadWijmoMenu($(".dropHeadMenu"));
var arrowOffsetFromEdge = 12;
//$("#menu_headMenu").wijmenu("option", "position", { my: "right top", at: "right+" + arrowOffsetFromEdge + " bottom" });
var currentWidth = $(".menuRight .headMenu .wijmo-wijmenu").width();
var currentLeft = $(".menuRight .headMenu .wijmo-wijmenu").position().left;
var menuWidth = 150;
var diff = menuWidth - currentWidth;
if (diff > 0) {
$(".menuRight .headMenu .wijmo-wijmenu").css("width", menuWidth + "px");
//$(".menuRight .headMenu .wijmo-wijmenu").css("left", (currentLeft - diff) + "px");
$(".menuRight .headMenu .wijmo-wijmenu").css("right", "3px");
$(".menuRight .headMenu .wijmo-wijmenu").css("left", "auto");
}
$("#photoLink").click(function () {
openIFrame('Upload Photo', '/pcrbin/editna.exe?user=&action=UploadPhoto&usermode=1&pcr-id=' + urlencode(sessionid), 600, 600);
return false;
});
top['runAfterPCRLibLoaded'](function(){
top['NotificationsManager'].initializeNotifications();
});
}
//main entry point for jquery plugin
$.fn.pcrmenu = function (options) {
this.initialize = function () {
var cache = true;
var settings = $.extend({
'baseurl': '/rest/uiapi/menu',
'sectionid': 100,
'type': 'sub',
'menuid': 0,
'params': "",
'sessionid': "",
'username': "",
'NameAccess': "",
'PositionAccess': "",
'CompanyAccess': "",
'callback': undefined
}, options);
var jqItem = this;
var template = "menu.html";
var isMain = true;
var isSystem = false;
if (settings["type"] == "sub") {
template = "submenu.html";
isMain = false;
}
if (settings["type"] == "sys") {
template = "systemmenu.html";
isMain = false;
isSystem = true;
}
CURRENT_PAGE_ID = settings["menuid"];
var dataUrl = settings["baseurl"] + "/" + settings["menuid"] + "?" + settings["params"];
var verStamp = $("#verstamp").attr("data-pcr-verstamp");
if (verStamp == null) { verStamp = window.versionstamp; }
$.get(dataUrl,
function (data) {
if (!isMain) {
var help = GetDataForHelp(data,
settings["menuid"],
settings["sessionid"],
settings["sectionid"]);
pcr_menu_help = help;
}
url = "/pcrimg/inc/templates/" + template;
if (verStamp !== undefined) {
url += "?ver=" + verStamp;
}
var banners = [];
var links = data.HeadMenu.Links;
for (var l in links) {
if (links.hasOwnProperty(l) && l.startsWith("banner")) {
banners.push(links[l]);
}
};
data.Banners = banners;
$.ajax({
url: url,
cache: cache,
async: true,
success: function (template) {
template = Handlebars.compile(template);
jqItem.html(template(data));
if (!isSystem) {
SetupMenu(jqItem, isMain, settings["sectionid"], settings["baseurl"], settings["sessionid"], settings["menuid"]);
}
else {
SetupSystemMenu(jqItem, settings["baseurl"], settings["sessionid"]);
}
if (isMain) {
$("#mSessionId").val(settings["sessionid"]);
SetupHeadMenu(settings["sessionid"]);
//update title data
try {
if (window.sessiondisplay) {
var userinfo = JSON.parse(window.sessiondisplay);
$('#photoLink').attr('title', userinfo.user + '/' + userinfo.databasedesc);
}
} catch (e) {
//no action
}
try {
if (typeof hasQuicksearch !== 'undefined' && hasQuicksearch) {
$(".headQuickSearch").css("display", "flex");
$("#qsearch").quicksearch({
pcrId: settings["sessionid"],
userName: settings["username"],
NameAccess: settings["NameAccess"],
PositionAccess: settings["PositionAccess"],
CompanyAccess: settings["CompanyAccess"],
overlay: "listtd"
});
}
} catch (e) { alert("Quicksearch Setup Error: " + e); }
}
if (settings['callback'] != undefined) {
settings['callback']();
}
$("li[data-menuid='" + settings["menuid"] + "']").addClass("activeSubmenu");
//try {
//google analytics
//window.setTimeout(function () { trackPageView(); }, 1000);
//}
//catch (e) { }
try {
var title = "";
var crumbs = 0;
if (data.Breadcrumbs.length > 0) {
while (crumbs < data.Breadcrumbs.length) {
check = crumbs + 1;
if (check < data.Breadcrumbs.length) {
if (data.Breadcrumbs[check].Text.indexOf("custom") > 0) {
title += data.Breadcrumbs[crumbs].Text;
break;
}
else {
title += data.Breadcrumbs[crumbs].Text + " - "
}
}
else {
title += data.Breadcrumbs[crumbs].Text;
}
crumbs++;
}
document.title = title;
}
}
catch (ex) { }
menuSetActive();
if (top.portrait === true && !isMain) {
$(".countContainer").css("margin-right", "10px");
}
}
});
});
return this;
};
return this.initialize();
};
})(jQuery);
function GetDataForHelp(data, menuId, sessionid, sectionid) {
var HELP_ACTION_ID = -99;
var SYSTEM_MENU_ID_ROOT = 20000;
var REPORT_MENU_ID_ROOT = 9000;
var help = {};
var ids = [];
var descs = [];
var imgs = [];
var pageFound = false;
help["sectionid"] = sectionid;
help["sessionid"] = sessionid;
for (var i = 0; i < data.Navigations.length; i++) {
if (data.Navigations[i].Id == menuId) {
var nav = {};
nav.id = data.Navigations[i].Id;
nav.desc = data.Navigations[i].Text;
nav.img = data.Navigations[i].Img;
//ids.push(data.Navigations[i].Id);
//descs.push(data.Navigations[i].Text);
//imgs.push(data.Navigations[i].Img);
help.nav = nav;
pageFound = true;
break;
}
}
//this is for search results and pages that are not on the navigation
if (!pageFound) {
if (menuId != SYSTEM_MENU_ID_ROOT && menuId != REPORT_MENU_ID_ROOT) {
var nav = {};
nav.id = menuId;
var desc = "";
try {
desc = data.Breadcrumbs[data.Breadcrumbs.length - 1].Text;
} catch (e) {/*screens without breacrumbs */ }
var spl = desc.split("/");
nav.desc = spl[spl.length - 1];
if (data.MenuContainerImg) {
nav.img = data.MenuContainerImg;
} else {
nav.img = 'icon-Resume';
}
help.nav = nav;
}
}
help.actions = data.Actions;
return help;
}
//Sets the counts of the tiles, count is required then pass
//dataMenuId or iconClass to find the appropiate tile to update
function SetTileCount(count, dataMenuId, iconClass, labelText) {
dataMenuId = (typeof dataMenuId === "undefined") ? "" : dataMenuId;
iconClass = (typeof iconClass === "undefined") ? "" : iconClass;
labelText = (typeof labelText === "undefined") ? "" : labelText;
var $textNode;
if (dataMenuId != "") {
$textNode = $("li[data-menuid='" + dataMenuId + "']").find("span");
} else if (iconClass != "") {
$textNode = $("." + iconClass).parent().next();
}
if (labelText != "") {
var txt = labelText;
} else {
var txt = $textNode.first().text();
}
if (dataMenuId == "" && labelText == "") {
dataMenuId = $textNode.parents("li").attr("data-menuid");
}
if ($(".breadcrumbBar").find("#count-" + dataMenuId).length > 0) {
$(".breadcrumbBar").find("#count-" + dataMenuId).text(txt + " " + count);
} else {
var $sel = $(".bcright");
if ($(".countContainer").length == 0) {
$sel.append($(""));
}
$sel.find(".countContainer").append("" + txt + " " + count + "");
}
}
function SetNameTileCount(count, dataMenuId, iconClass, labelText, caid, pcrid) {
dataMenuId = (typeof dataMenuId === "undefined") ? "" : dataMenuId;
iconClass = (typeof iconClass === "undefined") ? "" : iconClass;
labelText = (typeof labelText === "undefined") ? "" : labelText;
var $textNode;
if (dataMenuId != "") {
$textNode = $("li[data-menuid='" + dataMenuId + "']").find("span");
} else if (iconClass != "") {
$textNode = $("." + iconClass).parent().next();
}
if (labelText != "") {
var txt = labelText;
} else {
var txt = $textNode.first().text();
}
if (dataMenuId == "" && labelText == "") {
dataMenuId = $textNode.parents("li").attr("data-menuid");
}
if ($(".breadcrumbBar").find("#count-" + dataMenuId).length > 0) {
$(".breadcrumbBar").find("#count-" + dataMenuId).text(txt + " (" + count + ")");
} else {
var $sel = $(".bcright");
if ($(".countNameContainer").length == 0) {
var menu = '';
menu += '';
$sel.prepend($(menu))
.mouseleave(function () {
debounce = setTimeout(closeMenu, 400);
});
var debounce;
var closeMenu = function () {
$(".countContainerDIV").fadeOut();
clearTimeout(debounce);
}
}
$sel.find('.countContainerUL').append('' + txt + ' (' + count + ')');
}
}
function ShowNameTileCount(caid, pcrid) {
$('.countContainerDIV').fadeIn();
$('.quickAddContextMenu').css('top', $('.breadcrumbBar').height());
$.ajax({
url: "/pcrbin/name.exe?DoAction=MenuCounts&caid=" + caid + "&pcr-id=" + urlencode(pcrid),
type: "post",
datatype: 'json'
})
.success(function (data) {
$('#IntCount').text(data['counts'].interviews);
$('#AttCount').text(data['counts'].attachments);
});
}
function charmSelected(className) {
$("ul.charmbar li").removeClass("selected");
$("ul.charmbar li." + className).addClass("selected");
}
function UpdateUserInfo(username, fullName, imageUrl) {
if (username !== "") {
$("#headUserName").text(username);
}
if (fullName !== "") {
$("#headFullName").text(fullName);
}
if (imageUrl !== "") {
$("#photoLink").children("img").attr("src", imageUrl);
}
}
//takes any number of parameters and toggles the action
//icon. Should be called in menu callback
//Hides all other action icons and only shows the ones in args.
//params; any number of string action icon names
function ShowActionIcons() {
$(".actionsOverflow .actionIcon").hide();
$(".actionsContextMenu #actionScroll > li").hide();
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (arg.indexOf(".") != 0) {
arg = "." + arg;
}
$(".actionsOverflow ").find(arg).parent("li").show();
$(".actionsContextMenu").find(arg).parents("li").show();
//$(arg).show();
}
ShowHelp();
}
function HideActionIcons() {
$(".actionOverflow .actionIcon").show();
$(".actionsContextMenu #actionScroll > li").show();
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (arg.indexOf(".") != 0) {
arg = "." + arg;
}
//$(arg).hide();
$(".actionsOverflow ").find(arg).parent("li").hide();
$(".actionsContextMenu").find(arg).parents("li").hide();
}
ShowHelp();
}
function GetMenuAnalyticsNameFromId(menuId) {
var menuName = _MapIdToBaseSection(menuId);
menuName += "/";
var pageName = $(".menudropbar li[data-menuid='" + menuId + "']").find("span").text();
if (pageName) pageName = pageName.trim();
menuName += pageName;
return menuName;
}
function setMargin() {
if ($("#picture")) {
setTimeout("document.getElementById('menubar').style.marginLeft = '50px'", 500);
}
}
function GetActionAnalyticsNameFromId(menuId, actionId) {
var menuName = GetMenuAnalyticsNameFromId(menuId);
var actionName = $(".actionsOverflow li[data-menuid='" + actionId + "'] a").attr("title");
if (actionName) actionName = actionName.trim();
menuName += "-" + actionName;
return menuName;
}
function _MapIdToBaseSection(id) {
var baseName = "";
//company
if (id < 3000) {
baseName = "Company";
}
else if (id < 4000) {
baseName = "Name";
}
else if (id < 5000) {
baseName = "Position";
}
else if (id < 6000) {
baseName = "Activity";
}
else if (id < 7000) {
baseName = "Schedule";
}
else if (id < 9000) {
baseName = "Rollups";
}
else if (id < 11000) {
baseName = "Reports";
}
else if (id == 11000) {
baseName = "Help";
}
else if (id == 15000) {
baseName = "HelpDesk";
}
else if (id == 12000) {
baseName = "Logout";
}
else if (id < 14000) {
baseName = "Layout";
}
else if (id < 15000) {
baseName = "Contract";
}
else if (id < 17000) {
baseName = "Email";
}
else if (id < 18000) {
baseName = "Planner";
}
else {
baseName = "System";
}
return baseName;
}
function TrackActionClick(actionId) {
var actionName = GetActionAnalyticsNameFromId(CURRENT_PAGE_ID, actionId);
window.setTimeout(function () { trackPageView(actionName, "actionclick"); }, 1000);
}
function ShowHelp() {
$(".actionsOverflow .icon-Help").show();
$(".actionsContextMenu").find(".icon-Help").parents("li").show();
}
// Added functions for Rollup list window to have access to them.
var globalMenuFunctions = {
lht: 0,
restorepos: '0',
isMaximized: false,
isMinimized: false,
moveto: '425',
hasMainMenu: true,
scrollOff: function () {
//$($('#listframe')[0].contentWindow.document.body).css('overflowY', 'hidden');
//$($('#detailframe')[0].contentWindow.document.body).css('overflowY', 'hidden');
},
maximize: function () {
//if (!this.isMinimized) restorepos = this.moveto;
this.moveto = 0;
//$(".max").hide();
$(".restore").show().find(".icon-restore").addClass("icon-rotate180").addClass("minrestore").removeClass("maxrestore");
$(".min").show();
this.isMaximized = true;
this.isMinimized = false;
this.resizePageContent(true);
},
minimize: function () {
//if (!this.isMaximized) restorepos = this.moveto;
if (this.hasMainMenu == true) {
this.moveto = $(window).height() - 35 - $('#mainmenu').height() - $('#topBanner').height();
} else {
this.moveto = $(window).height() - 45 - $('#topBanner').height();
}
//$(".min").hide();
$(".max").show();
$(".restore").show().find(".icon-restore").removeClass("icon-rotate180").addClass("maxrestore").removeClass("minrestore");
this.isMinimized = true;
this.resizePageContent(true);
},
restore: function () {
//alert(this.restorepos);
this.moveto = this.restorepos;
$(".max").show();
$(".min").show();
//$(".restore").hide();
//restorepos = this.moveto;
this.isMaximized = false;
this.isMinimized = false;
this.resizePageContent(true);
if (this.hasMainMenu == false) {
$($('#detailframe')[0].contentWindow.document.body).css('overflow-x', '');
$($('#detailframe')[0].contentWindow.document.body).css('overflow-y', 'auto');
}
},
scrollOn: function () {
//$($('#listframe')[0].contentWindow.document.body).css('overflowY', 'auto');
//if (this.isMinimized == false) {
// $($('#detailframe')[0].contentWindow.document.body).css('overflowY', 'auto');
//}
},
resizeiframe: function (x) {
if (IsTouchDevice()) {
//$('#detailtd').height($(window).height() - 350);
//return;
}
if ($('body').hasClass('dashboard')) {
return;
}
//portrait mode uses CSS resizing
if (window.portrait) {
return;
}
var listht = 0;
var hasMainMenu = true;
var menuheight = 0;
//if there is no main menu the calculations need adjusteed (happens from rollups in new windows with a detail frame.)
if ($('#mainmenu').length < 1) {
this.hasMainMenu = false
}
if (this.hasMainMenu == true) {
if (menuheight < 2) {
menuheight = 50;
} else {
menuheight = $('#mainmenu').height();
}
listht = $('#listtd').height();
} else {
var frameoffset = $('#detailtd').offset();
listht = frameoffset.top;
}
var ht = $(window).height() - listht - menuheight - $('#splitter').height();
ht = ht - 4;
if (this.isMinimized === true) {
$('#detailtd').height(20);
} else {
$('#detailtd').height(ht);
}
this.lht = 0;
//trigger resize event to make sure quicksearch results resize with frame
$('#listtd').triggerHandler("resize");
},
resizePageContent: function (animate) {
if (IsTouchDevice()) {
//$('#listtd').css('height', 'auto').css('overflow', 'visible');
//$('#detailtd').height($(window).height()).css('overflow', 'visible');
//return;
}
if ($('body').hasClass('dashboard')) {
return;
}
//portrait mode uses CSS resizing
if(window.portrait) {
return;
}
mh = 0;
if (animate) {
this.lht = this.moveto - mh + 5;
this.resizeiframe();
this.scrollOff();
$('#listtd').stop().animate({
height: (this.moveto - mh + 5)
}, {
duration: 300,
easing: 'easeOutQuint',
complete: function () {
globalMenuFunctions.resizeiframe(true);
globalMenuFunctions.scrollOn();
}
});
} else {
$('#listtd').height(this.moveto - mh + 5);
this.resizeiframe();
}
if (this.isMinimized == true) {
$($('#detailframe')[0].contentWindow.document.body).css('overflow-x', 'hidden');
$($('#detailframe')[0].contentWindow.document.body).css('overflow-y', 'hidden');
}
},
//returns true/false if the current menu/actions have been loaded (UIAPI)
isMenuLoaded: function() {
return $('.menuLeft').length > 0 ? true : false;
},
hideNav: function(navClassName) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.hideNav(navClassName); }).bind(this), 100);
}
else {
$('.menuLeft .icon-med.' + navClassName).closest('li').hide();
}
},
showNav: function(navClassName) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.showNav(navClassName); }).bind(this), 100);
}
else {
$('.menuLeft .icon-med.' + navClassName).closest('li').show();
}
},
hideAction: function(actionClassName) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.hideAction(actionClassName); }).bind(this), 100);
}
else {
$('.menuRight .icon-med.' + actionClassName).closest('li').hide();
}
},
showAction: function(actionClassName) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.showAction(actionClassName); }).bind(this), 100);
}
else {
$('.menuRight .icon-med.' + actionClassName).closest('li').show();
}
},
hideActionById: function(id) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.hideActionById(id); }).bind(this), 100);
}else{
$("a[data-menuid='" + id + "']").hide();
$("li[data-menuid='" + id + "']").hide();
}
},
showActionById: function(id) {
if(!this.isMenuLoaded()) {
setTimeout((function() { this.showActionById(id); }).bind(this), 100);
}else{
$("a[data-menuid='" + id + "']").show();
$("li[data-menuid='" + id + "']").show();
}
}
}
function menuSetActive(e){
try{
var ul = $(e.target).closest('ul');
ul.find('li').removeClass('main-menu-active');
var li = ul.find('li');
var activeli = $(e.target).closest('li');
activeli.addClass('main-menu-active');
} catch(e) {
var li = $('.mainmenu').find('li');
}
li.each(function(){
var t = $(this).find('i');
var iconclass = t.attr('class');
if(iconclass && iconclass.indexOf('-solid') > -1) {
t.removeClass(iconclass);
t.removeClass(iconclass + '-solid');
t.addClass(iconclass.replace(/-solid/ig,''));
}
if($(this).hasClass('main-menu-active')) {
t.removeClass(iconclass + '-solid');
t.removeClass(iconclass);
t.removeClass(iconclass.replace(/-solid/ig,''));
t.addClass(iconclass.replace(/-solid/ig,'') + '-solid');
}
}
);
}
/* Move the actions menu function click handler */
function pcrmoveactions(e){
//alert(e);
$('.actionsContextMenu').hide();
if($('body').hasClass('globalActionsL')){
localStorage['menuLeft'] = 'n';
$('body').removeClass('globalActionsL');
} else {
localStorage['menuLeft'] = 'y';
$('body').addClass('globalActionsL');
}
}
$( document ).ready(function() {
if(localStorage['menuLeft']==='y'){
$('body').addClass('globalActionsL');
}
});