Skip to content

EasingFunction type #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 31 additions & 53 deletions src/main/scala/io/udash/wrappers/jquery/JQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ trait JQuery extends js.Object {

/** Perform a custom animation of a set of CSS properties. <br/>
* See: <a href="http://api.jquery.com/animate/">jQuery Docs</a> */
private[jquery] def animate(properties: js.Dictionary[Any], duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def animate(properties: js.Dictionary[Any], duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Perform a custom animation of a set of CSS properties. <br/>
* See: <a href="http://api.jquery.com/animate/">jQuery Docs</a> */
Expand Down Expand Up @@ -218,23 +218,23 @@ trait JQuery extends js.Object {

/** Display the matched elements by fading them to opaque. <br/>
* See: <a href="http://api.jquery.com/fadeIn/">jQuery Docs</a> */
def fadeIn(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def fadeIn(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display the matched elements by fading them to opaque. <br/>
* See: <a href="http://api.jquery.com/fadeIn/">jQuery Docs</a> */
private[jquery] def fadeIn(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def fadeIn(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display the matched elements by fading them to opaque. <br/>
* See: <a href="http://api.jquery.com/fadeIn/">jQuery Docs</a> */
private[jquery] def fadeIn(options: js.Dictionary[Any]): JQuery = js.native

/** Hide the matched elements by fading them to transparent. <br/>
* See: <a href="http://api.jquery.com/fadeOut/">jQuery Docs</a> */
def fadeOut(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def fadeOut(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Hide the matched elements by fading them to transparent. <br/>
* See: <a href="http://api.jquery.com/fadeOut/">jQuery Docs</a> */
private[jquery] def fadeOut(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def fadeOut(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Hide the matched elements by fading them to transparent. <br/>
* See: <a href="http://api.jquery.com/fadeOut/">jQuery Docs</a> */
Expand All @@ -250,19 +250,19 @@ trait JQuery extends js.Object {

/** Adjust the opacity of the matched elements. <br/>
* See: <a href="http://api.jquery.com/fadeTo/">jQuery Docs</a> */
def fadeTo(duration: Int, opacity: Double, easing: String): JQuery = js.native
def fadeTo(duration: Int, opacity: Double, easing: EasingFunction): JQuery = js.native

/** Adjust the opacity of the matched elements. <br/>
* See: <a href="http://api.jquery.com/fadeTo/">jQuery Docs</a> */
private[jquery] def fadeTo(duration: Int, opacity: Double, easing:String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display or hide the matched elements by animating their opacity. <br/>
* See: <a href="http://api.jquery.com/fadeToggle/">jQuery Docs</a> */
def fadeToggle(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def fadeToggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display or hide the matched elements by animating their opacity. <br/>
* See: <a href="http://api.jquery.com/fadeToggle/">jQuery Docs</a> */
private[jquery] def fadeToggle(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def fadeToggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display or hide the matched elements by animating their opacity. <br/>
* See: <a href="http://api.jquery.com/fadeToggle/">jQuery Docs</a> */
Expand Down Expand Up @@ -336,11 +336,11 @@ trait JQuery extends js.Object {

/** Hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
def hide(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def hide(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
private[jquery] def hide(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def hide(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
Expand Down Expand Up @@ -729,11 +729,11 @@ trait JQuery extends js.Object {

/** Display the matched elements. <br/>
* See: <a href="http://api.jquery.com/show/">jQuery Docs</a> */
def show(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def show(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display the matched elements. <br/>
* See: <a href="http://api.jquery.com/show/">jQuery Docs</a> */
private[jquery] def show(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def show(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display the matched elements. <br/>
* See: <a href="http://api.jquery.com/show/">jQuery Docs</a> */
Expand All @@ -749,35 +749,35 @@ trait JQuery extends js.Object {

/** Display the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideDown/">jQuery Docs</a> */
def slideDown(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def slideDown(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideDown/">jQuery Docs</a> */
private[jquery] def slideDown(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def slideDown(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideDown/">jQuery Docs</a> */
private[jquery] def slideDown(options: js.Dictionary[Any]): JQuery = js.native

/** Display or hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideToggle/">jQuery Docs</a> */
def slideToggle(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def slideToggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display or hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideToggle/">jQuery Docs</a> */
private[jquery] def slideToggle(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def slideToggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display or hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideToggle/">jQuery Docs</a> */
private[jquery] def slideToggle(options: js.Dictionary[Any]): JQuery = js.native

/** Hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideUp/">jQuery Docs</a> */
def slideUp(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def slideUp(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideUp/">jQuery Docs</a> */
private[jquery] def slideUp(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def slideUp(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideUp/">jQuery Docs</a> */
Expand Down Expand Up @@ -813,11 +813,11 @@ trait JQuery extends js.Object {

/** Display or hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */
def toggle(duration: Int = js.native, easing: String = js.native): JQuery = js.native
def toggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native

/** Display or hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */
private[jquery] def toggle(duration: Int, easing: String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native
private[jquery] def toggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native

/** Display or hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */
Expand Down Expand Up @@ -919,28 +919,6 @@ object JQuery {

private val registrations: mutable.Map[Element, mutable.Buffer[CallbackRegistrationRef]] = mutable.Map[Element, mutable.Buffer[CallbackRegistrationRef]]()

case class AnimationOptions(duration: Option[Int] = None, easing: String = null, queue: Option[Boolean] = None,
step: (Int, js.Dynamic) => Any = null, progress: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Int, Int) => js.Any = null,
complete: () => js.Any = null, start: JQueryPromise[js.Function1[js.Any, js.Any], js.Any] => js.Any = null,
done: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null,
fail: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null,
always: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null) {
def toJSDictionary: js.Dictionary[Any] = {
val r = js.Dictionary[Any]()
if (duration.isDefined) r.update("duration", duration.get)
if (easing != null) r.update("easing", easing)
if (queue.isDefined) r.update("queue", queue.get)
if (step != null) r.update("step", step)
if (progress != null) r.update("progress", progress)
if (complete != null) r.update("complete", complete)
if (start != null) r.update("start", start)
if (done != null) r.update("done", done)
if (fail != null) r.update("fail", fail)
if (always != null) r.update("always", always)
r
}
}

implicit class JQueryWrapper(private val jquery: JQuery) {
import js.JSConverters._

Expand All @@ -964,7 +942,7 @@ object JQuery {

/** Perform a custom animation of a set of CSS properties. <br/>
* See: <a href="http://api.jquery.com/animate/">jQuery Docs</a> */
def animate(properties: Map[String, Any], duration: Int = 400, easing: String = "swing", callback: (Element) => Any = (_) => {}): JQuery = jquery.animate(properties.toJSDictionary, duration, easing, callback)
def animate(properties: Map[String, Any], duration: Int = 400, easing: EasingFunction = EasingFunction.swing, callback: (Element) => Any = (_) => {}): JQuery = jquery.animate(properties.toJSDictionary, duration, easing, callback)

/** Perform a custom animation of a set of CSS properties. <br/>
* See: <a href="http://api.jquery.com/animate/">jQuery Docs</a> */
Expand Down Expand Up @@ -1070,15 +1048,15 @@ object JQuery {

/** Display the matched elements by fading them to opaque. <br/>
* See: <a href="http://api.jquery.com/fadeIn/">jQuery Docs</a> */
def fadeIn(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.fadeIn(duration, easing, callback)
def fadeIn(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeIn(duration, easing, callback)

/** Display the matched elements by fading them to opaque. <br/>
* See: <a href="http://api.jquery.com/fadeIn/">jQuery Docs</a> */
def fadeIn(options: AnimationOptions): JQuery = jquery.fadeIn(options.toJSDictionary)

/** Hide the matched elements by fading them to transparent. <br/>
* See: <a href="http://api.jquery.com/fadeOut/">jQuery Docs</a> */
def fadeOut(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.fadeOut(duration, easing, callback)
def fadeOut(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeOut(duration, easing, callback)

/** Hide the matched elements by fading them to transparent. <br/>
* See: <a href="http://api.jquery.com/fadeOut/">jQuery Docs</a> */
Expand All @@ -1090,11 +1068,11 @@ object JQuery {

/** Adjust the opacity of the matched elements. <br/>
* See: <a href="http://api.jquery.com/fadeTo/">jQuery Docs</a> */
def fadeTo(duration: Int, opacity: Double, easing: String, callback: (Element) => Any): JQuery = jquery.fadeTo(duration, opacity, easing, callback)
def fadeTo(duration: Int, opacity: Double, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeTo(duration, opacity, easing, callback)

/** Display or hide the matched elements by animating their opacity. <br/>
* See: <a href="http://api.jquery.com/fadeToggle/">jQuery Docs</a> */
def fadeToggle(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.fadeToggle(duration, easing, callback)
def fadeToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeToggle(duration, easing, callback)

/** Display or hide the matched elements by animating their opacity. <br/>
* See: <a href="http://api.jquery.com/fadeToggle/">jQuery Docs</a> */
Expand Down Expand Up @@ -1142,7 +1120,7 @@ object JQuery {

/** Hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
def hide(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.hide(duration, easing, callback)
def hide(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.hide(duration, easing, callback)

/** Hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
Expand Down Expand Up @@ -1451,31 +1429,31 @@ object JQuery {

/** Display the matched elements. <br/>
* See: <a href="http://api.jquery.com/show/">jQuery Docs</a> */
def show(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.show(duration, easing, callback)
def show(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.show(duration, easing, callback)

/** Display the matched elements. <br/>
* See: <a href="http://api.jquery.com/hide/">jQuery Docs</a> */
def show(options: AnimationOptions): JQuery = jquery.show(options.toJSDictionary)

/** Display the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideDown/">jQuery Docs</a> */
def slideDown(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.slideDown(duration, easing, callback)
def slideDown(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideDown(duration, easing, callback)

/** Display the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideDown/">jQuery Docs</a> */
def slideDown(options: AnimationOptions): JQuery = jquery.slideDown(options.toJSDictionary)

/** Display or hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideToggle/">jQuery Docs</a> */
def slideToggle(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.slideToggle(duration, easing, callback)
def slideToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideToggle(duration, easing, callback)

/** Display or hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideToggle/">jQuery Docs</a> */
def slideToggle(options: AnimationOptions): JQuery = jquery.slideToggle(options.toJSDictionary)

/** Hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideUp/">jQuery Docs</a> */
def slideUp(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.slideUp(duration, easing, callback)
def slideUp(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideUp(duration, easing, callback)

/** Hide the matched elements with a sliding motion. <br/>
* See: <a href="http://api.jquery.com/slideUp/">jQuery Docs</a> */
Expand All @@ -1499,7 +1477,7 @@ object JQuery {

/** Display or hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */
def toggle(duration: Int, easing: String, callback: (Element) => Any): JQuery = jquery.toggle(duration, easing, callback)
def toggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.toggle(duration, easing, callback)

/** Display or hide the matched elements. <br/>
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */
Expand Down
20 changes: 0 additions & 20 deletions src/main/scala/io/udash/wrappers/jquery/JQueryHelpers.scala

This file was deleted.

1 change: 1 addition & 0 deletions src/main/scala/io/udash/wrappers/jquery/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import scala.scalajs.js.annotation.JSName
package object jquery {
/** See: <a href="http://api.jquery.com/category/selectors/">jQuery Docs</a> */
type Selector = String
type EasingFunction = String
type JQueryCallback = (Element, JQueryEvent) => Any

def jQ: JQueryStatic = js.Dynamic.global.jQuery.asInstanceOf[JQueryStatic]
Expand Down
Loading