From 63403d665b56e4f08f6a1dc2d07b78ff8cf165a4 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Wed, 4 Oct 2023 10:54:21 +0200 Subject: [PATCH] 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