xlawrence    2005/08/05 16:01:27 CEST

  Modified files:
    src/view/jsp         actions.js web_css.jsp 
    src/view/jsp/include blog_entries.inc blog_list.inc 
                         left_menu.inc main_menu.inc 
  Log:
  Modifications to support the new AJAX action menus and change to the 
ContentBean API
  - Added Javascript functions in actions.js
  - Added CSS classes
  - Updated files to support the changes
  
  Revision  Changes    Path
  1.3       +227 -33   corporate_portal_templates/src/view/jsp/actions.js
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/actions.js.diff?r1=1.2&r2=1.3&f=h
  1.6       +1 -1      
corporate_portal_templates/src/view/jsp/include/blog_entries.inc
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/blog_entries.inc.diff?r1=1.5&r2=1.6&f=h
  1.7       +1 -1      
corporate_portal_templates/src/view/jsp/include/blog_list.inc
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/blog_list.inc.diff?r1=1.6&r2=1.7&f=h
  1.17      +10 -10    
corporate_portal_templates/src/view/jsp/include/left_menu.inc
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/left_menu.inc.diff?r1=1.16&r2=1.17&f=h
  1.18      +3 -3      
corporate_portal_templates/src/view/jsp/include/main_menu.inc
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/main_menu.inc.diff?r1=1.17&r2=1.18&f=h
  1.34      +19 -0     corporate_portal_templates/src/view/jsp/web_css.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/web_css.jsp.diff?r1=1.33&r2=1.34&f=h
  
  
  
  Index: actions.js
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/actions.js,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- actions.js        4 Aug 2003 14:41:45 -0000       1.2
  +++ actions.js        5 Aug 2005 14:01:26 -0000       1.3
  @@ -4,6 +4,8 @@
   //
   // Copyright 2000 by Mike Hall.
   // See http://www.brainjar.com for terms of use.
  +
  +// Modified by Xavier Lawrence, 2005 Copyright Jahia Solutions
   
