JBoss Rich Faces SVN: r4116 - branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-11-20 12:34:11 -0500 (Tue, 20 Nov 2007)
New Revision: 4116
Added:
branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/OrderingListComponentTest.java
Removed:
branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/JSFComponentTest.java
Log:
Ordering list: JUnit tests.
Deleted: branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-11-20 16:31:25 UTC (rev 4115)
+++ branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-11-20 17:34:11 UTC (rev 4116)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class JSFComponentTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public JSFComponentTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
Copied: branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/OrderingListComponentTest.java (from rev 4078, branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/JSFComponentTest.java)
===================================================================
--- branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/OrderingListComponentTest.java (rev 0)
+++ branches/3.1.x/ui/orderingList/src/test/java/org/richfaces/component/OrderingListComponentTest.java 2007-11-20 17:34:11 UTC (rev 4116)
@@ -0,0 +1,263 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlOrderingList;
+
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class OrderingListComponentTest extends AbstractAjax4JsfTestCase {
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public OrderingListComponentTest( String testName )
+ {
+ super( testName );
+ }
+
+ private UIForm form = null;
+ private UIOrderingList orderingList = null;
+ private OrderingListBean bean = null;
+ private UICommand command = null;
+ private UIOrderingList orderingList2 = null;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ application.addComponent("org.richfaces.OrderingList", "org.richfaces.component.html.HtmlOrderingList");
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ command = new HtmlCommandLink();
+ command.setId("command");
+ form.getChildren().add(command);
+
+ bean = new OrderingListBean();
+
+ orderingList = (UIOrderingList)application.createComponent("org.richfaces.OrderingList");
+ orderingList.setControlsType("link");
+ orderingList.setVar("item");
+ orderingList.setValueBinding("value", new ValueBinding() {
+
+ public Class getType(FacesContext arg0) throws EvaluationException,
+ PropertyNotFoundException {
+ return String.class;
+ }
+
+ public Object getValue(FacesContext arg0)
+ throws EvaluationException, PropertyNotFoundException {
+ return bean.getValue();
+ }
+
+ public boolean isReadOnly(FacesContext arg0)
+ throws EvaluationException, PropertyNotFoundException {
+ return false;
+ }
+
+ public void setValue(FacesContext arg0, Object arg1)
+ throws EvaluationException, PropertyNotFoundException {
+ assertTrue(arg1 instanceof List);
+ bean.setValue((List)arg1);
+ }
+
+ });
+
+ form.getChildren().add(orderingList);
+
+ orderingList2 = (UIOrderingList)application.createComponent("org.richfaces.OrderingList");
+ }
+
+ public void tearDown() throws Exception {
+ bean = null;
+ orderingList = null;
+ orderingList2 = null;
+ command = null;
+ form = null;
+
+ super.tearDown();
+ }
+
+ /**
+ * Tests if component accepts request parameters and stores them in submittedValue().
+ * If component is immediate, validation (possibly with conversion) should occur on that phase.
+ *
+ * @throws Exception
+ */
+ public void testDecode() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlAnchor anchor = (HtmlAnchor)page.getDocumentElement().getHtmlElementById(command.getClientId(facesContext));
+ anchor.click();
+ externalContext.addRequestParameterMap(orderingList.getClientId(facesContext), "1sa,0");
+ orderingList.processDecodes(facesContext);
+ Object submittedValue = orderingList.getSubmittedValue();
+ assertNotNull(submittedValue);
+ assertTrue(submittedValue instanceof Object[]);
+ assertEquals(2, ((Object[])submittedValue).length);
+
+ Object valueHolder = ((Object[])submittedValue)[0];
+ assertNotNull(valueHolder);
+ assertTrue(valueHolder instanceof UIOrderingList.SubmittedValue);
+ assertEquals("1,0sa", valueHolder.toString());
+
+ orderingList.setImmediate(true);
+ orderingList.addValidator(new Validator() {
+
+ public void validate(FacesContext arg0, UIComponent arg1,
+ Object arg2) throws ValidatorException {
+ FacesMessage mess = new FacesMessage("Fake test message.");
+ throw new ValidatorException(mess);
+
+ }
+
+ });
+
+ page = renderView();
+ anchor = (HtmlAnchor)page.getDocumentElement().getHtmlElementById(command.getClientId(facesContext));
+ anchor.click();
+ externalContext.addRequestParameterMap(orderingList.getClientId(facesContext), "1sa,0");
+ orderingList.processDecodes(facesContext);
+ assertTrue(facesContext.getMessages().hasNext());
+ }
+
+ /**
+ * Tests if component handles value bindings correctly
+ *
+ * @throws Exception
+ */
+ public void testUpdate() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlAnchor anchor = (HtmlAnchor)page.getDocumentElement().getHtmlElementById(command.getClientId(facesContext));
+ anchor.click();
+ externalContext.addRequestParameterMap(orderingList.getClientId(facesContext), "1sa,0");
+ orderingList.processDecodes(facesContext);
+ orderingList.processValidators(facesContext);
+ orderingList.processUpdates(facesContext);
+
+ List newValue = bean.getValue();
+ assertNotNull(newValue);
+ assertEquals(2, newValue.size());
+ assertEquals(newValue.get(0), "2");
+ assertEquals(newValue.get(1), "1");
+ }
+
+ /**
+ * Tests if component handles validation correctly
+ *
+ * @throws Exception
+ */
+ public void testValidate() throws Exception {
+ orderingList.addValidator(new Validator() {
+
+ public void validate(FacesContext arg0, UIComponent arg1,
+ Object arg2) throws ValidatorException {
+ FacesMessage mess = new FacesMessage("Fake test message.");
+ throw new ValidatorException(mess);
+
+ }
+
+ });
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlAnchor anchor = (HtmlAnchor)page.getDocumentElement().getHtmlElementById(command.getClientId(facesContext));
+ anchor.click();
+ externalContext.addRequestParameterMap(orderingList.getClientId(facesContext), "1sa,0");
+ orderingList.processDecodes(facesContext);
+ orderingList.processValidators(facesContext);
+ assertTrue(facesContext.getMessages().hasNext());
+
+ Object submittedValue = orderingList.getSubmittedValue();
+ assertNotNull(submittedValue);
+ assertTrue(submittedValue instanceof Object[]);
+ assertEquals(2, ((Object[])submittedValue).length);
+
+ Object valueHolder = ((Object[])submittedValue)[0];
+ assertNotNull(valueHolder);
+ assertTrue(valueHolder instanceof UIOrderingList.SubmittedValue);
+ assertEquals("1,0sa", valueHolder.toString());
+ }
+
+ public void testSaveRestore() throws Exception {
+ String [] value = new String [] {"1"};
+ orderingList.setValueBinding("value", null);
+ orderingList.setValue(value);
+ assertEquals(value, orderingList.getValue());
+ assertNull(orderingList.getValueBinding("value"));
+
+ Object state = orderingList.saveState(facesContext);
+
+ orderingList2.restoreState(facesContext, state);
+ Object value2 = orderingList2.getValue();
+ assertNotNull(value2);
+ assertEquals(value, value2);
+ }
+
+ protected class OrderingListBean {
+ private List value = null;
+
+ public OrderingListBean() {
+ value = new ArrayList();
+ value.add("1");
+ value.add("2");
+ }
+
+ public List getValue() {
+ return value;
+ }
+
+ public void setValue(List value) {
+ this.value = value;
+ }
+ }
+}
18 years, 5 months
JBoss Rich Faces SVN: r4115 - in branches/3.1.x/ui/dropdown-menu/src/main: java/org/richfaces/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-20 11:31:25 -0500 (Tue, 20 Nov 2007)
New Revision: 4115
Removed:
branches/3.1.x/ui/dropdown-menu/src/main/config/resources/resources-config.xml
branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/images/
branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/css/
branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Modified:
branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
Log:
context menu moved to 3.1.x branch
Deleted: branches/3.1.x/ui/dropdown-menu/src/main/config/resources/resources-config.xml
===================================================================
--- branches/3.1.x/ui/dropdown-menu/src/main/config/resources/resources-config.xml 2007-11-20 16:31:12 UTC (rev 4114)
+++ branches/3.1.x/ui/dropdown-menu/src/main/config/resources/resources-config.xml 2007-11-20 16:31:25 UTC (rev 4115)
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resource-config>
-<!-- Menu list background -->
-
-
- <resource class="org.richfaces.renderkit.html.images.background.MenuListBackground">
- <name>org.richfaces.renderkit.html.images.background.MenuListBackground</name>
- </resource>
-</resource-config>
Modified: branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-11-20 16:31:12 UTC (rev 4114)
+++ branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-11-20 16:31:25 UTC (rev 4115)
@@ -21,140 +21,35 @@
package org.richfaces.renderkit.html;
-
-
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
import org.richfaces.component.UIMenuGroup;
-import org.richfaces.component.UIMenuItem;
-import org.richfaces.component.UIMenuSeparator;
-import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.ScriptOptions;
-public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {
+public class DropDownMenuRendererBase extends AbstractMenuRenderer {
protected Class getComponentClass() {
return UIDropDownMenu.class;
}
- public boolean getRendersChildren() {
- return true;
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- List flatListOfNodes = new LinkedList();
- String width = (String)component.getAttributes().get("popupWidth");
-
- flatten(component.getChildren(), flatListOfNodes);
- processLayer(context, component, width);
-
- for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
- UIMenuGroup node = (UIMenuGroup) iter.next();
- if (node.isRendered() && !node.isDisabled()) processLayer(context, node, width);
- }
- }
-
- public void processLayer(FacesContext context, UIComponent layer, String width) throws IOException {
- String clientId = layer.getClientId(context);
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("div", layer);
- writer.writeAttribute("id", clientId+"_menu", null);
- writer.writeAttribute("class", "dr-menu-list-border rich-menu-list-border", null);
- writer.writeAttribute("style", "visibility: hidden; z-index: 2; ", null);
- writer.startElement("div", layer);
- writer.writeAttribute("class", "dr-menu-list-bg rich-menu-list-bg", null);
- encodeItems(context, layer);
-
- writer.startElement("div", layer);
- writer.writeAttribute("class", "dr-menu-list-strut rich-menu-list-strut", null);
-
- writer.startElement("img", layer);
- writer.writeAttribute("width", "1", null);
- writer.writeAttribute("height", "1", null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("border", "0", null);
- writer.writeAttribute("style", width!=null && width.length() > 0 ? "width: " + HtmlUtil.qualifySize(width) : "", null);
- writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null),
- null);
- writer.endElement("img");
- writer.endElement("div");
-
- writer.endElement("div");
- writer.endElement("div");
-
- writer.startElement("iframe", layer);
- writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif")
- .getUri(context, null), null);
- writer.writeAttribute("id", clientId+"_menu_iframe", null);
- writer.writeAttribute("class", "underneath_iframe", null);
- writer.writeAttribute("style", "position:absolute; z-index: 1;", null);
- writer.endElement("iframe");
-
- writer.startElement("script", layer);
- writer.writeAttribute("id", clientId+"_menu_script", null);
- writer.writeAttribute("type", "text/javascript", null);
- encodeScript(context, layer);
- writer.endElement("script");
-
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
- renderedAreas.add(clientId + "_menu_iframe");
- renderedAreas.add(clientId + "_menu_script");
- }
-
- public void encodeItems(FacesContext context, UIComponent component) throws IOException {
- List kids = component.getChildren();
- Iterator it = kids.iterator();
- while (it.hasNext()) {
- UIComponent kid = (UIComponent)it.next();
- if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
- renderChild(context, kid);
- }
- }
- }
-
- private void flatten(List kids, List flatList){
- if(kids != null){
- for (Iterator iter = kids.iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid instanceof UIMenuGroup) {
- UIMenuGroup node = (UIMenuGroup) kid;
- flatList.add(node);
- flatten(node.getChildren(), flatList);
- }
- }
- }
- }
-
- public void encodeScript(FacesContext context, UIComponent component) throws IOException {
+ protected String getLayerScript(FacesContext context, UIComponent component) {
StringBuffer buffer = new StringBuffer();
JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
function.addParameter(component.getClientId(context)+"_menu");
function.addParameter(component.getAttributes().get("showDelay"));
- if (component instanceof UIDropDownMenu) {
+
+ if (component instanceof UIDropDownMenu) {
function.addParameter(component.getAttributes().get("hideDelay"));
+ } else {
+ function.addParameter(new Integer(300));
}
- else{
- function.addParameter(""+300);
- }
- function.appendScript(buffer);
+
+ function.appendScript(buffer);
+
if (component instanceof UIMenuGroup) {
buffer.append(".");
function = new JSFunction("asSubMenu");
@@ -162,14 +57,14 @@
function.addParameter("ref"+component.getClientId(context));
String evt = (String) component.getAttributes().get("event");
if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
+ evt = "onmouseover";
}
function.addParameter(evt);
- ScriptOptions Optionssub = new ScriptOptions(component);
- Optionssub.addOption("onopen", component.getAttributes().get("onopen"));
- Optionssub.addOption("onclose", component.getAttributes().get("onclose"));
- Optionssub.addOption("direction", component.getAttributes().get("direction"));
- function.addParameter(Optionssub);
+ ScriptOptions subMenuOptions = new ScriptOptions(component);
+ subMenuOptions.addEventHandler("onopen");
+ subMenuOptions.addEventHandler("onclose");
+ subMenuOptions.addOption("direction");
+ function.addParameter(subMenuOptions);
function.appendScript(buffer);
} else {
@@ -182,65 +77,24 @@
}
function.addParameter(evt);
function.addParameter("onmouseout");
- ScriptOptions Options = new ScriptOptions(component);
+ ScriptOptions menuOptions = new ScriptOptions(component);
- Options.addOption("direction", component.getAttributes().get("direction"));
- Options.addOption("jointPoint", component.getAttributes().get("jointPoint"));
- Options.addOption("verticalOffset", component.getAttributes().get("verticalOffset"));
+ menuOptions.addOption("direction");
+ menuOptions.addOption("jointPoint");
+ menuOptions.addOption("verticalOffset");
- Options.addOption("horizontalOffset", component.getAttributes().get("horizontalOffset"));
- Options.addOption("oncollapse", component.getAttributes().get("oncollapse"));
- Options.addOption("onexpand", component.getAttributes().get("onexpand"));
- Options.addOption("onitemselect", component.getAttributes().get("onitemselect"));
- Options.addOption("ongroupactivate", component.getAttributes().get("ongroupactivate"));
- function.addParameter(Options);
+ menuOptions.addOption("horizontalOffset");
+ menuOptions.addEventHandler("oncollapse");
+ menuOptions.addEventHandler("onexpand");
+ menuOptions.addEventHandler("onitemselect");
+ menuOptions.addEventHandler("ongroupactivate");
+ function.addParameter(menuOptions);
function.appendScript(buffer);
}
-
- List children = component.getChildren();
- for(Iterator it = children.iterator();it.hasNext();) {
- UIComponent kid = (UIComponent)it.next();
- String itemId = null;
- int flcloseonclick=1;
- int flagGroup = 0;
- if (kid instanceof UIMenuItem) {
- UIMenuItem MenuItem=(UIMenuItem)kid;
- itemId = kid.getClientId(context);
- if (MenuItem.isDisabled()){
- flcloseonclick=0;
- }
- } else if (kid instanceof UIMenuGroup) {
- UIMenuGroup menuGroup=(UIMenuGroup)kid;
- itemId = "ref" + kid.getClientId(context);
- flcloseonclick=0;
- if (menuGroup.isDisabled()) flagGroup = 2; else flagGroup = 1;
- }
- if(itemId != null){
- function = new JSFunction("addItem");
- function.addParameter(itemId);
- function.addParameter(new Integer(flcloseonclick));
-
- ScriptOptions options = new ScriptOptions(kid);
- options.addOption("onmouseout", kid.getAttributes().get("onmouseout"));
- options.addOption("onmouseover", kid.getAttributes().get("onmouseover"));
- options.addOption("flagGroup", new Integer(flagGroup));
- String tmp = (String)kid.getAttributes().get("selectClass");
- if (tmp != null && tmp.length() > 0) options.addOption("selectClass", tmp);
- function.addParameter(options);
- buffer.append('.');
- function.appendScript(buffer);
- }
- }
-
- ResponseWriter out = context.getResponseWriter();
- String script =buffer.append(";").toString();
- out.write(script);
-
-
-
+
+ return buffer.toString();
}
-
}
Deleted: branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-11-20 16:31:12 UTC (rev 4114)
+++ branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-11-20 16:31:25 UTC (rev 4115)
@@ -1,1204 +0,0 @@
-
-if(!window.RichFaces) window.RichFaces = {};
-if(!RichFaces.Menu) RichFaces.Menu = {};
-
-/**
- * Fixes IE bug with incorrect layer width when set to auto
- * @param layer
- */
-RichFaces.Menu.fitLayerToContent = function(layer) {
- if (!RichFaces.Menu.Layers.IE)
- return;
-
- var table = layer.childNodes[0];
- if (table) {
- if (layer.style.width.indexOf("px")!=-1) {
- var width = parseFloat(layer.style.width.substring(0,layer.style.width.indexOf('px')));
- var tmpDims = Element.getDimensions(table);
- if (tmpDims.width > width) layer.style.width = tmpDims.width + "px";
- }
- //layer.style.height = dims.height + "px";
- } // if
-}
-
-RichFaces.Menu.removePx = function(e) {
- if ((e+"").indexOf("px")!=-1)
- return (e+"").substring(0,e.length-2);
- else
- return e;
-}
-
-
-RichFaces.Menu.Layers = {
- listl: new Array(),
- father: {},
- lwidthDetected:false,
- lwidth:{},
- back: new Array(),
- horizontals: {},
- layers: {},
- levels: ['','','','','','','','','','',''],
- detectWidth: function(){
- this.IE = (navigator.userAgent.indexOf('MSIE') > -1) && (navigator.userAgent.indexOf('Opera') < 0);
- this.NS = (navigator.userAgent.indexOf('Netscape') > -1);
- }
- ,
-
- menuTopShift : -11,
- menuRightShift : 11,
- menuLeftShift : 0,
- shadowWidth: 0,
- thresholdY : 0,
- abscissaStep : 180,
-
- CornerRadius: 0,
-
- toBeHidden : new Array(),
- toBeHiddenLeft : new Array(),
- toBeHiddenTop : new Array(),
-
- layersMoved : 0,
- layerPoppedUp : '',
- layerTop : new Array(),
- layerLeft : new Array(),
- timeoutFlag : 0,
- useTimeouts : 1,
- timeoutLength : 500,
- showTimeOutFlag : 0,
- showTimeoutLength: 0,
- queuedId : '',
-
- LMPopUp:function(menuName, isCurrent) {
- if (!this.loaded || ( this.isVisible(menuName) && !isCurrent)) {
- return;
- }
- if (menuName == this.father[this.layerPoppedUp]) {
- this.LMPopUpL(this.layerPoppedUp, false);
- } else if (this.father[menuName] == this.layerPoppedUp) {
- this.LMPopUpL(menuName, true);
- } else {
- //this.shutdown();
- foobar = menuName;
- do {
- this.LMPopUpL(foobar, true);
- foobar = this.father[foobar];
- } while (foobar);
- }
- this.layerPoppedUp = menuName;
- },
-
- isVisible: function(layer) {
- return ($(layer).style.visibility == 'visible');
- },
-
- /**
- * @param menuName
- * @param visibleFlag
- */
- LMPopUpL: function(menuName, visibleFlag) {
- if (!this.loaded) {
- return;
- }
- this.detectWidth();
- var menu = $(menuName);
- RichFaces.Menu.fitLayerToContent(menu);
- var visible = this.isVisible(menuName);
- this.setVisibility(menuName, visibleFlag);
- this.ieSelectWorkAround(menuName, visibleFlag);
- if (visible && !visibleFlag) {
- var menuLayer = this.layers[menu.id];
- if (menuLayer && menuLayer.eventOnClose) menuLayer.eventOnClose();
- if (menuLayer && menuLayer.eventOnCollapse) menuLayer.eventOnCollapse();
- if (menuLayer.refItem) menuLayer.refItem.highLightGroup(false);
- } else if (!visible && visibleFlag) {
- var menuLayer = this.layers[menu.id];
- if (menuLayer && menuLayer.eventOnOpen) menuLayer.eventOnOpen();
- if (menuLayer && menuLayer.eventOnExpand) menuLayer.eventOnExpand();
-
- if (menuLayer.level>0) {
- do {
- menuLayer = this.layers[(this.father[menuLayer.id])];
- } while (menuLayer.level > 0)
- if (menuLayer && menuLayer.eventOnGroupActivate) menuLayer.eventOnGroupActivate();
- }
- }
- },
-
- ieSelectWorkAround: function(menuName, on){
- //alert(navigator.userAgent);
- if(this.IE || this.NS) {
- menuName = $(menuName).id;
- var menu = $(menuName);
- var iframe = $(menuName + "_iframe");
- var nsfix = (this.NS ? 7 : 0);
- if(on){
- var dim = Element.getDimensions(menu);
- iframe.style.top = menu.style.top;
- iframe.style.left = menu.style.left;
- iframe.style.width = menu.offsetWidth + "px"
- iframe.style.height = menu.offsetHeight + "px"
- iframe.style.visibility = "visible";
- } else {
- iframe.style.visibility = "hidden";
- }
- }
- },
-
- shutdown: function () {
- var needToResetLayers = false;
- for (i=0; i<this.listl.length; i++) {
- var layerId = this.listl[i];
- if ($(layerId)) {
- this.LMPopUpL(layerId, false);
- } else {
- needToResetLayers = true;
- }
- }
-
- if (needToResetLayers) {
- this.resetLayers();
- }
-
- this.layerPoppedUp = '';
- if (this.Konqueror || this.IE5) {
- this.seeThroughElements(true);
- }
- },
- resetLayers: function() {
- var newList = new Array();
- for (i=0; i<this.listl.length; i++) {
- var layer = this.listl[i];
- if ($(layer)) {
- newList.push(layer);
- }
- }
-
- this.listl = newList;
- }
- ,
-
- /**
- * Set visibility
- * @param layer the layer to visibility
- * @param visible the boolean flag, if true to set visible layer from variable, otherwise - hide this layer
- */
- setVisibility: function (layer, visible) {
- var tmpLayer = $(layer);
-
- if (visible) {
- tmpLayer.style.visibility = 'visible';
- } else {
- if(tmpLayer.getElementsByTagName){
- var inputs = tmpLayer.getElementsByTagName('INPUT');
- if(inputs){
- $A(inputs).each(function(node){node.blur()});
- } // if
- } // if
-
- tmpLayer.style.visibility = 'hidden';
-// tmpLayer.style.left = "-"+tmpLayer.clientWidth;
-// Element.hide(tmpLayer);
- } // else
- },
-
-
- clearLMTO: function () {
- if (this.useTimeouts) {
- clearTimeout(this.timeoutFlag);
- }
- },
-
- setLMTO: function (ratio) {
- if(!ratio){
- ratio = this.timeoutLength;
- }
- if (this.useTimeouts) {
- clearTimeout(this.timeoutFlag);
- this.timeoutFlag = setTimeout('RichFaces.Menu.Layers.shutdown()', ratio);
- }
- },
-
- loaded:1,
-
- clearPopUpTO: function(){
- clearTimeout(this.showTimeOutFlag);
- },
- showMenuLayer: function (layerId, e, delay){
- this.clearPopUpTO();
- this.showTimeOutFlag = setTimeout(new RichFaces.Menu.DelayedPopUp(layerId, e, function(){this.layerId = null;}.bind(this)).show, delay);
- this.layerId = layerId;
- },
- showDropDownLayer: function (layerId, parentId, e, delay){
- this.clearPopUpTO();
- this.showTimeOutFlag = setTimeout(new RichFaces.Menu.DelayedDropDown(layerId, parentId, e).show, delay);
- },
- showPopUpLayer: function (layer, e){
- this.shutdown();
- this.detectWidth();
- this.LMPopUp(menuName, false);
- this.setLMTO(4);
- }
-};
-
-/**
- * return true if defined document element or document body, otherwise return false
- */
-RichFaces.Menu.getWindowElement = function() {
- return (document.documentElement || document.body);
-}
-
-RichFaces.Menu.getWindowDimensions = function() {
- var x,y;
- if (self.innerHeight) // all except Explorer
- {
- x = self.innerWidth;
- y = self.innerHeight;
- }
- else if (document.documentElement && document.documentElement.clientHeight)
- // Explorer 6 Strict Mode
- {
- x = document.documentElement.clientWidth;
- y = document.documentElement.clientHeight;
- }
- else if (document.body) // other Explorers
- {
- x = document.body.clientWidth;
- y = document.body.clientHeight;
- }
- return {width:x, height:y};
-}
-
-RichFaces.Menu.getWindowScrollOffset = function() {
- var x,y;
- if (typeof pageYOffset != "undefined") // all except Explorer
- {
- x = window.pageXOffset;
- y = window.pageYOffset;
- }
- else if (document.documentElement && document.documentElement.scrollTop)
- // Explorer 6 Strict
- {
- x = document.documentElement.scrollLeft;
- y = document.documentElement.scrollTop;
- }
- else if (document.body) // all other Explorers
- {
- x = document.body.scrollLeft;
- y = document.body.scrollTop;
- }
-
- return {top:y, left: x};
-}
-
-RichFaces.Menu.getPageDimensions = function() {
- var x,y;
- var test1 = document.body.scrollHeight;
- var test2 = document.body.offsetHeight;
- if (test1 > test2) {
- // all but Explorer Mac
- x = document.body.scrollWidth;
- y = document.body.scrollHeight;
- }
- else {
- // Explorer Mac;
- // would also work in Explorer 6 Strict, Mozilla and Safari
-
- x = document.body.offsetWidth;
- y = document.body.offsetHeight;
- }
-
- return {width:x, height:y};
-}
-
-
-RichFaces.Menu.DelayedContextMenu = function(layer, e) {
- if (!e) {
- e = window.event;
- }
- this.event = e;
- this.element = Event.element(e);
- this.layer = $(layer);
- this.show = function() {
- RichFaces.Menu.Layers.shutdown();
- var body = RichFaces.Menu.getPageDimensions();
- var win = RichFaces.Menu.getWindowDimensions();
- var bodyHeight = body.height;
- var bodyWidth = body.width;
- var clientX = this.event.clientX;
- var clientY = this.event.clientY;
-
- var top = Event.pointerY(this.event);
- var left = Event.pointerX(this.event);
- var layerdim = Element.getDimensions(this.layer);
- var layerLeft = left;
-
- if (clientX + layerdim.width > win.width) {
- layerLeft -= (layerdim.width - RichFaces.Menu.Layers.shadowWidth - RichFaces.Menu.Layers.CornerRadius);
- }
-
- if (layerLeft < 0) {
- layerLeft = 0;
- }
-
- /*
- if (layerLeft + layerdim.width > bodyWidth) {
- layerLeft = bodyWidth - layerdim.width;
- }
-
- if (layerLeft < 0) {
- layerLeft = 0;
- }
- */
- var layerTop = top;
- /*if (layertop + layerdim.height > bodyHeight) {
- layertop = bodyHeight - layerdim.height;
- }
-
- if (layertop < 0) {
- layertop = 0;
- }
- */
- if (clientY + layerdim.height > win.height) {
- layerTop -= (layerdim.height - RichFaces.Menu.Layers.shadowWidth - RichFaces.Menu.Layers.CornerRadius);
- }
-
- if (layerTop < 0) {
- layerTop = 0;
- }
-
- this.layer.style.left = layerLeft + "px";
- this.layer.style.top = layerTop + "px";
-
- RichFaces.Menu.Layers.LMPopUp(this.layer.id, false);
- RichFaces.Menu.Layers.clearLMTO();
- }.bind(this);
-}
-
-
-/**
- * Calculates for DROPDOWN
- */
-RichFaces.Menu.DelayedDropDown = function(layer, elementId, e) {
- if (!e) {
- e = window.event;
- }
-
- this.event = e;
- this.element = $(elementId) || Event.element(e);
- this.layer = $(layer);
- Event.stop(e);
-
- this.listPositions = function(jp, dir) {
- var poss = new Array(new Array(2,1,4),new Array(1,2,3),new Array(4,3,2),new Array(3,4,1));
- var list = new Array();
- if (jp>0 && dir>0) {
- list.push({jointPoint: jp, direction: dir });
- } else if (jp>0 && dir==0) {
- for(var i=0;i<3;i++) {
- list.push({jointPoint: jp, direction: poss[jp-1][i] });
- }
- } else if (jp==0 && dir>0) {
- for(var i=0;i<3;i++) {
- list.push({jointPoint: poss[dir-1][i], direction: dir });
- }
- } else if (jp==0 && dir==0) {
- list.push({jointPoint: 4, direction: 3 });
- list.push({jointPoint: 1, direction: 2 });
- list.push({jointPoint: 3, direction: 4 });
- list.push({jointPoint: 2, direction: 1 });
- }
- return list;
- }.bind(this);
-
- this.calcPosition = function(jp, dir) {
- var layerLeft;
- var layerTop;
- switch (jp) {
- case 1:
- layerLeft = this.left;
- layerTop = this.top;
- break;
- case 2:
- layerLeft = this.right;
- layerTop = this.top;
- break;
- case 3:
- layerLeft = this.right;
- layerTop = this.bottom;
- break;
- case 4:
- layerLeft = this.left;
- layerTop = this.bottom;
- break;
- }
- switch (dir) {
- case 1:
- layerLeft -= this.layerdim.width;
- layerTop -= this.layerdim.height;
- break;
- case 2:
- layerTop -= this.layerdim.height;
- break;
- case 4:
- layerLeft -= this.layerdim.width;
- }
- return {left: layerLeft, top: layerTop};
- }.bind(this);
-
- this.show = function() {
- RichFaces.Menu.Layers.shutdown();
-
- var winOffset = RichFaces.Menu.getWindowScrollOffset();
- var win = RichFaces.Menu.getWindowDimensions();
- var pageDims = RichFaces.Menu.getPageDimensions();
-
-
- var windowHeight = win.height;
- var windowWidth = win.width;
-
-// var screenOffset = Position.cumulativeOffset(this.element);
-// if (Element.getStyle(this.element, 'position') == 'absolute') {
-// screenOffset[0] = 0;
-// screenOffset[1] = 0;
-// }
- var screenOffset = Position.positionedOffset(this.element);
- var innerDiv = this.element.lastChild;
- var dim = Element.getDimensions(this.element);
-
- var parOffset = Position.cumulativeOffset(this.element);
- var divOffset = Position.cumulativeOffset(innerDiv);
- var deltaX = divOffset[0] - parOffset[0];
- var deltaY = divOffset[1] - parOffset[1];
-
- // parent element
- this.top = screenOffset[1];
- this.left = screenOffset[0];
-
- this.bottom = this.top + dim.height;
- this.right = this.left + dim.width;
-
- this.layerdim = Element.getDimensions(this.layer);
-
- var options = RichFaces.Menu.Layers.layers[this.layer.id].options;
-
- var jointPoint = 0;
- if (options.jointPoint) {
- var sJp = options.jointPoint.toUpperCase();
- jointPoint = sJp.indexOf('TL') != -1?1:jointPoint;
- jointPoint = sJp.indexOf('TR') != -1?2:jointPoint;
- jointPoint = sJp.indexOf('BR') != -1?3:jointPoint;
- jointPoint = sJp.indexOf('BL') != -1?4:jointPoint;
- }
-
- var direction = 0;
- if (options.direction) {
- var sDir = options.direction.toUpperCase();
- direction = sDir.indexOf('TOP-LEFT') != -1?1:direction;
- direction = sDir.indexOf('TOP-RIGHT') != -1?2:direction;
- direction = sDir.indexOf('BOTTOM-RIGHT')!= -1?3:direction;
- direction = sDir.indexOf('BOTTOM-LEFT') != -1?4:direction;
- }
- var hOffset = options.horizontalOffset;
- var vOffset = options.verticalOffset;
-
- var listPos = this.listPositions(jointPoint, direction);
- var layerPos;
- var foundPos = false;
- for (var i=0;i<listPos.length;i++) {
- layerPos = this.calcPosition(listPos[i].jointPoint, listPos[i].direction)
- if ((layerPos.left + hOffset >= winOffset.left) &&
- (layerPos.left + hOffset + this.layerdim.width - winOffset.left <= windowWidth) &&
- (layerPos.top + vOffset >= winOffset.top) &&
- (layerPos.top + vOffset + this.layerdim.height - winOffset.top <= windowHeight)) {
- foundPos = true;
- break;
- }
- }
- if (!foundPos) {
- layerPos = this.calcPosition(listPos[0].jointPoint, listPos[0].direction)
- }
- this.layer.style.left = layerPos.left + hOffset - deltaX - this.left + "px";
- this.layer.style.top = layerPos.top + vOffset - deltaY - this.top + "px";
-
- this.layer.style.width = this.layer.clientWidth + "px";
-
- RichFaces.Menu.Layers.LMPopUp(this.layer.id, false);
- RichFaces.Menu.Layers.clearLMTO();
- }.bind(this);
-}
-
-RichFaces.Menu.DelayedPopUp = function(layer, e) {
- if (!e) {
- e = window.event;
- }
-
- this.event = e;
- this.element = Event.findElement(e, 'div');
- if (this.element.id.indexOf(":folder") == (this.element.id.length -7) ) {
- this.element = this.element.parentNode;
- }
- this.layer = $(layer);
-
- this.show = function() {
- if (!RichFaces.Menu.Layers.isVisible(this.layer) &&
- RichFaces.Menu.Layers.isVisible(RichFaces.Menu.Layers.father[this.layer.id])) {
- this.reposition();
- RichFaces.Menu.Layers.LMPopUp(this.layer, false);
- }
- }.bind(this);
-}
-
-RichFaces.Menu.DelayedPopUp.prototype.reposition = function() {
- var windowShift = RichFaces.Menu.getWindowScrollOffset();
- var body = RichFaces.Menu.getWindowDimensions();
- var windowHeight = body.height;
- var windowWidth = body.width;
- var scrolls = {top:0, left:0};
- var screenOffset = Position.positionedOffset(this.element);
- var leftPx = RichFaces.Menu.removePx(this.element.parentNode.parentNode.style.left);
- var topPx = RichFaces.Menu.removePx(this.element.parentNode.parentNode.style.top);
- screenOffset[0]+=Number(leftPx);
- screenOffset[1]+=Number(topPx);
- var cumulativeOffset = Position.cumulativeOffset(this.element);
- var labelOffset = [cumulativeOffset[0] - screenOffset[0], cumulativeOffset[1] - screenOffset[1]];
- var dim = Element.getDimensions(this.element);
- var top = screenOffset[1] + scrolls.top;
- var bottom = top + dim.height;
- var left = screenOffset[0] + scrolls.left;
- var right = left + dim.width;
- var layerdim = Element.getDimensions(this.layer);
-
- var options = RichFaces.Menu.Layers.layers[this.layer.id].options;
- var dir = 0;
- var vDir = 0;
- if (options.direction) {
- strDirection = options.direction.toUpperCase();
- dir = strDirection.indexOf('LEFT')!=-1?1:dir;
- dir = strDirection.indexOf('RIGHT')!=-1?2:dir;
- if (dir>0) {
- if (strDirection.indexOf('LEFT-UP')!=-1 ||
- strDirection.indexOf('RIGHT-UP')!=-1) vDir = 1;
- if (strDirection.indexOf('LEFT-DOWN')!=-1 ||
- strDirection.indexOf('RIGHT-DOWN')!=-1) vDir = 2;
- }
- }
-
- var layerLeft = right;
- var layerTop = top - this.layer.firstChild.firstChild.offsetTop;
-
- if (dir == 0) {
- if (layerLeft + layerdim.width + labelOffset[0] - windowShift.left >= windowWidth) {
- var invisibleRight = layerLeft + layerdim.width + labelOffset[0] - windowShift.left - windowWidth;
- layerLeft = left - layerdim.width;
- }
-
- if (layerLeft + labelOffset[0] < 0) {
- if (Math.abs(layerLeft + labelOffset[0]) > invisibleRight) {
- layerLeft = right;
- }
- }
-
- } else if (dir == 1) {
- layerLeft = left - layerdim.width;
- }
-
- if (vDir != 2) {
- if (layerTop + layerdim.height + labelOffset[1] - windowShift.top >= windowHeight
- || vDir == 1) {
- var invisibleBottom = layerTop + layerdim.height + labelOffset[1] - windowShift.top - windowHeight;
- var items = this.layer.firstChild.childNodes;
- if (items.length > 1) {
- var lastItem = items[items.length-2];
- // var layerOffset = Position.cumulativeOffset(this.layer);
- var itemOffset = Position.positionedOffset(lastItem);
- // layerTop = top -(itemOffset[1]-layerOffset[1]);
- layerTop = top - itemOffset[1];
- if (vDir == 0) {
- if (layerTop < 0) {
- if (Math.abs(layerTop) > invisibleBottom) layerTop = top;
- }
- }
- }
- }
- }
-
-/* if (layerLeft + layerdim.width >= windowWidth) {
- layerLeft = left - layerdim.width + RichFaces.Menu.Layers.shadowWidth;
- }
-
- if (layerLeft < 0) {
- layerLeft = 0;
- }
-
- // search offsetTop (ch-1351)
- var layerOffset = Position.cumulativeOffset(this.layer);
- var items = document.getElementsByClassName("exadel_menuItem",this.layer);
- var nodes = document.getElementsByClassName("exadel_menuNode",this.layer);
- var firstItem = (items.length>0) ? items[0] : ((nodes.length>0) ? nodes[0] : null);
- if (firstItem) {
- if (nodes.length>0 && firstItem.offsetTop>nodes[0].offsetTop) firstItem = nodes[0];
- var itemOffset = Position.cumulativeOffset(firstItem);
- layertop = top -(itemOffset[1]-layerOffset[1]);
- if (layertop + layerdim.height >= windowHeight) {
- var lastItem = (items.length>0) ? items[items.length-1] : nodes[nodes.length-1];
- if (nodes.length>0 && lastItem.offsetTop<nodes[nodes.length-1].offsetTop) lastItem = nodes[nodes.length-1];
- itemOffset = Position.cumulativeOffset(lastItem);
- layertop = top -(itemOffset[1]-layerOffset[1]);
- }
- } else layertop = top - RichFaces.Menu.Layers.CornerRadius;
-
- if (layertop < 0) {
- layertop = 0;
- } */
-
- this.layer.style.left = layerLeft + "px";
- this.layer.style.top = layerTop + "px";
-
- this.layer.style.width = this.layer.clientWidth + "px";
-
-}
-/**
- * set to true when a dropdown box inside menu receives focus
- */
-RichFaces.Menu.selectOpen = false;
-RichFaces.Menu.MouseIn = false;
-
-
-RichFaces.Menu.Layer = Class.create();
-RichFaces.Menu.Layer.prototype = {
- initialize: function(id,delay, hideDelay){
- RichFaces.Menu.Layers.listl.push(id);
- this.id = id;
- this.layer = $(id);
- this.level = 0;
- this.delay = delay;
- if (hideDelay){
- this.hideDelay=hideDelay;
- }
- else{
- this.hideDelay=hideDelay;
- }
- RichFaces.Menu.fitLayerToContent(this.layer);
- this.items = new Array();
- RichFaces.Menu.Layers.layers[id] = this;
- this.bindings = new Array();
-
-
-
- this.mouseover =
- function(e){
- RichFaces.Menu.MouseIn=true;
- RichFaces.Menu.Layers.clearLMTO();
-
- var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-select rich-ddmenu-label rich-ddmenu-label-select';
-
- Event.stop(e);
- }.bindAsEventListener(this);
-
- this.mouseout =
- function(e){
- RichFaces.Menu.MouseIn = false;
- if (!RichFaces.Menu.selectOpen) {
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- }
- var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect';
-
- Event.stop(e);
- }.bindAsEventListener(this);
-
-
-
- var binding = new RichFaces.Menu.Layer.Binding (
- this.id,
- "mouseover",
- this.mouseover);
-
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- this.id,
- "mouseout",
- this.mouseout);
- this.bindings.push(binding);
- binding.refresh();
-
- arrayinp=$A(this.layer.getElementsByTagName("select"));
- for(i=0; i<arrayinp.length; i++){
- var openSelectb = this.openSelect.bindAsEventListener(this);
- var closeSelectb = this.closeSelect.bindAsEventListener(this);
- Event.observe(arrayinp[i], "focus", openSelectb);
- Event.observe(arrayinp[i], "blur", closeSelectb);
- //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
- var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
- //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
- var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
- Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
- Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
-
- //var OnKeyPressb = RichFaces.Menu.Layer.OnKeyPress.bindAsEventListener(this);
- var OnKeyPressb = this.OnKeyPress.bindAsEventListener(this);
- Event.observe(arrayinp[i], "keypress", OnKeyPressb);
- }
-
- arrayinp=$A(this.layer.getElementsByTagName("input"));
- for(i=0; i<arrayinp.length; i++){
- var openSelectb = this.openSelect.bindAsEventListener(this);
- var closeSelectb = this.closeSelect.bindAsEventListener(this);
- Event.observe(arrayinp[i], "focus", openSelectb);
- Event.observe(arrayinp[i], "blur", closeSelectb);
- //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
- var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
- //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
- var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
- Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
- Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
- var OnKeyPressb = this.OnKeyPress.bindAsEventListener(this);
- Event.observe(arrayinp[i], "keypress", OnKeyPressb);
- }
-
- arrayinp=$A(this.layer.getElementsByTagName("textarea"));
- for(i=0; i<arrayinp.length; i++){
- var openSelectb = this.openSelect.bindAsEventListener(this);
- var closeSelectb = this.closeSelect.bindAsEventListener(this);
- Event.observe(arrayinp[i], "focus", openSelectb);
- Event.observe(arrayinp[i], "blur", closeSelectb);
- //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
- var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
- //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
- var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
- Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
- Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
- }
-
-/* if(window.A4J && A4J.AJAX ){
- var listener = new A4J.AJAX.Listener(this.rebind.bindAsEventListener(this));
- A4J.AJAX.AddListener(listener);
- } */
- },
-
-
-
- openSelect: function(event){
- RichFaces.Menu.selectOpen = true;
- var ClickInputb = this.ClickInput.bindAsEventListener(this);
- Event.observe(Event.element(event), "click", this.ClickInput);
-
- },
-
-
- closeSelect: function(event){
- RichFaces.Menu.selectOpen = false;
- var ClickInputb = this.ClickInput.bindAsEventListener(this);
- Event.stopObserving(Event.element(event), "click", this.ClickInput);
- if (RichFaces.Menu.MouseIn == false){
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- }
- },
-
-
-
- OnKeyPress: function(event){
-
- if(event.keyCode==13){
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- }
- },
-
-
- MouseoverInInput: function(event){
- //alert("event rabotaet "+ event.target);
- var ClickInputb = this.ClickInput.bindAsEventListener(this);
- Event.observe(Event.element(event), "click", this.ClickInput);
- },
-
-
- ClickInput: function(event){
- //alert("event rabotaet dsds ");
- Event.stop(event || window.event);
- return false;
- },
-
-
- MouseoutInInput: function(event){
- var ClickInputb = this.ClickInput.bindAsEventListener(this);
- Event.stopObserving(Event.element(event), "click", this.ClickInput);
-
- },
-
- rebind:function(){
- $A(this.bindings)
- .each(
- function(binding){
- binding.refresh();
- }
- );
- },
- showMe: function(e){
- this.closeSiblings(e);
- //LOG.a4j_debug('show me ' + this.id +' ' +this.level);
- RichFaces.Menu.Layers.showMenuLayer(this.id, e, this.delay);
- RichFaces.Menu.Layers.levels[this.level] = this;
-// if (this.eventOnOpen) this.eventOnOpen();
- },
- closeSiblings: function(e){
- //LOG.a4j_debug('closeASiblins ' + this.id +' ' +this.level);
- if(RichFaces.Menu.Layers.levels[this.level] && RichFaces.Menu.Layers.levels[this.level].id != this.id){
- for(var i = this.level; i < RichFaces.Menu.Layers.levels.length; i++){
- if(RichFaces.Menu.Layers.levels[i]) {
- RichFaces.Menu.Layers.levels[i].hideMe();
- //RichFaces.Menu.Layers.levels[i] = '';
- }
- }
- }
- },
- closeMinors: function(id){
- //LOG.a4j_debug('closeMinors ' + this.id +' ' +this.level);
- var item = this.items[id];
-// if(!item.childMenu){
- //LOG.a4j_debug('hiding menus ' + this.id +' ' +this.level);
- for(var i = this.level + (!item.childMenu?1:2); i < RichFaces.Menu.Layers.levels.length; i++){
- if(RichFaces.Menu.Layers.levels[i]) {
- //LOG.a4j_debug('hide ' +RichFaces.Menu.Layers.levels[i]);
- RichFaces.Menu.Layers.levels[i].hideMe();
- }
- }
-// }
- if (item.menu.refItem) {
- item.menu.refItem.highLightGroup(true);
- }
-
- },
- //addItem: function(itemId, hoverClass, plainClass, hoverStyle, plainStyle){
- addItem: function(itemId, flag_close_onclick, options) {
- var dis = this;
- var item = {
- highLightGroup: function(light) {
- if (light) {
- Element.removeClassName(this.id,"dr-menu-item-enabled");
- Element.addClassName(this.id,"dr-menu-item-hover");
- Element.addClassName(this.id,"rich-menu-group-hover");
- if (this.options.selectClass) Element.addClassName(this.id, this.options.selectClass);
-
- Element.addClassName(this.id+":icon","rich-menu-item-icon-selected");
- Element.addClassName(this.id+":anchor","rich-menu-item-label");
- } else if (!this.mouseOver) {
- Element.removeClassName(this.id,"dr-menu-item-hover");
- Element.removeClassName(this.id,"rich-menu-group-hover");
- Element.addClassName(this.id,"dr-menu-item-enabled");
- if (this.options.selectClass) Element.removeClassName(this.id, this.options.selectClass);
-
- Element.removeClassName(this.id+":icon","rich-menu-item-icon-selected");
- Element.removeClassName(this.id+":anchor","rich-menu-item-label");
- }
- }
- };
- item.id = itemId;
- item.obj = $(itemId);
- item.menu = this;
- item.options = options || {};
- item.mouseOver = false;
- if (item.options.onmouseover && item.options.onmouseover != ""){
- item.eventOnMouseOver = new Function("event",item.options.onmouseover).bindAsEventListener(item);
- }
- if (item.options.onmouseout && item.options.onmouseout != ""){
- item.eventOnMouseOut = new Function("event",item.options.onmouseout).bindAsEventListener(item);
- }
- this.items[itemId] = item;
-
- var onmouseover =
- function(e){
- this.menu.closeMinors(this.id);
- if (this.options.flagGroup == 1) {
- this.mouseOver = true;
- this.highLightGroup(true);
- }
- if (this.eventOnMouseOver) {
- var reltg = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
- while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOver();
- }
- }.bindAsEventListener(item);
-
- var onmouseout =
- function(e){
- if (this.options.flagGroup == 1) {
- this.mouseOver = false;
- this.highLightGroup(false);
- }
- if (this.eventOnMouseOut) {
- var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
- while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOut();
- }
- }.bindAsEventListener(item);
-
- var onmouseclick =
- function(e){
- var menuLayer = item.menu;
- while (menuLayer.level > 0) {
- menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
- }
- if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
- RichFaces.Menu.Layers.shutdown();
- }.bindAsEventListener(item);
-
- var binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseover",
- onmouseover);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseout",
- onmouseout);
- this.bindings.push(binding);
- binding.refresh();
- if (flag_close_onclick==1){
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "click",
- onmouseclick);
- this.bindings.push(binding);
- binding.refresh();
- }
-
- return this;
- },
- hideMe: function(e){
- RichFaces.Menu.Layers.clearPopUpTO();
- RichFaces.Menu.Layers.levels[this.level] = null;
- RichFaces.Menu.Layers.LMPopUpL(this.id, false);
-// if (this.eventOnClose) this.eventOnClose();
- },
- asDropDown: function(topLevel, onEvt, offEvt, options){
- this.options = options || {};
- if (this.options.ongroupactivate != ""){
- this.eventOnGroupActivate = new Function("event",this.options.ongroupactivate).bindAsEventListener(this);
- }
- if (this.options.onitemselect != ""){
- this.eventOnItemSelect = new Function("event",options.onitemselect).bindAsEventListener(this);
- }
- if (this.options.oncollapse != ""){
- this.eventOnCollapse = new Function("event",this.options.oncollapse).bindAsEventListener(this);
- }
- if (this.options.onexpand != ""){
- this.eventOnExpand = new Function("event",this.options.onexpand).bindAsEventListener(this);
- }
-
-// if($(topLevel)){ CH-1518
- var onmouseover = function(e){
- if (!e) {
- e = window.event;
- }
- RichFaces.Menu.Layers.showDropDownLayer(this.id, topLevel, e,this.delay);
- }.bindAsEventListener(this);
-
- if(!onEvt){
- onEvt = 'onmouseover';
- }
- onEvt = this.eventJsToPrototype(onEvt);
- if(!offEvt){
- offEvt = 'onmouseout';
- }
- offEvt = this.eventJsToPrototype(offEvt);
-
- var dis = this;
- var onmouseout =
- function(e){
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- RichFaces.Menu.Layers.clearPopUpTO();
- }.bindAsEventListener(this);
-
-// var item = $(topLevel);
- var binding = new RichFaces.Menu.Layer.Binding(topLevel,onEvt, onmouseover);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (topLevel, offEvt, onmouseout);
- this.bindings.push(binding);
- binding.refresh();
-
- RichFaces.Menu.Layers.horizontals[this.id] = topLevel;
-// }
- return this;
- },
-
- asSubMenu: function(parentv, refLayerName, evtName, options){
- this.options = options || {};
- if (this.options.onclose != ""){
- this.eventOnClose = new Function("event",this.options.onclose).bindAsEventListener(this);
- }
- if (this.options.onopen != ""){
- this.eventOnOpen = new Function("event",this.options.onopen).bindAsEventListener(this);
- }
-
- if(!evtName){
- evtName = 'onmouseover';
- }
- evtName = this.eventJsToPrototype(evtName);
- this.level = RichFaces.Menu.Layers.layers[parentv].level + 1;
- RichFaces.Menu.Layers.father[this.id] = parentv;
- if(!refLayerName){
- refLayerName = 'ref' + parentv;
- }
- var refLayer = $(refLayerName);
- this.refItem = RichFaces.Menu.Layers.layers[parentv].items[refLayerName];
- this.refItem.childMenu = this;
- var binding = new RichFaces.Menu.Layer.Binding(refLayerName, evtName, this.showMe.bindAsEventListener(this));
- this.bindings.push(binding);
- binding.refresh();
-
-
- // set parents hideDelay
- var menuLayer=this;
- while (menuLayer.level > 0) {
- menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
- }
- if (menuLayer && menuLayer.hideDelay){
- this.hideDelay=menuLayer.hideDelay;
- }
-
-
- return this;
- },
- asContextMenu: function(parent, evt){
- var refLayer = $(parent);
- if(!refLayer) return this;
- var id = this.id;
- if(!evt){
- evt = 'onclick';
- }
- var offEvt = 'onmouseout';
- offEvt = this.eventJsToPrototype(offEvt);
-
- var dis = this;
- var onmouseout =
- function(e){
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- RichFaces.Menu.Layers.clearPopUpTO();
- }.bindAsEventListener(this);
- evt = this.eventJsToPrototype(evt);
- var handler = function(e){new RichFaces.Menu.DelayedContextMenu(this.id, e).show();}.bindAsEventListener(this);
- var binding = new RichFaces.Menu.Layer.Binding (parent, evt, handler);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (parent, offEvt, onmouseout);
- this.bindings.push(binding);
- binding.refresh();
- return this;
- },
- eventJsToPrototype: function(evtName){
- var indexof = evtName.indexOf('on');
- if(indexof >= 0){
- evtName = evtName.substr(indexof + 2);
- }
- return evtName;
- }
-
-};
-
-RichFaces.Menu.Layer.Binding = Class.create();
-RichFaces.Menu.Layer.Binding.prototype = {
- initialize:function(objectId, eventname, handler){
- this.objectId = objectId;
- this.eventname = eventname;
- this.handler = handler;
- },
- refresh:function(){
- /*LOG.a4j_debug("rebinding " + $H(this).inspect());*/
- var obj = $(this.objectId);
- if(obj){
- Event.stopObserving(obj, this.eventname, this.handler);
- Event.observe(obj, this.eventname, this.handler);
- return true;
- }
- return false;
- }
-};
-if(!RichFaces.Menu.Item) RichFaces.Menu.Item = {};
-
-/**
- *
- */
-RichFaces.Menu.Item.Onclick = function(evt, item, action, params, target) {
- var form = Event.findElement(evt, 'form');
-
- /*if(!form || typeof(form) == 'undefined' || !form.nodeName || form.nodeName.toLowerCase() != 'form'){
- form = document.createElement('form');
- form.setAttribute('method', 'post');
- form.setAttribute('enctype', 'application/x-www-form-urlencoded');
- form.action = action;
- document.body.appendChild(form);
- }*/
- var objectsCreated = new Array();
- var oldValues = new Object();
- RichFaces.Menu.Item._createOrInitHiddenInput(item + ":submit", item + ":submit", objectsCreated, oldValues, form);
-
- if (params) {
-
- for (var param in params) {
- var paramName = param;
- var paramValue = params[paramName];
- if (typeof(paramValue) != 'function') {
- if (paramValue) {
- paramValue = String(paramValue);
- }
- RichFaces.Menu.Item._createOrInitHiddenInput(paramName, paramValue, objectsCreated, oldValues, form);
-
- }
- }
- }
-
- var l = objectsCreated.length;
-
- for (var i = 0; i < l; i++) {
- var kid = objectsCreated[i];
- form.appendChild(kid);
- }
-
- var targ = form.target;
-
- if (target) {
- form.target = target;
- }
-
- form.submit();
-
- form.target = targ;
-
- for (var j = 0; j < l; j++) {
- var kid = objectsCreated[j];
- if (form && kid) {
- form.removeChild(kid);
- }
- }
-
- for (var key in oldValues) {
- var value = oldValues[key];
- if (typeof(value) != 'function') {
- ($(key) || form[key]).value = value;
- }
- }
- }
-
-RichFaces.Menu.Item._createOrInitHiddenInput = function(name, value, list, oldValues, form) {
- var hiddenObj = $(name) || form[name];
-
- if (!hiddenObj) {
- hiddenObj = document.createElement('input');
- hiddenObj.setAttribute('type', 'hidden');
- hiddenObj.setAttribute('name', name);
- hiddenObj.setAttribute('id', name);
- list.push(hiddenObj);
- } else {
- oldValues[name] = hiddenObj.value;
- }
- hiddenObj.value = value;
-}
-
18 years, 5 months
JBoss Rich Faces SVN: r4114 - in branches/3.1.x/framework/impl/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-20 11:31:12 -0500 (Tue, 20 Nov 2007)
New Revision: 4114
Modified:
branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
Log:
context menu moved to 3.1.x branch
Modified: branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-11-20 16:30:57 UTC (rev 4113)
+++ branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-11-20 16:31:12 UTC (rev 4114)
@@ -29,7 +29,7 @@
this.epilog = epilog;
}
- private List parseExpressiion(String expressionString) throws SAXException {
+ protected List parseExpressiion(String expressionString) throws SAXException {
try {
List result = new RichMacroDefinition(new StringReader(expressionString)).expression();
@@ -41,6 +41,12 @@
private void encodeExpressionString(String string) throws IOException,
SAXException {
+
+ if (string.length() == 0) {
+ outputWriter.write("\'\'");
+ return;
+ }
+
List parsedExpressiion = parseExpressiion(string);
boolean isExpression = false;
Modified: branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-11-20 16:30:57 UTC (rev 4113)
+++ branches/3.1.x/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-11-20 16:31:12 UTC (rev 4114)
@@ -7,6 +7,7 @@
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
+import java.io.Writer;
import java.util.Properties;
import javax.faces.component.UIComponent;
@@ -26,11 +27,11 @@
import org.ajax4jsf.webapp.tidy.TidyParser;
import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.component.TemplateComponent;
-import org.richfaces.json.JSContentHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.ContentHandler;
/**
* @author Nick Belaevski - mailto:nbelaevski@exadel.com
@@ -95,7 +96,7 @@
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- JSContentHandler contentHandler = new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
+ ContentHandler contentHandler = createContentHandler(writer);
Result result = new SAXResult(contentHandler);
for (int i = 0; i < bodyChildrenLength; i++) {
@@ -158,4 +159,9 @@
writer.write(";\n new Insertion.Top($('" + component.getClientId(context) + "'), evaluator.invoke('getContent', window).join(''));");
writer.endElement("script");
}
+
+
+ protected ContentHandler createContentHandler(Writer writer) {
+ return new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
+ }
}
Modified: branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-11-20 16:30:57 UTC (rev 4113)
+++ branches/3.1.x/framework/impl/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-11-20 16:31:12 UTC (rev 4114)
@@ -142,6 +142,19 @@
return value;
}
+Richfaces.interpolate = function (placeholders, context) {
+
+ for(var k in context) {
+ var v = context[k];
+ var regexp = new RegExp("\\{" + k + "\\}", "g");
+ placeholders = placeholders.replace(regexp, v);
+ }
+
+ return placeholders;
+
+};
+
+
Richfaces.getComponent = function(componentType, element)
{
var attribute="richfacesComponent";
18 years, 5 months
JBoss Rich Faces SVN: r4113 - in branches/3.1.x/ui/menu-components/src/main: config/resources and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-20 11:30:57 -0500 (Tue, 20 Nov 2007)
New Revision: 4113
Added:
branches/3.1.x/ui/menu-components/src/main/config/resources/
branches/3.1.x/ui/menu-components/src/main/config/resources/resources-config.xml
branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/background/MenuListBackground.java
branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss
branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/
branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Modified:
branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
Log:
context menu moved to 3.1.x branch
Added: branches/3.1.x/ui/menu-components/src/main/config/resources/resources-config.xml
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/config/resources/resources-config.xml (rev 0)
+++ branches/3.1.x/ui/menu-components/src/main/config/resources/resources-config.xml 2007-11-20 16:30:57 UTC (rev 4113)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource-config>
+<!-- Menu list background -->
+
+ <resource class="org.richfaces.renderkit.html.images.background.MenuListBackground">
+ <name>org.richfaces.renderkit.html.images.background.MenuListBackground</name>
+ </resource>
+</resource-config>
Added: branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java (rev 0)
+++ branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2007-11-20 16:30:57 UTC (rev 4113)
@@ -0,0 +1,211 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UIMenuGroup;
+import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.UIMenuSeparator;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class AbstractMenuRenderer extends HeaderResourcesRendererBase {
+
+ private final InternetResource[] scripts = {
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
+ getResource("scripts/menu.js") };
+
+
+ protected InternetResource[] getScripts() {
+ return scripts;
+ }
+
+ protected InternetResource[] getStyles() {
+ return super.getStyles();
+ }
+
+ public void encodeScript(FacesContext context, UIComponent component) throws IOException {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append(getLayerScript(context, component));
+
+ List children = component.getChildren();
+ for(Iterator it = children.iterator();it.hasNext();) {
+ buffer.append(getItemScript(context, (UIComponent) it.next()));
+ }
+
+ ResponseWriter out = context.getResponseWriter();
+ String script = buffer.append(";").toString();
+ out.write(script);
+ }
+
+ protected abstract String getLayerScript(FacesContext context, UIComponent layer);
+
+ protected String getItemScript(FacesContext context, UIComponent kid) {
+ String itemId = null;
+ int flcloseonclick = 1;
+ int flagGroup = 0;
+ if (kid instanceof UIMenuItem) {
+ UIMenuItem menuItem = (UIMenuItem) kid;
+ itemId = kid.getClientId(context);
+ if (menuItem.isDisabled()) {
+ flcloseonclick = 0;
+ }
+ } else if (kid instanceof UIMenuGroup) {
+ UIMenuGroup menuGroup = (UIMenuGroup) kid;
+ itemId = "ref" + kid.getClientId(context);
+ flcloseonclick = 0;
+ if (menuGroup.isDisabled()) {
+ flagGroup = 2;
+ } else {
+ flagGroup = 1;
+ }
+ }
+ if (itemId != null) {
+ JSFunction function = new JSFunction(".addItem");
+ function.addParameter(itemId);
+ function.addParameter(new Integer(flcloseonclick));
+
+ ScriptOptions options = new ScriptOptions(kid);
+ options.addEventHandler("onmouseout");
+ options.addEventHandler("onmouseover");
+ options.addOption("flagGroup", new Integer(flagGroup));
+ options.addOption("selectClass");
+ function.addParameter(options);
+ return function.toScript();
+ }
+ return "";
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ List flatListOfNodes = new LinkedList();
+ String width = (String) component.getAttributes().get("popupWidth");
+
+ flatten(component.getChildren(), flatListOfNodes);
+ processLayer(context, component, width);
+
+ for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
+ UIMenuGroup node = (UIMenuGroup) iter.next();
+ if (node.isRendered() && !node.isDisabled())
+ processLayer(context, node, width);
+ }
+ }
+
+ public void processLayer(FacesContext context, UIComponent layer, String width) throws IOException {
+ String clientId = layer.getClientId(context);
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("div", layer);
+ writer.writeAttribute("id", clientId+"_menu", null);
+ writer.writeAttribute("class", "dr-menu-list-border rich-menu-list-border", null);
+ writer.writeAttribute("style", "visibility: hidden; z-index: 2; ", null);
+ writer.startElement("div", layer);
+ writer.writeAttribute("class", "dr-menu-list-bg rich-menu-list-bg", null);
+ encodeItems(context, layer);
+
+ writer.startElement("div", layer);
+ writer.writeAttribute("class", "dr-menu-list-strut rich-menu-list-strut", null);
+
+ writer.startElement("img", layer);
+ writer.writeAttribute("width", "1", null);
+ writer.writeAttribute("height", "1", null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("border", "0", null);
+ writer.writeAttribute("style", width!=null && width.length() > 0 ? "width: " + HtmlUtil.qualifySize(width) : "", null);
+ writer.writeAttribute("src",
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null),
+ null);
+ writer.endElement("img");
+ writer.endElement("div");
+
+ writer.endElement("div");
+ writer.endElement("div");
+
+ writer.startElement("iframe", layer);
+ writer.writeAttribute("src",
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif")
+ .getUri(context, null), null);
+ writer.writeAttribute("id", clientId+"_menu_iframe", null);
+ writer.writeAttribute("class", "underneath_iframe", null);
+ writer.writeAttribute("style", "position:absolute; z-index: 1;", null);
+ writer.endElement("iframe");
+
+ writer.startElement("script", layer);
+ writer.writeAttribute("id", clientId+"_menu_script", null);
+ writer.writeAttribute("type", "text/javascript", null);
+ encodeScript(context, layer);
+ writer.endElement("script");
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
+ renderedAreas.add(clientId + "_menu_iframe");
+ renderedAreas.add(clientId + "_menu_script");
+ }
+
+ public void encodeItems(FacesContext context, UIComponent component) throws IOException {
+ List kids = component.getChildren();
+ Iterator it = kids.iterator();
+ while (it.hasNext()) {
+ UIComponent kid = (UIComponent)it.next();
+ if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
+ renderChild(context, kid);
+ }
+ }
+ }
+
+ private void flatten(List kids, List flatList){
+ if(kids != null){
+ for (Iterator iter = kids.iterator(); iter.hasNext();) {
+ UIComponent kid = (UIComponent) iter.next();
+ if (kid instanceof UIMenuGroup) {
+ UIMenuGroup node = (UIMenuGroup) kid;
+ flatList.add(node);
+ flatten(node.getChildren(), flatList);
+ }
+ }
+ }
+ }
+
+}
Copied: branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/background/MenuListBackground.java (from rev 4100, branches/3.1.x/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/images/background/MenuListBackground.java)
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/background/MenuListBackground.java (rev 0)
+++ branches/3.1.x/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/background/MenuListBackground.java 2007-11-20 16:30:57 UTC (rev 4113)
@@ -0,0 +1,32 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images.background;
+
+import org.richfaces.renderkit.html.BaseGradient;
+
+public class MenuListBackground extends BaseGradient {
+
+ public MenuListBackground() {
+ super(22, 3, "additionalBackgroundColor", "tabBackgroundColor", true);
+ }
+
+}
Added: branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss (rev 0)
+++ branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss 2007-11-20 16:30:57 UTC (rev 4113)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template xmlns:f='http:/jsf.exadel.com/template'
+ xmlns:u='http:/jsf.exadel.com/template/util'
+ xmlns="http://www.w3.org/1999/xhtml" >
+
+<f:verbatim><![CDATA[
+
+
+.dr-menu-list-border {
+ border : 1px solid;
+ float : left;
+ position : absolute;
+}
+.dr-menu-list-bg {
+ border-top-style : solid;
+ border-left-style : solid;
+ border-right-style : solid;
+
+ border-top-width : 1px;
+ border-left-width : 1px;
+ border-right-width : 1px;
+
+ background : repeat-y left;
+}
+.dr-menu-label {
+ left: 0px;
+ top: 0px;
+ padding : 2px 5px 2px 5px;
+ white-space : nowrap;
+ width : auto;
+ height : auto;
+}
+.dr-menu-label-unselect {
+ border : 0px solid transparent;
+ padding : 3px 6px;
+}
+.dr-menu-label-select {
+ border : 1px solid;
+ cursor : pointer;
+}
+
+.dr-menu-list-strut {
+ font-size : 0px;
+ border: 0px;
+ margin : 0px;
+ position: relative;
+}
+
+.underneath_iframe{
+ position: absolute;
+ z-index: 90;
+ visibility:hidden;
+ left:0px;
+ top:0px;
+ height:1px;
+ width:1px;
+}
+
+]]>
+
+</f:verbatim>
+
+<u:selector name=".dr-label-text-decor">
+ <u:style name="font-weight" skin="headerWeightFont" />
+</u:selector>
+
+<u:selector name=".dr-menu-list-border">
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="background-color" skin="additionalBackgroundColor" />
+</u:selector>
+
+<u:selector name=".dr-menu-list-bg">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.background.MenuListBackground"/>
+ </u:style>
+ <u:style name="border-top-color" skin="additionalBackgroundColor" />
+ <u:style name="border-left-color" skin="additionalBackgroundColor" />
+ <u:style name="border-right-color" skin="additionalBackgroundColor" />
+</u:selector>
+
+<u:selector name=".dr-menu-label">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+</u:selector>
+
+<u:selector name=".dr-menu-label-select">
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="background-color" skin="controlBackgroundColor" />
+ <u:style name="color" skin="generalTextColor" />
+</u:selector>
+
+</f:template>
Modified: branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2007-11-20 16:30:43 UTC (rev 4112)
+++ branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2007-11-20 16:30:57 UTC (rev 4113)
@@ -49,6 +49,56 @@
.dr-menu-item-disabled .dr-menu-node {
background-position : bottom;
}
+
+.dr-menu-list-border {
+ border : 1px solid;
+ float : left;
+ position : absolute;
+}
+.dr-menu-list-bg {
+ border-top-style : solid;
+ border-left-style : solid;
+ border-right-style : solid;
+
+ border-top-width : 1px;
+ border-left-width : 1px;
+ border-right-width : 1px;
+
+ background : repeat-y left;
+}
+.dr-menu-label {
+ left: 0px;
+ top: 0px;
+ padding : 2px 5px 2px 5px;
+ white-space : nowrap;
+ width : auto;
+ height : auto;
+}
+.dr-menu-label-unselect {
+ border : 0px solid transparent;
+ padding : 3px 6px;
+}
+.dr-menu-label-select {
+ border : 1px solid;
+ cursor : pointer;
+}
+
+.dr-menu-list-strut {
+ font-size : 0px;
+ border: 0px;
+ margin : 0px;
+ position: relative;
+}
+
+.underneath_iframe{
+ position: absolute;
+ z-index: 90;
+ visibility:hidden;
+ left:0px;
+ top:0px;
+ height:1px;
+ width:1px;
+}
]]>
</f:verbatim>
@@ -80,4 +130,33 @@
</u:style>
</u:selector>
+<u:selector name=".dr-label-text-decor">
+ <u:style name="font-weight" skin="headerWeightFont" />
+</u:selector>
+
+<u:selector name=".dr-menu-list-border">
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="background-color" skin="additionalBackgroundColor" />
+</u:selector>
+
+<u:selector name=".dr-menu-list-bg">
+ <u:style name="background-image">
+ <f:resource f:key="org.richfaces.renderkit.html.images.background.MenuListBackground"/>
+ </u:style>
+ <u:style name="border-top-color" skin="additionalBackgroundColor" />
+ <u:style name="border-left-color" skin="additionalBackgroundColor" />
+ <u:style name="border-right-color" skin="additionalBackgroundColor" />
+</u:selector>
+
+<u:selector name=".dr-menu-label">
+ <u:style name="font-family" skin="generalFamilyFont" />
+ <u:style name="font-size" skin="generalSizeFont" />
+</u:selector>
+
+<u:selector name=".dr-menu-label-select">
+ <u:style name="border-color" skin="panelBorderColor" />
+ <u:style name="background-color" skin="controlBackgroundColor" />
+ <u:style name="color" skin="generalTextColor" />
+</u:selector>
+
</f:template>
Copied: branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js (from rev 4100, branches/3.1.x/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js)
===================================================================
--- branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js (rev 0)
+++ branches/3.1.x/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-11-20 16:30:57 UTC (rev 4113)
@@ -0,0 +1,1210 @@
+
+if(!window.RichFaces) window.RichFaces = {};
+if(!RichFaces.Menu) RichFaces.Menu = {};
+
+/**
+ * Fixes IE bug with incorrect layer width when set to auto
+ * @param layer
+ */
+RichFaces.Menu.fitLayerToContent = function(layer) {
+ if (!RichFaces.Menu.Layers.IE)
+ return;
+
+ var table = layer.childNodes[0];
+ if (table) {
+ if (layer.style.width.indexOf("px")!=-1) {
+ var width = parseFloat(layer.style.width.substring(0,layer.style.width.indexOf('px')));
+ var tmpDims = Element.getDimensions(table);
+ if (tmpDims.width > width) layer.style.width = tmpDims.width + "px";
+ }
+ //layer.style.height = dims.height + "px";
+ } // if
+}
+
+RichFaces.Menu.removePx = function(e) {
+ if ((e+"").indexOf("px")!=-1)
+ return (e+"").substring(0,e.length-2);
+ else
+ return e;
+}
+
+
+RichFaces.Menu.Layers = {
+ listl: new Array(),
+ father: {},
+ lwidthDetected:false,
+ lwidth:{},
+ back: new Array(),
+ horizontals: {},
+ layers: {},
+ levels: ['','','','','','','','','','',''],
+ detectWidth: function(){
+ this.IE = (navigator.userAgent.indexOf('MSIE') > -1) && (navigator.userAgent.indexOf('Opera') < 0);
+ this.NS = (navigator.userAgent.indexOf('Netscape') > -1);
+ }
+ ,
+
+ menuTopShift : -11,
+ menuRightShift : 11,
+ menuLeftShift : 0,
+ shadowWidth: 0,
+ thresholdY : 0,
+ abscissaStep : 180,
+
+ CornerRadius: 0,
+
+ toBeHidden : new Array(),
+ toBeHiddenLeft : new Array(),
+ toBeHiddenTop : new Array(),
+
+ layersMoved : 0,
+ layerPoppedUp : '',
+ layerTop : new Array(),
+ layerLeft : new Array(),
+ timeoutFlag : 0,
+ useTimeouts : 1,
+ timeoutLength : 500,
+ showTimeOutFlag : 0,
+ showTimeoutLength: 0,
+ queuedId : '',
+
+ LMPopUp:function(menuName, isCurrent) {
+ if (!this.loaded || ( this.isVisible(menuName) && !isCurrent)) {
+ return;
+ }
+ if (menuName == this.father[this.layerPoppedUp]) {
+ this.LMPopUpL(this.layerPoppedUp, false);
+ } else if (this.father[menuName] == this.layerPoppedUp) {
+ this.LMPopUpL(menuName, true);
+ } else {
+ //this.shutdown();
+ foobar = menuName;
+ do {
+ this.LMPopUpL(foobar, true);
+ foobar = this.father[foobar];
+ } while (foobar);
+ }
+ this.layerPoppedUp = menuName;
+ },
+
+ isVisible: function(layer) {
+ return ($(layer).style.visibility == 'visible');
+ },
+
+ /**
+ * @param menuName
+ * @param visibleFlag
+ */
+ LMPopUpL: function(menuName, visibleFlag) {
+ if (!this.loaded) {
+ return;
+ }
+ this.detectWidth();
+ var menu = $(menuName);
+ RichFaces.Menu.fitLayerToContent(menu);
+ var visible = this.isVisible(menuName);
+ this.setVisibility(menuName, visibleFlag);
+ this.ieSelectWorkAround(menuName, visibleFlag);
+ if (visible && !visibleFlag) {
+ var menuLayer = this.layers[menu.id];
+ if (menuLayer && menuLayer.eventOnClose) menuLayer.eventOnClose();
+ if (menuLayer && menuLayer.eventOnCollapse) menuLayer.eventOnCollapse();
+ if (menuLayer.refItem) menuLayer.refItem.highLightGroup(false);
+ } else if (!visible && visibleFlag) {
+ var menuLayer = this.layers[menu.id];
+ if (menuLayer && menuLayer.eventOnOpen) menuLayer.eventOnOpen();
+ if (menuLayer && menuLayer.eventOnExpand) menuLayer.eventOnExpand();
+
+ if (menuLayer.level>0) {
+ do {
+ menuLayer = this.layers[(this.father[menuLayer.id])];
+ } while (menuLayer.level > 0)
+ if (menuLayer && menuLayer.eventOnGroupActivate) menuLayer.eventOnGroupActivate();
+ }
+ }
+ },
+
+ ieSelectWorkAround: function(menuName, on){
+ //alert(navigator.userAgent);
+ if(this.IE || this.NS) {
+ menuName = $(menuName).id;
+ var menu = $(menuName);
+ var iframe = $(menuName + "_iframe");
+ var nsfix = (this.NS ? 7 : 0);
+ if(on){
+ var dim = Element.getDimensions(menu);
+ iframe.style.top = menu.style.top;
+ iframe.style.left = menu.style.left;
+ iframe.style.width = menu.offsetWidth + "px"
+ iframe.style.height = menu.offsetHeight + "px"
+ iframe.style.visibility = "visible";
+ } else {
+ iframe.style.visibility = "hidden";
+ }
+ }
+ },
+
+ shutdown: function () {
+ var needToResetLayers = false;
+ for (var i=0; i<this.listl.length; i++) {
+ var layerId = this.listl[i];
+ if ($(layerId)) {
+ this.LMPopUpL(layerId, false);
+ } else {
+ needToResetLayers = true;
+ }
+ }
+
+ if (needToResetLayers) {
+ this.resetLayers();
+ }
+
+ this.layerPoppedUp = '';
+ if (this.Konqueror || this.IE5) {
+ this.seeThroughElements(true);
+ }
+ },
+ resetLayers: function() {
+ var newList = new Array();
+ for (i=0; i<this.listl.length; i++) {
+ var layer = this.listl[i];
+ if ($(layer)) {
+ newList.push(layer);
+ }
+ }
+
+ this.listl = newList;
+ }
+ ,
+
+ /**
+ * Set visibility
+ * @param layer the layer to visibility
+ * @param visible the boolean flag, if true to set visible layer from variable, otherwise - hide this layer
+ */
+ setVisibility: function (layer, visible) {
+ var tmpLayer = $(layer);
+
+ if (visible) {
+ tmpLayer.style.visibility = 'visible';
+ } else {
+ if(tmpLayer.getElementsByTagName){
+ var inputs = tmpLayer.getElementsByTagName('INPUT');
+ if(inputs){
+ $A(inputs).each(function(node){node.blur()});
+ } // if
+ } // if
+
+ tmpLayer.style.visibility = 'hidden';
+// tmpLayer.style.left = "-"+tmpLayer.clientWidth;
+// Element.hide(tmpLayer);
+ } // else
+ },
+
+
+ clearLMTO: function () {
+ if (this.useTimeouts) {
+ clearTimeout(this.timeoutFlag);
+ }
+ },
+
+ setLMTO: function (ratio) {
+ if(!ratio){
+ ratio = this.timeoutLength;
+ }
+ if (this.useTimeouts) {
+ clearTimeout(this.timeoutFlag);
+ this.timeoutFlag = setTimeout('RichFaces.Menu.Layers.shutdown()', ratio);
+ }
+ },
+
+ loaded:1,
+
+ clearPopUpTO: function(){
+ clearTimeout(this.showTimeOutFlag);
+ },
+ showMenuLayer: function (layerId, e, delay){
+ this.clearPopUpTO();
+ this.showTimeOutFlag = setTimeout(new RichFaces.Menu.DelayedPopUp(layerId, e, function(){this.layerId = null;}.bind(this)).show, delay);
+ this.layerId = layerId;
+ },
+ showDropDownLayer: function (layerId, parentId, e, delay){
+ this.clearPopUpTO();
+ this.showTimeOutFlag = setTimeout(new RichFaces.Menu.DelayedDropDown(layerId, parentId, e).show, delay);
+ },
+ showPopUpLayer: function (layer, e){
+ this.shutdown();
+ this.detectWidth();
+ this.LMPopUp(menuName, false);
+ this.setLMTO(4);
+ }
+};
+
+/**
+ * return true if defined document element or document body, otherwise return false
+ */
+RichFaces.Menu.getWindowElement = function() {
+ return (document.documentElement || document.body);
+}
+
+RichFaces.Menu.getWindowDimensions = function() {
+ var x,y;
+ if (self.innerHeight) // all except Explorer
+ {
+ x = self.innerWidth;
+ y = self.innerHeight;
+ }
+ else if (document.documentElement && document.documentElement.clientHeight)
+ // Explorer 6 Strict Mode
+ {
+ x = document.documentElement.clientWidth;
+ y = document.documentElement.clientHeight;
+ }
+ else if (document.body) // other Explorers
+ {
+ x = document.body.clientWidth;
+ y = document.body.clientHeight;
+ }
+ return {width:x, height:y};
+}
+
+RichFaces.Menu.getWindowScrollOffset = function() {
+ var x,y;
+ if (typeof pageYOffset != "undefined") // all except Explorer
+ {
+ x = window.pageXOffset;
+ y = window.pageYOffset;
+ }
+ else if (document.documentElement && document.documentElement.scrollTop)
+ // Explorer 6 Strict
+ {
+ x = document.documentElement.scrollLeft;
+ y = document.documentElement.scrollTop;
+ }
+ else if (document.body) // all other Explorers
+ {
+ x = document.body.scrollLeft;
+ y = document.body.scrollTop;
+ }
+
+ return {top:y, left: x};
+}
+
+RichFaces.Menu.getPageDimensions = function() {
+ var x,y;
+ var test1 = document.body.scrollHeight;
+ var test2 = document.body.offsetHeight;
+ if (test1 > test2) {
+ // all but Explorer Mac
+ x = document.body.scrollWidth;
+ y = document.body.scrollHeight;
+ }
+ else {
+ // Explorer Mac;
+ // would also work in Explorer 6 Strict, Mozilla and Safari
+
+ x = document.body.offsetWidth;
+ y = document.body.offsetHeight;
+ }
+
+ return {width:x, height:y};
+}
+
+
+RichFaces.Menu.DelayedContextMenu = function(layer, e) {
+ if (!e) {
+ e = window.event;
+ }
+ Event.stop(e);
+ this.event = e;
+ this.element = Event.element(e);
+ this.layer = $(layer);
+ this.show = function() {
+ RichFaces.Menu.Layers.shutdown();
+ var body = RichFaces.Menu.getPageDimensions();
+ var win = RichFaces.Menu.getWindowDimensions();
+ var bodyHeight = body.height;
+ var bodyWidth = body.width;
+ var clientX = this.event.clientX;
+ var clientY = this.event.clientY;
+
+ var top = Event.pointerY(this.event);
+ var left = Event.pointerX(this.event);
+ var layerdim = Element.getDimensions(this.layer);
+ var layerLeft = left;
+
+ if (clientX + layerdim.width > win.width) {
+ layerLeft -= (layerdim.width - RichFaces.Menu.Layers.shadowWidth - RichFaces.Menu.Layers.CornerRadius);
+ }
+
+ if (layerLeft < 0) {
+ layerLeft = 0;
+ }
+
+ /*
+ if (layerLeft + layerdim.width > bodyWidth) {
+ layerLeft = bodyWidth - layerdim.width;
+ }
+
+ if (layerLeft < 0) {
+ layerLeft = 0;
+ }
+ */
+ var layerTop = top;
+ /*if (layertop + layerdim.height > bodyHeight) {
+ layertop = bodyHeight - layerdim.height;
+ }
+
+ if (layertop < 0) {
+ layertop = 0;
+ }
+ */
+ if (clientY + layerdim.height > win.height) {
+ layerTop -= (layerdim.height - RichFaces.Menu.Layers.shadowWidth - RichFaces.Menu.Layers.CornerRadius);
+ }
+
+ if (layerTop < 0) {
+ layerTop = 0;
+ }
+
+ this.layer.style.left = layerLeft + "px";
+ this.layer.style.top = layerTop + "px";
+
+ RichFaces.Menu.Layers.LMPopUp(this.layer.id, false);
+ RichFaces.Menu.Layers.clearLMTO();
+ }.bind(this);
+}
+
+
+/**
+ * Calculates for DROPDOWN
+ */
+RichFaces.Menu.DelayedDropDown = function(layer, elementId, e) {
+ if (!e) {
+ e = window.event;
+ }
+
+ this.event = e;
+ this.element = $(elementId) || Event.element(e);
+ this.layer = $(layer);
+ Event.stop(e);
+
+ this.listPositions = function(jp, dir) {
+ var poss = new Array(new Array(2,1,4),new Array(1,2,3),new Array(4,3,2),new Array(3,4,1));
+ var list = new Array();
+ if (jp>0 && dir>0) {
+ list.push({jointPoint: jp, direction: dir });
+ } else if (jp>0 && dir==0) {
+ for(var i=0;i<3;i++) {
+ list.push({jointPoint: jp, direction: poss[jp-1][i] });
+ }
+ } else if (jp==0 && dir>0) {
+ for(var i=0;i<3;i++) {
+ list.push({jointPoint: poss[dir-1][i], direction: dir });
+ }
+ } else if (jp==0 && dir==0) {
+ list.push({jointPoint: 4, direction: 3 });
+ list.push({jointPoint: 1, direction: 2 });
+ list.push({jointPoint: 3, direction: 4 });
+ list.push({jointPoint: 2, direction: 1 });
+ }
+ return list;
+ }.bind(this);
+
+ this.calcPosition = function(jp, dir) {
+ var layerLeft;
+ var layerTop;
+ switch (jp) {
+ case 1:
+ layerLeft = this.left;
+ layerTop = this.top;
+ break;
+ case 2:
+ layerLeft = this.right;
+ layerTop = this.top;
+ break;
+ case 3:
+ layerLeft = this.right;
+ layerTop = this.bottom;
+ break;
+ case 4:
+ layerLeft = this.left;
+ layerTop = this.bottom;
+ break;
+ }
+ switch (dir) {
+ case 1:
+ layerLeft -= this.layerdim.width;
+ layerTop -= this.layerdim.height;
+ break;
+ case 2:
+ layerTop -= this.layerdim.height;
+ break;
+ case 4:
+ layerLeft -= this.layerdim.width;
+ }
+ return {left: layerLeft, top: layerTop};
+ }.bind(this);
+
+ this.show = function() {
+ RichFaces.Menu.Layers.shutdown();
+
+ var winOffset = RichFaces.Menu.getWindowScrollOffset();
+ var win = RichFaces.Menu.getWindowDimensions();
+ var pageDims = RichFaces.Menu.getPageDimensions();
+
+
+ var windowHeight = win.height;
+ var windowWidth = win.width;
+
+// var screenOffset = Position.cumulativeOffset(this.element);
+// if (Element.getStyle(this.element, 'position') == 'absolute') {
+// screenOffset[0] = 0;
+// screenOffset[1] = 0;
+// }
+ var screenOffset = Position.positionedOffset(this.element);
+ var innerDiv = this.element.lastChild;
+ var dim = Element.getDimensions(this.element);
+
+ var parOffset = Position.cumulativeOffset(this.element);
+ var divOffset = Position.cumulativeOffset(innerDiv);
+ var deltaX = divOffset[0] - parOffset[0];
+ var deltaY = divOffset[1] - parOffset[1];
+
+ // parent element
+ this.top = screenOffset[1];
+ this.left = screenOffset[0];
+
+ this.bottom = this.top + dim.height;
+ this.right = this.left + dim.width;
+
+ this.layerdim = Element.getDimensions(this.layer);
+
+ var options = RichFaces.Menu.Layers.layers[this.layer.id].options;
+
+ var jointPoint = 0;
+ if (options.jointPoint) {
+ var sJp = options.jointPoint.toUpperCase();
+ jointPoint = sJp.indexOf('TL') != -1?1:jointPoint;
+ jointPoint = sJp.indexOf('TR') != -1?2:jointPoint;
+ jointPoint = sJp.indexOf('BR') != -1?3:jointPoint;
+ jointPoint = sJp.indexOf('BL') != -1?4:jointPoint;
+ }
+
+ var direction = 0;
+ if (options.direction) {
+ var sDir = options.direction.toUpperCase();
+ direction = sDir.indexOf('TOP-LEFT') != -1?1:direction;
+ direction = sDir.indexOf('TOP-RIGHT') != -1?2:direction;
+ direction = sDir.indexOf('BOTTOM-RIGHT')!= -1?3:direction;
+ direction = sDir.indexOf('BOTTOM-LEFT') != -1?4:direction;
+ }
+ var hOffset = options.horizontalOffset;
+ var vOffset = options.verticalOffset;
+
+ var listPos = this.listPositions(jointPoint, direction);
+ var layerPos;
+ var foundPos = false;
+ for (var i=0;i<listPos.length;i++) {
+ layerPos = this.calcPosition(listPos[i].jointPoint, listPos[i].direction)
+ if ((layerPos.left + hOffset >= winOffset.left) &&
+ (layerPos.left + hOffset + this.layerdim.width - winOffset.left <= windowWidth) &&
+ (layerPos.top + vOffset >= winOffset.top) &&
+ (layerPos.top + vOffset + this.layerdim.height - winOffset.top <= windowHeight)) {
+ foundPos = true;
+ break;
+ }
+ }
+ if (!foundPos) {
+ layerPos = this.calcPosition(listPos[0].jointPoint, listPos[0].direction)
+ }
+ this.layer.style.left = layerPos.left + hOffset - deltaX - this.left + "px";
+ this.layer.style.top = layerPos.top + vOffset - deltaY - this.top + "px";
+
+ this.layer.style.width = this.layer.clientWidth + "px";
+
+ RichFaces.Menu.Layers.LMPopUp(this.layer.id, false);
+ RichFaces.Menu.Layers.clearLMTO();
+ }.bind(this);
+}
+
+RichFaces.Menu.DelayedPopUp = function(layer, e) {
+ if (!e) {
+ e = window.event;
+ }
+
+ this.event = e;
+ this.element = Event.findElement(e, 'div');
+ if (this.element.id.indexOf(":folder") == (this.element.id.length -7) ) {
+ this.element = this.element.parentNode;
+ }
+ this.layer = $(layer);
+
+ this.show = function() {
+ if (!RichFaces.Menu.Layers.isVisible(this.layer) &&
+ RichFaces.Menu.Layers.isVisible(RichFaces.Menu.Layers.father[this.layer.id])) {
+ this.reposition();
+ RichFaces.Menu.Layers.LMPopUp(this.layer, false);
+ }
+ }.bind(this);
+}
+
+RichFaces.Menu.DelayedPopUp.prototype.reposition = function() {
+ var windowShift = RichFaces.Menu.getWindowScrollOffset();
+ var body = RichFaces.Menu.getWindowDimensions();
+ var windowHeight = body.height;
+ var windowWidth = body.width;
+ var scrolls = {top:0, left:0};
+ var screenOffset = Position.positionedOffset(this.element);
+ var leftPx = RichFaces.Menu.removePx(this.element.parentNode.parentNode.style.left);
+ var topPx = RichFaces.Menu.removePx(this.element.parentNode.parentNode.style.top);
+ screenOffset[0]+=Number(leftPx);
+ screenOffset[1]+=Number(topPx);
+ var cumulativeOffset = Position.cumulativeOffset(this.element);
+ var labelOffset = [cumulativeOffset[0] - screenOffset[0], cumulativeOffset[1] - screenOffset[1]];
+ var dim = Element.getDimensions(this.element);
+ var top = screenOffset[1] + scrolls.top;
+ var bottom = top + dim.height;
+ var left = screenOffset[0] + scrolls.left;
+ var right = left + dim.width;
+ var layerdim = Element.getDimensions(this.layer);
+
+ var options = RichFaces.Menu.Layers.layers[this.layer.id].options;
+ var dir = 0;
+ var vDir = 0;
+ if (options.direction) {
+ strDirection = options.direction.toUpperCase();
+ dir = strDirection.indexOf('LEFT')!=-1?1:dir;
+ dir = strDirection.indexOf('RIGHT')!=-1?2:dir;
+ if (dir>0) {
+ if (strDirection.indexOf('LEFT-UP')!=-1 ||
+ strDirection.indexOf('RIGHT-UP')!=-1) vDir = 1;
+ if (strDirection.indexOf('LEFT-DOWN')!=-1 ||
+ strDirection.indexOf('RIGHT-DOWN')!=-1) vDir = 2;
+ }
+ }
+
+ var layerLeft = right;
+ var layerTop = top - this.layer.firstChild.firstChild.offsetTop;
+
+ if (dir == 0) {
+ if (layerLeft + layerdim.width + labelOffset[0] - windowShift.left >= windowWidth) {
+ var invisibleRight = layerLeft + layerdim.width + labelOffset[0] - windowShift.left - windowWidth;
+ layerLeft = left - layerdim.width;
+ }
+
+ if (layerLeft + labelOffset[0] < 0) {
+ if (Math.abs(layerLeft + labelOffset[0]) > invisibleRight) {
+ layerLeft = right;
+ }
+ }
+
+ } else if (dir == 1) {
+ layerLeft = left - layerdim.width;
+ }
+
+ if (vDir != 2) {
+ if (layerTop + layerdim.height + labelOffset[1] - windowShift.top >= windowHeight
+ || vDir == 1) {
+ var invisibleBottom = layerTop + layerdim.height + labelOffset[1] - windowShift.top - windowHeight;
+ var items = this.layer.firstChild.childNodes;
+ if (items.length > 1) {
+ var lastItem = items[items.length-2];
+ // var layerOffset = Position.cumulativeOffset(this.layer);
+ var itemOffset = Position.positionedOffset(lastItem);
+ // layerTop = top -(itemOffset[1]-layerOffset[1]);
+ layerTop = top - itemOffset[1];
+ if (vDir == 0) {
+ if (layerTop < 0) {
+ if (Math.abs(layerTop) > invisibleBottom) layerTop = top;
+ }
+ }
+ }
+ }
+ }
+
+/* if (layerLeft + layerdim.width >= windowWidth) {
+ layerLeft = left - layerdim.width + RichFaces.Menu.Layers.shadowWidth;
+ }
+
+ if (layerLeft < 0) {
+ layerLeft = 0;
+ }
+
+ // search offsetTop (ch-1351)
+ var layerOffset = Position.cumulativeOffset(this.layer);
+ var items = document.getElementsByClassName("exadel_menuItem",this.layer);
+ var nodes = document.getElementsByClassName("exadel_menuNode",this.layer);
+ var firstItem = (items.length>0) ? items[0] : ((nodes.length>0) ? nodes[0] : null);
+ if (firstItem) {
+ if (nodes.length>0 && firstItem.offsetTop>nodes[0].offsetTop) firstItem = nodes[0];
+ var itemOffset = Position.cumulativeOffset(firstItem);
+ layertop = top -(itemOffset[1]-layerOffset[1]);
+ if (layertop + layerdim.height >= windowHeight) {
+ var lastItem = (items.length>0) ? items[items.length-1] : nodes[nodes.length-1];
+ if (nodes.length>0 && lastItem.offsetTop<nodes[nodes.length-1].offsetTop) lastItem = nodes[nodes.length-1];
+ itemOffset = Position.cumulativeOffset(lastItem);
+ layertop = top -(itemOffset[1]-layerOffset[1]);
+ }
+ } else layertop = top - RichFaces.Menu.Layers.CornerRadius;
+
+ if (layertop < 0) {
+ layertop = 0;
+ } */
+
+ this.layer.style.left = layerLeft + "px";
+ this.layer.style.top = layerTop + "px";
+
+ this.layer.style.width = this.layer.clientWidth + "px";
+
+}
+/**
+ * set to true when a dropdown box inside menu receives focus
+ */
+RichFaces.Menu.selectOpen = false;
+RichFaces.Menu.MouseIn = false;
+
+
+RichFaces.Menu.Layer = Class.create();
+RichFaces.Menu.Layer.prototype = {
+ initialize: function(id,delay, hideDelay){
+ RichFaces.Menu.Layers.listl.push(id);
+ this.id = id;
+ this.layer = $(id);
+ this.level = 0;
+ this.delay = delay;
+ if (hideDelay){
+ this.hideDelay=hideDelay;
+ }
+ else{
+ this.hideDelay=hideDelay;
+ }
+ RichFaces.Menu.fitLayerToContent(this.layer);
+ this.items = new Array();
+ RichFaces.Menu.Layers.layers[id] = this;
+ this.bindings = new Array();
+
+ //Usually set on DD menu to true
+ this.highlightParent = true;
+
+
+ this.mouseover =
+ function(e){
+ RichFaces.Menu.MouseIn=true;
+ RichFaces.Menu.Layers.clearLMTO();
+ if (this.highlightParent) {
+ var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
+ menuNode.className='dr-menu-label dr-menu-label-select rich-ddmenu-label rich-ddmenu-label-select';
+ }
+
+ Event.stop(e);
+ }.bindAsEventListener(this);
+
+ this.mouseout =
+ function(e){
+ RichFaces.Menu.MouseIn = false;
+ if (!RichFaces.Menu.selectOpen) {
+ RichFaces.Menu.Layers.setLMTO(this.hideDelay);
+ }
+ if (this.highlightParent) {
+ var menuNode = RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
+ menuNode.className='dr-menu-label dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect';
+ }
+ Event.stop(e);
+ }.bindAsEventListener(this);
+
+
+
+ var binding = new RichFaces.Menu.Layer.Binding (
+ this.id,
+ "mouseover",
+ this.mouseover);
+
+ this.bindings.push(binding);
+ binding.refresh();
+ binding = new RichFaces.Menu.Layer.Binding (
+ this.id,
+ "mouseout",
+ this.mouseout);
+ this.bindings.push(binding);
+ binding.refresh();
+
+ arrayinp=$A(this.layer.getElementsByTagName("select"));
+ for(i=0; i<arrayinp.length; i++){
+ var openSelectb = this.openSelect.bindAsEventListener(this);
+ var closeSelectb = this.closeSelect.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "focus", openSelectb);
+ Event.observe(arrayinp[i], "blur", closeSelectb);
+ //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
+ var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
+ //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
+ var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
+ Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
+
+ //var OnKeyPressb = RichFaces.Menu.Layer.OnKeyPress.bindAsEventListener(this);
+ var OnKeyPressb = this.OnKeyPress.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "keypress", OnKeyPressb);
+ }
+
+ arrayinp=$A(this.layer.getElementsByTagName("input"));
+ for(i=0; i<arrayinp.length; i++){
+ var openSelectb = this.openSelect.bindAsEventListener(this);
+ var closeSelectb = this.closeSelect.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "focus", openSelectb);
+ Event.observe(arrayinp[i], "blur", closeSelectb);
+ //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
+ var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
+ //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
+ var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
+ Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
+ var OnKeyPressb = this.OnKeyPress.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "keypress", OnKeyPressb);
+ }
+
+ arrayinp=$A(this.layer.getElementsByTagName("textarea"));
+ for(i=0; i<arrayinp.length; i++){
+ var openSelectb = this.openSelect.bindAsEventListener(this);
+ var closeSelectb = this.closeSelect.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "focus", openSelectb);
+ Event.observe(arrayinp[i], "blur", closeSelectb);
+ //var MouseoverInInputb = RichFaces.Menu.Layer.MouseoverInInput.bindAsEventListener(this);
+ var MouseoverInInputb = this.MouseoverInInput.bindAsEventListener(this);
+ //var MouseoutInInputb = RichFaces.Menu.Layer.MouseoutInInput.bindAsEventListener(this);
+ var MouseoutInInputb = this.MouseoutInInput.bindAsEventListener(this);
+ Event.observe(arrayinp[i], "mouseover", MouseoverInInputb);
+ Event.observe(arrayinp[i], "mouseout", MouseoutInInputb);
+ }
+
+/* if(window.A4J && A4J.AJAX ){
+ var listener = new A4J.AJAX.Listener(this.rebind.bindAsEventListener(this));
+ A4J.AJAX.AddListener(listener);
+ } */
+ },
+
+
+
+ openSelect: function(event){
+ RichFaces.Menu.selectOpen = true;
+ var ClickInputb = this.ClickInput.bindAsEventListener(this);
+ Event.observe(Event.element(event), "click", this.ClickInput);
+
+ },
+
+
+ closeSelect: function(event){
+ RichFaces.Menu.selectOpen = false;
+ var ClickInputb = this.ClickInput.bindAsEventListener(this);
+ Event.stopObserving(Event.element(event), "click", this.ClickInput);
+ if (RichFaces.Menu.MouseIn == false){
+ RichFaces.Menu.Layers.setLMTO(this.hideDelay);
+ }
+ },
+
+
+
+ OnKeyPress: function(event){
+
+ if(event.keyCode==13){
+ RichFaces.Menu.Layers.setLMTO(this.hideDelay);
+ }
+ },
+
+
+ MouseoverInInput: function(event){
+ //alert("event rabotaet "+ event.target);
+ var ClickInputb = this.ClickInput.bindAsEventListener(this);
+ Event.observe(Event.element(event), "click", this.ClickInput);
+ },
+
+
+ ClickInput: function(event){
+ //alert("event rabotaet dsds ");
+ Event.stop(event || window.event);
+ return false;
+ },
+
+
+ MouseoutInInput: function(event){
+ var ClickInputb = this.ClickInput.bindAsEventListener(this);
+ Event.stopObserving(Event.element(event), "click", this.ClickInput);
+
+ },
+
+ rebind:function(){
+ $A(this.bindings)
+ .each(
+ function(binding){
+ binding.refresh();
+ }
+ );
+ },
+ showMe: function(e){
+ this.closeSiblings(e);
+ //LOG.a4j_debug('show me ' + this.id +' ' +this.level);
+ RichFaces.Menu.Layers.showMenuLayer(this.id, e, this.delay);
+ RichFaces.Menu.Layers.levels[this.level] = this;
+// if (this.eventOnOpen) this.eventOnOpen();
+ },
+ closeSiblings: function(e){
+ //LOG.a4j_debug('closeASiblins ' + this.id +' ' +this.level);
+ if(RichFaces.Menu.Layers.levels[this.level] && RichFaces.Menu.Layers.levels[this.level].id != this.id){
+ for(var i = this.level; i < RichFaces.Menu.Layers.levels.length; i++){
+ if(RichFaces.Menu.Layers.levels[i]) {
+ RichFaces.Menu.Layers.levels[i].hideMe();
+ //RichFaces.Menu.Layers.levels[i] = '';
+ }
+ }
+ }
+ },
+ closeMinors: function(id){
+ //LOG.a4j_debug('closeMinors ' + this.id +' ' +this.level);
+ var item = this.items[id];
+// if(!item.childMenu){
+ //LOG.a4j_debug('hiding menus ' + this.id +' ' +this.level);
+ for(var i = this.level + (!item.childMenu?1:2); i < RichFaces.Menu.Layers.levels.length; i++){
+ if(RichFaces.Menu.Layers.levels[i]) {
+ //LOG.a4j_debug('hide ' +RichFaces.Menu.Layers.levels[i]);
+ RichFaces.Menu.Layers.levels[i].hideMe();
+ }
+ }
+// }
+ if (item.menu.refItem) {
+ item.menu.refItem.highLightGroup(true);
+ }
+
+ },
+ //addItem: function(itemId, hoverClass, plainClass, hoverStyle, plainStyle){
+ addItem: function(itemId, flag_close_onclick, options) {
+ var dis = this;
+ var item = {
+ highLightGroup: function(light) {
+ if (light) {
+ Element.removeClassName(this.id,"dr-menu-item-enabled");
+ Element.addClassName(this.id,"dr-menu-item-hover");
+ Element.addClassName(this.id,"rich-menu-group-hover");
+ if (this.options.selectClass) Element.addClassName(this.id, this.options.selectClass);
+
+ Element.addClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.addClassName(this.id+":anchor","rich-menu-item-label");
+ } else if (!this.mouseOver) {
+ Element.removeClassName(this.id,"dr-menu-item-hover");
+ Element.removeClassName(this.id,"rich-menu-group-hover");
+ Element.addClassName(this.id,"dr-menu-item-enabled");
+ if (this.options.selectClass) Element.removeClassName(this.id, this.options.selectClass);
+
+ Element.removeClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.removeClassName(this.id+":anchor","rich-menu-item-label");
+ }
+ }
+ };
+ item.id = itemId;
+ item.obj = $(itemId);
+ item.menu = this;
+ item.options = options || {};
+ item.mouseOver = false;
+ if (item.options.onmouseover && item.options.onmouseover != ""){
+ item.eventOnMouseOver = new Function("event",item.options.onmouseover).bindAsEventListener(item);
+ }
+ if (item.options.onmouseout && item.options.onmouseout != ""){
+ item.eventOnMouseOut = new Function("event",item.options.onmouseout).bindAsEventListener(item);
+ }
+ this.items[itemId] = item;
+
+ var onmouseover =
+ function(e){
+ this.menu.closeMinors(this.id);
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = true;
+ this.highLightGroup(true);
+ }
+ if (this.eventOnMouseOver) {
+ var reltg = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
+ while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
+ reltg = reltg.parentNode;
+ if (reltg == this.obj) return;
+ this.eventOnMouseOver();
+ }
+ }.bindAsEventListener(item);
+
+ var onmouseout =
+ function(e){
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = false;
+ this.highLightGroup(false);
+ }
+ if (this.eventOnMouseOut) {
+ var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
+ while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
+ reltg = reltg.parentNode;
+ if (reltg == this.obj) return;
+ this.eventOnMouseOut();
+ }
+ }.bindAsEventListener(item);
+
+ var onmouseclick =
+ function(e){
+ var menuLayer = item.menu;
+ while (menuLayer.level > 0) {
+ menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
+ }
+ if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
+ RichFaces.Menu.Layers.shutdown();
+ }.bindAsEventListener(item);
+
+ var binding = new RichFaces.Menu.Layer.Binding (
+ item.id,
+ "mouseover",
+ onmouseover);
+ this.bindings.push(binding);
+ binding.refresh();
+ binding = new RichFaces.Menu.Layer.Binding (
+ item.id,
+ "mouseout",
+ onmouseout);
+ this.bindings.push(binding);
+ binding.refresh();
+ if (flag_close_onclick==1){
+ binding = new RichFaces.Menu.Layer.Binding (
+ item.id,
+ "click",
+ onmouseclick);
+ this.bindings.push(binding);
+ binding.refresh();
+ }
+
+ return this;
+ },
+ hideMe: function(e){
+ RichFaces.Menu.Layers.clearPopUpTO();
+ RichFaces.Menu.Layers.levels[this.level] = null;
+ RichFaces.Menu.Layers.LMPopUpL(this.id, false);
+// if (this.eventOnClose) this.eventOnClose();
+ },
+ asDropDown: function(topLevel, onEvt, offEvt, options){
+ this.options = options || {};
+ if (this.options.ongroupactivate){
+ this.eventOnGroupActivate = this.options.ongroupactivate.bindAsEventListener(this);
+ }
+ if (this.options.onitemselect){
+ this.eventOnItemSelect = this.options.onitemselect.bindAsEventListener(this);
+ }
+ if (this.options.oncollapse){
+ this.eventOnCollapse = this.options.oncollapse.bindAsEventListener(this);
+ }
+ if (this.options.onexpand){
+ this.eventOnExpand = this.options.onexpand.bindAsEventListener(this);
+ }
+
+// if($(topLevel)){ CH-1518
+ var onmouseover = function(e){
+ if (!e) {
+ e = window.event;
+ }
+ RichFaces.Menu.Layers.showDropDownLayer(this.id, topLevel, e,this.delay);
+ }.bindAsEventListener(this);
+
+ if(!onEvt){
+ onEvt = 'onmouseover';
+ }
+ onEvt = this.eventJsToPrototype(onEvt);
+ if(!offEvt){
+ offEvt = 'onmouseout';
+ }
+ offEvt = this.eventJsToPrototype(offEvt);
+
+ var dis = this;
+ var onmouseout =
+ function(e){
+ RichFaces.Menu.Layers.setLMTO(this.hideDelay);
+ RichFaces.Menu.Layers.clearPopUpTO();
+ }.bindAsEventListener(this);
+
+// var item = $(topLevel);
+ var binding = new RichFaces.Menu.Layer.Binding(topLevel,onEvt, onmouseover);
+ this.bindings.push(binding);
+ binding.refresh();
+ binding = new RichFaces.Menu.Layer.Binding (topLevel, offEvt, onmouseout);
+ this.bindings.push(binding);
+ binding.refresh();
+
+ RichFaces.Menu.Layers.horizontals[this.id] = topLevel;
+// }
+ return this;
+ },
+
+ asSubMenu: function(parentv, refLayerName, evtName, options){
+ this.options = options || {};
+ if (this.options.onclose){
+ this.eventOnClose = this.options.onclose.bindAsEventListener(this);
+ }
+ if (this.options.onopen){
+ this.eventOnOpen = this.options.onopen.bindAsEventListener(this);
+ }
+
+ if(!evtName){
+ evtName = 'onmouseover';
+ }
+ evtName = this.eventJsToPrototype(evtName);
+ this.level = RichFaces.Menu.Layers.layers[parentv].level + 1;
+ RichFaces.Menu.Layers.father[this.id] = parentv;
+ if(!refLayerName){
+ refLayerName = 'ref' + parentv;
+ }
+ var refLayer = $(refLayerName);
+ this.refItem = RichFaces.Menu.Layers.layers[parentv].items[refLayerName];
+ this.refItem.childMenu = this;
+ var binding = new RichFaces.Menu.Layer.Binding(refLayerName, evtName, this.showMe.bindAsEventListener(this));
+ this.bindings.push(binding);
+ binding.refresh();
+
+
+ // set parents hideDelay
+ var menuLayer=this;
+ while (menuLayer.level > 0) {
+ menuLayer = RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
+ }
+ if (menuLayer && menuLayer.hideDelay){
+ this.hideDelay=menuLayer.hideDelay;
+ }
+
+
+ return this;
+ },
+ asContextMenu: function(parent, evt){
+ var refLayer = $(parent);
+ if(!refLayer) return this;
+ var id = this.id;
+ this.highlightParent = false;
+ if(!evt){
+ evt = 'onclick';
+ }
+ var offEvt = 'onmouseout';
+ offEvt = this.eventJsToPrototype(offEvt);
+
+ var dis = this;
+ var onmouseout =
+ function(e){
+ RichFaces.Menu.Layers.setLMTO(this.hideDelay);
+ RichFaces.Menu.Layers.clearPopUpTO();
+ }.bindAsEventListener(this);
+ evt = this.eventJsToPrototype(evt);
+ var handler = function(e){new RichFaces.Menu.DelayedContextMenu(this.id, e).show();}.bindAsEventListener(this);
+ var binding = new RichFaces.Menu.Layer.Binding (parent, evt, handler);
+ this.bindings.push(binding);
+ binding.refresh();
+ binding = new RichFaces.Menu.Layer.Binding (parent, offEvt, onmouseout);
+ this.bindings.push(binding);
+ binding.refresh();
+ return this;
+ },
+ eventJsToPrototype: function(evtName){
+ var indexof = evtName.indexOf('on');
+ if(indexof >= 0){
+ evtName = evtName.substr(indexof + 2);
+ }
+ return evtName;
+ }
+
+};
+
+RichFaces.Menu.Layer.Binding = Class.create();
+RichFaces.Menu.Layer.Binding.prototype = {
+ initialize:function(objectId, eventname, handler){
+ this.objectId = objectId;
+ this.eventname = eventname;
+ this.handler = handler;
+ },
+ refresh:function(){
+ /*LOG.a4j_debug("rebinding " + $H(this).inspect());*/
+ var obj = $(this.objectId);
+ if(obj){
+ Event.stopObserving(obj, this.eventname, this.handler);
+ Event.observe(obj, this.eventname, this.handler);
+ return true;
+ }
+ return false;
+ }
+};
+if(!RichFaces.Menu.Item) RichFaces.Menu.Item = {};
+
+/**
+ *
+ */
+RichFaces.Menu.Item.Onclick = function(evt, item, action, params, target) {
+ var form = Event.findElement(evt, 'form');
+
+ /*if(!form || typeof(form) == 'undefined' || !form.nodeName || form.nodeName.toLowerCase() != 'form'){
+ form = document.createElement('form');
+ form.setAttribute('method', 'post');
+ form.setAttribute('enctype', 'application/x-www-form-urlencoded');
+ form.action = action;
+ document.body.appendChild(form);
+ }*/
+ var objectsCreated = new Array();
+ var oldValues = new Object();
+ RichFaces.Menu.Item._createOrInitHiddenInput(item + ":submit", item + ":submit", objectsCreated, oldValues, form);
+
+ if (params) {
+
+ for (var param in params) {
+ var paramName = param;
+ var paramValue = params[paramName];
+ if (typeof(paramValue) != 'function') {
+ if (paramValue) {
+ paramValue = String(paramValue);
+ }
+ RichFaces.Menu.Item._createOrInitHiddenInput(paramName, paramValue, objectsCreated, oldValues, form);
+
+ }
+ }
+ }
+
+ var l = objectsCreated.length;
+
+ for (var i = 0; i < l; i++) {
+ var kid = objectsCreated[i];
+ form.appendChild(kid);
+ }
+
+ var targ = form.target;
+
+ if (target) {
+ form.target = target;
+ }
+
+ form.submit();
+
+ form.target = targ;
+
+ for (var j = 0; j < l; j++) {
+ var kid = objectsCreated[j];
+ if (form && kid) {
+ form.removeChild(kid);
+ }
+ }
+
+ for (var key in oldValues) {
+ var value = oldValues[key];
+ if (typeof(value) != 'function') {
+ ($(key) || form[key]).value = value;
+ }
+ }
+ }
+
+RichFaces.Menu.Item._createOrInitHiddenInput = function(name, value, list, oldValues, form) {
+ var hiddenObj = $(name) || form[name];
+
+ if (!hiddenObj) {
+ hiddenObj = document.createElement('input');
+ hiddenObj.setAttribute('type', 'hidden');
+ hiddenObj.setAttribute('name', name);
+ hiddenObj.setAttribute('id', name);
+ list.push(hiddenObj);
+ } else {
+ oldValues[name] = hiddenObj.value;
+ }
+ hiddenObj.value = value;
+}
+
18 years, 5 months
JBoss Rich Faces SVN: r4112 - branches/3.1.x/sandbox/samples/contextMenuDemo.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-20 11:30:43 -0500 (Tue, 20 Nov 2007)
New Revision: 4112
Modified:
branches/3.1.x/sandbox/samples/contextMenuDemo/pom.xml
Log:
context menu moved to 3.1.x branch
Modified: branches/3.1.x/sandbox/samples/contextMenuDemo/pom.xml
===================================================================
--- branches/3.1.x/sandbox/samples/contextMenuDemo/pom.xml 2007-11-20 16:30:38 UTC (rev 4111)
+++ branches/3.1.x/sandbox/samples/contextMenuDemo/pom.xml 2007-11-20 16:30:43 UTC (rev 4112)
@@ -2,34 +2,34 @@
<parent>
<artifactId>samples</artifactId>
<groupId>org.richfaces.sandbox</groupId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.richfaces.sandbox.samples</groupId>
<artifactId>contextMenuDemo</artifactId>
<packaging>war</packaging>
<name>contextMenuDemo Maven Webapp</name>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.richfaces.samples</groupId>
<artifactId>skins</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>core</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>dataTable</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.richfaces.sandbox.ui</groupId>
<artifactId>contextMenu</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
18 years, 5 months
JBoss Rich Faces SVN: r4111 - in branches/3.1.x/sandbox/ui/contextMenu: src/main/java/org/richfaces/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-20 11:30:38 -0500 (Tue, 20 Nov 2007)
New Revision: 4111
Modified:
branches/3.1.x/sandbox/ui/contextMenu/pom.xml
branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuContentHandler.java
branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/Lifo.java
Log:
context menu moved to 3.1.x branch
Modified: branches/3.1.x/sandbox/ui/contextMenu/pom.xml
===================================================================
--- branches/3.1.x/sandbox/ui/contextMenu/pom.xml 2007-11-20 16:25:31 UTC (rev 4110)
+++ branches/3.1.x/sandbox/ui/contextMenu/pom.xml 2007-11-20 16:30:38 UTC (rev 4111)
@@ -2,19 +2,19 @@
<parent>
<artifactId>ui</artifactId>
<groupId>org.richfaces.sandbox</groupId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.richfaces.sandbox.ui</groupId>
<artifactId>contextMenu</artifactId>
<name>contextMenu</name>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.richfaces.cdk</groupId>
<artifactId>maven-cdk-plugin</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
<executions>
<execution>
<phase>generate-sources</phase>
@@ -44,12 +44,12 @@
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>menu-components</artifactId>
- <version>3.2.0-SNAPSHOT</version>
+ <version>3.1.3-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuContentHandler.java
===================================================================
--- branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuContentHandler.java 2007-11-20 16:25:31 UTC (rev 4110)
+++ branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuContentHandler.java 2007-11-20 16:30:38 UTC (rev 4111)
@@ -40,7 +40,7 @@
public class ContextMenuContentHandler extends MacroDefinitionJSContentHandler {
- private static final Set<String> INTERPOLATED_ATTRIBUTES = new HashSet<String>();
+ private static final Set INTERPOLATED_ATTRIBUTES = new HashSet();
static {
String[] attrs = {
@@ -59,12 +59,12 @@
HTML.onselect_ATTRIBUTE
};
- for (String string : attrs) {
- INTERPOLATED_ATTRIBUTES.add(string);
+ for (int i = 0; i < attrs.length; i++) {
+ INTERPOLATED_ATTRIBUTES.add(attrs[i]);
}
}
- private Lifo<String> elementStack = new Lifo<String>();
+ private Lifo elementStack = new Lifo();
/**
@@ -76,22 +76,19 @@
super(writer, prolog, epilog);
}
- @Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
elementStack.push(localName);
super.startElement(uri, localName, name, attributes);
}
- @Override
public void endElement(String uri, String localName, String name)
throws SAXException {
elementStack.pop();
super.endElement(uri, localName, name);
}
- @Override
- protected List<?> parseExpressiion(String expressionString)
+ protected List parseExpressiion(String expressionString)
throws SAXException {
if (HTML.SCRIPT_ELEM.equals(elementStack.peek())) {
@@ -101,7 +98,7 @@
}
}
- @Override
+
protected void encodeAttributeValue(Attributes attributes, int idx)
throws SAXException, IOException {
Modified: branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
===================================================================
--- branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2007-11-20 16:25:31 UTC (rev 4110)
+++ branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2007-11-20 16:30:38 UTC (rev 4111)
@@ -60,22 +60,19 @@
System.arraycopy(ownScripts, 0, scripts, delegateScripts.length, ownScripts.length);
}
- @Override
protected InternetResource[] getScripts() {
return scripts;
}
- @Override
protected InternetResource[] getStyles() {
return delegate.getStyles();
}
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
+ protected Class getComponentClass() {
return delegate.getComponentClass();
}
- @Override
+
protected void doEncodeBegin(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
writer.startElement(HTML.DIV_ELEM, component);
@@ -83,7 +80,6 @@
}
- @Override
public void renderChildren(FacesContext context, UIComponent component)
throws IOException {
delegate.encodeChildren(context, component);
@@ -102,13 +98,11 @@
- @Override
protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
writer.endElement(HTML.DIV_ELEM);
}
- @Override
protected ContentHandler createContentHandler(Writer writer) {
return new ContextMenuContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
}
Modified: branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
===================================================================
--- branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2007-11-20 16:25:31 UTC (rev 4110)
+++ branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2007-11-20 16:30:38 UTC (rev 4111)
@@ -39,7 +39,6 @@
/* (non-Javadoc)
* @see org.richfaces.renderkit.html.AbstractMenuRenderer#getLayerScript(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
- @Override
protected String getLayerScript(FacesContext context, UIComponent component) {
StringBuffer buffer = new StringBuffer();
JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
@@ -107,8 +106,7 @@
/* (non-Javadoc)
* @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
+ protected Class getComponentClass() {
return UIContextMenu.class;
}
Modified: branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/Lifo.java
===================================================================
--- branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/Lifo.java 2007-11-20 16:25:31 UTC (rev 4110)
+++ branches/3.1.x/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/Lifo.java 2007-11-20 16:30:38 UTC (rev 4111)
@@ -21,13 +21,13 @@
package org.richfaces.renderkit.html;
-public class Lifo<T> {
+public class Lifo {
private class Element {
- private T content;
+ private Object content;
private Element next;
- public Element(Element next, T content) {
+ public Element(Element next, Object content) {
super();
this.next = next;
this.content = content;
@@ -37,11 +37,11 @@
private Element top = null;
- public void push(T element) {
+ public void push(Object element) {
top = new Element(top, element);
}
- public T pop() {
+ public Object pop() {
if (top == null) {
return null;
}
@@ -52,7 +52,7 @@
return e.content;
}
- public T peek() {
+ public Object peek() {
if (top == null) {
return null;
}
18 years, 5 months
JBoss Rich Faces SVN: r4110 - in branches/3.1.x/ui/orderingList/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2007-11-20 11:25:31 -0500 (Tue, 20 Nov 2007)
New Revision: 4110
Added:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
bug: RF-1379
Modified: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-20 15:53:03 UTC (rev 4109)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-11-20 16:25:31 UTC (rev 4110)
@@ -1,23 +1,3 @@
-if (LayoutManager.isIE()) {
-Array.prototype.indexOf = function(obj) {
- for(var i=0; i < this.length; i++) {
- if(this[i]==obj) {
- return i;
- }
- }
- return -1;
-}
-}
-
-Array.prototype.remove = function(object) {
- var index = this.indexOf(object, 0, this.length);
- if (index == 0) {
- this.shift();
- } else {
- this.splice(index, 1);
- }
-}
-
Shuttle = function(containerId, contentTableId, headerTableId, focusKeeperId, valueKeeperId,
ids, onclickControlId, onorderchanged) {
this.container = document.getElementById(containerId);
Added: branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js (rev 0)
+++ branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ShuttleUtils.js 2007-11-20 16:25:31 UTC (rev 4110)
@@ -0,0 +1,34 @@
+Object.extend(Event, {
+ _domReady : function() {
+ if (arguments.callee.done) return;
+ arguments.callee.done = true;
+ if (Event._timer) clearInterval(Event._timer);
+ Event._readyCallbacks.each(function(f) { f() });
+ Event._readyCallbacks = null;
+ },
+ onReady : function(f) {
+ if (!this._readyCallbacks) {
+ var domReady = this._domReady;
+ if (domReady.done) return f();
+ if (document.addEventListener)
+ document.addEventListener("DOMContentLoaded", domReady, false);
+ if (/WebKit/i.test(navigator.userAgent)) {
+ this._timer = setInterval(function() {
+ if (/loaded|complete/.test(document.readyState)) domReady();
+ }, 10);
+ }
+ Event.observe(window, 'load', domReady);
+ Event._readyCallbacks = [];
+ }
+ Event._readyCallbacks.push(f);
+ }
+});
+
+Array.prototype.remove = function(object) {
+ var index = this.indexOf(object, 0, this.length);
+ if (index == 0) {
+ this.shift();
+ } else {
+ this.splice(index, 1);
+ }
+}
\ No newline at end of file
Modified: branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-20 15:53:03 UTC (rev 4109)
+++ branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-20 16:25:31 UTC (rev 4110)
@@ -13,6 +13,7 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
+ scripts/ShuttleUtils.js,
scripts/SelectItem.js,
scripts/LayoutManager.js
scripts/Control.js,
@@ -62,15 +63,17 @@
</table>
<a id="#{clientId}sortLabel" href="#">Header</a>
- </div>
<f:clientId var="cId"/>
<script type="text/javascript">
var clientId = '#{cId}';
- if (window.attachEvent) {
+ /*if (window.attachEvent) {
window.attachEvent("onload", init);
} else {
window.addEventListener("load", init, false);
- }
+ }*/
+
+ Event.onReady(init);
+
document.body.onselectstart = function() {return false;};
document.body.className = "body";
function init() {
@@ -81,4 +84,5 @@
}
//setTimeout(init, 0);
</script>
+ </div>
</f:root>
\ No newline at end of file
18 years, 5 months
JBoss Rich Faces SVN: r4109 - trunk/docs/faq/en/src/main/docbook/module.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-11-20 10:53:03 -0500 (Tue, 20 Nov 2007)
New Revision: 4109
Modified:
trunk/docs/faq/en/src/main/docbook/module/RFCfaq.xml
Log:
http://jira.jboss.com/jira/browse/RF-1368 - verified links, fixed errors., http://jira.jboss.com/jira/browse/RF-389 - added new question
Modified: trunk/docs/faq/en/src/main/docbook/module/RFCfaq.xml
===================================================================
--- trunk/docs/faq/en/src/main/docbook/module/RFCfaq.xml 2007-11-20 14:53:23 UTC (rev 4108)
+++ trunk/docs/faq/en/src/main/docbook/module/RFCfaq.xml 2007-11-20 15:53:03 UTC (rev 4109)
@@ -10,7 +10,7 @@
<section>
<?dbhtml filename="Wherearebinary/sourcedistributionforRichFacesrelease.html"?>
- <title>Where are binary/source distribution for RichFaces 3.1.0 release?</title>
+ <title>Where are binary/source distribution for RichFaces?</title>
<para> Most important links for RichFaces can be found <ulink
url="http://jboss.com/index.html?module=bb&op=viewtopic&t=104575"
>here</ulink>.</para>
@@ -25,6 +25,95 @@
</section>
<section>
+ <?dbhtml filename="HowtobuildRichFacessnapshotmanually.html"?>
+ <title>How to configure Maven for RichFaces</title>
+ <itemizedlist>
+ <listitem>
+ <para>Download and install Maven if you have not it yet installed.
+ Follow the instruction at <ulink
+ url="http://maven.apache.org/download.html">
+ http://maven.apache.org/download.html</ulink>.</para>
+ </listitem>
+
+ <listitem>
+ <para>Open
+ <property><Maven-Root>/conf/settings.xml</property>
+ file to edit</para>
+
+ <para>Add into the <property><profile></property>
+ section:</para>
+ <programlisting role="XML"><![CDATA[
+ <id>RichFaces</id>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>
+ http://repository.jboss.com/maven2/
+ </url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <id>maven2-snapshots.jboss.com</id>
+ <name>Jboss Repository for Maven Snapshots</name>
+ <url>http://snapshots.jboss.com/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>maven2-snapshots.jboss.com</id>
+ <name>Jboss Repository for Maven Snapshots</name>
+ <url>http://snapshots.jboss.com/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>
+ http://repository.jboss.com/maven2/
+ </url>
+ <layout>default</layout>
+ </pluginRepository>
+ </pluginRepositories>
+]]></programlisting>
+ <para> Add into the
+ <property><activeProfiles></property> section:</para>
+ <programlisting role="XML"><![CDATA[<activeProfile>RichFaces</activeProfile>]]></programlisting>
+
+ </listitem>
+
+ </itemizedlist>
+ </section>
+
+ <section>
<?dbhtml filename="WhatstructureofRichFacesSVNrepositoryis.html"?>
<title>What is the structure of RichFaces SVN repository?</title>
<para>RichFaces repository structure overview can be found <ulink
@@ -43,7 +132,7 @@
<section>
<?dbhtml filename="IstheredemoforRichFacescomponents.html"?>
- <title>Where could I find a demo for RichFaces 3.1.0 components?</title>
+ <title>Where could I find a demo for RichFaces components?</title>
<para>Online demo Web applications that show the most important functionality of
RichFaces components are available <ulink
url="http://livedemo.exadel.com/richfaces-demo/">here</ulink>.</para>
@@ -78,7 +167,7 @@
Prototype.Browser() function can't be found.</title>
<para>RichFaces 3.1.0 has been released with the latest Prototype 1.5.1.1. The
conflict happens because on your page an older version of prototypes that
- can be added from Tomahawk 1.1.6 is used. See the solution to the problem
+ can be added from Tomahawk 1.1.6 is used. See the solution for the problem
<ulink
url="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=118526&a..."
>here.</ulink></para>
@@ -279,9 +368,14 @@
<section>
<?dbhtml filename="HowtocustomizesimpleTogglePanel.html"?>
<title>How to pass own parameters during a modalPanel opening or closing?</title>
- <para>The answer could be found in the "Details of usage" of <link
- linkend="modalPanel"><rich:modalPanel>
- component</link>.</para>
+ <para> You can pass your parameters during modalPanel opening or closing. This passing could be
+ performed in the following way: </para>
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="JAVA"><![CDATA[Richfaces.showModalPanel('panelId', {left: auto}, {param1: value1});]]></programlisting>
+ <para> Thus, except the standard modalPanel parameters you can pass any of your own parameters. </para>
</section>
<section>
@@ -662,8 +756,7 @@
<section id="DecidingWhatToChangeOnTheServerSide">
<?dbhtml filename="DecidingWhatToChangeOnTheServerSide.html"?>
<title>What should I change on the server side?</title>
- <para> As it was mentioned <ulink url="index.html#DecideWhatToChange"
- >before</ulink>, the list of zones to be reRendered can be specified as EL
+ <para> The list of zones to be reRendered can be specified as EL
expression. But there is a question that must be specified more exactly. </para>
<para> The list of Ids is formed during beforePhase of RENDER_RESPONSE. Therefore,
in this case one can point reRender to the Set type Bean's property
@@ -1014,16 +1107,34 @@
<para>The problem is solved with browser cash update (e.g. CTRL+F5).</para>
</section>
-
+
<section id="RerenderingPartPage">
<?dbhtml filename="RerenderingPartPage.html"?>
<title>How to reRender only particular row(s) of table?</title>
- <para> If you use dataTable then you may use <emphasis>
+ <!--para> If you use dataTable then you may use <emphasis>
+ <property>"ajaxKeys"</property>
+ </emphasis> attribute to bind the rowKeys to be reRendered there. After you
+ need to point reRender on the specific rows. </para-->
+ <para><emphasis>
<property>"ajaxKeys"</property>
- </emphasis> attribute to bind the rowKeys to be reRendered there.
- After you need to point reRender on the specific rows. See also
- <link linkend="IterationcomponentsAjaxattributes"
- >"Iteration components Ajax attributes
- section"</link>. </para>
+ </emphasis> attribute defines strings that are updated after an Ajax request. It provides
+ possibility to update several child components separately without updating the whole page.</para>
+
+ <programlisting role="XML"><![CDATA[...
+ <a4j:poll intervall="1000" action="#{repeater.action}" reRender="text">
+ <table>
+ <tbody>
+ <a4j:repeat value="#{bean.props}" var="detail" ajaxKeys="#{repeater.ajaxedRowsSet}">
+ <tr>
+ <td>
+ <h:outputText value="detail.someProperty" id="text"/>
+ </td>
+ </tr>
+ </a4j:repeat>
+ </tbody>
+ </table>
+ </a4j:poll>
+...
+]]></programlisting>
</section>
</chapter>
18 years, 5 months
JBoss Rich Faces SVN: r4108 - trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2007-11-20 09:53:23 -0500 (Tue, 20 Nov 2007)
New Revision: 4108
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1314
Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-11-20 14:52:06 UTC (rev 4107)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-11-20 14:53:23 UTC (rev 4108)
@@ -678,8 +678,9 @@
var offsetDimBase = Richfaces.Calendar.getOffsetDimensions(base);
var offsetDimButton = Richfaces.Calendar.getOffsetDimensions(baseButton);
- var o = {left: offsetBase[0],
- top: offsetBase[1],
+ var offsetTemp = Position.realOffset(baseButton);
+ var o = {left: offsetBase[0]-offsetTemp[0],
+ top: offsetBase[1]-offsetTemp[1],
width: offsetDimBase.width,
height: (offsetDimInput && offsetDimInput.height>offsetDimButton.height ? offsetDimInput.height : offsetDimButton.height)};
18 years, 5 months
JBoss Rich Faces SVN: r4107 - trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2007-11-20 09:52:06 -0500 (Tue, 20 Nov 2007)
New Revision: 4107
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
revert from 3734
Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-11-20 14:47:19 UTC (rev 4106)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-11-20 14:52:06 UTC (rev 4107)
@@ -269,11 +269,10 @@
var counter=1;
var y,m,d;
- var a,h,min;
var shortLabel=false;
pattern = pattern.replace(/([.*+?^<>=!:${}()|[\]\/\\])/g, '\\$1');
- pattern = pattern.replace(/(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
+ pattern = pattern.replace(/(y+|M+|d+)/g,
function($1) {
switch ($1) {
case 'y' :
@@ -282,12 +281,6 @@
case 'M' : m=counter; counter++; return '(\\d{1,2})';
case 'd' : d=counter; counter++; return '(\\d{1,2})';
case 'MMM': m=counter; counter++; shortLabel=true; return '('+monthNamesShort.join('|')+')';
- case 'a' : a=counter; counter++; return '(AM|am|PM|pm)?';
- case 'HH' :
- case 'hh' : h=counter; counter++; return '(\\d{2})?';
- case 'H' :
- case 'h' : h=counter; counter++; return '(\\d{1,2})?';
- case 'mm' : min=counter; counter++; return '(\\d{2})?';
}
// y+,M+,d+
var ch = $1.charAt(0);
@@ -304,72 +297,34 @@
var yy = parseInt(match[y],10); if (isNaN(yy)) return null; else if (yy<70) yy+=2000; else if (yy<100) yy+=1900;
var mm = parseInt(match[m],10); if (isNaN(mm)) mm = Richfaces.Calendar.getMonthByLabel(match[m], shortLabel ? monthNamesShort : monthNames); else if (--mm<0 || mm>11) return null;
var dd = parseInt(match[d],10); if (isNaN(dd) || dd<1 || dd>daysInMonth(yy, mm)) return null;
-
- // time parsing
- if (min!=undefined && h!=undefined)
- {
- var hh,mmin,aa;
- mmin = parseInt(match[min],10); if (isNaN(mmin) || mmin<0 || mmin>59) return null;
- hh = parseInt(match[h],10); if (isNaN(hh)) return null;
- if (a!=undefined)
- {
- aa = match[a].toLowerCase();
- if ((aa!='am' && aa!='pm') || hh<1 || hh>12) return null;
- if (aa=='pm')
- {
- if (hh!=12) hh+=11;
- } else if (hh==12) hh = 0;
- }
- else if (hh<0 || hh>23) return null;
-
- return new Date(yy, mm, dd, hh, mmin, 0);
- }
-
return new Date(yy, mm, dd);
}
return null;
- },
-
- escape : function (str)
- {
- return str.replace(/[yMdaHhm]/g,"\\$1");
- },
-
- unescape : function (str)
- {
- return str.replace(/\\([yMdaHhm])/g,"$1");
- }
+ }
});
Object.extend(Date.prototype, {
format : function(pattern, monthNames, monthNamesShort) {
if (!monthNames) monthNames = Date.getDefaultMonthNames();
if (!monthNamesShort) monthNamesShort = Date.getDefaultMonthNames(true);
- var d = this; var mm; var dd; var hh;
- var result = pattern.replace(/(^|[^\\yMdHhm])(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
- function($1,$2,$3) {
- switch ($3) {
+ var d = this; var mm; var dd;
+ return pattern.replace(/(y+|M+|d+)/g,
+ function($1) {
+ switch ($1) {
case 'y':
- case 'yy': return $2+d.getYear().toString().slice(-2);
- case 'M': return $2+(d.getMonth()+1);
- case 'MM': return $2+((mm = d.getMonth()+1)<10 ? '0'+mm : mm);
- case 'MMM': return $2+monthNamesShort[d.getMonth()];
- case 'd': return $2+d.getDate();
- case 'a' : return $2+(d.getHours()<12 ? 'AM' : 'PM');
- case 'HH' : return $2+((hh = d.getHours())<10 ? '0'+hh : hh);
- case 'H' : return $2+d.getHours();
- case 'hh' : return $2+((hh = d.getHours())==0 ? '12' : (hh<10 ? '0'+hh : (hh>12 ? hh-12 : hh)));
- case 'h' : return $2+((hh = d.getHours())==0 ? '12' : (hh>12 ? hh-12 : hh));
- case 'mm' : return $2+((min = d.getMinutes())<10 ? '0'+min : min);
+ case 'yy': return str = d.getYear().toString().slice(-2);
+ case 'M': return d.getMonth()+1;
+ case 'MM': return (mm = d.getMonth()+1)<10 ? '0'+mm : mm;
+ case 'MMM': return monthNamesShort[d.getMonth()];
+ case 'd': return d.getDate();
}
// y+,M+,d+
- var ch = $3.charAt(0);
- if (ch=='y') return $2+d.getFullYear();
- if (ch=='M') return $2+monthNames[d.getMonth()];
- if (ch=='d') return $2+((dd = d.getDate())<10 ? '0'+dd : dd);
+ var ch = $1.charAt(0);
+ if (ch=='y') return d.getFullYear();
+ if (ch=='M') return monthNames[d.getMonth()];
+ if (ch=='d') return (dd = d.getDate())<10 ? '0'+dd : dd;
}
);
- return Date.unescape(result);
}
});
@@ -479,11 +434,8 @@
this.params = parameters;
if (!this.params.showWeekDaysBar) this.params.showWeekDaysBar = true;
if (!this.params.showWeeksBar) this.params.showWeeksBar = true;
- if (!this.params.datePattern) this.params.datePattern = "MMM d, y h:mm a";
+ if (!this.params.datePattern) this.params.datePattern = "MMM d, y";
- // time
- this.setTimeProperties();
-
// markups initialization
if (!this.params.dayListMarkup)
{
@@ -639,41 +591,6 @@
},
- setTimeProperties: function() {
- this.timeType = 0;
- this.dateTimePattern = this.params.datePattern;
- var h,hh,m,a;
- this.dateTimePattern = this.dateTimePattern.replace(/(^|[^\\Hhm])(H{1,2}|h{1,2}|m{2}|a)/g,
- function($1,$2,$3) {
- switch ($3) {
- case 'a' : a=true; return $2+'<sp\\an st\\yle="b\\ackgroun\\d-color:#BED6F8;" onclick="Ric\\hf\\aces.getCo\\mponent(\'c\\alen\\d\\ar\',t\\his).c\\h\\angeTi\\me(t\\his,\'\\a\'); return true;">'+$3+'</sp\\an>';
- case 'H' :
- case 'HH' : h=true; return $2+'<sp\\an st\\yle="b\\ackgroun\\d-color:#BED6F8;" onclick="Ric\\hf\\aces.getCo\\mponent(\'c\\alen\\d\\ar\',t\\his).c\\h\\angeTi\\me(t\\his,\'\\h\'); return true;">'+$3+'</sp\\an>';
- case 'h' :
- case 'hh' : hh=true; return $2+'<sp\\an st\\yle="b\\ackgroun\\d-color:#BED6F8;" onclick="Ric\\hf\\aces.getCo\\mponent(\'c\\alen\\d\\ar\',t\\his).c\\h\\angeTi\\me(t\\his,\'\\hh\'); return true;">'+$3+'</sp\\an>';
- case 'mm' : m=true; return $2+'<sp\\an st\\yle="b\\ackgroun\\d-color:#BED6F8;" onclick="Ric\\hf\\aces.getCo\\mponent(\'c\\alen\\d\\ar\',t\\his).c\\h\\angeTi\\me(t\\his,\'\\m\'); return true;">'+$3+'</sp\\an>';
- }
- }
- );
- if (m && h) this.timeType = 1;
- else if (m && hh && a) this.timeType = 2;
- },
-
- changeTime: function(element, v) {
- if (v=='a')
- {
- var h = this.selectedDate.getHours();
- if (h>11) {
- h -= 12;
- } else {
- h +=12;
- }
- this.selectedDate.setHours(h);
- this.renderHeader();
- this.renderFooter();
- }
- },
-
doCollapse: function() {
if (!this.params.popup || !this.isVisible) return;
@@ -1554,17 +1471,13 @@
return new E('div',attr,[new T(text)]);
};
-CalendarView.getSelectedDateControl = function(calendar, functionName) {
+CalendarView.getSelectedDateControl = function(text, functionName) {
var attr = {
onclick: "Richfaces.getComponent('calendar',this).showSelectedDate(); return true;",
className: "rich-calendar-btn"
};
- var text = "";
- if (calendar.selectedDate) text = calendar.selectedDate.format( (calendar.timeType ? calendar.dateTimePattern : calendar.params.datePattern), calendar.params.monthLabels, calendar.params.monthLabelsShort);
-
-
- var a = [new ET(text)];
+ var a = [new T(text)];
if (text)
{
a.push(new T(" "));
@@ -1580,7 +1493,8 @@
CalendarView.previousMonthControl = CalendarView.getControl("<", "prevMonth");
CalendarView.currentMonthControl = function (context) { return context.calendar.getCurrentDate().format("MMMM, yyyy", context.monthLabels, context.monthLabelsShort);};
CalendarView.todayControl = CalendarView.getControl("Today", "today");
-CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar);};
+CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar.getSelectedDateString(context.calendar.params.datePattern));};
+//CalendarView.resetSelectedDateControl = function (context) { return (context.calendar.getSelectedDate() ? CalendarView.getControl("x", "resetSelectedDate") : "");};
CalendarView.header = [
new E('table',{'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'width': '100%'},
@@ -1658,5 +1572,6 @@
previousMonthControl: CalendarView.previousMonthControl,
currentMonthControl: CalendarView.currentMonthControl,
todayControl: CalendarView.todayControl,
- selectedDateControl: CalendarView.selectedDateControl,
+ selectedDateControl: CalendarView.selectedDateControl
+ //resetSelectedDateControl: CalendarView.resetSelectedDateControl,
});
\ No newline at end of file
18 years, 5 months