+++ /dev/null
-//
-// Displays and hide pop-up menus.
-// Pop-ups are displayed when left-clicking on an edition icon of a link.
-// The HTML corresponding tags are supposed being the following:
-//
-// <a href="popupname"><img src="{path}icon.ed..." .../></a>
-//
-// Any other HTML construct will be ignored.
-//
-// Pop-ups can be used on a web page including java applets.
-// If a pop-up hides an applet, this latter must be hidden when displaying the pop-up - as a limitation,
-// the applet is supposed entirely hidden by the pop-up.
-// By convention:
-// - such pop-up must be named "toolpop" (<div id="toolpop"...></div><a href="toolpop">...</a>),
-// - the applet must be named "perform" (<applet id="perform"...></applet>).
-
- var _iconName = "icon.ed";
- var _appletName = "perform";
- var _hiddingPopup = "toolpop";
-
- var _replaceContext = false; // replace the system context menu
- var _mouseOverContext = false; // is the mouse over the context menu
- var _divContext = null;
- var _appletContext = null; // Applet hidden by the popup
-
- InitContext();
-
- function InitContext() {
-// ----------------------
- document.onmousedown = ContextMouseDown;
- document.onclick = ContextShow;
- }
-
-// Call from the onMouseDown event, passing the event if standards compliant
- function ContextMouseDown(event) {
-// --------------------------------
- if (_mouseOverContext) return;
-
- var leftbutton = 0;
-
- // IE is evil and doesn't pass the event object
- if (event == null) {
- event = window.event;
- leftbutton = 1;
- }
- // We assume we have a standards compliant browser, but check if we have IE
- var target = event.target != null ? event.target : event.srcElement;
-
- // Only show the context menu if the right mouse button is pressed
- // and a hyperlink on an edit icon has been clicked
- if (_divContext != null) ContextHide(); // In case of another context menu previously shown
- if (target.tagName.toLowerCase() == 'img') {
- if (target.src.indexOf(_iconName) < 0) return;
- target = target.parentNode;
- }
- if (event.button == leftbutton && target.tagName.toLowerCase() == 'a') {
- _replaceContext = true;
- if (target.getAttribute("href") == _hiddingPopup) _appletContext = document.getElementById(_appletName);
- }
- }
-
- function ContextHide() {
-// -----------------------
- _divContext.style.display = 'none';
- if (_appletContext != null) {
- _appletContext.style.display = 'inline';
- _appletContext = null;
- }
- }
-
-// Call from the onContextMenu event, passing the event
-// If this function returns false, the browser's context menu will not show up
- function ContextShow(event) {
-// ---------------------------
- if (_mouseOverContext) return true;
-
- // IE is evil and doesn't pass the event object
- if (event == null) event = window.event;
-
- // we assume we have a standards compliant browser, but check if we have IE
- var target = event.target != null ? event.target : event.srcElement;
- target = target.parentNode; // Gets the hyperlink
- if (_replaceContext) {
- _divContext = $(target.attributes[0].nodeValue); // Popup involved (made of document index prefixed by "popup")
-
- // document.body.scrollTop does not work in IE
- var scrollTop = document.scrollTop ? document.scrollTop : document.documentElement.scrollTop;
- var scrollLeft = document.scrollLeft ? document.scrollLeft : document.documentElement.scrollLeft;
-
- // hide the menu first to avoid an "up-then-over" visual effect
- _divContext.style.display = 'none';
- _divContext.style.left = event.clientX + scrollLeft + 'px';
- _divContext.style.top = event.clientY + scrollTop + 'px';
- _divContext.style.display = 'block';
-
- _replaceContext = false;
- if (_appletContext != null) _appletContext.style.display = 'none';
-
- return false;
- }
- return true;
- }
-
-// For making easier on the eyes and fingers
- function $(id) {
-// --------------
- return document.getElementById(id);
- }
\ No newline at end of file