liftweb-uirouter
angularjs ui-router module for scala liftweb framework
git clone https://9o.is/git/liftweb-uirouter.git
UiRoundTrip.scala
(948B)
1 package net.liftmodules.uirouter
2 package snippet
3
4 import net.liftweb._
5 import http._
6 import util._
7 import Helpers._
8 import js.JE._
9 import js.JsCmds._
10
11 /**
12 * When using Lift roundtrips with UI-router.
13 */
14 trait UiRoundTrip extends SnippetHelper {
15
16 def roundTrips: List[RoundTripInfo]
17
18 def render: CssSel =
19 for (sess <- S.session) yield {
20 val roundtrips = sess.buildRoundtrip(roundTrips)
21
22 val lastcomet = S.cometAtEnd.last
23 val whenregex = "<div.*lift:when=\"([0-9]*)\".*/>".r
24
25 val when: String = lastcomet.toString match {
26 case whenregex(when) => when
27 case _ => ""
28 }
29
30 val className: String = this.getClass.getName.split("""\.""").last
31
32 "* *+" #> <script class="ui-liftjs">{SetExp(JsVar("window", className), roundtrips).toJsCmd}</script> &
33 "* *+" #> <div class="ui-liftwatches">{(lastcomet % ("class" -> "ui-liftwatch") % ("when" -> when))}</div>
34 }
35 }