diff --git a/.travis.yml b/.travis.yml index b1875ab..632188e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ dist: trusty jdk: oraclejdk8 scala: - - 2.11.11 - - 2.12.2 + - 2.11.12 + - 2.12.6 before_script: - "export DISPLAY=:99.0" @@ -22,6 +22,6 @@ before_script: - export PATH=$PWD/selenium-bin:$PATH script: - - sbt ++$TRAVIS_SCALA_VERSION "set (jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Chrome))" test - - sbt ++$TRAVIS_SCALA_VERSION publishLocal - - cd example && sbt ++$TRAVIS_SCALA_VERSION compile \ No newline at end of file + - sbt ++$TRAVIS_SCALA_VERSION test + - sbt ++$TRAVIS_SCALA_VERSION +publishLocal + - cd example && sbt ++$TRAVIS_SCALA_VERSION compile fullOptJS \ No newline at end of file diff --git a/build.sbt b/build.sbt index 6dd6da8..090b491 100644 --- a/build.sbt +++ b/build.sbt @@ -1,37 +1,71 @@ +import org.openqa.selenium.chrome.ChromeOptions +import org.openqa.selenium.remote.DesiredCapabilities +import org.scalajs.jsenv.selenium.SeleniumJSEnv name := "udash-jquery" -version := "1.1.1" -organization := "io.udash" -scalaVersion := "2.12.2" -crossScalaVersions := Seq("2.11.11", "2.12.2") -scalacOptions in ThisBuild ++= Seq( - "-feature", - "-deprecation", - "-unchecked", - "-language:implicitConversions", - "-language:existentials", - "-language:dynamics", - "-Xfuture", - "-Xfatal-warnings", - CrossVersion.partialVersion(scalaVersion.value).collect { - // WORKAROUND https://github.com/scala/scala/pull/5402 - case (2, 12) => "-Xlint:-unused,_" - }.getOrElse("-Xlint:_") -) +inThisBuild(Seq( + version := "1.2.0", + organization := "io.udash", + scalaVersion := "2.12.6", + crossScalaVersions := Seq("2.11.12", "2.12.6"), + scalacOptions ++= Seq( + "-feature", + "-deprecation", + "-unchecked", + "-language:implicitConversions", + "-language:existentials", + "-language:dynamics", + "-language:postfixOps", + "-language:experimental.macros", + "-Xfuture", + "-Xfatal-warnings", + "-Xlint:_", + ), + scalacOptions ++= { + if (CrossVersion.partialVersion((root / scalaVersion).value).contains((2, 12))) Seq( + "-Ywarn-unused:_,-explicits,-implicits", + "-Ybackend-parallelism", "4", + "-Ycache-plugin-class-loader:last-modified", + "-Ycache-macro-class-loader:last-modified" + ) else Seq.empty + }, +)) + +// Settings for JS tests run in browser +val browserCapabilities: DesiredCapabilities = { + // requires ChromeDriver: https://sites.google.com/a/chromium.org/chromedriver/ + val capabilities = DesiredCapabilities.chrome() + capabilities.setCapability(ChromeOptions.CAPABILITY, { + val options = new ChromeOptions() + options.addArguments("--headless", "--disable-gpu") + options + }) + capabilities +} -jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Firefox()) +val commonJSSettings = Seq( + Compile / emitSourceMaps := true, + Test / parallelExecution := false, + Test / scalaJSStage := FastOptStage, + Test / jsEnv := new SeleniumJSEnv(browserCapabilities), + scalacOptions += { + val localDir = (ThisBuild / baseDirectory).value.toURI.toString + val githubDir = "https://raw.githubusercontent.com/UdashFramework/scala-js-jquery" + s"-P:scalajs:mapSourceURI:$localDir->$githubDir/v${version.value}/" + }, + scalacOptions += "-P:scalajs:sjsDefinedByDefault", +) libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.9.2", - "org.scalatest" %%% "scalatest" % "3.0.3" % Test, - "com.lihaoyi" %%% "scalatags" % "0.6.5" % Test + "org.scala-js" %%% "scalajs-dom" % "0.9.5", + "org.scalatest" %%% "scalatest" % "3.0.5" % Test, + "com.lihaoyi" %%% "scalatags" % "0.6.7" % Test ) jsDependencies += - "org.webjars" % "jquery" % "3.2.1" / "3.2.1/jquery.js" minified "3.2.1/jquery.min.js" - -requiresDOM in Test := true + "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" lazy val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) + .settings(commonJSSettings) diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..bacbfad --- /dev/null +++ b/example/README.md @@ -0,0 +1,4 @@ +### How to use? + +Run `sbt fastOptJS` or `sbt fullOptJS` to compile this demo. You can find all generated files +in the `generated` directory. Open `index.html` in your browser. diff --git a/example/build.sbt b/example/build.sbt index 3cbf20d..a6221fe 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -1,48 +1,61 @@ -import UdashBuild._ -import Dependencies._ - name := "jquery-demo" -version in ThisBuild := "1.1.0" -scalaVersion in ThisBuild := "2.12.2" -organization in ThisBuild := "io.udash" -crossPaths in ThisBuild := false -scalacOptions in ThisBuild ++= Seq( - "-feature", - "-deprecation", - "-unchecked", - "-language:implicitConversions", - "-language:existentials", - "-language:dynamics", - "-Xfuture", - "-Xfatal-warnings" -) +inThisBuild(Seq( + version := "1.2.0", + organization := "io.udash", + scalaVersion := "2.12.6", + scalacOptions ++= Seq( + "-feature", + "-deprecation", + "-unchecked", + "-language:implicitConversions", + "-language:existentials", + "-language:dynamics", + "-language:postfixOps", + "-Xfuture", + "-Xfatal-warnings", + "-Xlint:_", + ), + scalacOptions ++= { + if (CrossVersion.partialVersion((`jquery-demo` / scalaVersion).value).contains((2, 12))) Seq( + "-Ywarn-unused:_,-explicits,-implicits", + "-Ybackend-parallelism", "4", + "-Ycache-plugin-class-loader:last-modified", + "-Ycache-macro-class-loader:last-modified" + ) else Seq.empty + }, +)) val generatedDir = file("generated") +val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") val `jquery-demo` = project.in(file(".")).enablePlugins(ScalaJSPlugin) .settings( - libraryDependencies ++= deps.value, + libraryDependencies ++= Dependencies.deps.value, /* move these files out of target/. */ - crossTarget in (Compile, fullOptJS) := generatedDir, - crossTarget in (Compile, fastOptJS) := generatedDir, - crossTarget in (Compile, packageJSDependencies) := generatedDir, - crossTarget in (Compile, packageMinifiedJSDependencies) := generatedDir, + Compile / fullOptJS / crossTarget := generatedDir, + Compile / fastOptJS / crossTarget := generatedDir, + Compile / packageJSDependencies / crossTarget := generatedDir, + Compile / packageMinifiedJSDependencies / crossTarget := generatedDir, - compile := (compile in Compile).dependsOn(compileStatics).value, - compileStatics := { - compileStaticsForRelease.value - (crossTarget.value / StaticFilesDir).***.get - }, + Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value, + Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value, scalaJSUseMainModuleInitializer := true, - artifactPath in(Compile, fastOptJS) := - (crossTarget in(Compile, fastOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl-fast.js", - artifactPath in(Compile, fullOptJS) := - (crossTarget in(Compile, fullOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl.js", - artifactPath in(Compile, packageJSDependencies) := - (crossTarget in(Compile, packageJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps-fast.js", - artifactPath in(Compile, packageMinifiedJSDependencies) := - (crossTarget in(Compile, packageMinifiedJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps.js" + copyAssets := { + IO.copyFile( + sourceDirectory.value / "main/assets/index.html", + generatedDir / "index.html" + ) + }, + + Compile / fastOptJS / artifactPath := + (Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js", + Compile / fullOptJS / artifactPath := + (Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js", + Compile / packageJSDependencies / artifactPath := + (Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js", + Compile / packageMinifiedJSDependencies / artifactPath := + (Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js" ) \ No newline at end of file diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 946b5be..48bac51 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -2,8 +2,8 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import sbt._ object Dependencies { - val udashCoreVersion = "0.5.0" - val udashJQueryVersion = "1.1.0" + val udashCoreVersion = "0.6.1" + val udashJQueryVersion = "1.2.0" val deps = Def.setting(Seq[ModuleID]( "io.udash" %%% "udash-core-frontend" % udashCoreVersion, diff --git a/example/project/UdashBuild.scala b/example/project/UdashBuild.scala deleted file mode 100644 index f58e7c3..0000000 --- a/example/project/UdashBuild.scala +++ /dev/null @@ -1,36 +0,0 @@ -import org.scalajs.sbtplugin.ScalaJSPlugin.AutoImport._ -import sbt.Keys._ -import sbt._ - -object UdashBuild { - val StaticFilesDir = "UdashStatic" - val WebContent = "WebContent" - - def copyIndex(file: File, to: File) = { - val newFile = Path(to.toPath.toString + "/index.html") - IO.copyFile(file, newFile.asFile) - } - - val compileStatics = taskKey[Seq[File]]("Frontend static files manager.") - - val compileStaticsForRelease = Def.taskDyn { - def outDir(target: File) = target / StaticFilesDir / WebContent - if (!isSnapshot.value) { - Def.task { - val indexFile = sourceDirectory.value / "main/assets/index.prod.html" - copyIndex(indexFile, outDir((crossTarget in (Compile, fullOptJS)).value)) - (fullOptJS in Compile).value - (packageMinifiedJSDependencies in Compile).value - (packageScalaJSLauncher in Compile).value - } - } else { - Def.task { - val indexFile = sourceDirectory.value / "main/assets/index.dev.html" - copyIndex(indexFile, outDir((crossTarget in (Compile, fastOptJS)).value)) - (fastOptJS in Compile).value - (packageJSDependencies in Compile).value - (packageScalaJSLauncher in Compile).value - } - } - } -} \ No newline at end of file diff --git a/example/project/build.properties b/example/project/build.properties index 6be4958..c3e3abc 100644 --- a/example/project/build.properties +++ b/example/project/build.properties @@ -1 +1 @@ -sbt.version = 0.13.15 \ No newline at end of file +sbt.version = 1.1.4 \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt index 68fe409..293d135 100644 --- a/example/project/plugins.sbt +++ b/example/project/plugins.sbt @@ -1,2 +1,3 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18") \ No newline at end of file + +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") \ No newline at end of file diff --git a/example/src/main/assets/index.dev.html b/example/src/main/assets/index.dev.html deleted file mode 100644 index ce52d69..0000000 --- a/example/src/main/assets/index.dev.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - jquery-demo - development - - - - - - -
- - \ No newline at end of file diff --git a/example/src/main/assets/index.prod.html b/example/src/main/assets/index.html similarity index 98% rename from example/src/main/assets/index.prod.html rename to example/src/main/assets/index.html index 187b36d..fd8b57a 100644 --- a/example/src/main/assets/index.prod.html +++ b/example/src/main/assets/index.html @@ -6,7 +6,6 @@ -
diff --git a/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala b/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala index 118e345..f43d899 100644 --- a/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala +++ b/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala @@ -1,7 +1,6 @@ package io.udash.demos.jquery import io.udash._ -import io.udash.utils.Bidirectional class RoutingRegistryDef extends RoutingRegistry[RoutingState] { def matchUrl(url: Url): RoutingState = @@ -10,7 +9,7 @@ class RoutingRegistryDef extends RoutingRegistry[RoutingState] { def matchState(state: RoutingState): Url = Url(state2Url.apply(state)) - private val (url2State, state2Url) = Bidirectional[String, RoutingState] { + private val (url2State, state2Url) = bidirectional { case "" => IndexState case "/add" => AddState case "/addBack" => AddBackState diff --git a/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala b/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala index 0ff8f68..dee3a6e 100644 --- a/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala +++ b/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala @@ -4,8 +4,8 @@ import io.udash._ import io.udash.demos.jquery.views.functions._ import io.udash.demos.jquery.views.{ErrorViewPresenter, IndexViewPresenter, RootViewPresenter} -class StatesToViewPresenterDef extends ViewPresenterRegistry[RoutingState] { - def matchStateToResolver(state: RoutingState): ViewPresenter[_ <: RoutingState] = state match { +class StatesToViewPresenterDef extends ViewFactoryRegistry[RoutingState] { + def matchStateToResolver(state: RoutingState): ViewFactory[_ <: RoutingState] = state match { case RootState => RootViewPresenter case IndexState => IndexViewPresenter case AddState => AddViewPresenter diff --git a/example/src/main/scala/io/udash/demos/jquery/init.scala b/example/src/main/scala/io/udash/demos/jquery/init.scala index 30d7f4b..549798b 100644 --- a/example/src/main/scala/io/udash/demos/jquery/init.scala +++ b/example/src/main/scala/io/udash/demos/jquery/init.scala @@ -3,9 +3,8 @@ package io.udash.demos.jquery import io.udash._ import io.udash.wrappers.jquery._ import org.scalajs.dom -import org.scalajs.dom.{Element, document} +import org.scalajs.dom.Element -import scala.scalajs.js.JSApp import scala.scalajs.js.annotation.JSExport object Context { @@ -13,7 +12,7 @@ object Context { private val routingRegistry = new RoutingRegistryDef private val viewPresenterRegistry = new StatesToViewPresenterDef - implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState) + implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry) } object Init { diff --git a/example/src/main/scala/io/udash/demos/jquery/states.scala b/example/src/main/scala/io/udash/demos/jquery/states.scala index 2ef0306..f4e7452 100644 --- a/example/src/main/scala/io/udash/demos/jquery/states.scala +++ b/example/src/main/scala/io/udash/demos/jquery/states.scala @@ -2,40 +2,31 @@ package io.udash.demos.jquery import io.udash._ -sealed abstract class RoutingState(val parentState: RoutingState) extends State { - def url(implicit application: Application[RoutingState]): String = s"#${application.matchState(this).value}" -} - -case object RootState extends RoutingState(null) - -case object ErrorState extends RoutingState(RootState) - -case object IndexState extends RoutingState(RootState) - -case object AddState extends RoutingState(RootState) - -case object AddBackState extends RoutingState(RootState) - -case object AfterBeforeState extends RoutingState(RootState) - -case object AnimateState extends RoutingState(RootState) - -case object AppendPrependState extends RoutingState(RootState) +sealed abstract class RoutingState(val parentState: Option[ContainerRoutingState]) extends State { + type HierarchyRoot = RoutingState -case object AttrState extends RoutingState(RootState) - -case object CallbacksState extends RoutingState(RootState) - -case object ChildrenState extends RoutingState(RootState) - -case object DataState extends RoutingState(RootState) - -case object DeferredState extends RoutingState(RootState) - -case object EachState extends RoutingState(RootState) - -case object HideShowState extends RoutingState(RootState) - -case object OffsetPositionState extends RoutingState(RootState) + def url(implicit application: Application[RoutingState]): String = + s"#${application.matchState(this).value}" +} -case object OnOneOffState extends RoutingState(RootState) \ No newline at end of file +sealed abstract class ContainerRoutingState(parentState: Option[ContainerRoutingState]) extends RoutingState(parentState) with ContainerState +sealed abstract class FinalRoutingState(parentState: ContainerRoutingState) extends RoutingState(Option(parentState)) with FinalState + + +case object RootState extends ContainerRoutingState(None) +case object ErrorState extends FinalRoutingState(RootState) +case object IndexState extends FinalRoutingState(RootState) +case object AddState extends FinalRoutingState(RootState) +case object AddBackState extends FinalRoutingState(RootState) +case object AfterBeforeState extends FinalRoutingState(RootState) +case object AnimateState extends FinalRoutingState(RootState) +case object AppendPrependState extends FinalRoutingState(RootState) +case object AttrState extends FinalRoutingState(RootState) +case object CallbacksState extends FinalRoutingState(RootState) +case object ChildrenState extends FinalRoutingState(RootState) +case object DataState extends FinalRoutingState(RootState) +case object DeferredState extends FinalRoutingState(RootState) +case object EachState extends FinalRoutingState(RootState) +case object HideShowState extends FinalRoutingState(RootState) +case object OffsetPositionState extends FinalRoutingState(RootState) +case object OnOneOffState extends FinalRoutingState(RootState) \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala b/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala index 2a427cf..a2b8fa7 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala @@ -2,9 +2,8 @@ package io.udash.demos.jquery.views import io.udash._ import io.udash.demos.jquery.IndexState -import org.scalajs.dom.Element -object ErrorViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new ErrorView) +object ErrorViewPresenter extends StaticViewFactory[IndexState.type](() => new ErrorView) class ErrorView extends FinalView { import scalatags.JsDom.all._ diff --git a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala index aaf2e46..cad18f0 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala @@ -2,13 +2,11 @@ package io.udash.demos.jquery.views import io.udash._ import io.udash.demos.jquery._ -import org.scalajs.dom.Element -object IndexViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new IndexView) +object IndexViewPresenter extends StaticViewFactory[IndexState.type](() => new IndexView) class IndexView extends FinalView { import Context._ - import scalatags.JsDom.all._ private val content = div( diff --git a/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala b/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala index c58cf5d..3906559 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala @@ -2,28 +2,15 @@ package io.udash.demos.jquery.views import io.udash._ import io.udash.demos.jquery.{Context, IndexState, RootState} -import org.scalajs.dom.Element -object RootViewPresenter extends DefaultViewPresenterFactory[RootState.type](() => new RootView) +object RootViewPresenter extends StaticViewFactory[RootState.type](() => new RootView) -class RootView extends View { +class RootView extends ContainerView { import Context._ - import scalatags.JsDom.all._ - private var child: Element = div().render - - private val content = div( + override def getTemplate: Modifier = div( a(href := IndexState.url)(h1("jquery-demo")), - child + childViewContainer ) - - override def getTemplate: Modifier = content - - override def renderChild(view: View): Unit = { - import io.udash.wrappers.jquery._ - - jQ(child).children().remove() - view.getTemplate.applyTo(child) - } } \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala index 76037ce..cdc25ba 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala @@ -7,7 +7,7 @@ import io.udash.wrappers.jquery._ import scalatags.JsDom.tags2 -object AddBackViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AddBackView) +object AddBackViewPresenter extends StaticViewFactory[IndexState.type](() => new AddBackView) /** Based on examples from: jQuery Docs. */ class AddBackView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala index c77042d..9c0b0d8 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala @@ -7,7 +7,7 @@ import io.udash.wrappers.jquery._ import scalatags.JsDom.tags2 -object AddViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AddView) +object AddViewPresenter extends StaticViewFactory[IndexState.type](() => new AddView) /** Based on examples from: jQuery Docs. */ class AddView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala index 15ffc96..7e61e09 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala @@ -5,7 +5,7 @@ import io.udash.demos.jquery.IndexState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object AfterBeforeViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AfterBeforeView) +object AfterBeforeViewPresenter extends StaticViewFactory[IndexState.type](() => new AfterBeforeView) /** Based on examples from: jQuery Docs. */ class AfterBeforeView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala index ad4c630..c1c8693 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala @@ -8,7 +8,7 @@ import org.scalajs.dom.Element import scalatags.JsDom.tags2 -object AnimateViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AnimateView) +object AnimateViewPresenter extends StaticViewFactory[IndexState.type](() => new AnimateView) /** Based on examples from: jQuery Docs. */ class AnimateView extends FunctionView { @@ -39,7 +39,7 @@ class AnimateView extends FunctionView { ).render override protected val script = () => { - jQ("#go1").click((_: Element, _: JQueryEvent) => { + jQ("#go1").on(EventName.click, (_: Element, _: JQueryEvent) => { jQ( "#block1" ) .animate(Map( "width" -> "90%" @@ -51,18 +51,18 @@ class AnimateView extends FunctionView { .animate(Map("borderRightWidth" -> "15px"), 1500) }) - jQ("#go2").click((_: Element, _: JQueryEvent) => { + jQ("#go2").on(EventName.click, (_: Element, _: JQueryEvent) => { jQ("#block2") .animate(Map("width" -> "90%"), 1000) .animate(Map("fontSize" -> "24px"), 1000) .animate(Map("borderLeftWidth" -> "15px"), 1000) }) - jQ("#go3").click((_: Element, _: JQueryEvent) => { - jQ("#go1").add("#go2").click() + jQ("#go3").on(EventName.click, (_: Element, _: JQueryEvent) => { + jQ("#go1").add("#go2").trigger("click") }) - jQ("#go4").click((_: Element, _: JQueryEvent) => { + jQ("#go4").on(EventName.click, (_: Element, _: JQueryEvent) => { // TODO: It does not work without explicit Map elements type import scala.scalajs.js.`|` jQ("div").css(Map[String, String | Int | Double | Boolean]( diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala index 6640498..2908b43 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala @@ -5,7 +5,7 @@ import io.udash.demos.jquery.IndexState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object AppendPrependViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AppendPrependView) +object AppendPrependViewPresenter extends StaticViewFactory[IndexState.type](() => new AppendPrependView) /** Based on examples from: jQuery Docs. */ class AppendPrependView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala index 433981f..7ae29d0 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala @@ -6,7 +6,7 @@ import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ import org.scalajs.dom.{Element, Event} -object AttrViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AttrView) +object AttrViewPresenter extends StaticViewFactory[IndexState.type](() => new AttrView) /** Based on examples from: jQuery Docs. */ class AttrView extends FunctionView { @@ -18,34 +18,34 @@ class AttrView extends FunctionView { label(`for` := "check1")("Check me"), p(), button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", "checked").change() + jQ(".demo input").attr("data-checked", "checked").trigger("change") false }))(".attr(\"data-checked\", \"checked\")"), button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", "").change() + jQ(".demo input").attr("data-checked", "").trigger("change") false }))(".attr(\"data-checked\", \"\")"), button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", null).change() + jQ(".demo input").attr("data-checked", null).trigger("change") false }))(".attr(\"data-checked\", null)"), br(), button(onclick :+= ((_: Event) => { - jQ(".demo input").prop("checked", true).change() + jQ(".demo input").prop("checked", true).trigger("change") false }))(".prop(\"checked\", true)"), button(onclick :+= ((_: Event) => { - jQ(".demo input").prop("checked", false).change() + jQ(".demo input").prop("checked", false).trigger("change") false }))(".prop(\"checked\", false)") ).render override protected val script = () => { - jQ(".demo input").change((input: Element, _: JQueryEvent) => { + jQ(".demo input").on(EventName.change, (input: Element, _: JQueryEvent) => { jQ(".demo p").html( s""".attr('data-checked'): ${jQ(input).attr("data-checked")}
|.prop('checked'): ${jQ(input).prop("checked")}
|.is(':checked'): ${jQ(input).is(":checked")}""".stripMargin ) - }).change() + }).trigger("change") } } \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala index aa297a2..e3824bb 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala @@ -7,7 +7,7 @@ import io.udash.wrappers.jquery._ import scala.scalajs.js -object CallbacksViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new CallbacksView) +object CallbacksViewPresenter extends StaticViewFactory[IndexState.type](() => new CallbacksView) /** Based on examples from: jQuery Docs. */ class CallbacksView extends FunctionView { @@ -40,11 +40,11 @@ class CallbacksView extends FunctionView { jQ("#div").append(li(s"$a / $b = ${a/b}").render) }) - callbacks.fire(1, 1) - callbacks.fire(3, 3) - callbacks.fire(7, 4) + callbacks.fire((1, 1)) + callbacks.fire((3, 3)) + callbacks.fire((7, 4)) callbacks.disable() - callbacks.fire(1, 2) + callbacks.fire((1, 2)) } } \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala index 845042f..ea4d0f6 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala @@ -5,7 +5,7 @@ import io.udash.demos.jquery.IndexState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object ChildrenViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new ChildrenView) +object ChildrenViewPresenter extends StaticViewFactory[IndexState.type](() => new ChildrenView) /** Based on examples from: jQuery Docs. */ class ChildrenView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala index 8d67ac0..f905ec5 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala @@ -5,7 +5,7 @@ import io.udash.demos.jquery.IndexState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object DataViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new DataView) +object DataViewPresenter extends StaticViewFactory[IndexState.type](() => new DataView) /** Based on examples from: jQuery Docs. */ class DataView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala index edb6ced..82ee717 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala @@ -8,7 +8,7 @@ import org.scalajs.dom.Event import scala.scalajs.js -object DeferredViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new DeferredView) +object DeferredViewPresenter extends StaticViewFactory[IndexState.type](() => new DeferredView) /** Based on examples from: jQuery Docs. */ class DeferredView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala index 10e9395..447267b 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala @@ -6,7 +6,7 @@ import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ import org.scalajs.dom.Element -object EachViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new EachView) +object EachViewPresenter extends StaticViewFactory[IndexState.type](() => new EachView) /** Based on examples from: jQuery Docs. */ class EachView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala index fcd8246..9ed0a46 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala @@ -5,7 +5,7 @@ import io.udash.demos.jquery.IndexState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object HideShowViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new HideShowView) +object HideShowViewPresenter extends StaticViewFactory[IndexState.type](() => new HideShowView) /** Based on examples from: jQuery Docs. */ class HideShowView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala index d2304d9..9ec5d02 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala @@ -1,12 +1,11 @@ package io.udash.demos.jquery.views.functions import io.udash._ -import io.udash.demos.jquery.{IndexState, OffsetPositionState} +import io.udash.demos.jquery.OffsetPositionState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -import org.scalajs.dom.{Element, Event} -object OffsetPositionViewPresenter extends DefaultViewPresenterFactory[OffsetPositionState.type](() => new OffsetPositionView) +object OffsetPositionViewPresenter extends StaticViewFactory[OffsetPositionState.type](() => new OffsetPositionView) /** Based on examples from: jQuery Docs. */ class OffsetPositionView extends FunctionView { diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala index e237e37..08035d0 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala @@ -6,7 +6,7 @@ import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ import org.scalajs.dom.{Element, Event} -object OnOneOffViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new OnOneOffView) +object OnOneOffViewPresenter extends StaticViewFactory[IndexState.type](() => new OnOneOffView) /** Based on examples from: jQuery Docs. */ class OnOneOffView extends FunctionView { @@ -26,8 +26,8 @@ class OnOneOffView extends FunctionView { disabled := "disabled", onclick :+= ((_: Event) => { jQ(".demo #click") - .off("click", onCallback) - .off("click", oneCallback) + .off(EventName.click, onCallback) + .off(EventName.click, oneCallback) false }) )("Off") @@ -35,8 +35,8 @@ class OnOneOffView extends FunctionView { override protected val script = () => { jQ(".demo #click") - .on("click", onCallback) - .one("click", oneCallback) + .on(EventName.click, onCallback) + .one(EventName.click, oneCallback) jQ(".demo button") .prop("disabled", "") diff --git a/project/build.properties b/project/build.properties index 6be4958..c3e3abc 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 0.13.15 \ No newline at end of file +sbt.version = 1.1.4 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 3a623d2..953c2a1 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18") +libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.2.0" -libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.1.3" +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") diff --git a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala index f2afbf1..f3c3fa5 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala @@ -3,10 +3,9 @@ package io.udash.wrappers.jquery import org.scalajs.dom._ import scala.collection.mutable -import scala.concurrent.duration.Duration import scala.scalajs.js import scala.scalajs.js.annotation.JSName -import scala.scalajs.js.{Dictionary, ThisFunction1, UndefOr, |} +import scala.scalajs.js.{ThisFunction1, UndefOr, |} @js.native trait JQuery extends js.Object { @@ -62,10 +61,12 @@ trait JQuery extends js.Object { /** Trigger blur event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def blur(): JQuery = js.native /** Trigger change event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def change(): JQuery = js.native /** Get the children of each element in the set of matched elements.
@@ -86,6 +87,7 @@ trait JQuery extends js.Object { /** Trigger click event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def click(): JQuery = js.native /** Create a deep copy of the set of matched elements.
@@ -94,11 +96,11 @@ trait JQuery extends js.Object { /** For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
* See: jQuery Docs */ - def closest(selector: String | Element | JQuery): JQuery = js.native + def closest(selector: Selector | Element | JQuery): JQuery = js.native /** For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
* See: jQuery Docs */ - def closest(selector: String, context: Element): JQuery = js.native + def closest(selector: Selector, context: Element): JQuery = js.native /** Get the children of each element in the set of matched elements, including text and comment nodes.
* See: jQuery Docs */ @@ -107,6 +109,7 @@ trait JQuery extends js.Object { /** Trigger contextmenu event on an element.
* See: jQuery Docs */ @JSName("contextmenu") + @deprecated("Since jQuery 3.3.0", "1.2.0") def contextMenu(): JQuery = js.native /** Get the computed style properties for the first element in the set of matched elements.
@@ -128,6 +131,7 @@ trait JQuery extends js.Object { /** Trigger dblclick event on an element.
* See: jQuery Docs */ @JSName("dblclick") + @deprecated("Since jQuery 3.3.0", "1.2.0") def dblClick(): JQuery = js.native /** Set a timer to delay execution of subsequent items in the queue.
@@ -190,7 +194,7 @@ trait JQuery extends js.Object { /** Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
* See: jQuery Docs */ - def find(selector: String | Element | JQuery): JQuery = js.native + def find(selector: Selector | Element | JQuery): JQuery = js.native /** Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
* See: jQuery Docs */ @@ -202,21 +206,24 @@ trait JQuery extends js.Object { /** Trigger focus event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focus(): JQuery = js.native /** Trigger focusin event on an element.
* See: jQuery Docs */ @JSName("focusin") + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusIn(): JQuery = js.native /** Trigger focusout event on an element.
* See: jQuery Docs */ @JSName("focusout") + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusOut(): JQuery = js.native /** Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
* See: jQuery Docs */ - def has(selector: String | Element): JQuery = js.native + def has(selector: Selector | Element): JQuery = js.native /** Determine whether any of the matched elements are assigned the given class.
* See: jQuery Docs */ @@ -268,15 +275,15 @@ trait JQuery extends js.Object { /** Insert every element in the set of matched elements after the target.
* See: jQuery Docs */ - def insertAfter(selector: String | Element | JQuery): JQuery = js.native + def insertAfter(selector: Selector | Element | JQuery): JQuery = js.native /** Insert every element in the set of matched elements before the target.
* See: jQuery Docs */ - def insertBefore(selector: String | Element | JQuery): JQuery = js.native + def insertBefore(selector: Selector | Element | JQuery): JQuery = js.native /** Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
* See: jQuery Docs */ - def is(selector: String | Element | JQuery): Boolean = js.native + def is(selector: Selector | Element | JQuery): Boolean = js.native /** A string containing the jQuery version number.
* See: jQuery Docs */ @@ -285,16 +292,19 @@ trait JQuery extends js.Object { /** Trigger keydown event on an element.
* See: jQuery Docs */ @JSName("keydown") + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyDown(): JQuery = js.native /** Trigger keypress event on an element.
* See: jQuery Docs */ @JSName("keypress") + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyPress(): JQuery = js.native /** Trigger keyup event on an element.
* See: jQuery Docs */ @JSName("keyup") + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyUp(): JQuery = js.native /** Reduce the set of matched elements to the final one in the set.
@@ -312,36 +322,43 @@ trait JQuery extends js.Object { /** Trigger mousedown event on an element.
* See: jQuery Docs */ @JSName("mousedown") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseDown(): JQuery = js.native /** Trigger mouseenter event on an element.
* See: jQuery Docs */ @JSName("mouseenter") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseEnter(): JQuery = js.native /** Trigger mouseleave event on an element.
* See: jQuery Docs */ @JSName("mouseleave") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseLeave(): JQuery = js.native /** Trigger mousemove event on an element.
* See: jQuery Docs */ @JSName("mousemove") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseMove(): JQuery = js.native /** Trigger mouseout event on an element.
* See: jQuery Docs */ @JSName("mouseout") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOut(): JQuery = js.native /** Trigger mouseover event on an element.
* See: jQuery Docs */ @JSName("mouseover") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOver(): JQuery = js.native /** Trigger mouseup event on an element.
* See: jQuery Docs */ @JSName("mouseup") + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseUp(): JQuery = js.native /** Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
@@ -358,7 +375,7 @@ trait JQuery extends js.Object { /** Remove elements from the set of matched elements.
* See: jQuery Docs */ - def not(selector: String | JQuery): JQuery = js.native + def not(selector: Selector | JQuery): JQuery = js.native /** Remove elements from the set of matched elements.
* See: jQuery Docs */ @@ -374,7 +391,7 @@ trait JQuery extends js.Object { /** Remove an event handler.
* See: jQuery Docs */ - def off(jEvent: JQueryEvent, selector: String = js.native): JQuery = js.native + def off(jEvent: JQueryEvent, selector: Selector = js.native): JQuery = js.native /** Get the closest ancestor element that is positioned.
* See: jQuery Docs */ @@ -470,10 +487,12 @@ trait JQuery extends js.Object { /** Trigger resize event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def resize(): JQuery = js.native /** Trigger scroll event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def scroll(): JQuery = js.native /** Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
@@ -494,6 +513,7 @@ trait JQuery extends js.Object { /** Trigger select event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def select(): JQuery = js.native /** Encode a set of form elements as a string for submission.
@@ -510,7 +530,7 @@ trait JQuery extends js.Object { /** Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
* See: jQuery Docs */ - def siblings(selector: String = js.native): JQuery = js.native + def siblings(selector: Selector = js.native): JQuery = js.native /** Reduce the set of matched elements to a subset specified by a range of indices. Including `start`, without `end`.
* See: jQuery Docs */ @@ -534,6 +554,7 @@ trait JQuery extends js.Object { /** Trigger submit event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def submit(): JQuery = js.native /** Get the combined text contents of each element in the set of matched elements, including their descendants.
@@ -562,11 +583,11 @@ trait JQuery extends js.Object { /** Execute all handlers and behaviors attached to the matched elements for the given event type.
* See: jQuery Docs */ - def trigger(event: String | JQueryEvent): JQuery = js.native + def trigger(event: EventName | JQueryEvent): JQuery = js.native /** Execute all handlers attached to an element for an event.
* See: jQuery Docs */ - def triggerHandler(event: String | JQueryEvent): JQuery = js.native + def triggerHandler(event: EventName | JQueryEvent): JQuery = js.native /** Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
* See: jQuery Docs */ @@ -608,15 +629,15 @@ object JQuery { def unregister(): Unit } - case class CallbackParameters(once: Boolean, selector: String, data: js.Any) - case class CallbackRegistrationRef(event: String, callback: JQueryCallback, registration: CallbackRegistration) + case class CallbackParameters(once: Boolean, selector: Selector, data: js.Any) + case class CallbackRegistrationRef(event: EventName, callback: JQueryCallback, registration: CallbackRegistration) private val registrations: mutable.Map[Element, mutable.Buffer[CallbackRegistrationRef]] = mutable.Map[Element, mutable.Buffer[CallbackRegistrationRef]]() implicit class JQueryWrapper(private val jquery: JQuery) { import js.JSConverters._ - class OnCallbackRegistration(event: String, callback: JQueryCallback, + class OnCallbackRegistration(event: EventName, callback: JQueryCallback, reg: (ThisFunction1[Element, JQueryEvent, Any]) => Any, unreg: (String, ThisFunction1[Element, JQueryEvent, Any]) => js.Any = (event, c) => jquery.asInstanceOf[js.Dynamic].off(event, c)) extends CallbackRegistration { @@ -626,6 +647,11 @@ object JQuery { override def unregister(): Unit = unreg(event, c) } + /** Adds the specified class(es) to each element in the set of matched elements.
+ * See: jQuery Docs */ + def addClass(classNames: Seq[String]): JQuery = + jquery.asInstanceOf[js.Dynamic].addClass(classNames.toJSArray).asInstanceOf[JQuery] + /** Adds the specified class(es) to each element in the set of matched elements.
* See: jQuery Docs */ def addClass(function: (Int) => String): JQuery = @@ -673,34 +699,42 @@ object JQuery { /** Bind an event handler to the "blur" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def blur(callback: JQueryCallback): JQuery = on("blur", callback) /** Bind an event handler to the "blur" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def blur(data: js.Any, callback: JQueryCallback): JQuery = on("blur", data, callback) /** Bind an event handler to the "change" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def change(callback: JQueryCallback): JQuery = on("change", callback) /** Bind an event handler to the "change" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def change(data: js.Any, callback: JQueryCallback): JQuery = on("change", data, callback) /** Bind an event handler to the "click" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def click(callback: JQueryCallback): JQuery = on("click", callback) /** Bind an event handler to the "click" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def click(data: js.Any, callback: JQueryCallback): JQuery = on("click", data, callback) /** Bind an event handler to the "contextmenu" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def contextMenu(callback: JQueryCallback): JQuery = on("contextmenu", callback) /** Bind an event handler to the "contextmenu" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def contextMenu(data: js.Any, callback: JQueryCallback): JQuery = on("contextmenu", data, callback) /** Set one or more CSS properties for the set of matched elements.
@@ -725,10 +759,12 @@ object JQuery { /** Bind an event handler to the "dblclick" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def dblClick(callback: JQueryCallback): JQuery = on("dblclick", callback) /** Bind an event handler to the "dblclick" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def dblClick(data: js.Any, callback: JQueryCallback): JQuery = on("dblclick", data, callback) /** Iterate over a jQuery object, executing a function for each matched element.
@@ -793,26 +829,32 @@ object JQuery { /** Bind an event handler to the "focus" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focus(callback: JQueryCallback): JQuery = on("focus", callback) /** Bind an event handler to the "focus" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focus(data: js.Any, callback: JQueryCallback): JQuery = on("focus", data, callback) /** Bind an event handler to the "focusIn" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusIn(callback: JQueryCallback): JQuery = on("focusin", callback) /** Bind an event handler to the "focusIn" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusIn(data: js.Any, callback: JQueryCallback): JQuery = on("focusin", data, callback) /** Bind an event handler to the "focusOut" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusOut(callback: JQueryCallback): JQuery = on("focusout", callback) /** Bind an event handler to the "focusOut" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def focusOut(data: js.Any, callback: JQueryCallback): JQuery = on("focusout", data, callback) /** Retrieve one of the elements matched by the jQuery object.
@@ -843,8 +885,8 @@ object JQuery { /** Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
* See: jQuery Docs */ def hover(handlerIn: (Element) => Any, handlerOut: (Element) => Any): JQuery = { - mouseEnter((el, _) => handlerIn(el)) - mouseLeave((el, _) => handlerOut(el)) + on("mouseenter", (el, _) => handlerIn(el)) + on("mouseleave", (el, _) => handlerOut(el)) jquery } @@ -869,26 +911,32 @@ object JQuery { /** Bind an event handler to the "keydown" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyDown(callback: JQueryCallback): JQuery = on("keydown", callback) /** Bind an event handler to the "keydown" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyDown(data: js.Any, callback: JQueryCallback): JQuery = on("keydown", data, callback) /** Bind an event handler to the "keypress" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyPress(callback: JQueryCallback): JQuery = on("keypress", callback) /** Bind an event handler to the "keypress" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyPress(data: js.Any, callback: JQueryCallback): JQuery = on("keypress", data, callback) /** Bind an event handler to the "keyup" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyUp(callback: JQueryCallback): JQuery = on("keyup", callback) /** Bind an event handler to the "keyup" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def keyUp(data: js.Any, callback: JQueryCallback): JQuery = on("keyup", data, callback) /** Load data from the server and place the returned HTML into the matched element.
@@ -903,58 +951,72 @@ object JQuery { /** Bind an event handler to the "mousedown" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseDown(callback: JQueryCallback): JQuery = on("mousedown", callback) /** Bind an event handler to the "mousedown" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseDown(data: js.Any, callback: JQueryCallback): JQuery = on("mousedown", data, callback) /** Bind an event handler to the "mouseenter" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseEnter(callback: JQueryCallback): JQuery = on("mouseenter", callback) /** Bind an event handler to the "mouseenter" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseEnter(data: js.Any, callback: JQueryCallback): JQuery = on("mouseenter", data, callback) /** Bind an event handler to the "mouseleave" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseLeave(callback: JQueryCallback): JQuery = on("mouseleave", callback) /** Bind an event handler to the "mouseleave" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseLeave(data: js.Any, callback: JQueryCallback): JQuery = on("mouseleave", data, callback) /** Bind an event handler to the "mousemove" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseMove(callback: JQueryCallback): JQuery = on("mousemove", callback) /** Bind an event handler to the "mousemove" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseMove(data: js.Any, callback: JQueryCallback): JQuery = on("mousemove", data, callback) /** Bind an event handler to the "mouseout" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOut(callback: JQueryCallback): JQuery = on("mouseout", callback) /** Bind an event handler to the "mouseout" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOut(data: js.Any, callback: JQueryCallback): JQuery = on("mouseout", data, callback) /** Bind an event handler to the "mouseover" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOver(callback: JQueryCallback): JQuery = on("mouseover", callback) /** Bind an event handler to the "mouseover" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseOver(data: js.Any, callback: JQueryCallback): JQuery = on("mouseover", data, callback) /** Bind an event handler to the "mouseup" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseUp(callback: JQueryCallback): JQuery = on("mouseup", callback) /** Bind an event handler to the "mouseup" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def mouseUp(data: js.Any, callback: JQueryCallback): JQuery = on("mouseup", data, callback) /** Remove elements from the set of matched elements.
@@ -976,63 +1038,63 @@ object JQuery { /** Attach an event handler function for one or more events to the selected elements.
* See: jQuery Docs */ - def on(event: String, callback: JQueryCallback): JQuery = { + def on(event: EventName, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(false, null, null)) jquery } /** Attach an event handler function for one or more events to the selected elements.
* See: jQuery Docs */ - def on(event: String, data: js.Any, callback: JQueryCallback): JQuery = { + def on(event: EventName, data: js.Any, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(false, null, data)) jquery } /** Attach an event handler function for one or more events to the selected elements.
* See: jQuery Docs */ - def on(event: String, selector: String, callback: JQueryCallback): JQuery = { + def on(event: EventName, selector: Selector, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(false, selector, null)) jquery } /** Attach an event handler function for one or more events to the selected elements.
* See: jQuery Docs */ - def on(event: String, selector: String, data: js.Any, callback: JQueryCallback): JQuery = { + def on(event: EventName, selector: Selector, data: js.Any, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(false, selector, data)) jquery } /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
* See: jQuery Docs */ - def one(event: String, callback: JQueryCallback): JQuery = { + def one(event: EventName, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(true, null, null)) jquery } /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
* See: jQuery Docs */ - def one(event: String, data: js.Any, callback: JQueryCallback): JQuery = { + def one(event: EventName, data: js.Any, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(true, null, data)) jquery } /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
* See: jQuery Docs */ - def one(event: String, selector: String, callback: JQueryCallback): JQuery = { + def one(event: EventName, selector: Selector, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(true, selector, null)) jquery } /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
* See: jQuery Docs */ - def one(event: String, selector: String, data: js.Any, callback: JQueryCallback): JQuery = { + def one(event: EventName, selector: Selector, data: js.Any, callback: JQueryCallback): JQuery = { separateCallbacks(event, callback, new CallbackParameters(true, selector, data)) jquery } /** Remove an event handler.
* See: jQuery Docs */ - def off(event: String, callback: JQueryCallback): JQuery = { + def off(event: EventName, callback: JQueryCallback): JQuery = { jquery.asInstanceOf[js.Dynamic].toArray().asInstanceOf[js.Array[Element]] .foreach( el => { if (registrations.contains(el)) { @@ -1052,7 +1114,7 @@ object JQuery { jquery } - private def separateCallbacks(event: String, callback: JQueryCallback, params: CallbackParameters): Unit = { + private def separateCallbacks(event: EventName, callback: JQueryCallback, params: CallbackParameters): Unit = { type ThisFunctionCallback = ThisFunction1[Element, JQueryEvent, Any] @@ -1074,7 +1136,7 @@ object JQuery { })) } - private def collectRegistration(event: String, callback: JQueryCallback, el: Element, index: Int, params: CallbackParameters, reg: CallbackRegistration) = { + private def collectRegistration(event: EventName, callback: JQueryCallback, el: Element, index: Int, params: CallbackParameters, reg: CallbackRegistration) = { val jqueryRegs: mutable.Buffer[CallbackRegistrationRef] = registrations.getOrElse(el, mutable.Buffer[CallbackRegistrationRef]()) jqueryRegs += CallbackRegistrationRef(event, callback, reg) registrations.update(el, jqueryRegs) @@ -1128,6 +1190,11 @@ object JQuery { def ready(callback: (Element) => Any): JQuery = jquery.asInstanceOf[js.Dynamic].ready(js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] + /** Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
+ * See: jQuery Docs */ + def removeClass(classNames: Seq[String]): JQuery = + jquery.asInstanceOf[js.Dynamic].removeClass(classNames.toJSArray).asInstanceOf[JQuery] + /** Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
* See: jQuery Docs */ def removeClass(function: (Int, String) => String): JQuery = @@ -1140,26 +1207,32 @@ object JQuery { /** Bind an event handler to the "resize" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def resize(callback: JQueryCallback): JQuery = on("resize", callback) /** Bind an event handler to the "resize" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def resize(data: js.Any, callback: JQueryCallback): JQuery = on("resize", data, callback) /** Bind an event handler to the "scroll" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def scroll(callback: JQueryCallback): JQuery = on("scroll", callback) /** Bind an event handler to the "scroll" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def scroll(data: js.Any, callback: JQueryCallback): JQuery = on("scroll", data, callback) /** Bind an event handler to the "select" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def select(callback: JQueryCallback): JQuery = on("select", callback) /** Bind an event handler to the "select" JavaScript event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def select(data: js.Any, callback: JQueryCallback): JQuery = on("select", data, callback) /** Display the matched elements.
@@ -1204,10 +1277,12 @@ object JQuery { /** Trigger submit event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def submit(callback: JQueryCallback): JQuery = on("submit", callback) /** Trigger submit event on an element.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def submit(data: js.Any, callback: JQueryCallback): JQuery = on("submit", data, callback) /** Set the content of each element in the set of matched elements to the specified text.
@@ -1230,6 +1305,11 @@ object JQuery { def toggle(options: AnimationOptions): JQuery = jquery.asInstanceOf[js.Dynamic].toggle(options.toJSDictionary).asInstanceOf[JQuery] + /** Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
+ * See: jQuery Docs */ + def toggleClass(classNames: Seq[String]): JQuery = + jquery.asInstanceOf[js.Dynamic].toggleClass(classNames.toJSArray).asInstanceOf[JQuery] + /** Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
* See: jQuery Docs */ def toggleClass(function: (Int, String, Boolean) => String): JQuery = @@ -1242,22 +1322,22 @@ object JQuery { /** Execute all handlers and behaviors attached to the matched elements for the given event type.
* See: jQuery Docs */ - def trigger(event: String | JQueryEvent, extraParams: Map[String, Any]): JQuery = + def trigger(event: EventName | JQueryEvent, extraParams: Map[String, Any]): JQuery = jquery.asInstanceOf[js.Dynamic].trigger(event.asInstanceOf[js.Dynamic], extraParams.toJSDictionary).asInstanceOf[JQuery] /** Execute all handlers and behaviors attached to the matched elements for the given event type.
* See: jQuery Docs */ - def trigger(event: String | JQueryEvent, extraParams: Seq[Any]): JQuery = + def trigger(event: EventName | JQueryEvent, extraParams: Seq[Any]): JQuery = jquery.asInstanceOf[js.Dynamic].trigger(event.asInstanceOf[js.Dynamic], extraParams.toJSArray).asInstanceOf[JQuery] /** Execute all handlers attached to an element for an event.
* See: jQuery Docs */ - def triggerHandler(event: String | JQueryEvent, extraParams: Map[String, Any]): JQuery = + def triggerHandler(event: EventName | JQueryEvent, extraParams: Map[String, Any]): JQuery = jquery.asInstanceOf[js.Dynamic].triggerHandler(event.asInstanceOf[js.Dynamic], extraParams.toJSDictionary).asInstanceOf[JQuery] /** Execute all handlers attached to an element for an event.
* See: jQuery Docs */ - def triggerHandler(event: String | JQueryEvent, extraParams: Seq[Any]): JQuery = + def triggerHandler(event: EventName | JQueryEvent, extraParams: Seq[Any]): JQuery = jquery.asInstanceOf[js.Dynamic].triggerHandler(event.asInstanceOf[js.Dynamic], extraParams.toJSArray).asInstanceOf[JQuery] /** Set the value of each element in the set of matched elements.
diff --git a/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala b/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala index 0695953..e0ee079 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala @@ -1,7 +1,5 @@ package io.udash.wrappers.jquery -import org.scalajs.dom._ - import scala.scalajs.js @js.native diff --git a/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala b/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala index f4d4ac3..7044e8f 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala @@ -108,10 +108,12 @@ trait JQueryStatic extends js.Object { /** Determine if the argument passed is a JavaScript function object.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def isFunction[T](el: js.Any): Boolean = js.native /** Determines whether its argument is a number.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def isNumeric[T](el: js.Any): Boolean = js.native /** Check to see if an object is a plain object (created using "{}" or "new Object").
@@ -120,6 +122,7 @@ trait JQueryStatic extends js.Object { /** Determine whether the argument is a window.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.3.0", "1.2.0") def isWindow[T](el: js.Any): Boolean = js.native /** Check to see if a DOM node is within an XML document (or is an XML document).
diff --git a/src/main/scala/io/udash/wrappers/jquery/package.scala b/src/main/scala/io/udash/wrappers/jquery/package.scala index 51cc4dc..16a83bd 100644 --- a/src/main/scala/io/udash/wrappers/jquery/package.scala +++ b/src/main/scala/io/udash/wrappers/jquery/package.scala @@ -3,13 +3,13 @@ package io.udash.wrappers import org.scalajs.dom._ import scala.scalajs.js -import scala.scalajs.js.annotation.JSName /** All docs are quoted from jQuery API docs. */ package object jquery { /** See: jQuery Docs */ type Selector = String type EasingFunction = String + type EventName = String type JQueryCallback = (Element, JQueryEvent) => Any def jQ: JQueryStatic = js.Dynamic.global.jQuery.asInstanceOf[JQueryStatic] diff --git a/src/main/scala/io/udash/wrappers/jquery/utils.scala b/src/main/scala/io/udash/wrappers/jquery/utils.scala index e584afc..4c18fdb 100644 --- a/src/main/scala/io/udash/wrappers/jquery/utils.scala +++ b/src/main/scala/io/udash/wrappers/jquery/utils.scala @@ -37,38 +37,63 @@ case class AnimationOptions(duration: Option[Int] = None, easing: Option[EasingF /** Easing functions specify the speed at which an animation progresses at different points within the animation.
* See: jQuery Docs */ object EasingFunction { - val linear = "linear" - val swing = "swing" + val linear: EasingFunction = "linear" + val swing: EasingFunction = "swing" /* Require jQuery UI */ - val easeInQuad = "easeInQuad" - val easeOutQuad = "easeOutQuad" - val easeInOutQuad = "easeInOutQuad" - val easeInCubic = "easeInCubic" - val easeOutCubic = "easeOutCubic" - val easeInOutCubic = "easeInOutCubic" - val easeInQuart = "easeInQuart" - val easeOutQuart = "easeOutQuart" - val easeInOutQuart = "easeInOutQuart" - val easeInQuint = "easeInQuint" - val easeOutQuint = "easeOutQuint" - val easeInOutQuint = "easeInOutQuint" - val easeInExpo = "easeInExpo" - val easeOutExpo = "easeOutExpo" - val easeInOutExpo = "easeInOutExpo" - val easeInSine = "easeInSine" - val easeOutSine = "easeOutSine" - val easeInOutSine = "easeInOutSine" - val easeInCirc = "easeInCirc" - val easeOutCirc = "easeOutCirc" - val easeInOutCirc = "easeInOutCirc" - val easeInElastic = "easeInElastic" - val easeOutElastic = "easeOutElastic" - val easeInOutElastic = "easeInOutElastic" - val easeInBack = "easeInBack" - val easeOutBack = "easeOutBack" - val easeInOutBack = "easeInOutBack" - val easeInBounce = "easeInBounce" - val easeOutBounce = "easeOutBounce" - val easeInOutBounce = "easeInOutBounce" + val easeInQuad: EasingFunction = "easeInQuad" + val easeOutQuad: EasingFunction = "easeOutQuad" + val easeInOutQuad: EasingFunction = "easeInOutQuad" + val easeInCubic: EasingFunction = "easeInCubic" + val easeOutCubic: EasingFunction = "easeOutCubic" + val easeInOutCubic: EasingFunction = "easeInOutCubic" + val easeInQuart: EasingFunction = "easeInQuart" + val easeOutQuart: EasingFunction = "easeOutQuart" + val easeInOutQuart: EasingFunction = "easeInOutQuart" + val easeInQuint: EasingFunction = "easeInQuint" + val easeOutQuint: EasingFunction = "easeOutQuint" + val easeInOutQuint: EasingFunction = "easeInOutQuint" + val easeInExpo: EasingFunction = "easeInExpo" + val easeOutExpo: EasingFunction = "easeOutExpo" + val easeInOutExpo: EasingFunction = "easeInOutExpo" + val easeInSine: EasingFunction = "easeInSine" + val easeOutSine: EasingFunction = "easeOutSine" + val easeInOutSine: EasingFunction = "easeInOutSine" + val easeInCirc: EasingFunction = "easeInCirc" + val easeOutCirc: EasingFunction = "easeOutCirc" + val easeInOutCirc: EasingFunction = "easeInOutCirc" + val easeInElastic: EasingFunction = "easeInElastic" + val easeOutElastic: EasingFunction = "easeOutElastic" + val easeInOutElastic: EasingFunction = "easeInOutElastic" + val easeInBack: EasingFunction = "easeInBack" + val easeOutBack: EasingFunction = "easeOutBack" + val easeInOutBack: EasingFunction = "easeInOutBack" + val easeInBounce: EasingFunction = "easeInBounce" + val easeOutBounce: EasingFunction = "easeOutBounce" + val easeInOutBounce: EasingFunction = "easeInOutBounce" } + +object EventName { + val blur: EventName = "blur" + val change: EventName = "change" + val click: EventName = "click" + val contextMenu: EventName = "contextmenu" + val dblClick: EventName = "dblclick" + val focus: EventName = "focus" + val focusIn: EventName = "focusin" + val focusOut: EventName = "focusout" + val keyDown: EventName = "keydown" + val keyPress: EventName = "keypress" + val keyUp: EventName = "keyup" + val mouseDown: EventName = "mousedown" + val mouseEnter: EventName = "mouseenter" + val mouseLeave: EventName = "mouseleave" + val mouseMove: EventName = "mousemove" + val mouseOut: EventName = "mouseout" + val mouseover: EventName = "mouseover" + val mouseUp: EventName = "mouseup" + val resize: EventName = "resize" + val scroll: EventName = "scroll" + val select: EventName = "select" + val submit: EventName = "submit" +} \ No newline at end of file diff --git a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala index d042acb..1400684 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -63,9 +63,9 @@ class TraversingTest extends WordSpec with Matchers { val el1 = span.render val el2 = span.render val el3 = h1.render - val p1 = div(el1).render - val p2 = div(el2).render - val p3 = div(el3).render + div(el1).render + div(el2).render + div(el3).render val selection = jQ(el1, el2, el3) selection.parent().filter("div").length should be(3) @@ -89,7 +89,7 @@ class TraversingTest extends WordSpec with Matchers { val el1 = span.render val el2 = span.render val el3 = h1.render - val d = div(el1, el2, el3).render + div(el1, el2, el3).render val selection = jQ(el1, el2, el3) selection.parent().filter("div").length should be(1)