void winnowResultsSetHighlight() { if (resultHighlight == null) { GQuery selectedResults = querySelectedResults(); GQuery doHigh = selectedResults != null && selectedResults.length() > 0 ? selectedResults.first() : getFirstActive(); if (doHigh != null) { resultDoHighlight(doHigh); } } }
/** * Replaces the elements matched by the target with the selected elements. This function is the * complement to replaceWith() which does the same task with the parameters reversed. * * @return a {@link GQuery} object containing the new elements. */ public GQuery replaceAll(GQuery target) { // if there is only one element and it is not attached to the dom, we have // to clone it to be reused on each element of target (if target contains // more than one element) boolean mustBeCloned = length() == 1 && parents().filter("body").length() == 0; List<Element> newElements = new ArrayList<Element>(); for (int i = 0, l = target.size(); i < l; i++) { GQuery that = (i > 0 && mustBeCloned) ? this.clone() : this; $(target.get(i)).replaceWith(that); newElements.addAll(Arrays.asList(that.elements)); } return $(newElements); }
void winnowResultsSetHighlight() { if (resultHighlight == null) { GQuery selectedResults = querySelectedResults(); GQuery doHigh = selectedResults != null && selectedResults.length() > 0 ? selectedResults.first() : getFirstActive(); if (doHigh != null) { resultDoHighlight(doHigh); } } }
public void setAttribute(Element e, String name, Object value) { String tag = e.getNodeName(); if (NOT_AUTHORIZED_NODE.test(tag) && GQuery.$(e).parents("body").length() > 0) { // TODO maybe it's better to simply do nothing... throw new RuntimeException( "You cannot change type of button or input element if the element is already attached to the dom"); } if ("input".equals(tag.toLowerCase()) && "radio".equals(value)) { // some browser (IE6-9) resets value property of the input when you change the type to radio button InputElement ie = InputElement.as(e); String keepValue = ie.getValue(); super.setAttribute(ie, "type", value); ie.setValue(keepValue); } else { super.setAttribute(e, name, value); } } }
private boolean testActiveClick(Event e) { Element target = e.getEventTarget().cast(); GQuery $e = $(target); if ($e.parents("#" + containerId).length() > 0) { activeField = true; } else { closeField(); } return false; }
private boolean testActiveClick(Event e) { Element target = e.getEventTarget().cast(); GQuery $e = $(target); if ($e.parents("#" + containerId).length() > 0) { activeField = true; } else { closeField(); } return true; }
private boolean testActiveClick(Event e) { Element target = e.getEventTarget().cast(); GQuery $e = $(target); if ($e.parents("#" + containerId).length() > 0) { activeField = true; } else { closeField(); } return true; }
private boolean searchResultsMouseOut(Event e) { Element targetEl = e.getEventTarget().cast(); GQuery $e = $(targetEl); if ($e.hasClass(css.activeResult()) || $e.parents("." + css.activeResult()).length() > 0) { resultClearHighlight(); } return false; }
protected boolean searchResultsMouseOut(Event e) { Element targetEl = e.getEventTarget().cast(); GQuery $e = $(targetEl); if ($e.hasClass(css.activeResult()) || $e.parents("." + css.activeResult()).length() > 0) { resultClearHighlight(); } return false; }
protected boolean searchResultsMouseOut(Event e) { Element targetEl = e.getEventTarget().cast(); GQuery $e = $(targetEl); if ($e.hasClass(css.activeResult()) || $e.parents("." + css.activeResult()).length() > 0) { resultClearHighlight(); } return false; }
private void winnowResultsSetHighlight() { if (resultHighlight == null) { GQuery selectedResults = !isMultiple ? searchResults.find("." + css.resultSelected() + "." + css.activeResult()) : null; GQuery doHigh = selectedResults != null && selectedResults.length() > 0 ? selectedResults.first() : searchResults.find("." + css.activeResult()).first(); if (doHigh != null) { resultDoHighlight(doHigh); } } }
private boolean notHandleMouseDown(Element element, GqEvent mouseDownEvent) { boolean isNotBoutonLeft = mouseDownEvent.getButton() != NativeEvent.BUTTON_LEFT; Element eventTarget = mouseDownEvent.getEventTarget().cast(); boolean isElementCancel = false; if (options.getCancel() != null) { isElementCancel = $(eventTarget).parents().add($(eventTarget)).filter(options.getCancel()).length() > 0; } return isNotBoutonLeft || isElementCancel || !mouseCapture(element, mouseDownEvent); }
private void resultDoHighlight(GQuery el) { if (el == null || el.length() == 0) { return; } resultClearHighlight(); resultHighlight = el; resultHighlight.addClass(css.highlighted()); int maxHeight = (int) searchResults.cur("maxHeight", true); int visibleTop = searchResults.scrollTop(); int visibleBottom = maxHeight + visibleTop; int highTop = resultHighlight.position().top + searchResults.scrollTop(); int highBottom = highTop + resultHighlight.outerHeight(); if (highBottom >= visibleBottom) { int toScroll = highBottom - maxHeight; searchResults.scrollTop(toScroll > 0 ? toScroll : 0); } else if (highTop < visibleTop) { searchResults.scrollTop(highTop); } }
private void keyupArrow() { if (!resultsShowing && !isMultiple) { resultsShow(); } else if (resultHighlight != null) { // TODO should be replaced by : // GQuery prevSibs = resultHighlight.prevAll("li." + css.activeResult()); // but performance is bad... See http://code.google.com/p/gwtquery/issues/detail?id=146 GQuery prevSibling = resultHighlight.prev(); while (!prevSibling.isEmpty() && !prevSibling.is("li." + css.activeResult())) { prevSibling = prevSibling.prev(); } if (prevSibling.length() > 0) { resultDoHighlight(prevSibling.first()); } else { if (choices > 0) { resultsHide(); } resultClearHighlight(); } } }
protected void resultDoHighlight(GQuery el) { if (el == null || el.length() == 0 || isDetached(el)) { return; } resultClearHighlight(); resultHighlight = el; el.addClass(css.highlighted()); int searchResultHeight = searchResults.innerHeight(); int visibleTop = searchResults.scrollTop(); int visibleBottom = searchResultHeight + visibleTop; int highTop = resultHighlight.position().top + searchResults.scrollTop(); int highBottom = highTop + resultHighlight.outerHeight(); if (highBottom >= visibleBottom) { int toScroll = highBottom - searchResultHeight; searchResults.scrollTop(toScroll > 0 ? toScroll : 0); } else if (highTop < visibleTop) { searchResults.scrollTop(highTop); } }
protected void containerMouseDownImpl(Event e, GQuery element) { if (!activeField) { $(document).click(clickTestAction); resultsShow(); } else if (!element.isEmpty() && (element.get(0) == selectedItem.get(0) || element.parents("a." + css.chznSingle()).length() > 0)) { e.preventDefault(); resultsToggle(); } if (!element.hasClass(css.activeResult())) { activateField(); } }
protected void resultDoHighlight(GQuery el) { if (el == null || el.length() == 0 || isDetached(el)) { return; } resultClearHighlight(); resultHighlight = el; el.addClass(css.highlighted()); int searchResultHeight = searchResults.innerHeight(); int visibleTop = searchResults.scrollTop(); int visibleBottom = searchResultHeight + visibleTop; int highTop = resultHighlight.position().top + searchResults.scrollTop(); int highBottom = highTop + resultHighlight.outerHeight(); if (highBottom >= visibleBottom) { int toScroll = highBottom - searchResultHeight; searchResults.scrollTop(toScroll > 0 ? toScroll : 0); } else if (highTop < visibleTop) { searchResults.scrollTop(highTop); } }
protected void containerMouseDownImpl(Event e, GQuery element) { if (!activeField) { $(document).click(clickTestAction); resultsShow(); } else if (!element.isEmpty() && (element.get(0) == selectedItem.get(0) || element.parents("a." + css.chznSingle()).length() > 0)) { e.preventDefault(); resultsToggle(); } if (!element.hasClass(css.activeResult())) { activateField(); } }
private void keyupArrow() { if (!resultsShowing) { resultsShow(); } else if (isNotResultHighlighted()) { activateLastResult(); } else if (resultHighlight != null) { // TODO should be replaced by : // GQuery prevSibs = resultHighlight.prevAll("li." + css.activeResult()); // but performance is bad... See http://code.google.com/p/gwtquery/issues/detail?id=146 GQuery prevSibling = resultHighlight.prev(); while (!prevSibling.isEmpty() && !prevSibling.is("li." + css.activeResult())) { prevSibling = prevSibling.prev(); } if (prevSibling.length() > 0) { resultDoHighlight(prevSibling.first()); } else { if (choices > 0) { resultsHide(); } resultClearHighlight(); } } }
private void keyupArrow() { if (!resultsShowing) { resultsShow(); } else if (isNotResultHighlighted()) { activateLastResult(); } else if (resultHighlight != null) { // TODO should be replaced by : // GQuery prevSibs = resultHighlight.prevAll("li." + css.activeResult()); // but performance is bad... See http://code.google.com/p/gwtquery/issues/detail?id=146 GQuery prevSibling = resultHighlight.prev(); while (!prevSibling.isEmpty() && !prevSibling.is("li." + css.activeResult())) { prevSibling = prevSibling.prev(); } if (prevSibling.length() > 0) { resultDoHighlight(prevSibling.first()); } else { if (choices > 0) { resultsHide(); } resultClearHighlight(); } } }