Skip to content

Commit 56acabe

Browse files
committed
Merge pull request #6 from UdashFramework/easing-consts
EasingFunction type
2 parents a9d2f90 + 78af322 commit 56acabe

File tree

4 files changed

+96
-73
lines changed

4 files changed

+96
-73
lines changed

src/main/scala/io/udash/wrappers/jquery/JQuery.scala

+31-53
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ trait JQuery extends js.Object {
5454

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

922-
case class AnimationOptions(duration: Option[Int] = None, easing: String = null, queue: Option[Boolean] = None,
923-
step: (Int, js.Dynamic) => Any = null, progress: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Int, Int) => js.Any = null,
924-
complete: () => js.Any = null, start: JQueryPromise[js.Function1[js.Any, js.Any], js.Any] => js.Any = null,
925-
done: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null,
926-
fail: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null,
927-
always: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => js.Any = null) {
928-
def toJSDictionary: js.Dictionary[Any] = {
929-
val r = js.Dictionary[Any]()
930-
if (duration.isDefined) r.update("duration", duration.get)
931-
if (easing != null) r.update("easing", easing)
932-
if (queue.isDefined) r.update("queue", queue.get)
933-
if (step != null) r.update("step", step)
934-
if (progress != null) r.update("progress", progress)
935-
if (complete != null) r.update("complete", complete)
936-
if (start != null) r.update("start", start)
937-
if (done != null) r.update("done", done)
938-
if (fail != null) r.update("fail", fail)
939-
if (always != null) r.update("always", always)
940-
r
941-
}
942-
}
943-
944922
implicit class JQueryWrapper(private val jquery: JQuery) {
945923
import js.JSConverters._
946924

@@ -964,7 +942,7 @@ object JQuery {
964942

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

15041482
/** Display or hide the matched elements. <br/>
15051483
* See: <a href="http://api.jquery.com/toggle/">jQuery Docs</a> */

src/main/scala/io/udash/wrappers/jquery/JQueryHelpers.scala

-20
This file was deleted.

src/main/scala/io/udash/wrappers/jquery/package.scala

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import scala.scalajs.js.annotation.JSName
99
package object jquery {
1010
/** See: <a href="http://api.jquery.com/category/selectors/">jQuery Docs</a> */
1111
type Selector = String
12+
type EasingFunction = String
1213
type JQueryCallback = (Element, JQueryEvent) => Any
1314

1415
def jQ: JQueryStatic = js.Dynamic.global.jQuery.asInstanceOf[JQueryStatic]

0 commit comments

Comments
 (0)