diff --git a/plugin/src/main/java/com/arcbees/chosen/client/ChosenOptions.java b/plugin/src/main/java/com/arcbees/chosen/client/ChosenOptions.java index 4da9d94..e7d66a9 100644 --- a/plugin/src/main/java/com/arcbees/chosen/client/ChosenOptions.java +++ b/plugin/src/main/java/com/arcbees/chosen/client/ChosenOptions.java @@ -49,14 +49,6 @@ public int getDisableSearchThreshold() { return disableSearchThreshold; } - public String getManySelectedTextMultipleMobile() { - return manySelectedTextMultipleMobile; - } - - public String getOneSelectedTextMultipleMobile() { - return oneSelectedTextMultipleMobile; - } - /** * Set the number of items needed to show and enable the search input. This option is when the Chosen component is * used in "multiple select" mode or when a custom ResultFilter is used. @@ -151,6 +143,10 @@ public ChosenOptions setMobileViewportMaxWidth(int mobileViewportMaxWidth) { return this; } + public String getOneSelectedTextMultipleMobile() { + return oneSelectedTextMultipleMobile; + } + /** * Set the text to use when one option is selected on a mobile multiple select. *

@@ -159,8 +155,13 @@ public ChosenOptions setMobileViewportMaxWidth(int mobileViewportMaxWidth) { * Ex: * options.setOneSelectedTextMultipleMobile("{} country selected"); */ - public void setOneSelectedTextMultipleMobile(String oneSelectedTextMultipleMobile) { + public ChosenOptions setOneSelectedTextMultipleMobile(String oneSelectedTextMultipleMobile) { this.oneSelectedTextMultipleMobile = oneSelectedTextMultipleMobile; + return this; + } + + public String getManySelectedTextMultipleMobile() { + return manySelectedTextMultipleMobile; } /** @@ -171,8 +172,9 @@ public void setOneSelectedTextMultipleMobile(String oneSelectedTextMultipleMobil * Ex: * options.setManySelectedTextMultipleMobile("{} countries selected"); */ - public void setManySelectedTextMultipleMobile(String manySelectedTextMultipleMobile) { + public ChosenOptions setManySelectedTextMultipleMobile(String manySelectedTextMultipleMobile) { this.manySelectedTextMultipleMobile = manySelectedTextMultipleMobile; + return this; } public String getNoResultsText() { diff --git a/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.java b/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.java index 8d3fa53..544d823 100644 --- a/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.java +++ b/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.java @@ -18,6 +18,7 @@ import com.arcbees.chosen.client.ChosenOptions; import com.arcbees.chosen.client.DropdownPosition; +import com.arcbees.chosen.sample.client.resources.ChosenCustomResources; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.event.logical.shared.AttachEvent; @@ -34,6 +35,7 @@ interface Binder extends UiBinder { } private static final Binder binder = GWT.create(Binder.class); + private static final ChosenCustomResources CUSTOM_RESOURCES = GWT.create(ChosenCustomResources.class); @UiField SelectElement allowSingleDeselect; @@ -50,11 +52,23 @@ interface Binder extends UiBinder { @UiField SelectElement dropdownPosition; @UiField + SelectElement dropdownResources; + @UiField SelectElement mobileWidth; @UiField SelectElement mobileAnimation; @UiField SelectElement mobileSpeed; + @UiField + SelectElement dropdownPlaceholder; + @UiField + SelectElement dropdownPlaceholderSingle; + @UiField + SelectElement dropdownPlaceholderMultiple; + @UiField + SelectElement mobileOneText; + @UiField + SelectElement mobileManyText; private final Widget widget; @@ -86,6 +100,18 @@ public void onAttachOrDetach(AttachEvent attachEvent) { $(dropdownPosition).as(Chosen).chosen( new ChosenOptions().setDropdownPosition(DropdownPosition.ABOVE)); + $(dropdownResources).as(Chosen).chosen( + new ChosenOptions().setResources(CUSTOM_RESOURCES)); + + $(dropdownPlaceholder).as(Chosen).chosen( + new ChosenOptions().setPlaceholderText("Well, hello!")); + + $(dropdownPlaceholderSingle).as(Chosen).chosen( + new ChosenOptions().setPlaceholderTextSingle("I'm single, ladies!")); + + $(dropdownPlaceholderMultiple).as(Chosen).chosen( + new ChosenOptions().setPlaceholderTextMultiple("I'm so multiple!")); + $(mobileWidth).as(Chosen).chosen( new ChosenOptions().setMobileViewportMaxWidth(2000)); @@ -94,6 +120,12 @@ public void onAttachOrDetach(AttachEvent attachEvent) { $(mobileSpeed).as(Chosen).chosen( new ChosenOptions().setMobileAnimationSpeed(1500)); + + $(mobileOneText).as(Chosen).chosen( + new ChosenOptions().setOneSelectedTextMultipleMobile("{} bear selected")); + + $(mobileManyText).as(Chosen).chosen( + new ChosenOptions().setManySelectedTextMultipleMobile("{} bears selected")); } } }); diff --git a/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.ui.xml b/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.ui.xml index f8d68a2..c1f0242 100644 --- a/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.ui.xml +++ b/sample/src/main/java/com/arcbees/chosen/sample/client/application/chosensample/ChosenOptionsView.ui.xml @@ -140,46 +140,18 @@ - searchContains - boolean - If - searchContains - equals false, search - will only match words starting with the query entered by the - user. Otherwise, the search will match words containing the - query. - - false - -

searchContains = true

- - - - - singleBackstrokeDelete - boolean - Indicates if a choice from a - multiple - select box can be deleted by pressing one backspace. If this - option is set to false (default), the first backspace selects - the last choice, the second removes it. + dropdownPosition + DropdownPosition + Sets the positioning of the dropdown. ABOVE, BELOW or AUTO. When auto is + selected, the dropdown will be displayed below the input box only if there's + enough vertical space below. Otherwise, the dropdown will be displayed above + the input box. - false + BELOW -

singleBackstrokeDelete = true

+

dropdownPosition = DropdownPosition.ABOVE

+ + + + + + + + + + + + + + placeholderTextSingle + String + Defines the text to display in the input when nothing is typed / selected. Will only + affect Single select. + + Select an Option + +

placeholderTextSingle = "I'm single, ladies!"

+ + + + + placeholderTextMultiple + String + Defines the text to display in the input when nothing is typed / selected. Will only + affect Multiple select. + + Select Some Options + +

placeholderTextMultiple = "I'm so multiple"

+ + + + + resources + Resources + Provides a custom resources file if you want to use your own styling. See the source + code for more details on how to implement it. + + + +

resources = CUSTOM_RESOURCES

+ + + + searchContains + boolean + If + searchContains + equals false, search + will only match words starting with the query entered by the + user. Otherwise, the search will match words containing the + query. + + false + +

searchContains = true

+ + + + + singleBackstrokeDelete + boolean + Indicates if a choice from a + multiple + select box can be deleted by pressing one backspace. If this + option is set to false (default), the first backspace selects + the last choice, the second removes it. + + false + +

singleBackstrokeDelete = true

+ + + oneSelectedTextMultipleMobile + String + Set the text to use when one option is selected on a mobile multiple select. + {} can be used in the text to indicate where to put the number of option + selected (in this case 1). + + {} item selected + +

oneSelectedTextMultipleMobile = "{} bears selected"

+ + + + + manySelectedTextMultipleMobile + String + Set the text to use when several options are selected on a mobile multiple select. + {} can be used in the text to indicate where to put the number of option + selected. + + {} items selected + +

manySelectedTextMultipleMobile = "{} bears selected"

+ + + diff --git a/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ChosenCustomResources.java b/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ChosenCustomResources.java new file mode 100644 index 0000000..33cb363 --- /dev/null +++ b/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ChosenCustomResources.java @@ -0,0 +1,33 @@ +/** + * Copyright 2015 ArcBees Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.arcbees.chosen.sample.client.resources; + +import com.arcbees.chosen.client.resources.ChosenCss; +import com.arcbees.chosen.client.resources.Resources; + +public interface ChosenCustomResources extends Resources { + interface CustomChosenCss extends ChosenCss { + } + + @Override + @Source({"com/arcbees/gsss/mixin/client/mixins.gss", + "com/arcbees/chosen/client/resources/icons/icons.gss", + "css/chosenCustomColors.gss", + "com/arcbees/chosen/client/resources/css/chosen.gss", + "com/arcbees/chosen/client/resources/css/mobile.gss"}) + CustomChosenCss css(); +} diff --git a/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ResourceLoader.java b/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ResourceLoader.java index a278676..7c00b79 100644 --- a/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ResourceLoader.java +++ b/sample/src/main/java/com/arcbees/chosen/sample/client/resources/ResourceLoader.java @@ -21,9 +21,11 @@ public class ResourceLoader { @Inject ResourceLoader( - AppResources appResources) { + AppResources appResources, + ChosenCustomResources chosenCustomResources) { appResources.normalize().ensureInjected(); appResources.style().ensureInjected(); appResources.grid().ensureInjected(); + chosenCustomResources.css().ensureInjected(); } } diff --git a/sample/src/main/resources/com/arcbees/chosen/sample/client/resources/css/chosenCustomColors.gss b/sample/src/main/resources/com/arcbees/chosen/sample/client/resources/css/chosenCustomColors.gss new file mode 100644 index 0000000..2b467a9 --- /dev/null +++ b/sample/src/main/resources/com/arcbees/chosen/sample/client/resources/css/chosenCustomColors.gss @@ -0,0 +1,21 @@ +@provide 'chosen-colors'; + +@def CHZN_C_PRIMARY #000; +@def CHZN_C_PRIMARY_STEP1 #080808; +@def CHZN_C_PRIMARY_STEP2 #111; +@def CHZN_C_PRIMARY_STEP3 #111; + +@def CHZN_C_SECONDARY #fff; +@def CHZN_C_SECONDARY_LIGHT #eee; +@def CHZN_C_SECONDARY_DARK #ddd; + +@def CHZN_C_CHOICE CHZN_C_PRIMARY; +@def CHZN_C_CHOICE_STEP1 CHZN_C_PRIMARY_STEP1; +@def CHZN_C_CHOICE_STEP2 CHZN_C_PRIMARY_STEP2; +@def CHZN_C_CHOICE_STEP3 CHZN_C_PRIMARY_STEP3; + +@def CHZN_C_TEXT #eee; +@def CHZN_C_TEXT_LIGHT #aaa; + +@def CHZN_C_BORDER #fff; +@def CHZN_C_HIGHLIGHT #444;