//*****************************************************************************
   
   
//----------------------------------------------------------------------------
  @@ -52,6 +54,9 @@
   
   var activeButton = null;
   
  +// AJAX variables
  +var req;
  +
   // Capture mouse clicks on the page so any active button can be
   // deactivated.
   
  @@ -90,66 +95,56 @@
     }
   }
   
  -function buttonClick(event, menuId) {
  -
  -  var button;
  -
  -  // Get the target button element.
  -
  -  if (browser.isIE)
  -    button = window.event.srcElement;
  -  else
  -    button = event.currentTarget;
  +// Opens up the menu of the given id
  +function buttonClick (menuId) {
  +  var button = 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 == null) {
  -    button.menu = document.getElementById(menuId);
  -    if (button.menu.isInitialized == null)
  +     button.menu = getObjectById (menuId);
  +    if (button.menu.isInitialized == null) {
         menuInit(button.menu);
  +     }
     }
   
     // Reset the currently active button, if any.
   
  -  if (activeButton != null)
  +  if (activeButton != null) {
       resetButton(activeButton);
  +  }
   
     // Activate this button, unless it was the currently active one.
   
     if (button != activeButton) {
       depressButton(button);
       activeButton = button;
  -  }
  -  else
  +  } else {
       activeButton = null;
  -
  -  return false;
  +  }
   }
   
  +// Switches menu if the user's mouse goes on another menu
   function buttonMouseover(event, menuId) {
  +     var button;
   
  -  var button;
  -
  -  // Find the target button element.
  -
  -  if (browser.isIE)
  -    button = window.event.srcElement;
  -  else
  -    button = event.currentTarget;
  -
  -  // If any other button menu is active, make this one active instead.
  -
  -  if (activeButton != null && activeButton != button)
  -    buttonClick(event, menuId);
  +     // Find the target button element.
  +     if (browser.isIE) {
  +             button = window.event.srcElement;
  +     } else {
  +             button = event.currentTarget;
  +     }
  +
  +     // If any other button menu is active, make this one active instead.
  +     if (activeButton != null && activeButton != button) {
  +             buttonClick (menuId);
  +     }
   }
   
   function depressButton(button) {
  -
     var x, y;
   
     // Update the button's style class to make it look like it's
  @@ -444,3 +439,202 @@
   
     return y;
   }
  +
  +// Check the browser for DOM manipulation
  +function checkBrowser(){
  +     this.ver=navigator.appVersion;
  +     this.dom=document.getElementById?1:0;
  +     this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
  +     this.ie55=((this.ver.indexOf("MSIE 5.5")>-1 || this.ie6) && 
this.dom)?1:0;
  +     this.ie5=((this.ver.indexOf("MSIE 5")>-1 || this.ie5 || this.ie6) && 
this.dom)?1:0;
  +     this.ie4=(document.all && !this.dom)?1:0;
  +     this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  +     this.ns4=(document.layers && !this.dom)?1:0;
  +     this.ie4plus=(this.ie6 || this.ie5 || this.ie4);
  +     this.ie5plus=(this.ie6 || this.ie5)
  +     this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5);
  +     return this;
  +}
  +
  +bw = 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...");
  +}
  +
  +// Returns an array of values. The delimiter is the ',' character
  +function getNodeValues (content, nodeName) {
  +     var tag = "<" + nodeName + ">";
  +     var start = content.indexOf (tag);
  +     var end   = content.indexOf ("</" + nodeName + ">");
  +     
  +     if (start < end) {
  +         var values = 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 = "<" + nodeName + ">";
  +     var start = content.indexOf (tag);
  +     var end   = 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, 
parentID, pageID) {
  +     try {
  +             // correct values are "POST" or "GET" (HTTP methods).
  +             var method = "POST" ;
  +             var data = "key=" + objectKey + "&type=" + objectType + 
  +                             "&def=" + definitionID + "&parent=" + parentID 
+ 
  +                             "&page=" + pageID;
  +         var url = context + "/menu/";
  +             
  +             if (method == "GET") {
  +                     url += "?" + data;
  +                     data = null;
  +             }
  +             
  +             // Create new XMLHttpRequest request
  +     if (window.XMLHttpRequest) {
  +             req = new XMLHttpRequest ();
  +                     
  +     } else if (window.ActiveXObject) {
  +             req = new ActiveXObject ("Microsoft.XMLHTTP");
  +                     
  +     } else {
  +                     alert ("Error: Your Browser does not support 
XMLHTTPRequests, please upgrade...");  
  +                     return;
  +             }
  +             
  +             req.open (method, url, true);
  +             
  +             req.onreadystatechange = function () {
  +                     buildActionMenu();
  +             }
  +
  +             if (method == "POST") {
  +                     req.setRequestHeader ("Content-type", 
"application/x-www-form-urlencoded"); 
  +             }
  +             req.send (data);
  +             
  +     } catch (e) {
  +             alert ("Exception sending the Request: " + e);
  +     }
  +}
  +
  +// Build the Action Menu
  +function buildActionMenu () {
  +     var readyState = req.readyState;
  +     if (req.readyState == 4) {
  +             // alert ("resp: " + req.responseText);
  +     if (req.status == 200) {
  +                     try {
  +                             var response = req.responseText;
  +                             var objectType = getNodeValue (response, 
"type");
  +                             var objectKey  = getNodeValue (response, "key");
  +                             var definitionID = getNodeValue (response, 
"def");
  +                             var parentID = getNodeValue (response, 
"parent");
  +                             var pageID = getNodeValue (response, "page");
  +                             
  +                             var uniqueID = objectType + "_" + objectKey + 
"_" + 
  +                                                     definitionID + "_" + 
parentID + "_" + pageID;
  +                     
  +                             var methods = getNodeValues (response, 
"method");
  +                             var launchers = getNodeValues (response, 
"launcher");
  +                             var images = getNodeValues (response, "image");
  +                             
  +                             var fieldset = 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);
  +             }
  +     }       
  +}
  +
  +// Changes the default grey border. Use in case the object is locked for 
example
  +function updateFieldSet (id, param) {
  +     // alert ("Updating fieldSet for " + id + ", param = " + param);
  +     if (param == null) { return; }
  +     
  +     var setID = "fieldset_" + id;
  +     var setElem = getObjectById (setID);
  +     
  +     var content;
  +     if (param == "complete") {
  +             content = "completeLocked";
  +             
  +     } else if (param == "partial") {
  +             content = "partialLocked";
  +                             
  +     } else {
  +             return;
  +     }
  +     
  +     setElem.className = content;
  +}
  +
  +// Changes the href value of the given element
  +function changeURL (id) {
  +     var button = getObjectById ("button_" + id);
  +     button.href = "javascript:buttonClick('" + id + "');";
  +}
  +
  +// Adds the Actions to the action menu
  +function addActions (id, methods, launchers, images) {
  +     var menuDiv = getObjectById (id);
  +     var content = "\n";
  +     
  +     var i;
  +     for (i=0; i<methods.length; i++) {
  +             if (methods[i].length > 0) { 
  +                     // alert ("Adding action: '" + methods[i] + "' in div " 
+ id);
  +                     content += printLauncher(launchers[i]) + 
printImage(images[i]) + 
  +                     printMethod(methods[i]);
  +             }
  +     }
  +     menuDiv.innerHTML = content;  
  +}
  +
  +// Returns a String for the Action Launcher URI
  +function printLauncher (launcher) {
  +     return "   <a class=\"menuItem\" href=\"javascript:" + launcher + 
"\">\n";      
  +}
  +
  +// Returns a String for the Action Image
  +function printImage (imageName) {
  +     return "      <img src=\"" + imageName + "\" alt=\"\" border=\"0\" 
/>&nbsp;";
  +}
  +
  +// Returns a String for the Action method name
  +function printMethod (methodName) {
  +     return methodName + "\n   </a>\n";
  +}
  
  
  
  Index: web_css.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/web_css.jsp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- web_css.jsp       1 Jun 2005 12:45:21 -0000       1.33
  +++ web_css.jsp       5 Aug 2005 14:01:26 -0000       1.34
  @@ -953,4 +953,23 @@
   }
   span.hl {
       background: #FFFF66;
  +}
  +
  +.unlocked {
  +    padding: 5px;
  +}
  +
  +.completeLocked {
  +    padding: 5px;
  +    border: 1px solid #FF0000;
  +}
  +
  +.partialLocked {
  +    padding: 5px;
  +    border: 1px solid #FF8000;
  +}
  +
  +.workflow {
  +    padding: 5px;
  +    border: 1px solid #309030;
   }
  \ No newline at end of file
  
  
  
  Index: blog_entries.inc
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/include/blog_entries.inc,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- blog_entries.inc  1 Jun 2005 14:22:58 -0000       1.5
  +++ blog_entries.inc  5 Aug 2005 14:01:27 -0000       1.6
  @@ -16,7 +16,7 @@
           org.jahia.engines.JahiaEngine theAddContainerEngine =
               (org.jahia.engines.JahiaEngine) 
