Permalink
Browse files

Fix for #363

  • Loading branch information...
1 parent 9c65368 commit d35df8c0b139975a421367c26ef7c12f7acdca80 marius committed Feb 24, 2010
Oops, something went wrong.
@@ -150,14 +150,8 @@ object LiftRules extends Factory with FormVendor {
/**
* Holds the JS library specific UI artifacts. By efault it uses JQuery's artifacts
*/
- @volatile var jsArtifacts: JSArtifacts = JQueryArtifacts
+ @volatile var jsArtifacts: JSArtifacts = JQuery13Artifacts
- object JQueryVersion extends Enumeration("1.3.2", "1.4.1") {
- val v13, v14 = Value
- }
-
- @volatile var jQueryVersion: JQueryVersion.Value = JQueryVersion.v13
-
/**
* Use this PartialFunction to to automatically add static URL parameters
* to any URL reference from the markup of Ajax request.
@@ -37,8 +37,13 @@ object ResourceServer {
case "jquery-autocomplete" :: "indicator.gif" :: Nil => true
}
- var pathRewriter: PartialFunction[List[String], List[String]] = {
- case "jquery.js" :: Nil => List("jquery-" + LiftRules.jQueryVersion.toString + "-min.js")
+ private def rewriter = new PartialFunction[List[String], List[String]]{
+ def isDefinedAt(in: List[String]) = LiftRules.jsArtifacts.pathRewriter.isDefinedAt(in)
+
+ def apply(in: List[String]): List[String] = LiftRules.jsArtifacts.pathRewriter(in)
+ }
+
+ var pathRewriter: PartialFunction[List[String], List[String]] = rewriter orElse {
case "json.js" :: Nil => List("json2-min.js")
case "json2.js" :: Nil => List("json2-min.js")
case xs => xs
@@ -85,6 +85,19 @@ trait JSArtifacts {
* Converts a form denominated by formId into a JSON object
*/
def formToJSON(formId: String): JsExp
+
+ /**
+ * Rewrites the incomming path with the actual script path
+ *
+ */
+ def pathRewriter: PartialFunction[List[String], List[String]] =
+ new PartialFunction[List[String], List[String]] {
+
+ def isDefinedAt(in: List[String]): Boolean = false
+
+ def apply(in: List[String]): List[String] = Nil
+
+ }
}
/**
@@ -546,7 +546,6 @@ object JsCmds {
object OnLoad {
def apply(what: JsCmd): JsCmd = LiftRules.jsArtifacts.onLoad(what)
-
}
case class SetValById(id: String, right: JsExp) extends JsCmd {
@@ -36,7 +36,7 @@ trait JxBase {
def appendToParent(parentName: String): JsCmd
- def label = "jx" // throw new UnsupportedOperationException("Xml2Js does not have a label")
+ def label = "jx"
def addAttrs(varName: String, attrs: List[MetaData]): JsCmd = attrs.map {
m =>
@@ -28,7 +28,7 @@ import JE._
import JqJE._
import util.Helpers._
-object JQueryArtifacts extends JSArtifacts {
+trait JQueryArtifacts extends JSArtifacts {
def toggle(id: String) = JqId(id) ~> new JsMethod {
def toJsCmd = "toggle()"
}
@@ -82,6 +82,20 @@ object JQueryArtifacts extends JSArtifacts {
info.failFunc.map("error : " + _).toList mkString ("{ ", ", ", " }")
}
+case object JQuery13Artifacts extends JQueryArtifacts {
+ override def pathRewriter: PartialFunction[List[String], List[String]] = {
+ case "jquery.js" :: Nil => List("jquery-1.3.2-min.js")
+ }
+}
+
+
+case object JQuery14Artifacts extends JQueryArtifacts {
+ override def pathRewriter: PartialFunction[List[String], List[String]] = {
+ case "jquery.js" :: Nil => List("jquery-1.4.2.min.js")
+ }
+}
+
+
}
}
}

0 comments on commit d35df8c

Please sign in to comment.