From 138a7f0a8ae4f7eebd1369976f667afa8015a225 Mon Sep 17 00:00:00 2001 From: starzu Date: Thu, 28 Jan 2016 08:58:43 +0100 Subject: [PATCH 01/44] Deployment configuration --- build.sbt | 35 +++++++++++++++++++++++++++++++++++ project/plugins.sbt | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/build.sbt b/build.sbt index 36e1b7f..cae2d61 100644 --- a/build.sbt +++ b/build.sbt @@ -30,3 +30,38 @@ scalaJSUseRhino in Test := false lazy val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) + +// Deployment configuration +publishMavenStyle := true +publishArtifact in Test := false +pomIncludeRepository := { _ => false } + +publishTo := { + val nexus = "https://oss.sonatype.org/" + if (isSnapshot.value) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") +} + +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/ + + +} diff --git a/project/plugins.sbt b/project/plugins.sbt index e513ea5..afe60eb 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,7 @@ logLevel := Level.Warn addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.9") + +// Deployment configuration +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") \ No newline at end of file From 57c8e2f017808ee0e17ab920568d6e6b26cc8b4b Mon Sep 17 00:00:00 2001 From: Mateusz Starzec Date: Tue, 22 Jan 2019 14:28:05 +0100 Subject: [PATCH 02/44] v3.0.1 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index ead37eb..b76070c 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ import org.openqa.selenium.chrome.ChromeOptions name := "udash-jquery" inThisBuild(Seq( - version := "3.0.0", + version := "3.0.1", organization := "io.udash", )) From 4968d5f983f143323eac1458cc450b764d2694d5 Mon Sep 17 00:00:00 2001 From: ddworak Date: Tue, 15 Oct 2019 06:57:25 +0200 Subject: [PATCH 03/44] Update deployment plugins --- project/plugins.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index c32bd8f..2b1dd16 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,5 +6,5 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.29") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6") // Deployment configuration -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3") \ No newline at end of file +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0-M2") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.4") \ No newline at end of file From 016f3d79ae27375e05238eb0065206f04e7ccb14 Mon Sep 17 00:00:00 2001 From: ddworak Date: Wed, 18 Mar 2020 14:50:46 +0100 Subject: [PATCH 04/44] Dependency upgrades --- build.sbt | 43 ++----------------- project/build.properties | 2 +- project/plugins.sbt | 8 ++-- .../jquery_test/DomManipulationTest.scala | 6 ++- .../jquery_test/EventsHandlingTest.scala | 9 ++-- .../jquery_test/MiscellaneousTest.scala | 10 +++-- .../wrappers/jquery_test/SelectorsTest.scala | 6 ++- .../wrappers/jquery_test/TraversingTest.scala | 7 +-- 8 files changed, 33 insertions(+), 58 deletions(-) diff --git a/build.sbt b/build.sbt index 8902567..4ca74b7 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ name := "udash-jquery" inThisBuild(Seq( - version := "3.0.2", + version := "3.0.3", organization := "io.udash", )) @@ -50,46 +50,11 @@ lazy val root = project.in(file(".")) commonJSSettings, libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.9.7", - "org.scalatest" %%% "scalatest" % "3.0.8" % Test, - "com.lihaoyi" %%% "scalatags" % "0.7.0" % Test + "org.scala-js" %%% "scalajs-dom" % "0.9.8", + "org.scalatest" %%% "scalatest" % "3.1.1" % Test, + "com.lihaoyi" %%% "scalatags" % "0.8.6" % Test ), Compile / npmDependencies += "jquery" -> "3.3.1", Test / requireJsDomEnv := true ) - -// Deployment configuration -publishMavenStyle := true -publishArtifact in Test := false -pomIncludeRepository := { _ => false } - -publishTo := { - val nexus = "https://oss.sonatype.org/" - if (isSnapshot.value) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") -} - -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/ - - -} diff --git a/project/build.properties b/project/build.properties index ebcc8ac..c9c5a37 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.3.2 \ No newline at end of file +sbt.version=1.3.8 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 2b1dd16..ea0423d 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,9 +2,9 @@ logLevel := Level.Warn libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.3.0" -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.29") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler-sjs06" % "0.17.0") // Deployment configuration -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0-M2") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.4") \ No newline at end of file +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1") \ 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 95b3953..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) @@ -45,7 +46,8 @@ class MiscellaneousTest extends WordSpec with Matchers { } "serialize objects to URL query string" in { - import scala.scalajs.js, js.JSConverters._ + 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 1400684..82116cf 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 { From 1c7a60e8c8932b1c218741ed930f5509bdd7b4a9 Mon Sep 17 00:00:00 2001 From: ddworak Date: Wed, 18 Mar 2020 15:36:22 +0100 Subject: [PATCH 05/44] Bundler-only demo --- example/build.sbt | 44 ++----------------- .../global-demo/src/main/assets/index.html | 13 ------ example/project/Dependencies.scala | 7 +-- example/project/build.properties | 2 +- example/project/plugins.sbt | 4 +- .../src/main/assets/index.html | 0 6 files changed, 8 insertions(+), 62 deletions(-) delete mode 100644 example/global-demo/src/main/assets/index.html rename example/{bundler-demo => }/src/main/assets/index.html (100%) diff --git a/example/build.sbt b/example/build.sbt index 04eeabb..8f85222 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -1,13 +1,13 @@ name := "jquery-demo" inThisBuild(Seq( - version := "3.0.1", + version := "3.0.2", organization := "io.udash", )) val commonSettings = Seq( scalaVersion := "2.12.10", - crossScalaVersions := Seq("2.12.10"), //todo 2.13 + crossScalaVersions := Seq("2.12.10"), //todo 2.13 & SJS 1.0 with Udash 0.9 scalacOptions ++= Seq( "-feature", "-deprecation", @@ -33,46 +33,10 @@ val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) .settings(commonSettings) -val `jquery-global-demo` = project.in(file("global-demo")) - .enablePlugins(ScalaJSPlugin) - .settings( - commonSettings, - - jsDependencies ++= Dependencies.jsDeps.value, - - sourceDirsSettings(_.getParentFile), - - /* move these files out of target/. */ - Compile / fullOptJS / crossTarget := generatedGlobalDir, - Compile / fastOptJS / crossTarget := generatedGlobalDir, - Compile / packageJSDependencies / crossTarget := generatedGlobalDir, - Compile / packageMinifiedJSDependencies / crossTarget := generatedGlobalDir, - - Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value, - Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value, - - scalaJSUseMainModuleInitializer := true, - - copyAssets := { - IO.copyFile( - sourceDirectory.value / "main/assets/index.html", - generatedGlobalDir / "index.html" - ) - }, - - Compile / fastOptJS / artifactPath := - (Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js", - Compile / fullOptJS / artifactPath := - (Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js", - Compile / packageJSDependencies / artifactPath := - (Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js", - Compile / packageMinifiedJSDependencies / artifactPath := - (Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js" - ) - val generatedBundlerDir = file("generated/bundler") val compileStatics = taskKey[Unit]("Compiles all static files.") -val `jquery-bundler-demo` = project.in(file("bundler-demo")) + +val example = project.in(file(".")) .enablePlugins(ScalaJSBundlerPlugin) .settings( commonSettings, diff --git a/example/global-demo/src/main/assets/index.html b/example/global-demo/src/main/assets/index.html deleted file mode 100644 index b746eab..0000000 --- a/example/global-demo/src/main/assets/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - jquery-demo - global scope - - -
- - - - - \ No newline at end of file diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index caa9172..32852d9 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -1,17 +1,12 @@ -import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ import sbt._ object Dependencies { - val udashCoreVersion = "0.8.1" + val udashCoreVersion = "0.8.3" val udashJQueryVersion = "3.0.2" val deps = Def.setting(Seq[ModuleID]( "io.udash" %%% "udash-core" % udashCoreVersion, "io.udash" %%% "udash-jquery" % udashJQueryVersion )) - - val jsDeps = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID]( - "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" - )) } \ No newline at end of file diff --git a/example/project/build.properties b/example/project/build.properties index ebcc8ac..c9c5a37 100644 --- a/example/project/build.properties +++ b/example/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.3.2 \ No newline at end of file +sbt.version=1.3.8 \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt index cafe39a..c0848e6 100644 --- a/example/project/plugins.sbt +++ b/example/project/plugins.sbt @@ -1,4 +1,4 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.29") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0-0.6") \ No newline at end of file +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler-sjs06" % "0.17.0") \ No newline at end of file diff --git a/example/bundler-demo/src/main/assets/index.html b/example/src/main/assets/index.html similarity index 100% rename from example/bundler-demo/src/main/assets/index.html rename to example/src/main/assets/index.html From b71ad988dd574d1f05c8b9604b5f25448a2fb3d8 Mon Sep 17 00:00:00 2001 From: ddworak Date: Wed, 18 Mar 2020 15:40:02 +0100 Subject: [PATCH 06/44] SJS 1.0.1 --- build.sbt | 4 +--- project/plugins.sbt | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 4ca74b7..b330dc3 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ inThisBuild(Seq( val commonSettings = Seq( scalaVersion := "2.13.1", - crossScalaVersions := Seq("2.12.10", "2.13.1"), + crossScalaVersions := Seq("2.12.11", "2.13.1"), scalacOptions ++= Seq( "-feature", "-deprecation", @@ -29,7 +29,6 @@ val commonSettings = Seq( ) val commonJSSettings = Seq( - Compile / emitSourceMaps := true, Test / parallelExecution := false, Test / scalaJSStage := FastOptStage, // ScalaJSBundlerPlugin does not work with scalajs-env-selenium: @@ -40,7 +39,6 @@ val commonJSSettings = Seq( val githubDir = "https://raw.githubusercontent.com/UdashFramework/scala-js-jquery" s"-P:scalajs:mapSourceURI:$localDir->$githubDir/v${version.value}/" }, - scalacOptions += "-P:scalajs:sjsDefinedByDefault", ) lazy val root = project.in(file(".")) diff --git a/project/plugins.sbt b/project/plugins.sbt index ea0423d..ab16f2f 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,8 +2,8 @@ logLevel := Level.Warn libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.3.0" -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler-sjs06" % "0.17.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") // Deployment configuration addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") From 70fabcf43a2335c14e6f5769f176cae67abb3635 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 07:13:01 +0100 Subject: [PATCH 07/44] CI cleanup --- .travis.yml | 2 +- example/build.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56f862c..c1c2b6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,4 @@ before_script: script: - sbt +test +publishLocal - - cd example && sbt compile jquery-global-demo/fullOptJS jquery-bundler-demo/compileStatics \ No newline at end of file + - cd example && sbt compileStatics \ No newline at end of file diff --git a/example/build.sbt b/example/build.sbt index 8f85222..422bf9d 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -33,7 +33,7 @@ val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) .settings(commonSettings) -val generatedBundlerDir = file("generated/bundler") +val generatedBundlerDir = file("generated") val compileStatics = taskKey[Unit]("Compiles all static files.") val example = project.in(file(".")) From 949cb211a638a082f6ddfeb9f8e99d7a38dacaec Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 08:17:23 +0100 Subject: [PATCH 08/44] Travis setup for releasing --- .travis.yml | 49 ++++++++++++++++++++++++++++++++----------------- travis.gpg.enc | Bin 0 -> 3712 bytes 2 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 travis.gpg.enc diff --git a/.travis.yml b/.travis.yml index c1c2b6a..86def1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,41 @@ -language: scala dist: trusty - +language: scala jdk: openjdk11 - scala: - 2.13.1 +stages: + - test + - name: release + if: tag =~ ^v + 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.38/chromedriver_linux64.zip - - unzip chromedriver_linux64.zip -d selenium-bin - - export PATH=$PWD/selenium-bin:$PATH + - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz + - mkdir geckodriver + - tar -xzf geckodriver-v0.24.0-linux64.tar.gz -C geckodriver + - export PATH=$PWD/geckodriver:$PATH script: - sbt +test +publishLocal - - cd example && sbt compileStatics \ No newline at end of file + - cd example && sbt compileStatics + +jobs: + include: + - stage: release + script: + - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv -in travis/travis.gpg.enc -out travis/travis.gpg -d + - gpg --import travis/travis.gpg + - test $TRAVIS_PULL_REQUEST = "false" && sbt +publishSigned sonatypeBundleRelease + +before_cache: + # Cleanup the cached directories to avoid unnecessary cache updates + - rm -fv $HOME/.ivy2/.sbt.ivy.lock + - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete + - find $HOME/.sbt -name "*.lock" -print -delete + +cache: + directories: + - $HOME/.ivy2/cache + - $HOME/.m2 + - $HOME/.cache + - $HOME/.sbt \ No newline at end of file diff --git a/travis.gpg.enc b/travis.gpg.enc new file mode 100644 index 0000000000000000000000000000000000000000..399e4773eceb781b839288110f4eb79b00f9e135 GIT binary patch literal 3712 zcmV-`4uA2*H7koBJ8%!iZTWF$!{Z-QD*oRFDW;sl!QySp%&UtFSA@?)Ezh1<@e zau_=SuvL!Tpo3ELmII4Skngn(thtLkE10yq{iZL40@L~09np95yr5&jcTVrKD)X?Y znm1{n@xL*E`PILmVck}3W>@|MDj@^jf}mWr%F4P~U7VGCHRmI`idtw5J;$7yMp&AO zavvK2s?cc4f>NLgrFY?~KuMF|p+(OyvDq%^W*~{JTLk{p*mm6xqw^L9hKo}`PKc@0 z;AUAm{+EI@tpCfJH<0rFh`+-=UC}mJ6D!XH_b{#wcA?MAyC(*|pkyaj&oqBdKJts3JBd~|LY zZZK>1#9%&WoE$Wo0qA5`$r>}EPv3}h-+Gp|*<}s%<`PZ(w97t8_>G^-90o!?w$|wP zCSlq2LIfA@l&41CpWAc5b=JO=ghqUnq3!swPRh88^gf;vE#oN$JZ3KXZ zNHpfpMlC;E*=;zM+i)6bxor0lzUBW9$+`Qpq&_i3yypiKVaT5ISY(Q?>E*VE51(;F zjmE!)REd@<8!-(VLGfy}+z`#6$5)ano{e2?0UjDLuE>0&;()S%TL zZYo4aw5JAt*R{&A(Ub?T@4}25qn*5)bw2frbfnt^r}oxjj$9Im@;IQ2fv~(Yc1I{} zMZrPD`g=+}{7Xdo!s(=kU;L>t{p00{2Se7ifba3O1z%prX>K0nHl<9pw;H(g&b9TH zcA-5o`2mVT>9e!HDj|Vh>R<5DHx{m_6 zGkoa2wop$_O1omwPhS6}!c8l7iO4o!MgkbdvMu?x%T;KqIgLfOMGb52t@r&;;}Rv^ zWT))87nG!F8N5J9;qE^2mmXKF5jjWU$cZ;$FfZs(VMq-|C)LXSbC3zReacAfk`GZh zmTMZq`ZGvvr5`=MXvwj~-0~p**IW>JB`0cFTH$jvd;!V5wKU^PZS08i(TO=Qn@39& zRl0$pVuG&G3@ZH0awpKaLbKut>}lyXrbkScE#LWf;Nt6VN|SP0SEa>1LVr*Y`Vuv! z7XtKS@HY&pRas*3bG*e4{+c4}M|y+%36v4{AK;MF{bP8G**HF96L=gRH?|{q#=QVT z72^G(`XBprjiIpeStxIaPDR;?#gB8lDLa?q++pv=q4quk15|C#f^TT;PdOZ zF42&DE5IAaGd4%`Z38S)JC>A?1X{!0rw7_UpeCysKr#53NJC*f|KOtul-yUqP7;c7 zCLaAow$MfDU!&!0hhPla zc-N({E}Fy+SCx9!2XyVqc&R1%fjI8Vz{&P!u!n4g^=phbw%o6SIbgo8NIh7QH%=kj?IfPMAu?G3XL1Rzj zFC4ZCv^fFY7JZ&kf_G`Uow$-Jb7^oY-cy8U+W5EhgI0C5sO>1%9vS_ER%ayC%k~?9 zb>s1ccf9i>G$SnzS}UnM==BH)fk!<)Fo$PzuXL5JR zHE54^B+S7ZljvVLQ;ILWemRf9k~O2c)AG?u#o!GLtY42OVJ-HUjHM|+_T9iSa!-pc zlIJ&QqadZASpI>UThjcM)_2ObgYP*<82*{YT4`|g({a@lr^Vw}zQy55?63Pxoc~rK z;r&^J%D`+dzgR%9MVU9Ae6r_%Ud+nI+`+#~#n6mHF%Bo+>5fd~njY;4H(FJzHM%qx zHEjHr>>n7>${W0-Df>mzKdEuuN{U!f_4I-1T)?oDe<7u00*UMFX93u32aOWBcx~36 zyeQ7S3m=RVv>+@jU8e?kNrinG`zqbj{31w?@LTd*)vXv9uZEvwfL`gr{1j8*8UR}b zz4wQWp>11}VRNe<<7knD4$nv=M(MAUIG_gVX1B1hPhOaxRjml;i1W_Zb~A2qc5e*j zJSyn0ktIbs4W0w4<18QdCSbgZY$rfjwQ;U<5M7w7%trfcd(xbj9atipn%W*cGeStv zhvi?IQj(7J z^b1;k_M*vFg=x-528fO(Tsm@W5hAbAtBNyQrWv#X6E~-R5AcFds20Cu_6?6^z66$> zR_>K+$AIMF!s{6mZ6Th88=2xL!4G7sdjxgegRik2qStjg#Q#{w7os;eyx%(wBWO*G zeSf|Sa4SrV=DY|^MHLwe`r0_(?^7j1FRn?Iat661Yke!%UQ%3szH1YZWZk1zP#ny;B<#2>fpTqfTMsz!-B~iRHR_b ziRh3yVt(#UH@~`A=|GzuP}$ZF02ULInaEhRbos`W**%oxW{8!pyKJBn9?v(N(Du=6 zRqV2tUtwsXqrZZd_*;xX#-8RL{;oMmJ1~k}I}4n-LIH@#Dm!-D!5Y{<>w7wjksc4V z{DTB-GP3TqU7n;-E|}vuWm-Uk*^QeUHnuLe z)Vf4y$Q^I*Fhd>vH0`VLhlq>{65S;(=G+Afs5q5|XMCF9e;s5O?;~?tC@55S=tx+< z+nE0*r^8)P%GG}%H3Hf%o;Uf4Cd<~4t*Hf%b@Qn29=Hh zr}sv?`Zha8$kzBdtF>0eYl)iJu%eWB<%z#^LqDQE-7!(*5DbQ9L#9{g(3`3mWsM`D zmL6Xl1;`l;6t}s0fF{BbI7&h~awIIz?{kCiV|k`2-{~KoMv9lMVvJ|quHdDre(-kd z(*ECRT?<^KyR_z?jJk-*0=DFGOD}=SLB}!XD z!*z$WIhhzQBcE1G`qFs!y7TiOxYTgb8A;F>>p95%d`)l;>${2pDr4gG_9(Yt^8>PZ zkpr$G0cCT~=Qk0{n15)@@Wczb^S>0%mFdtcq8FsOas8}zXc9f9+M(gytG1G$pd4tf z%g}j@3})aX(2l*iZSc#5)+6Jr1U{!xj5`HZ&={WRV;Yh#pwG`6j~rSXRB8$8{Wkz0 zu{#wTje{bcAN+v*n(NEpq)@|<^2suf>@U|<=%sDFM;04N6aM$EVGnh<6^*yJMS879 zW=_n%=LKjryk2g2)CHGN?Ava7qb7<6>w= e*PLdv@dpma`3t##6ry)fh1I!P_X>&~CqX&^>Q6HO literal 0 HcmV?d00001 From 08e13154aa86336105245e7a4b5d3dcdca5d507e Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 08:19:03 +0100 Subject: [PATCH 09/44] Default to snapshot version in dev --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index b330dc3..f69a332 100644 --- a/build.sbt +++ b/build.sbt @@ -3,8 +3,9 @@ name := "udash-jquery" inThisBuild(Seq( - version := "3.0.3", + version := sys.env.get("TRAVIS_TAG").filter(_.startsWith("v")).map(_.drop(1)).getOrElse("3.0.0-SNAPSHOT"), organization := "io.udash", + cancelable := true, )) val commonSettings = Seq( From 6e10c20ebadce3b5fbcaa3fd17339612b4525255 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 08:20:34 +0100 Subject: [PATCH 10/44] Travis fix --- .travis.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86def1f..1534178 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,18 +9,17 @@ stages: - name: release if: tag =~ ^v -before_script: - - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz - - mkdir geckodriver - - tar -xzf geckodriver-v0.24.0-linux64.tar.gz -C geckodriver - - export PATH=$PWD/geckodriver:$PATH - -script: - - sbt +test +publishLocal - - cd example && sbt compileStatics - jobs: include: + - stage: test + before_script: + - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz + - mkdir geckodriver + - tar -xzf geckodriver-v0.24.0-linux64.tar.gz -C geckodriver + - export PATH=$PWD/geckodriver:$PATH + script: + - sbt +test +publishLocal + - cd example && sbt compileStatics - stage: release script: - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv -in travis/travis.gpg.enc -out travis/travis.gpg -d From a236e022f005c50cdbbe4d9429ffd4dd46e544fa Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 09:15:53 +0100 Subject: [PATCH 11/44] Complete autopublish setup --- .travis.yml | 24 ++++++++++++------------ build.sbt | 38 +++++++++++++++++++++++++++++++++++--- project/plugins.sbt | 4 +--- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1534178..5bb28bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,34 +7,34 @@ scala: stages: - test - name: release - if: tag =~ ^v + - if: tag =~ ^v jobs: include: - stage: test - before_script: - - wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz - - mkdir geckodriver - - tar -xzf geckodriver-v0.24.0-linux64.tar.gz -C geckodriver - - export PATH=$PWD/geckodriver:$PATH script: - sbt +test +publishLocal - cd example && sbt compileStatics - stage: release script: - - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv -in travis/travis.gpg.enc -out travis/travis.gpg -d + - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv + -in travis/travis.gpg.enc -out travis/travis.gpg -d - gpg --import travis/travis.gpg - test $TRAVIS_PULL_REQUEST = "false" && sbt +publishSigned sonatypeBundleRelease before_cache: - # Cleanup the cached directories to avoid unnecessary cache updates - rm -fv $HOME/.ivy2/.sbt.ivy.lock - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete - find $HOME/.sbt -name "*.lock" -print -delete cache: directories: - - $HOME/.ivy2/cache - - $HOME/.m2 - - $HOME/.cache - - $HOME/.sbt \ No newline at end of file + - "$HOME/.ivy2/cache" + - "$HOME/.m2" + - "$HOME/.cache" + - "$HOME/.sbt" + +env: + global: + - secure: rG9cHG3au9EUYQSJKHAsMxws3IW/tSxG1Y/xbuW2Ri1JVr6L6c9ig8gYj4Hju5KkVvxXejb1/8bYCoZEP1vZpNeSkNordHECp0l+i9mI5ZFo5RN3vMCq4/0xWEQTdZ7c3BjN+pn4veDJ+W8cHFXgivC9tsX7FEbksz4bFVIm1knvz5r7HN4ntgQUeLwY/J9EpKSr/TYZsnEcf8aH9q6tvTLqcfYAR6ggs68Kc2qJ5sII0rj3vP2NANjTLuvdkPSe3i/9KCDRDr9KIoVsam4LfFDG8YXSNWBP3OQU86DF19V0brt6WGGX6G5V2dyjlHyyUy0GBFJOlPmfkEL8ylOprGy1OPw40ZPRbtzpbztFlVmgJoO3UcKIWlyB8umz0M9A+E3Of3P9mTnskAe366VPSq8R/G3kxc7ictZDQH7hgf2nKqlFQNXCJkBqynWRlC0HQ31izrACqNmmYdwQspUnAFVOEFSmfXu8sPVyOSQhHT4IG+xgG4KCKdC8Cv4buOFDzj4z0DRnfJwR71KvxA9KGhUtMZXXqfdZANThHMV1bsi3S3UPQKqRg62aja4+I7lzbwrPRbkDPsl0eTdULF39jIMnbfjC2TqeCgfG+tpel0DBMBOuuESvTVFVX38HSgK1QNhSAAu1nrVIFtZQbKDZLOm7hCgfOJO6v65R3PgIFFI= + - secure: wjX1uXAYdNxpUr1nz9cQ96cgJI3wUqJ7hIQlHwtg1gLJJtgdf6STSTbAm1IKMb0Ouytc2muC1H8jhBbv94tyZh2/NI7IDk7OY2wcLobH2Jh/wnDEAAcATIhqR/oFtSdqr0umr1HDevUPIBU/ZFViCPribnCQ/Rxn8jttguGd3Ho1k1dxzJ9pEiET66nU8CnW0j8g1Nkg540xFPff0Q+1C7+3akU03KwLnh8C0KR1oGhT354IhocLtFKWPuD9GTXAiA6qcOZ0cmUlv8jwHhWyJ6dmVkOlv873nGPrFaWEDPepNkGaAz2TYjkeFS0YS8q1zbd7YM0opnQd8TJCnFddyzc09+1d5RMAJVWdKOKVjrbDwvKaNWfEHW6GXJ83xm8cbo3dCREfL7UTKjejkQTRgmj2BdrZVRB9xs+XKZpZi0ECVbIrwik9tyYoiuSHe96yNN3Ma56Q4x094ZTvsccjy7pET4FCpNwrFu0aD+HFPerWB/xlr9ILz7sWy99r4eafS+O2eidoQnPIHAHZ+z/k9ExQedKUzTxO/skgrf1FvswrY7cpfnNApOhCSKm8C5NfMB5BC7M7OsYqDIhIwfs/Q3J9gw18F4fa9czpnduVzkpQUGdZ2vtS+oxDGICB7uaxkRq7HudHHElhz4w9qEOIMpTJjICPa38Hr/fKGxpuhKE= \ No newline at end of file diff --git a/build.sbt b/build.sbt index f69a332..ed68634 100644 --- a/build.sbt +++ b/build.sbt @@ -27,14 +27,46 @@ val commonSettings = Seq( "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", ), + autoAPIMappings := true, + publishMavenStyle := true, + publishArtifact in Test := false, + pomIncludeRepository := { _ => false }, + + publishTo := sonatypePublishToBundle.value, + + 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/ + + + } ) val commonJSSettings = Seq( Test / parallelExecution := false, Test / scalaJSStage := FastOptStage, - // ScalaJSBundlerPlugin does not work with scalajs-env-selenium: - // https://github.com/scalacenter/scalajs-bundler/issues/89 - // Test / jsEnv := new SeleniumJSEnv(browserCapabilities), scalacOptions += { val localDir = (ThisBuild / baseDirectory).value.toURI.toString val githubDir = "https://raw.githubusercontent.com/UdashFramework/scala-js-jquery" diff --git a/project/plugins.sbt b/project/plugins.sbt index ab16f2f..418498b 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,8 @@ logLevel := Level.Warn -libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.3.0" - addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") // Deployment configuration -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1") \ No newline at end of file From f5328c14488d8f1719f84ab60c88a31b005ef916 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 09:22:28 +0100 Subject: [PATCH 12/44] Move key file --- travis.gpg.enc => travis/travis.gpg.enc | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename travis.gpg.enc => travis/travis.gpg.enc (100%) diff --git a/travis.gpg.enc b/travis/travis.gpg.enc similarity index 100% rename from travis.gpg.enc rename to travis/travis.gpg.enc From 4acb8d5453b66e66951321f62156189eac8d5f66 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 19 Mar 2020 09:23:03 +0100 Subject: [PATCH 13/44] Attempt to cleanup stages --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bb28bf..e2322af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,6 @@ jdk: openjdk11 scala: - 2.13.1 -stages: - - test - - name: release - - if: tag =~ ^v - jobs: include: - stage: test @@ -16,6 +11,7 @@ jobs: - sbt +test +publishLocal - cd example && sbt compileStatics - stage: release + if: tag =~ ^v script: - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv -in travis/travis.gpg.enc -out travis/travis.gpg -d From efbabe0b7a9b91923e3de9a3a8dbe75443b7816a Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 19 Mar 2020 13:44:08 +0100 Subject: [PATCH 14/44] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77158a1..fd89164 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# 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/) +[![Build Status](https://travis-ci.org/UdashFramework/scala-js-jquery.svg?branch=master)](https://travis-ci.org/UdashFramework/scala-js-jquery) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) +[![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. From 8a6a55f6fe107677f9e9d9e1cedc393f363648ce Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 19 Mar 2020 13:48:00 +0100 Subject: [PATCH 15/44] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd89164..71b1d97 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -udash-jquery [](http://www.avsystem.com/) +# udash-jquery [](http://www.avsystem.com/) [![Build Status](https://travis-ci.org/UdashFramework/scala-js-jquery.svg?branch=master)](https://travis-ci.org/UdashFramework/scala-js-jquery) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/uudash-jquery_sjs1_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) [![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. From 7c48457a6b35bb5777c176cf9510116ef1ed8b3d Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 19 Mar 2020 13:50:17 +0100 Subject: [PATCH 16/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71b1d97..8e775a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # udash-jquery [](http://www.avsystem.com/) [![Build Status](https://travis-ci.org/UdashFramework/scala-js-jquery.svg?branch=master)](https://travis-ci.org/UdashFramework/scala-js-jquery) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/uudash-jquery_sjs1_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) [![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. From e3794013fbefc1a05db30151558b6d3c2993bc49 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 26 Mar 2020 11:41:36 +0100 Subject: [PATCH 17/44] Publish both npm and js deps in jar --- build.sbt | 5 ++--- example/project/Dependencies.scala | 2 +- project/plugins.sbt | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index ed68634..1addc24 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,3 @@ - - name := "udash-jquery" inThisBuild(Seq( @@ -75,7 +73,7 @@ val commonJSSettings = Seq( ) lazy val root = project.in(file(".")) - .enablePlugins(ScalaJSBundlerPlugin) + .enablePlugins(ScalaJSBundlerPlugin, JSDependenciesPlugin) .settings( commonSettings, commonJSSettings, @@ -87,5 +85,6 @@ lazy val root = project.in(file(".")) ), Compile / npmDependencies += "jquery" -> "3.3.1", + jsDependencies += "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js", Test / requireJsDomEnv := true ) diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 32852d9..8885338 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -3,7 +3,7 @@ import sbt._ object Dependencies { val udashCoreVersion = "0.8.3" - val udashJQueryVersion = "3.0.2" + val udashJQueryVersion = "3.0.0-SNAPSHOT" val deps = Def.setting(Seq[ModuleID]( "io.udash" %%% "udash-core" % udashCoreVersion, diff --git a/project/plugins.sbt b/project/plugins.sbt index 418498b..84c42cf 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,7 @@ logLevel := Level.Warn addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") +addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0") // Deployment configuration addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") From 69208bc978779717fd54e9874a71cf28dc9bb745 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 26 Mar 2020 15:59:54 +0100 Subject: [PATCH 18/44] Restore global dep demo --- example/build.sbt | 53 ++++++++++++++++++++++++++---- example/project/Dependencies.scala | 7 +++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/example/build.sbt b/example/build.sbt index 422bf9d..103332f 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -28,15 +28,56 @@ val commonSettings = Seq( ) val generatedGlobalDir = file("generated/global") +val compileStatics = taskKey[Unit]("Compiles all static files.") val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") -val root = project.in(file(".")) + +lazy val root: Project = project.in(file(".")) + .aggregate(`jquery-bundler-demo`, `jquery-global-demo`) + .settings( + crossScalaVersions := Nil, + ) + +lazy val `jquery-global-demo` = project.in(file("global-demo")) .enablePlugins(ScalaJSPlugin) - .settings(commonSettings) + .settings( + commonSettings, -val generatedBundlerDir = file("generated") -val compileStatics = taskKey[Unit]("Compiles all static files.") + jsDependencies ++= Dependencies.jsDeps.value, + + sourceDirsSettings(_.getParentFile), + + /* move these files out of target/. */ + Compile / fullOptJS / crossTarget := generatedGlobalDir, + Compile / fastOptJS / crossTarget := generatedGlobalDir, + Compile / packageJSDependencies / crossTarget := generatedGlobalDir, + Compile / packageMinifiedJSDependencies / crossTarget := generatedGlobalDir, + + Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value, + Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value, + + scalaJSUseMainModuleInitializer := true, + + copyAssets := { + IO.copyFile( + root.base / "src/main/assets/index.html", + generatedGlobalDir / "index.html" + ) + }, + + compileStatics := (Compile / fastOptJS).value, + + Compile / fastOptJS / artifactPath := + (Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js", + Compile / fullOptJS / artifactPath := + (Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js", + Compile / packageJSDependencies / artifactPath := + (Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js", + Compile / packageMinifiedJSDependencies / artifactPath := + (Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js" + ) -val example = project.in(file(".")) +val generatedBundlerDir = file("generated/bundler") +lazy val `jquery-bundler-demo` = project.in(file("bundler-demo")) .enablePlugins(ScalaJSBundlerPlugin) .settings( commonSettings, @@ -47,7 +88,7 @@ val example = project.in(file(".")) copyAssets := { IO.copyFile( - sourceDirectory.value / "main/assets/index.html", + root.base / "src/main/assets/index.html", generatedBundlerDir / "index.html" ) }, diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 8885338..92576f0 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -1,12 +1,17 @@ +import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ import sbt._ object Dependencies { val udashCoreVersion = "0.8.3" - val udashJQueryVersion = "3.0.0-SNAPSHOT" + val udashJQueryVersion = "3.0.2" val deps = Def.setting(Seq[ModuleID]( "io.udash" %%% "udash-core" % udashCoreVersion, "io.udash" %%% "udash-jquery" % udashJQueryVersion )) + + val jsDeps = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID]( + "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" + )) } \ No newline at end of file From f913939db0a7e114fa797182604f2cbbd26fb2b5 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 26 Mar 2020 16:03:32 +0100 Subject: [PATCH 19/44] Restore separate index files --- example/build.sbt | 6 +++--- .../{ => bundler-demo}/src/main/assets/index.html | 0 example/global-demo/src/main/assets/index.html | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) rename example/{ => bundler-demo}/src/main/assets/index.html (100%) create mode 100644 example/global-demo/src/main/assets/index.html diff --git a/example/build.sbt b/example/build.sbt index 103332f..97e63f2 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -31,7 +31,7 @@ val generatedGlobalDir = file("generated/global") val compileStatics = taskKey[Unit]("Compiles all static files.") val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") -lazy val root: Project = project.in(file(".")) +lazy val root = project.in(file(".")) .aggregate(`jquery-bundler-demo`, `jquery-global-demo`) .settings( crossScalaVersions := Nil, @@ -59,7 +59,7 @@ lazy val `jquery-global-demo` = project.in(file("global-demo")) copyAssets := { IO.copyFile( - root.base / "src/main/assets/index.html", + sourceDirectory.value / "main/assets/index.html", generatedGlobalDir / "index.html" ) }, @@ -88,7 +88,7 @@ lazy val `jquery-bundler-demo` = project.in(file("bundler-demo")) copyAssets := { IO.copyFile( - root.base / "src/main/assets/index.html", + sourceDirectory.value / "main/assets/index.html", generatedBundlerDir / "index.html" ) }, diff --git a/example/src/main/assets/index.html b/example/bundler-demo/src/main/assets/index.html similarity index 100% rename from example/src/main/assets/index.html rename to example/bundler-demo/src/main/assets/index.html diff --git a/example/global-demo/src/main/assets/index.html b/example/global-demo/src/main/assets/index.html new file mode 100644 index 0000000..9276c28 --- /dev/null +++ b/example/global-demo/src/main/assets/index.html @@ -0,0 +1,13 @@ + + + + + jquery-demo - ScalaJSBundlerPlugin demo + + +
+ + + + + \ No newline at end of file From 32bad57ae3f1de9edd83ab5ed61f1b8b2386b740 Mon Sep 17 00:00:00 2001 From: ddworak Date: Thu, 26 Mar 2020 16:08:22 +0100 Subject: [PATCH 20/44] Root project deps --- example/build.sbt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/example/build.sbt b/example/build.sbt index 97e63f2..49478f2 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -32,10 +32,8 @@ val compileStatics = taskKey[Unit]("Compiles all static files.") val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") lazy val root = project.in(file(".")) - .aggregate(`jquery-bundler-demo`, `jquery-global-demo`) - .settings( - crossScalaVersions := Nil, - ) + .enablePlugins(ScalaJSPlugin) + .settings(commonSettings) lazy val `jquery-global-demo` = project.in(file("global-demo")) .enablePlugins(ScalaJSPlugin) From 6a737892db6aaff4ebc16a4e84c744fbd5670641 Mon Sep 17 00:00:00 2001 From: ddworak Date: Sun, 29 Mar 2020 13:52:51 +0200 Subject: [PATCH 21/44] Udash-less views --- .../global-demo/src/main/assets/index.html | 4 +- example/project/Dependencies.scala | 6 +-- .../demos/jquery/{init.scala => Init.scala} | 12 +---- .../demos/jquery/RoutingRegistryDef.scala | 29 ------------ .../jquery/StatesToViewPresenterDef.scala | 27 ----------- .../scala/io/udash/demos/jquery/states.scala | 32 ------------- .../udash/demos/jquery/views/ErrorView.scala | 13 ------ .../demos/jquery/views/FunctionView.scala | 15 ++++--- .../udash/demos/jquery/views/IndexView.scala | 45 +++++++++---------- .../udash/demos/jquery/views/RootView.scala | 16 ------- .../jquery/views/functions/AddBackView.scala | 20 ++++----- .../jquery/views/functions/AddView.scala | 14 +++--- ...{AfterView.scala => AfterBeforeView.scala} | 13 +++--- .../jquery/views/functions/AnimateView.scala | 16 +++---- .../views/functions/AppendPrependView.scala | 13 +++--- .../jquery/views/functions/AttrView.scala | 23 +++++----- .../views/functions/CallbacksView.scala | 17 +++---- .../jquery/views/functions/ChildrenView.scala | 13 +++--- .../jquery/views/functions/DataView.scala | 13 +++--- .../jquery/views/functions/DeferredView.scala | 13 +++--- .../jquery/views/functions/EachView.scala | 13 +++--- .../jquery/views/functions/HideShowView.scala | 13 +++--- .../views/functions/OffsetPositionView.scala | 13 +++--- .../jquery/views/functions/OnOneOffView.scala | 15 +++---- 24 files changed, 117 insertions(+), 291 deletions(-) rename example/src/main/scala/io/udash/demos/jquery/{init.scala => Init.scala} (52%) delete mode 100644 example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/states.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/RootView.scala rename example/src/main/scala/io/udash/demos/jquery/views/functions/{AfterView.scala => AfterBeforeView.scala} (61%) diff --git a/example/global-demo/src/main/assets/index.html b/example/global-demo/src/main/assets/index.html index 9276c28..90d7641 100644 --- a/example/global-demo/src/main/assets/index.html +++ b/example/global-demo/src/main/assets/index.html @@ -2,12 +2,12 @@ - jquery-demo - ScalaJSBundlerPlugin demo + jquery-demo - global scope
- + \ No newline at end of file diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 92576f0..7be9655 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -1,13 +1,13 @@ -import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ +import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import sbt._ object Dependencies { - val udashCoreVersion = "0.8.3" + val scalatagsVersion = "0.8.6" val udashJQueryVersion = "3.0.2" val deps = Def.setting(Seq[ModuleID]( - "io.udash" %%% "udash-core" % udashCoreVersion, + "com.lihaoyi" %%% "scalatags" % scalatagsVersion, "io.udash" %%% "udash-jquery" % udashJQueryVersion )) diff --git a/example/src/main/scala/io/udash/demos/jquery/init.scala b/example/src/main/scala/io/udash/demos/jquery/Init.scala similarity index 52% rename from example/src/main/scala/io/udash/demos/jquery/init.scala rename to example/src/main/scala/io/udash/demos/jquery/Init.scala index 549798b..0836569 100644 --- a/example/src/main/scala/io/udash/demos/jquery/init.scala +++ b/example/src/main/scala/io/udash/demos/jquery/Init.scala @@ -1,22 +1,12 @@ package io.udash.demos.jquery -import io.udash._ import io.udash.wrappers.jquery._ import org.scalajs.dom import org.scalajs.dom.Element 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) -} - object Init { - import Context._ @JSExport def main(args: Array[String]): Unit = { @@ -25,7 +15,7 @@ object Init { if (appRoot.isEmpty) { dom.console.error("Application root element not found! Check you index.html file!") } else { - applicationInstance.run(appRoot.get) + //applicationInstance.run(appRoot.get) } }) } 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 f43d899..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala +++ /dev/null @@ -1,29 +0,0 @@ -package io.udash.demos.jquery - -import io.udash._ - -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 { - 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 dee3a6e..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 ViewFactoryRegistry[RoutingState] { - def matchStateToResolver(state: RoutingState): ViewFactory[_ <: 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/states.scala b/example/src/main/scala/io/udash/demos/jquery/states.scala deleted file mode 100644 index f4e7452..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/states.scala +++ /dev/null @@ -1,32 +0,0 @@ -package io.udash.demos.jquery - -import io.udash._ - -sealed abstract class RoutingState(val parentState: Option[ContainerRoutingState]) extends State { - type HierarchyRoot = RoutingState - - def url(implicit application: Application[RoutingState]): String = - s"#${application.matchState(this).value}" -} - -sealed abstract class ContainerRoutingState(parentState: Option[ContainerRoutingState]) extends RoutingState(parentState) with ContainerState -sealed abstract class FinalRoutingState(parentState: ContainerRoutingState) extends RoutingState(Option(parentState)) with FinalState - - -case object RootState extends ContainerRoutingState(None) -case object ErrorState extends FinalRoutingState(RootState) -case object IndexState extends FinalRoutingState(RootState) -case object AddState extends FinalRoutingState(RootState) -case object AddBackState extends FinalRoutingState(RootState) -case object AfterBeforeState extends FinalRoutingState(RootState) -case object AnimateState extends FinalRoutingState(RootState) -case object AppendPrependState extends FinalRoutingState(RootState) -case object AttrState extends FinalRoutingState(RootState) -case object CallbacksState extends FinalRoutingState(RootState) -case object ChildrenState extends FinalRoutingState(RootState) -case object DataState extends FinalRoutingState(RootState) -case object DeferredState extends FinalRoutingState(RootState) -case object EachState extends FinalRoutingState(RootState) -case object HideShowState extends FinalRoutingState(RootState) -case object OffsetPositionState extends FinalRoutingState(RootState) -case object OnOneOffState extends FinalRoutingState(RootState) \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala b/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala deleted file mode 100644 index a2b8fa7..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala +++ /dev/null @@ -1,13 +0,0 @@ -package io.udash.demos.jquery.views - -import io.udash._ -import io.udash.demos.jquery.IndexState - -object ErrorViewPresenter extends StaticViewFactory[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 index 5874d47..d26459e 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala @@ -1,19 +1,20 @@ package io.udash.demos.jquery.views -import io.udash._ -import org.scalajs.dom.{Element, Event} +import org.scalajs.dom.Event + +abstract class FunctionView { -abstract class FunctionView extends FinalView { import scalatags.JsDom.all._ - protected val content: Element - protected val script: () => Any + protected def content: Modifier + + protected def script: () => Any - override def getTemplate: Modifier = + final def getTemplate: Modifier = div( content, button( - onclick :+= ((_: Event) => { + onclick := ((_: Event) => { script() false }) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala index cad18f0..4783c0f 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala @@ -1,33 +1,30 @@ package io.udash.demos.jquery.views -import io.udash._ -import io.udash.demos.jquery._ +import io.udash.demos.jquery.views.functions._ -object IndexViewPresenter extends StaticViewFactory[IndexState.type](() => new IndexView) +object 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()")) - ) + private val demos = Seq( + AddBackView, + AddView, + AfterBeforeView, + AnimateView, + AppendPrependView, + AttrView, + CallbacksView, + ChildrenView, + DataView, + DeferredView, + EachView, + HideShowView, + OffsetPositionView, + OnOneOffView, ) - override def getTemplate: Modifier = content + final val content = div( + "Take a look at following demo pages:", + demos.map(_.getTemplate), + ) } \ 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 3906559..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/RootView.scala +++ /dev/null @@ -1,16 +0,0 @@ -package io.udash.demos.jquery.views - -import io.udash._ -import io.udash.demos.jquery.{Context, IndexState, RootState} - -object RootViewPresenter extends StaticViewFactory[RootState.type](() => new RootView) - -class RootView extends ContainerView { - import Context._ - import scalatags.JsDom.all._ - - override def getTemplate: Modifier = div( - a(href := IndexState.url)(h1("jquery-demo")), - childViewContainer - ) -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala index cdc25ba..620c320 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala @@ -1,19 +1,15 @@ 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 StaticViewFactory[IndexState.type](() => new AddBackView) - /** Based on examples from: jQuery Docs. */ -class AddBackView extends FunctionView { +object AddBackView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".addBack() & .addClass()"), tags2.style( """.demo p, .demo div { @@ -48,15 +44,15 @@ class AddBackView extends FunctionView { p("Second Paragraph") ) ) - ).render + ) - override protected val script = () => { - jQ( ".demo div.left, .demo div.right" ).find( "div, div > p" ).addClass( "border" ) + override protected def 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" ) + jQ(".demo div.before-addback").find("p").addClass("background") // Second Example - jQ( ".demo div.after-addback" ).find( "p" ).addBack().addClass( "background" ) + 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 index 9c0b0d8..f97749d 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala @@ -1,19 +1,15 @@ 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 StaticViewFactory[IndexState.type](() => new AddView) - /** Based on examples from: jQuery Docs. */ -class AddView extends FunctionView { +object AddView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".add() & .css()"), tags2.style( """.demo div { @@ -38,9 +34,9 @@ class AddView extends FunctionView { div(), div(), p("Added this... (notice no border)") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo div").css("border", "2px solid red") .add(".demo p") .css("background", "yellow") 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/AfterBeforeView.scala similarity index 61% rename from example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala rename to example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala index 7e61e09..32acbed 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala @@ -1,17 +1,14 @@ 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 StaticViewFactory[IndexState.type](() => new AfterBeforeView) - /** Based on examples from: jQuery Docs. */ -class AfterBeforeView extends FunctionView { +object AfterBeforeView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".after()"), div( p(cls := "after")("I would like to say: ") @@ -20,9 +17,9 @@ class AfterBeforeView extends FunctionView { div( p(cls := "before")("is what I said...") ) - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".after").after("Hello") jQ(".before").before("Hello") } diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala index c1c8693..ec14da8 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala @@ -1,20 +1,16 @@ 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 StaticViewFactory[IndexState.type](() => new AnimateView) - /** Based on examples from: jQuery Docs. */ -class AnimateView extends FunctionView { +object AnimateView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".animate() & .click()"), tags2.style( """.demo div { @@ -36,11 +32,11 @@ class AnimateView extends FunctionView { button(id := "go4", disabled := "disabled")("» Reset"), div(id := "block1")("Block1"), div(id := "block2")("Block2") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ("#go1").on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ( "#block1" ) + jQ("#block1") .animate(Map( "width" -> "90%" ), AnimationOptions( diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala index 2908b43..90d01e5 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala @@ -1,24 +1,21 @@ 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 StaticViewFactory[IndexState.type](() => new AppendPrependView) - /** Based on examples from: jQuery Docs. */ -class AppendPrependView extends FunctionView { +object AppendPrependView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def 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 = () => { + override protected def script = () => { jQ("#append").append("hello") jQ("#prepend").prepend("Hello ") } diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala index 7ae29d0..3fc4748 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala @@ -1,45 +1,42 @@ 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 StaticViewFactory[IndexState.type](() => new AttrView) - /** Based on examples from: jQuery Docs. */ -class AttrView extends FunctionView { +object AttrView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".attr() & .prop()"), input(id := "check1", tpe := "checkbox", checked := "checked"), label(`for` := "check1")("Check me"), p(), - button(onclick :+= ((_: Event) => { + button(onclick := ((_: Event) => { jQ(".demo input").attr("data-checked", "checked").trigger("change") false }))(".attr(\"data-checked\", \"checked\")"), - button(onclick :+= ((_: Event) => { + button(onclick := ((_: Event) => { jQ(".demo input").attr("data-checked", "").trigger("change") false }))(".attr(\"data-checked\", \"\")"), - button(onclick :+= ((_: Event) => { + button(onclick := ((_: Event) => { jQ(".demo input").attr("data-checked", null).trigger("change") false }))(".attr(\"data-checked\", null)"), br(), - button(onclick :+= ((_: Event) => { + button(onclick := ((_: Event) => { jQ(".demo input").prop("checked", true).trigger("change") false }))(".prop(\"checked\", true)"), - button(onclick :+= ((_: Event) => { + button(onclick := ((_: Event) => { jQ(".demo input").prop("checked", false).trigger("change") false }))(".prop(\"checked\", false)") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo input").on(EventName.change, (input: Element, _: JQueryEvent) => { jQ(".demo p").html( s""".attr('data-checked'): ${jQ(input).attr("data-checked")}
diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala index e3824bb..639b700 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala @@ -1,35 +1,32 @@ 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 StaticViewFactory[IndexState.type](() => new CallbacksView) - /** Based on examples from: jQuery Docs. */ -class CallbacksView extends FunctionView { +object CallbacksView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3("Callbacks"), ul(id := "plus"), ul(id := "minus"), ul(id := "mul"), ul(id := "div") - ).render + ) - override protected val script = () => { + override protected def 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) + 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) + jQ("#minus").append(li(s"$a - $b = ${a - b}").render) }) callbacks.add((t: (Int, Int)) => { val (a, b) = t diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala index ea4d0f6..a1e492e 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala @@ -1,17 +1,14 @@ 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 StaticViewFactory[IndexState.type](() => new ChildrenView) - /** Based on examples from: jQuery Docs. */ -class ChildrenView extends FunctionView { +object ChildrenView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".children()"), div( span("Hello"), @@ -19,9 +16,9 @@ class ChildrenView extends FunctionView { div(cls := "selected")("and again"), p("and one last time.") ) - ).render + ) - override protected val script = () => { + override protected def 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") diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala index f905ec5..3f315f6 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala @@ -1,17 +1,14 @@ 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 StaticViewFactory[IndexState.type](() => new DataView) - /** Based on examples from: jQuery Docs. */ -class DataView extends FunctionView { +object DataView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".data()"), div( "The values stored were ", @@ -19,9 +16,9 @@ class DataView extends FunctionView { " and ", span("_") ) - ).render + ) - override protected val script = () => { + override protected def 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) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala index 82ee717..a4e1cbe 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala @@ -1,22 +1,19 @@ 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 StaticViewFactory[IndexState.type](() => new DeferredView) - /** Based on examples from: jQuery Docs. */ -class DeferredView extends FunctionView { +object DeferredView extends FunctionView { + import scalatags.JsDom.all._ var deferred: JQueryDeferred[js.Function1[Int, js.Any], Int] = null - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3("Deferred"), div( div(id := "deferred")("???"), @@ -42,9 +39,9 @@ class DeferredView extends FunctionView { }) )("Notify(1)") ) - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo button").prop("disabled", "") deferred = jQ.deferred[js.Function1[Int, js.Any], Int]() jQ("#deferred").text(s"Waiting...") diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala index 447267b..dd64fc7 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala @@ -1,25 +1,22 @@ 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 StaticViewFactory[IndexState.type](() => new EachView) - /** Based on examples from: jQuery Docs. */ -class EachView extends FunctionView { +object EachView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".each()"), div("Click button"), div("to iterate through"), div("these divs.") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo div").each((el: Element, idx: Int) => { jQ(el).replaceWith(span(s"${el.textContent} ").render) }) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala index 9ed0a46..4227d2c 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala @@ -1,22 +1,19 @@ 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 StaticViewFactory[IndexState.type](() => new HideShowView) - /** Based on examples from: jQuery Docs. */ -class HideShowView extends FunctionView { +object HideShowView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".hide() & .show()"), div("Click button to hide me") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo div") .hide(AnimationOptions( duration = Some(3000), diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala index 9ec5d02..9ad4328 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala @@ -1,25 +1,22 @@ package io.udash.demos.jquery.views.functions -import io.udash._ -import io.udash.demos.jquery.OffsetPositionState import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ -object OffsetPositionViewPresenter extends StaticViewFactory[OffsetPositionState.type](() => new OffsetPositionView) - /** Based on examples from: jQuery Docs. */ -class OffsetPositionView extends FunctionView { +object OffsetPositionView extends FunctionView { + import scalatags.JsDom.all._ - override protected val content = div(cls := "demo")( + override protected def 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 = () => { + override protected def script = () => { val div = jQ(".demo div") val p = jQ(".demo div p") jQ("#results").html( diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala index 08035d0..1c0de22 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala @@ -1,15 +1,12 @@ 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 StaticViewFactory[IndexState.type](() => new OnOneOffView) - /** Based on examples from: jQuery Docs. */ -class OnOneOffView extends FunctionView { +object OnOneOffView extends FunctionView { + import scalatags.JsDom.all._ val onCallback = (_: Element, _: JQueryEvent) => @@ -17,23 +14,23 @@ class OnOneOffView extends FunctionView { val oneCallback = (_: Element, _: JQueryEvent) => jQ(".demo ul").append(li("This will be added only once").render) - override protected val content = div(cls := "demo")( + override protected def content = div(cls := "demo")( h3(".on() & .one() & .off()"), button(id := "click", disabled := "disabled")("Click me"), ul(), button( id := "off", disabled := "disabled", - onclick :+= ((_: Event) => { + onclick := ((_: Event) => { jQ(".demo #click") .off(EventName.click, onCallback) .off(EventName.click, oneCallback) false }) )("Off") - ).render + ) - override protected val script = () => { + override protected def script = () => { jQ(".demo #click") .on(EventName.click, onCallback) .one(EventName.click, oneCallback) From 02637545b9994ea261b30ce307a94222178402c7 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 08:25:54 +0200 Subject: [PATCH 22/44] Append demos --- example/src/main/scala/io/udash/demos/jquery/Init.scala | 2 ++ .../main/scala/io/udash/demos/jquery/views/IndexView.scala | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example/src/main/scala/io/udash/demos/jquery/Init.scala b/example/src/main/scala/io/udash/demos/jquery/Init.scala index 0836569..40ed49c 100644 --- a/example/src/main/scala/io/udash/demos/jquery/Init.scala +++ b/example/src/main/scala/io/udash/demos/jquery/Init.scala @@ -1,5 +1,6 @@ package io.udash.demos.jquery +import io.udash.demos.jquery.views.IndexView import io.udash.wrappers.jquery._ import org.scalajs.dom import org.scalajs.dom.Element @@ -15,6 +16,7 @@ object Init { if (appRoot.isEmpty) { dom.console.error("Application root element not found! Check you index.html file!") } else { + appRoot.get.appendChild(IndexView.content.render) //applicationInstance.run(appRoot.get) } }) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala index 4783c0f..672b852 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala @@ -24,7 +24,7 @@ object IndexView { ) final val content = div( - "Take a look at following demo pages:", - demos.map(_.getTemplate), + "Take a look at following demos:", + demos.map(demo => div(demo.getTemplate)), ) } \ No newline at end of file From 64ddf4b652d5a588601d81addc19693ebe847c94 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 10:34:05 +0200 Subject: [PATCH 23/44] Fixes for single view scripts --- .../demos/jquery/views/FunctionView.scala | 9 ++++--- .../udash/demos/jquery/views/IndexView.scala | 2 +- .../jquery/views/functions/AddBackView.scala | 26 ++++++------------- .../jquery/views/functions/AddView.scala | 12 ++++----- .../views/functions/AfterBeforeView.scala | 8 +++--- .../jquery/views/functions/AnimateView.scala | 26 +++++++++---------- .../views/functions/AppendPrependView.scala | 8 +++--- .../jquery/views/functions/AttrView.scala | 19 +++++++------- .../views/functions/CallbacksView.scala | 12 ++++----- .../jquery/views/functions/ChildrenView.scala | 10 +++---- .../jquery/views/functions/DataView.scala | 12 ++++----- .../jquery/views/functions/DeferredView.scala | 14 +++++----- .../jquery/views/functions/EachView.scala | 6 ++--- .../jquery/views/functions/HideShowView.scala | 6 ++--- .../views/functions/OffsetPositionView.scala | 10 +++---- .../jquery/views/functions/OnOneOffView.scala | 15 ++++++----- 16 files changed, 94 insertions(+), 101 deletions(-) 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 index d26459e..e3c7360 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala @@ -1,23 +1,24 @@ package io.udash.demos.jquery.views -import org.scalajs.dom.Event +import org.scalajs.dom.{Element, Event} abstract class FunctionView { import scalatags.JsDom.all._ - protected def content: Modifier + protected val content: Element protected def script: () => Any final def getTemplate: Modifier = div( content, - button( + h3(button( + marginTop := 10.px, onclick := ((_: Event) => { script() false }) - )("Run script") + )("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 index 672b852..0a1e7e2 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala @@ -25,6 +25,6 @@ object IndexView { final val content = div( "Take a look at following demos:", - demos.map(demo => div(demo.getTemplate)), + demos.map(demo => Seq(hr, div(demo.getTemplate))), ) } \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala index 620c320..3927a6b 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala @@ -9,25 +9,15 @@ object AddBackView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div(cls := "addback")( h3(".addBack() & .addClass()"), tags2.style( - """.demo p, .demo div { - | margin: 5px; - | padding: 5px; - |} - |.border { + """ + |.addback .border { | border: 2px solid red; |} - |.background { + |.addback .background { | background: yellow; - |} - |.left, .right { - | width: 45%; - | float: left; - |} - |.right { - | margin-left: 3%; |}""".stripMargin ), div(cls := "left")( @@ -44,15 +34,15 @@ object AddBackView extends FunctionView { p("Second Paragraph") ) ) - ) + ).render override protected def script = () => { - jQ(".demo div.left, .demo div.right").find("div, div > p").addClass("border") + jQ("div.left, div.right", content).find("div, div > p").addClass("border") // First Example - jQ(".demo div.before-addback").find("p").addClass("background") + jQ("div.before-addback", content).find("p").addClass("background") // Second Example - jQ(".demo div.after-addback").find("p").addBack().addClass("background") + jQ("div.after-addback", content).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 index f97749d..45c65f1 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala @@ -9,16 +9,16 @@ object AddView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div(cls := "addview")( h3(".add() & .css()"), tags2.style( - """.demo div { + """.addview div { | width: 60px; | height: 60px; | margin: 10px; | float: left; |} - |.demo p { + |.addview p { | clear: left; | font-weight: bold; | font-size: 16px; @@ -34,11 +34,11 @@ object AddView extends FunctionView { div(), div(), p("Added this... (notice no border)") - ) + ).render override protected def script = () => { - jQ(".demo div").css("border", "2px solid red") - .add(".demo p") + jQ("div", content).css("border", "2px solid red") + .add("p", content) .css("background", "yellow") } } \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala index 32acbed..3aaf39d 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala @@ -8,7 +8,7 @@ object AfterBeforeView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".after()"), div( p(cls := "after")("I would like to say: ") @@ -17,10 +17,10 @@ object AfterBeforeView extends FunctionView { div( p(cls := "before")("is what I said...") ) - ) + ).render override protected def script = () => { - jQ(".after").after("Hello") - jQ(".before").before("Hello") + jQ(".after", content).after("Hello") + jQ(".before", content).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 index ec14da8..445631d 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala @@ -10,10 +10,10 @@ object AnimateView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div(cls := "animate")( h3(".animate() & .click()"), tags2.style( - """.demo div { + """.animate div { | background-color: #bca; | width: 200px; | height: 1.1em; @@ -22,7 +22,7 @@ object AnimateView extends FunctionView { | margin: 3px; | font-size: 14px; |} - |.demo button { + |.animate button { | font-size: 14px; |}""".stripMargin ), @@ -32,11 +32,11 @@ object AnimateView extends FunctionView { button(id := "go4", disabled := "disabled")("» Reset"), div(id := "block1")("Block1"), div(id := "block2")("Block2") - ) + ).render override protected def script = () => { - jQ("#go1").on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#block1") + jQ("#go1", content).on(EventName.click, (_: Element, _: JQueryEvent) => { + jQ("#block1", content) .animate(Map( "width" -> "90%" ), AnimationOptions( @@ -47,27 +47,27 @@ object AnimateView extends FunctionView { .animate(Map("borderRightWidth" -> "15px"), 1500) }) - jQ("#go2").on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#block2") + jQ("#go2", content).on(EventName.click, (_: Element, _: JQueryEvent) => { + jQ("#block2", content) .animate(Map("width" -> "90%"), 1000) .animate(Map("fontSize" -> "24px"), 1000) .animate(Map("borderLeftWidth" -> "15px"), 1000) }) - jQ("#go3").on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#go1").add("#go2").trigger("click") + jQ("#go3", content).on(EventName.click, (_: Element, _: JQueryEvent) => { + jQ("#go1", content).add("#go2", content).trigger("click") }) - jQ("#go4").on(EventName.click, (_: Element, _: JQueryEvent) => { + jQ("#go4", content).on(EventName.click, (_: Element, _: JQueryEvent) => { // TODO: It does not work without explicit Map elements type import scala.scalajs.js.`|` - jQ("div").css(Map[String, String | Int | Double | Boolean]( + jQ("div", content).css(Map[String, String | Int | Double | Boolean]( "width" -> "", "fontSize" -> "", "borderWidth" -> "" )) }) - jQ(".demo button").prop("disabled", "") + jQ("button", content).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 index 90d01e5..b5d2d81 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala @@ -8,15 +8,15 @@ object AppendPrependView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".append()"), p(id := "append")("I would like to say: "), h3(".prepend()"), p(id := "prepend")("amigo!") - ) + ).render override protected def script = () => { - jQ("#append").append("hello") - jQ("#prepend").prepend("Hello ") + jQ("#append", content).append("hello") + jQ("#prepend", content).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 index 3fc4748..0c6f2be 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala @@ -2,6 +2,7 @@ package io.udash.demos.jquery.views.functions import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ +import org.scalajs.dom.html.Div import org.scalajs.dom.{Element, Event} /** Based on examples from: jQuery Docs. */ @@ -9,36 +10,36 @@ object AttrView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content: Div = div( 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").trigger("change") + jQ("input", content).attr("data-checked", "checked").trigger("change") false }))(".attr(\"data-checked\", \"checked\")"), button(onclick := ((_: Event) => { - jQ(".demo input").attr("data-checked", "").trigger("change") + jQ("input", content).attr("data-checked", "").trigger("change") false }))(".attr(\"data-checked\", \"\")"), button(onclick := ((_: Event) => { - jQ(".demo input").attr("data-checked", null).trigger("change") + jQ("input", content).attr("data-checked", null).trigger("change") false }))(".attr(\"data-checked\", null)"), br(), button(onclick := ((_: Event) => { - jQ(".demo input").prop("checked", true).trigger("change") + jQ("input", content).prop("checked", true).trigger("change") false }))(".prop(\"checked\", true)"), button(onclick := ((_: Event) => { - jQ(".demo input").prop("checked", false).trigger("change") + jQ("input", content).prop("checked", false).trigger("change") false }))(".prop(\"checked\", false)") - ) + ).render override protected def script = () => { - jQ(".demo input").on(EventName.change, (input: Element, _: JQueryEvent) => { - jQ(".demo p").html( + jQ("input", content).on(EventName.change, (input: Element, _: JQueryEvent) => { + jQ("p", content).html( s""".attr('data-checked'): ${jQ(input).attr("data-checked")}
|.prop('checked'): ${jQ(input).prop("checked")}
|.is(':checked'): ${jQ(input).is(":checked")}""".stripMargin diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala index 639b700..a7a8243 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala @@ -10,31 +10,31 @@ object CallbacksView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3("Callbacks"), ul(id := "plus"), ul(id := "minus"), ul(id := "mul"), ul(id := "div") - ) + ).render override protected def 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) + jQ("#plus", content).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) + jQ("#minus", content).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) + jQ("#mul", content).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) + jQ("#div", content).append(li(s"$a / $b = ${a / b}").render) }) callbacks.fire((1, 1)) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala index a1e492e..7043bc8 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala @@ -8,7 +8,7 @@ object ChildrenView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".children()"), div( span("Hello"), @@ -16,11 +16,11 @@ object ChildrenView extends FunctionView { div(cls := "selected")("and again"), p("and one last time.") ) - ) + ).render override protected def 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") + jQ("div", content).children().css("color", "blue") + jQ("div", content).children(".selected").css("border-bottom", "3px double red") + jQ("div", content).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 index 3f315f6..ad3f660 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala @@ -8,7 +8,7 @@ object DataView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".data()"), div( "The values stored were ", @@ -16,12 +16,12 @@ object DataView extends FunctionView { " and ", span("_") ) - ) + ).render override protected def 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) + jQ("div", content).data("test", Map("first" -> 16, "last" -> "pizza!")) + val data: Map[String, Any] = jQ("div", content).data("test").get.asInstanceOf[Map[String, Any]] + jQ("div span:first", content).text(data.get("first").get.toString) + jQ("div span:last", content).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 index a4e1cbe..ae31443 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala @@ -13,7 +13,7 @@ object DeferredView extends FunctionView { var deferred: JQueryDeferred[js.Function1[Int, js.Any], Int] = null - override protected def content = div(cls := "demo")( + override protected val content = div( h3("Deferred"), div( div(id := "deferred")("???"), @@ -39,14 +39,14 @@ object DeferredView extends FunctionView { }) )("Notify(1)") ) - ) + ).render override protected def script = () => { - jQ(".demo button").prop("disabled", "") + jQ("button", content).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")) + jQ("#deferred", content).text(s"Waiting...") + deferred.done((i: Int) => jQ("#deferred", content).text(s"Done: $i")) + deferred.fail((i: Int) => jQ("#deferred", content).text(s"Fail: $i")) + deferred.progress((i: Int) => jQ("#deferred", content).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 index dd64fc7..0f5097a 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala @@ -9,15 +9,15 @@ object EachView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".each()"), div("Click button"), div("to iterate through"), div("these divs.") - ) + ).render override protected def script = () => { - jQ(".demo div").each((el: Element, idx: Int) => { + jQ("div", content).each((el: Element, idx: Int) => { jQ(el).replaceWith(span(s"${el.textContent} ").render) }) } diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala index 4227d2c..7a1d137 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala @@ -8,13 +8,13 @@ object HideShowView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( h3(".hide() & .show()"), div("Click button to hide me") - ) + ).render override protected def script = () => { - jQ(".demo div") + jQ("div", content) .hide(AnimationOptions( duration = Some(3000), easing = Some(EasingFunction.linear) diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala index 9ad4328..0796b29 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala @@ -8,18 +8,18 @@ object OffsetPositionView extends FunctionView { import scalatags.JsDom.all._ - override protected def content = div(cls := "demo")( + override protected val content = div( 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 def script = () => { - val div = jQ(".demo div") - val p = jQ(".demo div p") - jQ("#results").html( + val div = jQ("div", content) + val p = jQ("div p", content) + jQ("#results", content).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})
diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala index 1c0de22..368f69f 100644 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala +++ b/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala @@ -2,6 +2,7 @@ package io.udash.demos.jquery.views.functions import io.udash.demos.jquery.views.FunctionView import io.udash.wrappers.jquery._ +import org.scalajs.dom.html.Div import org.scalajs.dom.{Element, Event} /** Based on examples from: jQuery Docs. */ @@ -10,11 +11,11 @@ object OnOneOffView extends FunctionView { import scalatags.JsDom.all._ val onCallback = (_: Element, _: JQueryEvent) => - jQ(".demo ul").append(li("This will be added on every click").render) + jQ("ul", content).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) + jQ("ul", content).append(li("This will be added only once").render) - override protected def content = div(cls := "demo")( + override protected val content: Div = div( h3(".on() & .one() & .off()"), button(id := "click", disabled := "disabled")("Click me"), ul(), @@ -22,20 +23,20 @@ object OnOneOffView extends FunctionView { id := "off", disabled := "disabled", onclick := ((_: Event) => { - jQ(".demo #click") + jQ("#click", content) .off(EventName.click, onCallback) .off(EventName.click, oneCallback) false }) )("Off") - ) + ).render override protected def script = () => { - jQ(".demo #click") + jQ("#click", content) .on(EventName.click, onCallback) .one(EventName.click, oneCallback) - jQ(".demo button") + jQ("button", content) .prop("disabled", "") } } \ No newline at end of file From 06ca2e3517d76ea94c26d7e198e566c3ba61bae1 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 10:40:12 +0200 Subject: [PATCH 24/44] Fix global demo --- example/global-demo/src/main/assets/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/global-demo/src/main/assets/index.html b/example/global-demo/src/main/assets/index.html index 90d7641..b746eab 100644 --- a/example/global-demo/src/main/assets/index.html +++ b/example/global-demo/src/main/assets/index.html @@ -7,7 +7,7 @@
- + \ No newline at end of file From 3800211c7814d6ed6b9a3ff731a0f0f252d6a771 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 11:07:31 +0200 Subject: [PATCH 25/44] Use locally published snapshot with Scala 2.13 and SJS 1.0 --- example/build.sbt | 16 +++++++++------- example/project/Dependencies.scala | 7 +------ example/project/plugins.sbt | 5 +++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/example/build.sbt b/example/build.sbt index 49478f2..58ef253 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -1,13 +1,13 @@ name := "jquery-demo" inThisBuild(Seq( - version := "3.0.2", + version := "3.0.0-SNAPSHOT", organization := "io.udash", )) val commonSettings = Seq( - scalaVersion := "2.12.10", - crossScalaVersions := Seq("2.12.10"), //todo 2.13 & SJS 1.0 with Udash 0.9 + scalaVersion := "2.12.11", + crossScalaVersions := Seq("2.13.1"), scalacOptions ++= Seq( "-feature", "-deprecation", @@ -34,17 +34,17 @@ val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") lazy val root = project.in(file(".")) .enablePlugins(ScalaJSPlugin) .settings(commonSettings) + .aggregate(`jquery-bundler-demo`, `jquery-global-demo`) lazy val `jquery-global-demo` = project.in(file("global-demo")) - .enablePlugins(ScalaJSPlugin) + .enablePlugins(ScalaJSPlugin, JSDependenciesPlugin) .settings( commonSettings, - jsDependencies ++= Dependencies.jsDeps.value, - sourceDirsSettings(_.getParentFile), - /* move these files out of target/. */ + cleanFiles += generatedGlobalDir, + Compile / fullOptJS / crossTarget := generatedGlobalDir, Compile / fastOptJS / crossTarget := generatedGlobalDir, Compile / packageJSDependencies / crossTarget := generatedGlobalDir, @@ -91,6 +91,8 @@ lazy val `jquery-bundler-demo` = project.in(file("bundler-demo")) ) }, + cleanFiles += generatedBundlerDir, + compileStatics := { val sjsFileName = (Compile / fastOptJS).value.data.name.stripSuffix(".js") IO.copyFile( diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala index 7be9655..a21498f 100644 --- a/example/project/Dependencies.scala +++ b/example/project/Dependencies.scala @@ -1,17 +1,12 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ -import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ import sbt._ object Dependencies { val scalatagsVersion = "0.8.6" - val udashJQueryVersion = "3.0.2" + val udashJQueryVersion = "3.0.0-SNAPSHOT" val deps = Def.setting(Seq[ModuleID]( "com.lihaoyi" %%% "scalatags" % scalatagsVersion, "io.udash" %%% "udash-jquery" % udashJQueryVersion )) - - val jsDeps = Def.setting(Seq[org.scalajs.sbtplugin.JSModuleID]( - "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" - )) } \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt index c0848e6..17a23aa 100644 --- a/example/project/plugins.sbt +++ b/example/project/plugins.sbt @@ -1,4 +1,5 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.32") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler-sjs06" % "0.17.0") \ No newline at end of file +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") +addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0") \ No newline at end of file From 1dc8d7e1e12957a069bb336b96ea3150350507f3 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 11:09:03 +0200 Subject: [PATCH 26/44] Cross-compile in tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e2322af..8464a62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ jobs: - stage: test script: - sbt +test +publishLocal - - cd example && sbt compileStatics + - cd example && sbt +compileStatics - stage: release if: tag =~ ^v script: From 0c61ec228532584bcc69dabce1b500752e72e557 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 11:54:07 +0200 Subject: [PATCH 27/44] Docs update --- README.md | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8e775a1..88ff328 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) program Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "3.0.2" +libraryDependencies += "io.udash" %%% "udash-jquery" % "3.0.4" ``` then import the jQuery package: @@ -19,21 +19,9 @@ then import the jQuery package: import io.udash.wrappers.jquery._ ``` -Since version `3.0.0` the wrapper is published as a CommonJS module with JS dependencies managed -by [scalajs-bundler](https://github.com/scalacenter/scalajs-bundler). - -If you do not want to use the bundler, you have to include jQuery sources manually by: - * explicit link in your `index.html`. - ```html - - ``` - * or a [Scala.js dependency](http://www.scala-js.org/doc/project/dependencies.html). - ```scala - jsDependencies += - "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js" - ``` +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 From e48541737cc55884d07f7c522123e7e9ae0c5b51 Mon Sep 17 00:00:00 2001 From: ddworak Date: Mon, 30 Mar 2020 11:59:38 +0200 Subject: [PATCH 28/44] Simplified init --- .../main/scala/io/udash/demos/jquery/Init.scala | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/example/src/main/scala/io/udash/demos/jquery/Init.scala b/example/src/main/scala/io/udash/demos/jquery/Init.scala index 40ed49c..a1f296e 100644 --- a/example/src/main/scala/io/udash/demos/jquery/Init.scala +++ b/example/src/main/scala/io/udash/demos/jquery/Init.scala @@ -1,24 +1,13 @@ package io.udash.demos.jquery import io.udash.demos.jquery.views.IndexView -import io.udash.wrappers.jquery._ import org.scalajs.dom -import org.scalajs.dom.Element import scala.scalajs.js.annotation.JSExport object Init { @JSExport - def main(args: Array[String]): Unit = { - jQ((_: Element) => { - val appRoot = jQ("#application").get(0) - if (appRoot.isEmpty) { - dom.console.error("Application root element not found! Check you index.html file!") - } else { - appRoot.get.appendChild(IndexView.content.render) - //applicationInstance.run(appRoot.get) - } - }) - } + def main(args: Array[String]): Unit = + dom.document.querySelector("#application").appendChild(IndexView.content.render) } \ No newline at end of file From 51ac68f4df0434dfc86088b3b5812b871cefbc8d Mon Sep 17 00:00:00 2001 From: ddworak Date: Fri, 3 Apr 2020 11:50:25 +0200 Subject: [PATCH 29/44] Don't run tests on tag runs --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8464a62..a8090ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ scala: jobs: include: - stage: test + if: !(tag =~ ^v) script: - sbt +test +publishLocal - cd example && sbt +compileStatics From 86bb34ebf9278099f7a2ac5d115a80db6e821f1b Mon Sep 17 00:00:00 2001 From: ddworak Date: Fri, 3 Apr 2020 11:56:31 +0200 Subject: [PATCH 30/44] Don't run tests on tag runs again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8090ca..d996112 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ scala: jobs: include: - stage: test - if: !(tag =~ ^v) + if: NOT tag =~ ^v script: - sbt +test +publishLocal - cd example && sbt +compileStatics From fb7f0089dc26ad059b00e4b758c5e175c4948d4e Mon Sep 17 00:00:00 2001 From: ddworak Date: Fri, 10 Apr 2020 15:22:25 +0200 Subject: [PATCH 31/44] jQuery 3.4.1 --- build.sbt | 8 ++++---- project/build.properties | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 1addc24..8482c85 100644 --- a/build.sbt +++ b/build.sbt @@ -63,8 +63,9 @@ val commonSettings = Seq( ) val commonJSSettings = Seq( - Test / parallelExecution := false, 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" @@ -84,7 +85,6 @@ lazy val root = project.in(file(".")) "com.lihaoyi" %%% "scalatags" % "0.8.6" % Test ), - Compile / npmDependencies += "jquery" -> "3.3.1", - jsDependencies += "org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js", - Test / requireJsDomEnv := true + Compile / npmDependencies += "jquery" -> "3.4.1", + jsDependencies += "org.webjars" % "jquery" % "3.4.1" / "3.4.1/jquery.js", ) diff --git a/project/build.properties b/project/build.properties index c9c5a37..ef622e7 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.3.8 \ No newline at end of file +sbt.version=1.3.9 \ No newline at end of file From 588df79e92319e358379a3a18c0f13b66f597de9 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 26 Aug 2021 09:13:56 +0200 Subject: [PATCH 32/44] Dependency upgrades --- .gitignore | 3 ++- build.sbt | 17 ++++++++--------- project/build.properties | 2 +- project/plugins.sbt | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) 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/build.sbt b/build.sbt index 8482c85..36f6d3c 100644 --- a/build.sbt +++ b/build.sbt @@ -7,8 +7,8 @@ inThisBuild(Seq( )) val commonSettings = Seq( - scalaVersion := "2.13.1", - crossScalaVersions := Seq("2.12.11", "2.13.1"), + scalaVersion := "2.13.6", + crossScalaVersions := Seq("2.13.6", "2.12.14"), scalacOptions ++= Seq( "-feature", "-deprecation", @@ -19,15 +19,14 @@ val commonSettings = Seq( "-language:postfixOps", "-language:experimental.macros", "-Xfatal-warnings", - "-Xlint:_", - "-Ywarn-unused:_,-explicits,-implicits", - "-Ybackend-parallelism", "4", + "-Xlint:_,-missing-interpolator,-unused", + "-Yrangepos", + "-Ybackend-parallelism", "8", "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", ), autoAPIMappings := true, publishMavenStyle := true, - publishArtifact in Test := false, pomIncludeRepository := { _ => false }, publishTo := sonatypePublishToBundle.value, @@ -80,9 +79,9 @@ lazy val root = project.in(file(".")) commonJSSettings, libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "0.9.8", - "org.scalatest" %%% "scalatest" % "3.1.1" % Test, - "com.lihaoyi" %%% "scalatags" % "0.8.6" % Test + "org.scala-js" %%% "scalajs-dom" % "1.2.0", + "org.scalatest" %%% "scalatest" % "3.2.9" % Test, + "com.lihaoyi" %%% "scalatags" % "0.9.4" % Test ), Compile / npmDependencies += "jquery" -> "3.4.1", diff --git a/project/build.properties b/project/build.properties index ef622e7..e9db047 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.3.9 \ No newline at end of file +sbt.version=1.5.5 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 84c42cf..fa81d0b 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,9 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") -addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") +addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") // Deployment configuration -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1") \ No newline at end of file +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10") \ No newline at end of file From 8a1d6dd0340665efa16d93d0c41b545d44594c8d Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 26 Aug 2021 09:48:18 +0200 Subject: [PATCH 33/44] Initial setup for GitHub Actions --- .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 37 ---------------- 2 files changed, 91 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a13e3a --- /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.12.14, 2.13.6 ] + 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/.travis.yml b/.travis.yml deleted file mode 100644 index d996112..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -dist: trusty -language: scala -jdk: openjdk11 -scala: - - 2.13.1 - -jobs: - include: - - stage: test - if: NOT tag =~ ^v - script: - - sbt +test +publishLocal - - cd example && sbt +compileStatics - - stage: release - if: tag =~ ^v - script: - - openssl aes-256-cbc -K $encrypted_f00a6d0a0202_key -iv $encrypted_f00a6d0a0202_iv - -in travis/travis.gpg.enc -out travis/travis.gpg -d - - gpg --import travis/travis.gpg - - test $TRAVIS_PULL_REQUEST = "false" && sbt +publishSigned sonatypeBundleRelease - -before_cache: - - rm -fv $HOME/.ivy2/.sbt.ivy.lock - - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete - - find $HOME/.sbt -name "*.lock" -print -delete - -cache: - directories: - - "$HOME/.ivy2/cache" - - "$HOME/.m2" - - "$HOME/.cache" - - "$HOME/.sbt" - -env: - global: - - secure: rG9cHG3au9EUYQSJKHAsMxws3IW/tSxG1Y/xbuW2Ri1JVr6L6c9ig8gYj4Hju5KkVvxXejb1/8bYCoZEP1vZpNeSkNordHECp0l+i9mI5ZFo5RN3vMCq4/0xWEQTdZ7c3BjN+pn4veDJ+W8cHFXgivC9tsX7FEbksz4bFVIm1knvz5r7HN4ntgQUeLwY/J9EpKSr/TYZsnEcf8aH9q6tvTLqcfYAR6ggs68Kc2qJ5sII0rj3vP2NANjTLuvdkPSe3i/9KCDRDr9KIoVsam4LfFDG8YXSNWBP3OQU86DF19V0brt6WGGX6G5V2dyjlHyyUy0GBFJOlPmfkEL8ylOprGy1OPw40ZPRbtzpbztFlVmgJoO3UcKIWlyB8umz0M9A+E3Of3P9mTnskAe366VPSq8R/G3kxc7ictZDQH7hgf2nKqlFQNXCJkBqynWRlC0HQ31izrACqNmmYdwQspUnAFVOEFSmfXu8sPVyOSQhHT4IG+xgG4KCKdC8Cv4buOFDzj4z0DRnfJwR71KvxA9KGhUtMZXXqfdZANThHMV1bsi3S3UPQKqRg62aja4+I7lzbwrPRbkDPsl0eTdULF39jIMnbfjC2TqeCgfG+tpel0DBMBOuuESvTVFVX38HSgK1QNhSAAu1nrVIFtZQbKDZLOm7hCgfOJO6v65R3PgIFFI= - - secure: wjX1uXAYdNxpUr1nz9cQ96cgJI3wUqJ7hIQlHwtg1gLJJtgdf6STSTbAm1IKMb0Ouytc2muC1H8jhBbv94tyZh2/NI7IDk7OY2wcLobH2Jh/wnDEAAcATIhqR/oFtSdqr0umr1HDevUPIBU/ZFViCPribnCQ/Rxn8jttguGd3Ho1k1dxzJ9pEiET66nU8CnW0j8g1Nkg540xFPff0Q+1C7+3akU03KwLnh8C0KR1oGhT354IhocLtFKWPuD9GTXAiA6qcOZ0cmUlv8jwHhWyJ6dmVkOlv873nGPrFaWEDPepNkGaAz2TYjkeFS0YS8q1zbd7YM0opnQd8TJCnFddyzc09+1d5RMAJVWdKOKVjrbDwvKaNWfEHW6GXJ83xm8cbo3dCREfL7UTKjejkQTRgmj2BdrZVRB9xs+XKZpZi0ECVbIrwik9tyYoiuSHe96yNN3Ma56Q4x094ZTvsccjy7pET4FCpNwrFu0aD+HFPerWB/xlr9ILz7sWy99r4eafS+O2eidoQnPIHAHZ+z/k9ExQedKUzTxO/skgrf1FvswrY7cpfnNApOhCSKm8C5NfMB5BC7M7OsYqDIhIwfs/Q3J9gw18F4fa9czpnduVzkpQUGdZ2vtS+oxDGICB7uaxkRq7HudHHElhz4w9qEOIMpTJjICPa38Hr/fKGxpuhKE= \ No newline at end of file From 03b18206f9df4b371608f3beaa0a82b749f21eac Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 26 Aug 2021 16:02:13 +0200 Subject: [PATCH 34/44] Deployment configuration cleanup --- build.sbt | 31 +++++++++++++++++-------------- travis/travis.gpg.enc | Bin 3712 -> 0 bytes 2 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 travis/travis.gpg.enc diff --git a/build.sbt b/build.sbt index 36f6d3c..aa79099 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,8 @@ name := "udash-jquery" inThisBuild(Seq( - version := sys.env.get("TRAVIS_TAG").filter(_.startsWith("v")).map(_.drop(1)).getOrElse("3.0.0-SNAPSHOT"), + version := "3.1.0-SNAPSHOT", organization := "io.udash", - cancelable := true, )) val commonSettings = Seq( @@ -25,8 +24,22 @@ val commonSettings = Seq( "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", ), - autoAPIMappings := true, +) + +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}/" + }, +) + +val deploymentConfiguration = Seq( publishMavenStyle := true, + Test / publishArtifact := false, pomIncludeRepository := { _ => false }, publishTo := sonatypePublishToBundle.value, @@ -61,22 +74,12 @@ val commonSettings = Seq( } ) -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}/" - }, -) - lazy val root = project.in(file(".")) .enablePlugins(ScalaJSBundlerPlugin, JSDependenciesPlugin) .settings( commonSettings, commonJSSettings, + deploymentConfiguration, libraryDependencies ++= Seq( "org.scala-js" %%% "scalajs-dom" % "1.2.0", diff --git a/travis/travis.gpg.enc b/travis/travis.gpg.enc deleted file mode 100644 index 399e4773eceb781b839288110f4eb79b00f9e135..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3712 zcmV-`4uA2*H7koBJ8%!iZTWF$!{Z-QD*oRFDW;sl!QySp%&UtFSA@?)Ezh1<@e zau_=SuvL!Tpo3ELmII4Skngn(thtLkE10yq{iZL40@L~09np95yr5&jcTVrKD)X?Y znm1{n@xL*E`PILmVck}3W>@|MDj@^jf}mWr%F4P~U7VGCHRmI`idtw5J;$7yMp&AO zavvK2s?cc4f>NLgrFY?~KuMF|p+(OyvDq%^W*~{JTLk{p*mm6xqw^L9hKo}`PKc@0 z;AUAm{+EI@tpCfJH<0rFh`+-=UC}mJ6D!XH_b{#wcA?MAyC(*|pkyaj&oqBdKJts3JBd~|LY zZZK>1#9%&WoE$Wo0qA5`$r>}EPv3}h-+Gp|*<}s%<`PZ(w97t8_>G^-90o!?w$|wP zCSlq2LIfA@l&41CpWAc5b=JO=ghqUnq3!swPRh88^gf;vE#oN$JZ3KXZ zNHpfpMlC;E*=;zM+i)6bxor0lzUBW9$+`Qpq&_i3yypiKVaT5ISY(Q?>E*VE51(;F zjmE!)REd@<8!-(VLGfy}+z`#6$5)ano{e2?0UjDLuE>0&;()S%TL zZYo4aw5JAt*R{&A(Ub?T@4}25qn*5)bw2frbfnt^r}oxjj$9Im@;IQ2fv~(Yc1I{} zMZrPD`g=+}{7Xdo!s(=kU;L>t{p00{2Se7ifba3O1z%prX>K0nHl<9pw;H(g&b9TH zcA-5o`2mVT>9e!HDj|Vh>R<5DHx{m_6 zGkoa2wop$_O1omwPhS6}!c8l7iO4o!MgkbdvMu?x%T;KqIgLfOMGb52t@r&;;}Rv^ zWT))87nG!F8N5J9;qE^2mmXKF5jjWU$cZ;$FfZs(VMq-|C)LXSbC3zReacAfk`GZh zmTMZq`ZGvvr5`=MXvwj~-0~p**IW>JB`0cFTH$jvd;!V5wKU^PZS08i(TO=Qn@39& zRl0$pVuG&G3@ZH0awpKaLbKut>}lyXrbkScE#LWf;Nt6VN|SP0SEa>1LVr*Y`Vuv! z7XtKS@HY&pRas*3bG*e4{+c4}M|y+%36v4{AK;MF{bP8G**HF96L=gRH?|{q#=QVT z72^G(`XBprjiIpeStxIaPDR;?#gB8lDLa?q++pv=q4quk15|C#f^TT;PdOZ zF42&DE5IAaGd4%`Z38S)JC>A?1X{!0rw7_UpeCysKr#53NJC*f|KOtul-yUqP7;c7 zCLaAow$MfDU!&!0hhPla zc-N({E}Fy+SCx9!2XyVqc&R1%fjI8Vz{&P!u!n4g^=phbw%o6SIbgo8NIh7QH%=kj?IfPMAu?G3XL1Rzj zFC4ZCv^fFY7JZ&kf_G`Uow$-Jb7^oY-cy8U+W5EhgI0C5sO>1%9vS_ER%ayC%k~?9 zb>s1ccf9i>G$SnzS}UnM==BH)fk!<)Fo$PzuXL5JR zHE54^B+S7ZljvVLQ;ILWemRf9k~O2c)AG?u#o!GLtY42OVJ-HUjHM|+_T9iSa!-pc zlIJ&QqadZASpI>UThjcM)_2ObgYP*<82*{YT4`|g({a@lr^Vw}zQy55?63Pxoc~rK z;r&^J%D`+dzgR%9MVU9Ae6r_%Ud+nI+`+#~#n6mHF%Bo+>5fd~njY;4H(FJzHM%qx zHEjHr>>n7>${W0-Df>mzKdEuuN{U!f_4I-1T)?oDe<7u00*UMFX93u32aOWBcx~36 zyeQ7S3m=RVv>+@jU8e?kNrinG`zqbj{31w?@LTd*)vXv9uZEvwfL`gr{1j8*8UR}b zz4wQWp>11}VRNe<<7knD4$nv=M(MAUIG_gVX1B1hPhOaxRjml;i1W_Zb~A2qc5e*j zJSyn0ktIbs4W0w4<18QdCSbgZY$rfjwQ;U<5M7w7%trfcd(xbj9atipn%W*cGeStv zhvi?IQj(7J z^b1;k_M*vFg=x-528fO(Tsm@W5hAbAtBNyQrWv#X6E~-R5AcFds20Cu_6?6^z66$> zR_>K+$AIMF!s{6mZ6Th88=2xL!4G7sdjxgegRik2qStjg#Q#{w7os;eyx%(wBWO*G zeSf|Sa4SrV=DY|^MHLwe`r0_(?^7j1FRn?Iat661Yke!%UQ%3szH1YZWZk1zP#ny;B<#2>fpTqfTMsz!-B~iRHR_b ziRh3yVt(#UH@~`A=|GzuP}$ZF02ULInaEhRbos`W**%oxW{8!pyKJBn9?v(N(Du=6 zRqV2tUtwsXqrZZd_*;xX#-8RL{;oMmJ1~k}I}4n-LIH@#Dm!-D!5Y{<>w7wjksc4V z{DTB-GP3TqU7n;-E|}vuWm-Uk*^QeUHnuLe z)Vf4y$Q^I*Fhd>vH0`VLhlq>{65S;(=G+Afs5q5|XMCF9e;s5O?;~?tC@55S=tx+< z+nE0*r^8)P%GG}%H3Hf%o;Uf4Cd<~4t*Hf%b@Qn29=Hh zr}sv?`Zha8$kzBdtF>0eYl)iJu%eWB<%z#^LqDQE-7!(*5DbQ9L#9{g(3`3mWsM`D zmL6Xl1;`l;6t}s0fF{BbI7&h~awIIz?{kCiV|k`2-{~KoMv9lMVvJ|quHdDre(-kd z(*ECRT?<^KyR_z?jJk-*0=DFGOD}=SLB}!XD z!*z$WIhhzQBcE1G`qFs!y7TiOxYTgb8A;F>>p95%d`)l;>${2pDr4gG_9(Yt^8>PZ zkpr$G0cCT~=Qk0{n15)@@Wczb^S>0%mFdtcq8FsOas8}zXc9f9+M(gytG1G$pd4tf z%g}j@3})aX(2l*iZSc#5)+6Jr1U{!xj5`HZ&={WRV;Yh#pwG`6j~rSXRB8$8{Wkz0 zu{#wTje{bcAN+v*n(NEpq)@|<^2suf>@U|<=%sDFM;04N6aM$EVGnh<6^*yJMS879 zW=_n%=LKjryk2g2)CHGN?Ava7qb7<6>w= e*PLdv@dpma`3t##6ry)fh1I!P_X>&~CqX&^>Q6HO From a2f351108716c2aa31485950fe274df387a48bb4 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Thu, 26 Aug 2021 16:06:57 +0200 Subject: [PATCH 35/44] Update badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88ff328..32fdc79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # udash-jquery [](http://www.avsystem.com/) -[![Build Status](https://travis-ci.org/UdashFramework/scala-js-jquery.svg?branch=master)](https://travis-ci.org/UdashFramework/scala-js-jquery) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.udash/udash-jquery_sjs1_2.12) +![Build Status](https://github.com/UdashFramework/scala-js-jquery.svg/workflows/CI/badge.svg?branch=master&event=push) +[![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. From fdc903611d997315b833c39829562d789c6112ba Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Fri, 27 Aug 2021 07:00:18 +0200 Subject: [PATCH 36/44] scalac flag cleanup --- build.sbt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index aa79099..b04eb23 100644 --- a/build.sbt +++ b/build.sbt @@ -15,11 +15,9 @@ val commonSettings = Seq( "-language:implicitConversions", "-language:existentials", "-language:dynamics", - "-language:postfixOps", "-language:experimental.macros", "-Xfatal-warnings", - "-Xlint:_,-missing-interpolator,-unused", - "-Yrangepos", + "-Xlint:_", "-Ybackend-parallelism", "8", "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", From ddce161cd80a53acefdf3c118f14cc3fb7136286 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Fri, 27 Aug 2021 12:58:44 +0200 Subject: [PATCH 37/44] Add minified resource hint --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index b04eb23..b3d46ed 100644 --- a/build.sbt +++ b/build.sbt @@ -86,5 +86,5 @@ lazy val root = project.in(file(".")) ), Compile / npmDependencies += "jquery" -> "3.4.1", - jsDependencies += "org.webjars" % "jquery" % "3.4.1" / "3.4.1/jquery.js", + jsDependencies += "org.webjars" % "jquery" % "3.4.1" / "3.4.1/jquery.js" minified s"3.4.1/jquery.min.js", ) From 737770afc8394da272da29d457c4fe7bc8a8938a Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Mon, 25 Oct 2021 15:30:06 +0200 Subject: [PATCH 38/44] Update scalajs-dom, scalatags --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index b3d46ed..10d98a6 100644 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ inThisBuild(Seq( val commonSettings = Seq( scalaVersion := "2.13.6", - crossScalaVersions := Seq("2.13.6", "2.12.14"), + crossScalaVersions := Seq("2.13.6", "2.12.15"), scalacOptions ++= Seq( "-feature", "-deprecation", @@ -80,9 +80,9 @@ lazy val root = project.in(file(".")) deploymentConfiguration, libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "1.2.0", + "org.scala-js" %%% "scalajs-dom" % "2.0.0", "org.scalatest" %%% "scalatest" % "3.2.9" % Test, - "com.lihaoyi" %%% "scalatags" % "0.9.4" % Test + "com.lihaoyi" %%% "scalatags" % "0.10.0" % Test ), Compile / npmDependencies += "jquery" -> "3.4.1", From 7386128b79e8225218bce56855dede8c9a6f4952 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Mon, 25 Oct 2021 15:30:14 +0200 Subject: [PATCH 39/44] 3.1.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 10d98a6..4c67a0f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := "udash-jquery" inThisBuild(Seq( - version := "3.1.0-SNAPSHOT", + version := "3.1.0", organization := "io.udash", )) From e8317fba092bab0e07db475986dea55fbae20458 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Mon, 25 Oct 2021 16:11:44 +0200 Subject: [PATCH 40/44] 3.2.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4c67a0f..f00c61c 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := "udash-jquery" inThisBuild(Seq( - version := "3.1.0", + version := "3.2.0", organization := "io.udash", )) From 6d8ee18f015a3ebceee5363443b6e58d64f1a4e3 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Mon, 25 Oct 2021 16:12:15 +0200 Subject: [PATCH 41/44] Towards 3.3.0 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f00c61c..5259e63 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ name := "udash-jquery" inThisBuild(Seq( - version := "3.2.0", + version := "3.3.0-SNAPSHOT", organization := "io.udash", )) From ad6342a6c5954618a93d47b2aad3d9699e097998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= <64359735+halotukozak@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:38:00 +0200 Subject: [PATCH 42/44] upgrade jQuery to 3.6.4 (#33) * upgrade jQuery to 3.6.4 due to CVE-2020-11022, CVE-2020-23064, CVE-2020-11023 vulnerabilities * upgrade scalaJs, add jQuery methods * upgrade webpack to 5.75.0 * move webpack version declaration * add "even/odd matching element" test case * refactor test * refactor test --- README.md | 2 +- build.sbt | 7 ++++--- project/build.properties | 2 +- project/plugins.sbt | 4 ++-- .../scala/io/udash/wrappers/jquery/JQuery.scala | 8 ++++++++ .../wrappers/jquery_test/TraversingTest.scala | 16 ++++++++++++++++ 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 32fdc79..b794ab8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) program Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "3.0.4" +libraryDependencies += "io.udash" %%% "udash-jquery" % "3.2.0" ``` then import the jQuery package: diff --git a/build.sbt b/build.sbt index 5259e63..6d600cf 100644 --- a/build.sbt +++ b/build.sbt @@ -33,6 +33,7 @@ val commonJSSettings = Seq( 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 ) val deploymentConfiguration = Seq( @@ -80,11 +81,11 @@ lazy val root = project.in(file(".")) deploymentConfiguration, libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "2.0.0", + "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.4.1", - jsDependencies += "org.webjars" % "jquery" % "3.4.1" / "3.4.1/jquery.js" minified s"3.4.1/jquery.min.js", + 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/project/build.properties b/project/build.properties index e9db047..657d488 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.5.5 \ No newline at end of file +sbt.version=1.9.2 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index fa81d0b..6e5469d 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") // Deployment configuration diff --git a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala index 8218c5a..89f1be9 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala @@ -164,6 +164,10 @@ trait JQuery extends js.Object { @JSName("eq") def at(index: Int): 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 */ def fadeIn(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native @@ -381,6 +385,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def not(el: Element*): 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 */ def off(): JQuery = js.native 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 82116cf..2ff1b89 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -166,5 +166,21 @@ class TraversingTest extends AnyWordSpec 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" + } + } } From 4fd23a31e75c90bfbf4e6f5302e8f84a9c494244 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Wed, 4 Oct 2023 10:48:58 +0200 Subject: [PATCH 43/44] Prepare 3.3.0 release --- .github/workflows/ci.yml | 2 +- README.md | 6 +++--- build.sbt | 3 +-- project/build.properties | 2 +- project/plugins.sbt | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a13e3a..cf04a0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - scala: [ 2.12.14, 2.13.6 ] + scala: [ 2.13.12 ] command: [ test ] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index b794ab8..f5492de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # udash-jquery [](http://www.avsystem.com/) -![Build Status](https://github.com/UdashFramework/scala-js-jquery.svg/workflows/CI/badge.svg?branch=master&event=push) -[![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) + +[![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. @@ -10,7 +10,7 @@ Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) program Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "3.2.0" +libraryDependencies += "io.udash" %%% "udash-jquery" % "3.3.0" ``` then import the jQuery package: diff --git a/build.sbt b/build.sbt index 6d600cf..065d200 100644 --- a/build.sbt +++ b/build.sbt @@ -6,8 +6,7 @@ inThisBuild(Seq( )) val commonSettings = Seq( - scalaVersion := "2.13.6", - crossScalaVersions := Seq("2.13.6", "2.12.15"), + scalaVersion := "2.13.12", scalacOptions ++= Seq( "-feature", "-deprecation", diff --git a/project/build.properties b/project/build.properties index 657d488..ff95dc2 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.9.2 \ No newline at end of file +sbt.version=1.9.6 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 6e5469d..fa4a47a 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2") +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") From 63403d665b56e4f08f6a1dc2d07b78ff8cf165a4 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Wed, 4 Oct 2023 10:54:21 +0200 Subject: [PATCH 44/44] Remove abandoned example project --- example/.gitignore | 132 ------------------ example/README.md | 13 -- example/build.sbt | 129 ----------------- .../bundler-demo/src/main/assets/index.html | 12 -- .../global-demo/src/main/assets/index.html | 13 -- example/project/Dependencies.scala | 12 -- example/project/build.properties | 2 - example/project/plugins.sbt | 5 - .../scala/io/udash/demos/jquery/Init.scala | 13 -- .../demos/jquery/views/FunctionView.scala | 24 ---- .../udash/demos/jquery/views/IndexView.scala | 30 ---- .../jquery/views/functions/AddBackView.scala | 48 ------- .../jquery/views/functions/AddView.scala | 44 ------ .../views/functions/AfterBeforeView.scala | 26 ---- .../jquery/views/functions/AnimateView.scala | 73 ---------- .../views/functions/AppendPrependView.scala | 22 --- .../jquery/views/functions/AttrView.scala | 49 ------- .../views/functions/CallbacksView.scala | 47 ------- .../jquery/views/functions/ChildrenView.scala | 26 ---- .../jquery/views/functions/DataView.scala | 27 ---- .../jquery/views/functions/DeferredView.scala | 52 ------- .../jquery/views/functions/EachView.scala | 24 ---- .../jquery/views/functions/HideShowView.scala | 24 ---- .../views/functions/OffsetPositionView.scala | 30 ---- .../jquery/views/functions/OnOneOffView.scala | 42 ------ 25 files changed, 919 deletions(-) delete mode 100644 example/.gitignore delete mode 100644 example/README.md delete mode 100644 example/build.sbt delete mode 100644 example/bundler-demo/src/main/assets/index.html delete mode 100644 example/global-demo/src/main/assets/index.html delete mode 100644 example/project/Dependencies.scala delete mode 100644 example/project/build.properties delete mode 100644 example/project/plugins.sbt delete mode 100644 example/src/main/scala/io/udash/demos/jquery/Init.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala delete mode 100644 example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala 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/README.md b/example/README.md deleted file mode 100644 index ea8efda..0000000 --- a/example/README.md +++ /dev/null @@ -1,13 +0,0 @@ -The `build.sbt` file contains two configurations: -* `jquery-global-demo` uses global jQuery dependency. -* `jquery-bundler-demo` uses `ScalaJSBundlerPlugin` in order to manage module dependencies. - -### How to use? - -Run `sbt jquery-global-demo/fastOptJS` or `sbt jquery-global-demo/fullOptJS` to compile this demo. You can find all generated files -in the `generated/global` directory. Open `index.html` in your browser. - -### How to use? (ScalaJSBundlerPlugin) - -Run `sbt jquery-bundler-demo/compileStatics` to compile this demo. You can find all generated files -in the `generated/bundler` directory. Open `index.html` in your browser. \ No newline at end of file diff --git a/example/build.sbt b/example/build.sbt deleted file mode 100644 index 58ef253..0000000 --- a/example/build.sbt +++ /dev/null @@ -1,129 +0,0 @@ -name := "jquery-demo" - -inThisBuild(Seq( - version := "3.0.0-SNAPSHOT", - organization := "io.udash", -)) - -val commonSettings = Seq( - scalaVersion := "2.12.11", - crossScalaVersions := Seq("2.13.1"), - scalacOptions ++= Seq( - "-feature", - "-deprecation", - "-unchecked", - "-language:implicitConversions", - "-language:existentials", - "-language:dynamics", - "-language:postfixOps", - "-Xfatal-warnings", - "-Xlint:_", - "-Ywarn-unused:_,-explicits,-implicits", - "-Ybackend-parallelism", "4", - "-Ycache-plugin-class-loader:last-modified", - "-Ycache-macro-class-loader:last-modified" - ), - - libraryDependencies ++= Dependencies.deps.value -) - -val generatedGlobalDir = file("generated/global") -val compileStatics = taskKey[Unit]("Compiles all static files.") -val copyAssets = taskKey[Unit]("Copies all assets to the target directory.") - -lazy val root = project.in(file(".")) - .enablePlugins(ScalaJSPlugin) - .settings(commonSettings) - .aggregate(`jquery-bundler-demo`, `jquery-global-demo`) - -lazy val `jquery-global-demo` = project.in(file("global-demo")) - .enablePlugins(ScalaJSPlugin, JSDependenciesPlugin) - .settings( - commonSettings, - - sourceDirsSettings(_.getParentFile), - - cleanFiles += generatedGlobalDir, - - Compile / fullOptJS / crossTarget := generatedGlobalDir, - Compile / fastOptJS / crossTarget := generatedGlobalDir, - Compile / packageJSDependencies / crossTarget := generatedGlobalDir, - Compile / packageMinifiedJSDependencies / crossTarget := generatedGlobalDir, - - Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value, - Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value, - - scalaJSUseMainModuleInitializer := true, - - copyAssets := { - IO.copyFile( - sourceDirectory.value / "main/assets/index.html", - generatedGlobalDir / "index.html" - ) - }, - - compileStatics := (Compile / fastOptJS).value, - - Compile / fastOptJS / artifactPath := - (Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js", - Compile / fullOptJS / artifactPath := - (Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js", - Compile / packageJSDependencies / artifactPath := - (Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js", - Compile / packageMinifiedJSDependencies / artifactPath := - (Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js" - ) - -val generatedBundlerDir = file("generated/bundler") -lazy val `jquery-bundler-demo` = project.in(file("bundler-demo")) - .enablePlugins(ScalaJSBundlerPlugin) - .settings( - commonSettings, - - sourceDirsSettings(_.getParentFile), - - Compile / scalaJSUseMainModuleInitializer := true, - - copyAssets := { - IO.copyFile( - sourceDirectory.value / "main/assets/index.html", - generatedBundlerDir / "index.html" - ) - }, - - cleanFiles += generatedBundlerDir, - - compileStatics := { - val sjsFileName = (Compile / fastOptJS).value.data.name.stripSuffix(".js") - IO.copyFile( - (Compile / npmUpdate / crossTarget).value / s"$sjsFileName-bundle.js", - generatedBundlerDir / "scripts/frontend.js" - ) - IO.copyFile( - (Compile / npmUpdate / crossTarget).value / s"$sjsFileName-bundle.js.map", - generatedBundlerDir / "scripts/frontend.js.map" - ) - }, - compileStatics := compileStatics.dependsOn(Compile / fastOptJS / webpack, copyAssets).value, - ) - -def mkSourceDirs(base: File, scalaBinary: String, conf: String): Seq[File] = Seq( - base / "src" / conf / "scala", - base / "src" / conf / s"scala-$scalaBinary", - base / "src" / conf / "java" -) - -def mkResourceDirs(base: File, conf: String): Seq[File] = Seq( - base / "src" / conf / "resources" -) - -def sourceDirsSettings(baseMapper: File => File) = Seq( - Compile / unmanagedSourceDirectories ++= - mkSourceDirs(baseMapper(baseDirectory.value), scalaBinaryVersion.value, "main"), - Compile / unmanagedResourceDirectories ++= - mkResourceDirs(baseMapper(baseDirectory.value), "main"), - Test / unmanagedSourceDirectories ++= - mkSourceDirs(baseMapper(baseDirectory.value), scalaBinaryVersion.value, "test"), - Test / unmanagedResourceDirectories ++= - mkResourceDirs(baseMapper(baseDirectory.value), "test"), -) \ No newline at end of file diff --git a/example/bundler-demo/src/main/assets/index.html b/example/bundler-demo/src/main/assets/index.html deleted file mode 100644 index 45d07e6..0000000 --- a/example/bundler-demo/src/main/assets/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - jquery-demo - ScalaJSBundlerPlugin demo - - -
- - - - \ No newline at end of file diff --git a/example/global-demo/src/main/assets/index.html b/example/global-demo/src/main/assets/index.html deleted file mode 100644 index b746eab..0000000 --- a/example/global-demo/src/main/assets/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - jquery-demo - global scope - - -
- - - - - \ No newline at end of file diff --git a/example/project/Dependencies.scala b/example/project/Dependencies.scala deleted file mode 100644 index a21498f..0000000 --- a/example/project/Dependencies.scala +++ /dev/null @@ -1,12 +0,0 @@ -import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ -import sbt._ - -object Dependencies { - val scalatagsVersion = "0.8.6" - val udashJQueryVersion = "3.0.0-SNAPSHOT" - - val deps = Def.setting(Seq[ModuleID]( - "com.lihaoyi" %%% "scalatags" % scalatagsVersion, - "io.udash" %%% "udash-jquery" % udashJQueryVersion - )) -} \ No newline at end of file diff --git a/example/project/build.properties b/example/project/build.properties deleted file mode 100644 index c9c5a37..0000000 --- a/example/project/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -# suppress inspection "UnusedProperty" -sbt.version=1.3.8 \ No newline at end of file diff --git a/example/project/plugins.sbt b/example/project/plugins.sbt deleted file mode 100644 index 17a23aa..0000000 --- a/example/project/plugins.sbt +++ /dev/null @@ -1,5 +0,0 @@ -logLevel := Level.Warn - -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.17.0") -addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.0") \ 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 a1f296e..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/Init.scala +++ /dev/null @@ -1,13 +0,0 @@ -package io.udash.demos.jquery - -import io.udash.demos.jquery.views.IndexView -import org.scalajs.dom - -import scala.scalajs.js.annotation.JSExport - -object Init { - - @JSExport - def main(args: Array[String]): Unit = - dom.document.querySelector("#application").appendChild(IndexView.content.render) -} \ 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 e3c7360..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala +++ /dev/null @@ -1,24 +0,0 @@ -package io.udash.demos.jquery.views - -import org.scalajs.dom.{Element, Event} - -abstract class FunctionView { - - import scalatags.JsDom.all._ - - protected val content: Element - - protected def script: () => Any - - final def getTemplate: Modifier = - div( - content, - h3(button( - marginTop := 10.px, - 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 0a1e7e2..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/IndexView.scala +++ /dev/null @@ -1,30 +0,0 @@ -package io.udash.demos.jquery.views - -import io.udash.demos.jquery.views.functions._ - -object IndexView { - - import scalatags.JsDom.all._ - - private val demos = Seq( - AddBackView, - AddView, - AfterBeforeView, - AnimateView, - AppendPrependView, - AttrView, - CallbacksView, - ChildrenView, - DataView, - DeferredView, - EachView, - HideShowView, - OffsetPositionView, - OnOneOffView, - ) - - final val content = div( - "Take a look at following demos:", - demos.map(demo => Seq(hr, div(demo.getTemplate))), - ) -} \ 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 3927a6b..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddBackView.scala +++ /dev/null @@ -1,48 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import scalatags.JsDom.tags2 - -/** Based on examples from: jQuery Docs. */ -object AddBackView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div(cls := "addback")( - h3(".addBack() & .addClass()"), - tags2.style( - """ - |.addback .border { - | border: 2px solid red; - |} - |.addback .background { - | background: yellow; - |}""".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 def script = () => { - jQ("div.left, div.right", content).find("div, div > p").addClass("border") - - // First Example - jQ("div.before-addback", content).find("p").addClass("background") - - // Second Example - jQ("div.after-addback", content).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 45c65f1..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AddView.scala +++ /dev/null @@ -1,44 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import scalatags.JsDom.tags2 - -/** Based on examples from: jQuery Docs. */ -object AddView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div(cls := "addview")( - h3(".add() & .css()"), - tags2.style( - """.addview div { - | width: 60px; - | height: 60px; - | margin: 10px; - | float: left; - |} - |.addview 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 def script = () => { - jQ("div", content).css("border", "2px solid red") - .add("p", content) - .css("background", "yellow") - } -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala deleted file mode 100644 index 3aaf39d..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AfterBeforeView.scala +++ /dev/null @@ -1,26 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object AfterBeforeView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".after()"), - div( - p(cls := "after")("I would like to say: ") - ), - h3(".before()"), - div( - p(cls := "before")("is what I said...") - ) - ).render - - override protected def script = () => { - jQ(".after", content).after("Hello") - jQ(".before", content).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 445631d..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AnimateView.scala +++ /dev/null @@ -1,73 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.Element -import scalatags.JsDom.tags2 - -/** Based on examples from: jQuery Docs. */ -object AnimateView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div(cls := "animate")( - h3(".animate() & .click()"), - tags2.style( - """.animate div { - | background-color: #bca; - | width: 200px; - | height: 1.1em; - | text-align: center; - | border: 2px solid green; - | margin: 3px; - | font-size: 14px; - |} - |.animate 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 def script = () => { - jQ("#go1", content).on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#block1", content) - .animate(Map( - "width" -> "90%" - ), AnimationOptions( - queue = Some(false), - duration = Some(3000) - )) - .animate(Map("fontSize" -> "24px"), 1500) - .animate(Map("borderRightWidth" -> "15px"), 1500) - }) - - jQ("#go2", content).on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#block2", content) - .animate(Map("width" -> "90%"), 1000) - .animate(Map("fontSize" -> "24px"), 1000) - .animate(Map("borderLeftWidth" -> "15px"), 1000) - }) - - jQ("#go3", content).on(EventName.click, (_: Element, _: JQueryEvent) => { - jQ("#go1", content).add("#go2", content).trigger("click") - }) - - jQ("#go4", content).on(EventName.click, (_: Element, _: JQueryEvent) => { - // TODO: It does not work without explicit Map elements type - import scala.scalajs.js.`|` - jQ("div", content).css(Map[String, String | Int | Double | Boolean]( - "width" -> "", - "fontSize" -> "", - "borderWidth" -> "" - )) - }) - - jQ("button", content).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 b5d2d81..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AppendPrependView.scala +++ /dev/null @@ -1,22 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object AppendPrependView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".append()"), - p(id := "append")("I would like to say: "), - h3(".prepend()"), - p(id := "prepend")("amigo!") - ).render - - override protected def script = () => { - jQ("#append", content).append("hello") - jQ("#prepend", content).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 0c6f2be..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/AttrView.scala +++ /dev/null @@ -1,49 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.html.Div -import org.scalajs.dom.{Element, Event} - -/** Based on examples from: jQuery Docs. */ -object AttrView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content: Div = div( - h3(".attr() & .prop()"), - input(id := "check1", tpe := "checkbox", checked := "checked"), - label(`for` := "check1")("Check me"), - p(), - button(onclick := ((_: Event) => { - jQ("input", content).attr("data-checked", "checked").trigger("change") - false - }))(".attr(\"data-checked\", \"checked\")"), - button(onclick := ((_: Event) => { - jQ("input", content).attr("data-checked", "").trigger("change") - false - }))(".attr(\"data-checked\", \"\")"), - button(onclick := ((_: Event) => { - jQ("input", content).attr("data-checked", null).trigger("change") - false - }))(".attr(\"data-checked\", null)"), br(), - button(onclick := ((_: Event) => { - jQ("input", content).prop("checked", true).trigger("change") - false - }))(".prop(\"checked\", true)"), - button(onclick := ((_: Event) => { - jQ("input", content).prop("checked", false).trigger("change") - false - }))(".prop(\"checked\", false)") - ).render - - override protected def script = () => { - jQ("input", content).on(EventName.change, (input: Element, _: JQueryEvent) => { - jQ("p", content).html( - s""".attr('data-checked'): ${jQ(input).attr("data-checked")}
- |.prop('checked'): ${jQ(input).prop("checked")}
- |.is(':checked'): ${jQ(input).is(":checked")}""".stripMargin - ) - }).trigger("change") - } -} \ No newline at end of file diff --git a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala b/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala deleted file mode 100644 index a7a8243..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/CallbacksView.scala +++ /dev/null @@ -1,47 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -import scala.scalajs.js - -/** Based on examples from: jQuery Docs. */ -object CallbacksView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3("Callbacks"), - ul(id := "plus"), - ul(id := "minus"), - ul(id := "mul"), - ul(id := "div") - ).render - - override protected def script = () => { - val callbacks = jQ.callbacks[js.Function1[(Int, Int), js.Any], (Int, Int)]() - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#plus", content).append(li(s"$a + $b = ${a + b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#minus", content).append(li(s"$a - $b = ${a - b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#mul", content).append(li(s"$a * $b = ${a * b}").render) - }) - callbacks.add((t: (Int, Int)) => { - val (a, b) = t - jQ("#div", content).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 7043bc8..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/ChildrenView.scala +++ /dev/null @@ -1,26 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object ChildrenView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".children()"), - div( - span("Hello"), - p(cls := "selected")("Hello again"), - div(cls := "selected")("and again"), - p("and one last time.") - ) - ).render - - override protected def script = () => { - jQ("div", content).children().css("color", "blue") - jQ("div", content).children(".selected").css("border-bottom", "3px double red") - jQ("div", content).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 ad3f660..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DataView.scala +++ /dev/null @@ -1,27 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object DataView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".data()"), - div( - "The values stored were ", - span("_"), - " and ", - span("_") - ) - ).render - - override protected def script = () => { - jQ("div", content).data("test", Map("first" -> 16, "last" -> "pizza!")) - val data: Map[String, Any] = jQ("div", content).data("test").get.asInstanceOf[Map[String, Any]] - jQ("div span:first", content).text(data.get("first").get.toString) - jQ("div span:last", content).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 ae31443..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/DeferredView.scala +++ /dev/null @@ -1,52 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.Event - -import scala.scalajs.js - -/** Based on examples from: jQuery Docs. */ -object DeferredView extends FunctionView { - - import scalatags.JsDom.all._ - - var deferred: JQueryDeferred[js.Function1[Int, js.Any], Int] = null - - override protected val content = div( - 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 def script = () => { - jQ("button", content).prop("disabled", "") - deferred = jQ.deferred[js.Function1[Int, js.Any], Int]() - jQ("#deferred", content).text(s"Waiting...") - deferred.done((i: Int) => jQ("#deferred", content).text(s"Done: $i")) - deferred.fail((i: Int) => jQ("#deferred", content).text(s"Fail: $i")) - deferred.progress((i: Int) => jQ("#deferred", content).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 0f5097a..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/EachView.scala +++ /dev/null @@ -1,24 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.Element - -/** Based on examples from: jQuery Docs. */ -object EachView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".each()"), - div("Click button"), - div("to iterate through"), - div("these divs.") - ).render - - override protected def script = () => { - jQ("div", content).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 7a1d137..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/HideShowView.scala +++ /dev/null @@ -1,24 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object HideShowView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - h3(".hide() & .show()"), - div("Click button to hide me") - ).render - - override protected def script = () => { - jQ("div", content) - .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 0796b29..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OffsetPositionView.scala +++ /dev/null @@ -1,30 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ - -/** Based on examples from: jQuery Docs. */ -object OffsetPositionView extends FunctionView { - - import scalatags.JsDom.all._ - - override protected val content = div( - 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 def script = () => { - val div = jQ("div", content) - val p = jQ("div p", content) - jQ("#results", content).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 368f69f..0000000 --- a/example/src/main/scala/io/udash/demos/jquery/views/functions/OnOneOffView.scala +++ /dev/null @@ -1,42 +0,0 @@ -package io.udash.demos.jquery.views.functions - -import io.udash.demos.jquery.views.FunctionView -import io.udash.wrappers.jquery._ -import org.scalajs.dom.html.Div -import org.scalajs.dom.{Element, Event} - -/** Based on examples from: jQuery Docs. */ -object OnOneOffView extends FunctionView { - - import scalatags.JsDom.all._ - - val onCallback = (_: Element, _: JQueryEvent) => - jQ("ul", content).append(li("This will be added on every click").render) - val oneCallback = (_: Element, _: JQueryEvent) => - jQ("ul", content).append(li("This will be added only once").render) - - override protected val content: Div = div( - h3(".on() & .one() & .off()"), - button(id := "click", disabled := "disabled")("Click me"), - ul(), - button( - id := "off", - disabled := "disabled", - onclick := ((_: Event) => { - jQ("#click", content) - .off(EventName.click, onCallback) - .off(EventName.click, oneCallback) - false - }) - )("Off") - ).render - - override protected def script = () => { - jQ("#click", content) - .on(EventName.click, onCallback) - .one(EventName.click, oneCallback) - - jQ("button", content) - .prop("disabled", "") - } -} \ No newline at end of file