org.jahia.registries.EnginesRegistry.getInstance().getEngine( "addcontainer" );
           StringBuffer addContName = new StringBuffer("addContainer_");
  -        addContName.append(entriesBean.getId());
  +        addContName.append(entriesBean.getID());
           
addContName.append(jData.gui().html().cleanSessionID(jParams.getSessionID()));
           String addContHtml = theAddContainerEngine.renderLink( jParams, 
entriesBean.getJahiaContainerList() );
           String launcher = 
"OpenJahiaScrollableWindow('"+addContHtml+"','"+addContName+"',640,480)";
  
  
  
  Index: blog_list.inc
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/include/blog_list.inc,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- blog_list.inc     11 Jul 2005 15:00:16 -0000      1.6
  +++ blog_list.inc     5 Aug 2005 14:01:27 -0000       1.7
  @@ -65,7 +65,7 @@
                   org.jahia.engines.JahiaEngine theAddContainerEngine =
                       (org.jahia.engines.JahiaEngine) 
org.jahia.registries.EnginesRegistry.getInstance().getEngine( "addcontainer" );
                   StringBuffer addContName = new StringBuffer("addContainer_");
  -                addContName.append(blogsBean.getId());
  +                addContName.append(blogsBean.getID());
                   
addContName.append(jData.gui().html().cleanSessionID(jParams.getSessionID()));
                   String addContHtml = theAddContainerEngine.renderLink( 
jParams, blogsBean.getJahiaContainerList() );
                   String launcher = 
