選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

JsQuery.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package gwtquery.jsquery.client;
  2. import gwtquery.jsquery.client.JQ.Dollar;
  3. import gwtquery.jsquery.client.JQ.JEasing;
  4. import gwtquery.jsquery.client.JQ.JFunction;
  5. import gwtquery.jsquery.client.JQ.JOffset;
  6. import gwtquery.jsquery.client.JQ.JPredicate;
  7. import com.google.gwt.core.client.EntryPoint;
  8. import com.google.gwt.core.client.GWT;
  9. import com.google.gwt.core.client.Scheduler;
  10. import com.google.gwt.user.client.Timer;
  11. import static com.google.gwt.user.client.Window.*;
  12. public class JsQuery implements EntryPoint {
  13. public void onModuleLoad() {
  14. // GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
  15. // public void onUncaughtException(Throwable e) {
  16. // String r = "";
  17. // for (StackTraceElement s :e.getStackTrace()) {
  18. // r += s + "\n";
  19. // }
  20. // Window.alert(r);
  21. // }
  22. // });
  23. GWT.create(JFunction.class);
  24. GWT.create(JPredicate.class);
  25. GWT.create(JOffset.class);
  26. GWT.create(JEasing.class);
  27. GWT.create(JQ.class);
  28. // new JQExporterImpl();
  29. GWT.create(Dollar.class);
  30. // new DollarExporterImpl();
  31. // System.out.println(testExtend("kaka"));
  32. JsMenu.loadPlugin();
  33. myJs();
  34. // onJsQueryLoad();
  35. }
  36. private native static void myJs() /*-{
  37. try {
  38. $ = $wnd.$;
  39. var options = {minWidth: 120, arrowSrc: 'arrow_right.gif', copyClassAttr: true, onClick: function(e, menuItem){
  40. alert('you clicked item "' + $(this).text() + '"');
  41. }};
  42. $('#menuone').menu(options);
  43. var items = [ {src: 'test', url:'http://www.jquery.com'},
  44. {src: ''}, // separator
  45. {src: 'test2', subMenu: [ {src: 'sub 1'},
  46. {src: 'sub 2', url: 'http://p.sohei.org', target: '_blank'},
  47. {src: 'sub 3'}]}];
  48. $('#menutwo').menu(options, items);
  49. $('#menuthree').menu(options);
  50. $('#menufive>img').menu(options, '#menufivelist');
  51. // creating a menu without items
  52. var menu = new $.Menu('#menufour', null, options);
  53. // adding items to the menu
  54. menu.addItems([
  55. new $.MenuItem({src: 'test', url:'http://www.jquery.com'}, options),
  56. new $.MenuItem({src: ''}) // separator
  57. ]);
  58. var itemWithSubmenu = new $.MenuItem({src: 'test2'}, options);
  59. // creating a menu with items (as child of itemWithSubmenu)
  60. new $.Menu(itemWithSubmenu, [
  61. new $.MenuItem({src: 'sub 1'}, options),
  62. new $.MenuItem({src: 'sub 2', url: 'http://p.sohei.org', target: '_blank'}, options),
  63. new $.MenuItem({src: 'sub 3'}, options)
  64. ], options);
  65. // adding the submenu to the main menu
  66. menu.addItem(itemWithSubmenu);
  67. } catch(e){alert(e);}
  68. }-*/;
  69. private native static String testExtend(String s) /*-{
  70. $wnd.$.extend({hola: function(){return s;}});
  71. return $wnd.$('*').hola();
  72. }-*/;
  73. private native static void onJsQueryLoad() /*-{
  74. $wnd.onJsQueryLoad && $wnd.onJsQueryLoad();
  75. $wnd.JsQuery && $wnd.JsQuery.onLoad && $wnd.JsQuery.onLoad();
  76. }-*/;
  77. }