List of usage examples for com.google.gwt.query.client GQuery html
public GQuery html(String html)
From source file:be.dramaix.ai.slidingpuzzle.client.Puzzle.java
License:Apache License
public void loadState(State s) { GQuery puzzle = SELECTOR.getPuzzleBoard(); puzzle.empty();// w w w.j a v a 2 s . c om byte[] board = s.getAllCells(); for (int i = 0; i < board.length; i++) { byte value = board[i]; GQuery cell = $("<div class='tile'></div>"); if (value == 0) { cell.addClass("empty"); } else { cell.html("" + value); } puzzle.append(cell); } // int puzzleDimension = TILE_DIMENSION * dimension; puzzle.height(puzzleDimension).width(puzzleDimension); }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private void setup() { boolean isHidden = false; containerId = buildContainerId();/*from w ww . j a v a 2 s . c o m*/ fWidth = $selectElement.outerWidth(); isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl"); // Temporary fix. IIf the select element is inside a hidden container // GQuery cannot get the size of the select element. if (fWidth == 0) { $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>"); GQuery tempDiv = $("#gwt_chosen_temp_div"); tempDiv.append($selectElement.clone()); fWidth = tempDiv.children("select").outerWidth(); tempDiv.remove(); isHidden = fWidth > 0; } String containerClass = getContainerClass(); String cssClasses = isRTL ? containerClass + " " + css.chznRtl() : containerClass; // recopy classes present on the select element cssClasses += " " + selectElement.getClassName(); GQuery containerTemp = $(ChosenTemplate.templates.container(containerId, cssClasses).asString()) .width(fWidth); final SafeStylesBuilder ssb = new SafeStylesBuilder(); if (isRTL) { ssb.right(HORIZONTAL_OFFSET, Style.Unit.PX); } else { ssb.left(HORIZONTAL_OFFSET, Style.Unit.PX); } ssb.top(VERTICAL_OFFSET, Style.Unit.PX); containerTemp.html(buildContainerHtml(defaultText, ssb).asString()); // insert container after the select elements $selectElement.hide().after(containerTemp); container = $("#" + containerId); container.addClass(isMultiple() ? css.chznContainerMulti() : css.chznContainerSingle()); dropdown = container.find("div." + css.chznDrop()).first(); int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden); dropdown.css("width", buildDropdownWidth(ddWidth)); searchField = container.find("input").first(); searchResults = container.find("ul." + css.chznResults()).first(); searchFieldScale(fWidth); initSearchElement(ddWidth, isHidden); resultsBuild(true); setTabIndex(); fireEvent(new ReadyEvent(this)); }
From source file:com.arcbees.chosen.client.ClientResultsFilter.java
License:Apache License
@Override public void filter(String searchText, ChosenImpl chosen, boolean isShowing) { ChosenOptions options = chosen.getOptions(); // TODO should be part of this object String regexAnchor = options.isSearchContains() ? "" : "^"; // escape reg exp special chars String escapedSearchText = regExpChars.replace(searchText, "\\$&"); RegExp regex = RegExp.compile(regexAnchor + escapedSearchText, "i"); RegExp zregex = RegExp.compile("(" + escapedSearchText + ")", "i"); int results = 0; List<SelectItem> selectItems = chosen.getSelectItems(); for (SelectItem item : selectItems) { if (item.isDisabled() || item.isEmpty()) { continue; }/*from w ww . j ava 2 s.c o m*/ if (item.isGroup()) { $('#' + item.getDomId()).css("display", "none"); } else { OptionItem option = (OptionItem) item; if (!(chosen.isMultiple() && option.isSelected())) { boolean found = false; String resultId = option.getDomId(); GQuery result = $("#" + resultId); String optionContent = option.getHtml(); if (optionContent == null || optionContent.trim().isEmpty()) { optionContent = option.getText(); } if (regex.test(optionContent)) { found = true; results++; } else if (optionContent.contains(" ") || optionContent.indexOf("[") == 0) { String[] parts = optionContent.replaceAll("\\[|\\]", "").split(" "); for (String part : parts) { if (regex.test(part)) { found = true; results++; } } } if (found) { String text; if (searchText.length() > 0) { text = zregex.replace(optionContent, "<em>$1</em>"); } else { text = optionContent; } result.html(text); chosen.resultActivate(result); if (option.getGroupArrayIndex() != -1) { $("#" + selectItems.get(option.getGroupArrayIndex()).getDomId()).css("display", "list-item"); } } else { if (chosen.getResultHighlight() != null && resultId.equals(chosen.getResultHighlight().attr("id"))) { chosen.resultClearHighlight(); } chosen.resultDeactivate(result); } } } } if (results < 1 && !searchText.isEmpty()) { chosen.noResults(searchText); } else { chosen.winnowResultsSetHighlight(); } if (isShowing) { chosen.positionDropdownResult(); } }
From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java
License:Apache License
private void setContent(GQuery inner) { String title = getTitle();//from www . j ava 2 s . c o m if (options.isHtml()) { inner.html(title); } else { inner.text(title); } }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private void setup() { boolean isHidden = false; containerId = buildContainerId();/* ww w . j a va 2 s . c o m*/ fWidth = $selectElement.outerWidth(); //Temporary fix. IIf the select element is inside a hidden container //GQuery cannot get the size of the select element. if (fWidth == 0) { $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>"); GQuery tempDiv = $("#gwt_chosen_temp_div"); tempDiv.append($selectElement.clone()); fWidth = tempDiv.children("select").outerWidth(); tempDiv.remove(); isHidden = fWidth > 0; } isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl"); String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer(); GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString()) .width(fWidth); if (isMultiple) { containerTemp.html(ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(), defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(), (isRTL ? "right" : "left")) .asString()); } else { containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(), defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), (isRTL ? "right" : "left")) .asString()); } // insert container after the select elements $selectElement.hide().after(containerTemp); container = $("#" + containerId); container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle()); dropdown = container.find("div." + css.chznDrop()).first(); int ddTop = container.height(); int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden); dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}")); searchField = container.find("input").first(); searchResults = container.find("ul." + css.chznResults()).first(); searchFieldScale(); if (isMultiple) { searchChoices = container.find("ul." + css.chznChoices()).first(); searchContainer = container.find("li." + css.searchField()).first(); } else { searchContainer = container.find("div." + css.chznSearch()).first(); selectedItem = container.find("." + css.chznSingle()).first(); int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden) - getSideBorderPadding(searchField, isHidden); searchField.css("width", searchFieldWidth + "px"); } resultsBuild(); setTabIndex(); fireEvent(new ReadyEvent(this)); }
From source file:com.watopi.chosen.client.ChosenImpl.java
License:Open Source License
private void winnowResults() { noResultClear();/*from w ww.ja v a 2s.c om*/ int results = 0; String searchText = defaultText.equals(searchField.val()) ? "" : searchField.val().trim(); searchText = SafeHtmlUtils.htmlEscape(searchText); String regexAnchor = options.isSearchContains() ? "" : "^"; // escape reg exp special chars String escapedSearchText = regExpChars.replace(searchText, "\\$&"); String test2 = "test"; test2.substring(1); RegExp regex = RegExp.compile(regexAnchor + escapedSearchText, "i"); RegExp zregex = RegExp.compile("(" + escapedSearchText + ")", "i"); for (int i = 0; i < selectItems.length(); i++) { SelectItem item = selectItems.get(i); if (item.isDisabled() || item.isEmpty()) { continue; } if (item.isGroup()) { $('#' + item.getDomId()).css("display", "none"); } else { OptionItem option = (OptionItem) item; if (!(isMultiple && option.isSelected())) { boolean found = false; String resultId = option.getDomId(); GQuery result = $("#" + resultId); String optionContent = option.getHtml(); if (regex.test(optionContent)) { found = true; results++; } else if (optionContent.indexOf(" ") >= 0 || optionContent.indexOf("[") == 0) { String[] parts = optionContent.replaceAll("\\[|\\]", "").split(" "); for (String part : parts) { if (regex.test(part)) { found = true; results++; } } } if (found) { String text; if (searchText.length() > 0) { text = zregex.replace(optionContent, "<em>$1</em>"); } else { text = optionContent; } result.html(text); resultActivate(result); if (option.getGroupArrayIndex() != -1) { $("#" + selectItems.get(option.getGroupArrayIndex()).getDomId()).css("display", "list-item"); } } else { if (resultHighlight != null && resultId.equals(resultHighlight.attr("id"))) { resultClearHighlight(); } resultDeactivate(result); } } } } if (results < 1 && searchText.length() > 0) { noResults(searchText); } else { winnowResultsSetHighlight(); } }
From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java
License:Apache License
private void setup() { boolean isHidden = false; containerId = buildContainerId();/* w w w. jav a 2 s . co m*/ fWidth = $selectElement.outerWidth(); //Temporary fix. IIf the select element is inside a hidden container //GQuery cannot get the size of the select element. if (fWidth == 0) { $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;" + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>"); GQuery tempDiv = $("#gwt_chosen_temp_div"); tempDiv.append($selectElement.clone()); fWidth = tempDiv.children("select").outerWidth(); tempDiv.remove(); isHidden = fWidth > 0; } isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl"); String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer(); GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString()) .width(fWidth); SafeStyles horizontalOffset = isRTL ? SafeStylesUtils.forRight(HORIZONTAL_OFFSET, Style.Unit.PX) : SafeStylesUtils.forLeft(HORIZONTAL_OFFSET, Style.Unit.PX); if (isMultiple) { containerTemp.html( ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(), defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(), horizontalOffset).asString()); } else { containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(), defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), horizontalOffset).asString()); } // insert container after the select elements $selectElement.hide().after(containerTemp); container = $("#" + containerId); container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle()); dropdown = container.find("div." + css.chznDrop()).first(); int ddTop = container.height(); int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden); dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}")); searchField = container.find("input").first(); searchResults = container.find("ul." + css.chznResults()).first(); searchFieldScale(); if (isMultiple) { searchChoices = container.find("ul." + css.chznChoices()).first(); searchContainer = container.find("li." + css.searchField()).first(); } else { searchContainer = container.find("div." + css.chznSearch()).first(); selectedItem = container.find("." + css.chznSingle()).first(); int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden) - getSideBorderPadding(searchField, isHidden); searchField.css("width", searchFieldWidth + "px"); } resultsBuild(); setTabIndex(); fireEvent(new ReadyEvent(this)); }
From source file:org.otalo.ao.client.widget.chlist.client.ChosenImpl.java
License:Apache License
private int getResults(String searchText) { int results = 0; String regexAnchor = options.isSearchContains() ? "" : "^"; // escape reg exp special chars String escapedSearchText = regExpChars.replace(searchText, "\\$&"); String test2 = "test"; test2.substring(1);//from w w w.j ava 2 s . c o m RegExp regex = RegExp.compile(regexAnchor + escapedSearchText, "i"); RegExp zregex = RegExp.compile("(" + escapedSearchText + ")", "i"); for (int i = 0; i < selectItems.length(); i++) { SelectItem item = selectItems.get(i); if (item.isDisabled() || item.isEmpty()) { continue; } if (item.isGroup()) { $('#' + item.getDomId()).css("display", "none"); } else { OptionItem option = (OptionItem) item; if (!(isMultiple && option.isSelected())) { boolean found = false; String resultId = option.getDomId(); GQuery result = $("#" + resultId); String optionContent = option.getHtml(); if (regex.test(optionContent)) { found = true; results++; } else if (optionContent.indexOf(" ") >= 0 || optionContent.indexOf("[") == 0) { String[] parts = optionContent.replaceAll("\\[|\\]", "").split(" "); for (String part : parts) { if (regex.test(part)) { found = true; results++; } } } if (found) { String text; if (searchText.length() > 0) { text = zregex.replace(optionContent, "<em>$1</em>"); } else { text = optionContent; } result.html(text); resultActivate(result); if (option.getGroupArrayIndex() != -1) { $("#" + selectItems.get(option.getGroupArrayIndex()).getDomId()).css("display", "list-item"); } } else { if (resultHighlight != null && resultId.equals(resultHighlight.attr("id"))) { resultClearHighlight(); } resultDeactivate(result); } } } } return results; }