myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject [myfaces-tobago] 03/19: Tobago-1999: styling
Date Fri, 29 Nov 2019 15:55:10 GMT
This is an automated email from the ASF dual-hosted git repository.

weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 946609967ae6aa6633ecd43ecf2eecb37880eb94
Author: Volker Weber <v.weber@inexso.de>
AuthorDate: Tue Aug 20 16:53:01 2019 +0200

    Tobago-1999: styling
---
 .../internal/component/AbstractUISelectOneChoice.java    |  2 +-
 .../src/main/webapp/content/25-select/select.xhtml       |  2 +-
 .../renderkit/html/speyside/standard/style/tobago.less   | 14 ++++++++++++++
 .../standard/standard/tag/SelectManyBoxRenderer.java     |  9 ++++++++-
 .../standard/standard/tag/SelectOneChoiceRenderer.java   | 15 ++++++++++++++-
 .../html/standard/standard/script/tobago-select2.js      | 16 ++++------------
 .../renderkit/html/standard/standard/style/tobago.css    |  6 +++---
 7 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
index 34c9779..d42d95e 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
@@ -31,7 +31,7 @@ public abstract class AbstractUISelectOneChoice extends AbstractUISelectOneBase
     return false;
   }
 
-  public void setSelect2(Boolean bool) {
+  public void setSelect2(boolean bool) {
     getStateHelper().put(Select2Keys.isSelect2, bool);
   }
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
index ce08551..9b248bd 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
@@ -66,7 +66,7 @@
 
     <!-- code-sniplet-start id="selectOneChoice" -->
     <tx:selectOneChoice value="selectOneChoice0"
-                        label="Contact me1: "
+                        label="Select 2 single: "
                         select2="true">
       
       <tc:selectItem itemLabel="Letter" itemValue="letter"/>
diff --git a/tobago-theme/tobago-theme-speyside/src/main/less/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/tobago.less
b/tobago-theme/tobago-theme-speyside/src/main/less/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/tobago.less
index 3bcbc7f..95cf64a 100644
--- a/tobago-theme/tobago-theme-speyside/src/main/less/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/tobago.less
+++ b/tobago-theme/tobago-theme-speyside/src/main/less/org/apache/myfaces/tobago/renderkit/html/speyside/standard/style/tobago.less
@@ -1043,6 +1043,13 @@ input.tobago-time-markup-error, input.tobago-time-markup-fatal {
 
 /* select2 */
 
+.select2-container--default .select2-selection--single {
+  border: 1px solid darken(@borderColor, 10%);
+  font: @font;
+  .border-radius;
+  height: 20px;
+}
+
 .select2-container--default .select2-selection--single .select2-selection__rendered {
   color: @textColor;
   line-height: 18px;
@@ -1056,3 +1063,10 @@ input.tobago-time-markup-error, input.tobago-time-markup-fatal {
 .select2-container--default .select2-selection--single .select2-selection__arrow b {
   border-color: @textColor transparent transparent transparent;
 }
+
+.select2-container--default .select2-selection--multiple {
+  border: 1px solid darken(@borderColor, 10%);
+  font: @font;
+  .border-radius;
+
+}
\ No newline at end of file
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyBoxRenderer.java
b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyBoxRenderer.java
index 9ef2753..ddb1950 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyBoxRenderer.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectManyBoxRenderer.java
@@ -21,6 +21,7 @@ package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.UISelectManyBox;
 import org.apache.myfaces.tobago.component.UISelectManyListbox;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.SelectManyRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
@@ -61,11 +62,17 @@ public class SelectManyBoxRenderer extends SelectManyRendererBase {
     final Iterable<SelectItem> items = SelectItemUtils.getItemIterator(facesContext,
select);
     final boolean readonly = select.isReadonly();
     final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || readonly;
+    final Style style = new Style(facesContext, select);
 
     ComponentUtils.putDataAttribute(select, "tobago-select2", "{}");
 
 
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
+    writer.startElement(HtmlElements.DIV, select);
+    writer.writeStyleAttribute(style);
+    style.setTop(Measure.ZERO);
+    style.setLeft(Measure.ZERO);
+
     writer.startElement(HtmlElements.SELECT, select);
     writer.writeNameAttribute(id);
     writer.writeIdAttribute(id);
@@ -78,7 +85,6 @@ public class SelectManyBoxRenderer extends SelectManyRendererBase {
     if (tabIndex != null) {
       writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
     }
-    final Style style = new Style(facesContext, select);
     writer.writeStyleAttribute(style);
     writer.writeClassAttribute(Classes.create(select));
     writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
@@ -91,6 +97,7 @@ public class SelectManyBoxRenderer extends SelectManyRendererBase {
     HtmlRendererUtils.renderSelectItems(select, items, values, submittedValues, writer, facesContext);
 
     writer.endElement(HtmlElements.SELECT);
+    writer.endElement(HtmlElements.DIV);
   }
 
 }
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
index 13fab7d..8727d30 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SelectOneChoiceRenderer.java
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.UISelectOneChoice;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.HtmlUtils;
 import org.apache.myfaces.tobago.renderkit.SelectOneRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
@@ -64,6 +65,15 @@ public class SelectOneChoiceRenderer extends SelectOneRendererBase {
     final Iterable<SelectItem> items = SelectItemUtils.getItemIterator(facesContext,
select);
     final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
     final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || select.isReadonly();
+    final Style style = new Style(facesContext, select);
+
+    if (select.isSelect2()) {
+      writer.startElement(HtmlElements.DIV, select);
+      writer.writeStyleAttribute(style);
+      style.setTop(Measure.ZERO);
+      style.setLeft(Measure.ZERO);
+    }
+
 
     writer.startElement(HtmlElements.SELECT, select);
     writer.writeNameAttribute(id);
@@ -74,7 +84,6 @@ public class SelectOneChoiceRenderer extends SelectOneRendererBase {
     if (tabIndex != null) {
       writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
     }
-    final Style style = new Style(facesContext, select);
     writer.writeStyleAttribute(style);
     writer.writeClassAttribute(Classes.create(select));
     if (title != null) {
@@ -91,6 +100,10 @@ public class SelectOneChoiceRenderer extends SelectOneRendererBase {
         facesContext);
 
     writer.endElement(HtmlElements.SELECT);
+    if (select.isSelect2()) {
+      writer.endElement(HtmlElements.DIV);
+    }
+
     super.encodeEnd(facesContext, select);
   }
 }
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-select2.js
b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-select2.js
index fc94170..82f23dd 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-select2.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-select2.js
@@ -24,18 +24,10 @@ Tobago.Select2 = {
           var element = jQuery(this);
           var options = element.data("tobago-select2");
           console.info("typeof options: " + typeof options);
-          var value = {
-            minimumResultsForSearch: Infinity,
-            ts: "hallo",
-            tn: 22
-          };
-          console.info("XXXX : " + JSON.stringify(value));
-          options.containerCss = element.data("tobago-style");
-          options.dropdownCss = {
-            left: options.containerCss.left,
-            top: options.containerCss.top,
-            position: "absolute"
-          };
+
+          if (element.hasClass("tobago-selectManyBox")) {
+            options.containerCss = {height: element.data("tobago-style").height};
+          }
           console.info("Select2.init" + element.attr("id") + " with data: " + JSON.stringify(options));
// @DEV_ONLY
           element.select2(options);
         });
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
index 5dd9a27..6d49612 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
@@ -1,6 +1,6 @@
 /* select2 */
 
-.select2-container {
-  position: absolute;
-}
+/*.select2-container {*/
+  /*position: absolute;*/
+/*}*/
 


Mime
View raw message