Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created January 16, 2013 03:18
Show Gist options
  • Save fmpwizard/4544385 to your computer and use it in GitHub Desktop.
Save fmpwizard/4544385 to your computer and use it in GitHub Desktop.
Boostrap friendly 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