"OpenJahiaScrollableWindow('"+addContHtml+"','"+addContName+"',640,480)";
  
  
  
  Index: left_menu.inc
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/include/left_menu.inc,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- left_menu.inc     29 Apr 2005 12:48:46 -0000      1.16
  +++ left_menu.inc     5 Aug 2005 14:01:27 -0000       1.17
  @@ -25,7 +25,7 @@
                   if (linkBean != null) {
                       int truncSize = editMode ? 30 - (currentLevel * 3) : 40 
- (currentLevel * 3);
                       String pageTitle = 
jData.gui().glueTitle(linkBean.getTitle(),truncSize);
  -                    logger.debug("pageTitle is " + pageTitle + " for pid " + 
linkBean.getId());
  +                    logger.debug("pageTitle is " + pageTitle + " for pid " + 
linkBean.getID());
                       boolean displayLine = false;
                       if (pageTitle != null) {
                           if (pageTitle.length() == 0) {
  @@ -45,25 +45,25 @@
                       if (displayLine) {
                           // displays page info
                           String state = "";
  -                        if ( jData.gui().isPageInPath(linkBean.getId()) ) {
  +                        if ( jData.gui().isPageInPath(linkBean.getID()) ) {
                               state = "on";
                           }
  -                        if ( linkBean.getId() == rootPageID ) {
  +                        if ( linkBean.getID() == rootPageID ) {
                               state = "current";
                           }
                           out.println("<tr><td>&nbsp;</td>");
                           out.println("<td class=\"left"+state+"\"");
   
  -                        if (! jData.gui().isPageInPath(linkBean.getId()) && 
! "current".equals(state)){
  +                        if (! jData.gui().isPageInPath(linkBean.getID()) && 
! "current".equals(state)){
                               out.println(" onmouseover=\"leftOn(this)\" 
onmouseout=\"leftOff(this)\"");
                           }
                           out.println(">");
   
                           out.println("<a class=\"leftlevel" + currentLevel);
                           out.println("\" href=\"" + linkBean.getUrl() + 
"\"><span");
  -                        if (linkBean.getType() == PageInfoInterface.TYPE_URL 
){
  +                        if (linkBean.getPageType() == 
PageInfoInterface.TYPE_URL ){
                               out.println(" class='remote'");
  -                        } else if (linkBean.getType() == 
PageInfoInterface.TYPE_LINK ) {
  +                        } else if (linkBean.getPageType() == 
PageInfoInterface.TYPE_LINK ) {
                               out.println(" class='local'");
                           }
                           out.println(">");
  @@ -76,7 +76,7 @@
   
                           // displays sub links
                           if (linkBean.isInCurrentPagePath()) {
  -                            getPageSubTree(jData , rootPageID, 
linkBean.getId(), theURL,currentLevel, pageContext,logger);
  +                            getPageSubTree(jData , rootPageID, 
linkBean.getID(), theURL,currentLevel, pageContext,logger);
                           }
                       }
                   } else {
  @@ -223,10 +223,10 @@
                                   <%
                                   PageBean link = (PageBean) 
pageContext.getAttribute("link");
                                   boolean isRemoteLink =
  -                                    (link.getType() == 
PageInfoInterface.TYPE_URL) ||
  -                                    (link.getType() == 
PageInfoInterface.TYPE_LINK );
  +                                    (link.getPageType() == 
PageInfoInterface.TYPE_URL) ||
  +                                    (link.getPageType() == 
PageInfoInterface.TYPE_LINK );
                                   if (isRemoteLink) {
  -                                    %><span class='<%=link.getType() == 
PageInfoInterface.TYPE_URL ? "remote" : "local"%>'><%
  +                                    %><span class='<%=link.getPageType() == 
PageInfoInterface.TYPE_URL ? "remote" : "local"%>'><%
                                   }
                                   %>
                                   <bean:write name="link" property="title" 
filter="false"/>
  
  
  
  Index: main_menu.inc
  ===================================================================
  RCS file: 
/home/cvs/repository/corporate_portal_templates/src/view/jsp/include/main_menu.inc,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- main_menu.inc     4 Apr 2005 12:33:16 -0000       1.17
  +++ main_menu.inc     5 Aug 2005 14:01:27 -0000       1.18
  @@ -96,8 +96,8 @@
                           onmouseout += "topOff('menu" + menuCount + "');";
                       }
                       boolean isRemoteLink =
  -                        (topLinkBean.getType() == 
PageInfoInterface.TYPE_URL) ||
  -                        (topLinkBean.getType() == 
PageInfoInterface.TYPE_LINK );
  +                        (topLinkBean.getPageType() == 
PageInfoInterface.TYPE_URL) ||
  +                        (topLinkBean.getPageType() == 
PageInfoInterface.TYPE_LINK );
                                %>
                       <td id="menu<%=menuCount%>" class="<bean:write 
name="classpath"/><bean:write name="myColorSet"/>">
                        <a href="<bean:write name='topLink' property='url'/>"<%
  @@ -109,7 +109,7 @@
                                }
                                %>><%
                               if (isRemoteLink) {
  -                                %><img 
src="<%=theURL%>/images/<%=topLinkBean.getType() == PageInfoInterface.TYPE_URL 
? "remote" : "local"%>.gif" border="0" width="9" height="9"/><%
  +                                %><img 
src="<%=theURL%>/images/<%=topLinkBean.getPageType() == 
PageInfoInterface.TYPE_URL ? "remote" : "local"%>.gif" border="0" width="9" 
height="9"/><%
                               }
                               %><bean:write name="topLink" property="title" 
filter="false"/>
                                <logic:empty name="topLink" 
property="title"><span style="color:#ff0000;"><content:resourceBundle
  

Reply via email to