Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Bootstrap v4.1.3 #169

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import net.liftweb.http.js.JsCmd
* ==Bootstrap Script Helper Bootstrap v4.x==
* Bootstrap script helper is a helper class that implements some commonly
* used bootstrap component init/usage script functions.
* This convenience script functions is used in the [[net.liftmodules.FoBoBs.snippet.FoBo.Bs4Comp]]
* This convenience script functions is used in the [[net.liftmodules.fobobs4.snippet.FoBo.Bs4Comp]]
* snippet but can also be used as a convenience helper in your own customized snippets.
*
* @example If you find that the [[net.liftmodules.FoBoBs.snippet.FoBo.Bs4Comp]] snippet dose not fit you exact needs
* @example If you find that the [[net.liftmodules.fobobs4.snippet.FoBo.Bs4Comp]] snippet dose not fit you exact needs
* your can still use the BootstrapSH class to customize your own project snippets.
* {{{
* import net.liftmodules.FoBoBs.lib.{BootstrapSH=>sch}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package net.liftmodules.fobobs4.snippet.FoBo

import scala.xml.{NodeSeq, Text}
import scala.xml.{NodeSeq}
import net.liftweb.util._
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb._
import Helpers._
import net.liftweb.http.js._
import net.liftweb.http.js.JsCmds._
import net.liftmodules.fobobs4.lib.{BootstrapSH => sch}
import net.liftweb.sitemap.{Loc, SiteMap}

/**
* ==Bs4Component's Snippet Bootstrap v4.x==
Expand All @@ -25,6 +25,7 @@ class Bs4Comp extends StatefulSnippet with Loggable {
private lazy val sch = new sch()

def dispatch = {
case "breadCrumb" => breadCrumb
case "popover" => popover
case "popoverAppendJs" => popoverAppendJs
case "popoverPreventDefault" => popoverPreventDefault
Expand All @@ -35,6 +36,54 @@ class Bs4Comp extends StatefulSnippet with Loggable {
case "activateDropdownAppendJs" => activateDropdownAppendJs
}

/**
* This function creates a bootstrap breadCrumb component using Loc information from Lift.
*
* '''Snippet Params:'''
*
* - '''Param''' ''prefix'' - A optional param to prefix the breadcrumb list with if it's value can
* be found as a Loc.name.
*
* '''Example'''
* {{{ <script data-lift="FoBo.Bs4Comp.breadCrumb?prefix=Home"></script> }}}
*
* @since v2.0.1
*/
def breadCrumb: CssSel = {
val locName = S.attr("prefix") openOr ""
val aPrefix: Box[Loc[_]] = SiteMap.findLoc(locName)
var breadcrumbs: List[Loc[_]] =
for {
currentLoc <- S.location.toList
loc <- currentLoc.breadCrumbs
} yield loc

breadcrumbs = aPrefix match {
case Full(prefix) => prefix :: breadcrumbs
case _ => breadcrumbs
}

" *" #> <nav aria-label="breadcrumb" role="navigation">
<ol class="breadcrumb">
{breadcrumbs.map { loc =>
val linkText = loc.linkText.openOr(NodeSeq.Empty)
val link = loc.createDefaultLink.getOrElse(NodeSeq.Empty)

if (loc == S.location.openOr(NodeSeq.Empty))
<li class="breadcrumb-item active" aria-current="page">
{linkText}
</li>
else
<li class="breadcrumb-item">
<a href={link}>
{linkText}
</a>
</li>
}}
</ol>
</nav>
}

/**
* This function sets a popover action on a element by inlining a script snippet on the page.
*
Expand Down Expand Up @@ -112,7 +161,7 @@ class Bs4Comp extends StatefulSnippet with Loggable {
* // ]]>
* </script>
* }}}
* @see [[net.liftmodules.FoBoBs.lib.BootstrapSH.tooltipScript]]
* @see [[net.liftmodules.fobobs4.lib.BootstrapSH.tooltipScript]]
* @since v2.0
*/
def tooltip: CssSel = {
Expand Down
Loading