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 2016/08/31 09:54:22 UTC

svn commit: r1758570 - in /myfaces/tobago/trunk: tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/ tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/ tobago...

Author: lofwyr
Date: Wed Aug 31 09:54:22 2016
New Revision: 1758570

URL: http://svn.apache.org/viewvc?rev=1758570&view=rev
Log:
TOBAGO-1587: links doesn't support rightklick->newTab
TOBAGO-1557: Consolidate <tc:button>, <tc:link> and <tc:command>
* tc:link and tc:button will render same HTML, but with other CSS classes

[developed with hnoeth]

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/commands.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/60-bar/bar.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.test.js
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button%2Blink/button%2Blink.xhtml?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/00-button+link/button+link.xhtml Wed Aug 31 09:54:22 2016
@@ -72,6 +72,11 @@
         <tc:link image="fa-play-circle" label="Play"/>
         <tc:link image="fa-pause-circle" label="Pause"/>
         <tc:link image="fa-stop-circle" label="Stop"/>
+        <tc:link label="Track">
+          <tc:link label="1"/>
+          <tc:link label="2"/>
+          <tc:link label="3"/>
+        </tc:link>
       </tc:link>
     </tc:section>
 
@@ -84,6 +89,11 @@
         <tc:link image="fa-play-circle" label="Play"/>
         <tc:link image="fa-pause-circle" label="Pause"/>
         <tc:link image="fa-stop-circle" label="Stop"/>
+        <tc:link label="Track">
+          <tc:link label="1"/>
+          <tc:link label="2"/>
+          <tc:link label="3"/>
+        </tc:link>
       </tc:button>
     </tc:section>
 

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/commands.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/commands.xhtml?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/commands.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/25-commands/commands.xhtml Wed Aug 31 09:54:22 2016
@@ -62,6 +62,11 @@
         <tc:link label="Action 1"/>
         <tc:link label="Action 2"/>
         <tc:link label="Action 3"/>
+        <tc:link label="Submenu">
+          <tc:link label="Action 1"/>
+          <tc:link label="Action 2"/>
+          <tc:link label="Action 3"/>
+        </tc:link>
       </tc:link>
       <tc:link label="Center"/>
       <tc:link label="Right"/>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/60-bar/bar.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/60-bar/bar.xhtml?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/60-bar/bar.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/60-bar/bar.xhtml Wed Aug 31 09:54:22 2016
@@ -36,8 +36,7 @@
       Buttons and links don't have any functionality.</p>
     <tc:bar>
       <f:facet name="brand">
-        <tc:image value="image/feather-leaf.png"/>
-        <tc:label value="Tobago"/>
+        <tc:link id="brand" label="Tobago Demo" image="image/feather-leaf.png" link="/"/>
       </f:facet>
       <tc:commands>
         <tc:link label="Home"/>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.test.js?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.test.js Wed Aug 31 09:54:22 2016
