var wptheme_DebugUtils = { // summary: Collection of utilities for logging debug messages. enabled: false, log: function ( /*String*/className, /*String*/message ) { // summary: Logs a debugging message, if debugging is enabled. // className: the javascript class name or function name which is logging the message // message: the message to log if ( this.enabled ) { message = className + " ==> " + message; if ( typeof( console ) == "undefined" ) { console.debug( message ); } else { //better alternative for browsers that don't support console???? alert( message ); } } } } var wptheme_HTMLElementUtils = { // summary: Collection of utility functions useful for manipulating HTML elements in a cross-browser fashion. className: "wptheme_HTMLElementUtils", _debugUtils: wptheme_DebugUtils, _uniqueIdCounter: 0, getUniqueId: function () { // summary: Generates a unique identifier (to the current page) by appending a counter to a set prefix. // A page refresh resets the unique identifier counter. // returns: a unique identifier var retVal = "wptheme_unique_" + this._uniqueIdCounter; this._uniqueIdCounter++; return retVal; // String }, sizeToViewableArea: function ( /*HTMLElement*/element ) { // summary: Sizes the given element to the viewable area of the browser in a cross-browser fashion. // element: the html element to size var browserDimensions = new BrowserDimensions(); element.style.height = browserDimensions.getViewableAreaHeight() + "px"; element.style.width = browserDimensions.getViewableAreaWidth() + "px"; element.style.top = browserDimensions.getScrollFromTop() + "px"; element.style.left = browserDimensions.getScrollFromLeft() + "px"; }, sizeToEntireArea: function ( /*HTMLElement*/element ) { // summary: Sizes the given element to the viewable area plus the scroll area. // element: the html element to size var browserDimensions = new BrowserDimensions(); //The getHTMLElement*() functions return the exact size of the body element in IE even if the viewable area is //larger (i.e. no scroll bars). In Firefox, the dimensions of the viewable area plus the scrollable area is returned. //So in IE, we take the viewable area if that is larger and the HTMLElement* area if that is larger. element.style.height = Math.max( browserDimensions.getHTMLElementHeight(), browserDimensions.getViewableAreaHeight() ) + "px"; element.style.width = Math.max( browserDimensions.getHTMLElementWidth(), browserDimensions.getViewableAreaWidth() ) + "px"; }, sizeRelativeToViewableArea: function ( /*HTMLElement*/element, /*float*/heightFactor, /*float*/widthFactor ) { // summary: Sizes the given element to a certain multiple of the viewable area. For example, if heightFactor is 0.5, // the height of the given element will be set to half of the viewable area height. // element: the html element to size // heightFactor: the factor to multiply the viewable area height by // widthFactor: the factor to multiply the viewable area width by var browserDimensions = new BrowserDimensions(); element.style.height = ( browserDimensions.getViewableAreaHeight() * heightFactor ) + "px"; element.style.width = ( browserDimensions.getViewableAreaWidth() * widthFactor ) + "px"; }, positionRelativeToViewableArea: function ( /*HTMLElement*/element, /*float*/heightFactor, /*float*/widthFactor ) { // summary: Positions the given element relative to the viewable area. For example, if the heightFactor is 0.5, the // top of the element will be positioned (Y axis) halfway down the viewable area. Note that this means the element // will be ABSOLUTELY positioned. // element: the html element to position // heightFactor: the factor to multiply the viewable area height by // widthFactor: the factor to multiply the viewable area width by var browserDimensions = new BrowserDimensions(); element.style.position = "absolute"; if ( this._debugUtils.enabled ) { this._debugUtils.log( this.className, "Browser's viewable height: " + browserDimensions.getViewableAreaHeight() ); this._debugUtils.log( this.className, "Browser's viewable width: " + browserDimensions.getViewableAreaWidth() ); this._debugUtils.log( this.className, "Browser's scroll from top: " + browserDimensions.getScrollFromTop() ); this._debugUtils.log( this.className, "Browser's scroll from left: " + browserDimensions.getScrollFromLeft() ); } element.style.top = ( ( browserDimensions.getViewableAreaHeight() * heightFactor ) + browserDimensions.getScrollFromTop() ) + "px"; //Scroll left behaves differently in FF & IE in RTL languages. The "correct" behavior is up for debate. In FF, it will return the "correct" value //(scrollLeft switches when the page is rendered right-to-left). In IE, scroll left will basically return the scroll width for the body element. //There's no real "capability" to test for here so the window.attachEvent is a cheap trick to check for IE. //bidiSupport is defined in the theme. if ( bidiSupport.isRTL && window.attachEvent ) { if ( this._debugUtils.enabled ) { this._debugUtils.log( this.className, "scrollWidth = " + browserDimensions.getHTMLElementWidth() ); this._debugUtils.log( this.className, "clientWidth = " + browserDimensions.getViewableAreaWidth() ); this._debugUtils.log( this.className, "Scroll Offset should be: " + ( browserDimensions.getHTMLElementWidth() - browserDimensions.getViewableAreaWidth() - browserDimensions.getScrollFromLeft() ) ); } element.style.left = ( ( browserDimensions.getViewableAreaWidth() * widthFactor) + ( browserDimensions.getHTMLElementWidth() - browserDimensions.getViewableAreaWidth() - browserDimensions.getScrollFromLeft() ) ) + "px"; } else { element.style.left = ( ( browserDimensions.getViewableAreaWidth() * widthFactor ) + browserDimensions.getScrollFromLeft() ) + "px"; } }, positionOutsideElementTopRight: function ( /*HTMLElement*/elementToPosition, /*HTMLElement*/relativeElement ) { // summary: Positions the given element just outside (to the top and lining up with the right edge) of the // relative element. // description: Sets the top (Y-axis) position of the given element to the top of the relative element minus the // height of element being positioned. Sets the left (X-axis) position of the given element to the left position of // the relative element plus the width of the relative element (to get the right edge) minus the width of the element // being positioned (to line the end of the element being positioned up with the right edge of the relative element). elementToPosition.style.position = "absolute"; elementToPosition.style.top = ( this.stripUnits( relativeElement.style.top ) - elementToPosition.offsetHeight ) + "px"; if ( bidiSupport.isRTL ) { elementToPosition.style.left = ( this.stripUnits( relativeElement.style.left ) ) + "px"; } else { elementToPosition.style.left = ( this.stripUnits( relativeElement.style.left ) + relativeElement.offsetWidth - elementToPosition.offsetWidth) + "px"; } }, stripUnits: function ( /*String*/cssProp ) { // summary: Strips any units (i.e. "px") from a CSS style property. // returns: the number value minus any units return parseInt( cssProp.substring( 0, cssProp.length - 2 )); //integer }, addClassName: function ( /*HTMLElement*/element, /*String*/className ) { // summary: Adds the given className to the element's style definitions. // element: the HTMLElement to add the class name to // className: the className to add var clazz = element.className; if ( clazz.indexOf( className ) < 0 ) { element.className += (" " + className); } }, removeClassName: function ( /*HTMLElement*/element, /*String*/className ) { // summary: Removes the given className from the element's style definitions. // element: the HTMLElement to remove the class name from // className: the className to remove var clazz = element.className; var startIndex = clazz.indexOf( className ); if ( startIndex >= 0 ) { clazz = clazz.substring(0, startIndex) + clazz.substring( startIndex + className.length + 1 ); element.className = clazz; } }, hideElementsByTagName: function ( /*String 1...N*/) { // summary: Hides every element of a given tag name. Stores the old visibility style so it can be // restored by the showElementsByTagName function. for ( var i = 0; i < arguments.length; i++ ) { var elements = document.getElementsByTagName( arguments[i] ); for ( var j = 0; j < elements.length; j++ ) { if ( elements[j] && elements[j].style ) { elements[j]._oldVisibilityStyle = elements[j].style.visibility; elements[j].style.visibility = "hidden"; } } } }, showElementsByTagName: function ( /*String 1...N*/) { // summary: Shows every element of a given tag name. Uses the old visibility style so that elements hidden // by hideElementsByTagName are properly restored. for ( var i = 0; i < arguments.length; i++ ) { var elements = document.getElementsByTagName( arguments[i] ); for ( var j = 0; j < elements.length; j++ ) { if ( elements[j] && elements[j].style ) { if ( elements[j]._oldVisibility ) { elements[j].style.visibility = elements[j]._oldVisibility; elements[j]._oldVisibility = null; } else { elements[j].style.visibility = "visible"; } } } } }, addOnload: function ( /*Function*/func ) { // summary: Adds a function to be called on page load. // func: the function to call if ( window.addEventListener ) { window.addEventListener( "load", func, false ); } else if ( window.attachEvent ) { window.attachEvent( "onload", func ); } }, getEventObject: function ( /*Event?*/event ) { // summary: Cross-browser function to retrieve the event object. // event: In W3C-compliant browsers, this object will just simply be // returned // returns: the event object var result = event; if ( !event && window.event ) { result = window.event; } return result; // Event } } var wptheme_CookieUtils = { // summary: Various utility functions for dealing with cookies on the client. _deleteDate: new Date( "1/1/2003" ), _undefinedOrNull: function ( /*Object*/variable ) { // summary: Determines if a given variable is undefined or NULL. // returns: true if undefined OR NULL, false otherwise. return ( typeof ( variable ) == "undefined" || variable == null ); // boolean }, debug: wptheme_DebugUtils, className: "wptheme_CookieUtils", getCookie: function ( /*String*/cookieName ) { // summary: Gets the value for a given cookie name. If no value is found, returns NULL. if ( this.debug.enabled ) { this.debug.log( this.className, "getCookie( " + cookieName + " )" ); } cookieName = cookieName + "=" var retVal = null; if ( this.debug.enabled ) { this.debug.log( this.className, "document.cookie=" + document.cookie ); this.debug.log( this.className, "indexOf cookieName: " + document.cookie.indexOf( cookieName ) ); } if ( document.cookie.indexOf( cookieName ) >= 0 ) { var cookies = document.cookie.split(";"); var c = 0; if ( this.debug.enabled && cookies.length > 0 ) { this.debug.log( this.className, "cookies[0] = " + cookies[0] ); } while ( c < cookies.length && ( cookies[c].indexOf( cookieName ) == -1 ) ) { if ( this.debug.enabled ) { this.debug.log( this.className, "cookies[" + c + "] = " + cookies[0] ); } c=c+1; } //Make sure there's no leading or trailing spaces on our cookie name/value pair. var cookieNVP = cookies[c].replace( /^[ \s]+|[ \s]+$/, '' ); if ( this.debug.enabled ) { this.debug.log( this.className, "cookieName=\"" + cookieName + "\"." ); this.debug.log( this.className, "cookieName.length=\"" + cookieName.length + "\"." ); this.debug.log( this.className, "cookieNVP=\"" + cookieNVP + "\"." ); this.debug.log( this.className, "cookieNVP.length=\"" + cookieNVP.length + "\"." ); } var cookieValue = cookieNVP.substring( cookieName.length ); if ( this.debug.enabled ) { this.debug.log( this.className, "cookie value =\"" + cookieValue + "\"."); } if ( cookieValue != "null" ) { retVal = cookieValue; } } if ( this.debug.enabled ) { this.debug.log( this.className, "getCookie( " + cookieName + " ) return " + retVal ); } return retVal; // String }, setCookie: function ( /*String*/name, /*String*/value, /*Date?*/expiration, /*String?*/path ) { // summary: Creates the cookie based on the given information. // name: the name of the cookie // value: the value for the cookie // expiration: OPTIONAL -- when the cookie should expire // path: OPTIONAL -- the url path the cookie applies to if ( this.debug.enabled ) { this.debug.log( this.className, "set cookie (" + [ name, value, expiration, path ] + ")"); } if ( this._undefinedOrNull( name ) ) { throw Error( "Unable to set cookie! No name given!" ); } if ( this._undefinedOrNull( value ) ) { throw Error( "Unable to set cookie! No value given!" ); } if ( this._undefinedOrNull( expiration ) ) { expiration = ""; } else { expiration = "expiration=" + expiration.toUTCString() + ";"; } if ( this._undefinedOrNull( path ) ) { path = "path=/;"; } else { path = "path=" + path + ";"; } document.cookie=name + '=' + value + ';' + expiration + path; if ( this.debug.enabled ) { this.debug.log( this.className, "document.cookie after setting the cookie=" + document.cookie ); } }, deleteCookie: function ( /*String*/cookieName ) { // summary: Deletes a given cookie by setting the value to "null" and setting the expiration // value to expire completely. if ( this.debug.enabled ) { this.debug.log( this.className, "delete cookie (" + [ cookieName ] + ") "); } if(wpsFLY_isIE){ this.setCookie( cookieName, "null", this._deleteDate); }else{ this.setCookie( cookieName, ""); } } } // Populates and shows a context menu asynchronously. // // uniqueID - some unique identifier describing the context of the menu (i.e. portlet window id) // urlToMenuContents - url target for the iFrame // isLTR - indicates if the page orientation is Left-to-Right // // // This function creates a context menu using the WCL context menu javascript library. It populates this menu // by creating a hidden DIV ( the ID consists of the unique identifier with "_DIV" appended ) which contains // a hidden IFRAME ( the ID consists of the DIV identifier with "_IFRAME" appended ). The IFRAME loads the // specified URL and calls the buildAndDisplayMenu() function upon completion of loading the IFRAME. The document // returned by the specified URL must contain a javascript function called "getMenuContents()" which returns // an array. The contents of the array must be in the following format ( array[i] = ; // array[i+1] = ). The menu is attached to an HTML element with the id equal to the // unique identifier. So, in the portlet context menu case, the image associated with the context menu must have // an ID equal to the portlet window ID. The dynamically created DIV and IFRAME are deleted after the menu // contents are populated and the same menu is returned for the duration of the request in which it was created. // //Control debugging. // -1 - no debugging // 0 - minimal debugging ( adding items to menus ) // 1 - medium debugging ( function entry/exit ) // 2 - maximum debugging ( makes iframe visible ) // 999 - make iframe visible only var asynchContextMenuDebug = -1; var asynchContextMenuMouseOverIndicator = ""; var portletIdMap = new Object(); function asynchContextMenuOnMouseClickHandler( uniqueID, isLTR, urlToMenuContents, menuBorderStyle, menuTableStyle, menuItemStyle, menuItemSelectedStyle, emptyMenuText, loadingImage, renderBelow ) { var menuID = "contextMenu_" + uniqueID; var menu = getContextMenu( menuID ); if (menu == null) { asynchContextMenu_menuCurrentlyLoading = uniqueID; if ( loadingImage ) { setLoadingImage( loadingImage ); } menu = createContextMenu( menuID, isLTR, null, menuBorderStyle, menuTableStyle, emptyMenuText, null, renderBelow ); loadAsynchContextMenu( uniqueID, urlToMenuContents, isLTR, menuItemStyle, menuItemSelectedStyle, '', true ); } else { if ( asynchContextMenu_menuCurrentlyLoading == uniqueID ) { return; } showContextMenu( menuID, document.getElementById( uniqueID ) ); } } var asynchContextMenu_originalMenuImgElementSrc; function setLoadingImage( img ) { asynchContextMenu_originalMenuImgElementSrc = document.getElementById( asynchContextMenu_menuCurrentlyLoading + "_img" ).src; document.getElementById( asynchContextMenu_menuCurrentlyLoading + "_img" ).src = img; } function clearLoadingImage() { document.getElementById( asynchContextMenu_menuCurrentlyLoading + "_img" ).src = asynchContextMenu_originalMenuImgElementSrc; } function loadAsynchContextMenu( uniqueID, url, isLTR, menuItemStyle, menuItemSelectedStyle, emptyMenuText, showMenu, onMenuAffordanceShowHandler ) { asynchDebug( 'ENTRY loadAsynchContextMenu p1=' + uniqueID + '; p2=' + url + '; p3=' + isLTR + '; p4=' + isLTR); var menuID = "contextMenu_" + uniqueID; var dialogTag = null; var ID = uniqueID + '_DIV'; //an iframe wasn't cleaned up properly if ( document.getElementById( ID ) != null ) { closeMenu( ID ); return; } //create the div tag and assign the styles to it dialogTag = document.createElement( "DIV" ); dialogTag.style.position="absolute"; if ( asynchContextMenuDebug < 2 ) { dialogTag.style.left = "0px"; dialogTag.style.top = "-9999px"; dialogTag.style.visibility = "hidden"; } if ( asynchContextMenuDebug >= 2 || asynchContextMenuDebug == 999 ) { dialogTag.style.left = "100px"; dialogTag.style.top = "100px"; dialogTag.style.visibility = "visible"; } dialogTag.id=ID; var styleString = 'null'; if ( menuItemStyle != null ) { styleString = "'" + menuItemStyle + "'"; } if ( menuItemSelectedStyle != null ) { styleString = styleString + ", '" + menuItemSelectedStyle + "'"; } else { styleString = styleString + ", null"; } //alert( 'buildAndDisplayMenu( this.id, this.name, ' + styleString + ', ' + showMenu + ' , ' + callbackFn + ' );' ); //create the iframe this way because onload handlers attached when creating dynamically don't seem to fire dialogTag.innerHTML=''; //append the div tag to the document body document.body.appendChild( dialogTag ); asynchDebug( 'EXIT createDynamicElements' ); } //Builds and displays the menu from the contents of the IFRAME. function buildAndDisplayMenu( menuID, iframeID, menuItemStyle, menuItemSelectedStyle, showMenu, onMenuAffordanceShowHandler ) { asynchDebug( 'ENTRY buildAndDisplayMenu p1=' + menuID + '; p2=' + iframeID + '; p3=' + showMenu + '; p4=' + onMenuAffordanceShowHandler ); //get the context menu, should have already been created. var menu = getContextMenu( menuID ); //clear out our loading indicator clearLoadingImage(); asynchContextMenu_menuCurrentlyLoading = null; //if the menu doesn't exist, we shouldn't even be here....but just in case. if ( menu == null ) { return false; } //strip the _IFRAME from the id to come up with the DIV id index = iframeID.indexOf( "_IFRAME" ); var divID = iframeID.substring( 0, index ); //strip the _DIV from the id to come up with the portlet id index2 = divID.indexOf( "_DIV" ); var uniqueID = divID.substring( 0, index2 ); asynchDebug( 'divID = ' + divID ); asynchDebug( 'uniqueID = ' + uniqueID ); var frame, c=-1, done=false; //In IE, referencing the iFrame via the name in the window.frames[] array //does not appear to work in this case, so we have to cycle through all the //frames and compare the names to find the correct one. while ( ( c + 1 ) < window.frames.length && !done ) { c=c+1; //We have to surround this with a try/catch block because there are //cases where attempting to access the 'name' property of the current //frame in the array will generate an access denied exception. This is //OK to ignore because any frame that generates this exception shouldn't //be the one we are looking for. try { done = ( window.frames[c].name == iframeID ); } catch ( e ) { //do nothing. } } //Check for the existence of the function we are looking to call. //If not, don't bother creating the menu. if ( window.frames[c].getMenuContents ) { contents = window.frames[c].getMenuContents(); } else { //we were unable to load the context menu for whatever reason return false; } //Cycle through the array created by the getMenuContents() //function. The structure of the array should be [url, name]. for ( i=0; i < contents.length; i=i+3 ) { asynchDebug2( 'Adding item: ' + contents[i+1] ); asynchDebug2( 'URL: ' + contents[i] ); if ( contents[i] ) { asynchDebug2( 'url length: ' + contents[i].length ); } asynchDebug2( 'icon: ' + contents[i+2] ); if ( contents[i] && contents[i].length != 0 ) { var icon = null; if ( contents[i+2] && contents[i+2].length != 0 ) { icon = contents[i+2]; } menu.add( new UilMenuItem( contents[i+1], true, '', contents[i], null, icon, null, menuItemStyle, menuItemSelectedStyle ) ); } } //our target image should have an ID of the uniqueID var target = document.getElementById( uniqueID ); //remove our iframe since we've created the menu, we don't need the iframe on this request anymore. // (148004) deleting the elements causes the status bar to spin forever on mozilla //deleteDynamicElements( divID ); asynchDebug( 'EXIT buildAndDisplayMenu' ); //asynchContextMenuOnLoadCheck( menuID, uniqueID, target, onMenuAffordanceShowHandler ); //...and display! if ( showMenu == null || showMenu == true ) { return showContextMenu( menuID, target ); } } function asynchDebug( str ) { if ( asynchContextMenuDebug >= 1 && asynchContextMenuDebug != 999 ) { alert( str ); } } function asynchDebug2( str ) { if ( asynchContextMenuDebug >= 0 && asynchContextMenuDebug != 999 ) { alert( str) ; } } //MMD - this function is used so that relative URLs may be used with the context menus. function asynchDoFormSubmit( url ){ var formElem = document.createElement("form"); document.body.appendChild(formElem); formElem.setAttribute("method", "GET"); var delimLocation = url.indexOf("?"); if (delimLocation >= 0) { var newUrl = url.substring(0, delimLocation); var paramsEnd = url.length; // test to see if a # fragment identifier (the layout node id) is appended to the end of the URL var layoutNodeLocation = url.indexOf("#"); if (layoutNodeLocation >= 0 && layoutNodeLocation > delimLocation) { paramsEnd = layoutNodeLocation; newUrl = newUrl + url.substring(layoutNodeLocation, url.length); } var params = url.substring(delimLocation + 1, paramsEnd); var paramArray = params.split("&"); for (var i = 0; i < paramArray.length; i++) { var name = paramArray[i].substring(0, paramArray[i].indexOf("=")); var value = paramArray[i].substring(paramArray[i].indexOf("=") + 1, paramArray[i].length); var inputElem = document.createElement("input"); inputElem.setAttribute("type", "hidden"); inputElem.setAttribute("name", name); inputElem.setAttribute("value", value); formElem.appendChild(inputElem); } url = newUrl; } formElem.setAttribute("action", url); formElem.submit(); } var asynchContextMenu_menuCurrentlyLoading = null; function menuMouseOver( id, selectedImage ) { if ( asynchContextMenu_menuCurrentlyLoading != null ) return; portletIdMap[id] = 'menu_'+id+'_img'; showAffordance(id, selectedImage); } function menuMouseOut( id, disabledImage ) { if ( asynchContextMenu_menuCurrentlyLoading != null ) return; hideAffordance(id , disabledImage); portletIdMap[id] = ""; } function showAffordance( id, selectedImage ) { document.getElementById( 'menu_'+id ).style.cursor='pointer'; document.getElementById( 'menu_'+id+'_img').src=selectedImage; } function hideAffordance( id, disabledImage ) { document.getElementById( 'menu_'+id ).style.cursor='default'; document.getElementById( 'menu_'+id+'_img').src=disabledImage; } function menuMouseOverThinSkin(id, selectedImage, minimized) { if ( asynchContextMenu_menuCurrentlyLoading != null ) return; portletIdMap[id] = 'menu_'+id+'_img'; showAffordanceThinSkin(id, selectedImage, minimized); } function menuMouseOutThinSkin(id, disabledImage, minimized ) { if ( asynchContextMenu_menuCurrentlyLoading != null) return; hideAffordanceThinSkin(id , disabledImage, minimized); portletIdMap[id] = ""; } function showAffordanceThinSkin(id, selectedImage, minimized) { document.getElementById( 'menu_'+id ).style.cursor='pointer'; document.getElementById( 'portletTitleBar_'+id ).className='wpsThinSkinContainerBar wpsThinSkinContainerBarBorder'; document.getElementById( 'title_'+id ).className='wpsThinSkinDragZoneContainer wpsThinSkinVisible'; document.getElementById( 'menu_'+id+'_img' ).src=selectedImage; } function hideAffordanceThinSkin(id, disabledImage, minimized) { document.getElementById( 'menu_'+id ).style.cursor='default'; /* when minimized, the titlebar should always be displayed so it can be found by the user, so we don't hide it */ if (minimized == null || minimized == false){ document.getElementById( 'portletTitleBar_'+id ).className='wpsThinSkinContainerBar'; } document.getElementById( 'title_'+id ).className='wpsThinSkinDragZoneContainer wpsThinSkinInvisible'; document.getElementById( 'menu_'+id+'_img' ).src=disabledImage; } var onmousedownold_; function closeMenu(id, disabledImage) { hideCurrentContextMenu(); if ( portletIdMap[id] == "") { hideAffordance( id, disabledImage ); } document.onmousedown = onmousedownold_; } function showPortletMenu( id, portletNoActionsText, isRTL, menuPortletURL, disabledImage, loadingImage ) { if ( portletIdMap[id].indexOf( id ) < 0 ) return; asynchContextMenuOnMouseClickHandler('menu_'+id,!isRTL,menuPortletURL, null, null, null, null, portletNoActionsText, loadingImage ); onmousedownold_ = document.onmousedown; document.onmousedown = closeMenu; } function accessibleShowMenu( event , id , portletNoActionsText, isRTL, menuPortletURL, loadingImage ) { if ( event.which == 13 ) { asynchContextMenuOnMouseClickHandler( 'menu_'+id,!isRTL,menuPortletURL, null, null, null, null, portletNoActionsText, loadingImage ); } else { return true; } } wptheme_AsyncMenuAffordance = function ( /*String*/anchorId, /*String*/imageId, /*String*/showingImgUrl, /*String*/hidingImgUrl ) { // summary: Representation of an asynchronous menu's affordance (UI element which triggers the menu to show). Manages the details // of showing/hiding the affordance, if appropriate. // description: In the Portal theme, we want the menu affordance to only show during certain events (e.g. mouseover the page name). The details // of the showing/hiding is a little more complicated than changing the css on an HTML element due to various rendering/accessibility concerns. This // object manages these details. this.anchorId = anchorId; this.imageId = imageId; this.showingImgUrl = showingImgUrl; this.hidingImgUrl = hidingImgUrl; this.show = function () { // summary: Shows the affordance. if (document.getElementById( this.anchorId ) != null) { document.getElementById( this.anchorId ).style.cursor = 'pointer'; document.getElementById( this.imageId ).src=this.showingImgUrl; } } this.hide = function () { // summary: Hides the affordance. if (document.getElementById( this.anchorId ) != null) { document.getElementById( this.anchorId ).style.cursor = 'default'; document.getElementById( this.imageId ).src=this.hidingImgUrl; } } } wptheme_AsyncMenu = function ( /*String*/id, /*String*/menuBorderStyle, /*String*/menuStyle, /*String*/menuItemStyle, /*String*/selectedMenuItemStyle ) { // summary: Representation of an asynchronous context menu. Manages showing/hiding the menu as well as showing/hiding the menu's affordance (UI element // which opens the menu). // id: the menu's id // menuBorderStyle: the style name to be applied to the menu's border // menuStyle: the style name to be applied to the general menu // menuItemStyle: the style name to be applied to the menu item // selectedMenuItemStyle: the style name to be applied to a selected menu item //global utilities this._htmlUtils = wptheme_HTMLElementUtils; //properties passed in at construction time this.id = id; this.menuBorderStyle = menuBorderStyle; this.menuStyle = menuStyle; this.menuItemStyle = menuItemStyle; this.selectedMenuItemStyle = selectedMenuItemStyle; //properties that have to be initialized in the theme this.url = null; this.isRTL = false; this.emptyMenuText = null; this.loadingImgUrl = null; this.affordance = null; this.init = function ( /*String*/ url, /*boolean*/isRTL, /*String*/ emptyMenuText, /*String*/ loadingImgUrl, /*wptheme_MenuAffordance*/affordance, /*boolean*/renderBelow ) { // summary: Convenience function for setting up the required variables for showing the page menu. // url: the url to load page menu contents (usually created with ) // isRTL: is the current locale a right-to-left locale // emptyMenuText: the text to display if the user has no valid options // loadingImgUrl: the url to the image to display while the menu is loading this.url = url; this.isRTL = isRTL; this.emptyMenuText = emptyMenuText; this.loadingImgUrl = loadingImgUrl; this.affordance = affordance; this.renderBelow = renderBelow; } this.show = function ( /*Event?*/evt ) { // summary: Shows the page menu for the selected page. // description: Typically triggered by 2 types of events: click and keypress. On a click event, we just want to show the menu. On a keypress // event, we want to make sure the ENTER/RETURN key was pressed before showing the menu. // event: Event object passed in when triggered from a key press event. evt = this._htmlUtils.getEventObject( evt ); var show = false; var result; //On a keypress event, we want to make sure the ENTER/RETURN key was pressed before showing the menu. if ( evt && evt.type == "keypress" ) { var keyCode = -1; if ( evt && evt.which ){ keyCode = evt.which; } else { keyCode = evt.keyCode } //Enter/Return was the key that triggered this keypress event. if ( keyCode == 13 ) { show = true; } } else { //Some other kind of event, just show the menu already... show = true; } //Show the menu if necessary. if ( show ) { result = asynchContextMenuOnMouseClickHandler( this.id, !this.isRTL, this.url, this.menuBorderStyle, this.menuStyle, this.menuItemStyle, this.selectedMenuItemStyle, this.emptyMenuText, this.loadingImgUrl, this.renderBelow ); } return result; } this.showAffordance = function () { // summary: Shows the affordance associated with the given asynchronous menu. if ( asynchContextMenu_menuCurrentlyLoading == null ) { this.affordance.show(); } } this.hideAffordance = function () { // summary: Hides the affordance associated with the given asynchronous menu. if ( asynchContextMenu_menuCurrentlyLoading == null ) { this.affordance.hide(); } } } wptheme_ContextMenuUtils = { // summary: Utility object for managing the different context menus in the theme. Constructs the wptheme_AsyncMenu objects here, initialization must take place in // the head section of the HTML document (usually the initialization values require the usage of JSP tags). moreMenu: new wptheme_AsyncMenu( "wptheme_more_menu", "wptheme-more-menu-border", "wptheme-more-menu", "wptheme-more-menu-item", "wptheme-more-menu-item-selected", true ), topNavPageMenu: new wptheme_AsyncMenu( "wptheme_selected_page_menu", "wptheme-page-menu-border", "wptheme-page-menu", "wptheme-page-menu-item", "wptheme-page-menu-item-selected" ), sideNavPageMenu: new wptheme_AsyncMenu( "wptheme_selected_page_menu", "wptheme-page-menu-border", "wptheme-page-menu", "wptheme-page-menu-item", "wptheme-page-menu-item-selected" ) } ////////////////////////////////////////////////////////////////// // begin BrowserDimensions object definition BrowserDimensions.prototype = new Object(); BrowserDimensions.prototype.constructor = BrowserDimensions; BrowserDimensions.superclass = null; function BrowserDimensions(){ this.body = document.body; if (this.isStrictDoctype() && !this.isSafari()) { this.body = document.documentElement; } } BrowserDimensions.prototype.getScrollFromLeft = function(){ return this.body.scrollLeft ; } BrowserDimensions.prototype.getScrollFromTop = function(){ return this.body.scrollTop ; } BrowserDimensions.prototype.getViewableAreaWidth = function(){ return this.body.clientWidth ; } BrowserDimensions.prototype.getViewableAreaHeight = function(){ if(this.isSafari()) return document.documentElement.clientHeight; return this.body.clientHeight ; } BrowserDimensions.prototype.getHTMLElementWidth = function(){ return this.body.scrollWidth ; } BrowserDimensions.prototype.getHTMLElementHeight = function(){ return this.body.scrollHeight ; } BrowserDimensions.prototype.isStrictDoctype = function(){ return (document.compatMode && document.compatMode != "BackCompat"); } BrowserDimensions.prototype.isSafari = function(){ return (navigator.userAgent.toLowerCase().indexOf("safari") >= 0); } BrowserDimensions.prototype.isOpera = function(){ return (navigator.userAgent.toLowerCase().indexOf("opera") >= 0); } // end BrowserDimensions object definition ////////////////////////////////////////////////////////////////// //Provides a controller for enabling and disabling javascript events //on a particular HTML element. Elements must register with the controller //in order to be enabled/disabled. The act of registering with the controller //disables the element, unless otherwise specified. // // // **The main purpose of this controller is to disable the javascript //actions of certain elements that, if executed prior to the page completely //loading, cause problems. //Object definition for ElementJavascriptEventController function ElementJavascriptEventController() { //Registered elements to disable and enable upon page load. this.elements = new Array(); this.arrayPosition = 0; //Function mappings this.enableAll = enableRegisteredElementsInternal; this.disableAll = disableRegisteredElementsInternal; this.register = registerElementInternal; this.enable = enableRegisteredElementInternal; this.disable = disableRegisteredElementInternal; //Enables all registered items. function enableRegisteredElementsInternal() { for ( c=0; c < this.arrayPosition; c=c+1 ) { this.elements[c].enable(); } } function enableRegisteredElementInternal( id ) { for ( c=0; c < this.arrayPosition; c=c+1 ) { if ( this.elements[c].ID == id ) { this.elements[c].enable(); } } } //Disables all registered items. function disableRegisteredElementsInternal() { for ( c=0; c < this.arrayPosition; c=c+1 ) { this.elements[c].disable(); } } function disableRegisteredElementInternal( id ) { for ( c=0; c < this.arrayPosition; c=c+1 ) { if ( this.elements[c].ID == id ) { this.elements[c].disable(); } } } //Registers an item with the controller. function registerElementInternal( HTMLElementID, doNotDisable, optionalOnEnableJavascriptAction ) { this.elements[ this.arrayPosition ] = new RegisteredElement( HTMLElementID, doNotDisable, optionalOnEnableJavascriptAction ); this.arrayPosition = this.arrayPosition + 1; } } //Object definition for an element registered with the controller. //These objects should only be created by the controller. function RegisteredElement( ElementID, doNotDisable, optionalOnEnableJavascriptAction ) { //Information about the element. this.ID = ElementID; this.oldCursor = "normal"; this.ItemOnMouseDown = null; this.ItemOnMouseUp = null; this.ItemOnMouseOver = null; this.ItemOnMouseOut = null; this.ItemOnMouseClick = null; this.ItemOnBlur = null; this.ItemOnFocus = null; this.ItemOnChange = null; this.onEnableJS = optionalOnEnableJavascriptAction; //Function mappings this.enable = enableInternal; this.disable = disableInternal; //Enables an element. Enabling consists of changing the cursor //style back to the original style, and returning all the stored //javascript events to their original state. If the HTML element //is a button, the disabled property is simply set to false. function enableInternal() { if ( document.getElementById( this.ID ) ) { //Return the old cursor style. document.getElementById( this.ID ).style.cursor = this.oldCursor; //If it's a button, re-enable it. if ( document.getElementById( this.ID ).tagName == "BUTTON" ) { document.getElementById( this.ID ).disabled = false; } else { //Return all the events. document.getElementById( this.ID ).onmousedown = this.ItemOnMouseDown; document.getElementById( this.ID ).onmouseup = this.ItemOnMouseUp; document.getElementById( this.ID ).onmouseover = this.ItemOnMouseOver; document.getElementById( this.ID ).onmouseout = this.ItemOnMouseOut; document.getElementById( this.ID ).onclick = this.ItemOnMouseClick; document.getElementById( this.ID ).onblur = this.ItemOnBlur; document.getElementById( this.ID ).onfocus = this.ItemOnFocus; document.getElementById( this.ID ).onchange = this.ItemOnChange; } //Execute the onEnable Javascript, if specified. if ( this.onEnableJS != null ) { eval( this.onEnableJS ); } } } //Disables an element. Disabling consists of changing the cursor //style to "not-allowed", and setting all the javascript events to //do nothing. If the HTML element is a button, the "disabled" property //is simply set to true. function disableInternal() { if ( document.getElementById( this.ID ) ) { //Set the cursor style to point out that you can't do anything yet this.oldCursor = document.getElementById( this.ID ).style.cursor; document.getElementById( this.ID ).style.cursor = "not-allowed"; //If the HTML element is a BUTTON, we can easily disable it by //setting the disabled property to true. if ( document.getElementById( this.ID ).tagName == "BUTTON" ) { document.getElementById( this.ID ).disabled = true; } else { //Store all the current events registered to the item. this.ItemOnMouseDown = document.getElementById( this.ID ).onmousedown; this.ItemOnMouseUp = document.getElementById( this.ID ).onmouseup; this.ItemOnMouseOver = document.getElementById( this.ID ).onmouseover; this.ItemOnMouseOut = document.getElementById( this.ID ).onmouseout; this.ItemOnMouseClick = document.getElementById( this.ID ).onclick; this.ItemOnBlur = document.getElementById( this.ID ).onblur; this.ItemOnFocus = document.getElementById( this.ID ).onfocus; this.ItemOnChange = document.getElementById( this.ID ).onchange; //Now set all the current events to do nothing. document.getElementById( this.ID ).onmousedown = function () { void(0); return false; }; document.getElementById( this.ID ).onmouseup = function () { void(0); return false; }; document.getElementById( this.ID ).onmouseover = function () { void(0); return false; }; document.getElementById( this.ID ).onmouseout = function () { void(0); return false; }; document.getElementById( this.ID ).onclick = function () { void(0); return false; }; document.getElementById( this.ID ).onblur = function () { void(0); return false; }; document.getElementById( this.ID ).onfocus = function () { void(0); return false; }; document.getElementById( this.ID ).onchange = function () { void(0); return false; }; } } } //Disable the element if ( !doNotDisable ) { this.disable(); } } //Shows an IFRAME inside a lightbox which blocks access to the page. var wptheme_IFrameLightbox = function ( /*String*/disabledBackgroundClassname, /*String*/borderBoxClassname, /*String*/closeLinkClassname, /*String*/closeString ) { // summary: Creates a "lightbox" effect where a partially opaque div is set to cover the entire viewable area of the browser and the content // is displayed in an iframe in approximately the middle of the viewable area. // description: Creates a div the size of the viewable area of the browser which is styled using the given "disabledBackgroundClassname". The iframe is // displayed inside another div which is approximately centered and styled according to the given "borderBoxClassname". The content of the iframe is // set using the "setURL" function. The "lightbox" is closed via a text anchor link which is positioned above the top right edge of the border box. The // text displayed is controlled using the "closeString" parameter and the link is styled according to the "closeLinkClassname". // disabledBackgroundClassname: the CSS class name to apply to the background div displayed when the lightbox is showing // borderBoxClassname: the CSS class name to apply to the border box in the center of the page // closeString: the string which will be displayed as the link to close the lightbox this.className = "wptheme_IFrameLightbox"; //Declare this here so that any dependency error (e.g. wptheme_HTMLElementUtils not yet being defined) //is clear from the beginning (throws an error at construction time instead of runtime). Also, allows //for easy substitution of alternate implementations (as long as function names & signatures are the same). this._htmlUtils = wptheme_HTMLElementUtils; this._debugUtils = wptheme_DebugUtils; this._initialized = false; this.showing = false; var uniquePrefix = this._htmlUtils.getUniqueId(); this._backgroundDivId = uniquePrefix + "_lightboxPageBackgroundDiv"; this._borderDivId = uniquePrefix + "_lightboxBorderDiv"; this._closeLinkId = uniquePrefix + "_lightboxCloseLink"; this._iframeId = uniquePrefix + "_lightboxIframe"; // **************************************************************** // * Dynamically created DOM elements. // **************************************************************** function createDiv(idStr, className, parent ) { // summary: Creates a div with the given ID, class, and appends to the given parent node. The display property is set to none by default. var div = document.createElement( "DIV" ); div.id = idStr; div.className = className; div.style.display = "none"; parent.appendChild( div ); return div; } var me = this; function createLink(idStr, className, text, parent) { // summary: Creates a link with the given ID, class, textContent, and appends it to the given parent node. The display property is set to none // by default. The onclick is set to hide the lightbox. var a = document.createElement( "A" ); a.id = idStr; a.className = className; a.href = "javascript:void(0);"; a.onclick = function () { me.hide() }; a.style.display = "none"; a.appendChild( document.createTextNode( text ) ); parent.appendChild( a ); return a; } function createIFrame( idStr, parent ) { // summary: Creates an iframe with the given ID (also used for the name) and appends it to the given parent node. var iframe = document.createElement( "IFRAME" ); iframe.name = idStr; iframe.id = idStr; //iframe.style.display = "none"; parent.appendChild( iframe ); return iframe; } // **************************************************************** // * Initialization. // **************************************************************** this._init = function () { this._initialized = true; //Create the background div. createDiv( this._backgroundDivId, disabledBackgroundClassname, document.body ); //Create the border box div createIFrame( this._iframeId, createDiv( this._borderDivId, borderBoxClassname, document.body )); //Create the close link. createLink( this._closeLinkId, closeLinkClassname, closeString, document.body ); } // **************************************************************** // * Handling the browser scrolling and resizing dynamically. // **************************************************************** //Make sure to call any existing onscroll handler. var oldScrollFunc = window.onscroll; window.onscroll = function (e) { if ( me.showing ) { me.sizeAndPositionBorderBox(); //me.sizeBackgroundDisablingDiv(); } if ( oldScrollFunc ) { if (e) { oldScrollFunc(e); } else { oldScrollFunc(); } } } //Make sure to call any existing onresize handler. var oldResizeFunc = window.onresize; window.onresize = function (e) { if ( me.showing ) { me.sizeAndPositionBorderBox(); me.sizeBackgroundDisablingDiv(); } if ( oldResizeFunc ) { if (e) { oldResizeFunc(e); } else { oldResizeFunc(); } } } // **************************************************************** // * Main functions for use in the theme. // **************************************************************** this.setURL = function ( /*String*/url ) { // summary: Sets the URL displayed by the IFRAME in the lightbox. // url: the url to the resource to display window.frames[this._iframeId].location = url; } this.show = function ( /*String?*/url ) { // summary: Shows the lightbox above the disabled background div. // url: OPTIONAL -- the url to display in the iframe in the center of the screen if ( !this._initialized ) { this._init(); } this.showing = true; this.disableBackground(); this.showBorderBox(); if ( url ) { this.setURL( url ); } } this.hide = function() { // summary: Hides the lightbox and the disabled background div. if ( !this._initialized ) { this._init(); } this.showing = false; this.enableBackground(); this.hideBorderBox(); } // **************************************************************** // * Content border box // **************************************************************** this.showBorderBox = function () { // summary: Shows and positions the border box which contains the IFRAME. var div = document.getElementById( this._borderDivId ); div.style.display = "block"; var link = document.getElementById( this._closeLinkId ); link.style.display = "block"; this.sizeAndPositionBorderBox(); } this.sizeAndPositionBorderBox = function () { // summary: Sizes and positions the border box which contains the IFRAME. var div = document.getElementById( this._borderDivId ); this._htmlUtils.sizeRelativeToViewableArea( div, 0.60, 0.75 ); this._htmlUtils.positionRelativeToViewableArea( div, 0.20, 0.12 ); var link = document.getElementById( this._closeLinkId ); this._htmlUtils.positionOutsideElementTopRight( link, div ); } this.hideBorderBox = function () { // summary: hides the border box and IFRAME. document.getElementById( this._borderDivId ).style.display = "none"; document.getElementById( this._closeLinkId ).style.display = "none"; } // **************************************************************** // * Transparent background controls // **************************************************************** this.disableBackground = function () { // summary: Disables the background by laying a transparent div over top of the document body. var div = document.getElementById( this._backgroundDivId ); div.style.display = "block"; this.sizeBackgroundDisablingDiv(); this._htmlUtils.hideElementsByTagName( "select" ); } this.sizeBackgroundDisablingDiv = function () { // summary: Sizes the transparent div appropriately. var div = document.getElementById( this._backgroundDivId ); //dynamically size the div to the inner browser window this._htmlUtils.sizeToEntireArea( div ); } this.enableBackground=function () { // summary: Enables the background by hiding the overlaid div. this._htmlUtils.showElementsByTagName( "select" ); document.getElementById( this._backgroundDivId ).style.display = "none"; } }; /*********************************************************** {COPYRIGHT-TOP} *** * Licensed Materials - Property of IBM * Tivoli Presentation Services * * (C) Copyright IBM Corp. 2002,2003 All Rights Reserved. * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. ************************************************************ {COPYRIGHT-END} *** * Change Activity on 6/20/03 version 1.17: * @00=WCL, V3R0, 04/14/2002, JCP: Initial version * @01=D96484, V3R2, 06/14/2002, bcourt: hide select/iframe elements * @02=D99067, V3R2, 06/25/2002, bcourt: hide listbox scrollbar * @03=D97043, V3R3, 09/03/2002, JCP: fix launch menu item on linux NS6 * @04=D104656, V3R3, 09/16/2002, JCP: form submit instead of triggers, mozilla compatibility * @05=D107029, V3R4, 12/03/2002, Mark Rebuck: Added support for timed menu hiding * @06=D110173, V3R4, 03/24/2003, JCP: selection sometimes gets stuck * @07=D113641, V3R4, 04/29/2003, LSR: Requirement #258 Shorten CSS Names * @08=D113626, V3R4, 06/20/2003, JCP: clicking on text doesn't launch action on linux Moz13 *******************************************************************************/ var visibleMenu_ = null; var padding_ = 10; var transImg_ = "transparent.gif"; var arrowNorm_ = "contextArrowDefault.gif"; var arrowSel_ = "contextArrowSelected.gif"; var arrowDis_ = "contextArrowDisabled.gif"; var launchNorm_ = "contextLauncherDefault.gif"; var launchSel_ = "contextLauncherSelected.gif"; var arrowNormRTL_ = "contextArrowDefault.gif"; var arrowSelRTL_ = "contextArrowSelected.gif"; var arrowDisRTL_ = "contextArrowDisabled.gif"; var launchNormRTL_ = "contextLauncherDefault.gif"; var launchSelRTL_ = "contextLauncherSelected.gif"; var wclIsOpera_ = /Opera/.test(navigator.userAgent); //ARC CHANGES FOR SPECIFYING STYLES - BEGIN var defaultContextMenuBorderStyle_ = "lwpShadowBorder"; var defaultContextMenuTableStyle_ = "lwpBorderAll"; //ARC CHANGES FOR SPECIFYING STYLES - END var arrowWidth_ = "12"; var arrowHeight_ = "12"; var submenuAltText_ = "+"; //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - BEGIN var defaultNoActionsText_ = "(0)"; var defaultNoActionsTextStyle_ = "lwpMenuItemDisabled"; //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - END var hideCurrentMenuTimer_ = null; var onmousedown_ = document.onmousedown; function clearMenuTimer( ) { //@05 if (null != hideCurrentMenuTimer_) { clearTimeout( hideCurrentMenuTimer_ ); hideCurrentMenuTimer_ = null; } } function setMenuTimer( ) { // @05 clearMenuTimer( ); hideCurrentMenuTimer_ = setTimeout( 'hideCurrentContextMenu( )', 2000); } function debug( str ) { /* if ( xbDEBUG != null ) { xbDEBUG.dump( str ); } */ } // constructor function UilContextMenu( name, isLTR, width, borderStyle, tableStyle, emptyMenuText, emptyMenuTextStyle, positionUnder ) { // member variables this.name = name; this.items = new Array(); this.isVisible = false; this.isDismissable = true; this.selectedItem = null; this.isDynamic = false; this.isCacheable = false; this.isEmpty = true; this.isLTR = isLTR; this.hiddenItems = new Array(); //@01A this.isHyperlinkChild = true; // We will reset later if needed. this.bottomPositioned = positionUnder; // html variables this.launcher = null; this.menuTag = null; //ARC CHANGES FOR SPECIFYING STYLES - BEGIN //styles for menu if ( borderStyle != null ) { this.menuBorderStyle = borderStyle; } else { this.menuBorderStyle = defaultContextMenuBorderStyle_; } if ( tableStyle != null ) { this.menuTableStyle = tableStyle; } else { this.menuTableStyle = defaultContextMenuTableStyle_; } //ARC CHANGES FOR SPECIFYING STYLES - END //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - BEGIN if ( emptyMenuText != null ) { this.noActionsText = emptyMenuText; } else { this.noActionsText = defaultNoActionsText_; } if ( emptyMenuTextStyle != null ) { this.noActionsTextStyle = emptyMenuTextStyle; } else { this.noActionsTextStyle = defaultNoActionsTextStyle_; } //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - END // external methods this.add = UilContextMenuAdd; this.addSeparator = UilContextMenuAddSeparator; this.show = UilContextMenuShow; this.hide = UilContextMenuHide; // internal methods this.create = UilContextMenuCreate; this.getMenuItem = UilContextMenuGetMenuItem; this.getSelectedItem = UilContextMenuGetSelectedItem; if ( this.name == null ) { this.name = "UilContextMenu_" + allMenus_.length; } } // adds a menu item to the context menu function UilContextMenuAdd( item ) { this.items[ this.items.length ] = item; this.isEmpty = false; } function UilContextMenuAddSeparator() { var sep = new UilMenuItem(); sep.isSeparator = true; this.add( sep ); } // shows the context menu // launcher- html element (anchor) that is launching the menu // launchItem- menu item that is launching the menu function UilContextMenuShow( launcher, launchItem ) { if ( this.items.length == 0 ) { // empty context menu debug( 'menu is empty!' ); //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - BEGIN this.add( new UilMenuItem( this.noActionsText, false, "javascript:void(0);", null, null, null, null, this.noActionsTextStyle ) ); //ARC CHANGES FOR SPECIFIYING EMPTY MENU TEXT - END this.isEmpty = true; } if ( this.menuTag == null ) { // create the context menu html this.create(); } else { this.menuTag.style.left = ""; //196195 //Reset this.menuTag.style.top = ""; //196195 //Reset this.menuTag.style.width = ""; //"0px"; //196195 //Reset this.menuTag.style.height = ""; //196195 //Reset this.menuTag.style.overflow = "visible"; //196195 //Reset, No horizontal and vertical scrollbars } if ( this.menuTag != null) { // store the launcher for later this.launcher = launcher; if ( this.launcher.tagName == "IMG" ) { this.isHyperlinkChild = false; // we want the anchor tag this.launcher = this.launcher.parentNode; } // boundaries of window var bd = new ContextMenuBrowserDimensions(); var maxX = bd.getScrollFromLeft() + bd.getViewableAreaWidth(); var maxY = bd.getScrollFromTop() + bd.getViewableAreaHeight(); var minX = bd.getScrollFromLeft(); var minY = bd.getScrollFromTop(); debug( 'max: ' + maxX + ', ' + maxY ); var menuWidth = getWidth( this.menuTag ); var menuHeight = getHeight( this.menuTag ); // move the context menu to the right of the launcher var posX = 0; var posY = 0; var fUseUpperY = false; //196195 var maxUpperPosY = 0; //196195 if ( launchItem != null ) { // launched from submenu var launchTag = launchItem.itemTag; var launchTagWidth = getWidth( launchTag ); var parentTag = launchItem.parentMenu.menuTag; //@04A var launchOffsetX = getLeft( parentTag ); //@04C var launchOffsetY = getTop( parentTag ); //@04C posX = launchOffsetX + getLeft( launchTag ) + launchTagWidth; //@04C posY = launchOffsetY + getTop( launchTag ); //@04C if ( !this.isLTR ) { posX -= launchTagWidth; posX -= menuWidth; } // try to keep it in the window if ( this.isLTR ) { if ( posX + menuWidth > maxX ) { // try to show it to the left of the parent menu var posX1 = launchOffsetX - menuWidth; var posX2 = maxX - menuWidth; if ( 0 <= posX1 ) { posX = posX1; } else { posX = Math.max( minX, posX2 ); } } } else { if ( posX < 0 ) { // try to show it to the right of the parent menu var posX1 = launchOffsetX + launchTagWidth; if ( posX1 + menuWidth < maxX ) { posX = posX1; } else { posX = Math.min( maxX, maxX - menuWidth ); } } } if ( posY + menuHeight > maxY ) { var posY1 = maxY - menuHeight; posY = Math.max( minY, posY1 ); } } else { // launched from menu link var launcherLeft = getLeft( this.launcher, true ) if ( this.launcher.tagName == "BUTTON" || this.bottomPositioned ) { posX = launcherLeft; // bidi if ( !this.isLTR ) { //196195 posX += getWidth( this.launcher ) - getWidth( this.menuTag ); posX += getWidth( this.launcher ) - menuWidth; //196195 } if (this.isLTR) { if ((posX + menuWidth) > maxX) { //196195 begins if ((posX + getWidth(this.launcher)) > maxX) { posX = Math.max(minX, maxX - menuWidth); } else //196195 ends posX = Math.max(minX, posX + getWidth( this.launcher ) - menuWidth); } //196195 begins else if (posX < minX) { posX = minX; } //196195 ends } else{ if (posX < minX) { //196195 if ((launcherLeft + menuWidth) < maxX) { if ((launcherLeft > minX) && ((launcherLeft + menuWidth) < maxX)) { //196195 posX = launcherLeft; } else{ posX = Math.min(minX, maxX - menuWidth); } } //196195 begins else if ( (posX + menuWidth) > maxX) { if (Math.min(posX, maxX - menuWidth) >= minX) posX = Math.min(posX, maxX - menuWidth); } //196195 ends } maxUpperPosY = getTop( this.launcher, true ); //196195 var upperVisibleHeight = maxUpperPosY - minY; //196195 posY = getTop( this.launcher, true ) + getHeight( this.launcher ); var lowerVisibleHeight = maxY - posY; //196195 //196195 if ( posY + menuHeight > maxY ) { if ( (posY + menuHeight > maxY) && (lowerVisibleHeight < upperVisibleHeight) ) { //196195 // top posY -= (menuHeight + getHeight( this.launcher )); fUseUpperY = true; //196195 } if ( posY < minY ) { posY = minY; } } else { // left-right posX = launcherLeft + this.launcher.offsetWidth; posY = getTop( this.launcher, true ); if ( !this.isLTR ) { posX -= this.launcher.offsetWidth; posX -= menuWidth; } // keep it in the window if ( this.isLTR ) { if ( posX + menuWidth > maxX ) { // try to show it on the left side of the launcher var posX1 = launcherLeft - menuWidth; if ( posX1 > 0 ) { posX = posX1; } else { posX = Math.max( minX, maxX - menuWidth ); } } } else { if ( posX < minX ) { // try to show it on the right side of the launcher var posX1 = launcherLeft + this.launcher.offsetWidth; if ( posX1 + menuWidth < maxX ) { posX = posX1; } else { posX = Math.min( minX, maxX - menuWidth ); } } } if ( posY + menuHeight > maxY ) { posY = Math.max( minY, maxY - menuHeight ); } } if ( ((posX + menuWidth) > maxX) || (((posY + menuHeight) > maxY) && (fUseUpperY == false)) || (((posY + menuHeight) > maxUpperPosY) && (fUseUpperY == true)) ) { if (posX + menuWidth > maxX) { this.menuTag.style.width = (maxX - posX) + "px"; } else{ this.menuTag.style.width = menuWidth + "px"; } if (fUseUpperY == false) { if (posY + menuHeight > maxY) { this.menuTag.style.height = (maxY - posY) + "px"; } else { this.menuTag.style.height = menuHeight + "px"; } } else { if (posY + menuHeight > maxUpperPosY) { this.menuTag.style.height = (maxUpperPosY - posY) + "px"; } else { this.menuTag.style.height = menuHeight + "px"; } } this.menuTag.style.overflow = "auto"; } else { //196195 begins this.menuTag.style.width = menuWidth + "px"; this.menuTag.style.height = menuHeight + "px"; this.menuTag.style.overflow = "visible"; //196195 } //196196 ends } debug( 'show ' + this.name + ': ' + posX + ', ' + posY ); this.menuTag.style.left = posX + "px"; this.menuTag.style.top = posY + "px"; // make the context menu visible this.menuTag.style.visibility = "visible"; this.isVisible = true; // set focus on the first menu item this.items[0].setSelected( true ); this.items[0].anchorTag.focus(); /* // no longer needed since fixed in Opera 9, and no other non-IE browsers need this // @01A - Hide any items that intersect this menu var coll = document.getElementsByTagName("SELECT"); if (coll!=null) { for (i=0; i= b ) ) { return true; } else { return false; } } // hides the context menu function UilContextMenuHide() { if ( this.menuTag != null ) { debug( 'hide ' + this.name ); // hide any visible submenus first for ( var i=0; i