You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LazyGQuery.java 40KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /*
  2. * Copyright 2009 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.google.gwt.query.client;
  17. import static com.google.gwt.query.client.plugins.Effects.Effects;
  18. import static com.google.gwt.query.client.plugins.Events.Events;
  19. import static com.google.gwt.query.client.plugins.Widgets.Widgets;
  20. import java.util.ArrayList;
  21. import java.util.Collection;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. import com.google.gwt.core.client.GWT;
  25. import com.google.gwt.core.client.JavaScriptObject;
  26. import com.google.gwt.core.client.JsArray;
  27. import com.google.gwt.core.client.JsArrayString;
  28. import com.google.gwt.dom.client.BodyElement;
  29. import com.google.gwt.dom.client.ButtonElement;
  30. import com.google.gwt.dom.client.Document;
  31. import com.google.gwt.dom.client.Element;
  32. import com.google.gwt.dom.client.IFrameElement;
  33. import com.google.gwt.dom.client.InputElement;
  34. import com.google.gwt.dom.client.Node;
  35. import com.google.gwt.dom.client.NodeList;
  36. import com.google.gwt.dom.client.OptionElement;
  37. import com.google.gwt.dom.client.SelectElement;
  38. import com.google.gwt.dom.client.Style.Display;
  39. import com.google.gwt.dom.client.TextAreaElement;
  40. import com.google.gwt.query.client.css.CssProperty;
  41. import com.google.gwt.query.client.css.Length;
  42. import com.google.gwt.query.client.css.Percentage;
  43. import com.google.gwt.query.client.css.TakesLength;
  44. import com.google.gwt.query.client.css.TakesPercentage;
  45. import com.google.gwt.query.client.impl.DocumentStyleImpl;
  46. import com.google.gwt.query.client.plugins.EventsListener;
  47. import com.google.gwt.user.client.DOM;
  48. import com.google.gwt.user.client.Event;
  49. import com.google.gwt.user.client.EventListener;
  50. import com.google.gwt.user.client.Window;
  51. import com.google.gwt.user.client.ui.Widget;
  52. import com.google.gwt.query.client.LazyBase;
  53. public interface LazyGQuery<T> extends LazyBase<T>{
  54. /**
  55. * Add elements to the set of matched elements if they are not included yet.
  56. * It also update the selector appending the new one.
  57. */
  58. LazyGQuery<T> add(GQuery previousObject);
  59. /**
  60. * Add elements to the set of matched elements if they are not included yet.
  61. */
  62. LazyGQuery<T> add(String selector);
  63. /**
  64. * Adds the specified classes to each matched element.
  65. */
  66. LazyGQuery<T> addClass(String... classes);
  67. /**
  68. * Insert content after each of the matched elements. The elements must
  69. * already be inserted into the document (you can't insert an element after
  70. * another if it's not in the page).
  71. */
  72. LazyGQuery<T> after(GQuery query);
  73. /**
  74. * Insert content after each of the matched elements. The elements must
  75. * already be inserted into the document (you can't insert an element after
  76. * another if it's not in the page).
  77. */
  78. LazyGQuery<T> after(Node n);
  79. /**
  80. * Insert content after each of the matched elements. The elements must
  81. * already be inserted into the document (you can't insert an element after
  82. * another if it's not in the page).
  83. */
  84. LazyGQuery<T> after(String html);
  85. /**
  86. * Add the previous selection to the current selection. Useful for traversing
  87. * elements, and then adding something that was matched before the last
  88. * traversal.
  89. */
  90. LazyGQuery<T> andSelf();
  91. /**
  92. * Append content to the inside of every matched element. This operation is
  93. * similar to doing an appendChild to all the specified elements, adding them
  94. * into the document.
  95. */
  96. LazyGQuery<T> append(GQuery query);
  97. /**
  98. * Append content to the inside of every matched element. This operation is
  99. * similar to doing an appendChild to all the specified elements, adding them
  100. * into the document.
  101. */
  102. LazyGQuery<T> append(Node n);
  103. /**
  104. * Append content to the inside of every matched element. This operation is
  105. * similar to doing an appendChild to all the specified elements, adding them
  106. * into the document.
  107. */
  108. LazyGQuery<T> append(String html);
  109. /**
  110. * All of the matched set of elements will be inserted at the end
  111. * of the element(s) specified by the parameter other.
  112. *
  113. * The operation $(A).appendTo(B) is, essentially, the reverse of doing a regular
  114. * $(A).append(B), instead of appending B to A, you're appending A to B.
  115. */
  116. LazyGQuery<T> appendTo(GQuery other);
  117. /**
  118. * All of the matched set of elements will be inserted at the end
  119. * of the element(s) specified by the parameter other.
  120. *
  121. * The operation $(A).appendTo(B) is, essentially, the reverse of doing a regular
  122. * $(A).append(B), instead of appending B to A, you're appending A to B.
  123. */
  124. LazyGQuery<T> appendTo(Node n);
  125. /**
  126. * All of the matched set of elements will be inserted at the end
  127. * of the element(s) specified by the parameter other.
  128. *
  129. * The operation $(A).appendTo(B) is, essentially, the reverse of doing a regular
  130. * $(A).append(B), instead of appending B to A, you're appending A to B.
  131. */
  132. LazyGQuery<T> appendTo(String html);
  133. /**
  134. * Convert to Plugin interface provided by Class literal.
  135. */
  136. <T extends GQuery> T as(Class<T> plugin);
  137. /**
  138. * Return a GWT Widget containing the first matched element.
  139. *
  140. * If the element is already associated to a widget it returns the original widget,
  141. * otherwise a new GWT widget will be created depending on the tagName.
  142. *
  143. */
  144. Widget asWidget();
  145. /**
  146. * Set a key/value object as properties to all matched elements.
  147. *
  148. * Example: $("img").attr(new Properties("src: 'test.jpg', alt: 'Test Image'"))
  149. */
  150. LazyGQuery<T> attr(Properties properties);
  151. /**
  152. * Access a property on the first matched element. This method makes it easy
  153. * to retrieve a property value from the first matched element. If the element
  154. * does not have an attribute with such a name, undefined is returned.
  155. * Attributes include title, alt, src, href, width, style, etc.
  156. */
  157. String attr(String name);
  158. /**
  159. * Set a single property to a computed value, on all matched elements.
  160. */
  161. LazyGQuery<T> attr(String key, Function closure);
  162. /**
  163. * Set a single property to a value, on all matched elements.
  164. */
  165. LazyGQuery<T> attr(String key, String value);
  166. /**
  167. * Insert content before each of the matched elements. The elements must
  168. * already be inserted into the document (you can't insert an element before
  169. * another if it's not in the page).
  170. */
  171. LazyGQuery<T> before(GQuery query);
  172. /**
  173. * Insert content before each of the matched elements. The elements must
  174. * already be inserted into the document (you can't insert an element before
  175. * another if it's not in the page).
  176. */
  177. LazyGQuery<T> before(Node n);
  178. /**
  179. * Insert content before each of the matched elements. The elements must
  180. * already be inserted into the document (you can't insert an element before
  181. * another if it's not in the page).
  182. */
  183. LazyGQuery<T> before(String html);
  184. /**
  185. * Binds a set of handlers to a particular Event for each matched element.
  186. *
  187. * The event handlers are passed as Functions that you can use to prevent
  188. * default behavior. To stop both default action and event bubbling, the
  189. * function event handler has to return false.
  190. *
  191. * You can pass an additional Object data to your Function as the second
  192. * parameter
  193. *
  194. */
  195. LazyGQuery<T> bind(int eventbits, Object data, Function...funcs);
  196. /**
  197. * Bind a set of functions to the blur event of each matched element.
  198. * Or trigger the event if no functions are provided.
  199. */
  200. LazyGQuery<T> blur(Function...f);
  201. /**
  202. * Bind a set of functions to the change event of each matched element.
  203. * Or trigger the event if no functions are provided.
  204. */
  205. LazyGQuery<T> change(Function...f);
  206. /**
  207. * Get a set of elements containing all of the unique immediate children of
  208. * each of the matched set of elements. Also note: while parents() will look
  209. * at all ancestors, children() will only consider immediate child elements.
  210. */
  211. LazyGQuery<T> children();
  212. /**
  213. * Get a set of elements containing all of the unique children of each of the
  214. * matched set of elements. This set is filtered with the expressions that
  215. * will cause only elements matching any of the selectors to be collected.
  216. */
  217. LazyGQuery<T> children(String... filters);
  218. /**
  219. * Bind a set of functions to the click event of each matched element.
  220. * Or trigger the event if no functions are provided.
  221. */
  222. LazyGQuery<T> click(Function...f);
  223. /**
  224. * Returns the inner height of the first matched element, including padding
  225. * but not the vertical scrollbar height, border, or margin.
  226. */
  227. int clientHeight();
  228. /**
  229. * Returns the inner width of the first matched element, including padding
  230. * but not the vertical scrollbar width, border, or margin.
  231. */
  232. int clientWidth();
  233. /**
  234. * Clone matched DOM Elements and select the clones. This is useful for moving
  235. * copies of the elements to another location in the DOM.
  236. */
  237. LazyGQuery<T> clone();
  238. /**
  239. * Filter the set of elements to those that contain the specified text.
  240. */
  241. LazyGQuery<T> contains(String text);
  242. /**
  243. * Find all the child nodes inside the matched elements (including text
  244. * nodes), or the content document, if the element is an iframe.
  245. */
  246. LazyGQuery<T> contents();
  247. /**
  248. * Set a key/value object as style properties to all matched elements. This
  249. * serves as the best way to set a large number of style properties on all
  250. * matched elements.
  251. *
  252. * Example: $(".item").css(Properties.create("color: 'red', background:
  253. * 'blue'"))
  254. */
  255. LazyGQuery<T> css(Properties properties);
  256. /**
  257. * Return a style property on the first matched element.
  258. */
  259. String css(String name);
  260. /**
  261. * Return a style property on the first matched element.
  262. *
  263. * The parameter force has a special meaning here:
  264. * - When force is false, returns the value of the css property defined
  265. * in the style attribute of the element.
  266. * - Otherwise it returns the real computed value.
  267. *
  268. * For instance if you define 'display=none' not in the element style
  269. * but in the css stylesheet, it returns an empty string unless you
  270. * pass the parameter force=true.
  271. */
  272. String css(String name, boolean force);
  273. /**
  274. * Set a single style property to a value, on all matched elements.
  275. */
  276. LazyGQuery<T> css(String prop, String val);
  277. /**
  278. * Set CSS property on every matched element using type-safe enumerations.
  279. */
  280. <S, T extends CssProperty<S>> LazyGQuery<T> css(T cssProperty, S value);
  281. /**
  282. * Set CSS property on every matched element using type-safe enumerations.
  283. */
  284. LazyGQuery<T> css(TakesLength cssProperty, Length value);
  285. /**
  286. * Set CSS property on every matched element using type-safe enumerations.
  287. */
  288. LazyGQuery<T> css(TakesPercentage cssProperty, Percentage value);
  289. /**
  290. * Returns value at named data store for the element, as set by data(name,
  291. * value).
  292. */
  293. Object data(String name);
  294. /**
  295. * Returns value at named data store for the element, as set by data(name,
  296. * value) with desired return type.
  297. *
  298. * @param clz return type class literal
  299. */
  300. <T> T data(String name, Class<T> clz);
  301. /**
  302. * Stores the value in the named spot with desired return type.
  303. */
  304. LazyGQuery<T> data(String name, Object value);
  305. /**
  306. * Bind a set of functions to the dblclick event of each matched element.
  307. * Or trigger the event if no functions are provided.
  308. */
  309. LazyGQuery<T> dblclick(Function...f);
  310. /**
  311. * Run one or more Functions over each element of the GQuery.
  312. * You have to override one of these funcions:
  313. * public void f(Element e)
  314. * public String f(Element e, int i)
  315. */
  316. LazyGQuery<T> each(Function... f);
  317. /**
  318. * Returns the working set of nodes as a Java array. <b>Do NOT</b> attempt to
  319. * modify this array, e.g. assign to its elements, or call Arrays.sort()
  320. */
  321. Element[] elements();
  322. /**
  323. * Remove all child nodes from the set of matched elements.
  324. * In the case of a document element, it removes all the content
  325. * You should call this method whenever you create a new iframe and you
  326. * want to add dynamic content to it.
  327. */
  328. LazyGQuery<T> empty();
  329. /**
  330. * Revert the most recent 'destructive' operation, changing the set of matched
  331. * elements to its previous state (right before the destructive operation).
  332. */
  333. LazyGQuery<T> end();
  334. /**
  335. * Reduce GQuery to element in the specified position.
  336. */
  337. LazyGQuery<T> eq(int pos);
  338. /**
  339. * Bind a set of functions to the error event of each matched element.
  340. * Or trigger the event if no functions are provided.
  341. */
  342. LazyGQuery<T> error(Function... f);
  343. /**
  344. * Fade in all matched elements by adjusting their opacity. The effect will
  345. * take 1000 milliseconds to complete
  346. */
  347. LazyGQuery<T> fadeIn(Function... f);
  348. /**
  349. * Fade in all matched elements by adjusting their opacity.
  350. */
  351. LazyGQuery<T> fadeIn(int millisecs, Function... f);
  352. /**
  353. * Fade out all matched elements by adjusting their opacity. The effect will
  354. * take 1000 milliseconds to complete
  355. */
  356. LazyGQuery<T> fadeOut(Function... f);
  357. /**
  358. * Fade out all matched elements by adjusting their opacity.
  359. */
  360. LazyGQuery<T> fadeOut(int millisecs, Function... f);
  361. /**
  362. * Removes all elements from the set of matched elements that do not match the
  363. * specified function. The function is called with a context equal to the
  364. * current element. If the function returns false, then the element is removed
  365. * - anything else and the element is kept.
  366. */
  367. LazyGQuery<T> filter(Predicate filterFn);
  368. /**
  369. * Removes all elements from the set of matched elements that do not pass the
  370. * specified css expression. This method is used to narrow down the results of
  371. * a search. Provide a comma-separated list of expressions to apply multiple
  372. * filters at once.
  373. */
  374. LazyGQuery<T> filter(String... filters);
  375. /**
  376. * Searches for all elements that match the specified css expression. This
  377. * method is a good way to find additional descendant elements with which to
  378. * process.
  379. *
  380. * Provide a comma-separated list of expressions to apply multiple filters at
  381. * once.
  382. */
  383. LazyGQuery<T> find(String... filters);
  384. /**
  385. * Reduce the set of matched elements to the first in the set.
  386. */
  387. LazyGQuery<T> first();
  388. /**
  389. * Bind a set of functions to the focus event of each matched element.
  390. * Or trigger the event if no functions are provided.
  391. */
  392. LazyGQuery<T> focus(Function...f);
  393. /**
  394. * Return all elements matched in the GQuery as a NodeList. @see #elements()
  395. * for a method which returns them as an immutable Java array.
  396. */
  397. NodeList<Element> get();
  398. /**
  399. * Return the ith element matched.
  400. */
  401. Element get(int i);
  402. /**
  403. * Return the previous set of matched elements prior to the last destructive
  404. * operation (e.g. query)
  405. */
  406. LazyGQuery<T> getPreviousObject();
  407. /**
  408. * Return the selector representing the current set of matched elements.
  409. */
  410. String getSelector();
  411. /**
  412. * Returns true any of the specified classes are present on any of the matched
  413. * Reduce the set of matched elements to all elements after a given position.
  414. * The position of the element in the set of matched elements starts at 0 and
  415. * goes to length - 1.
  416. */
  417. LazyGQuery<T> gt(int pos);
  418. /**
  419. * Returns true any of the specified classes are present on any of the matched
  420. * elements.
  421. */
  422. boolean hasClass(String... classes);
  423. /**
  424. * Get the current computed, pixel, height of the first matched element.
  425. */
  426. int height();
  427. /**
  428. * Set the height of every element in the matched set.
  429. */
  430. LazyGQuery<T> height(int height);
  431. /**
  432. * Set the height style property of every matched element. It's useful for
  433. * using 'percent' or 'em' units Example: $(".a").width("100%")
  434. */
  435. LazyGQuery<T> height(String height);
  436. /**
  437. * Make invisible all matched elements.
  438. */
  439. LazyGQuery<T> hide();
  440. /**
  441. * Bind a function to the mouseover event of each matched element. A method
  442. * for simulating hovering (moving the mouse on, and off, an object). This is
  443. * a custom method which provides an 'in' to a frequent task. Whenever the
  444. * mouse cursor is moved over a matched element, the first specified function
  445. * is fired. Whenever the mouse moves off of the element, the second specified
  446. * function fires.
  447. */
  448. LazyGQuery<T> hover(Function fover, Function fout);
  449. /**
  450. * Get the innerHTML of the first matched element.
  451. */
  452. String html();
  453. /**
  454. * Set the innerHTML of every matched element.
  455. */
  456. LazyGQuery<T> html(String html);
  457. /**
  458. * Find the index of the specified Element.
  459. */
  460. int index(Element element);
  461. /**
  462. * Insert all of the matched elements after another, specified, set of
  463. * elements.
  464. */
  465. LazyGQuery<T> insertAfter(Element elem);
  466. /**
  467. * Insert all of the matched elements after another, specified, set of
  468. * elements.
  469. */
  470. LazyGQuery<T> insertAfter(GQuery query);
  471. /**
  472. * Insert all of the matched elements after another, specified, set of
  473. * elements.
  474. */
  475. LazyGQuery<T> insertAfter(String selector);
  476. /**
  477. * Insert all of the matched elements before another, specified, set of
  478. * elements.
  479. *
  480. * The elements must already be inserted into the document (you can't insert
  481. * an element after another if it's not in the page).
  482. */
  483. LazyGQuery<T> insertBefore(Element item);
  484. /**
  485. * Insert all of the matched elements before another, specified, set of
  486. * elements.
  487. *
  488. * The elements must already be inserted into the document (you can't insert
  489. * an element after another if it's not in the page).
  490. */
  491. LazyGQuery<T> insertBefore(GQuery query);
  492. /**
  493. * Insert all of the matched elements before another, specified, set of
  494. * elements.
  495. *
  496. * The elements must already be inserted into the document (you can't insert
  497. * an element after another if it's not in the page).
  498. */
  499. LazyGQuery<T> insertBefore(String selector);
  500. /**
  501. * Checks the current selection against an expression and returns true, if at
  502. * least one element of the selection fits the given expression. Does return
  503. * false, if no element fits or the expression is not valid.
  504. */
  505. boolean is(String... filters);
  506. /**
  507. * Bind a set of functions to the keydown event of each matched element.
  508. * Or trigger the event if no functions are provided.
  509. */
  510. LazyGQuery<T> keydown(Function...f);
  511. /**
  512. * Trigger a keydown event passing the key pushed.
  513. */
  514. LazyGQuery<T> keydown(int key);
  515. /**
  516. * Bind a set of functions to the keypress event of each matched element.
  517. * Or trigger the event if no functions are provided.
  518. */
  519. LazyGQuery<T> keypress(Function...f);
  520. /**
  521. * Trigger a keypress event passing the key pushed.
  522. */
  523. LazyGQuery<T> keypress(int key);
  524. /**
  525. * Bind a set of functions to the keyup event of each matched element.
  526. * Or trigger the event if no functions are provided.
  527. */
  528. LazyGQuery<T> keyup(Function...f);
  529. /**
  530. * Trigger a keyup event passing the key pushed.
  531. */
  532. LazyGQuery<T> keyup(int key);
  533. /**
  534. * Reduce the set of matched elements to the final one in the set.
  535. */
  536. LazyGQuery<T> last();
  537. /**
  538. * Returns the computed left position of the first element matched.
  539. */
  540. int left();
  541. /**
  542. * Returns the number of elements currently matched. The size function will
  543. * return the same value.
  544. */
  545. int length();
  546. /**
  547. * Bind a function to the load event of each matched element.
  548. */
  549. LazyGQuery<T> load(Function f);
  550. /**
  551. * Reduce the set of matched elements to all elements before a given position.
  552. * The position of the element in the set of matched elements starts at 0 and
  553. * goes to length - 1.
  554. */
  555. LazyGQuery<T> lt(int pos);
  556. /**
  557. * Pass each element in the current matched set through a function,
  558. * producing a new array containing the return values.
  559. */
  560. <W> ArrayList<W> map(Function f);
  561. /**
  562. * Bind a set of functions to the mousedown event of each matched element.
  563. * Or trigger the event if no functions are provided.
  564. */
  565. LazyGQuery<T> mousedown(Function...f);
  566. /**
  567. * Bind a set of functions to the mousemove event of each matched element.
  568. * Or trigger the event if no functions are provided.
  569. */
  570. LazyGQuery<T> mousemove(Function...f);
  571. /**
  572. * Bind a set of functions to the mouseout event of each matched element.
  573. * Or trigger the event if no functions are provided.
  574. */
  575. LazyGQuery<T> mouseout(Function...f);
  576. /**
  577. * Bind a set of functions to the mouseover event of each matched element.
  578. * Or trigger the event if no functions are provided.
  579. */
  580. LazyGQuery<T> mouseover(Function...f);
  581. /**
  582. * Bind a set of functions to the mouseup event of each matched element.
  583. * Or trigger the event if no functions are provided.
  584. */
  585. LazyGQuery<T> mouseup(Function...f);
  586. /**
  587. * Get a set of elements containing the unique next siblings of each of the
  588. * given set of elements. next only returns the very next sibling for each
  589. * element, not all next siblings see {#nextAll}.
  590. */
  591. LazyGQuery<T> next();
  592. /**
  593. * Get a set of elements containing the unique next siblings of each of the
  594. * given set of elements filtered by 1 or more selectors. next only returns
  595. * the very next sibling for each element, not all next siblings see
  596. * {#nextAll}.
  597. */
  598. LazyGQuery<T> next(String... selectors);
  599. /**
  600. * Find all sibling elements after the current element.
  601. */
  602. LazyGQuery<T> nextAll();
  603. /**
  604. * Removes the specified Element from the set of matched elements. This method
  605. * is used to remove a single Element from a jQuery object.
  606. */
  607. LazyGQuery<T> not(Element elem);
  608. /**
  609. * Removes any elements inside the passed set of elements from the set of
  610. * matched elements.
  611. */
  612. LazyGQuery<T> not(GQuery gq);
  613. /**
  614. * Removes elements matching the specified expression from the set of matched
  615. * elements.
  616. */
  617. LazyGQuery<T> not(String... filters);
  618. /**
  619. * Get the current offset of the first matched element, in pixels, relative to
  620. * the document. The returned object contains two integer properties, top and
  621. * left. The method works only with visible elements.
  622. */
  623. com.google.gwt.query.client.GQuery.Offset offset();
  624. /**
  625. * Returns a GQuery collection with the positioned parent of the first matched
  626. * element. This is the first parent of the element that has position (as in
  627. * relative or absolute). This method only works with visible elements.
  628. */
  629. LazyGQuery<T> offsetParent();
  630. /**
  631. * Binds a handler to a particular Event (like Event.ONCLICK) for each matched
  632. * element. The handler is executed only once for each element.
  633. *
  634. * The event handler is passed as a Function that you can use to prevent
  635. * default behavior. To stop both default action and event bubbling, the
  636. * function event handler has to return false.
  637. *
  638. * You can pass an additional Object data to your Function as the second
  639. * parameter
  640. */
  641. LazyGQuery<T> one(int eventbits, Object data, Function f);
  642. /**
  643. * Get the current computed height for the first element in the set of matched elements,
  644. * including padding, border, but not the margin.
  645. */
  646. int outerHeight();
  647. /**
  648. * Get the current computed height for the first element in the set of matched elements,
  649. * including padding, border, and optionally margin.
  650. */
  651. int outerHeight(boolean includeMargin);
  652. /**
  653. * Get the current computed width for the first element in the set of matched elements,
  654. * including padding, border, but not the margin.
  655. */
  656. int outerWidth();
  657. /**
  658. * Get the current computed width for the first element in the set of matched elements,
  659. * including padding and border and optionally margin.
  660. */
  661. int outerWidth(boolean includeMargin);
  662. /**
  663. * Get a set of elements containing the unique parents of the matched set of
  664. * elements.
  665. */
  666. LazyGQuery<T> parent();
  667. /**
  668. * Get a set of elements containing the unique parents of the matched set of
  669. * elements. You may use an optional expressions to filter the set of parent
  670. * elements that will match one of them.
  671. */
  672. LazyGQuery<T> parent(String... filters);
  673. /**
  674. * Get a set of elements containing the unique ancestors of the matched set of
  675. * elements (except for the root element).
  676. */
  677. LazyGQuery<T> parents();
  678. /**
  679. * Get a set of elements containing the unique ancestors of the matched set of
  680. * elements (except for the root element). The matched elements are filtered,
  681. * returning those that match any of the filters.
  682. */
  683. LazyGQuery<T> parents(String... filters);
  684. /**
  685. * Gets the top and left position of an element relative to its offset parent.
  686. * The returned object contains two Integer properties, top and left. For
  687. * accurate calculations make sure to use pixel values for margins, borders
  688. * and padding. This method only works with visible elements.
  689. */
  690. com.google.gwt.query.client.GQuery.Offset position();
  691. /**
  692. * Prepend content to the inside of every matched element. This operation is
  693. * the best way to insert elements inside, at the beginning, of all matched
  694. * elements.
  695. */
  696. LazyGQuery<T> prepend(GQuery query);
  697. /**
  698. * Prepend content to the inside of every matched element. This operation is
  699. * the best way to insert elements inside, at the beginning, of all matched
  700. * elements.
  701. */
  702. LazyGQuery<T> prepend(Node n);
  703. /**
  704. * Prepend content to the inside of every matched element. This operation is
  705. * the best way to insert elements inside, at the beginning, of all matched
  706. * elements.
  707. */
  708. LazyGQuery<T> prepend(String html);
  709. /**
  710. * All of the matched set of elements will be inserted at the beginning
  711. * of the element(s) specified by the parameter other.
  712. *
  713. * The operation $(A).prependTo(B) is, essentially, the reverse of doing a regular
  714. * $(A).prepend(B), instead of prepending B to A, you're prepending A to B.
  715. */
  716. LazyGQuery<T> prependTo(GQuery other);
  717. /**
  718. * All of the matched set of elements will be inserted at the beginning
  719. * of the element(s) specified by the parameter other.
  720. *
  721. * The operation $(A).prependTo(B) is, essentially, the reverse of doing a regular
  722. * $(A).prepend(B), instead of prepending B to A, you're prepending A to B.
  723. */
  724. LazyGQuery<T> prependTo(Node n);
  725. /**
  726. * All of the matched set of elements will be inserted at the beginning
  727. * of the element(s) specified by the parameter other.
  728. *
  729. * The operation $(A).prependTo(B) is, essentially, the reverse of doing a regular
  730. * $(A).prepend(B), instead of prepending B to A, you're prepending A to B.
  731. */
  732. LazyGQuery<T> prependTo(String html);
  733. /**
  734. * Get a set of elements containing the unique previous siblings of each of
  735. * the matched set of elements. Only the immediately previous sibling is
  736. * returned, not all previous siblings.
  737. */
  738. LazyGQuery<T> prev();
  739. /**
  740. * Get a set of elements containing the unique previous siblings of each of
  741. * the matched set of elements filtered by selector. Only the immediately
  742. * previous sibling is returned, not all previous siblings.
  743. */
  744. LazyGQuery<T> prev(String... selectors);
  745. /**
  746. * Find all sibling elements in front of the current element.
  747. */
  748. LazyGQuery<T> prevAll();
  749. /**
  750. * Removes all matched elements from the DOM.
  751. */
  752. LazyGQuery<T> remove();
  753. /**
  754. * Remove the named attribute from every element in the matched set.
  755. */
  756. LazyGQuery<T> removeAttr(String key);
  757. /**
  758. * Removes the specified classes to each matched element.
  759. */
  760. LazyGQuery<T> removeClass(String... classes);
  761. /**
  762. * Removes named data store from an element.
  763. */
  764. LazyGQuery<T> removeData(String name);
  765. /**
  766. * Replaces the elements matched by the specified selector with the matched
  767. * elements. This function is the complement to replaceWith() which does the
  768. * same task with the parameters reversed.
  769. */
  770. LazyGQuery<T> replaceAll(Element elem);
  771. /**
  772. * Replaces the elements matched by the specified selector with the matched
  773. * elements. This function is the complement to replaceWith() which does the
  774. * same task with the parameters reversed.
  775. */
  776. LazyGQuery<T> replaceAll(GQuery query);
  777. /**
  778. * Replaces the elements matched by the specified selector with the matched
  779. * elements. This function is the complement to replaceWith() which does the
  780. * same task with the parameters reversed.
  781. */
  782. LazyGQuery<T> replaceAll(String html);
  783. /**
  784. * Replaces all matched elements with the specified HTML or DOM elements. This
  785. * returns the GQuery element that was just replaced, which has been removed
  786. * from the DOM.
  787. */
  788. LazyGQuery<T> replaceWith(Element elem);
  789. /**
  790. * Replaces all matched elements with the specified HTML or DOM elements. This
  791. * returns the GQuery element that was just replaced, which has been removed
  792. * from the DOM.
  793. */
  794. LazyGQuery<T> replaceWith(GQuery query);
  795. /**
  796. * Replaces all matched elements with the specified HTML or DOM elements. This
  797. * returns the GQuery element that was just replaced, which has been removed
  798. * from the DOM.
  799. */
  800. LazyGQuery<T> replaceWith(String html);
  801. /**
  802. * Save a set of Css properties of every matched element.
  803. */
  804. void restoreCssAttrs(String... cssProps);
  805. /**
  806. * Restore a set of previously saved Css properties in every matched element.
  807. */
  808. void saveCssAttrs(String... cssProps);
  809. /**
  810. * Bind a set of functions to the scroll event of each matched element.
  811. * Or trigger the event if no functions are provided.
  812. */
  813. LazyGQuery<T> scroll(Function...f);
  814. /**
  815. * Gets the scroll left offset of the first matched element. This method works
  816. * for both visible and hidden elements.
  817. */
  818. int scrollLeft();
  819. /**
  820. * When a value is passed in, the scroll left offset is set to that value on
  821. * all matched elements. This method works for both visible and hidden
  822. * elements.
  823. */
  824. LazyGQuery<T> scrollLeft(int left);
  825. /**
  826. * Gets the scroll top offset of the first matched element. This method works
  827. * for both visible and hidden elements.
  828. */
  829. int scrollTop();
  830. /**
  831. * When a value is passed in, the scroll top offset is set to that value on
  832. * all matched elements. This method works for both visible and hidden
  833. * elements.
  834. */
  835. LazyGQuery<T> scrollTop(int top);
  836. LazyGQuery<T> select();
  837. /**
  838. * Force the current matched set of elements to become
  839. * the specified array of elements.
  840. */
  841. LazyGQuery<T> setArray(NodeList<Element> nodes);
  842. /**
  843. * Set CSS property on the first element.
  844. */
  845. <S, T extends CssProperty<S>> LazyGQuery<T> setCss(T cssProperty, S value);
  846. /**
  847. * Set CSS property on first matched element using type-safe enumerations.
  848. */
  849. LazyGQuery<T> setCss(TakesLength cssProperty, Length value);
  850. /**
  851. * Set CSS property on first matched element using type-safe enumerations.
  852. */
  853. LazyGQuery<T> setCss(TakesPercentage cssProperty, Percentage value);
  854. void setPreviousObject(GQuery previousObject);
  855. void setSelector(String selector);
  856. /**
  857. * Return the number of elements in the matched set. Make visible all mached
  858. * elements
  859. */
  860. LazyGQuery<T> show();
  861. /**
  862. * Get a set of elements containing all of the unique siblings of each of the
  863. * matched set of elements.
  864. */
  865. LazyGQuery<T> siblings();
  866. /**
  867. * Get a set of elements containing all of the unique siblings of each of the
  868. * matched set of elements filtered by the provided set of selectors.
  869. */
  870. LazyGQuery<T> siblings(String... selectors);
  871. /**
  872. * Return the number of elements in the matched set.
  873. */
  874. int size();
  875. /**
  876. * Selects a subset of the matched elements.
  877. */
  878. LazyGQuery<T> slice(int start, int end);
  879. LazyGQuery<T> submit();
  880. /**
  881. * Return the text contained in the first matched element.
  882. */
  883. String text();
  884. /**
  885. * Set the innerText of every matched element.
  886. */
  887. LazyGQuery<T> text(String txt);
  888. /**
  889. * Toggle visibility of elements.
  890. */
  891. LazyGQuery<T> toggle();
  892. /**
  893. * Toggle among two or more function calls every other click.
  894. */
  895. LazyGQuery<T> toggle(Function... fn);
  896. /**
  897. * Adds or removes the specified classes to each matched element
  898. * depending on the class's presence.
  899. */
  900. LazyGQuery<T> toggleClass(String... classes);
  901. /**
  902. * Adds or removes the specified classes to each matched element
  903. * depending on the value of the switch argument.
  904. *
  905. * if addOrRemove is true, the class is added and in the case of
  906. * false it is removed.
  907. */
  908. LazyGQuery<T> toggleClass(String clz, boolean addOrRemove);
  909. /**
  910. * Returns the computed left position of the first element matched.
  911. */
  912. int top();
  913. /**
  914. * Produces a string representation of the matched elements.
  915. */
  916. String toString();
  917. /**
  918. * Produces a string representation of the matched elements.
  919. */
  920. String toString(boolean pretty);
  921. /**
  922. * Trigger a set of events on each matched element.
  923. *
  924. * For keyboard events you can pass a second parameter which represents
  925. * the key-code of the pushed key.
  926. *
  927. * Example: fire(Event.ONCLICK | Event.ONFOCUS)
  928. * Example: fire(Event.ONKEYDOWN. 'a');
  929. */
  930. LazyGQuery<T> trigger(int eventbits, int... keys);
  931. /**
  932. * Removes all events that match the eventbits.
  933. */
  934. LazyGQuery<T> unbind(int eventbits);
  935. /**
  936. * Remove all duplicate elements from an array of elements. Note that this
  937. * only works on arrays of DOM elements, not strings or numbers.
  938. */
  939. JSArray unique(JSArray result);
  940. /**
  941. * Gets the content of the value attribute of the first matched element,
  942. * returns only the first value even if it is a multivalued element. To get an
  943. * array of all values in multivalues elements use vals()
  944. *
  945. * When the first element is a radio-button and is not checked, then it looks
  946. * for a the first checked radio-button that has the same name in the list of
  947. * matched elements.
  948. */
  949. String val();
  950. /**
  951. * Sets the value attribute of every matched element In the case of multivalue
  952. * elements, all values are setted for other elements, only the first value is
  953. * considered.
  954. */
  955. LazyGQuery<T> val(String... values);
  956. /**
  957. * Gets the content of the value attribute of the first matched element,
  958. * returns more than one value if it is a multiple select.
  959. *
  960. * When the first element is a radio-button and is not checked, then it looks
  961. * for a the first checked radio-button that has the same name in the list of
  962. * matched elements.
  963. *
  964. * This method always returns an array. If no valid value can be determined
  965. * the array will be empty, otherwise it will contain one or more values.
  966. */
  967. String[] vals();
  968. /**
  969. * Return true if the first element is visible.
  970. */
  971. boolean visible();
  972. /**
  973. * Return the first non null attached widget from the matched elements
  974. * or null if there isn't any.
  975. */
  976. <W extends Widget> W widget();
  977. /**
  978. * return the list of attached widgets matching the query
  979. */
  980. List<Widget> widgets();
  981. /**
  982. * Get the current computed, pixel, width of the first matched element.
  983. */
  984. int width();
  985. /**
  986. * Set the width of every matched element.
  987. */
  988. LazyGQuery<T> width(int width);
  989. /**
  990. * Wrap each matched element with the specified HTML content. This wrapping
  991. * process is most useful for injecting additional structure into a document,
  992. * without ruining the original semantic qualities of a document. This works
  993. * by going through the first element provided (which is generated, on the
  994. * fly, from the provided HTML) and finds the deepest descendant element
  995. * within its structure -- it is that element that will enwrap everything
  996. * else.
  997. */
  998. LazyGQuery<T> wrap(Element elem);
  999. /**
  1000. * Wrap each matched element with the specified HTML content. This wrapping
  1001. * process is most useful for injecting additional structure into a document,
  1002. * without ruining the original semantic qualities of a document. This works
  1003. * by going through the first element provided (which is generated, on the
  1004. * fly, from the provided HTML) and finds the deepest descendant element
  1005. * within its structure -- it is that element that will enwrap everything
  1006. * else.
  1007. */
  1008. LazyGQuery<T> wrap(GQuery query);
  1009. /**
  1010. * Wrap each matched element with the specified HTML content. This wrapping
  1011. * process is most useful for injecting additional structure into a document,
  1012. * without ruining the original semantic qualities of a document. This works
  1013. * by going through the first element provided (which is generated, on the
  1014. * fly, from the provided HTML) and finds the deepest descendant element
  1015. * within its structure -- it is that element that will enwrap everything
  1016. * else.
  1017. */
  1018. LazyGQuery<T> wrap(String html);
  1019. /**
  1020. * Wrap all the elements in the matched set into a single wrapper element.
  1021. * This is different from .wrap() where each element in the matched set would
  1022. * get wrapped with an element. This wrapping process is most useful for
  1023. * injecting additional structure into a document, without ruining the
  1024. * original semantic qualities of a document.
  1025. *
  1026. * This works by going through the first element provided (which is generated,
  1027. * on the fly, from the provided HTML) and finds the deepest descendant
  1028. * element within its structure -- it is that element that will enwrap
  1029. * everything else.
  1030. */
  1031. LazyGQuery<T> wrapAll(Element elem);
  1032. /**
  1033. * Wrap all the elements in the matched set into a single wrapper element.
  1034. * This is different from .wrap() where each element in the matched set would
  1035. * get wrapped with an element. This wrapping process is most useful for
  1036. * injecting additional structure into a document, without ruining the
  1037. * original semantic qualities of a document.
  1038. *
  1039. * This works by going through the first element provided (which is generated,
  1040. * on the fly, from the provided HTML) and finds the deepest descendant
  1041. * element within its structure -- it is that element that will enwrap
  1042. * everything else.
  1043. */
  1044. LazyGQuery<T> wrapAll(GQuery query);
  1045. /**
  1046. * Wrap all the elements in the matched set into a single wrapper element.
  1047. * This is different from .wrap() where each element in the matched set would
  1048. * get wrapped with an element. This wrapping process is most useful for
  1049. * injecting additional structure into a document, without ruining the
  1050. * original semantic qualities of a document.
  1051. *
  1052. * This works by going through the first element provided (which is generated,
  1053. * on the fly, from the provided HTML) and finds the deepest descendant
  1054. * element within its structure -- it is that element that will enwrap
  1055. * everything else.
  1056. */
  1057. LazyGQuery<T> wrapAll(String html);
  1058. /**
  1059. * Wrap the inner child contents of each matched element (including text
  1060. * nodes) with an HTML structure. This wrapping process is most useful for
  1061. * injecting additional structure into a document, without ruining the
  1062. * original semantic qualities of a document. This works by going through the
  1063. * first element provided (which is generated, on the fly, from the provided
  1064. * HTML) and finds the deepest ancestor element within its structure -- it is
  1065. * that element that will enwrap everything else.
  1066. */
  1067. LazyGQuery<T> wrapInner(Element elem);
  1068. /**
  1069. * Wrap the inner child contents of each matched element (including text
  1070. * nodes) with an HTML structure. This wrapping process is most useful for
  1071. * injecting additional structure into a document, without ruining the
  1072. * original semantic qualities of a document. This works by going through the
  1073. * first element provided (which is generated, on the fly, from the provided
  1074. * HTML) and finds the deepest ancestor element within its structure -- it is
  1075. * that element that will enwrap everything else.
  1076. */
  1077. LazyGQuery<T> wrapInner(GQuery query);
  1078. /**
  1079. * Wrap the inner child contents of each matched element (including text
  1080. * nodes) with an HTML structure. This wrapping process is most useful for
  1081. * injecting additional structure into a document, without ruining the
  1082. * original semantic qualities of a document. This works by going through the
  1083. * first element provided (which is generated, on the fly, from the provided
  1084. * HTML) and finds the deepest ancestor element within its structure -- it is
  1085. * that element that will enwrap everything else.
  1086. */
  1087. LazyGQuery<T> wrapInner(String html);
  1088. }