@@ -21,11 +21,11 @@ QUnit.test("Simple Popup", function (ass
   var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $open = jQueryFrame("#page\\:mainForm\\:simple\\:open");
-  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:simple\\:submitOnPage");
-  var $in = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:in\\:\\:field");
-  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:submitOnPopup");
-  var $close = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:close");
+  var $open = jQueryFrame("#page\\:mainForm\\:simple\\:open1");
+  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:simple\\:submitOnPage1");
+  var $in = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:in1\\:\\:field");
+  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:submitOnPopup1");
+  var $close = jQueryFrame("#page\\:mainForm\\:simple\\:controllerPopup\\:close1");
 
   $open.click();
 
@@ -87,11 +87,11 @@ QUnit.test("Full Server Request", functi
   var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $open = jQueryFrame("#page\\:mainForm\\:server\\:open");
-  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:server\\:submitOnPage");
-  var $in = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:in\\:\\:field");
-  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:submitOnPopup");
-  var $close = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:close");
+  var $open = jQueryFrame("#page\\:mainForm\\:server\\:open2");
+  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:server\\:submitOnPage2");
+  var $in = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:in2\\:\\:field");
+  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:submitOnPopup2");
+  var $close = jQueryFrame("#page\\:mainForm\\:server\\:fullServerRequestPopup\\:close2");
 
   $open.click();
 
@@ -153,12 +153,12 @@ QUnit.test("Client Sided", function (ass
   var step = 1;
 
   var $messages = jQueryFrame("#page\\:messages .tobago-messages");
-  var $open = jQueryFrame("#page\\:mainForm\\:client\\:open");
-  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:client\\:submitOnPage");
+  var $open = jQueryFrame("#page\\:mainForm\\:client\\:open3");
+  var $submitOnPage = jQueryFrame("#page\\:mainForm\\:client\\:submitOnPage3");
   var $popupCollapsed = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:\\:collapse");
-  var $in = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:in\\:\\:field");
-  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:submitOnPopup");
-  var $close = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:close");
+  var $in = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:in3\\:\\:field");
+  var $submitOnPopup = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:submitOnPopup3");
+  var $close = jQueryFrame("#page\\:mainForm\\:client\\:clientPopup\\:close3");
 
   $open.click();
   assert.equal($popupCollapsed.val(), "false");

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java Wed Aug 31 09:54:22 2016
@@ -19,20 +19,5 @@
 
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
-import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
-import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
-import org.apache.myfaces.tobago.renderkit.css.CssItem;
-
-import javax.faces.context.FacesContext;
-import java.util.List;
-
 public class CommandRenderer extends CommandRendererBase {
-
-  @Override
-  protected void addCssItems(
-      final FacesContext facesContext, final AbstractUICommand command, final List<CssItem> collected) {
-
-    collected.add(BootstrapClass.BTN);
-    collected.add(BootstrapClass.BTN_LINK);
-  }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRendererBase.java Wed Aug 31 09:54:22 2016
@@ -20,6 +20,8 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.Attributes;
+import org.apache.myfaces.tobago.component.UICommands;
+import org.apache.myfaces.tobago.internal.component.AbstractUIButton;
 import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
 import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
@@ -82,25 +84,22 @@ public abstract class CommandRendererBas
     final String clientId = command.getClientId(facesContext);
     final boolean disabled = command.isDisabled();
     final LabelWithAccessKey label = new LabelWithAccessKey(command);
-    final String href = command.getLink();
-    final boolean link = href != null;
+    final boolean link = command.getLink() != null && !disabled;
+    final String target = command.getTarget();
 
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
-    if (command.isParentOfCommands()) {
-      if (link) {
-        writer.startElement(HtmlElements.SPAN);
+    if (needsExtraSpanElement(command)) {
+      writer.startElement(HtmlElements.SPAN);
+      if (component instanceof AbstractUIButton) { // todo: check if we should differ here
         writer.writeClassAttribute(BootstrapClass.BTN_GROUP);
+      } else {
+        writer.writeClassAttribute(BootstrapClass.DROPDOWN);
       }
     }
 
     if (link) {
       writer.startElement(HtmlElements.A);
-      if (disabled) {
-        writer.writeAttribute(HtmlAttributes.HREF, "#/", false);
-      } else {
-        writer.writeAttribute(HtmlAttributes.HREF, href, false);
-      }
     } else {
       writer.startElement(HtmlElements.BUTTON);
       writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
@@ -109,13 +108,25 @@ public abstract class CommandRendererBas
     writer.writeNameAttribute(clientId);
     writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
 
-    if (!disabled) {
+    if (disabled) {
+      writer.writeAttribute(HtmlAttributes.HREF, "#/", false);
+    } else {
+      final String href;
       String commands = RenderUtils.getBehaviorCommands(facesContext, command);
       if (commands == null) { // old way
         final CommandMap map = new CommandMap(new Command(facesContext, command));
         commands = JsonUtils.encode(map);
+        href = map.getClick().getUrl();
+      } else {
+        href = RenderUtils.generateUrl(facesContext, command);
+      }
+      if (link) {
+        writer.writeAttribute(HtmlAttributes.HREF, href, false);
+        writer.writeAttribute(HtmlAttributes.TARGET, target, false);
+      } else {
+        writer.writeAttribute(DataAttributes.COMMANDS, commands, true);
+        writer.writeAttribute(HtmlAttributes.HREF, "#/", false);
       }
-      writer.writeAttribute(DataAttributes.COMMANDS, commands, true);
 
       if (label.getAccessKey() != null) {
         writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
@@ -135,7 +146,6 @@ public abstract class CommandRendererBas
     if (command.isParentOfCommands()) {
       // XXX BootstrapClass.NAV_LINK should only be shown inside of UICommands or UIButtons
       cssItems.add(BootstrapClass.DROPDOWN_TOGGLE);
-      cssItems.add(BootstrapClass.NAV_LINK);
       writer.writeAttribute(DataAttributes.TOGGLE, "dropdown", false);
     }
     addCssItems(facesContext, command, cssItems);
@@ -229,18 +239,14 @@ public abstract class CommandRendererBas
   public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
 
     final AbstractUICommand command = (AbstractUICommand) component;
-    final boolean link = command.getLink() != null;
-
     final TobagoResponseWriter writer = getResponseWriter(facesContext);
 
     if (command.isParentOfCommands()) {
       writer.endElement(HtmlElements.UL);
     }
 
-    if (command.isParentOfCommands()) {
-      if (link) {
-        writer.endElement(HtmlElements.SPAN);
-      }
+    if (needsExtraSpanElement(command)) {
+      writer.endElement(HtmlElements.SPAN);
     }
   }
 
@@ -251,4 +257,13 @@ public abstract class CommandRendererBas
   protected void addCssItems(
       final FacesContext facesContext, final AbstractUICommand command, final List<CssItem> collected) {
   }
+
+  /**
+   * We need an extra SPAN element with position: relative or absolute for positioning the dropdown
+   * */
+  private boolean needsExtraSpanElement(AbstractUICommand command) {
+    return !(command.getParent() instanceof AbstractUICommand) // only needed for top elements
+        && !(command.getParent() instanceof UICommands) // not needed inside of tc:commands
+        && command.isParentOfCommands(); // only needed for sub-menus
+  }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
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/style/tobago.css?rev=1758570&r1=1758569&r2=1758570&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css Wed Aug 31 09:54:22 2016
@@ -233,6 +233,24 @@ table.tobago-gridLayout > tbody > tr:fir
   white-space: normal
 }
 
+.tobago-link-markup-disabled {
+  color: #909090;
+}
+
+.tobago-link-markup-disabled:focus, .tobago-link-markup-disabled:hover {
+  color: #484848;
+}
+
+button.tobago-link {
+  font-weight: normal;
+  color: #0275d8;
+  border-width: 0;
+  padding: 0;
+  background-color: transparent;
+
+  /* todo: to be continued... */
+}
+
 /* messages ----------------------------------------------------------- */
 
 .tobago-messages label {
@@ -245,6 +263,17 @@ table.tobago-gridLayout > tbody > tr:fir
 
 /* nav ----------------------------------------------------------- */
 
+.nav-item > .tobago-link, .nav-item > .tobago-command {
+  padding-top: .425rem;
+  padding-bottom: .425rem;
+  display: inline-block;
+}
+
+/* styles for drop down menu first level */
+.dropdown-toggle:focus, .dropdown-toggle:hover {
+  text-decoration: none;
+}
+
 /* styles for drop down menu with deeper level */
 .dropdown-submenu {
   position: relative;
@@ -270,9 +299,9 @@ table.tobago-gridLayout > tbody > tr:fir
   left: 100%;
   margin-top: -6px;
   margin-left: -1px;
-  -webkit-border-radius: 0 6px 6px 6px;
-  -moz-border-radius: 0 6px 6px 6px;
-  border-radius: 0 6px 6px 6px;
+  -webkit-border-radius: 6px 6px 6px 6px;
+  -moz-border-radius: 6px 6px 6px 6px;
+  border-radius: 6px 6px 6px 6px;
 }
 
 .dropdown-submenu:hover > .dropdown-menu {