
net.liftmodules.FoBoTB.FoBoTB.scala Maven / Gradle / Ivy
The newest version!
package net.liftmodules
import _root_.net.liftweb._
import util.{ Props }
import http._
import common._
/**
* ==FoBo - Sub-module==
* This package object is only of interest to you if you are using this module
* as a stand alone artifact dependency in your project (without FoBo).
* This package object provides information on how to initiate and use this module
* in your project. If you are using this module in FoBo see [[net.liftmodules.FoBo]]
* for usage information.
*/
package object FoBoTB {
/**
* @example In bootstrap liftweb Boot set
* {{{
* FoBoTB.init()
* }}}
* The above example just calls init without specifying fobo init
* params so default Toolkit and JQuery values will be used.
*/
def init() {
LiftRules.addToPackages("net.liftmodules.FoBoTB")
ResourceServer.allow {
case "fobo" :: tail => true
}
}
abstract trait FoBoJQuery
abstract trait FoBoToolkit
/**
* Extends your Lift SiteMap with various common bootstrap menu manipulations such
* as horizontal and vertical menu dividers and menu labels.
*
* This object should be used in conjunction with the TB* menu builder objects in [[net.liftmodules.FoBo.snippet.FoBo]] snippet's.
*
* '''Example:'''
* {{{
* :
* //add a horizontal menu divider
* divider1 >> LocGroup(...) >> FoBoTB.TBLocInfo.Divider,
* :
* //add a vertical menu divider
* divider2 >> LocGroup(...) >> FoBoTB.TBLocInfo.DividerVertical,
* :
* }}}
*/
object TBLocInfo {
private val hd: Box[String] = Full("divider")
private val vd: Box[String] = Full("divider-vertical")
private val nh: Box[String] = Full("nav-header")
private val ltb: Box[String] = Full("_blank")
private val lts: Box[String] = Full("_self")
private val ltp: Box[String] = Full("_parent")
private val ltt: Box[String] = Full("_top")
/**
* Provides a way to specify a horizontal divider for your bootstrap menu in Lift's SiteMap.
*
* '''Example:'''
* {{{
* val index = Menu.i("Home") / "index"
* :
* val about = Menu.i("About") / "about"
* val divider2 = Menu("divider2") / "divider2" //dummy entry only showing a menu divider
* val navHeader1 = Menu.i("navHeader1") / "navHeader1" //Adds a header (label) to your FoBo.NavList
*
* def sitemap = SiteMap(
* navHeader1 >> LocGroup("nl1") >> FoBoTB.TBLocInfo.NavHeader,
* index >> LocGroup("top","nl1",...),
* :
* ddLabel >> LocGroup("top",...) >> PlaceHolder submenus(
* about ,
* divider2 >> FoBo.TBLocInfo.Divider,
* contact,
* feedback
* )
* )
* }}}
*/
val Divider = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = hd.map(x => () => x) }
/**
* Add a vertical divider in your bootstrap menu.
* For a usage example see the Divider val above.
*/
val DividerVertical = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = vd.map(x => () => x) }
/**
* Add nav header(s) to your bootstrap nav list.
* For a usage example see the NavHeader val above.
*/
val NavHeader = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = nh.map(x => () => x) }
/**
* Adds target="_blank" to the link
* @since v1.2
*/
val LinkTargetBlank = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = ltb.map(x => () => x) }
/**
* Adds target="_self" to the link
* @since v1.2
*/
val LinkTargetSelf = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = lts.map(x => () => x) }
/**
* Adds target="_parent" to the link
* @since v1.2
*/
val LinkTargetParent = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = ltp.map(x => () => x) }
/**
* Adds target="_top" to the link
* @since v1.2
*/
val LinkTargetTop = new net.liftweb.sitemap.Loc.LocInfo[String]{def apply() = ltt.map(x => () => x) }
}
/**
* Enable Toolkit(s)/JQuery options for the FoBo module in your bootstrap liftweb Boot.
*
* '''Example:'''
*
* {{{
* FoBoTB.InitParam.JQuery=FoBoTB.JQuery172
* FoBoTB.InitParam.Toolkit=FoBoTB.Bootstrap232
* }}}
* This example uses the Bootstrap v2.3.2 option.
*
*/
object InitParam extends FoBoToolkit with FoBoJQuery {
var ToolKit: FoBoToolkit = null //Bootstrap222
}
/**
* Enable usage of Twitter Bootstrap version 2․3․2 in your bootstrap liftweb Boot.
* @version 2.3.2
*
* '''Example'''
*
* {{{
* FoBoTB.InitParam.Toolkit=FoBoTB.Bootstrap232
* }}}
*/
case object Bootstrap232 extends FoBoToolkit {
FoBoResources.bootstrap232
}
/**
* Object holding internally used FoBo resources.
*/
private object FoBoResources {
lazy val bootstrap232: Unit = {
ResourceServer.rewrite {
case "fobo" :: "bootstrap.css" :: Nil if Props.devMode => List("fobo", "bootstrap","2.3.2", "css", "bootstrap.css")
case "fobo" :: "bootstrap.css" :: Nil => List("fobo", "bootstrap","2.3.2", "css", "bootstrap-min.css")
case "fobo" :: "bootstrap-responsive.css" :: Nil if Props.devMode => List("fobo", "bootstrap","2.3.2", "css", "responsive.css")
case "fobo" :: "bootstrap-responsive.css" :: Nil => List("fobo", "bootstrap","2.3.2","css", "responsive-min.css")
case "fobo" :: "bootstrap.js" :: Nil if Props.devMode => List("fobo", "bootstrap","2.3.2", "js", "bootstrap.js")
case "fobo" :: "bootstrap.js" :: Nil => List("fobo", "bootstrap","2.3.2", "js", "bootstrap-min.js")
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy