diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cf04a0d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: CI + +env: + JAVA_OPTS: "-Dfile.encoding=UTF-8 -Xms1024M -Xmx3072M -Xss4M -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler" + +on: + push: + branches: '*' + tags: [ "v[0-9]+*" ] + pull_request: + # avoid duplicate checks (push & PR) further in the review process + types: [opened] + +jobs: + test: + name: Run tests + runs-on: ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md + strategy: + fail-fast: false + matrix: + scala: [ 2.13.12 ] + command: [ test ] + steps: + - uses: actions/checkout@v2 + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache + ~/.cache/coursier + key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}-${{ hashFiles('project/Dependencies.scala') }} + restore-keys: ${{ runner.os }}-sbt- + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache npm + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-node- + - name: Set up node + uses: actions/setup-node@v2-beta + - name: Run tests + run: sbt "set concurrentRestrictions in Global += Tags.limit(ScalaJSTags.Link, 1)" ++${{ matrix.scala }} ${{ matrix.command }} + + publish: + name: Publish to Sonatype + # only run on tag push + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v')) + needs: [ test ] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache + ~/.cache/coursier + key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}-${{ hashFiles('project/Dependencies.scala') }} + restore-keys: ${{ runner.os }}-sbt- + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Get version + id: get_tag_name + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + - name: Import GPG key + env: + #exported via `gpg -a --export-secret-keys | cat -e | sed 's/\$/\\n/g' | xclip -selection clipboard` and added to org secrets + SONATYPE_GPG: ${{ secrets.SONATYPE_GPG }} + run: echo -e $SONATYPE_GPG | gpg --import - + - name: Publish artifacts + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: sbt 'set version in ThisBuild := "${{ steps.get_tag_name.outputs.VERSION }}"' +publishSigned + - name: Release Sonatype bundle + #https://github.com/xerial/sbt-sonatype#publishing-your-artifact + if: ${{ !endsWith(steps.get_tag_name.outputs.VERSION, 'SNAPSHOT') }} + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: sbt 'set version in ThisBuild := "${{ steps.get_tag_name.outputs.VERSION }}"' sonatypeBundleRelease diff --git a/.gitignore b/.gitignore index c67de7b..de4683c 100644 --- a/.gitignore +++ b/.gitignore @@ -84,7 +84,7 @@ buildNumber.properties ## Plugin-specific files: # IntelliJ -/out/ +out/ # mpeltonen/sbt-idea plugin .idea_modules/ @@ -117,6 +117,7 @@ hs_err_pid* .cache .history .lib/ +.bsp/ dist/* target/ lib_managed/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 556f7d1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: scala -dist: trusty - -jdk: oraclejdk8 -scala: - - 2.11.8 - - 2.12.1 - -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - # Instal google-chrome - - export CHROME_BIN=/usr/bin/google-chrome - - sudo apt-get update - - sudo apt-get install -y libappindicator1 fonts-liberation - - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - - sudo dpkg -i google-chrome*.deb - # Install Selenium chromedriver - - wget http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip - - unzip chromedriver_linux64.zip -d selenium-bin - - 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 diff --git a/README.md b/README.md index fca8785..f5492de 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ -# scala-js-jquery [![Build Status](https://travis-ci.org/UdashFramework/scala-js-jquery.svg?branch=master)](https://travis-ci.org/UdashFramework/scala-js-jquery) [![Join the chat at https://gitter.im/UdashFramework/scala-js-jquery](https://badges.gitter.im/UdashFramework/scala-js-jquery.svg)](https://gitter.im/UdashFramework/scala-js-jquery?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](http://www.avsystem.com/) +# udash-jquery [](http://www.avsystem.com/) + +[![CI](https://github.com/UdashFramework/scala-js-jquery/actions/workflows/ci.yml/badge.svg)](https://github.com/UdashFramework/scala-js-jquery/actions/workflows/ci.yml)[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.13) +[![Join the chat at https://gitter.im/UdashFramework/scala-js-jquery](https://badges.gitter.im/UdashFramework/scala-js-jquery.svg)](https://gitter.im/UdashFramework/scala-js-jquery?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) programs. ## Usage -Add the following to your SBT build: +Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "1.0.0" +libraryDependencies += "io.udash" %%% "udash-jquery" % "3.3.0" ``` then import the jQuery package: @@ -16,6 +19,11 @@ then import the jQuery package: import io.udash.wrappers.jquery._ ``` +Since version `3.0.4` the wrapper targets SJS 1.x series and supports JS dependencies managed by +by [scalajs-bundler](https://github.com/scalacenter/scalajs-bundler) or [sbt-jsdependencies +](https://github.com/scala-js/jsdependencies) + + ## Examples ```scala diff --git a/build.sbt b/build.sbt index 2d41939..065d200 100644 --- a/build.sbt +++ b/build.sbt @@ -1,36 +1,90 @@ - name := "udash-jquery" -version := "1.0.1" -organization := "io.udash" -scalaVersion := "2.12.1" -crossScalaVersions := Seq("2.11.8", "2.12.1") -scalacOptions in ThisBuild ++= Seq( - "-feature", - "-deprecation", - "-unchecked", - "-language:implicitConversions", - "-language:existentials", - "-language:dynamics", - "-Xfuture", - "-Xfatal-warnings", - "-Xlint:_,-missing-interpolator,-adapted-args" -) +inThisBuild(Seq( + version := "3.3.0-SNAPSHOT", + organization := "io.udash", +)) -jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Firefox) +val commonSettings = Seq( + scalaVersion := "2.13.12", + scalacOptions ++= Seq( + "-feature", + "-deprecation", + "-unchecked", + "-language:implicitConversions", + "-language:existentials", + "-language:dynamics", + "-language:experimental.macros", + "-Xfatal-warnings", + "-Xlint:_", + "-Ybackend-parallelism", "8", + "-Ycache-plugin-class-loader:last-modified", + "-Ycache-macro-class-loader:last-modified", + ), +) -libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.9.1", - "org.scalatest" %%% "scalatest" % "3.0.1" % Test, - "com.lihaoyi" %%% "scalatags" % "0.6.2" % Test +val commonJSSettings = Seq( + Test / scalaJSStage := FastOptStage, + Test / requireJsDomEnv := true, + npmExtraArgs += "--silent", + 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}/" + }, + webpack / version := "5.75.0", // TODO: can be removed when sbt-scalajs-bundler > 0.21.1 ) -jsDependencies += - "org.webjars" % "jquery" % "2.2.4" / "2.2.4/jquery.js" minified "2.2.4/jquery.min.js" +val deploymentConfiguration = Seq( + publishMavenStyle := true, + Test / publishArtifact := false, + pomIncludeRepository := { _ => false }, + + publishTo := sonatypePublishToBundle.value, -requiresDOM in Test := true -persistLauncher in Test := false -scalaJSUseRhino in Test := false + credentials in Global += Credentials( + "Sonatype Nexus Repository Manager", + "oss.sonatype.org", + sys.env.getOrElse("SONATYPE_USERNAME", ""), + sys.env.getOrElse("SONATYPE_PASSWORD", "") + ), + + pomExtra := { + https://github.com/UdashFramework/scala-js-jquery + + + Apache v.2 License + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + git@github.com:UdashFramework/scala-js-jquery.git + scm:git@github.com:UdashFramework/scala-js-jquery.git + + + + avsystem + AVSystem + http://www.avsystem.com/ + + + } +) lazy val root = project.in(file(".")) - .enablePlugins(ScalaJSPlugin) + .enablePlugins(ScalaJSBundlerPlugin, JSDependenciesPlugin) + .settings( + commonSettings, + commonJSSettings, + deploymentConfiguration, + + libraryDependencies ++= Seq( + "org.scala-js" %%% "scalajs-dom" % "2.7.0", + "org.scalatest" %%% "scalatest" % "3.2.9" % Test, + "com.lihaoyi" %%% "scalatags" % "0.10.0" % Test + ), + + Compile / npmDependencies += "jquery" -> "3.6.4", + jsDependencies += "org.webjars" % "jquery" % "3.6.4" / "3.6.4/jquery.js" minified s"3.6.4/jquery.min.js", + ) diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 75bb5f2..0000000 --- a/example/.gitignore +++ /dev/null @@ -1,132 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### Eclipse template -*.pydevproject -.metadata -.gradle -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath - -# Eclipse Core -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Java annotation processor (APT) -.factorypath - -# PDT-specific -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipse -### Maven template -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio - -*.iml - -## Directory-based project format: -.idea/ -# if you remove the above rule, at least ignore the following: - -# User-specific stuff: -# .idea/workspace.xml -# .idea/tasks.xml -# .idea/dictionaries - -# Sensitive or high-churn files: -# .idea/dataSources.ids -# .idea/dataSources.xml -# .idea/sqlDataSources.xml -# .idea/dynamic.xml -# .idea/uiDesigner.xml - -# Gradle: -# .idea/gradle.xml -# .idea/libraries - -# Mongo Explorer plugin: -# .idea/mongoSettings.xml - -## File-based project format: -*.ipr -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -### Java template -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -### Scala template -*.class -*.log - -# sbt specific -.cache -.history -.lib/ -dist/* -target/ -lib_managed/ -src_managed/ -project/boot/ -project/plugins/project/ - -# Scala-IDE specific -.scala_dependencies -.worksheet - - -generated/ \ No newline at end of file diff --git a/example/build.sbt b/example/build.sbt deleted file mode 100644 index 19f5556..0000000 --- a/example/build.sbt +++ /dev/null @@ -1,48 +0,0 @@ -name := "jquery-demo" - -version in ThisBuild := "1.0.1-SNAPSHOT" -scalaVersion in ThisBuild := "2.11.8" -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", - "-Xlint:_,-missing-interpolator,-adapted-args" -) - -val generatedDir = file("generated") -val `jquery-demo` = project.in(file(".")).enablePlugins(ScalaJSPlugin) - .settings( - libraryDependencies ++= deps.value, - persistLauncher in Compile := true, - - /* move these files out of target/. */ - crossTarget in (Compile, fullOptJS) := generatedDir, - crossTarget in (Compile, fastOptJS) := generatedDir, - crossTarget in (Compile, packageJSDependencies) := generatedDir, - crossTarget in (Compile, packageScalaJSLauncher) := generatedDir, - crossTarget in (Compile, packageMinifiedJSDependencies) := generatedDir, - - compile <<= (compile in Compile).dependsOn(compileStatics), - compileStatics := { - compileStaticsForRelease.value - (crossTarget.value / StaticFilesDir).***.get - }, - - 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", - artifactPath in(Compile, packageScalaJSLauncher) := - (crossTarget in(Compile, packageScalaJSLauncher)).value / StaticFilesDir / WebContent / "scripts" / "frontend-init.js" - ) \ No newline at end of file diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala deleted file mode 100644 index 9364f20..0000000 --- a/example/project/Dependencies.scala +++ /dev/null @@ -1,15 +0,0 @@ -import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ -import sbt._ - -object Dependencies extends Build { - val udashCoreVersion = "0.4.0" - val udashJQueryVersion = "1.0.1" - - val deps = Def.setting(Seq[ModuleID]( - "io.udash" %%% "udash-core-frontend" % udashCoreVersion, - "io.udash" %%% "udash-jquery" % udashJQueryVersion - )) - - val depsJS = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID]( - )) -} \ No newline at end of file diff --git a/example/project/UdashBuild.scala b/example/project/UdashBuild.scala deleted file mode 100644 index 464b556..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 extends Build { - 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 deleted file mode 100644 index e0cbc71..0000000 --- a/example/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version = 0.13.13 \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt deleted file mode 100644 index 26a69b3..0000000 --- a/example/project/plugins.sbt +++ /dev/null @@ -1,2 +0,0 @@ -logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13") \ 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 72b62d5..0000000 --- a/example/src/main/assets/index.dev.html +++ /dev/null @@ -1,15 +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.prod.html deleted file mode 100644 index 9c2609e..0000000 --- a/example/src/main/assets/index.prod.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - jquery-demo - - - - - - - -
- - \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala b/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala deleted file mode 100644 index 118e345..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala +++ /dev/null @@ -1,30 +0,0 @@ -package io.udash.demos.jquery - -import io.udash._ -import io.udash.utils.Bidirectional - -class RoutingRegistryDef extends RoutingRegistry[RoutingState] { - def matchUrl(url: Url): RoutingState = - url2State.applyOrElse(url.value.stripSuffix("/"), (x: String) => ErrorState) - - def matchState(state: RoutingState): Url = - Url(state2Url.apply(state)) - - private val (url2State, state2Url) = Bidirectional[String, RoutingState] { - case "" => IndexState - case "/add" => AddState - case "/addBack" => AddBackState - case "/after" => AfterBeforeState - case "/animate" => AnimateState - case "/append" => AppendPrependState - case "/attr" => AttrState - case "/callbacks" => CallbacksState - case "/children" => ChildrenState - case "/data" => DataState - case "/deferred" => DeferredState - case "/each" => EachState - case "/hide" => HideShowState - case "/offset" => OffsetPositionState - case "/on" => OnOneOffState - } -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala b/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala deleted file mode 100644 index 0ff8f68..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala +++ /dev/null @@ -1,27 +0,0 @@ -package io.udash.demos.jquery - -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 { - case RootState => RootViewPresenter - case IndexState => IndexViewPresenter - case AddState => AddViewPresenter - case AddBackState => AddBackViewPresenter - case AfterBeforeState => AfterBeforeViewPresenter - case AnimateState => AnimateViewPresenter - case AppendPrependState => AppendPrependViewPresenter - case AttrState => AttrViewPresenter - case CallbacksState => CallbacksViewPresenter - case ChildrenState => ChildrenViewPresenter - case DataState => DataViewPresenter - case DeferredState => DeferredViewPresenter - case EachState => EachViewPresenter - case HideShowState => HideShowViewPresenter - case OnOneOffState => OnOneOffViewPresenter - case OffsetPositionState => OffsetPositionViewPresenter - case _ => ErrorViewPresenter - } -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/init.scala b/example/src/main/scala/io/udash/demos/jquery/init.scala deleted file mode 100644 index 8bbe6ce..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/init.scala +++ /dev/null @@ -1,33 +0,0 @@ -package io.udash.demos.jquery - -import io.udash._ -import io.udash.wrappers.jquery._ -import org.scalajs.dom -import org.scalajs.dom.{Element, document} - -import scala.scalajs.js.JSApp -import scala.scalajs.js.annotation.JSExport - -object Context { - implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue - private val routingRegistry = new RoutingRegistryDef - private val viewPresenterRegistry = new StatesToViewPresenterDef - - implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState) -} - -object Init extends JSApp { - import Context._ - - @JSExport - override def main(): Unit = { - jQ(document).ready((_: Element) => { - val appRoot = jQ("#application").get(0) - if (appRoot.isEmpty) { - dom.console.error("Application root element not found! Check you index.html file!") - } else { - applicationInstance.run(appRoot.get) - } - }) - } -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/states.scala b/example/src/main/scala/io/udash/demos/jquery/states.scala deleted file mode 100644 index 2ef0306..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/states.scala +++ /dev/null @@ -1,41 +0,0 @@ -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) - -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) - -case object OnOneOffState extends RoutingState(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 deleted file mode 100644 index 2a427cf..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala +++ /dev/null @@ -1,14 +0,0 @@ -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) - -class ErrorView extends FinalView { - import scalatags.JsDom.all._ - - override def getTemplate: Modifier = - h3("URL not found!") -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala b/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala deleted file mode 100644 index 5874d47..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala +++ /dev/null @@ -1,22 +0,0 @@ -package io.udash.demos.jquery.views - -import io.udash._ -import org.scalajs.dom.{Element, Event} - -abstract class FunctionView extends FinalView { - import scalatags.JsDom.all._ - - protected val content: Element - protected val script: () => Any - - override def getTemplate: Modifier = - div( - content, - button( - onclick :+= ((_: Event) => { - script() - false - }) - )("Run script") - ) -} \ No newline at end of file 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 deleted file mode 100644 index aaf2e46..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ /dev/null @@ -1,35 +0,0 @@ -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) - -class IndexView extends FinalView { - import Context._ - - import scalatags.JsDom.all._ - - private val content = div( - "Take a look at following demo pages:", - ul( - li(a(href := AddState.url)(".add() & .css()")), - li(a(href := AddBackState.url)(".addBack() & .addClass()")), - li(a(href := AfterBeforeState.url)(".after() & .before()")), - li(a(href := AnimateState.url)(".animate() & .click()")), - li(a(href := AppendPrependState.url)(".append() & .prepend()")), - li(a(href := AttrState.url)(".attr()")), - li(a(href := CallbacksState.url)("Callbacks")), - li(a(href := ChildrenState.url)(".children()")), - li(a(href := DataState.url)(".data()")), - li(a(href := DeferredState.url)("Deferred")), - li(a(href := EachState.url)(".each()")), - li(a(href := HideShowState.url)(".hide() & .show()")), - li(a(href := OnOneOffState.url)(".on() & .one() & .off()")), - li(a(href := OffsetPositionState.url)(".offset() & .position()")) - ) - ) - - override def getTemplate: Modifier = content -} \ No newline at end of file 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 deleted file mode 100644 index c58cf5d..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala +++ /dev/null @@ -1,29 +0,0 @@ -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) - -class RootView extends View { - import Context._ - - import scalatags.JsDom.all._ - - private var child: Element = div().render - - private val content = div( - a(href := IndexState.url)(h1("jquery-demo")), - child - ) - - 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 deleted file mode 100644 index 76037ce..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala +++ /dev/null @@ -1,62 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -import scalatags.JsDom.tags2 - -object AddBackViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AddBackView) - -/** Based on examples from: jQuery Docs. */ -class AddBackView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".addBack() & .addClass()"), - tags2.style( - """.demo p, .demo div { - | margin: 5px; - | padding: 5px; - |} - |.border { - | border: 2px solid red; - |} - |.background { - | background: yellow; - |} - |.left, .right { - | width: 45%; - | float: left; - |} - |.right { - | margin-left: 3%; - |}""".stripMargin - ), - div(cls := "left")( - p(strong("Before ", code("addBack()"))), - div(cls := "before-addback")( - p("First Paragraph"), - p("Second Paragraph") - ) - ), - div(cls := "right")( - p(strong("After ", code("addBack()"))), - div(cls := "after-addback")( - p("First Paragraph"), - p("Second Paragraph") - ) - ) - ).render - - override protected val script = () => { - jQ( ".demo div.left, .demo div.right" ).find( "div, div > p" ).addClass( "border" ) - - // First Example - jQ( ".demo div.before-addback" ).find( "p" ).addClass( "background" ) - - // Second Example - jQ( ".demo div.after-addback" ).find( "p" ).addBack().addClass( "background" ) - } -} \ No newline at end of file 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 deleted file mode 100644 index c77042d..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala +++ /dev/null @@ -1,48 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -import scalatags.JsDom.tags2 - -object AddViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AddView) - -/** Based on examples from: jQuery Docs. */ -class AddView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".add() & .css()"), - tags2.style( - """.demo div { - | width: 60px; - | height: 60px; - | margin: 10px; - | float: left; - |} - |.demo p { - | clear: left; - | font-weight: bold; - | font-size: 16px; - | color: blue; - | margin: 0 10px; - | padding: 2px; - |}""".stripMargin - ), - div(), - div(), - div(), - div(), - div(), - div(), - p("Added this... (notice no border)") - ).render - - override protected val script = () => { - jQ(".demo div").css("border", "2px solid red") - .add(".demo p") - .css("background", "yellow") - } -} \ No newline at end of file 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 deleted file mode 100644 index 15ffc96..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala +++ /dev/null @@ -1,29 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -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) - -/** Based on examples from: jQuery Docs. */ -class AfterBeforeView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".after()"), - div( - p(cls := "after")("I would like to say: ") - ), - h3(".before()"), - div( - p(cls := "before")("is what I said...") - ) - ).render - - override protected val script = () => { - jQ(".after").after("Hello") - jQ(".before").before("Hello") - } -} \ No newline at end of file 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 deleted file mode 100644 index ad4c630..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala +++ /dev/null @@ -1,77 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.Element - -import scalatags.JsDom.tags2 - -object AnimateViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new AnimateView) - -/** Based on examples from: jQuery Docs. */ -class AnimateView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".animate() & .click()"), - tags2.style( - """.demo div { - | background-color: #bca; - | width: 200px; - | height: 1.1em; - | text-align: center; - | border: 2px solid green; - | margin: 3px; - | font-size: 14px; - |} - |.demo button { - | font-size: 14px; - |}""".stripMargin - ), - button(id := "go1", disabled := "disabled")("» Animate Block1"), - button(id := "go2", disabled := "disabled")("» Animate Block2"), - button(id := "go3", disabled := "disabled")("» Animate Both"), - button(id := "go4", disabled := "disabled")("» Reset"), - div(id := "block1")("Block1"), - div(id := "block2")("Block2") - ).render - - override protected val script = () => { - jQ("#go1").click((_: Element, _: JQueryEvent) => { - jQ( "#block1" ) - .animate(Map( - "width" -> "90%" - ), AnimationOptions( - queue = Some(false), - duration = Some(3000) - )) - .animate(Map("fontSize" -> "24px"), 1500) - .animate(Map("borderRightWidth" -> "15px"), 1500) - }) - - jQ("#go2").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("#go4").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]( - "width" -> "", - "fontSize" -> "", - "borderWidth" -> "" - )) - }) - - jQ(".demo button").prop("disabled", "") - } -} \ No newline at end of file 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 deleted file mode 100644 index 6640498..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala +++ /dev/null @@ -1,25 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -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) - -/** Based on examples from: jQuery Docs. */ -class AppendPrependView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".append()"), - p(id := "append")("I would like to say: "), - h3(".prepend()"), - p(id := "prepend")("amigo!") - ).render - - override protected val script = () => { - jQ("#append").append("hello") - jQ("#prepend").prepend("Hello ") - } -} \ No newline at end of file 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 deleted file mode 100644 index 433981f..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala +++ /dev/null @@ -1,51 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -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) - -/** Based on examples from: jQuery Docs. */ -class AttrView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".attr() & .prop()"), - input(id := "check1", tpe := "checkbox", checked := "checked"), - label(`for` := "check1")("Check me"), - p(), - button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", "checked").change() - false - }))(".attr(\"data-checked\", \"checked\")"), - button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", "").change() - false - }))(".attr(\"data-checked\", \"\")"), - button(onclick :+= ((_: Event) => { - jQ(".demo input").attr("data-checked", null).change() - false - }))(".attr(\"data-checked\", null)"), br(), - button(onclick :+= ((_: Event) => { - jQ(".demo input").prop("checked", true).change() - false - }))(".prop(\"checked\", true)"), - button(onclick :+= ((_: Event) => { - jQ(".demo input").prop("checked", false).change() - false - }))(".prop(\"checked\", false)") - ).render - - override protected val script = () => { - jQ(".demo input").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() - } -} \ 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 deleted file mode 100644 index aa297a2..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala +++ /dev/null @@ -1,50 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -import scala.scalajs.js - -object CallbacksViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new CallbacksView) - -/** Based on examples from: jQuery Docs. */ -class CallbacksView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3("Callbacks"), - ul(id := "plus"), - ul(id := "minus"), - ul(id := "mul"), - ul(id := "div") - ).render - - override protected val script = () => { - val callbacks = jQ.callbacks[js.Function1[(Int, Int), js.Any], (Int, Int)]() - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#plus").append(li(s"$a + $b = ${a+b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#minus").append(li(s"$a - $b = ${a-b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#mul").append(li(s"$a * $b = ${a*b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#div").append(li(s"$a / $b = ${a/b}").render) - }) - - callbacks.fire(1, 1) - callbacks.fire(3, 3) - callbacks.fire(7, 4) - - callbacks.disable() - 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 deleted file mode 100644 index 845042f..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala +++ /dev/null @@ -1,29 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -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) - -/** Based on examples from: jQuery Docs. */ -class ChildrenView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".children()"), - div( - span("Hello"), - p(cls := "selected")("Hello again"), - div(cls := "selected")("and again"), - p("and one last time.") - ) - ).render - - override protected val script = () => { - jQ(".demo div").children().css("color", "blue") - jQ(".demo div").children(".selected").css("border-bottom", "3px double red") - jQ(".demo div").children("div.selected").css("border-top", "1px dashed green") - } -} \ No newline at end of file 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 deleted file mode 100644 index 8d67ac0..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala +++ /dev/null @@ -1,30 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -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) - -/** Based on examples from: jQuery Docs. */ -class DataView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".data()"), - div( - "The values stored were ", - span("_"), - " and ", - span("_") - ) - ).render - - override protected val script = () => { - jQ(".demo div").data("test", Map("first" -> 16, "last" -> "pizza!")) - val data: Map[String, Any] = jQ(".demo div").data("test").get.asInstanceOf[Map[String, Any]] - jQ(".demo div span:first").text(data.get("first").get.toString) - jQ(".demo div span:last").text(data.get("last").get.toString) - } -} \ No newline at end of file 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 deleted file mode 100644 index edb6ced..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala +++ /dev/null @@ -1,55 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.Event - -import scala.scalajs.js - -object DeferredViewPresenter extends DefaultViewPresenterFactory[IndexState.type](() => new DeferredView) - -/** Based on examples from: jQuery Docs. */ -class DeferredView extends FunctionView { - import scalatags.JsDom.all._ - - var deferred: JQueryDeferred[js.Function1[Int, js.Any], Int] = null - - override protected val content = div(cls := "demo")( - h3("Deferred"), - div( - div(id := "deferred")("???"), - button( - id := "resolve", - disabled := "disabled", - onclick := ((ev: Event) => { - deferred.resolve(5) - }) - )("Resolve(5)"), - button( - id := "reject", - disabled := "disabled", - onclick := ((ev: Event) => { - deferred.reject(-5) - }) - )("Reject(-5)"), - button( - id := "notify", - disabled := "disabled", - onclick := ((ev: Event) => { - deferred.notify(1) - }) - )("Notify(1)") - ) - ).render - - override protected val script = () => { - jQ(".demo button").prop("disabled", "") - deferred = jQ.deferred[js.Function1[Int, js.Any], Int]() - jQ("#deferred").text(s"Waiting...") - deferred.done((i: Int) => jQ("#deferred").text(s"Done: $i")) - deferred.fail((i: Int) => jQ("#deferred").text(s"Fail: $i")) - deferred.progress((i: Int) => jQ("#deferred").text(s"Progress: $i")) - } -} \ No newline at end of file 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 deleted file mode 100644 index 10e9395..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala +++ /dev/null @@ -1,27 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -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) - -/** Based on examples from: jQuery Docs. */ -class EachView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".each()"), - div("Click button"), - div("to iterate through"), - div("these divs.") - ).render - - override protected val script = () => { - jQ(".demo div").each((el: Element, idx: Int) => { - jQ(el).replaceWith(span(s"${el.textContent} ").render) - }) - } -} \ No newline at end of file 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 deleted file mode 100644 index fcd8246..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala +++ /dev/null @@ -1,27 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -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) - -/** Based on examples from: jQuery Docs. */ -class HideShowView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".hide() & .show()"), - div("Click button to hide me") - ).render - - override protected val script = () => { - jQ(".demo div") - .hide(AnimationOptions( - duration = Some(3000), - easing = Some(EasingFunction.linear) - )) - .show(1500, EasingFunction.swing) - } -} \ No newline at end of file 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 deleted file mode 100644 index d2304d9..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala +++ /dev/null @@ -1,34 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.{IndexState, 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) - -/** Based on examples from: jQuery Docs. */ -class OffsetPositionView extends FunctionView { - import scalatags.JsDom.all._ - - override protected val content = div(cls := "demo")( - h3(".offset() & .position()"), - div(style := "padding: 12px; border: 1px red solid;")( - p(style := "margin-left: 10px; border: 1px blue solid;")("Hello world!") - ), - p(id := "results")("") - ).render - - override protected val script = () => { - val div = jQ(".demo div") - val p = jQ(".demo div p") - jQ("#results").html( - s"""Div offset: (${div.offset().top}, ${div.offset().left})
- |Div position: (${div.position().top}, ${div.position().left})
- |Paragraph offset: (${p.offset().top}, ${p.offset().left})
- |Paragraph position: (${p.position().top}, ${p.position().left}) - """.stripMargin - ) - } -} \ No newline at end of file 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 deleted file mode 100644 index e237e37..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala +++ /dev/null @@ -1,44 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash._ -import io.udash.demos.jquery.IndexState -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) - -/** Based on examples from: jQuery Docs. */ -class OnOneOffView extends FunctionView { - import scalatags.JsDom.all._ - - val onCallback = (_: Element, _: JQueryEvent) => - jQ(".demo ul").append(li("This will be added on every click").render) - val oneCallback = (_: Element, _: JQueryEvent) => - jQ(".demo ul").append(li("This will be added only once").render) - - override protected val content = div(cls := "demo")( - h3(".on() & .one() & .off()"), - button(id := "click", disabled := "disabled")("Click me"), - ul(), - button( - id := "off", - disabled := "disabled", - onclick :+= ((_: Event) => { - jQ(".demo #click") - .off("click", onCallback) - .off("click", oneCallback) - false - }) - )("Off") - ).render - - override protected val script = () => { - jQ(".demo #click") - .on("click", onCallback) - .one("click", oneCallback) - - jQ(".demo button") - .prop("disabled", "") - } -} \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index e0cbc71..ff95dc2 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1,2 @@ -sbt.version = 0.13.13 \ No newline at end of file +# suppress inspection "UnusedProperty" +sbt.version=1.9.6 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 5aec49e..fa4a47a 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,9 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") +addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") -libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.1.3" +// Deployment configuration +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10") \ No newline at end of file diff --git a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala index 6e4b757..89f1be9 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala @@ -1,12 +1,11 @@ package io.udash.wrappers.jquery -import org.scalajs.dom._ +import org.scalajs.dom.Element 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 { @@ -36,14 +35,6 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def addClass(className: String): JQuery = js.native - /** Adds the specified class(es) to each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def addClass(function: js.Function1[Int, String]): JQuery = js.native - - /** Adds the specified class(es) to each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def addClass(function: js.Function2[Int, String, String]): JQuery = js.native - /** Insert content, specified by the parameter, after each element in the set of matched elements.
* See: jQuery Docs */ def after(content: (Selector | Element | JQuery)*): JQuery = js.native @@ -52,22 +43,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def after(function: js.Function2[Int, String, String | Element | JQuery]): JQuery = js.native - /** Perform a custom animation of a set of CSS properties.
- * See: jQuery Docs */ - private[jquery] def animate(properties: js.Dictionary[Any], duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Perform a custom animation of a set of CSS properties.
- * See: jQuery Docs */ - private[jquery] def animate(properties: js.Dictionary[Any], options: js.Dictionary[Any]): JQuery = js.native - /** Insert content, specified by the parameter, to the end of each element in the set of matched elements.
* See: jQuery Docs */ def append(content: (String | Element | JQuery)*): JQuery = js.native - /** Insert content, specified by the parameter, to the end of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def append(function: js.ThisFunction2[Element, Int, String, Any]): JQuery = js.native - /** Insert every element in the set of matched elements to the end of the target.
* See: jQuery Docs */ def appendTo(target: (Selector | Element | JQuery)*): JQuery = js.native @@ -76,32 +55,18 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def attr(attributeName: String, attributeValue: String | Int | Double | Boolean): JQuery = js.native - /** Get the value of an attribute for the first element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def attr(attributeName: String): UndefOr[String] = js.native - - /** Set one or more attributes for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def attr(attributes: js.Dictionary[String | Int | Double | Boolean]): JQuery = js.native - - /** Set one or more attributes for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def attr(attributeName: String, function: js.Function2[Int, String, String | Int | Double | Boolean]): JQuery = js.native - /** Insert content, specified by the parameter, before each element in the set of matched elements.
* See: jQuery Docs */ def before(content: (String | Element | JQuery)*): JQuery = js.native - /** Insert content, specified by the parameter, before each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def before(content: js.Function2[Int, String, String | Element | JQuery]): JQuery = js.native - /** 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.
@@ -122,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.
@@ -130,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 */ @@ -143,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.
@@ -153,33 +120,18 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def css(attributeName: String, attributeValue: String | Int | Double | Boolean): JQuery = js.native - /** Set one or more CSS properties for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def css(attributeName: String, attributeFun: js.Function2[Int, String, String | Int | Double | Boolean]): JQuery = js.native - - /** Set one or more CSS properties for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def css(properties: js.Dictionary[String | Int | Double | Boolean]): JQuery = js.native - /** Store arbitrary data associated with the matched elements.
* See: jQuery Docs */ def data(key: String, value: Any): JQuery = js.native - /** Store arbitrary data associated with the matched elements.
- * See: jQuery Docs */ - private[jquery] def data(obj: js.Dictionary[Any]): JQuery = js.native - /** Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
* See: jQuery Docs */ def data(): js.Dynamic = js.native - /** Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
- * See: jQuery Docs */ - private[jquery] def data(key: String): UndefOr[Any] = js.native - /** 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.
@@ -192,11 +144,7 @@ trait JQuery extends js.Object { /** Remove the set of matched elements from the DOM.
* See: jQuery Docs */ - def detach(selector: Selector): JQuery = js.native - - /** Iterate over a jQuery object, executing a function for each matched element.
- * See: jQuery Docs */ - private[jquery] def each(function: js.ThisFunction1[Element, Int, Any]): JQuery = js.native + def detach(selector: Selector = js.native): JQuery = js.native /** Remove all child nodes of the set of matched elements from the DOM.
* See: jQuery Docs */ @@ -216,58 +164,30 @@ trait JQuery extends js.Object { @JSName("eq") def at(index: Int): JQuery = js.native - /** Display the matched elements by fading them to opaque.
- * See: jQuery Docs */ - def fadeIn(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native + /** Reduce the set of matched elements to the even ones in the set, numbered from zero.
+ * See: jQuery Docs */ + def even(): JQuery = js.native /** Display the matched elements by fading them to opaque.
* See: jQuery Docs */ - private[jquery] def fadeIn(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display the matched elements by fading them to opaque.
- * See: jQuery Docs */ - private[jquery] def fadeIn(options: js.Dictionary[Any]): JQuery = js.native + def fadeIn(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native /** Hide the matched elements by fading them to transparent.
* See: jQuery Docs */ def fadeOut(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Hide the matched elements by fading them to transparent.
- * See: jQuery Docs */ - private[jquery] def fadeOut(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Hide the matched elements by fading them to transparent.
- * See: jQuery Docs */ - private[jquery] def fadeOut(options: js.Dictionary[Any]): JQuery = js.native - /** Adjust the opacity of the matched elements.
* See: jQuery Docs */ def fadeTo(duration: Int, opacity: Double): JQuery = js.native - /** Adjust the opacity of the matched elements.
- * See: jQuery Docs */ - private[jquery] def fadeTo(duration: Int, opacity: Double, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - /** Adjust the opacity of the matched elements.
* See: jQuery Docs */ def fadeTo(duration: Int, opacity: Double, easing: EasingFunction): JQuery = js.native - /** Adjust the opacity of the matched elements.
- * See: jQuery Docs */ - private[jquery] def fadeTo(duration: Int, opacity: Double, easing:String, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - /** Display or hide the matched elements by animating their opacity.
* See: jQuery Docs */ def fadeToggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Display or hide the matched elements by animating their opacity.
- * See: jQuery Docs */ - private[jquery] def fadeToggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display or hide the matched elements by animating their opacity.
- * See: jQuery Docs */ - private[jquery] def fadeToggle(options: js.Dictionary[Any]): JQuery = js.native - /** Reduce the set of matched elements to those that match the selector or pass the function's test.
* See: jQuery Docs */ def filter(selector: Selector | JQuery): JQuery = js.native @@ -276,13 +196,9 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def filter(elements: Element*): JQuery = js.native - /** Reduce the set of matched elements to those that match the selector or pass the function's test.
- * See: jQuery Docs */ - private[jquery] def filter(function: js.ThisFunction2[Element, Int, Element, Boolean]): JQuery = js.native - /** 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 */ @@ -294,29 +210,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 - /** Retrieve one of the elements matched by the jQuery object.
- * See: jQuery Docs */ - private[jquery] def get(index: Int): UndefOr[Element] = js.native - - /** Retrieve the elements matched by the jQuery object.
- * See: jQuery Docs */ - private[jquery] def get(): js.Array[Element] = 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 */ @@ -330,22 +241,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def height(value: String | Int | Double): JQuery = js.native - /** Set the CSS height of every matched element.
- * See: jQuery Docs */ - private[jquery] def height(function: js.ThisFunction2[Element, Int, Int, String | Int | Double]): JQuery = js.native - /** Hide the matched elements.
* See: jQuery Docs */ def hide(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Hide the matched elements.
- * See: jQuery Docs */ - private[jquery] def hide(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Hide the matched elements.
- * See: jQuery Docs */ - private[jquery] def hide(options: js.Dictionary[Any]): JQuery = js.native - /** Get the HTML contents of the first element in the set of matched elements.
* See: jQuery Docs */ def html(): String = js.native @@ -370,10 +269,6 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def innerHeight(value: Double | String): JQuery = js.native - /** Set the CSS inner height of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def innerHeight(function: js.ThisFunction2[Element, Int, Double, Int | Double | String]): JQuery = js.native - /** Get the current computed inner width for the first element in the set of matched elements, including padding but not border.
* See: jQuery Docs */ def innerWidth(): Double = js.native @@ -382,25 +277,17 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def innerWidth(value: Int | Double | String): JQuery = js.native - /** Set the CSS inner width of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def innerWidth(function: js.ThisFunction2[Element, Int, Double, Int | Double | String]): JQuery = js.native - /** 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 - - /** 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 */ - private[jquery] def is(function: js.ThisFunction2[Element, Int, Element, Boolean]): Boolean = js.native + def is(selector: Selector | Element | JQuery): Boolean = js.native /** A string containing the jQuery version number.
* See: jQuery Docs */ @@ -409,16 +296,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.
@@ -433,47 +323,46 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def load(url: String, data: js.Any = js.native): JQuery = js.native - /** Load data from the server and place the returned HTML into the matched element.
- * See: jQuery Docs */ - private[jquery] def load(url: String, data: js.Any, callback: js.ThisFunction3[Element, String, String, JQueryXHR, Any]): JQuery = js.native - - /** Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
- * See: jQuery Docs */ - private[jquery] def map(callback: js.Function2[Int, Element, Any]): JQuery = js.native - /** 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.
@@ -490,15 +379,15 @@ 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 */ def not(el: Element*): JQuery = js.native - /** Remove elements from the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def not(function: js.ThisFunction2[Element, Int, Element, Boolean]): JQuery = js.native + /** Reduce the set of matched elements to the odd ones in the set, numbered from zero.
+ * See: jQuery Docs */ + def odd(): JQuery = js.native /** Remove an event handler.
* See: jQuery Docs */ @@ -510,79 +399,20 @@ trait JQuery extends js.Object { /** Remove an event handler.
* See: jQuery Docs */ - def off(jEvent: JQueryEvent, selector: String = js.native): JQuery = js.native - - // Don't use this method directly. Use CallbackRegistration::unregister() returned from on() instead - private[jquery] def off(events: String, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Get the current coordinates of the first element in the set of matched elements, relative to the document.
- * See: jQuery Docs */ - private[jquery] def offset(): js.Dictionary[Double] = js.native - - /** Get the current coordinates of the first element in the set of matched elements, relative to the document.
- * See: jQuery Docs */ - private[jquery] def offset(coordinates: js.Dictionary[Int | Double]): 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 */ def offsetParent(): JQuery = js.native - /** Attach an event handler function for one or more events to the selected elements.
- * See: jQuery Docs */ - private[jquery] def on(events: String, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach an event handler function for one or more events to the selected elements.
- * See: jQuery Docs */ - private[jquery] def on(events: String, data: js.Any, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach an event handler function for one or more events to the selected elements.
- * See: jQuery Docs */ - private[jquery] def on(events: String, selector: String, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach an event handler function for one or more events to the selected elements.
- * See: jQuery Docs */ - private[jquery] def on(events: String, selector: String, data: js.Any, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
- * See: jQuery Docs */ - private[jquery] def one(events: String, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
- * See: jQuery Docs */ - private[jquery] def one(events: String, data: js.Any, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
- * See: jQuery Docs */ - private[jquery] def one(events: String, selector: String, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
- * See: jQuery Docs */ - private[jquery] def one(events: String, selector: String, data: js.Any, callback: js.ThisFunction1[Element, JQueryEvent, Any]): JQuery = js.native - - /** Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns a number (without "px") representation of the value or null if called on an empty set of elements.
- * See: jQuery Docs */ - def outerHeight(includeMargin: Boolean = js.native): Double = js.native - /** Set the CSS outer Height of each element in the set of matched elements.
* See: jQuery Docs */ def outerHeight(value: Int | Double | String): JQuery = js.native - /** Set the CSS outer Height of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def outerHeight(function: js.ThisFunction2[Element, Int, Double, Double]): JQuery = js.native - - /** Get the current computed width for the first element in the set of matched elements, including padding and border.
- * See: jQuery Docs */ - def outerWidth(includeMargin: Boolean = js.native): Double = js.native - /** Set the CSS outer width of each element in the set of matched elements.
* See: jQuery Docs */ def outerWidth(value: Int | Double | String): JQuery = js.native - /** Set the CSS outer width of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def outerWidth(function: js.ThisFunction2[Element, Int, Double, Double]): JQuery = js.native - /** Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
* See: jQuery Docs */ def parent(selector: Selector = js.native): JQuery = js.native @@ -595,18 +425,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def parentsUntil(selector: Selector | Element | JQuery = js.native, filter: Selector = js.native): JQuery = js.native - /** Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
- * See: jQuery Docs */ - private[jquery] def position(): js.Dictionary[Double] = js.native - /** Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
* See: jQuery Docs */ def prepend(content: (String | Element | JQuery)*): JQuery = js.native - /** Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def prepend(function: js.ThisFunction2[Element, Int, String, Any]): JQuery = js.native - /** Insert every element in the set of matched elements to the beginning of the target.
* See: jQuery Docs */ def prependTo(target: (Selector | Element | JQuery)*): JQuery = js.native @@ -635,26 +457,6 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def prop(propertyName: String, value: js.Any): JQuery = js.native - /** Set one or more properties for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def prop(propertyName: String, function: js.ThisFunction2[Element, Int, js.Any, Any]): JQuery = js.native - - /** Set one or more properties for the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def prop(properties: js.Dictionary[Any]): JQuery = js.native - - /** Add a collection of DOM elements onto the jQuery stack.
- * See: jQuery Docs */ - private[jquery] def pushStack(elements: js.Array[Any]): JQuery = js.native - - /** Add a collection of DOM elements onto the jQuery stack.
- * See: jQuery Docs */ - private[jquery] def pushStack(elements: js.Array[Any], name: String, arguments: js.Array[Any]): JQuery = js.native - - /** Specify a function to execute when the DOM is fully loaded.
- * See: jQuery Docs */ - private[jquery] def ready(callback: js.ThisFunction0[Element, Any]): JQuery = js.native - /** Remove the set of matched elements from the DOM.
* See: jQuery Docs */ def remove(selector: String = js.native): JQuery = js.native @@ -667,18 +469,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def removeClass(className: String*): JQuery = js.native - /** Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def removeClass(function: js.Function2[Int, String, String]): JQuery = js.native - /** Remove a previously-stored piece of data.
* See: jQuery Docs */ def removeData(name: String = js.native): JQuery = js.native - /** Remove a previously-stored piece of data.
- * See: jQuery Docs */ - private[jquery] def removeData(list: js.Array[String]): JQuery = js.native - /** Remove a property for the set of matched elements.
* See: jQuery Docs */ def removeProp(propertyName: String): JQuery = js.native @@ -693,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.
@@ -717,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.
@@ -731,17 +528,9 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def show(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Display the matched elements.
- * See: jQuery Docs */ - private[jquery] def show(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display the matched elements.
- * See: jQuery Docs */ - private[jquery] def show(options: js.Dictionary[Any]): JQuery = js.native - /** 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 */ @@ -751,44 +540,21 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def slideDown(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Display the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideDown(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideDown(options: js.Dictionary[Any]): JQuery = js.native - /** Display or hide the matched elements with a sliding motion.
* See: jQuery Docs */ def slideToggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Display or hide the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideToggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display or hide the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideToggle(options: js.Dictionary[Any]): JQuery = js.native - /** Hide the matched elements with a sliding motion.
* See: jQuery Docs */ def slideUp(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Hide the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideUp(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Hide the matched elements with a sliding motion.
- * See: jQuery Docs */ - private[jquery] def slideUp(options: js.Dictionary[Any]): JQuery = js.native - /** Stop the currently-running animation on the matched elements.
* See: jQuery Docs */ def stop(queue: String = js.native, clearQueue: Boolean = js.native, jumpToEnd: Boolean = js.native): JQuery = js.native /** 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.
@@ -799,14 +565,6 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def text(text: String | Double | Int | Boolean): JQuery = js.native - /** Set the content of each element in the set of matched elements to the specified text.
- * See: jQuery Docs */ - private[jquery] def text(function: js.ThisFunction2[Element, Int, String, String]): JQuery = js.native - - /** Retrieve all the elements contained in the jQuery set, as an array.
- * See: jQuery Docs */ - private[jquery] def toArray(): js.Array[Element] = js.native - /** Display or hide the matched elements.
* See: jQuery Docs */ def toggle(display: Boolean): JQuery = js.native @@ -815,14 +573,6 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def toggle(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native - /** Display or hide the matched elements.
- * See: jQuery Docs */ - private[jquery] def toggle(duration: Int, easing: EasingFunction, callback: js.ThisFunction0[Element, Any]): JQuery = js.native - - /** Display or hide the matched elements.
- * See: jQuery Docs */ - private[jquery] def toggle(options: js.Dictionary[Any]): JQuery = js.native - /** 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(className: String): JQuery = js.native @@ -831,25 +581,13 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def toggleClass(className: String, state: Boolean): JQuery = js.native - /** 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 */ - private[jquery] def toggleClass(function: js.Function3[Int, String, Boolean, String], state: Boolean = js.native): JQuery = js.native - /** 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 - - /** Execute all handlers and behaviors attached to the matched elements for the given event type.
- * See: jQuery Docs */ - private[jquery] def trigger(event: String | JQueryEvent, extraParams: js.Dictionary[Any] | js.Array[Any]): 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 trigger(event: EventName | JQueryEvent): JQuery = js.native /** Execute all handlers attached to an element for an event.
* See: jQuery Docs */ - private[jquery] def triggerHandler(event: String | JQueryEvent, extraParams: js.Dictionary[Any] | js.Array[Any]): 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 */ @@ -865,11 +603,6 @@ trait JQuery extends js.Object { @JSName("val") def value(value: String | Int | Double | js.Array[Any]): JQuery = js.native - /** Set the value of each element in the set of matched elements.
- * See: jQuery Docs */ - @JSName("val") - private[jquery] def value(function: js.ThisFunction2[Element, Int, String, String]): JQuery = js.native - /** Get the current computed width for the first element in the set of matched elements.
* See: jQuery Docs */ def width(): Double = js.native @@ -878,53 +611,35 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def width(value: String | Int | Double): JQuery = js.native - /** Set the CSS width of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def width(function: js.ThisFunction2[Element, Int, Int, String | Int | Double]): JQuery = js.native - /** Wrap an HTML structure around each element in the set of matched elements.
* See: jQuery Docs */ def wrap(wrappingElement: Selector | Element | JQuery): JQuery = js.native - /** Wrap an HTML structure around each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def wrap(function: js.ThisFunction1[Element, Int, String | JQuery]): JQuery = js.native - /** Wrap an HTML structure around all elements in the set of matched elements.
* See: jQuery Docs */ def wrapAll(wrappingElement: Selector | Element | JQuery): JQuery = js.native - /** Wrap an HTML structure around all elements in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def wrapAll(function: js.ThisFunction1[Element, Int, String | JQuery]): JQuery = js.native - /** Wrap an HTML structure around the content of each element in the set of matched elements.
* See: jQuery Docs */ def wrapInner(wrappingElement: Selector | Element | JQuery): JQuery = js.native - - /** Wrap an HTML structure around the content of each element in the set of matched elements.
- * See: jQuery Docs */ - private[jquery] def wrapInner(function: js.ThisFunction1[Element, Int, String | JQuery]): JQuery = js.native } object JQuery { - import scala.scalajs.js.`|` - trait CallbackRegistration { 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.off(event, c)) + unreg: (String, ThisFunction1[Element, JQueryEvent, Any]) => js.Any = (event, c) => jquery.asInstanceOf[js.Dynamic].off(event, c)) extends CallbackRegistration { private val c: ThisFunction1[Element, JQueryEvent, Any] = callback reg(c) @@ -934,100 +649,128 @@ object JQuery { /** Adds the specified class(es) to each element in the set of matched elements.
* See: jQuery Docs */ - def addClass(function: (Int) => String): JQuery = jquery.addClass(function) + 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) => String): JQuery = jquery.addClass(function) + def addClass(function: (Int) => String): JQuery = + jquery.asInstanceOf[js.Dynamic].addClass(function).asInstanceOf[JQuery] + + /** Adds the specified class(es) to each element in the set of matched elements.
+ * See: jQuery Docs */ + def addClass(function: (Int, String) => String): JQuery = + jquery.asInstanceOf[js.Dynamic].addClass(function).asInstanceOf[JQuery] /** Perform a custom animation of a set of CSS properties.
* See: jQuery Docs */ def animate(properties: Map[String, Any], duration: Int = 400, easing: EasingFunction = EasingFunction.swing, callback: (Element) => Any = (_) => {}): JQuery = - jquery.animate(properties.toJSDictionary, duration, easing, callback) + jquery.asInstanceOf[js.Dynamic].animate(properties.toJSDictionary, duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Perform a custom animation of a set of CSS properties.
* See: jQuery Docs */ - def animate(properties: Map[String, Any], options: AnimationOptions): JQuery = jquery.animate(properties.toJSDictionary, options.toJSDictionary) + def animate(properties: Map[String, Any], options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].animate(properties.toJSDictionary, options.toJSDictionary).asInstanceOf[JQuery] /** Insert content, specified by the parameter, to the end of each element in the set of matched elements.
* See: jQuery Docs */ - def append(function: (Element, Int, String) => Any): JQuery = jquery.append(function) + def append(function: (Element, Int, String) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].append(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Get the value of an attribute for the first element in the set of matched elements.
* See: jQuery Docs */ - def attr(attributeName: String): Option[String] = jquery.attr(attributeName).toOption + def attr(attributeName: String): Option[String] = + jquery.asInstanceOf[js.Dynamic].attr(attributeName).asInstanceOf[UndefOr[String]].toOption /** Set one or more attributes for the set of matched elements.
* See: jQuery Docs */ - def attr(attributes: Map[String, String | Int | Double | Boolean]): JQuery = jquery.attr(attributes.toJSDictionary) + def attr(attributes: Map[String, String | Int | Double | Boolean]): JQuery = + jquery.asInstanceOf[js.Dynamic].attr(attributes.toJSDictionary).asInstanceOf[JQuery] /** Set one or more attributes for the set of matched elements.
* See: jQuery Docs */ - def attr(attributeName: String, function: (Int, String) => String | Int | Double | Boolean): JQuery = jquery.attr(attributeName, function) + def attr(attributeName: String, function: (Int, String) => String | Int | Double | Boolean): JQuery = + jquery.asInstanceOf[js.Dynamic].attr(attributeName, function).asInstanceOf[JQuery] /** Insert content, specified by the parameter, before each element in the set of matched elements.
* See: jQuery Docs */ - def before(content: (Int, String) => String | Element | JQuery): JQuery = jquery.before(content) + def before(content: (Int, String) => String | Element | JQuery): JQuery = + jquery.asInstanceOf[js.Dynamic].before(content).asInstanceOf[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.
* See: jQuery Docs */ - def css(propertyNames: Map[String, String | Int | Double | Boolean]): JQuery = jquery.css(propertyNames.toJSDictionary) + def css(propertyNames: Map[String, String | Int | Double | Boolean]): JQuery = + jquery.asInstanceOf[js.Dynamic].css(propertyNames.toJSDictionary).asInstanceOf[JQuery] /** Set one or more CSS properties for the set of matched elements.
* See: jQuery Docs */ - def css(attributeName: String, attributeFun: (Int, String) => String | Int | Double | Boolean): JQuery = jquery.css(attributeName, attributeFun) + def css(attributeName: String, attributeFun: (Int, String) => String | Int | Double | Boolean): JQuery = + jquery.asInstanceOf[js.Dynamic].css(attributeName, attributeFun).asInstanceOf[JQuery] /** Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
* See: jQuery Docs */ - def data(key: String): Option[Any] = jquery.data(key).toOption + def data(key: String): Option[Any] = + jquery.asInstanceOf[js.Dynamic].data(key).asInstanceOf[UndefOr[Any]].toOption /** Store arbitrary data associated with the matched elements.
* See: jQuery Docs */ - def data(obj: Map[String, Any]): JQuery = jquery.data(obj.toJSDictionary) + def data(obj: Map[String, Any]): JQuery = + jquery.asInstanceOf[js.Dynamic].data(obj.toJSDictionary).asInstanceOf[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.
* See: jQuery Docs */ - def each(callback: (Element, Int) => Any): JQuery = jquery.each(callback) + def each(callback: (Element, Int) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].each(js.ThisFunction.fromFunction2(callback)).asInstanceOf[JQuery] /** Bind an event handler to the "error" JavaScript event on an element.
* See: jQuery Docs */ @@ -1041,89 +784,109 @@ object JQuery { /** Display the matched elements by fading them to opaque.
* See: jQuery Docs */ - def fadeIn(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeIn(duration, easing, callback) + def fadeIn(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeIn(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display the matched elements by fading them to opaque.
* See: jQuery Docs */ - def fadeIn(options: AnimationOptions): JQuery = jquery.fadeIn(options.toJSDictionary) + def fadeIn(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeIn(options.toJSDictionary).asInstanceOf[JQuery] /** Hide the matched elements by fading them to transparent.
* See: jQuery Docs */ - def fadeOut(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeOut(duration, easing, callback) + def fadeOut(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeOut(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Hide the matched elements by fading them to transparent.
* See: jQuery Docs */ - def fadeOut(options: AnimationOptions): JQuery = jquery.fadeOut(options.toJSDictionary) + def fadeOut(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeOut(options.toJSDictionary).asInstanceOf[JQuery] /** Adjust the opacity of the matched elements.
* See: jQuery Docs */ - def fadeTo(duration: Int, opacity: Double, callback: (Element) => Any): JQuery = jquery.fadeTo(duration, opacity, callback) + def fadeTo(duration: Int, opacity: Double, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeTo(duration, opacity, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Adjust the opacity of the matched elements.
* See: jQuery Docs */ - def fadeTo(duration: Int, opacity: Double, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeTo(duration, opacity, easing, callback) + def fadeTo(duration: Int, opacity: Double, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeTo(duration, opacity, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display or hide the matched elements by animating their opacity.
* See: jQuery Docs */ - def fadeToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.fadeToggle(duration, easing, callback) + def fadeToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeToggle(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display or hide the matched elements by animating their opacity.
* See: jQuery Docs */ - def fadeToggle(options: AnimationOptions): JQuery = jquery.fadeToggle(options.toJSDictionary) + def fadeToggle(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].fadeToggle(options.toJSDictionary).asInstanceOf[JQuery] /** Reduce the set of matched elements to those that match the selector or pass the function's test.
* See: jQuery Docs */ - def filter(function: (Element, Int, Element) => Boolean): JQuery = jquery.filter(function) + def filter(function: (Element, Int, Element) => Boolean): JQuery = + jquery.asInstanceOf[js.Dynamic].filter(js.ThisFunction.fromFunction3(function)).asInstanceOf[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.
* See: jQuery Docs */ - def get(index: Int): Option[Element] = jquery.get(index).toOption + def get(index: Int): Option[Element] = + jquery.asInstanceOf[js.Dynamic].get(index).asInstanceOf[UndefOr[Element]].toOption /** Retrieve the elements matched by the jQuery object.
* See: jQuery Docs */ - def get(): Seq[Element] = jquery.get().toSeq + def get(): Seq[Element] = + jquery.asInstanceOf[js.Dynamic].get().asInstanceOf[js.Array[Element]].toSeq /** Set the CSS height of every matched element.
* See: jQuery Docs */ - def height(function: (Element, Int, Int) => String | Int | Double): JQuery = jquery.height(function) + def height(function: (Element, Int, Int) => String | Int | Double): JQuery = + jquery.asInstanceOf[js.Dynamic].height(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Hide the matched elements.
* See: jQuery Docs */ - def hide(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.hide(duration, easing, callback) + def hide(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].hide(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Hide the matched elements.
* See: jQuery Docs */ - def hide(options: AnimationOptions): JQuery = jquery.hide(options.toJSDictionary) + def hide(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].hide(options.toJSDictionary).asInstanceOf[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 } @@ -1133,182 +896,209 @@ object JQuery { /** Set the CSS inner height of each element in the set of matched elements.
* See: jQuery Docs */ - def innerHeight(function: (Element, Int, Double) => Int | Double | String): JQuery = jquery.innerHeight(function) + def innerHeight(function: (Element, Int, Double) => Int | Double | String): JQuery = + jquery.asInstanceOf[js.Dynamic].innerHeight(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Set the CSS inner width of each element in the set of matched elements.
* See: jQuery Docs */ - def innerWidth(function: (Element, Int, Double) => Int | Double | String): JQuery = jquery.innerWidth(function) + def innerWidth(function: (Element, Int, Double) => Int | Double | String): JQuery = + jquery.asInstanceOf[js.Dynamic].innerWidth(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** 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(function: (Element, Int, Element) => Boolean): Boolean = jquery.is(function) + def is(function: (Element, Int, Element) => Boolean): Boolean = + jquery.asInstanceOf[js.Dynamic].is(js.ThisFunction.fromFunction3(function)).asInstanceOf[Boolean] /** 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.
* See: jQuery Docs */ - def load(url: String, data: js.Any, callback: (Element, String, String, JQueryXHR) => Any): JQuery = jquery.load(url, data, callback) + def load(url: String, data: js.Any, callback: (Element, String, String, JQueryXHR) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].load(url, data, js.ThisFunction.fromFunction4(callback)).asInstanceOf[JQuery] /** Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
* See: jQuery Docs */ - def map(callback: (Int, Element) => Any): JQuery = jquery.map(callback) + def map(callback: (Int, Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].map(js.ThisFunction.fromFunction2(callback)).asInstanceOf[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.
* See: jQuery Docs */ - def not(function: (Element, Int, Element) => Boolean): JQuery = jquery.not(function) + def not(function: (Element, Int, Element) => Boolean): JQuery = + jquery.asInstanceOf[js.Dynamic].not(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Get the current coordinates of the first element in the set of matched elements, relative to the document.
* See: jQuery Docs */ def offset(): Offset = { - val o = jquery.offset() + val o = jquery.asInstanceOf[js.Dynamic].offset().asInstanceOf[js.Dictionary[Double]] Offset(o("top"), o("left")) } /** Get the current coordinates of the first element in the set of matched elements, relative to the document.
* See: jQuery Docs */ - def offset(coordinates: Offset): JQuery = jquery.offset(coordinates.toJSDictionary) + def offset(coordinates: Offset): JQuery = + jquery.asInstanceOf[js.Dynamic].offset(coordinates.toJSDictionary).asInstanceOf[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 = { - jquery.toArray() + def off(event: EventName, callback: JQueryCallback): JQuery = { + jquery.asInstanceOf[js.Dynamic].toArray().asInstanceOf[js.Array[Element]] .foreach( el => { if (registrations.contains(el)) { - val jqueryRegs: mutable.Buffer[CallbackRegistrationRef] = registrations.get(el).get + val jqueryRegs: mutable.Buffer[CallbackRegistrationRef] = registrations(el) val found: mutable.Buffer[CallbackRegistrationRef] = jqueryRegs.filter(r => { r match { case CallbackRegistrationRef(ev, cb, _) if cb == callback && ev == event => true @@ -1324,204 +1114,268 @@ 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] - jquery.each((element: Element, idx: Int) => { + jquery.asInstanceOf[js.Dynamic].each(js.ThisFunction.fromFunction2((element: Element, idx: Int) => { val cb = params match { - case CallbackParameters(false, null, null) => c: ThisFunctionCallback => jQ(element).on(event, c) - case CallbackParameters(false, null, data) => c: ThisFunctionCallback => jQ(element).on(event, data, c) - case CallbackParameters(false, selector, null) => c: ThisFunctionCallback => jQ(element).on(event, selector, c) - case CallbackParameters(false, selector, data) => c: ThisFunctionCallback => jQ(element).on(event, selector, data, c) - - case CallbackParameters(true, null, null) => c: ThisFunctionCallback => jQ(element).one(event, c) - case CallbackParameters(true, null, data) => c: ThisFunctionCallback => jQ(element).one(event, data, c) - case CallbackParameters(true, selector, null) => c: ThisFunctionCallback => jQ(element).one(event, selector, c) - case CallbackParameters(true, selector, data) => c: ThisFunctionCallback => jQ(element).one(event, selector, data, c) + case CallbackParameters(false, null, null) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].on(event, c) + case CallbackParameters(false, null, data) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].on(event, data, c) + case CallbackParameters(false, selector, null) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].on(event, selector, c) + case CallbackParameters(false, selector, data) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].on(event, selector, data, c) + + case CallbackParameters(true, null, null) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].one(event, c) + case CallbackParameters(true, null, data) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].one(event, data, c) + case CallbackParameters(true, selector, null) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].one(event, selector, c) + case CallbackParameters(true, selector, data) => c: ThisFunctionCallback => jQ(element).asInstanceOf[js.Dynamic].one(event, selector, data, c) } val registration: CallbackRegistration = new OnCallbackRegistration(event, callback, cb) collectRegistration(event, callback, element, idx, params, registration) - }) + })) } - 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) } + /** Get the current computed height for the first element in the set of matched elements, including padding, + * border, and optionally margin. Returns a number (without "px") representation of the value or undef + * if called on an empty set of elements.
+ * See: jQuery Docs */ + def outerHeight(includeMargin: Boolean = false): Option[Double] = + jquery.asInstanceOf[js.Dynamic].outerHeight(includeMargin).asInstanceOf[UndefOr[Double]].toOption + /** Set the CSS outer Height of each element in the set of matched elements.
* See: jQuery Docs */ - def outerHeight(function: (Element, Int, Double) => Double): JQuery = jquery.outerHeight(function) + def outerHeight(function: (Element, Int, Double) => Double): JQuery = + jquery.asInstanceOf[js.Dynamic].outerHeight(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] + + /** Get the current computed width for the first element in the set of matched elements, including padding and border.
+ * See: jQuery Docs */ + def outerWidth(includeMargin: Boolean = false): Option[Double] = + jquery.asInstanceOf[js.Dynamic].outerWidth(includeMargin).asInstanceOf[UndefOr[Double]].toOption /** Set the CSS outer width of each element in the set of matched elements.
* See: jQuery Docs */ - def outerWidth(function: (Element, Int, Double) => Double): JQuery = jquery.outerWidth(function) + def outerWidth(function: (Element, Int, Double) => Double): JQuery = + jquery.asInstanceOf[js.Dynamic].outerWidth(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
* See: jQuery Docs */ def position(): Position = { - val p = jquery.position() + val p = jquery.asInstanceOf[js.Dynamic].position().asInstanceOf[js.Dictionary[Double]] Position(p("top"), p("left")) } /** Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
* See: jQuery Docs */ - def prepend(function: (Element, Int, String) => Any): JQuery = jquery.prepend(function) + def prepend(function: (Element, Int, String) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].prepend(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Set one or more properties for the set of matched elements.
* See: jQuery Docs */ - def prop(propertyName: String, function: (Element, Int, Any) => Any): JQuery = jquery.prop(propertyName, function) + def prop(propertyName: String, function: (Element, Int, Any) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].prop(propertyName, js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Set one or more properties for the set of matched elements.
* See: jQuery Docs */ - def prop(properties: Map[String, Any]): JQuery = jquery.prop(properties.toJSDictionary) + def prop(properties: Map[String, Any]): JQuery = + jquery.asInstanceOf[js.Dynamic].prop(properties.toJSDictionary).asInstanceOf[JQuery] /** Add a collection of DOM elements onto the jQuery stack.
* See: jQuery Docs */ - def pushStack(elements: Seq[Any]): JQuery = jquery.pushStack(elements.toJSArray) + def pushStack(elements: Seq[Any]): JQuery = + jquery.asInstanceOf[js.Dynamic].pushStack(elements.toJSArray).asInstanceOf[JQuery] /** Add a collection of DOM elements onto the jQuery stack.
* See: jQuery Docs */ - def pushStack(elements: Seq[Any], name: String, arguments: Seq[Any]): JQuery = jquery.pushStack(elements.toJSArray, name, arguments.toJSArray) + def pushStack(elements: Seq[Any], name: String, arguments: Seq[Any]): JQuery = + jquery.asInstanceOf[js.Dynamic].pushStack(elements.toJSArray, name, arguments.toJSArray).asInstanceOf[JQuery] /** Specify a function to execute when the DOM is fully loaded.
* See: jQuery Docs */ - def ready(callback: (Element) => Any): JQuery = jquery.ready(callback) + @deprecated("Use jQ(callback) instead.", "1.1.0") + 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(function: (Int, String) => String): JQuery = jquery.removeClass(function) + 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 = + jquery.asInstanceOf[js.Dynamic].removeClass(function).asInstanceOf[JQuery] /** Remove a previously-stored piece of data.
* See: jQuery Docs */ - def removeData(list: String*): JQuery = jquery.removeData(list.toJSArray) + def removeData(list: String*): JQuery = + jquery.asInstanceOf[js.Dynamic].removeData(list.toJSArray).asInstanceOf[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.
* See: jQuery Docs */ - def show(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.show(duration, easing, callback) + def show(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].show(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display the matched elements.
* See: jQuery Docs */ - def show(options: AnimationOptions): JQuery = jquery.show(options.toJSDictionary) + def show(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].show(options.toJSDictionary).asInstanceOf[JQuery] /** Display the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideDown(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideDown(duration, easing, callback) + def slideDown(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].slideDown(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideDown(options: AnimationOptions): JQuery = jquery.slideDown(options.toJSDictionary) + def slideDown(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].slideDown(options.toJSDictionary).asInstanceOf[JQuery] /** Display or hide the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideToggle(duration, easing, callback) + def slideToggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].slideToggle(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display or hide the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideToggle(options: AnimationOptions): JQuery = jquery.slideToggle(options.toJSDictionary) + def slideToggle(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].slideToggle(options.toJSDictionary).asInstanceOf[JQuery] /** Hide the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideUp(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.slideUp(duration, easing, callback) + def slideUp(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].slideUp(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Hide the matched elements with a sliding motion.
* See: jQuery Docs */ - def slideUp(options: AnimationOptions): JQuery = jquery.slideUp(options.toJSDictionary) + def slideUp(options: AnimationOptions): JQuery = + jquery.asInstanceOf[js.Dynamic].slideUp(options.toJSDictionary).asInstanceOf[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.
* See: jQuery Docs */ - def text(function: (Element, Int, String) => String): JQuery = jquery.text(function) + def text(function: (Element, Int, String) => String): JQuery = + jquery.asInstanceOf[js.Dynamic].text(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Retrieve all the elements contained in the jQuery set, as an array.
* See: jQuery Docs */ - def toArray: Seq[Element] = jquery.toArray().toSeq + def toArray: Seq[Element] = + jquery.asInstanceOf[js.Dynamic].toArray().asInstanceOf[js.Array[Element]].toSeq /** Display or hide the matched elements.
* See: jQuery Docs */ - def toggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = jquery.toggle(duration, easing, callback) + def toggle(duration: Int, easing: EasingFunction, callback: (Element) => Any): JQuery = + jquery.asInstanceOf[js.Dynamic].toggle(duration, easing, js.ThisFunction.fromFunction1(callback)).asInstanceOf[JQuery] /** Display or hide the matched elements.
* See: jQuery Docs */ - def toggle(options: AnimationOptions): JQuery = jquery.toggle(options.toJSDictionary) + 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 = jquery.toggleClass(function) + def toggleClass(function: (Int, String, Boolean) => String): JQuery = + jquery.asInstanceOf[js.Dynamic].toggleClass(function).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, state: Boolean): JQuery = jquery.toggleClass(function, state) + def toggleClass(function: (Int, String, Boolean) => String, state: Boolean): JQuery = + jquery.asInstanceOf[js.Dynamic].toggleClass(function, state).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: Map[String, Any]): JQuery = jquery.trigger(event, extraParams.toJSDictionary) + 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 = jquery.trigger(event, extraParams.toJSArray) + 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 = jquery.triggerHandler(event, extraParams.toJSDictionary) + 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 = jquery.triggerHandler(event, extraParams.toJSArray) + 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.
* See: jQuery Docs */ - def value(function: (Element, Int, String) => String): JQuery = jquery.value(function) + def value(function: (Element, Int, String) => String): JQuery = + jquery.asInstanceOf[js.Dynamic].value(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Set the CSS width of each element in the set of matched elements.
* See: jQuery Docs */ - def width(function: (Element, Int, Int) => String | Int | Double): JQuery = jquery.width(function) + def width(function: (Element, Int, Int) => String | Int | Double): JQuery = + jquery.asInstanceOf[js.Dynamic].width(js.ThisFunction.fromFunction3(function)).asInstanceOf[JQuery] /** Wrap an HTML structure around each element in the set of matched elements.
* See: jQuery Docs */ - def wrap(function: (Element, Int) => String | JQuery): JQuery = jquery.wrap(function) + def wrap(function: (Element, Int) => String | JQuery): JQuery = + jquery.asInstanceOf[js.Dynamic].wrap(js.ThisFunction.fromFunction2(function)).asInstanceOf[JQuery] /** Wrap an HTML structure around all elements in the set of matched elements.
* See: jQuery Docs */ - def wrapAll(function: (Element, Int) => String | JQuery): JQuery = jquery.wrapAll(function) + def wrapAll(function: (Element, Int) => String | JQuery): JQuery = + jquery.asInstanceOf[js.Dynamic].wrapAll(js.ThisFunction.fromFunction2(function)).asInstanceOf[JQuery] /** Wrap an HTML structure around the content of each element in the set of matched elements.
* See: jQuery Docs */ - def wrapInner(function: (Element, Int) => String | JQuery): JQuery = jquery.wrapInner(function) + def wrapInner(function: (Element, Int) => String | JQuery): JQuery = + jquery.asInstanceOf[js.Dynamic].wrapInner(js.ThisFunction.fromFunction2(function)).asInstanceOf[JQuery] } } diff --git a/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala b/src/main/scala/io/udash/wrappers/jquery/JQueryDeferred.scala index da307ea..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 @@ -29,11 +27,7 @@ trait JQueryPromise[FunType <: js.Function1[ArgType, js.Any], ArgType] extends j /** Add handlers to be called when the Deferred object is resolved, rejected, or still in progress.
* See: jQuery Docs */ // Usage of then as identifier is deprecated. It can be used as a keyword in future versions of scala. - // def then(done: FunType, fail: FunType, progress: FunType): JQueryDeferred[FunType, ArgType] = js.native - - /** Determine the current state of a Deferred object.
- * See: jQuery Docs */ - private[jquery] def state: String = js.native + def `then`(done: FunType, fail: FunType, progress: FunType): JQueryDeferred[FunType, ArgType] = js.native } @@ -74,7 +68,7 @@ object JQueryPromise { implicit class JQueryPromiseExt(jQueryPromise: JQueryPromise[_, _]) { /** Determine the current state of a Deferred object.
* See: jQuery Docs */ - def state: JQueryDeferredState = jQueryPromise.state match { + def state: JQueryDeferredState = jQueryPromise.asInstanceOf[js.Dynamic].state.asInstanceOf[String] match { case "pending" => JQueryDeferredPending case "resolved" => JQueryDeferredResolved case "rejected" => JQueryDeferredRejected diff --git a/src/main/scala/io/udash/wrappers/jquery/JQueryEvent.scala b/src/main/scala/io/udash/wrappers/jquery/JQueryEvent.scala index 0b5dea0..d71f057 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQueryEvent.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQueryEvent.scala @@ -87,4 +87,8 @@ trait JQueryEvent extends Event { /** For key or mouse events, this property indicates the specific key or button that was pressed.
* See: jQuery Docs */ def which: Int = js.native + + /** The original JavaScript event. + * See: jQuery Docs */ + def originalEvent: Event = 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 b659bea..1d29cf6 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala @@ -29,10 +29,6 @@ trait JQueryStatic extends js.Object { * See: jQuery Docs */ def apply(`object`: js.Any): JQuery = js.native - /** Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.
- * See: jQuery Docs */ - private[jquery] def apply(elementArray: js.Array[Element]): JQuery = js.native - /** Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.
* See: jQuery Docs */ def apply(jq: JQuery): JQuery = js.native @@ -57,14 +53,6 @@ trait JQueryStatic extends js.Object { * See: jQuery Docs */ def ajax(url: String, settings: JQueryAjaxSettings = js.native): JQueryXHR = js.native - /** Handle custom Ajax options or modify existing options before each request is sent and before they are processed by `.ajax()`.
- * See: jQuery Docs */ - private[jquery] def ajaxPrefilter(dataTypes: String, handler: js.Function3[js.Dynamic, js.Dynamic, JQueryXHR, js.Any]): Unit = js.native - - /** Creates an object that handles the actual transmission of Ajax data.
- * See: jQuery Docs */ - private[jquery] def ajaxTransport(tpe: String, handler: js.Function3[js.Dynamic, js.Dynamic, JQueryXHR, js.Any]): Unit = js.native - /** A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
* See: jQuery Docs */ @JSName("Callbacks") @@ -88,52 +76,30 @@ trait JQueryStatic extends js.Object { * See: jQuery Docs */ def dequeue(element: Element, queueName: String): Unit = js.native - /** A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and - * array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, - * from 0 to length-1. Other objects are iterated via their named properties.
- * See: jQuery Docs */ - private[jquery] def each[T](array: js.Array[T], callback: js.Function2[Int, T, js.Any]): Unit = js.native - - /** A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and - * array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, - * from 0 to length-1. Other objects are iterated via their named properties.
- * See: jQuery Docs */ - private[jquery] def each(obj: js.Any, callback: js.Function2[String, js.Any, js.Any]): Unit = js.native + /** Escapes any character that has a special meaning in a CSS selector.
+ * See: jQuery Docs */ + def escapeSelector(index: Int): JQuery = js.native /** Load data from the server using a HTTP GET request.
* See: jQuery Docs */ def get(settings: JQueryAjaxSettings): Unit = js.native - /** Load data from the server using a HTTP GET request.
- * See: jQuery Docs */ - private[jquery] def get(url: String, data: js.Any | String = js.native, success: js.Function3[js.Dynamic, String, JQueryXHR, js.Any] = js.native, dataType: String = js.native): JQueryXHR = js.native - - /** Load a JavaScript file from the server using a GET HTTP request, then execute it.
- * See: jQuery Docs */ - private[jquery] def getScript(url: String, success: (String, String, JQueryXHR) => js.Any): JQueryXHR = js.native - /** Execute some JavaScript code globally.
* See: jQuery Docs */ def globalEval(code: String): Unit = js.native - /** Finds the elements of an array which satisfy a filter function. The original array is not affected.
- * See: jQuery Docs */ - private[jquery] def grep[T](array: js.Array[T], function: js.Function2[T, Int, Boolean], invert: Boolean): js.Array[T] = js.native - /** Determine whether an element has any jQuery data associated with it.
* See: jQuery Docs */ def hasData(element: Element): Boolean = js.native /** Determine whether an element has any jQuery data associated with it.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.2.0", "1.1.0") def holdReady(hold: Boolean): Unit = js.native - /** Search for a specified value within an array and return its index (or -1 if not found).
- * See: jQuery Docs */ - private[jquery] def inArray[T](value: T, array: js.Array[T], fromIndex: Int): Int = js.native - /** Determine whether the argument is an array.
* See: jQuery Docs */ + @deprecated("Since jQuery 3.2.0", "1.1.0") def isArray[T](el: js.Any): Boolean = js.native /** Check to see if an object is empty (contains no enumerable properties).
@@ -142,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").
@@ -154,22 +122,30 @@ 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).
* See: jQuery Docs */ def isXMLDoc[T](el: js.Any): Boolean = js.native + /** Create a serialized representation of an array, a plain object, or a jQuery object suitable + * for use in a URL query string or Ajax request. In case a jQuery object is passed, it should + * contain input elements with name/value properties.
+ * See: jQuery Docs */ + def param(obj: js.Array[js.Any] | js.Object | JQuery, traditional: Boolean = js.native): String = js.native + /** Parses a string into an array of DOM nodes.
- * See: jQuery Docs */ + * See: jQuery Docs */ def parseHTML(data: String, context: Element = js.native, keepScripts: Boolean = js.native): js.Array[Element] = js.native /** Takes a well-formed JSON string and returns the resulting JavaScript value.
- * See: jQuery Docs */ + * See: jQuery Docs */ + @deprecated("Since all the browsers supported by jQuery 3.0 support the native JSON.parse() method, we are deprecating jQuery.parseJSON().", "1.1.0") def parseJSON(json: String): js.Any = js.native /** Parses a string into an XML document.
- * See: jQuery Docs */ + * See: jQuery Docs */ def parseXML(xml: String): js.Dynamic = js.native /** Load data from the server using a HTTP POST request.
@@ -178,8 +154,13 @@ trait JQueryStatic extends js.Object { /** Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
* See: jQuery Docs */ + @deprecated("The jQuery.unique() method has been renamed to jQuery.uniqueSort() to make its behavior easier to understand.", "1.1.0") def unique[T](array: js.Array[T]): js.Array[T] = js.native + /** Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
+ * See: jQuery Docs */ + def uniqueSort[T](array: js.Array[T]): js.Array[T] = js.native + /** Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
* See: jQuery Docs */ def when[FunType <: js.Function1[ArgType, js.Any], ArgType](deferred: JQueryDeferred[FunType, ArgType]*): JQueryPromise[FunType, ArgType] = js.native @@ -206,49 +187,56 @@ object JQueryStatic { /** Handle custom Ajax options or modify existing options before each request is sent and before they are processed by `.ajax()`.
* See: jQuery Docs */ - def ajaxPrefilter(dataTypes: String, handler: (js.Dynamic, js.Dynamic, JQueryXHR) => js.Any): Unit = jQueryStatic.ajaxPrefilter(dataTypes, handler) + def ajaxPrefilter(dataTypes: String, handler: (js.Dynamic, js.Dynamic, JQueryXHR) => js.Any): Unit = + jQueryStatic.asInstanceOf[js.Dynamic].ajaxPrefilter(dataTypes, handler) /** Creates an object that handles the actual transmission of Ajax data.
* See: jQuery Docs */ - def ajaxTransport(tpe: String, handler: (js.Dynamic, js.Dynamic, JQueryXHR) => js.Any): Unit = jQueryStatic.ajaxTransport(tpe, handler) + def ajaxTransport(tpe: String, handler: (js.Dynamic, js.Dynamic, JQueryXHR) => js.Any): Unit = + jQueryStatic.asInstanceOf[js.Dynamic].ajaxTransport(tpe, handler) /** A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and * array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, * from 0 to length-1. Other objects are iterated via their named properties.
* See: jQuery Docs */ - def each[T](array: Seq[T], callback: (Int, T) => js.Any): Unit = jQueryStatic.each[T](array.toJSArray, callback) + def each[T](array: Seq[T], callback: (Int, T) => js.Any): Unit = + jQueryStatic.asInstanceOf[js.Dynamic].each(array.toJSArray, callback) /** A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and * array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, * from 0 to length-1. Other objects are iterated via their named properties.
* See: jQuery Docs */ - def each(obj: js.Any, callback: (String, js.Any) => js.Any): Unit = jQueryStatic.each(obj, callback) + def each(obj: js.Any, callback: (String, js.Any) => js.Any): Unit = + jQueryStatic.asInstanceOf[js.Dynamic].each(obj, callback) /** Load data from the server using a HTTP GET request.
* See: jQuery Docs */ def get[T](url: String, data: js.Any, success: (T, String, JQueryXHR) => js.Any, dataType: String): JQueryXHR = { val callback = (data: js.Dynamic, status: String, xhr: JQueryXHR) => success(data.asInstanceOf[T], status, xhr) - jQueryStatic.get(url, data, callback, dataType) + jQueryStatic.asInstanceOf[js.Dynamic].get(url, data, callback, dataType).asInstanceOf[JQueryXHR] } /** Load JSON-encoded data from the server using a GET HTTP request.
* See: jQuery Docs */ def getJSON[T](url: String, data: js.Any, success: (T, String, JQueryXHR) => js.Any): JQueryXHR = { val callback = (data: js.Dynamic, status: String, xhr: JQueryXHR) => success(data.asInstanceOf[T], status, xhr) - jQueryStatic.get(url, data, callback, "json") + jQueryStatic.asInstanceOf[js.Dynamic].get(url, data, callback, "json").asInstanceOf[JQueryXHR] } /** Load a JavaScript file from the server using a GET HTTP request, then execute it.
* See: jQuery Docs */ - def getScript(url: String, success: (String, String, JQueryXHR) => js.Any): JQueryXHR = jQueryStatic.getScript(url, success) + def getScript(url: String, success: (String, String, JQueryXHR) => js.Any): JQueryXHR = + jQueryStatic.asInstanceOf[js.Dynamic].getScript(url, success).asInstanceOf[JQueryXHR] /** Finds the elements of an array which satisfy a filter function. The original array is not affected.
* See: jQuery Docs */ - def grep[T](array: Seq[T], function: (T, Int) => Boolean, invert: Boolean = false): js.Array[T] = jQueryStatic.grep[T](array.toJSArray, function, invert) + def grep[T](array: Seq[T], function: (T, Int) => Boolean, invert: Boolean = false): Seq[T] = + jQueryStatic.asInstanceOf[js.Dynamic].grep(array.toJSArray, function, invert).asInstanceOf[js.Array[T]].toSeq /** Search for a specified value within an array and return its index (or -1 if not found).
* See: jQuery Docs */ - def inArray[T](value: T, array: Seq[T], fromIndex: Int): Int = jQueryStatic.inArray(value, array.toJSArray, fromIndex) + def inArray[T](value: T, array: Seq[T], fromIndex: Int): Int = + jQueryStatic.asInstanceOf[js.Dynamic].inArray(value.asInstanceOf[js.Dynamic], array.toJSArray, fromIndex).asInstanceOf[Int] def parse(data: String) = { jQ(jQueryStatic.parseHTML(data)(0)) diff --git a/src/main/scala/io/udash/wrappers/jquery/package.scala b/src/main/scala/io/udash/wrappers/jquery/package.scala index 51cc4dc..cf43fa1 100644 --- a/src/main/scala/io/udash/wrappers/jquery/package.scala +++ b/src/main/scala/io/udash/wrappers/jquery/package.scala @@ -3,14 +3,17 @@ package io.udash.wrappers import org.scalajs.dom._ import scala.scalajs.js -import scala.scalajs.js.annotation.JSName +import scala.scalajs.js.annotation.JSImport /** 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] -} + @js.native + @JSImport("jquery", JSImport.Default, "$") + object jQ extends JQueryStatic +} \ No newline at end of file diff --git a/src/main/scala/io/udash/wrappers/jquery/utils.scala b/src/main/scala/io/udash/wrappers/jquery/utils.scala index e584afc..ac287b1 100644 --- a/src/main/scala/io/udash/wrappers/jquery/utils.scala +++ b/src/main/scala/io/udash/wrappers/jquery/utils.scala @@ -12,12 +12,18 @@ sealed trait TopLeftCoords { case class Position(override val top: Double, override val left: Double) extends TopLeftCoords case class Offset(override val top: Double, override val left: Double) extends TopLeftCoords -case class AnimationOptions(duration: Option[Int] = None, easing: Option[EasingFunction] = None, queue: Option[Boolean] = None, - step: (Int, js.Dynamic) => Any = null, progress: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Int, Int) => Any = null, - complete: () => Any = null, start: JQueryPromise[js.Function1[js.Any, js.Any], js.Any] => Any = null, - done: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null, - fail: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null, - always: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null) { +case class AnimationOptions( + duration: Option[Int] = None, + easing: Option[EasingFunction] = None, + queue: Option[Boolean] = None, + step: (Int, js.Dynamic) => Any = null, + progress: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Int, Int) => Any = null, + complete: () => Any = null, + start: JQueryPromise[js.Function1[js.Any, js.Any], js.Any] => Any = null, + done: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null, + fail: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null, + always: (JQueryPromise[js.Function1[js.Any, js.Any], js.Any], Boolean) => Any = null +) { def toJSDictionary: js.Dictionary[Any] = { val r = js.Dictionary[Any]() if (duration.isDefined) r.update("duration", duration.get) @@ -37,38 +43,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/DomManipulationTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/DomManipulationTest.scala index ede038d..d16b4cc 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/DomManipulationTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/DomManipulationTest.scala @@ -1,8 +1,10 @@ package io.udash.wrappers.jquery_test -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec + +class DomManipulationTest extends AnyWordSpec with Matchers { -class DomManipulationTest extends WordSpec with Matchers { import io.udash.wrappers.jquery._ import scalatags.JsDom.all._ diff --git a/src/test/scala/io/udash/wrappers/jquery_test/EventsHandlingTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/EventsHandlingTest.scala index 42fea1c..710fa0a 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/EventsHandlingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/EventsHandlingTest.scala @@ -1,10 +1,13 @@ +package io.udash.wrappers.jquery_test + import org.scalajs.dom.Element import org.scalajs.dom.html.Input -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class EventsHandlingTest extends WordSpec with Matchers { - import io.udash.wrappers.jquery._ +class EventsHandlingTest extends AnyWordSpec with Matchers { + import io.udash.wrappers.jquery._ import scalatags.JsDom.all._ class C(i: Int) diff --git a/src/test/scala/io/udash/wrappers/jquery_test/MiscellaneousTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/MiscellaneousTest.scala index c2630c7..4d32382 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/MiscellaneousTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/MiscellaneousTest.scala @@ -1,10 +1,11 @@ package io.udash.wrappers.jquery_test -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class MiscellaneousTest extends WordSpec with Matchers { - import io.udash.wrappers.jquery._ +class MiscellaneousTest extends AnyWordSpec with Matchers { + import io.udash.wrappers.jquery._ import scalatags.JsDom.all._ class C(i: Int) @@ -43,6 +44,12 @@ class MiscellaneousTest extends WordSpec with Matchers { selection.index(jQ(el3)) should be(2) selection.index(el4) should be(-1) } + + "serialize objects to URL query string" in { + import scala.scalajs.js + import js.JSConverters._ + jQ.param(js.Dynamic.literal("a" -> Seq(1, 2, 3).toJSArray, "b" -> "c")) should be("a%5B%5D=1&a%5B%5D=2&a%5B%5D=3&b=c") + } } } diff --git a/src/test/scala/io/udash/wrappers/jquery_test/SelectorsTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/SelectorsTest.scala index 6654210..61ea636 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/SelectorsTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/SelectorsTest.scala @@ -1,8 +1,10 @@ package io.udash.wrappers.jquery_test -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec + +class SelectorsTest extends AnyWordSpec with Matchers { -class SelectorsTest extends WordSpec with Matchers { import io.udash.wrappers.jquery._ import scalatags.JsDom.all._ 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..2ff1b89 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -1,10 +1,11 @@ package io.udash.wrappers.jquery_test -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class TraversingTest extends WordSpec with Matchers { - import io.udash.wrappers.jquery._ +class TraversingTest extends AnyWordSpec with Matchers { + import io.udash.wrappers.jquery._ import scalatags.JsDom.all._ "jQuery" should { @@ -63,9 +64,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 +90,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) @@ -165,5 +166,21 @@ class TraversingTest extends WordSpec with Matchers { root.children("a").first().length should be(0) root.children("a").last().length should be(0) } + + "even/odd matching element" in { + val dom = div( + span("0"), + span("1"), + span("2"), + span("3"), + span("4"), + span("5"), + ).render + + val root = jQ(dom) + root.children("span").even().text() shouldBe "024" + root.children("span").odd().text() shouldBe "135" + } + } }