Author: xlawrence
Date: Mon Nov 5 16:36:24 2007
New Revision: 8
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D8&repname=3Dc=
orporate_portal_templates_v3
Log:
update the action menu file with the latest version coming from v2 templates
Modified:
trunk/src/jsp/shared/js/actions.js
Modified: trunk/src/jsp/shared/js/actions.js
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/src/jsp/shared/=
js/actions.js&rev=3D8&repname=3Dcorporate_portal_templates_v3
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/jsp/shared/js/actions.js (original)
+++ trunk/src/jsp/shared/js/actions.js Mon Nov 5 16:36:24 2007
@@ -1,770 +1,769 @@
-//************************************************************************=
*****
-// Do not remove this notice.
-//
-// Copyright 2000 by Mike Hall.
-// See http://www.brainjar.com for terms of use.
-
-// Modified by Xavier Lawrence, 2005 Copyright Jahia Solutions
-//************************************************************************=
*****
-
-//------------------------------------------------------------------------=
----
-// Code to determine the browser and version.
-//------------------------------------------------------------------------=
----
-
-function Browser() {
-
- var ua, s, i;
-
- this.isIE =3D false; // Internet Explorer
- this.isNS =3D false; // Netscape
- this.version =3D null;
-
- ua =3D navigator.userAgent;
-
- s =3D "MSIE";
- if ((i =3D ua.indexOf(s)) >=3D 0) {
- this.isIE =3D true;
- this.version =3D parseFloat(ua.substr(i + s.length));
- return;
- }
-
- s =3D "Netscape6/";
- if ((i =3D ua.indexOf(s)) >=3D 0) {
- this.isNS =3D true;
- this.version =3D parseFloat(ua.substr(i + s.length));
- return;
- }
-
- // Treat any other "Gecko" browser as NS 6.1.
-
- s =3D "Gecko";
- if ((i =3D ua.indexOf(s)) >=3D 0) {
- this.isNS =3D true;
- this.version =3D 6.1;
- return;
- }
-}
-
-var browser =3D new Browser();
-
-//------------------------------------------------------------------------=
----
-// Code for handling the menu bar and active button.
-//------------------------------------------------------------------------=
----
-
-var activeButton =3D null;
-
-// AJAX variables
-var req;
-
-// Capture mouse clicks on the page so any active button can be
-// deactivated.
-
-if (browser.isIE)
- document.onmousedown =3D pageMousedown;
-else
- document.addEventListener("mousedown", pageMousedown, true);
-
-function pageMousedown(event) {
-
- var el;
-
- // If there is no active button, exit.
-
- if (activeButton =3D=3D null)
- return;
-
- // Find the element that was clicked on.
-
- if (browser.isIE)
- el =3D window.event.srcElement;
- else
- el =3D (event.target.tagName ? event.target : event.target.parentNode);
-
- // If the active button was clicked on, exit.
-
- if (el =3D=3D activeButton)
- return;
-
- // If the element is not part of a menu, reset and clear the active
- // button.
-
- if (getContainerWith(el, "DIV", "menu") =3D=3D null) {
- resetButton(activeButton);
- activeButton =3D null;
- }
-}
-
-// Opens up the menu of the given id
-function buttonClick (menuId) {
- var button =3D getObjectById ("button_" + menuId);
-
- // Blur focus from the link to remove that annoying outline.
- button.blur();
-
- // Associate the named menu to this button if not already done.
- // Additionally, initialize menu display.
- if (button.menu =3D=3D null) {
- button.menu =3D getObjectById (menuId);
- if (button.menu.isInitialized =3D=3D null) {
- menuInit(button.menu);
- }
- }
-
- // Reset the currently active button, if any.
-
- if (activeButton !=3D null) {
- resetButton(activeButton);
- }
-
- // Activate this button, unless it was the currently active one.
-
- if (button !=3D activeButton) {
- depressButton(button);
- activeButton =3D button;
- } else {
- activeButton =3D null;
- }
-}
-
-// Switches menu if the user's mouse goes on another menu
-function buttonMouseover(event, menuId) {
- var button;
-
- // Find the target button element.
- if (browser.isIE) {
- button =3D window.event.srcElement;
- } else {
- button =3D event.currentTarget;
- }
-
- // If any other button menu is active, make this one active instead.
- if (activeButton !=3D null && activeButton !=3D button) {
- buttonClick (menuId);
- }
-}
-
-function depressButton(button) {
- var x, y;
-
- // Update the button's style class to make it look like it's
- // depressed.
-
- button.className +=3D " menuButtonActive";
-
- // Position the associated drop down menu under the button and
- // show it.
-
-
-
- var pos =3D Position.positionedOffset(button);
- var x =3D pos[0];
- var y =3D pos[1] + 15;
- if(x > 780)
- {
- x =3D 780;
- }
-
- button.menu.style.left =3D x + "px";
- button.menu.style.top =3D y + "px";
- button.menu.style.visibility =3D "visible";
- button.menu.style.display =3D "block";
-}
-
-function resetButton(button) {
-
- // Restore the button's style class.
-
- removeClassName(button, "menuButtonActive");
-
- // Hide the button's menu, first closing any sub menus.
-
- if (button.menu !=3D null) {
- closeSubMenu(button.menu);
- button.menu.style.display =3D "none";
- }
-}
-
-//------------------------------------------------------------------------=
----
-// Code to handle the menus and sub menus.
-//------------------------------------------------------------------------=
----
-
-function menuMouseover(event) {
-
- var menu;
-
- // Find the target menu element.
-
- if (browser.isIE)
- menu =3D getContainerWith(window.event.srcElement, "DIV", "menu");
- else
- menu =3D event.currentTarget;
-
- // Close any active sub menu.
-
- if (menu.activeItem !=3D null)
- closeSubMenu(menu);
-}
-
-function menuItemMouseover(event, menuId) {
-
- var item, menu, x, y;
-
- // Find the target item element and its parent menu element.
-
- if (browser.isIE)
- item =3D getContainerWith(window.event.srcElement, "A", "menuItem");
- else
- item =3D event.currentTarget;
- menu =3D getContainerWith(item, "DIV", "menu");
-
- // Close any active sub menu and mark this one as active.
-
- if (menu.activeItem !=3D null)
- closeSubMenu(menu);
- menu.activeItem =3D item;
-
- // Highlight the item element.
-
- item.className +=3D " menuItemHighlight";
-
- // Initialize the sub menu, if not already done.
-
- if (item.subMenu =3D=3D null) {
- item.subMenu =3D document.getElementById(menuId);
- if (item.subMenu.isInitialized =3D=3D null)
- menuInit(item.subMenu);
- }
-
- // Get position for submenu based on the menu item.
-
- x =3D getPageOffsetLeft(item) + item.offsetWidth;
- y =3D getPageOffsetTop(item);
-
- // Adjust position to fit in view.
-
- var maxX, maxY;
-
- if (browser.isNS) {
- maxX =3D window.scrollX + window.innerWidth;
- maxY =3D window.scrollY + window.innerHeight;
- }
- if (browser.isIE) {
- maxX =3D (document.documentElement.scrollLeft !=3D 0 ? document.docu=
mentElement.scrollLeft : document.body.scrollLeft)
- + (document.documentElement.clientWidth !=3D 0 ? document.docume=
ntElement.clientWidth : document.body.clientWidth);
- maxY =3D (document.documentElement.scrollTop !=3D 0 ? document.docu=
mentElement.scrollTop : document.body.scrollTop)
- + (document.documentElement.clientHeight !=3D 0 ? document.docume=
ntElement.clientHeight : document.body.clientHeight);
- }
- maxX -=3D item.subMenu.offsetWidth;
- maxY -=3D item.subMenu.offsetHeight;
-
- if (x > maxX)
- x =3D Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
- + (menu.offsetWidth - item.offsetWidth));
- y =3D Math.max(0, Math.min(y, maxY));
-
- // Position and show it.
-
- item.subMenu.style.left =3D x + "px";
- item.subMenu.style.top =3D y + "px";
- item.subMenu.style.visibility =3D "visible";
-
- // Stop the event from bubbling.
-
- if (browser.isIE)
- window.event.cancelBubble =3D true;
- else
- event.stopPropagation();
-}
-
-function closeSubMenu(menu) {
-
- if (menu =3D=3D null || menu.activeItem =3D=3D null)
- return;
-
- // Recursively close any sub menus.
-
- if (menu.activeItem.subMenu !=3D null) {
- closeSubMenu(menu.activeItem.subMenu);
- menu.activeItem.subMenu.style.visibility =3D "hidden";
- menu.activeItem.subMenu =3D null;
- }
- removeClassName(menu.activeItem, "menuItemHighlight");
- menu.activeItem =3D null;
-}
-
-//------------------------------------------------------------------------=
----
-// Code to initialize menus.
-//------------------------------------------------------------------------=
----
-
-function menuInit(menu) {
-
- var itemList, spanList;
- var textEl, arrowEl;
- var itemWidth;
- var w, dw;
- var i, j;
-
- // For IE, replace arrow characters.
-
- if (browser.isIE) {
- menu.style.lineHeight =3D "2.5ex";
- spanList =3D menu.getElementsByTagName("SPAN");
- for (i =3D 0; i < spanList.length; i++)
- if (hasClassName(spanList[i], "menuItemArrow")) {
- spanList[i].style.fontFamily =3D "Webdings";
- spanList[i].firstChild.nodeValue =3D "4";
- }
- }
-
- // Find the width of a menu item.
-
- itemList =3D menu.getElementsByTagName("A");
- if (itemList.length > 0)
- itemWidth =3D itemList[0].offsetWidth;
- else
- return;
-
- // For items with arrows, add padding to item text to make the
- // arrows flush right.
-
- for (i =3D 0; i < itemList.length; i++) {
- spanList =3D itemList[i].getElementsByTagName("SPAN");
- textEl =3D null;
- arrowEl =3D null;
- for (j =3D 0; j < spanList.length; j++) {
- if (hasClassName(spanList[j], "menuItemText"))
- textEl =3D spanList[j];
- if (hasClassName(spanList[j], "menuItemArrow"))
- arrowEl =3D spanList[j];
- }
- if (textEl !=3D null && arrowEl !=3D null)
- textEl.style.paddingRight =3D (itemWidth
- - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
- }
-
- // Fix IE hover problem by setting an explicit width on first item of
- // the menu.
-
- if (browser.isIE) {
- w =3D itemList[0].offsetWidth;
- itemList[0].style.width =3D w + "px";
- dw =3D itemList[0].offsetWidth - w;
- w -=3D dw;
- itemList[0].style.width =3D w + "px";
- }
-
- // Mark menu as initialized.
-
- menu.isInitialized =3D true;
-}
-
-//------------------------------------------------------------------------=
----
-// General utility functions.
-//------------------------------------------------------------------------=
----
-
-function getContainerWith(node, tagName, className) {
-
- // Starting with the given node, find the nearest containing element
- // with the specified tag name and style class.
-
- while (node !=3D null) {
- if (node.tagName !=3D null && node.tagName =3D=3D tagName &&
- hasClassName(node, className))
- return node;
- node =3D node.parentNode;
- }
-
- return node;
-}
-
-function hasClassName(el, name) {
-
- var i, list;
-
- // Return true if the given element currently has the given class
- // name.
-
- list =3D el.className.split(" ");
- for (i =3D 0; i < list.length; i++)
- if (list[i] =3D=3D name)
- return true;
-
- return false;
-}
-
-function removeClassName(el, name) {
-
- var i, curList, newList;
-
- if (el.className =3D=3D null)
- return;
-
- // Remove the given class name from the element's className property.
-
- newList =3D new Array();
- curList =3D el.className.split(" ");
- for (i =3D 0; i < curList.length; i++)
- if (curList[i] !=3D name) {
- // Workaround to replace the push method.
- var _curList =3D new Array(curList[i]);
- newList.concat(_curList);
- // Comment this line because not supported by IE5.0
- //newList.push(curList[i]);
- }
- el.className =3D newList.join(" ");
-}
-
-function getPageOffsetLeft(el) {
-
- var x;
-
- // Return the x coordinate of an element relative to the page.
-
- x =3D el.offsetLeft;
- if (el.offsetParent !=3D null)
- x +=3D getPageOffsetLeft(el.offsetParent);
-
- return x;
-}
-
-function getPageOffsetTop(el) {
-
- var y;
-
- // Return the x coordinate of an element relative to the page.
-
- y =3D el.offsetTop;
- if (el.offsetParent !=3D null)
- y +=3D getPageOffsetTop(el.offsetParent);
-
- return y;
-}
-
-// Check the browser for DOM manipulation
-function checkBrowser(){
- this.ver=3Dnavigator.appVersion;
- this.dom=3Ddocument.getElementById?1:0;
- this.ie6=3D(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
- this.ie55=3D((this.ver.indexOf("MSIE 5.5")>-1 || this.ie6) && this.dom)?=
1:0;
- this.ie5=3D((this.ver.indexOf("MSIE 5")>-1 || this.ie5 || this.ie6) && t=
his.dom)?1:0;
- this.ie4=3D(document.all && !this.dom)?1:0;
- this.ns5=3D(this.dom && parseInt(this.ver) >=3D 5) ?1:0;
- this.ns4=3D(document.layers && !this.dom)?1:0;
- this.ie4plus=3D(this.ie6 || this.ie5 || this.ie4);
- this.ie5plus=3D(this.ie6 || this.ie5)
- this.bw=3D(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5);
- return this;
-}
-
-bw =3D new checkBrowser();
-
-// Get an Object contained in a DOM document by its ID attribute
-function getObjectById (ID) {
- var obj;
- if (bw.dom)
- return document.getElementById (ID);
- else if (bw.ie4)
- return document.all (ID);
- else
- alert ("Error: Your browser version is not supported. Please upgrade..=
.");
- return null;
-}
-
-// Returns an array of values. The delimiter is the ',' character
-function getNodeValues (content, nodeName) {
- var tag =3D "<" + nodeName + ">";
- var start =3D content.indexOf (tag);
- var end =3D content.indexOf ("</" + nodeName + ">");
-
- if (start < end) {
- var values =3D content.substring (start + tag.length, end);
- return values.split (";;");
- } else {
- return new Array (0);
- }
-}
-
-// Returns the value of an XML tag
-function getNodeValue (content, nodeName) {
- var tag =3D "<" + nodeName + ">";
- var start =3D content.indexOf (tag);
- var end =3D content.indexOf ("</" + nodeName + ">");
-
- if (start < end) {
- return content.substring (start + tag.length, end);
- } else {
- return null;
- }
-}
-
-// AJAX based function to get all Actions to fill up the Action menu
-function getActionMenu(context, objectType, objectKey, definitionID, paren=
tID, pageID, domID) {
- document.body.style.cursor =3D "wait";
- try {
- // correct values are "POST" or "GET" (HTTP methods).
- var method =3D "POST" ;
- var data =3D "key=3D" + objectKey + "&type=3D" + objectType +
- "&def=3D" + definitionID + "&parent=3D" + parentID + "&=
domid=3D" + domID +
- "¶ms=3D/op/edit/pid/" + pageID;
-
- var url =3D context + "/ajaxaction/GetMenuItems";
-
- if (method =3D=3D "GET") {
- url +=3D "?" + data;
- data =3D null;
- }
-
- // Create new XMLHttpRequest request
- if (window.XMLHttpRequest) {
- req =3D new XMLHttpRequest ();
-
- } else if (window.ActiveXObject) {
- req =3D new ActiveXObject ("Microsoft.XMLHTTP");
-
- } else {
- alert ("Error: Your Browser does not support XMLHTTPRequests, please=
upgrade...");
- return;
- }
-
- req.open (method, url, true);
-
- req.onreadystatechange =3D function () {
- buildActionMenu();
- }
-
- if (method =3D=3D "POST") {
- req.setRequestHeader ("Content-type", "application/x-www-form-urlenc=
oded");
- }
- req.send (data);
-
- } catch (e) {
- alert ("Exception sending the Request: " + e);
- }
-}
-
-// Build the Action Menu
-function buildActionMenu () {
- var readyState =3D req.readyState;
- if (req.readyState =3D=3D 4) {
- // alert ("resp: " + req.responseText);
- if (req.status =3D=3D 200) {
- try {
- var response =3D req.responseText;
- var uniqueID =3D getNodeValue(response, "domid");
-
- var methods =3D getNodeValues (response, "method");
- var launchers =3D getNodeValues (response, "launcher");
- var images =3D getNodeValues (response, "image");
-
- var fieldset =3D getNodeValue (response, "fieldset");
- updateFieldSet (uniqueID, fieldset);
-
- addActions (uniqueID, methods, launchers, images);
-
- // changeURL(uniqueID);
-
- buttonClick (uniqueID);
-
- } catch (e) {
- alert ("Exception building Action Menu: " + e);
- }
-
- } else {
- alert ("There was a problem processing the request. Status: " +
- req.status + ", msg: " + req.statusText);
- }
- document.body.style.cursor =3D "default";
- }
-}
-
-// Changes the default grey border. Use in case the object is locked for e=
xample
-function updateFieldSet (id, param) {
- // alert ("Updating fieldSet for " + id + ", param =3D " + param);
- if (param =3D=3D null) {
- return;
- }
-
- var setID =3D "fieldset_" + id;
- var setElem =3D getObjectById (setID);
-
- var content;
- if (param =3D=3D "complete") {
- content =3D "completeLocked";
-
- } else if (param =3D=3D "partial") {
- content =3D "partialLocked";
-
- } else {
- return;
- }
-
- setElem.className =3D content;
-}
-
-// Changes the href value of the given element
-function changeURL (id) {
- var button =3D getObjectById ("button_" + id);
- button.href =3D "javascript:buttonClick('" + id + "');";
-}
-
-// Adds the Actions to the action menu
-function addActions(id, methods, launchers, images) {
- var menuDiv =3D getObjectById(id);
- var content =3D "\n";
-
- var i;
- for (i =3D 0; i < methods.length-1; i++) {
- //alert("i=3D"+i+methods[i])
-
- if(methods[i]=3D=3D"copies"){
-
- //specific code to display the list of pickers
- var parts=3Dlaunchers[i].split(",")
- p=3Dfalse
- if(parts.length>1) p=3Dparts[1]
-
- content +=3D"<a class=3D\"menuItem\" href=3D\""+parts[3]+"=
\" title=3D\"id:"+parts[0]+"\"><i>  =
;"+parts[2]+"</i></a>"
- } else {
- content +=3D printLauncher(launchers[i]) + printImage(imag=
es[i]) + printMethod(methods[i]);
- }
-
- }
- menuDiv.innerHTML =3D content;
-}
-
-// Returns a String for the Action Launcher URI
-function printLauncher (launcher) {
- return " <a class=3D\"menuItem\" href=3D\"javascript:" + launcher + "\=
">\n";
-}
-
-// Returns a String for the Action Image
-function printImage (imageName) {
- return " <img src=3D\"" + imageName + "\" alt=3D\"\" border=3D\"0\"=
/> ";
-}
-
-// Returns a String for the Action method name
-function printMethod (methodName) {
- return methodName + "\n </a>\n";
-}
-
-function clipboard (context, objectKey, op, pageID) {
- document.body.style.cursor =3D "wait";
- try {
- // correct values are "POST" or "GET" (HTTP methods).
- var method =3D "POST" ;
- var data =3D "key=3D" + objectKey + "&cop=3D" + op;
- var url =3D jahiaMainServletPath + "/op/edit/engineName/clipboard/=
pid/" + pageID ;
-
- if (method =3D=3D "GET") {
- url +=3D "?" + data;
- data =3D null;
- }
-
- // Create new XMLHttpRequest request
- if (window.XMLHttpRequest) {
- req =3D new XMLHttpRequest ();
-
- } else if (window.ActiveXObject) {
- req =3D new ActiveXObject ("Microsoft.XMLHTTP");
-
- } else {
- alert ("Error: Your Browser does not support XMLHTTPRequests, please=
upgrade...");
- return;
- }
-
- req.open (method, url, true);
-
- if (op =3D=3D "paste") {
- req.onreadystatechange =3D function () {
- if (req.readyState =3D=3D 4) {
- document.body.style.cursor =3D "default";
- window.location.reload();
- }
- }
- } else {
- req.onreadystatechange =3D function () {
- if (req.readyState =3D=3D 4) {
- //copy
- myurl =3D "http://" + document.location.host + context=
+ "/jsp/jahia/engines/images/clipboard_next.png";
- myclip =3D document.getElementById('clipboard');
- myclip.src =3D myurl;
- myclip.alt =3D "clipboard:" + objectKey;
- //window.location.reload();
- document.body.style.cursor =3D "default";
- }
- }
- }
-
- if (method =3D=3D "POST") {
- req.setRequestHeader ("Content-type", "application/x-www-form-urlenc=
oded");
- }
- req.send (data);
- } catch (e) {
- alert ("Exception sending the Request: " + e);
- }
-}
-
-function getWorkflowState(context, key, pid) {
- try {
- // correct values are "POST" or "GET" (HTTP methods).
- var method =3D "POST" ;
- var data =3D "key=3D" + key + "¶ms=3D/op/edit/pid/" + pid;
-
- var url =3D context + "/ajaxaction/GetWorkflowState";
-
- if (method =3D=3D "GET") {
- url +=3D "?" + data;
- data =3D null;
- }
-
- // Create new XMLHttpRequest request
- if (window.XMLHttpRequest) {
- req =3D new XMLHttpRequest ();
-
- } else if (window.ActiveXObject) {
- req =3D new ActiveXObject ("Microsoft.XMLHTTP");
-
- } else {
- alert("Error: Your Browser does not support XMLHTTPRequests, p=
lease upgrade...");
- return;
- }
-
- req.open(method, url, true);
-
- req.onreadystatechange =3D function () {
- changeIcone();
- }
-
- if (method =3D=3D "POST") {
- req.setRequestHeader("Content-type", "application/x-www-form-u=
rlencoded");
- }
- req.send(data);
-
- } catch (e) {
- alert("Exception sending the Request: " + e);
- }
-}
-
-function changeIcone() {
- var readyState =3D req.readyState;
- if (req.readyState =3D=3D 4) {
- // alert ("resp: " + req.responseText);
- if (req.status =3D=3D 200) {
- try {
- var response =3D req.responseText;
- var objectKey =3D getNodeValue(response, "key");
- var icone =3D getNodeValue(response, "stateIcone");
-
- var elem =3D getObjectById("img_" + objectKey);
- elem.src =3D icone;
-
- } catch (e) {
- alert("Exception changing Icone: " + e);
- }
-
- } else {
- alert("There was a problem processing the request. Status: " +
- req.status + ", msg: " + req.statusText);
- }
- }
-}
+//************************************************************************=
*****
+// Do not remove this notice.
+//
+// Copyright 2000 by Mike Hall.
+// See http://www.brainjar.com for terms of use.
+
+// Modified by Xavier Lawrence, 2005 Copyright Jahia Solutions
+//************************************************************************=
*****
+
+//------------------------------------------------------------------------=
----
+// Code to determine the browser and version.
+//------------------------------------------------------------------------=
----
+
+function Browser() {
+
+ var ua, s, i;
+
+ this.isIE =3D false; // Internet Explorer
+ this.isNS =3D false; // Netscape
+ this.version =3D null;
+
+ ua =3D navigator.userAgent;
+
+ s =3D "MSIE";
+ if ((i =3D ua.indexOf(s)) >=3D 0) {
+ this.isIE =3D true;
+ this.version =3D parseFloat(ua.substr(i + s.length));
+ return;
+ }
+
+ s =3D "Netscape6/";
+ if ((i =3D ua.indexOf(s)) >=3D 0) {
+ this.isNS =3D true;
+ this.version =3D parseFloat(ua.substr(i + s.length));
+ return;
+ }
+
+ // Treat any other "Gecko" browser as NS 6.1.
+
+ s =3D "Gecko";
+ if ((i =3D ua.indexOf(s)) >=3D 0) {
+ this.isNS =3D true;
+ this.version =3D 6.1;
+ return;
+ }
+}
+
+var browser =3D new Browser();
+
+//------------------------------------------------------------------------=
----
+// Code for handling the menu bar and active button.
+//------------------------------------------------------------------------=
----
+
+var activeButton =3D null;
+
+// AJAX variables
+var req;
+
+// Capture mouse clicks on the page so any active button can be
+// deactivated.
+
+if (browser.isIE)
+ document.onmousedown =3D pageMousedown;
+else
+ document.addEventListener("mousedown", pageMousedown, true);
+
+function pageMousedown(event) {
+
+ var el;
+
+ // If there is no active button, exit.
+
+ if (activeButton =3D=3D null)
+ return;
+
+ // Find the element that was clicked on.
+
+ if (browser.isIE)
+ el =3D window.event.srcElement;
+ else
+ el =3D (event.target.tagName ? event.target : event.target.parentNode);
+
+ // If the active button was clicked on, exit.
+
+ if (el =3D=3D activeButton)
+ return;
+
+ // If the element is not part of a menu, reset and clear the active
+ // button.
+
+ if (getContainerWith(el, "DIV", "menu") =3D=3D null) {
+ resetButton(activeButton);
+ activeButton =3D null;
+ }
+}
+
+// Opens up the menu of the given id
+function buttonClick (menuId) {
+ var button =3D getObjectById ("button_" + menuId);
+
+ // Blur focus from the link to remove that annoying outline.
+ button.blur();
+
+ // Associate the named menu to this button if not already done.
+ // Additionally, initialize menu display.
+ if (button.menu =3D=3D null) {
+ button.menu =3D getObjectById (menuId);
+ if (button.menu.isInitialized =3D=3D null) {
+ menuInit(button.menu);
+ }
+ }
+
+ // Reset the currently active button, if any.
+
+ if (activeButton !=3D null) {
+ resetButton(activeButton);
+ }
+
+ // Activate this button, unless it was the currently active one.
+
+ if (button !=3D activeButton) {
+ depressButton(button);
+ activeButton =3D button;
+ } else {
+ activeButton =3D null;
+ }
+}
+
+// Switches menu if the user's mouse goes on another menu
+function buttonMouseover(event, menuId) {
+ var button;
+
+ // Find the target button element.
+ if (browser.isIE) {
+ button =3D window.event.srcElement;
+ } else {
+ button =3D event.currentTarget;
+ }
+
+ // If any other button menu is active, make this one active instead.
+ if (activeButton !=3D null && activeButton !=3D button) {
+ buttonClick (menuId);
+ }
+}
+
+function depressButton(button) {
+ var x, y;
+
+ // Update the button's style class to make it look like it's
+ // depressed.
+
+ button.className +=3D " menuButtonActive";
+
+ // Position the associated drop down menu under the button and
+ // show it.
+
+ x =3D getPageOffsetLeft(button);
+ y =3D getPageOffsetTop(button) + button.offsetHeight - 5;
+
+ // For IE, adjust position.
+
+ if (browser.isIE) {
+ x +=3D button.offsetParent.clientLeft;
+ y +=3D button.offsetParent.clientTop;
+ }
+
+ button.menu.style.left =3D x + "px";
+ button.menu.style.top =3D y + "px";
+ button.menu.style.visibility =3D "visible";
+}
+
+function resetButton(button) {
+
+ // Restore the button's style class.
+
+ removeClassName(button, "menuButtonActive");
+
+ // Hide the button's menu, first closing any sub menus.
+
+ if (button.menu !=3D null) {
+ closeSubMenu(button.menu);
+ button.menu.style.visibility =3D "hidden";
+ }
+}
+
+//------------------------------------------------------------------------=
----
+// Code to handle the menus and sub menus.
+//------------------------------------------------------------------------=
----
+
+function menuMouseover(event) {
+
+ var menu;
+
+ // Find the target menu element.
+
+ if (browser.isIE)
+ menu =3D getContainerWith(window.event.srcElement, "DIV", "menu");
+ else
+ menu =3D event.currentTarget;
+
+ // Close any active sub menu.
+
+ if (menu.activeItem !=3D null)
+ closeSubMenu(menu);
+}
+
+function menuItemMouseover(event, menuId) {
+
+ var item, menu, x, y;
+
+ // Find the target item element and its parent menu element.
+
+ if (browser.isIE)
+ item =3D getContainerWith(window.event.srcElement, "A", "menuItem");
+ else
+ item =3D event.currentTarget;
+ menu =3D getContainerWith(item, "DIV", "menu");
+
+ // Close any active sub menu and mark this one as active.
+
+ if (menu.activeItem !=3D null)
+ closeSubMenu(menu);
+ menu.activeItem =3D item;
+
+ // Highlight the item element.
+
+ item.className +=3D " menuItemHighlight";
+
+ // Initialize the sub menu, if not already done.
+
+ if (item.subMenu =3D=3D null) {
+ item.subMenu =3D document.getElementById(menuId);
+ if (item.subMenu.isInitialized =3D=3D null)
+ menuInit(item.subMenu);
+ }
+
+ // Get position for submenu based on the menu item.
+
+ x =3D getPageOffsetLeft(item) + item.offsetWidth;
+ y =3D getPageOffsetTop(item);
+
+ // Adjust position to fit in view.
+
+ var maxX, maxY;
+
+ if (browser.isNS) {
+ maxX =3D window.scrollX + window.innerWidth;
+ maxY =3D window.scrollY + window.innerHeight;
+ }
+ if (browser.isIE) {
+ maxX =3D (document.documentElement.scrollLeft !=3D 0 ? document.docu=
mentElement.scrollLeft : document.body.scrollLeft)
+ + (document.documentElement.clientWidth !=3D 0 ? document.docume=
ntElement.clientWidth : document.body.clientWidth);
+ maxY =3D (document.documentElement.scrollTop !=3D 0 ? document.docu=
mentElement.scrollTop : document.body.scrollTop)
+ + (document.documentElement.clientHeight !=3D 0 ? document.docume=
ntElement.clientHeight : document.body.clientHeight);
+ }
+ maxX -=3D item.subMenu.offsetWidth;
+ maxY -=3D item.subMenu.offsetHeight;
+
+ if (x > maxX)
+ x =3D Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
+ + (menu.offsetWidth - item.offsetWidth));
+ y =3D Math.max(0, Math.min(y, maxY));
+
+ // Position and show it.
+
+ item.subMenu.style.left =3D x + "px";
+ item.subMenu.style.top =3D y + "px";
+ item.subMenu.style.visibility =3D "visible";
+
+ // Stop the event from bubbling.
+
+ if (browser.isIE)
+ window.event.cancelBubble =3D true;
+ else
+ event.stopPropagation();
+}
+
+function closeSubMenu(menu) {
+
+ if (menu =3D=3D null || menu.activeItem =3D=3D null)
+ return;
+
+ // Recursively close any sub menus.
+
+ if (menu.activeItem.subMenu !=3D null) {
+ closeSubMenu(menu.activeItem.subMenu);
+ menu.activeItem.subMenu.style.visibility =3D "hidden";
+ menu.activeItem.subMenu =3D null;
+ }
+ removeClassName(menu.activeItem, "menuItemHighlight");
+ menu.activeItem =3D null;
+}
+
+//------------------------------------------------------------------------=
----
+// Code to initialize menus.
+//------------------------------------------------------------------------=
----
+
+function menuInit(menu) {
+
+ var itemList, spanList;
+ var textEl, arrowEl;
+ var itemWidth;
+ var w, dw;
+ var i, j;
+
+ // For IE, replace arrow characters.
+
+ if (browser.isIE) {
+ menu.style.lineHeight =3D "2.5ex";
+ spanList =3D menu.getElementsByTagName("SPAN");
+ for (i =3D 0; i < spanList.length; i++)
+ if (hasClassName(spanList[i], "menuItemArrow")) {
+ spanList[i].style.fontFamily =3D "Webdings";
+ spanList[i].firstChild.nodeValue =3D "4";
+ }
+ }
+
+ // Find the width of a menu item.
+
+ itemList =3D menu.getElementsByTagName("A");
+ if (itemList.length > 0)
+ itemWidth =3D itemList[0].offsetWidth;
+ else
+ return;
+
+ // For items with arrows, add padding to item text to make the
+ // arrows flush right.
+
+ for (i =3D 0; i < itemList.length; i++) {
+ spanList =3D itemList[i].getElementsByTagName("SPAN");
+ textEl =3D null;
+ arrowEl =3D null;
+ for (j =3D 0; j < spanList.length; j++) {
+ if (hasClassName(spanList[j], "menuItemText"))
+ textEl =3D spanList[j];
+ if (hasClassName(spanList[j], "menuItemArrow"))
+ arrowEl =3D spanList[j];
+ }
+ if (textEl !=3D null && arrowEl !=3D null)
+ textEl.style.paddingRight =3D (itemWidth
+ - (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
+ }
+
+ // Fix IE hover problem by setting an explicit width on first item of
+ // the menu.
+
+ if (browser.isIE) {
+ w =3D itemList[0].offsetWidth;
+ itemList[0].style.width =3D w + "px";
+ dw =3D itemList[0].offsetWidth - w;
+ w -=3D dw;
+ itemList[0].style.width =3D w + "px";
+ }
+
+ // Mark menu as initialized.
+
+ menu.isInitialized =3D true;
+}
+
+//------------------------------------------------------------------------=
----
+// General utility functions.
+//------------------------------------------------------------------------=
----
+
+function getContainerWith(node, tagName, className) {
+
+ // Starting with the given node, find the nearest containing element
+ // with the specified tag name and style class.
+
+ while (node !=3D null) {
+ if (node.tagName !=3D null && node.tagName =3D=3D tagName &&
+ hasClassName(node, className))
+ return node;
+ node =3D node.parentNode;
+ }
+
+ return node;
+}
+
+function hasClassName(el, name) {
+
+ var i, list;
+
+ // Return true if the given element currently has the given class
+ // name.
+
+ list =3D el.className.split(" ");
+ for (i =3D 0; i < list.length; i++)
+ if (list[i] =3D=3D name)
+ return true;
+
+ return false;
+}
+
+function removeClassName(el, name) {
+
+ var i, curList, newList;
+
+ if (el.className =3D=3D null)
+ return;
+
+ // Remove the given class name from the element's className property.
+
+ newList =3D new Array();
+ curList =3D el.className.split(" ");
+ for (i =3D 0; i < curList.length; i++)
+ if (curList[i] !=3D name) {
+ // Workaround to replace the push method.
+ var _curList =3D new Array(curList[i]);
+ newList.concat(_curList);
+ // Comment this line because not supported by IE5.0
+ //newList.push(curList[i]);
+ }
+ el.className =3D newList.join(" ");
+}
+
+function getPageOffsetLeft(el) {
+
+ var x;
+
+ // Return the x coordinate of an element relative to the page.
+
+ x =3D el.offsetLeft;
+ if (el.offsetParent !=3D null)
+ x +=3D getPageOffsetLeft(el.offsetParent);
+
+ return x;
+}
+
+function getPageOffsetTop(el) {
+
+ var y;
+
+ // Return the x coordinate of an element relative to the page.
+
+ y =3D el.offsetTop;
+ if (el.offsetParent !=3D null)
+ y +=3D getPageOffsetTop(el.offsetParent);
+
+ return y;
+}
+
+// Check the browser for DOM manipulation
+function checkBrowser(){
+ this.ver=3Dnavigator.appVersion;
+ this.dom=3Ddocument.getElementById?1:0;
+ this.ie6=3D(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
+ this.ie55=3D((this.ver.indexOf("MSIE 5.5")>-1 || this.ie6) &&
this.dom)?1=
:0;
+ this.ie5=3D((this.ver.indexOf("MSIE 5")>-1 || this.ie5 || this.ie6) &&
th=
is.dom)?1:0;
+ this.ie4=3D(document.all && !this.dom)?1:0;
+ this.ns5=3D(this.dom && parseInt(this.ver) >=3D 5) ?1:0;
+ this.ns4=3D(document.layers && !this.dom)?1:0;
+ this.ie4plus=3D(this.ie6 || this.ie5 || this.ie4);
+ this.ie5plus=3D(this.ie6 || this.ie5)
+ this.bw=3D(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5);
+ return this;
+}
+
+bw =3D new checkBrowser();
+
+// Get an Object contained in a DOM document by its ID attribute
+function getObjectById (ID) {
+ var obj;
+ if (bw.dom)
+ return document.getElementById (ID);
+ else if (bw.ie4)
+ return document.all (ID);
+ else
+ alert ("Error: Your browser version is not supported. Please
upgrade..."=
);
+ return null;
+}
+
+// Returns an array of values. The delimiter is the ',' character
+function getNodeValues (content, nodeName) {
+ var tag =3D "<" + nodeName + ">";
+ var start =3D content.indexOf (tag);
+ var end =3D content.indexOf ("</" + nodeName + ">");
+
+ if (start < end) {
+ var values =3D content.substring (start + tag.length, end);
+ return values.split (";;");
+ } else {
+ return new Array (0);
+ }
+}
+
+// Returns the value of an XML tag
+function getNodeValue (content, nodeName) {
+ var tag =3D "<" + nodeName + ">";
+ var start =3D content.indexOf (tag);
+ var end =3D content.indexOf ("</" + nodeName + ">");
+
+ if (start < end) {
+ return content.substring (start + tag.length, end);
+ } else {
+ return null;
+ }
+}
+
+// AJAX based function to get all Actions to fill up the Action menu
+function getActionMenu(context, objectType, objectKey, definitionID, paren=
tID, pageID, domID, lang) {
+ document.body.style.cursor =3D "wait";
+ try {
+ // correct values are "POST" or "GET" (HTTP methods).
+ var method =3D "POST" ;
+ var data =3D "key=3D" + objectKey + "&type=3D" + objectType +
+ "&def=3D" + definitionID + "&parent=3D" + parentID + "&=
domid=3D" + domID +
+ "¶ms=3D/op/edit/lang/" + lang + "/pid/" + pageID;
+
+ var url =3D context + "/ajaxaction/GetMenuItems";
+
+ if (method =3D=3D "GET") {
+ url +=3D "?" + data;
+ data =3D null;
+ }
+
+ // Create new XMLHttpRequest request
+ if (window.XMLHttpRequest) {
+ req =3D new XMLHttpRequest ();
+
+ } else if (window.ActiveXObject) {
+ req =3D new ActiveXObject ("Microsoft.XMLHTTP");
+
+ } else {
+ alert ("Error: Your Browser does not support
XMLHTTPRequests, please up=
grade...");
+ return;
+ }
+
+ req.open (method, url, true);
+
+ req.onreadystatechange =3D function () {
+ buildActionMenu();
+ }
+
+ if (method =3D=3D "POST") {
+ req.setRequestHeader ("Content-type",
"application/x-www-form-urlencode=
d");
+ }
+ req.send (data);
+
+ } catch (e) {
+ alert ("Exception sending the Request: " + e);
+ }
+}
+
+// Build the Action Menu
+function buildActionMenu () {
+ var readyState =3D req.readyState;
+ if (req.readyState =3D=3D 4) {
+ // alert ("resp: " + req.responseText);
+ if (req.status =3D=3D 200) {
+ try {
+ var response =3D req.responseText;
+ var uniqueID =3D getNodeValue(response, "domid");
+
+ var methods =3D getNodeValues (response,
"method");
+ var launchers =3D getNodeValues (response,
"launcher");
+ var images =3D getNodeValues (response,
"image");
+
+ var fieldset =3D getNodeValue (response,
"fieldset");
+ updateFieldSet (uniqueID, fieldset);
+
+ addActions (uniqueID, methods, launchers,
images);
+
+ // changeURL(uniqueID);
+
+ buttonClick (uniqueID);
+
+ } catch (e) {
+ alert ("Exception building Action Menu: " + e);
+ }
+
+ } else {
+ alert ("There was a problem processing the request.
Status: " +
+ req.status + ", msg: " +
req.statusText);
+ }
+ document.body.style.cursor =3D "default";
+ }
+}
+
+// Changes the default grey border. Use in case the object is locked for e=
xample
+function updateFieldSet (id, param) {
+ // alert ("Updating fieldSet for " + id + ", param =3D " + param);
+ if (param =3D=3D null) {
+ return;
+ }
+
+ var setID =3D "fieldset_" + id;
+ var setElem =3D getObjectById (setID);
+
+ var content;
+ if (param =3D=3D "complete") {
+ content =3D "completeLocked";
+
+ } else if (param =3D=3D "partial") {
+ content =3D "partialLocked";
+
+ } else {
+ content =3D "unlocked";
+ }
+
+ setElem.className =3D content;
+}
+
+// Changes the href value of the given element
+function changeURL (id) {
+ var button =3D getObjectById ("button_" + id);
+ button.href =3D "javascript:buttonClick('" + id + "');";
+}
+
+// Adds the Actions to the action menu
+function addActions(id, methods, launchers, images) {
+ var menuDiv =3D getObjectById(id);
+ var content =3D "\n";
+
+ var i;
+ for (i =3D 0; i < methods.length-1; i++) {
+ //alert("i=3D"+i+methods[i])
+ =
+ if(methods[i]=3D=3D"copies"){
+
+ //specific code to display the list of pickers
+ var parts=3Dlaunchers[i].split(",")
+ p=3Dfalse
+ if(parts.length>1) p=3Dparts[1]
+
+ content +=3D"<a class=3D\"menuItem\" href=3D\""+parts[3]+"=
\" title=3D\"id:"+parts[0]+"\"><i>  =
;"+parts[2]+"</i></a>"
+ } else {
+ content +=3D printLauncher(launchers[i]) + printImage(imag=
es[i]) + printMethod(methods[i]);
+ }
+
+ }
+ menuDiv.innerHTML =3D content;
+}
+
+// Returns a String for the Action Launcher URI
+function printLauncher (launcher) {
+ return " <a class=3D\"menuItem\" href=3D\"javascript:" + launcher +
"\"=
>\n";
+}
+
+// Returns a String for the Action Image
+function printImage (imageName) {
+ return " <img src=3D\"" + imageName + "\" alt=3D\"\"
border=3D\"0\" =
/> ";
+}
+
+// Returns a String for the Action method name
+function printMethod (methodName) {
+ return methodName + "\n </a>\n";
+}
+
+function clipboard (context, objectKey, op, pageID) {
+ document.body.style.cursor =3D "wait";
+ try {
+ // correct values are "POST" or "GET" (HTTP methods).
+ var method =3D "POST" ;
+ var data =3D "key=3D" + objectKey + "&cop=3D" + op;
+ var url =3D jahiaMainServletPath + "/op/edit/engineName/clipboard/=
pid/" + pageID ;
+
+ if (method =3D=3D "GET") {
+ url +=3D "?" + data;
+ data =3D null;
+ }
+
+ // Create new XMLHttpRequest request
+ if (window.XMLHttpRequest) {
+ req =3D new XMLHttpRequest ();
+
+ } else if (window.ActiveXObject) {
+ req =3D new ActiveXObject ("Microsoft.XMLHTTP");
+
+ } else {
+ alert ("Error: Your Browser does not support
XMLHTTPRequests, please up=
grade...");
+ return;
+ }
+
+ req.open (method, url, true);
+
+ if (op =3D=3D "paste") {
+ req.onreadystatechange =3D function () {
+ if (req.readyState =3D=3D 4) {
+ document.body.style.cursor =3D "default";
+ window.location.reload();
+ }
+ }
+ } else {
+ req.onreadystatechange =3D function () {
+ if (req.readyState =3D=3D 4) {
+ //copy
+ myurl =3D "http://" + document.location.host + context=
+ "/jsp/jahia/engines/images/clipboard_next.png";
+ myclip =3D document.getElementById('clipboard');
+ myclip.src =3D myurl;
+ myclip.alt =3D "clipboard:" + objectKey;
+ //window.location.reload();
+ document.body.style.cursor =3D "default";
+ }
+ }
+ }
+
+ if (method =3D=3D "POST") {
+ req.setRequestHeader ("Content-type",
"application/x-www-form-urlencode=
d");
+ }
+ req.send (data);
+ } catch (e) {
+ alert ("Exception sending the Request: " + e);
+ }
+}
+
+function getWorkflowState(context, key, pid) {
+ try {
+ // correct values are "POST" or "GET" (HTTP methods).
+ var method =3D "POST" ;
+ var data =3D "key=3D" + key + "¶ms=3D/op/edit/pid/" + pid;
+
+ var url =3D context + "/ajaxaction/GetWorkflowState";
+
+ if (method =3D=3D "GET") {
+ url +=3D "?" + data;
+ data =3D null;
+ }
+
+ // Create new XMLHttpRequest request
+ if (window.XMLHttpRequest) {
+ req =3D new XMLHttpRequest ();
+
+ } else if (window.ActiveXObject) {
+ req =3D new ActiveXObject ("Microsoft.XMLHTTP");
+
+ } else {
+ alert("Error: Your Browser does not support XMLHTTPRequests, p=
lease upgrade...");
+ return;
+ }
+
+ req.open(method, url, true);
+
+ req.onreadystatechange =3D function () {
+ changeIcone();
+ }
+
+ if (method =3D=3D "POST") {
+ req.setRequestHeader("Content-type", "application/x-www-form-u=
rlencoded");
+ }
+ req.send(data);
+
+ } catch (e) {
+ alert("Exception sending the Request: " + e);
+ }
+}
+
+function changeIcone() {
+ var readyState =3D req.readyState;
+ if (req.readyState =3D=3D 4) {
+ // alert ("resp: " + req.responseText);
+ if (req.status =3D=3D 200) {
+ try {
+ var response =3D req.responseText;
+ var objectKey =3D getNodeValue(response, "key");
+ var icone =3D getNodeValue(response, "stateIcone");
+
+ var elem =3D getObjectById("img_" + objectKey);
+ elem.src =3D icone;
+
+ } catch (e) {
+ alert("Exception changing Icone: " + e);
+ }
+
+ } else {
+ alert("There was a problem processing the request. Status: " +
+ req.status + ", msg: " + req.statusText);
+ }
+ }
+}
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list