@SuppressWarnings("unchecked") public <T> T setText(String t) { g.text(t); return (T) this; }
public String getText() { return g.text(); }
public <T extends Enum<T>> T getTextAsEnum(Class<T> clazz) { String t = g.text().trim(); return Enum.valueOf(clazz, t); }
public double getTextAsNumber() { String t = g.text().replaceAll("[^\\d\\.\\-]", ""); return t.isEmpty() ? 0 : Double.parseDouble(t); }
public boolean getTextAsBoolean() { String t = g.text().trim().toLowerCase(); return !t.matches("^(|false|off|0)$"); }
public Date getTextAsDate() { String t = g.text().trim(); if (t.matches("\\d+")) { return new Date(Long.parseLong(t)); } else { return new Date((long) JsDate.parse(t)); } }
protected void addChoice(OptionItem item) { selectedItem.find("span").text(item.getText()); if (allowSingleDeselect) { singleDeselectControlBuild(); } selectedValues.clear(); }
protected void addChoice(OptionItem item) { selectedItem.find("span").text(item.getText()); singleDeselectControlBuild(); selectedValues.clear(); }
protected void resetSelectedItem() { selectedItem.find("span").text(defaultText); selectedItem.addClass(css.chznDefault()); }
/** * Filter the set of elements to those that contain the specified text. */ public GQuery contains(String text) { JsNodeArray array = JsNodeArray.create(); for (Element e : elements) { if ($(e).text().contains(text)) { array.addNode(e); } } return $(array); }
protected void resetSelectedItem() { selectedItem.find("span").text(defaultText); selectedItem.addClass(css.chznDefault()); }
private void updateSelectedText() { String selectedText; if (choices > 1) { selectedText = getOptions().getManySelectedTextMultipleMobile(); } else if (choices == 1) { selectedText = getOptions().getOneSelectedTextMultipleMobile(); } else { selectedText = defaultText; } selectedText = selectedText.replace("{}", "" + choices); getSelectedItem().find("span").text(selectedText); } }
private void updateSelectedText() { String selectedText; if (choices > 1) { selectedText = getOptions().getManySelectedTextMultipleMobile(); } else { selectedText = getOptions().getOneSelectedTextMultipleMobile(); } selectedText = selectedText.replace("{}", "" + choices); getSelectedItem().find("span").text(selectedText); } }
@Override protected void searchFieldScale(int fWidth) { StringBuilder styleBlock = new StringBuilder("position:absolute; " + (isRTL() ? "right" : "left") + ": -1000px; top: -1000px; " + "visibility:hidden;"); String[] styleToCopy = {"font-size", "font-style", "font-weight", "font-family", "line-height", "text-transform", "letter-spacing"}; for (String style : styleToCopy) { styleBlock.append(style).append(':').append(getSearchField().css(style)).append(";"); } GQuery div = $("<div />").attr("style", styleBlock.toString()).text(getSearchField().val()); $("body").append(div); int w = div.width() + 25; div.remove(); if (w > fWidth - 10) { w = fWidth - 10; } getSearchField().css("width", w + "px"); }
private void searchFieldScale() { if (!isMultiple) { return; } StringBuilder styleBlock = new StringBuilder("position:absolute; " + (isRTL ? "right" : "left") + ": -1000px; top: -1000px; " + "visibility:hidden;"); String[] styleToCopy = { "font-size", "font-style", "font-weight", "font-family", "line-height", "text-transform", "letter-spacing"}; for (String style : styleToCopy) { styleBlock.append(style).append(':').append(searchField.css(style)); } GQuery div = $("<div />").attr("style", styleBlock.toString()).text(searchField.val()); $("body").append(div); int w = div.width() + 25; div.remove(); if (w > fWidth - 10) { w = fWidth - 10; } searchField.css("width", w + "px"); int ddTop = container.height(); dropdown.css("top", ddTop + "px"); }
@Override protected void searchFieldScale(int fWidth) { StringBuilder styleBlock = new StringBuilder("position:absolute; " + (isRTL() ? "right" : "left") + ": -1000px; top: -1000px; " + "visibility:hidden;"); String[] styleToCopy = {"font-size", "font-style", "font-weight", "font-family", "line-height", "text-transform", "letter-spacing"}; for (String style : styleToCopy) { styleBlock.append(style).append(':').append(getSearchField().css(style)).append(";"); } GQuery div = $("<div />").attr("style", styleBlock.toString()).text(getSearchField().val()); $("body").append(div); int w = div.width() + 25; div.remove(); if (w > fWidth - 10) { w = fWidth - 10; } getSearchField().css("width", w + "px"); }
private void resultsReset(Event e) { OptionElement firstoption = selectElement.getOptions().getItem(0); if (firstoption != null) { firstoption.setSelected(true); } selectedItem.find("span").text(defaultText); if (!isMultiple) { selectedItem.addClass(css.chznDefault()); } showSearchFieldDefault(); resultsResetCleanup(); fireEvent(new ChosenChangeEvent(null, 0, this)); if (activeField) { resultsHide(); } }
@Override protected void resultsBuild(boolean init, String defaultText, boolean customFilter) { getSelectedItem().addClass(getCss().chznDefault()).find("span").text(defaultText); if (!customFilter && getSelectElement().getOptions().getLength() <= getOptions().getDisableSearchThreshold()) { getContainer().addClass(getCss().chznContainerSingleNoSearch()); } else { getContainer().removeClass(getCss().chznContainerSingleNoSearch()); } super.resultsBuild(init, defaultText, customFilter); }
choiceBuild(item); } else { selectedItem.find("span").text(item.getText()); if (allowSingleDeselect) { singleDeselectControlBuild();
@Override protected void resultsBuild(boolean init, String defaultText, boolean customFilter) { getSelectedItem().addClass(getCss().chznDefault()).find("span").text(defaultText); if (!customFilter && getSelectElement().getOptions().getLength() <= getOptions().getDisableSearchThreshold()) { getContainer().addClass(getCss().chznContainerSingleNoSearch()); } else { getContainer().removeClass(getCss().chznContainerSingleNoSearch()); } super.resultsBuild(init, defaultText, customFilter); }