Skip to content

Commit

Permalink
Remodel Directive API
Browse files Browse the repository at this point in the history
* Closes #29
  • Loading branch information
jokade committed Feb 7, 2015
1 parent 9aabc95 commit caea181
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//import SonatypeKeys._
import SonatypeKeys._

lazy val commonSettings = Seq(
organization := "biz.enef",
Expand All @@ -14,7 +14,7 @@ lazy val root = project.in(file(".")).
enablePlugins(ScalaJSPlugin).
settings(commonSettings: _*).
settings(publishingSettings: _*).
//settings(sonatypeSettings: _*).
settings(sonatypeSettings: _*).
settings(
name := "scalajs-angulate",
libraryDependencies ++= Seq(
Expand All @@ -29,12 +29,13 @@ lazy val tests = project.
dependsOn(root).
enablePlugins(ScalaJSPlugin).
settings(commonSettings: _*).
settings(utest.jsrunner.Plugin.utestJsSettings: _*).
settings(
publish := {},
scalacOptions ++= angulateDebugFlags,
scalaJSStage := FastOptStage,
libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0",
testFrameworks += new TestFramework("utest.runner.Framework"),
//libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0",
//testFrameworks += new TestFramework("utest.runner.Framework"),
jsDependencies += RuntimeDOM,
jsDependencies += "org.webjars" % "angularjs" % "1.3.8" / "angular.min.js" % "test",
jsDependencies += "org.webjars" % "angularjs" % "1.3.8" / "angular-mocks.js" % "test"
Expand Down
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0")
//addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.0-RC2")

addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.5-RC1")
9 changes: 5 additions & 4 deletions src/main/scala/biz/enef/angular/Directive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ trait Directive {

def priority: Int = ???

def controller(ctrl: ControllerType, scope: Scope, elem: JQLite, attrs: Attributes) : Unit = ???
def controller(ctrl: ControllerType, scope: ScopeType, elem: JQLite, attrs: Attributes) : Unit = ???

//def controller(scope: js.Dynamic, elem: JQLite, attrs: Attributes) : Unit = ???
type ControllerType <: js.Object
type ControllerType <: js.Any
type ScopeType <: js.Any

def controllerAs: String = ???

Expand All @@ -35,8 +36,8 @@ trait Directive {
def scope: Boolean = ???
def isolateScope: js.Dictionary[String] = ???

def postLink(scope: Scope, element: JQLite, attrs: Attributes) : Unit = ???
def postLink(scope: Scope, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ???
def postLink(scope: ScopeType, element: JQLite, attrs: Attributes) : Unit = ???
def postLink(scope: ScopeType, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ???
//def preLink(scope: Scope, element: JQLite, attrs: Attributes, controller: js.Dynamic) : Unit = ???

def compile(tElement: js.Dynamic, tAttrs: Attributes) : js.Any = ???
Expand Down
17 changes: 10 additions & 7 deletions tests/src/test/scala/test/DirectiveTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ object DirectiveTest extends AngulateTestSuite {
val $compile = injection[js.Dynamic]("$compile")
val $rootScope = injection[Scope]("$rootScope")

val elem = $compile("""<directive3></directive3>""").apply(literal()).asInstanceOf[JQLite]
val elem = $compile("""<directive3 x="1"></directive3>""").apply(literal()).asInstanceOf[JQLite]
//$rootScope.$digest()
println( elem.head.textContent )
//println( elem.head.textContent )
}
}

Expand Down Expand Up @@ -77,15 +77,18 @@ object DirectiveTest extends AngulateTestSuite {

class Directive3 extends Directive {
override type ControllerType = Directive3Ctrl
override def controllerAs = "ctrl"
override val template = "ctrl.bar"

//override def isolateScope = js.Dictionary()
//override val controllerAs = "ctr"
override val template = "<div>x</div>"

override def isolateScope = js.Dictionary(
"x" -> "=x"
)
/*
override def controller(ctrl: ControllerType, scope: Scope, elem: JQLite, attrs: Attributes): Unit = {
println(ctrl)
ctrl.bar = "foo"
ctrl.click = () => ctrl.bar = "bar"
}
}*/
}
}

0 comments on commit caea181

Please sign in to comment.