- function getContextMenuCode() {
- if ($this->isCMlayers()) {
- $content='
- <script type="text/javascript">
- /*<![CDATA[*/
- var GLV_gap=10;
- var GLV_curLayerX=new Array(0,0);
- var GLV_curLayerY=new Array(0,0);
- var GLV_curLayerWidth=new Array(0,0);
- var GLV_curLayerHeight=new Array(0,0);
- var GLV_isVisible=new Array(0,0);
- var GLV_x=0;
- var GLV_y=0;
- var GLV_xRel=0;
- var GLV_yRel=0;
- var layerObj=new Array();
- var layerObjCss=new Array();
-
- //browsercheck...
- function GL_checkBrowser(){ //
- this.dom= (document.getElementById);
- this.op= (navigator.userAgent.indexOf("Opera")>-1);
- this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
- this.konq= (navigator.userAgent.indexOf("Konq")>-1);
- this.ie4= (document.all && !this.dom && !this.op && !this.konq);
- this.ie5= (document.all && this.dom && !this.op && !this.konq);
- this.ns4= (document.layers && !this.dom && !this.konq);
- this.ns5= (!document.all && this.dom && !this.op && !this.konq);
- this.ns6= (this.ns5);
- this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
- return this;
- }
- bw= new GL_checkBrowser();
-
- // GL_getObj(obj)
- function GL_getObj(obj){ //
- nest="";
- this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
- this.css= bw.ns4?this.el:this.el.style;
- this.ref= bw.ns4?this.el.document:document;
- this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
- this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
- this.height= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
- this.width= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
- return this;
- }
- // GL_getObjCss(obj)
- function GL_getObjCss(obj){ //
- return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
- }
- // GL_getMouse(event)
- function GL_getMouse(event) { //
- if (layerObj) {
-// GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
-// GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
- // 17/12 2003: When documents run in XHTML standard compliance mode, the old scrollLeft/Top properties of document.body is gone - and for Opera/MSIE we have to use document.documentElement:
-
- GLV_xRel = event.clientX-2;
- GLV_yRel = event.clientY-2;
- GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
- GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
-
- // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
- if (GLV_isVisible[1]) {
- if (outsideLayer(1)) hideSpecific(1);
- } else if (GLV_isVisible[0]) {
- if (outsideLayer(0)) hideSpecific(0);
- }
- }
- }
- // outsideLayer(level)
- function outsideLayer(level) { //
- return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
- GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
- GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
- GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
- }
- // setLayerObj(html,level)
- function setLayerObj(html,level) { //
- var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
- var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
- var tempLayerObj = GL_getObj("contentMenu"+level);
- var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
-
- if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
- tempLayerObj.el.innerHTML = html;
- tempLayerObj.width= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
- tempLayerObj.height= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
-
- // konqueror (3.2.2) workaround
- winHeight = (bw.konq)?window.innerHeight:winHeight;
- winWidth = (bw.konq)?window.innerWidth:winWidth;
-
- // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
- if (winHeight-tempLayerObj.height < GLV_yRel) {
- if (GLV_yRel < tempLayerObj.height) {
- GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel); // Setting it so bottom is just above window height.
- } else {
- GLV_y-= tempLayerObj.height-8; // Showing the menu upwards
- }
- }
- // Adjusting the X position like Y above
- if (winWidth-tempLayerObj.width < GLV_xRel) {
- if (GLV_xRel < tempLayerObj.width) {
- GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
- } else {
- GLV_x-= tempLayerObj.width-8;
- }
- }
- GLV_x = Math.max(GLV_x,1);
- GLV_y = Math.max(GLV_y,1);
-
- GLV_curLayerX[level] = GLV_x;
- GLV_curLayerY[level] = GLV_y;
- tempLayerObjCss.left = GLV_x+"px";
- tempLayerObjCss.top = GLV_y+"px";
- tempLayerObjCss.visibility = "visible";
- if (bw.ie5) showHideSelectorBoxes("hidden");
-
- GLV_isVisible[level]=1;
- GLV_curLayerWidth[level] = tempLayerObj.width;
- GLV_curLayerHeight[level] = tempLayerObj.height;
- }
- }
- // hideEmpty()
- function hideEmpty() { //
- hideSpecific(0);
- hideSpecific(1);
- return false;
- }
- // hideSpecific(level)
- function hideSpecific(level) { //
- GL_getObjCss("contentMenu"+level).visibility = "hidden";
- GL_getObj("contentMenu"+level).el.innerHTML = "";
- GLV_isVisible[level]=0;