You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/08/19 17:17:16 UTC
svn commit: r987185 - in /myfaces/tobago/trunk:
tobago-example/tobago-example-demo/src/main/webapp/reference/
tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
tobago-theme/tobago-the...
Author: lofwyr
Date: Thu Aug 19 15:17:14 2010
New Revision: 987185
URL: http://svn.apache.org/viewvc?rev=987185&view=rev
Log:
TOBAGO-832: Menu
- fix initialization of menu, when the menu will loaded via AJAX
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml?rev=987185&r1=987184&r2=987185&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/reference/popup.xhtml Thu Aug 19 15:17:14 2010
@@ -31,7 +31,6 @@
<f:facet name="layout">
<tc:gridLayout rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;*"/>
</f:facet>
-
<f:facet name="menuBar">
<tc:menuBar>
<tc:menu label="Menu">
@@ -56,7 +55,18 @@
<f:facet name="layout">
<tc:gridLayout rows="fixed;fixed;fixed;fixed;*;fixed"/>
</f:facet>
+ <f:facet name="menuBar">
+ <tc:menuBar>
+ <tc:menu label="Menu">
+ <tc:menuCommand label="Say okay" onclick="alert('okay');"/>
+ </tc:menu>
+ </tc:menuBar>
+ </f:facet>
+ <tc:selectOneChoice>
+ <f:selectItem itemLabel="A" itemValue="a"/>
+ <f:selectItem itemLabel="B" itemValue="b"/>
+ </tc:selectOneChoice>
<tc:selectBooleanCheckbox value="#{reference.bool}"/>
<tc:in value="#{reference.text}" required="true"/>
<tx:date>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java?rev=987185&r1=987184&r2=987185&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java Thu Aug 19 15:17:14 2010
@@ -20,7 +20,6 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.component.UIMenu;
import org.apache.myfaces.tobago.context.Markup;
-import org.apache.myfaces.tobago.internal.context.ResponseWriterDivider;
import org.apache.myfaces.tobago.internal.util.AccessKeyMap;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
@@ -58,7 +57,7 @@ public class MenuRenderer extends Layout
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
-
+
final UIMenu menu = (UIMenu) component;
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
@@ -93,11 +92,6 @@ public class MenuRenderer extends Layout
}
writer.endElement(HtmlElements.A);
if (isParentMenu) {
- if (firstLevel) {
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, MenuBarRenderer.DIVIDER);
- divider.activateBranch(facesContext);
- writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- }
writer.startElement(HtmlElements.OL, menu);
writer.writeIdAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "menu");
}
@@ -108,16 +102,10 @@ public class MenuRenderer extends Layout
UIMenu menu = (UIMenu) component;
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- boolean firstLevel = !RendererTypes.MENU.equals(menu.getParent().getRendererType());
boolean isParentMenu = menu.getChildCount() > 0; // todo: may be not correct
if (isParentMenu) {
writer.endElement(HtmlElements.OL);
- if (firstLevel) {
- ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, MenuBarRenderer.DIVIDER);
- divider.passivateBranch(facesContext);
- writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- }
}
writer.endElement(HtmlElements.LI);
}
@@ -135,5 +123,4 @@ public class MenuRenderer extends Layout
LOG.warn("Can't find menu root component!");
}
}
-
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=987185&r1=987184&r2=987185&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Thu Aug 19 15:17:14 2010
@@ -208,50 +208,64 @@ function xxx_tobagoMenuSwitchOff(menuBar
menuBar.attr('menu-active', 'false'); // write state back
}
-function xxx_tobagoMenuInit() {
- jQuery(document).ready(function() {
-
- // a click on the top menu make the complete menu active or inactive respectively.
- jQuery(".tobago-menu-markup-top").click(function(event) {
+/**
+ * @param elements a jQuery object to initialize (ajax) or null for initializing the whole document (full load).
+ */
+function xxx_tobagoMenuInit(elements) {
+
+ var menus = elements == null
+ ? jQuery(".tobago-menu-markup-top")
+ : elements.find(".tobago-menu-markup-top");
+
+ // a click on the top menu make the complete menu active or inactive respectively.
+ menus.click(function(event) {
+
+ // e. g. disabled by a popup
+ if (jQuery(this).children("a").attr("disabled")) {
+ return;
+ }
+ // register on click handlers
+ var menuBar = jQuery(this).parent();
+ var wasActive = 'true' == menuBar.attr('menu-active'); // read state
+
+ if (wasActive) {
+ xxx_tobagoMenuSwitchOff(menuBar);
+ } else {
+ xxx_tobagoMenuSwitchOn(menuBar, jQuery(this));
+ }
- // e. g. disabled by a popup
- if(jQuery(this).children("a").attr("disabled")) {
- return;
- }
- // register on click handlers
- var menuBar = jQuery(this).parent();
- var wasActive = 'true' == menuBar.attr('menu-active'); // read state
-
- if (wasActive) {
- xxx_tobagoMenuSwitchOff(menuBar);
- } else {
- xxx_tobagoMenuSwitchOn(menuBar, jQuery(this));
- }
+ event.stopPropagation();
+ });
- event.stopPropagation();
- });
+ // IE6 select-tag fix
+ // put a iframe inside the div, so that a <select> tag doesn't shine through.
+ // the iframe must be resized (see above)
+ if (jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) {
+ menus.children("ol").prepend(
+ "<iframe class='tobago-menu-ie6bugfix' src='" + Tobago.blankPage + "'></iframe>");
+ }
+
+ jQuery(".tobago-page-menuStore").append(menus.children("ol"));
+
+ var toolBarMenu = elements == null
+ ? jQuery(".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu")
+ : elements.find(".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu");
+ // a click on toolBar menu opener -> forward to .tobago-menu-markup-top
+ toolBarMenu.click(function(event) {
+ $(this).next().find('a').click();
+ event.stopPropagation();
+ });
- // a click on toolBar menu opener -> forward to .tobago-menu-markup-top
- jQuery(".tobago-toolBar-menu .tobago-boxToolBar-menu .tobago-tabGroupToolBar-menu").click(function(event) {
- $(this).next().find('a').click();
- event.stopPropagation();
- });
-
- // init context menus
- jQuery(".tobago-menu-contextMenu").parent().bind("contextmenu", function(event) {
- jQuery(this).children(".tobago-menu-contextMenu").find('a').click();
- event.stopPropagation();
- return false;
- });
-
- // IE6 select-tag fix
- // put a iframe inside the div, so that a <select> tag doesn't shine through.
- // the iframe must be resized (see above)
- if (jQuery.browser.msie && parseInt(jQuery.browser.version) <= 6) {
- jQuery(".tobago-page-menuStore ol").prepend(
- "<iframe class='tobago-menu-ie6bugfix' src='" + Tobago.blankPage + "'></iframe>");
- }
+ // init context menus
+ var contextMenu = elements == null
+ ? jQuery(".tobago-menu-contextMenu")
+ : elements.find(".tobago-menu-contextMenu");
+ contextMenu.parent().bind("contextmenu", function(event) {
+ jQuery(this).children(".tobago-menu-contextMenu").find('a').click();
+ event.stopPropagation();
+ return false;
});
+
}
jQuery.tobagoMenuParent = function(element) {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=987185&r1=987184&r2=987185&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Thu Aug 19 15:17:14 2010
@@ -266,8 +266,8 @@ var Tobago = {
this.addBindEventListener(window, "unload", this, "onUnload");
// XXX not nice...
- xxx_tobagoMenuInit();
-
+ xxx_tobagoInit();
+
if (TbgTimer.endBody) {
TbgTimer.startAppOnload = new Date();
}
@@ -2283,11 +2283,14 @@ Tobago.Updater = {
doUpdate: function(data) {
if (data.responseCode == Tobago.Updater.CODE_SUCCESS) {
- jQuery(Tobago.escapeClientId(data.ajaxId)).replaceWith(data.html);
+ var element = jQuery(Tobago.escapeClientId(data.ajaxId));
+ var newElement = jQuery(data.html);
+ element.replaceWith(newElement);
try {
var updateScript;
eval("updateScript = " + data.script);
updateScript();
+ xxx_tobagoInit(newElement);
Tobago.fixPngAlphaAll();
} catch (e) {
LOG.error("Error in doUpdate: " + e);
@@ -2466,3 +2469,9 @@ function tobago_toolBarSetRadioValue(id,
}
TbgTimer.endTbgJs = new Date();
+
+// XXX write initialization
+
+function xxx_tobagoInit(elements) {
+ xxx_tobagoMenuInit(elements);
+}