Bootstrap navigation + carousel slider

This commit is contained in:
Tony Air 2018-05-28 19:42:05 +07:00
parent 37801ba685
commit 81f89ca8ea
13 changed files with 186 additions and 5 deletions

View File

@ -57,4 +57,4 @@
},
"prefer-stable": true,
"minimum-stability": "dev"
}
}

View File

@ -2,6 +2,7 @@
use SilverStripe\Forms\HTMLEditor\HtmlEditorConfig;
use SilverStripe\Core\Manifest\ModuleResourceLoader;
use SilverStripe\ORM\Search\FulltextSearchable;
HtmlEditorConfig::get('cms')->enablePlugins([
'template',
@ -13,3 +14,7 @@ HtmlEditorConfig::get('cms')->enablePlugins([
'lists',
'charcount' => ModuleResourceLoader::resourceURL('drmartingonzo/ss-tinymce-charcount:client/dist/js/bundle.js'),
]);
FulltextSearchable::enable();

View File

@ -1,3 +1,3 @@
SilverStripe\SiteConfig\SiteConfig:
extensions:
- Site\Extensions\SiteConfigExtension
- Site\Extensions\SiteConfigExtension

View File

@ -0,0 +1,51 @@
/**
* Just an example component
*/
import $ from 'jquery';
const SliderUI = (($) => {
class SliderUI {
static init() {
this.each(function ($this) {
const $items = $this.find('.carousel-item'),
id = $this.attr('id'),
count = $items.length;
if(!count){
return;
}
if($this.data('indicators')) {
let $controls = $('<ol class="carousel-indicators"></ol>');
$controls.append('<li data-target="#' + id + '" data-slide-to="0" class="active"></li>');
for (let i = 1; i < count; i++) {
$controls.append('<li data-target="#' + id + '" data-slide-to="' + i + '"></li>');
}
$this.prepend($controls);
}
if($this.data('arrows')){
$this.prepend('<i class="carousel-control-prev" data-target="#' + id + '" role="button" data-slide="prev"><i class="fas fa-chevron-left" aria-hidden="true"></i><i class="sr-only">Previous</i></i>');
$this.prepend('<i class="carousel-control-next" data-target="#' + id + '" role="button" data-slide="next"><i class="fas fa-chevron-right" aria-hidden="true"></i><i class="sr-only">Next</i></i>');
}
$this.carousel();
});
}
static dispose() {
self.each(function ($this) {
$this.carousel('dispose');
});
}
static each(callback) {
$('.carousel').each(function () {
callback($(this));
});
}
}
return SliderUI;
})($);
export default SliderUI;

View File

@ -3,6 +3,7 @@ import $ from 'jquery';
import Events from './_events';
// import an example component
import Spinner from './_components/_spinner';
import Slider from './_components/_slider';
const MainUI = (($) => {
// Constants
@ -17,6 +18,8 @@ const MainUI = (($) => {
Spinner.hide(() => {
$('body').addClass('loaded');
});
Slider.init();
}
static destroy() {

View File

@ -0,0 +1,19 @@
.carousel-control-prev,
.carousel-control-next {
z-index: 2;
font-size: 3rem;
text-shadow: 1px 1px #000;
&:hover,
&:focus {
background: rgba(0, 0, 0, 0.6);
}
}
.carousel-indicators li {
box-shadow: 1px 1px #000;
}
.carousel-title,
.carousel-content {
text-shadow: 1px 1px #000;
}

View File

@ -1,3 +1,5 @@
/**
* Your custom style
*/
@import "_components/slider";

View File

@ -0,0 +1 @@
@import "../_variables";

View File

@ -42,6 +42,7 @@ class DeferedRequirements implements TemplateGlobalProvider
DeferedRequirements::loadJS('//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');
// App libs
DeferedRequirements::loadCSS('//use.fontawesome.com/releases/v5.0.13/css/all.css');
DeferedRequirements::loadCSS('app.css');
DeferedRequirements::loadJS('app.js');

View File

@ -0,0 +1,28 @@
<% if $SlideShow %>
<%-- Use: data-ride="carousel" to autoinitialize bootstrap carousel --%>
<div id="Carousel{$ID}" class="carousel slide" data-indicators="true" data-arrows="true">
<div class="carousel-inner">
<% loop $SlideShow %>
<div class="carousel-item<% if $First %> active<% end_if %>">
<% if $PageLink %><a href="$PageLink.Link" title="$PageLink.MenuTitle.XML"><% end_if %>
<% if $Image %>
<img class="d-block w-100" src="$Image.Fill(1200,600).URL" alt="<% if $Headline %>$Headline<% end_if %>">
<% end_if %>
<% if $PageLink %></a><% end_if %>
<div class="carousel-caption d-none d-md-block">
<% if $Headline %><h2 class="carousel-title">$Headline</h2><% end_if %>
<% if $Description %><p class="carousel-content">$Description</p><% end_if %>
<% if $PageLinkID %>
<p>
<a href="$PageLink.Link" title="$PageLink.MenuTitle.XML" class="btn btn-default">
<%t Dynamic\FlexSlider\ORM\FlexSlider.LEARN_MORE "Learn more" %>
</a>
</p>
<% end_if %>
</div>
</div>
<% end_loop %>
</div>
</div>
<% end_if %>

View File

@ -0,0 +1,30 @@
<% if $Children %>
<li class="nav-item dropdown $ExtraClass <% if $isCurrent || $isSection %> active<% end_if %>">
<a
class="nav-link dropdown-toggle"
id="NavItem{$ID}"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
href="{$Link}"
title="$Title.XML"
>
$MenuTitle.XML
<% if $isCurrent || $isSection %><i class="sr-only">(current)</i><% end_if %>
</a>
<ul class="dropdown-menu" aria-labelledby="NavItem{$ID}">
<% loop $Children %>
<% include NavItem ExtraClass="dropdown-item" %>
<% end_loop %>
</ul>
</li>
<% else %>
<li class="nav-item $ExtraClass <% if $isCurrent || $isSection %> active<% end_if %>">
<a class="nav-link" href="{$Link}" title="$Title.XML">
$MenuTitle.XML
<% if $isCurrent || $isSection %><i class="sr-only">(current)</i><% end_if %>
</a>
</li>
<% end_if %>

View File

@ -0,0 +1,21 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="navbar-toggler-icon"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<% loop $Navigation %>
<% include NavItem %>
<% end_loop %>
</ul>
</div>
</nav>

View File

@ -13,10 +13,30 @@
<noscript><div class="main-bn"><%t Page.JAVASCRIPTREQUIRED 'Please, enable javascript.' %></div></noscript>
<%-- Loading Spinner --%>
<div id="PageLoading"><div class="loading-spinner"><div class="bubblingG"><span id="bubblingG_1"></span><span id="bubblingG_2"></span><span id="bubblingG_3"></span></div><br/><%t Page.LOADINGTEXT 'LOADING ..' %></div></div>
<div id="PageLoading"><div class="loading-spinner"><div class="bubblingG"><i id="bubblingG_1"></i><i id="bubblingG_2"></i><i id="bubblingG_3"></i></div><br/><%t Page.LOADINGTEXT 'LOADING ..' %></div></div>
<header>
<header class="container">
<div class="row">
<div class="col-sm-6">
<a href="/"><img src="/resources/site/client/dist/img/logo.png" alt="{$SiteConfig.Title}" /></a>
</div>
<div class="col-sm-6 text-right">
<% with $SiteConfig %>
<% if $PhoneNumber %>
<div class="phone-number">
<b>Call us today:</b>
$PhoneNumber
</div>
<% end_if %>
<% end_with %>
<% if $SearchForm %>
<div id="SearchFormContainer">$SearchForm</div>
<% end_if %>
</div>
</div>
<% include Navigation Navigation=$SiteConfig.Navigation %>
</header>
<main data-ajax-region="LayoutAjax">