Skip to content

Commit 6a73789

Browse files
committed
Udash-less views
1 parent 32bad57 commit 6a73789

24 files changed

+117
-291
lines changed

example/global-demo/src/main/assets/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5-
<title>jquery-demo - ScalaJSBundlerPlugin demo</title>
5+
<title>jquery-demo - global scope</title>
66
</head>
77
<body>
88
<div id="application"></div>
99

10-
<script src="scripts/frontend.js"></script>
10+
<script src="scripts/frontend-impl.js"></script>
1111
<script src="scripts/frontend-deps.js"></script>
1212
</body>
1313
</html>

example/project/Dependencies.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
21
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
2+
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
33
import sbt._
44

55
object Dependencies {
6-
val udashCoreVersion = "0.8.3"
6+
val scalatagsVersion = "0.8.6"
77
val udashJQueryVersion = "3.0.2"
88

99
val deps = Def.setting(Seq[ModuleID](
10-
"io.udash" %%% "udash-core" % udashCoreVersion,
10+
"com.lihaoyi" %%% "scalatags" % scalatagsVersion,
1111
"io.udash" %%% "udash-jquery" % udashJQueryVersion
1212
))
1313

example/src/main/scala/io/udash/demos/jquery/init.scala renamed to example/src/main/scala/io/udash/demos/jquery/Init.scala

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
package io.udash.demos.jquery
22

3-
import io.udash._
43
import io.udash.wrappers.jquery._
54
import org.scalajs.dom
65
import org.scalajs.dom.Element
76

87
import scala.scalajs.js.annotation.JSExport
98

10-
object Context {
11-
implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue
12-
private val routingRegistry = new RoutingRegistryDef
13-
private val viewPresenterRegistry = new StatesToViewPresenterDef
14-
15-
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry)
16-
}
17-
189
object Init {
19-
import Context._
2010

2111
@JSExport
2212
def main(args: Array[String]): Unit = {
@@ -25,7 +15,7 @@ object Init {
2515
if (appRoot.isEmpty) {
2616
dom.console.error("Application root element not found! Check you index.html file!")
2717
} else {
28-
applicationInstance.run(appRoot.get)
18+
//applicationInstance.run(appRoot.get)
2919
}
3020
})
3121
}

example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala

Lines changed: 0 additions & 29 deletions
This file was deleted.

example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala

Lines changed: 0 additions & 27 deletions
This file was deleted.

example/src/main/scala/io/udash/demos/jquery/states.scala

Lines changed: 0 additions & 32 deletions
This file was deleted.

example/src/main/scala/io/udash/demos/jquery/views/ErrorView.scala

Lines changed: 0 additions & 13 deletions
This file was deleted.

example/src/main/scala/io/udash/demos/jquery/views/FunctionView.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package io.udash.demos.jquery.views
22

3-
import io.udash._
4-
import org.scalajs.dom.{Element, Event}
3+
import org.scalajs.dom.Event
4+
5+
abstract class FunctionView {
56

6-
abstract class FunctionView extends FinalView {
77
import scalatags.JsDom.all._
88

9-
protected val content: Element
10-
protected val script: () => Any
9+
protected def content: Modifier
10+
11+
protected def script: () => Any
1112

12-
override def getTemplate: Modifier =
13+
final def getTemplate: Modifier =
1314
div(
1415
content,
1516
button(
16-
onclick :+= ((_: Event) => {
17+
onclick := ((_: Event) => {
1718
script()
1819
false
1920
})
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
package io.udash.demos.jquery.views
22

3-
import io.udash._
4-
import io.udash.demos.jquery._
3+
import io.udash.demos.jquery.views.functions._
54

6-
object IndexViewPresenter extends StaticViewFactory[IndexState.type](() => new IndexView)
5+
object IndexView {
76

8-
class IndexView extends FinalView {
9-
import Context._
107
import scalatags.JsDom.all._
118

12-
private val content = div(
13-
"Take a look at following demo pages:",
14-
ul(
15-
li(a(href := AddState.url)(".add() & .css()")),
16-
li(a(href := AddBackState.url)(".addBack() & .addClass()")),
17-
li(a(href := AfterBeforeState.url)(".after() & .before()")),
18-
li(a(href := AnimateState.url)(".animate() & .click()")),
19-
li(a(href := AppendPrependState.url)(".append() & .prepend()")),
20-
li(a(href := AttrState.url)(".attr()")),
21-
li(a(href := CallbacksState.url)("Callbacks")),
22-
li(a(href := ChildrenState.url)(".children()")),
23-
li(a(href := DataState.url)(".data()")),
24-
li(a(href := DeferredState.url)("Deferred")),
25-
li(a(href := EachState.url)(".each()")),
26-
li(a(href := HideShowState.url)(".hide() & .show()")),
27-
li(a(href := OnOneOffState.url)(".on() & .one() & .off()")),
28-
li(a(href := OffsetPositionState.url)(".offset() & .position()"))
29-
)
9+
private val demos = Seq(
10+
AddBackView,
11+
AddView,
12+
AfterBeforeView,
13+
AnimateView,
14+
AppendPrependView,
15+
AttrView,
16+
CallbacksView,
17+
ChildrenView,
18+
DataView,
19+
DeferredView,
20+
EachView,
21+
HideShowView,
22+
OffsetPositionView,
23+
OnOneOffView,
3024
)
3125

32-
override def getTemplate: Modifier = content
26+
final val content = div(
27+
"Take a look at following demo pages:",
28+
demos.map(_.getTemplate),
29+
)
3330
}

example/src/main/scala/io/udash/demos/jquery/views/RootView.scala

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)