123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158 |
- CCPopupMenu.menus = [];
- CCPopupMenu.activeMenu = null;
- CCPopupMenu.bIgnoreHideActiveMenu = false;
- CCPopupMenu.minSize = 3;
- var sPopUpWebRoot = "..";
- if (window.g_PS_getWebRoot) {
- if (g_PS_getWebRoot() != "") {
- sPopUpWebRoot = g_PS_getWebRoot();
- }
- }
- CCPopupMenu.imagesRoot = sPopUpWebRoot + "/ps";
- CCPopupMenu.psImagesPath = CCPopupMenu.imagesRoot + "/images";
- CCPopupMenu.portalImagesPath = CCPopupMenu.imagesRoot + "/portal/images";
- function addEvent(obj, evType, fn) {
- if (obj.addEventListener) {
- obj.addEventListener(evType, fn, false);
- return true;
- } else if (obj.attachEvent) {
- var r = obj.attachEvent("on" + evType, fn);
- return r;
- } else {
- return false;
- }
- }
- var extensions = {
- associate: function (target, obj, methodName) {
- return function (e) {
- e = e || window.event;
- return obj[methodName](e, target);
- };
- }
- };
- function removeEvent(obj, type, fn) {
- if (obj.removeEventListener) {
- return obj.removeEventListener(type, fn, false);
- } else if (obj.detachEvent) {
- return obj.detachEvent('on' + type, fn);
- } else {
- return false;
- }
- }
- function haltEventProcessing(event) {
- event.cancelBubble = 'true';
- event.returnValue = 'false';
-
- if (event.stopPropagation) {
- event.stopPropagation();
- event.preventDefault();
- }
- return false;
- }
- function windowWidth() {
- if (window.innerWidth) {
- return window.innerWidth;
- } else {
- return document.body.offsetWidth - 20;
- }
- }
- function getDropDownHeight(dropDownElement) {
- var indexOfPX;
- if (dropDownElement.style.height == "") {
- var height = dropDownElement.offsetHeight;
-
- if (window.navigator.userAgent.indexOf("Gecko") != -1) {
- var paddingTop = dropDownElement.style.paddingTop;
- indexOfPX = paddingTop.indexOf("px");
- var v = ((indexOfPX != -1) ? parseInt(paddingTop.substring(0, indexOfPX), 10) : parseInt(paddingTop, 10));
- height -= (isNaN(v) ? 0 : v);
- var paddingBottom = dropDownElement.style.paddingBottom;
- indexOfPX = paddingBottom.indexOf("px");
- v = ((indexOfPX != -1) ? parseInt(paddingBottom.substring(0, indexOfPX), 10) : parseInt(paddingBottom, 10));
- height -= (isNaN(v) ? 0 : v);
- var borderWidth = 1;
- height -= (2 * borderWidth);
- }
- return height;
- } else {
-
- var styleHeight = dropDownElement.style.height;
- indexOfPX = styleHeight.indexOf("px");
- if (indexOfPX != -1) {
- styleHeight = styleHeight.substring(0, indexOfPX);
- }
- return parseInt(styleHeight, 10);
- }
-
- }
- function getDropDownWidth(dropDownElement) {
- var indexOfPX;
- if (dropDownElement.style.width == "") {
- var width = dropDownElement.offsetWidth;
- if (window.navigator.userAgent.indexOf("Gecko") != -1) {
- var paddingLeft = dropDownElement.style.paddingLeft;
- indexOfPX = paddingLeft.indexOf("px");
- var v = ((indexOfPX != -1) ? parseInt(paddingLeft.substring(0, indexOfPX), 10) : parseInt(paddingLeft, 10));
- width -= (isNaN(v) ? 0 : v);
- var paddingRight = dropDownElement.style.paddingRight;
- indexOfPX = paddingRight.indexOf("px");
- v = ((indexOfPX != -1) ? parseInt(paddingRight.substring(0, indexOfPX), 10) : parseInt(paddingRight, 10));
- width -= (isNaN(v) ? 0 : v);
- var borderWidth = 1;
- width -= (2 * borderWidth);
- }
- return width;
- } else {
-
- var styleWidth = dropDownElement.style.width;
- indexOfPX = styleWidth.indexOf("px");
- if (indexOfPX != -1) {
- styleWidth = styleWidth.substring(0, indexOfPX);
- }
- return parseInt(styleWidth, 10);
- }
- }
- function getScrollXY() {
- var scrOfX = 0, scrOfY = 0;
- if (typeof window.pageYOffset == 'number') {
-
- scrOfY = window.pageYOffset;
- scrOfX = window.pageXOffset;
- } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
-
- scrOfY = document.body.scrollTop;
- scrOfX = document.body.scrollLeft;
- } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
-
- scrOfY = document.documentElement.scrollTop;
- scrOfX = document.documentElement.scrollLeft;
- }
- return [scrOfX, scrOfY];
- }
- function windowHeight() {
-
- if (window.innerHeight) {
- return window.innerHeight + getScrollXY()[1];
- } else {
- return document.body.offsetHeight + getScrollXY()[1];
- }
- }
- function setOverflowStyle(anEl) {
-
- if (window.navigator.userAgent.indexOf("Gecko") != -1) {
- anEl.style.overflow = "-moz-scrollbars-vertical";
- } else {
- anEl.style.overflowY = "auto";
- }
- }
- function CCPopupMenu_setControlFocus() {
- var currentMenu = CCPopupMenu.getMenu(CCPopupMenu.activeMenu.id);
- var controlElement = document.getElementById(currentMenu.controlId);
- if (controlElement != null) {
- controlElement.focus();
- }
- }
- function CCPopupMenu_checkBounds(event) {
- if (typeof event != "undefined" && event != null && CCPopupMenu.activeMenu.doCheckBounds) {
- var tr = event.srcElement;
- var table = tr.parentNode;
- var id = CCPopupMenu.activeMenu.id;
- if (tr.tagName == 'TR') {
- if (window.event.keyCode == 27 || window.event.keyCode == 13 || window.event.keyCode == 38 || window.event.keyCode == 40) {
- return true;
- }
- if (tr.rowIndex == 0 && event.shiftKey && event.shiftKey != false) {
- CCPopupMenu.hideActiveMenu();
- CCPopupMenu.setControlFocus();
- return false;
- } else if ((tr.rowIndex + 1) == table.rows.length && window.event.shiftKey == false) {
- CCPopupMenu.hideActiveMenu();
- CCPopupMenu.setControlFocus();
- return false;
- }
- }
- }
- return true;
- }
- function CCPopupMenu_hideActiveMenu() {
- if (!CCPopupMenu.bIgnoreHideActiveMenu && CCPopupMenu.activeMenu != null) {
- CCPopupMenu.activeMenu.activeMenuItemIndex = -1;
- CCPopupMenu.activeMenu.removeDropDown();
- }
- }
- function CCPopupMenu_ignoreHideActiveMenu(ignore) {
- CCPopupMenu.bIgnoreHideActiveMenu = (ignore == "ignore") ? true : false;
- }
- function CCPopupMenu_createInsulatingIframe(currentMenu, divEl) {
- var iframeEl = document.createElement("iframe");
- iframeEl.id = currentMenu.id + "inslIframe";
- iframeEl.setAttribute("role","presentation");
- iframeEl.title = currentMenu.id;
- iframeEl.style.display = "block";
- iframeEl.style.border = "0px";
- iframeEl.style.padding = "2px";
- iframeEl.style.position = "absolute";
- iframeEl.style.zIndex = "1";
- iframeEl.tabIndex = "-1";
-
- iframeEl.src = CCPopupMenu.psImagesPath + "/space.gif";
-
- var controlEl = document.getElementById(currentMenu.controlId);
- controlEl.appendChild(iframeEl);
-
- iframeEl.style.top = divEl.style.top;
- iframeEl.style.left = divEl.style.left;
- iframeEl.style.right = divEl.style.right;
- iframeEl.style.height = divEl.offsetHeight;
- iframeEl.style.width = divEl.offsetWidth;
- }
- function CCPopupMenu_sizeDropDown(dropDownElement, maxHeight, elementHeight) {
-
-
- if (this.mnHeight != -1) {
- var elems = dropDownElement.getElementsByTagName('td');
- providedHeight = elementHeight * this.mnHeight;
-
- var allowableHeight = Math.min(maxHeight, providedHeight);
- allowableHeight = providedHeight;
- if (dropDownElement.offsetHeight > allowableHeight) {
- dropDownElement.style.height = allowableHeight + "px";
- }
- } else {
- if (getDropDownHeight(dropDownElement) > maxHeight) {
- dropDownElement.style.height = maxHeight + "px";
- }
- }
- }
- function CCPopupMenu_fitHeightToBrowser(x, y) {
- var dropDownElement = this.dropDownElement;
- getDropDownWidth(dropDownElement);
- var winHeight = windowHeight();
- var originalMenuHeight = this.mnHeight;
- var originalHeight = getDropDownHeight(dropDownElement);
- var originalWidth = getDropDownWidth(dropDownElement);
- dropDownElement.style.height = originalHeight + "px";
- var controlElement = document.getElementById(this.controlId);
- var controlElementTop = y;
- var controlElementHeight = 0;
- if (controlElement != null) {
- controlElementTop = controlElement.offsetTop;
- controlElementHeight = getDropDownHeight(controlElement);
- }
-
-
- var spaceAboveControl = Math.max(0, controlElementTop);
- var spaceBelowControl = Math.max(0, winHeight - controlElementTop - controlElementHeight);
-
-
- var elems = dropDownElement.getElementsByTagName('td');
- var elementHeight = 20;
- if (elems.length > 0) {
- elementHeight = getDropDownHeight(elems[1]);
- }
-
-
-
- var minimumDropSize = Math.min(CCPopupMenu.minSize, this.menuItems.length) * elementHeight;
-
-
- this.sizeDropDown(dropDownElement, spaceBelowControl, elementHeight);
-
- var downHeight = getDropDownHeight(dropDownElement);
- var downWidth = getDropDownWidth(dropDownElement);
-
-
- dropDownElement.style.height = originalHeight + "px";
- dropDownElement.style.width = originalWidth + "px";
-
- this.sizeDropDown(dropDownElement, spaceAboveControl, elementHeight);
- var upHeight = getDropDownHeight(dropDownElement);
- var upWidth = getDropDownWidth(dropDownElement);
-
- dropDownElement.style.height = originalHeight + "px";
- dropDownElement.style.width = originalWidth + "px";
-
-
- if (downHeight < upHeight) {
-
-
- if (upHeight < minimumDropSize) {
-
- dropDownElement.style.height = minimumDropSize + "px";
- dropDownElement.style.top = y + controlElement.offsetHeight + "px";
- } else {
-
- dropDownElement.style.top = (controlElementTop - upHeight) + "px";
- dropDownElement.style.width = upWidth + "px";
- }
- } else {
-
-
-
-
- if (downHeight < minimumDropSize) {
- downHeight = minimumDropSize;
- }
- dropDownElement.style.width = downWidth + "px";
- dropDownElement.style.height = downHeight + "px";
- dropDownElement.style.top = y + controlElement.offsetHeight + "px";
- }
-
-
-
- if (getDropDownHeight(dropDownElement) < originalHeight) {
-
-
- dropDownElement.style.width = (getDropDownWidth(dropDownElement) + 20) + "px";
- setOverflowStyle(dropDownElement);
- }
- this.mnHeight = originalMenuHeight;
- }
- function CCPopupMenu_fitWidthToBrowser(x, y) {
- var controlElement = document.getElementById(this.controlId);
- if (controlElement == null) {
-
- return;
- }
- var dropDownElement = this.dropDownElement;
-
- var rtl=document.body.dir=="rtl";
- if(rtl)
- CCPopupMenu_fitWidthToBrowserRTL(controlElement, dropDownElement, x, y);
- else
- CCPopupMenu_fitWidthToBrowserLTR(controlElement, dropDownElement, x, y);
- }
- function CCPopupMenu_fitWidthToBrowserLTR(controlElement, dropDownElement, x, y) {
- var controlElementLeft = controlElement.offsetLeft;
-
-
- var winWidth = windowWidth();
- var dropDownRight = controlElementLeft + dropDownElement.offsetWidth;
-
-
-
- if (winWidth < dropDownRight) {
- var dropDownLeft = controlElement.offsetWidth - dropDownElement.offsetWidth;
- var dropDownAbsoluteLeft = controlElementLeft + dropDownLeft;
- if (dropDownAbsoluteLeft < 0) {
-
-
- dropDownElement.style.left = controlElement.offsetLeft * -1;
- } else {
- dropDownElement.style.left = (controlElement.offsetWidth - dropDownElement.offsetWidth) + "px";
- }
- } else {
- dropDownElement.style.left = x + "px";
- }
- }
- function CCPopupMenu_fitWidthToBrowserRTL(controlElement, dropDownElement, x, y) {
- var controlElementRight = controlElement.offsetLeft + controlElement.offsetWidth;
-
-
- var winWidth = windowWidth();
- var dropDownLeft = controlElementRight - dropDownElement.offsetWidth;
-
-
-
-
- if (dropDownLeft < 0) {
- var dropDownRight = controlElement.offsetWidth - dropDownElement.offsetWidth;
- var dropDownAbsoluteRight = controlElementRight - dropDownRight;
- if (dropDownAbsoluteRight > winWidth) {
-
-
- dropDownElement.style.right = controlElement.offsetRight * -1;
- } else {
-
- dropDownElement.style.left = 0 + "px";
- }
- } else {
- dropDownElement.style.right = x + "px";
- }
- }
- function CCPopupMenu_dropDown(event, x, y, id) {
- if (event.type == "keypress" && event.keyCode == 9) {
- CCPopupMenu.hideActiveMenu();
- return true;
- }
- var currentMenu = CCPopupMenu.getMenu(id);
- if (currentMenu != null) {
-
- if (currentMenu.dropDownElement == null) {
- return;
- }
-
-
- var isAlreadyOpen = false;
- if ((CCPopupMenu.activeMenu != null) && (CCPopupMenu.activeMenu.id == id)) {
- isAlreadyOpen = CCPopupMenu.activeMenu.isOpen;
- }
- CCPopupMenu.hideActiveMenu();
- if ((event.type == "keypress" && event.keyCode == 27) && (isAlreadyOpen)) {
- return true;
- }
-
- currentMenu.fitHeightToBrowser(x, y);
- currentMenu.fitWidthToBrowser(x, y);
-
-
- CCPopupMenu.createInsulatingIframe(currentMenu, currentMenu.dropDownElement);
-
-
- currentMenu.dropDownElement.style.visibility = "visible";
- CCPopupMenu.activeMenu = currentMenu;
- currentMenu.isOpen = true;
-
- if (event.type == "keypress" || event.type == 'click') {
- CCPopupMenu.activeMenu.doCheckBounds = false;
- CCPopupMenu.activeMenu.activeMenuItemIndex = -1;
- selectedObject = CCPopupMenu.activeMenu.getCurrentSelected();
- if (!selectedObject) {
- currentMenu.menuItems[0].menuItemEl.focus();
-
- } else {
- CCPopupMenu.setActiveMenuItem("current");
- }
- }
- }
- CCPopupMenu.ignoreHideActiveMenu("ignore");
- setTimeout('CCPopupMenu.ignoreHideActiveMenu("unignore")', 100);
- return haltEventProcessing(event);
- }
- function CCPopupMenu_dropDownOnclick(event) {
- if (event.stopPropagation) {
- event.stopPropagation();
- } else {
- event.cancelBubble = 'true';
- }
- }
- function CCPopupMenu_isTapInsideMenu(tapObject) {
- var tapX = tapObject.pageX;
- var tapY = tapObject.pageY;
- var menuRect = this.dropDownElement.getBoundingClientRect();
- if (!((tapX >= menuRect.left) && (tapX <= menuRect.right) && (tapY <= menuRect.bottom) && (tapY >= menuRect.top))) {
- return true;
- }
- return false;
- }
- function CCPopupMenu_createDropDown() {
-
- var divEl = document.createElement("div");
- var tableEl = document.createElement("table");
- var tbody = document.createElement("tbody");
- var itm;
-
- tableEl.appendChild(tbody);
- tableEl.style.borderCollapse = "collapse";
- tableEl.summary = "";
- tableEl.setAttribute("role", "menu");
- divEl.id = "flyout_" + this.id;
- divEl.className = "flyOutMenu";
- divEl.style.display = "block";
- divEl.style.position = "absolute";
- divEl.style.overflow = "visible";
-
-
- divEl.style.zIndex = "2";
- divEl.style.visibility = "hidden";
- divEl.style.padding = "2px";
- divEl.setAttribute("role", "presentation");
- if (this.label != null) {
- tableEl.setAttribute("aria-label", this.label);
- }
- divEl.tabIndex = -1;
-
- addEvent(divEl, "click", CCPopupMenu_dropDownOnclick);
-
- var moz = (window.navigator.userAgent.indexOf("Gecko") != -1);
- addEvent(divEl, (moz ? "keypress" : "keydown"), extensions.associate(itm, this, "presskey"));
-
- tableEl.id = "flyoutTab_" + this.id;
-
-
- var controlEl = document.getElementById(this.controlId);
- if (controlEl != null) {
- controlEl.appendChild(divEl);
- } else {
-
- document.body.appendChild(divEl);
- }
- divEl.appendChild(tableEl);
-
- var maxItmWidth = 0;
- for (index = 0; index < this.menuItems.length; index++) {
- if (index == 0) {
- itm = this.firstMenuItemEl = this.menuItems[index].renderItem(tbody, this.id);
- } else {
- itm = this.menuItems[index].renderItem(tbody, this.id);
- }
- if (moz && itm && itm.offsetWidth && maxItmWidth < itm.offsetWidth) {
- maxItmWidth = itm.offsetWidth;
- }
- }
- if (moz && maxItmWidth > 0) {
- divEl.style.width = maxItmWidth + "px";
- }
-
- this.dropDownElement = divEl;
-
- this.fitHeightToBrowser(0, 0);
- this.fitWidthToBrowser(0, 0);
-
-
- this.dropDownElement.style.visibility = "visible";
- this.dropDownElement.style.visibility = "hidden";
- }
- function CCPopupMenu_createDropDowns() {
- for (var index = 0; index < CCPopupMenu.menus.length; index++) {
- CCPopupMenu.menus[index].createDropDown();
- }
- }
- function CCPopupMenu_getMenu(id) {
- for (var index = 0; index < CCPopupMenu.menus.length; index++) {
- if (CCPopupMenu.menus[index].id == id) {
- return CCPopupMenu.menus[index];
- }
- }
- }
- function CCPopupMenu(sId, controlId, nHeight, hasCheckbox, messagesJSON) {
- this.controlId = controlId;
- this.id = sId;
- this.menuItems = [];
- this.isOpen = false;
- this.dropDownElement = null;
- this.mnHeight = -1;
- this.hasCheckbox = ((hasCheckbox != null) && (hasCheckbox == 'true'));
-
-
- if (nHeight != "") {
- this.mnHeight = parseInt(nHeight, 10);
- }
-
- this.activeMenuItemIndex = -1;
- this.firstMenuItemEl = null;
- this.doCheckBounds = true;
- this.label=null;
- this.messages = messagesJSON;
- CCPopupMenu.menus.push(this);
- }
- function CCPopupMenu_setLabel(newLabel){
- this.label = newLabel;
- }
- function CCPopupMenu_addMenuItem(id, groupId, label, icon, clickFunction) {
- var newMenuItem = new CCPopupMenuItem(id, groupId, label, icon, clickFunction, this.hasCheckbox, this);
- this.menuItems.push(newMenuItem);
- }
- function CCPopupMenu_getMenuItem(id) {
- for (var index = 0; index < this.menuItems.length; index++) {
- if (this.menuItems[index].id == id) {
- return this.menuItems[index];
- }
- }
- }
- function CCPopupMenu_clearGroup(id) {
- for (var index = 0; index < this.menuItems.length; index++) {
- if (this.menuItems[index].groupId == id) {
- this.menuItems[index].clearSelectionState();
- }
- }
- }
- function CCPopupMenu_setMenuItemChecked(id) {
-
- var currentMenuItem = this.getMenuItem(id);
- if (currentMenuItem.isInGroup()) {
- this.clearGroup(currentMenuItem.groupId);
- }
- currentMenuItem.check();
- }
- function CCPopupMenu_getCurrentSelected() {
- for (var index = 0; index < this.menuItems.length; index++) {
- if (this.menuItems[index].type != "item") {
- index++;
- }
- if (this.menuItems[index].itemSelectedState != "none") {
- return this.menuItems[index];
- }
- }
- return this.menuItems[index];
- }
- function CCPopupMenu_getCurrentSelectedIndex() {
- for (var index = 0;index < this.menuItems.length; index++) {
- if (this.menuItems[index].type != "item") {
- index++;
- }
- if (this.menuItems[index].itemSelectedState != "none") {
- return index;
- }
- }
- return this.activeMenuItemIndex;
- }
- function CCPopupMenu_setActiveMenuItem(direction) {
- currentMenu = CCPopupMenu.activeMenu;
- var index = direction == 'current' ? currentMenu.getCurrentSelectedIndex() : currentMenu.activeMenuItemIndex;
- if (direction == 'up') {
- if (index > 0) {
- if (currentMenu.menuItems[index - 1].type != "item") {
- index--;
- }
- index--;
- }
- } else if (direction == 'down') {
- if (index < currentMenu.menuItems.length - 1) {
- if (currentMenu.menuItems[index + 1].type != "item") {
- index++;
- }
- index++;
- }
- }
- if (index > -1 && index != currentMenu.activeMenuItemIndex) {
- currentMenu.activeMenuItemIndex = index;
- }
- currentMenu.menuItems[index].menuItemEl.focus();
- }
- function CCPopupMenu_setMenuItemSelected(id) {
-
- currentMenuItem = this.getMenuItem(id);
- if (currentMenuItem.isInGroup()) {
- this.clearGroup(currentMenuItem.groupId);
- }
- currentMenuItem.select();
- }
- function CCPopupMenu_setCurrentItemIndex(id) {
- currentMenu = CCPopupMenu.activeMenu;
- for (var index = 0; index < currentMenu.menuItems.length; index++) {
- if (currentMenu.menuItems[index].type != "item") {
- continue;
- }
- if (currentMenu.menuItems[index].menuItemEl.id == id) {
- currentMenu.activeMenuItemIndex = index;
- currentMenu.menuItems[index].menuItemEl.className = "menuItemOver";
- } else {
- currentMenu.menuItems[index].menuItemEl.className = "menuItemNormal";
- }
- }
- }
- function CCPopupMenu_addMenuSeparator() {
- var newMenuItem = new CCPopupMenuSeparator();
- this.menuItems.push(newMenuItem);
- }
- function CCPopupMenu_removeDropDown() {
- if ((this.dropDownElement != null)) {
- this.dropDownElement.style.visibility = "hidden";
- this.isOpen = false;
- var iframeID = this.id + "inslIframe";
- var iframeEl = document.getElementById(iframeID);
- if (iframeEl != null) {
- var controlElement = document.getElementById(this.controlId);
- controlElement.removeChild(iframeEl);
- }
- }
- }
- function CCPopupMenu_hidePopupForKeyPress() {
- var moz = (window.navigator.userAgent.indexOf("Gecko") != -1);
- if (moz) {
- var currentMenu = CCPopupMenu.getMenu(CCPopupMenu.activeMenu.id);
- var controlContainerElement = document.getElementById(currentMenu.controlId);
- CCPopupMenu.hideActiveMenu();
- if (controlContainerElement != null) {
- controlContainerElement.focus();
- }
- } else {
- CCPopupMenu.hideActiveMenu();
- }
- }
- function CCPopupMenu_presskey(evt) {
- evt = evt != null ? evt : window.event;
- if (evt.keyCode == 13) {
-
- if (CCPopupMenu.activeMenu.activeMenuItemIndex > -1) {
- CCPopupMenu.activeMenu.menuItems[CCPopupMenu.activeMenu.activeMenuItemIndex].keypressFunction();
- CCPopupMenu.hidePopupForKeyPress();
- }
- } else if (evt.keyCode == 27 || evt.keyCode == 9) {
-
-
- CCPopupMenu.hidePopupForKeyPress();
- if (evt.keyCode == 9) {
- return true;
- }
- } else if (evt.keyCode == 38) {
-
- CCPopupMenu.setActiveMenuItem('up');
- } else if (evt.keyCode == 40) {
-
- CCPopupMenu.setActiveMenuItem('down');
- }
- return haltEventProcessing(evt);
- }
-
- CCPopupMenu.prototype.addMenuItem = CCPopupMenu_addMenuItem;
- CCPopupMenu.prototype.addMenuSeparator = CCPopupMenu_addMenuSeparator;
- CCPopupMenu.prototype.removeDropDown = CCPopupMenu_removeDropDown;
- CCPopupMenu.prototype.fitHeightToBrowser = CCPopupMenu_fitHeightToBrowser;
- CCPopupMenu.prototype.fitWidthToBrowser = CCPopupMenu_fitWidthToBrowser;
- CCPopupMenu.prototype.getMenuItem = CCPopupMenu_getMenuItem;
- CCPopupMenu.prototype.clearGroup = CCPopupMenu_clearGroup;
- CCPopupMenu.prototype.setMenuItemChecked = CCPopupMenu_setMenuItemChecked;
- CCPopupMenu.prototype.setMenuItemSelected = CCPopupMenu_setMenuItemSelected;
- CCPopupMenu.prototype.sizeDropDown = CCPopupMenu_sizeDropDown;
- CCPopupMenu.prototype.getCurrentSelected = CCPopupMenu_getCurrentSelected;
- CCPopupMenu.prototype.createDropDown = CCPopupMenu_createDropDown;
- CCPopupMenu.prototype.getCurrentSelectedIndex = CCPopupMenu_getCurrentSelectedIndex;
- CCPopupMenu.prototype.presskey = CCPopupMenu_presskey;
- CCPopupMenu.prototype.setLabel = CCPopupMenu_setLabel;
- CCPopupMenu.prototype.isTapInsideMenu = CCPopupMenu_isTapInsideMenu;
- CCPopupMenu.hideActiveMenu = CCPopupMenu_hideActiveMenu;
- CCPopupMenu.hidePopupForKeyPress = CCPopupMenu_hidePopupForKeyPress;
- CCPopupMenu.ignoreHideActiveMenu = CCPopupMenu_ignoreHideActiveMenu;
- CCPopupMenu.getMenu = CCPopupMenu_getMenu;
- CCPopupMenu.dropDown = CCPopupMenu_dropDown;
- CCPopupMenu.checkBounds = CCPopupMenu_checkBounds;
- CCPopupMenu.createInsulatingIframe = CCPopupMenu_createInsulatingIframe;
- CCPopupMenu.setControlFocus = CCPopupMenu_setControlFocus;
- CCPopupMenu.createDropDowns = CCPopupMenu_createDropDowns;
- CCPopupMenu.setActiveMenuItem = CCPopupMenu_setActiveMenuItem;
- CCPopupMenu.setCurrentItemIndex = CCPopupMenu_setCurrentItemIndex;
- function CCPopupMenuSeparator() {
- this.type = "separator";
- }
- function CCPopupMenuSeparator_isInGroup() {
- return false;
- }
- function CCPopupMenuSeparator_renderItem(menuElement, id) {
- var menuItemEl = document.createElement("tr");
-
- menuItemEl.tabIndex = -1;
- menuItemEl.setAttribute("role", "separator");
- menuElement.appendChild(menuItemEl);
- var menuSeparatorContainer = document.createElement("td");
- menuSeparatorContainer.colSpan = 3;
- var menuSeparator = document.createElement("div");
- menuSeparator.className = "flyOutMenuSeparator";
- menuSeparatorContainer.appendChild(menuSeparator);
-
- menuItemEl.appendChild(menuSeparatorContainer);
- }
- CCPopupMenuSeparator.prototype.renderItem = CCPopupMenuSeparator_renderItem;
- CCPopupMenuSeparator.prototype.isInGroup = CCPopupMenuSeparator_isInGroup;
- function CCPopupMenuItem(sId, groupId, slabel, icon, clickFunction, hasCheckbox, menu) {
- this.id = sId;
- this.label = slabel;
- this.icon = icon;
- this.itemSelectedState = "none";
- this.type = "item";
- this.groupId = groupId;
- this.enabled = true;
- this.menuItemEl = null;
- this.menuLabelEl = null;
- this.iconImageEl = null;
- this.selectionStateIcon = null;
- this.selectionElement = null;
- this.menuIdx = -1;
- this.hasCheckbox = hasCheckbox;
- this.parentMenu = menu;
-
-
- var clickActionCode = clickFunction + ";CCPopupMenu.hideActiveMenu();";
-
-
-
- this.keypressFunction = new Function("event", clickActionCode);
-
-
-
- this.clickFunction = new Function("event", clickActionCode);
- }
- function CCPopupMenuItem_isInGroup() {
- return (this.groupId != "");
- }
- function CCPopupMenuItem_disable() {
- this.enabled = false;
- this.updateForEnabled();
- }
- function CCPopupMenuItem_enable() {
- this.enabled = true;
- this.updateForEnabled();
- }
- function CCPopupMenuItem_clearSelectionState() {
- this.itemSelectedState = "none";
- this.updateForSelectionState();
- }
- function CCPopupMenuItem_check() {
- this.itemSelectedState = "checked";
- this.updateForSelectionState();
- }
- function CCPopupMenuItem_select() {
- this.itemSelectedState = "selected";
- this.updateForSelectionState();
- }
- function CCPopupMenuItem_renderLabel(menuElement) {
- var menuItemLabel = document.createElement("td");
-
- menuItemLabel.style.padding = "2px";
- menuItemLabel.className = "menuItemNormal";
- this.menuLabelEl = menuItemLabel;
- menuElement.appendChild(menuItemLabel);
- var nonbreakingSpace = document.createElement("nobr");
- menuItemLabel.appendChild(nonbreakingSpace);
- var labelLink = document.createElement("span");
- labelLink.tabIndex = -1;
-
- nonbreakingSpace.appendChild(labelLink);
- labelLink.appendChild(document.createTextNode(this.label));
- }
- function CCPopupMenuItem_renderDecorations(menuElement) {
- var decorationTD = document.createElement("td");
- decorationTD.className = "text";
- decorationTD.style.cursor = "pointer";
- decorationTD.style.textDecoration = "underline";
- menuElement.appendChild(decorationTD);
- this.selectionElement = decorationTD;
- if (this.icon != "") {
- var imgEl = document.createElement("img");
- imgEl.src = this.icon;
- imgEl.style.height = "16px";
- imgEl.style.width = "16px";
- imgEl.alt="";
- imgEl.setAttribute("role","presentation");
- this.iconImageEl = imgEl;
- decorationTD.className = "menuItemIcon";
- decorationTD.appendChild(imgEl);
- }
- }
- function CCPopupMenuItem_updateForSelectionState() {
- if (this.menuItemEl == null) {
- return;
- }
- if (this.itemSelectedState == "none") {
- if (this.selectionStateIcon != null) {
-
- this.selectionStateIcon.parentNode.removeChild(this.selectionStateIcon);
- this.selectionStateIcon = null;
- this.menuItemEl.setAttribute("aria-checked","false");
- }
- } else {
- if (this.selectionStateIcon == null) {
- var imgEl = document.createElement("img");
- if (this.itemSelectedState == "checked") {
- imgEl.src = CCPopupMenu.portalImagesPath + "/checkmark.gif";
- if (this.parentMenu.messages != null){
- imgEl.alt = this.parentMenu.messages.IDS_CCPOPUP_CHECKED;
- }
- } else {
- imgEl.src = CCPopupMenu.portalImagesPath + "/dot.gif";
- if (this.parentMenu.messages != null){
- imgEl.alt = this.parentMenu.messages.IDS_CCPOPUP_DOT;
- }
- }
- this.selectionElement.appendChild(imgEl);
- this.selectionStateIcon = imgEl;
- } else {
- if (this.itemSelectedState == "checked") {
- this.selectionStateIcon.src = CCPopupMenu.portalImagesPath + "/checkmark.gif";
- if (this.parentMenu.messages != null){
- this.selectionStateIcon.alt = this.parentMenu.messages.IDS_CCPOPUP_CHECKED;
- }
- } else {
- this.selectionStateIcon.src = CCPopupMenu.portalImagesPath + "/dot.gif";
- if (this.parentMenu.messages != null){
- this.selectionStateIcon.alt = this.parentMenu.messages.IDS_CCPOPUP_DOT;
- }
- }
- this.updateForEnabled();
- }
- this.menuItemEl.setAttribute("aria-checked","true");
- }
- }
- function CCPopupMenuItem_updateForEnabled() {
- if (this.menuItemEl == null) {
- return;
- }
-
-
- if (this.enabled) {
-
-
- addEvent(this.menuItemEl, 'click', this.clickFunction);
-
- this.menuItemEl.style.MozOpacity = "1.0";
- this.menuItemEl.setAttribute("aria-disabled","false");
- this.menuItemEl.style.filter = "alpha(opacity=100)";
- this.menuLabelEl.className = "text";
- if (this.itemSelectedState != "none") {
- this.selectionStateIcon.style.MozOpacity = "1.0";
- this.selectionStateIcon.style.filter = "alpha(opacity=100)";
- }
- if (this.iconImageEl != null) {
- this.iconImageEl.style.MozOpacity = "1.0";
- this.iconImageEl.style.filter = "alpha(opacity=100)";
- }
- } else {
-
-
- removeEvent(this.menuItemEl, 'click', this.clickFunction);
-
- this.menuItemEl.style.MozOpacity = "0.5";
- this.menuItemEl.setAttribute("aria-disabled","true");
- this.menuItemEl.style.filter = "alpha(opacity=50)";
- if (this.itemSelectedState != "none") {
- this.selectionStateIcon.style.MozOpacity = "0.5";
- this.selectionStateIcon.style.filter = "alpha(opacity=50)";
- }
- if (this.iconImageEl != null) {
- this.iconImageEl.style.MozOpacity = "0.5";
- this.iconImageEl.style.filter = "alpha(opacity=50)";
- }
- this.menuLabelEl.className = "inactiveText";
- }
- }
- function menuItemOverEventHandler(id) {
- return function ccmenuitemovereventhandler() {
- var menuItemEl = document.getElementById(id);
- CCPopupMenu.setCurrentItemIndex(menuItemEl.id);
- };
- }
- function menuItemOutEventHandler(id) {
- return function ccmenuitemouteventhandler() {
- var menuItemEl = document.getElementById(id);
- menuItemEl.className = 'menuItemNormal';
- };
- }
- function menuItemBlurEventHandler(id) {
- return function ccmenuitemblureventhandler(event) {
- var menuItemEl = document.getElementById(id);
- menuItemEl.className = 'menuItemNormal';
- CCPopupMenu.checkBounds(event);
- };
- }
- function CCPopupMenuItem_createCommonEventHandlers(menuItemEl) {
- addEvent(menuItemEl, 'focus', menuItemOverEventHandler(menuItemEl.id));
- addEvent(menuItemEl, 'mouseout', menuItemOutEventHandler(menuItemEl.id));
- addEvent(menuItemEl, 'mouseover', menuItemOverEventHandler(menuItemEl.id));
- addEvent(menuItemEl, 'blur', menuItemBlurEventHandler(menuItemEl.id));
- }
- function CCPopupMenuItem_renderItem(menuElement, id) {
- var menuItemEl = document.createElement("tr");
- var itemRole = "menuitem";
-
- if (this.hasCheckbox){
- itemRole = "menuitemcheckbox";
- menuItemEl.setAttribute("aria-checked","false");
- }
- menuItemEl.setAttribute("role", itemRole);
- menuItemEl.className = "menuItemNormal";
- menuItemEl.id = this.id + "menuItemTR";
- menuItemEl.tabIndex = -1;
- this.createCommonEventHandlers(menuItemEl);
-
- menuItemEl.style.width = "100%";
- menuItemEl.style.overflow = "visible";
- menuElement.appendChild(menuItemEl);
-
- this.renderDecorations(menuItemEl);
- this.renderLabel(menuItemEl);
-
- var cascadingTD = document.createElement("td");
- cascadingTD.className = "text";
- cascadingTD.style.cursor = "pointer";
- cascadingTD.style.textDecoration = "underline";
- menuItemEl.appendChild(cascadingTD);
- this.menuItemEl = menuItemEl;
- this.updateForSelectionState();
- this.updateForEnabled();
- return menuItemEl;
- }
- CCPopupMenuItem.prototype.renderItem = CCPopupMenuItem_renderItem;
- CCPopupMenuItem.prototype.renderDecorations = CCPopupMenuItem_renderDecorations;
- CCPopupMenuItem.prototype.renderLabel = CCPopupMenuItem_renderLabel;
- CCPopupMenuItem.prototype.clearSelectionState = CCPopupMenuItem_clearSelectionState;
- CCPopupMenuItem.prototype.check = CCPopupMenuItem_check;
- CCPopupMenuItem.prototype.select = CCPopupMenuItem_select;
- CCPopupMenuItem.prototype.isInGroup = CCPopupMenuItem_isInGroup;
- CCPopupMenuItem.prototype.disable = CCPopupMenuItem_disable;
- CCPopupMenuItem.prototype.enable = CCPopupMenuItem_enable;
- CCPopupMenuItem.prototype.updateForEnabled = CCPopupMenuItem_updateForEnabled;
- CCPopupMenuItem.prototype.updateForSelectionState = CCPopupMenuItem_updateForSelectionState;
- CCPopupMenuItem.prototype.createCommonEventHandlers = CCPopupMenuItem_createCommonEventHandlers;
- function respondToTouch(){
- if (CCPopupMenu.activeMenu != null){
- var event = window.event;
- if (CCPopupMenu.activeMenu.isTapInsideMenu(event.targetTouches[0])) {
- var controlElement = document.getElementById(CCPopupMenu.activeMenu.controlId);
- if (event.taget != controlElement){
- CCPopupMenu.hideActiveMenu();
- }
- }
- }
- }
- addEvent(document, 'click', CCPopupMenu.hideActiveMenu);
- addEvent(document, 'touchstart', respondToTouch);
- addEvent(window, 'resize', CCPopupMenu.hideActiveMenu);
- addEvent(window, 'load', CCPopupMenu.createDropDowns);
|