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.

GwtQueryEffectsModule.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright 2011, The gwtquery team.
  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 gwtquery.samples.client;
  17. import static com.google.gwt.query.client.GQuery.$;
  18. import static com.google.gwt.query.client.GQuery.$$;
  19. import static com.google.gwt.query.client.GQuery.lazy;
  20. import com.google.gwt.core.client.EntryPoint;
  21. import com.google.gwt.dom.client.Element;
  22. import com.google.gwt.dom.client.Style.Position;
  23. import com.google.gwt.query.client.Function;
  24. import com.google.gwt.query.client.css.CSS;
  25. import com.google.gwt.query.client.css.Length;
  26. import com.google.gwt.query.client.css.RGBColor;
  27. import com.google.gwt.query.client.plugins.Effects;
  28. import com.google.gwt.query.client.plugins.PropertiesAnimation.Easing;
  29. import com.google.gwt.user.client.Event;
  30. public class GwtQueryEffectsModule implements EntryPoint {
  31. public void onModuleLoad() {
  32. $("div > div").css(CSS.COLOR.with(RGBColor.BLUE))
  33. .hover(lazy().css(CSS.COLOR.with(RGBColor.RED)).done(),
  34. lazy().css(CSS.COLOR.with(RGBColor.BLUE)).done());
  35. $("div.outer > div").css(CSS.POSITION.with(Position.RELATIVE)).dblclick(new Function() {
  36. public boolean f(Event e) {
  37. $("div.outer > div").as(Effects.Effects).
  38. animate($$("left: '+=100'"), 400, Easing.LINEAR).
  39. animate($$("top: '+=100'"), 400, Easing.LINEAR).
  40. animate($$("left: '-=100'"), 400, Easing.LINEAR).
  41. animate($$("top: '-=100'"), 400, Easing.LINEAR);
  42. return true;
  43. }
  44. });
  45. $(".note").click(lazy().fadeOut().done());
  46. $(".note").append(" Hello");
  47. final Effects a = $(".a, .b > div:nth-child(2)").as(Effects.Effects);
  48. final Effects b = $(".b > div:nth-child(odd)").as(Effects.Effects);
  49. $("#b0").width(150).css(CSS.FONT_SIZE.with(Length.px(10))).toggle(new Function() {
  50. public void f(Element e) {
  51. $("#b0").as(Effects.Effects).animate(" width: '400', opacity: '0.4', marginLeft: '0.6in', fontSize: '24px'");
  52. }
  53. }, new Function() {
  54. public void f(Element e) {
  55. $("#b0").as(Effects.Effects).animate(" width: '150', opacity: '1', marginLeft: '0', fontSize: '10px'");
  56. }
  57. });
  58. $("#b1").toggle(new Function() {
  59. public void f(Element e) {
  60. $(".a").toggle();
  61. }
  62. }, new Function() {
  63. public void f(Element e) {
  64. a.fadeOut();
  65. }
  66. }, new Function() {
  67. public void f(Element e) {
  68. a.fadeIn();
  69. }
  70. }, new Function() {
  71. public void f(Element e) {
  72. a.slideUp();
  73. }
  74. }, new Function() {
  75. public void f(Element e) {
  76. a.slideDown();
  77. }
  78. }, new Function() {
  79. public void f(Element e) {
  80. a.slideLeft();
  81. }
  82. }, new Function() {
  83. public void f(Element e) {
  84. a.slideRight();
  85. }
  86. }, new Function() {
  87. public void f(Element e) {
  88. a.animate("left: '+=300', width: 'hide'");
  89. }
  90. }, new Function() {
  91. public void f(Element e) {
  92. a.animate("left: '-=300', width: 'show'");
  93. }
  94. });
  95. $("#b2").toggle(new Function() {
  96. public void f(Element e) {
  97. b.as(Effects.Effects).clipUp();
  98. }
  99. }, new Function() {
  100. public void f(Element e) {
  101. b.as(Effects.Effects).clipDown();
  102. }
  103. }, new Function() {
  104. public void f(Element e) {
  105. b.as(Effects.Effects).clipDisappear();
  106. }
  107. }, new Function() {
  108. public void f(Element e) {
  109. b.as(Effects.Effects).clipAppear();
  110. }
  111. });
  112. }
  113. }