Skip to content

Commit

Permalink
Merge pull request ArcBees#289 from ArcBees/jl_mobileMultipleFixPlace…
Browse files Browse the repository at this point in the history
…holder

Fix placeholder on mobile multiple
  • Loading branch information
jasonlemay committed Nov 4, 2015
2 parents 2f547d0 + 7ee4e5c commit bd4fe36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public abstract class ChosenImpl {
protected boolean resultsShowing;
protected GQuery searchChoices;
protected GQuery searchContainer;
protected String defaultText;
private GQuery $selectElement;
private boolean allowSingleDeselect;
private GQuery container;
private String containerId;
private ChosenCss css;
private List<String> selectedValues = new ArrayList<String>();
private String defaultText;
private GQuery dropdown;
private EventBus eventBus;
private int fWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected StringBuilder buildOptionStyleClass(OptionItem option) {
return classes;
}

@Override
protected void addChoice(OptionItem option) {
if (maxSelectedOptionsReached()) {
fireEvent(new MaxSelectedEvent(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import com.arcbees.chosen.client.SelectParser.OptionItem;
import com.arcbees.chosen.client.event.MaxSelectedEvent;
import com.google.gwt.dom.client.OptionElement;
import com.google.gwt.dom.client.SelectElement;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.user.client.Event;
import com.google.web.bindery.event.shared.EventBus;

public class MobileMultipleChosenImpl extends AbstractMobileChosenImpl {
@Override
Expand Down Expand Up @@ -48,6 +50,7 @@ protected void addChoice(OptionItem item) {
}
}

@Override
protected void resultDeactivate(GQuery query, boolean selected) {
if (!selected) {
super.resultDeactivate(query, selected);
Expand Down Expand Up @@ -87,6 +90,13 @@ protected void update() {
closeField();
}

@Override
protected void init(SelectElement element, ChosenOptions options, EventBus eventBus) {
super.init(element, options, eventBus);

updateSelectedText();
}

private void resultDeselect(OptionItem item, GQuery element) {
choices--;

Expand All @@ -111,8 +121,10 @@ private void updateSelectedText() {
String selectedText;
if (choices > 1) {
selectedText = getOptions().getManySelectedTextMultipleMobile();
} else {
} else if (choices == 1) {
selectedText = getOptions().getOneSelectedTextMultipleMobile();
} else {
selectedText = defaultText;
}

selectedText = selectedText.replace("{}", "" + choices);
Expand Down

0 comments on commit bd4fe36

Please sign in to comment.