forked from gwtbootstrap3/gwtbootstrap3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2987ef
commit 6380422
Showing
19 changed files
with
520 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
gwtbootstrap3/src/main/java/org/gwtbootstrap3/client/shared/js/EventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.gwtbootstrap3.client.shared.js; | ||
|
||
/* | ||
* #%L | ||
* GwtBootstrap3 | ||
* %% | ||
* Copyright (C) 2013 - 2018 GwtBootstrap3 | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import com.google.gwt.user.client.Event; | ||
|
||
import jsinterop.annotations.JsFunction; | ||
|
||
/** | ||
* EventHandler helper functional interface to trigger | ||
* Java event functions inside JavaScript | ||
* @author Thiago Ricciardi | ||
* | ||
*/ | ||
@JsFunction | ||
@FunctionalInterface | ||
public interface EventHandler { | ||
|
||
void callEventHandler(Event event); | ||
|
||
} |
155 changes: 155 additions & 0 deletions
155
gwtbootstrap3/src/main/java/org/gwtbootstrap3/client/shared/js/JQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package org.gwtbootstrap3.client.shared.js; | ||
|
||
/* | ||
* #%L | ||
* GwtBootstrap3 | ||
* %% | ||
* Copyright (C) 2013 - 2018 GwtBootstrap3 | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import com.google.gwt.dom.client.Element; | ||
|
||
import jsinterop.annotations.JsMethod; | ||
import jsinterop.annotations.JsPackage; | ||
import jsinterop.annotations.JsType; | ||
|
||
/** | ||
* jQuery and Bootstrap methods wrapper | ||
* @author Thiago Ricciardi | ||
* | ||
*/ | ||
@JsType(isNative=true, namespace=JsPackage.GLOBAL, name="jQuery") | ||
public class JQuery { | ||
|
||
/** | ||
* Create a JQuery object | ||
* @param element the element to jQuerify | ||
* @return JQuery object of element | ||
*/ | ||
@JsMethod(namespace=JsPackage.GLOBAL, name="jQuery") | ||
public static native JQuery jQuery(Element element); | ||
/** | ||
* Select jQuery elements and create a JQuery object | ||
* @param selector jQuery selector | ||
* @return JQuery object of elements selected | ||
*/ | ||
@JsMethod(namespace=JsPackage.GLOBAL, name="jQuery") | ||
public static native JQuery jQuery(String selector); | ||
|
||
/** | ||
* Bootstrap button() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery button(String method); | ||
|
||
/** | ||
* jQuery html() method | ||
* @param htmlString A string of HTML to set as the content of each matched element | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery html(String htmlString); | ||
|
||
/** | ||
* jQuery on() method | ||
* @param events One or more space-separated event types and optional namespaces, | ||
* such as "click" or "keydown.myPlugin" | ||
* @param function A function to execute when the event is triggered | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery on(String events, EventHandler function); | ||
|
||
/** | ||
* jQuery off() method | ||
* @param events One or more space-separated event types and optional namespaces, | ||
* or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin" | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery off(String events); | ||
|
||
/** | ||
* Bootstrap alert() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery alert(String method); | ||
|
||
/** | ||
* Bootstrap carousel() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery carousel(String method); | ||
/** | ||
* Bootstrap carousel() method | ||
* @param slideNumber particular frame (0 based, similar to an array) | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery carousel(int slideNumber); | ||
|
||
/** | ||
* Bootstrap collapse() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery collapse(String method); | ||
|
||
/** | ||
* Bootstrap modal() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery modal(String method); | ||
|
||
/** | ||
* Bootstrap popover() method | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery popover(); | ||
/** | ||
* Bootstrap popover() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery popover(String method); | ||
|
||
/** | ||
* Bootstrap scrollspy() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery scrollspy(String method); | ||
|
||
/** | ||
* Bootstrap tab() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery tab(String method); | ||
|
||
/** | ||
* Bootstrap tooltip() method | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery tooltip(); | ||
/** | ||
* Bootstrap tooltip() method | ||
* @param method the method string | ||
* @return JQuery object for chaining purposes | ||
*/ | ||
public native JQuery tooltip(String method); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.gwtbootstrap3.client.shared.event.AlertCloseHandler; | ||
import org.gwtbootstrap3.client.shared.event.AlertClosedEvent; | ||
import org.gwtbootstrap3.client.shared.event.AlertClosedHandler; | ||
import org.gwtbootstrap3.client.shared.js.JQuery; | ||
import org.gwtbootstrap3.client.ui.base.HasResponsiveness; | ||
import org.gwtbootstrap3.client.ui.base.HasType; | ||
import org.gwtbootstrap3.client.ui.base.button.CloseButton; | ||
|
@@ -239,25 +240,24 @@ public HandlerRegistration addClosedHandler(final AlertClosedHandler handler) { | |
} | ||
|
||
// @formatter:off | ||
private native void alert(final Element e, final String arg) /*-{ | ||
$wnd.jQuery(e).alert(arg); | ||
}-*/; | ||
private void alert(final Element e, final String arg) { | ||
JQuery.jQuery(e).alert(arg); | ||
} | ||
|
||
private native void bindJavaScriptEvents(final Element e) /*-{ | ||
var target = this; | ||
var $alert = $wnd.jQuery(e); | ||
private void bindJavaScriptEvents(final Element e) { | ||
JQuery alert = JQuery.jQuery(e); | ||
|
||
$alert.on('close.bs.alert', function (evt) { | ||
[email protected]::onClose(Lcom/google/gwt/user/client/Event;)(evt); | ||
alert.on("close.bs.alert", (evt) -> { | ||
onClose(evt); | ||
}); | ||
|
||
$alert.on('closed.bs.alert', function (evt) { | ||
[email protected]::onClosed(Lcom/google/gwt/user/client/Event;)(evt); | ||
alert.on("closed.bs.alert", (evt) -> { | ||
onClosed(evt); | ||
}); | ||
}-*/; | ||
} | ||
|
||
private native void unbindJavaScriptEvents(final Element e) /*-{ | ||
$wnd.jQuery(e).off('close.bs.alert'); | ||
$wnd.jQuery(e).off('closed.bs.alert'); | ||
}-*/; | ||
private void unbindJavaScriptEvents(final Element e) { | ||
JQuery.jQuery(e).off("close.bs.alert"); | ||
JQuery.jQuery(e).off("closed.bs.alert"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,16 @@ | |
import org.gwtbootstrap3.client.shared.event.CarouselSlidHandler; | ||
import org.gwtbootstrap3.client.shared.event.CarouselSlideEvent; | ||
import org.gwtbootstrap3.client.shared.event.CarouselSlideHandler; | ||
import org.gwtbootstrap3.client.shared.js.JQuery; | ||
import org.gwtbootstrap3.client.ui.constants.Attributes; | ||
import org.gwtbootstrap3.client.ui.constants.Styles; | ||
import org.gwtbootstrap3.client.ui.html.Div; | ||
|
||
import com.google.gwt.event.shared.HandlerRegistration; | ||
import com.google.gwt.user.client.Event; | ||
|
||
import jsinterop.annotations.JsMethod; | ||
|
||
/** | ||
* @author Joshua Godi | ||
*/ | ||
|
@@ -148,38 +151,32 @@ private void onSlid(final Event evt) { | |
fireEvent(new CarouselSlidEvent(this, evt)); | ||
} | ||
|
||
private native void bindJavaScriptEvents(final com.google.gwt.dom.client.Element e) /*-{ | ||
var target = this; | ||
var $carousel = $wnd.jQuery(e); | ||
private void bindJavaScriptEvents(final com.google.gwt.dom.client.Element e) { | ||
JQuery carousel = JQuery.jQuery(e); | ||
|
||
$carousel.on('slide.bs.carousel', function (evt) { | ||
[email protected]::onSlide(Lcom/google/gwt/user/client/Event;)(evt); | ||
carousel.on("slide.bs.carousel", (evt) -> { | ||
onSlide(evt); | ||
}); | ||
|
||
$carousel.on('slid.bs.carousel', function (evt) { | ||
[email protected]::onSlid(Lcom/google/gwt/user/client/Event;)(evt); | ||
}); | ||
}-*/; | ||
|
||
private native void unbindJavaScriptEvents(final com.google.gwt.dom.client.Element e) /*-{ | ||
$wnd.jQuery(e).off('slide.bs.carousel'); | ||
$wnd.jQuery(e).off('slid.bs.carousel'); | ||
}-*/; | ||
|
||
private native void carousel(final com.google.gwt.dom.client.Element e, final int interval, final String pause, | ||
final boolean wrap) /*-{ | ||
$wnd.jQuery(e).carousel({ | ||
interval: interval, | ||
pause: pause, | ||
wrap: wrap | ||
carousel.on("slid.bs.carousel", (evt) -> { | ||
onSlid(evt); | ||
}); | ||
}-*/; | ||
} | ||
|
||
private void unbindJavaScriptEvents(final com.google.gwt.dom.client.Element e) { | ||
JQuery.jQuery(e).off("slide.bs.carousel"); | ||
JQuery.jQuery(e).off("slid.bs.carousel"); | ||
} | ||
|
||
@JsMethod | ||
private static native void carousel(final com.google.gwt.dom.client.Element e, final int interval, final String pause, | ||
final boolean wrap); | ||
|
||
private native void fireMethod(final com.google.gwt.dom.client.Element e, String method) /*-{ | ||
$wnd.jQuery(e).carousel(method); | ||
}-*/; | ||
private void fireMethod(final com.google.gwt.dom.client.Element e, String method) { | ||
JQuery.jQuery(e).carousel(method); | ||
} | ||
|
||
private native void fireMethod(final com.google.gwt.dom.client.Element e, int slideNumber) /*-{ | ||
$wnd.jQuery(e).carousel(slideNumber); | ||
}-*/; | ||
private void fireMethod(final com.google.gwt.dom.client.Element e, int slideNumber) { | ||
JQuery.jQuery(e).carousel(slideNumber); | ||
} | ||
} |
Oops, something went wrong.