Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created June 10, 2014 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmpwizard/25f9ed53a579c0e8221e to your computer and use it in GitHub Desktop.
Save fmpwizard/25f9ed53a579c0e8221e to your computer and use it in GitHub Desktop.
Bootstrap Lift messages / notices
val jsNotice =
"""$('#lift__noticesContainer___notice li')
|.addClass("alert alert-success")
|.append('<button type="button" class="close" data-dismiss="alert">×</button>')""".stripMargin
val jsWarning =
"""$('#lift__noticesContainer___warning li')
|.addClass("alert")
|.append('<button type="button" class="close" data-dismiss="alert">×</button>')""".stripMargin
val jsError =
"""$('#lift__noticesContainer___error li')
|.addClass("alert alert-error")
|.append('<button type="button" class="close" data-dismiss="alert">×</button>')""".stripMargin
LiftRules.noticesEffects.default.set(
(notice: Box[NoticeType.Value], id: String) => {
val js = notice.map( _.title) match{
case Full("Notice") => Full(JE.JsRaw( jsNotice ).cmd)
case Full("Warning") => Full(JE.JsRaw( jsWarning ).cmd)
case Full("Error") => Full(JE.JsRaw( jsError ).cmd)
case _ => Full(JE.JsRaw( jsNotice ).cmd)
}
js
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment