Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ntd committed Jul 19, 2016
2 parents 7b24739 + 2a96a52 commit 1bb925c
Show file tree
Hide file tree
Showing 25 changed files with 210 additions and 129 deletions.
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ Features
module, silverstrap will generate on the fly the table of contents of
the current page (if possible) and it will present it in a _.navlist_
on the right side. Your site will gain table of contents for free.
* Proper support for pages nested at arbitrary levels.
* Out of the box support for the
[silverstripe-carousel](http://dev.entidi.com/p/silverstripe-carousel/)
module.
* Out of the box support for the
[silverstripe-gallery](http://dev.entidi.com/p/silverstripe-gallery/)
module.
* Proper support for menu with pages nested at arbitrary levels.
* Quite extensible and customizable. This can be done by _overriding_
the default implementation instead of editing it: check the section
*Overriding silverstrap* for further details.
* Different components inclusion methods. By default external components
(such as JQuery and Bootstrap) are fetched from the jsdelivr CDN
network but a couple of alternate methods are provided. See the
section *External dependencies* for details.
* JavaScript configuration can be overriden: see *Customizing JavaScript
modules*.

External dependencies
---------------------
Expand Down Expand Up @@ -73,6 +81,25 @@ instead of the default one. If this is the case, just override
`Silverstrap.ss` to include the offline or the modular version. Consult
the next session to know how to override templates.

Customizing JavaScript modules
------------------------------

`silverstrap.js` defines the global object `silverstrap` where all the
default JavaScript settings are stored.

To override this settings (i.e. to change the out of the box behavior of
the JavaScript modules) you should change this global object after
including `silverstrap.js`, e.g.:

<script src="themes/silverstrap/js/silverstrap.js></script>
<script>
// Disable fullscreen in fotorama
silverstrap.fotorama.allowfullscreen = false;
// Colorbox zoom to 50% max
silverstrap.colorbox.maxWidth = '50%';
silverstrap.colorbox.maxHeight = '50%';
</script>

Overriding silverstrap
----------------------

Expand Down Expand Up @@ -147,5 +174,12 @@ website directory with the following content:
Support
-------

For bug reports or feature requests, please use the dedicated
[development tracker](http://dev.entidi.com/p/silverstrap/).
This project has been developed by [ntd](mailto:ntd@entidi.it). Its
[home page](http://silverstripe.entidi.com/themes/) is shared by other
[SilverStripe](http://www.silverstripe.org/) modules and themes.

To check out the code, report issues or propose enhancements, go to the
[dedicated tracker](http://dev.entidi.com/p/silverstripe-carousel).
[dedicated tracker](http://dev.entidi.com/p/silverstrap/).
Alternatively, you can do the same things by leveraging the official
[github repository](https://github.com/ntd/silverstrap).
36 changes: 22 additions & 14 deletions css/silverstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,22 @@ blockquote {
margin-left: 0;
margin-right: 15px;
}
.zoom img,
a.zoom img:hover {
background-color: #fff;
-moz-box-shadow: 0 0 6px 2px #eee;
-webkit-box-shadow: 0 0 6px 2px #eee;
box-shadow: 0 0 6px 2px #eee;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
.zoom img {
background-color: #eee;
box-shadow: 0 0 6px 2px #ccc;
-moz-box-shadow: 0 0 6px 2px #ccc;
-webkit-box-shadow: 0 0 6px 2px #ccc;
padding: 8px;
margin: 6px;
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 5px;
}
a.zoom img {
background-color: #eee;
-moz-box-shadow: 0 0 6px 2px #ccc;
-webkit-box-shadow: 0 0 6px 2px #ccc;
box-shadow: 0 0 6px 2px #ccc;
.zoom img:hover {
background-color: #fff;
box-shadow: 0 0 6px 2px #eee;
-moz-box-shadow: 0 0 6px 2px #eee;
-webkit-box-shadow: 0 0 6px 2px #eee;
border-color: rgba(0, 0, 0, 0.2);
}

/* Search results page */
Expand Down Expand Up @@ -136,6 +135,10 @@ a.zoom img {
margin-top: 0;
}

/* Form overriding */
form .tab-content {
padding: 15px 0;
}
/* Support for two columns forms, required by silverstripe-adg */
.ss-2col {
position: relative;
Expand All @@ -153,7 +156,12 @@ a.zoom img {
.ss-2col .col-sm-offset-3 {
margin-left: 60%;
}

.form-group .ss-without-label {
margin: 20px 0;
}
form legend .btn {
margin: 6px;
}

/* Company data, usually used in the Sitemap.ss footer */
.ss-company {
Expand Down
140 changes: 71 additions & 69 deletions js/silverstrap.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,78 @@
$(document).ready(function() {
var $subject;
var silverstrap = {
carousel: {
interval: 8000
},
scrollspy: {
target: '#ss-toc'
},
affix: {
offset: {
top: $('#ss-toc').data('offset-top') || 72,
bottom: $('#ss-toc').data('offset-bottom') || 350
}
},
colorbox: {
rel: 'group',
maxWidth: '98%',
maxHeight: '98%',
photo: true
},
fotorama: {
nav: 'thumbs',
click: ! $.isFunction($.colorbox),
allowfullscreen: 'native',
width: '100%'
}
};

// Enable colorbox support on Fotorama frames
if ($.isFunction($.colorbox) && $.isFunction($.Fotorama)) {
var transition;
$(document).on('fotorama:show', function () {
transition = true;
})
.on('fotorama:showend', function () {
transition = false;
})
.on('fotorama:load', function (ev, fotorama, extra) {
extra.frame['$stageFrame'].find('.fotorama__img').not('.fotorama__img--full')
.css('cursor', 'zoom-in')
.on('click', function () {
if (transition)
return;
$.colorbox({
href: extra.frame.full,
title: function () {
return extra.frame.summary || extra.frame.caption;
},
maxWidth: '98%',
maxHeight: '98%',
photo: true
});
});
});
}
$(document).ready(function () {
var $subject;

// Add ColorBox support for zooming images (silverstrap)
$subject = $('.zoom');
if ($subject.length && $.isFunction($.colorbox)) {
$subject.colorbox({
rel: 'group',
maxWidth: '98%',
maxHeight: '98%',
photo: true
});
}
// Enable colorbox support on Fotorama frames
if ($.isFunction($.colorbox) && $.isFunction($.Fotorama)) {
var transition;
$(document).on('fotorama:show', function () {
transition = true;
})
.on('fotorama:showend', function () {
transition = false;
})
.on('fotorama:load', function (ev, fotorama, extra) {
extra.frame['$stageFrame'].find('.fotorama__img').not('.fotorama__img--full')
.css('cursor', 'zoom-in')
.on('click', function () {
if (! transition)
$.colorbox($.extend({
href: extra.frame.full,
title: function () {
return extra.frame.summary || extra.frame.caption;
}}, silverstrap.colorbox));
});
});
}

// Customize the behavior of the table of contents (silverstripe-autotoc)
$subject = $('#ss-toc');
if ($subject.length && $.isFunction($.affix)) {
$('body').scrollspy({
target: '#ss-toc'
});
$subject.affix({
offset: {
top: $subject.attr('data-offset-top') || 72,
bottom: $subject.attr('data-offset-bottom') || 350
}
});
}
// Add ColorBox support for zooming images (silverstrap)
$subject = $('.zoom');
if ($subject.length && $.isFunction($.colorbox)) {
$subject.colorbox(silverstrap.colorbox);
}

// Enable the Bootstrap carousel (silverstripe-carousel)
$subject = $('#ss-carousel');
if ($subject.length && $.isFunction($.carousel)) {
$subject.carousel({
interval: 8000
});
}
// Customize the behavior of the table of contents (silverstripe-autotoc)
$subject = $('#ss-toc');
if ($subject.length && $.isFunction($.affix)) {
$('body').scrollspy(silverstrap.scrollspy);
$subject.affix(silverstrap.affix);
}

// Enable the Fotorama gallery (silverstripe-gallery)
$subject = $('#ss-gallery');
if ($subject.length && $.isFunction($.Fotorama)) {
$subject.fotorama({
// Enable the Bootstrap carousel (silverstripe-carousel)
$subject = $('#ss-carousel');
if ($subject.length && $.isFunction($.carousel)) {
$subject.carousel(silverstrap.carousel);
}

nav: 'thumbs',
click: ! $.isFunction($.colorbox),
allowfullscreen: 'native',
width: '100%'
});
}
// Enable the Fotorama gallery (silverstripe-gallery)
$subject = $('#ss-gallery');
if ($subject.length && $.isFunction($.Fotorama)) {
$subject.fotorama(silverstrap.fotorama);
}
});
2 changes: 1 addition & 1 deletion templates/Includes/Form.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if $IncludeFormTag %>
<form class="form-horizontal $extraClass" $AttributesHTML role="form"><% end_if %><% if $Message %>
<form class="form-horizontal $extraClass" $getAttributesHTML('class') role="form"><% end_if %><% if $Message %>
<div id="{$FormName}_error" class="alert $MessageType">
<button type="button" class="close" data-dismiss="alert">&times;</button>
$Message
Expand Down
1 change: 1 addition & 0 deletions templates/Includes/Metadata.ss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
<title>$Title</title><% if $MetaDescription %>
<meta name="description" content="$MetaDescription.ATT"><% end_if %><% if $MetaKeywords %>
<meta name="keywords" content="$MetaKeywords.ATT"><% end_if %>
<meta name="generator" content="SilverStripe - http://silverstripe.org">
$ExtraMeta
2 changes: 1 addition & 1 deletion templates/forms/CheckboxField.ss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input $getAttributesHTML(class)>
<input $AttributesHTML<% if $isReadonly %> readonly<% else_if $isDisabled %> disabled<% end_if %>>
19 changes: 10 additions & 9 deletions templates/forms/CheckboxField_holder.ss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<div class="form-group $HolderClasses<% if $Message %> has-error<% end_if %>">
<div class="col-sm-offset-3 col-sm-6">
<div class="checkbox">
<label>
$Field
$Title
</label><% if $Message %>
<p class="help-block">$Message</p><% end_if %>
</div>
</div>
<div class="col-sm-offset-3 col-sm-6">
<div class="checkbox<% if $isReadonly || $isDisabled %> disabled<% end_if %>">
<label>
$Field
$Title
</label><% if $Message %>
<p class="help-block">$Message</p><% else_if $Description %>
<p class="help-block">$Description</p><% end_if %>
</div>
</div>
</div>
4 changes: 4 additions & 0 deletions templates/forms/CheckboxField_holder_small.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<label class="checkbox-inline ss-without-label<% if $isReadonly || $isDisabled %> disabled<% end_if %>">
$Field
$Title
</label>
4 changes: 4 additions & 0 deletions templates/forms/CheckboxSetField.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% loop $Options %><label class="checkbox-inline $Class">
<input type="checkbox"<% if $ID %> id="$ID"<% end_if %> name="$Name" value="$Value"<% if $isChecked %> checked<% end_if %><% if $isDisabled %> disabled<% end_if %>>
$Title
</label><% end_loop %>
10 changes: 5 additions & 5 deletions templates/forms/CompositeField.ss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<$Tag class="$extraClass"><% if $Tag == 'fieldset' && $Legend %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$Field
</div><% else %>
$Field<% end_if %><% end_loop %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$Field
</div><% else %>
$Field<% end_if %><% end_loop %>
</$Tag>
10 changes: 5 additions & 5 deletions templates/forms/CompositeField_holder.ss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<$Tag class="$extraClass<% if ColumnCount %> multicolumn<% end_if %>"><% if $Tag == 'fieldset' && $Legend %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$FieldHolder
</div><% else %>
$FieldHolder<% end_if %><% end_loop %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$FieldHolder
</div><% else %>
$FieldHolder<% end_if %><% end_loop %>
</$Tag>
3 changes: 3 additions & 0 deletions templates/forms/DropdownField.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<select class="form-control $extraClass" $getAttributesHTML('class')<% if $isReadonly %> readonly<% else_if $isDisabled %> disabled<% end_if %>><% loop $Options %>
<option value="$Value.XML"<% if $Selected %> selected<% end_if %><% if $Disabled %> disabled<% end_if %>><% if $Title.exists %>$Title.XML<% else %>&nbsp;<% end_if %></option><% end_loop %>
</select>
14 changes: 8 additions & 6 deletions templates/forms/FieldGroup_holder.ss
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div class="form-group $HolderClasses<% if $Message %> has-error<% end_if %>"><% if $Title %>
<label class="control-label col-sm-3" for="$ID">$Title</label><% end_if %>
<div class="<% if not $Title %>col-sm-offset-3 <% end_if %>col-sm-6"><% loop $FieldList %>
$SmallFieldHolder<% end_loop %><% if $Message %>
<p class="help-block">$Message</p><% end_if %>
</div><% if $RightTitle %>
<label class="control-label col-sm-3" for="$ID">$RightTitle</label><% end_if %>
<label class="control-label col-sm-3"<% if $ID %> for="$ID"<% end_if %>>$Title</label><% end_if %><% loop $FieldList %>
<%-- The following div should pertain to SmallFieldHolder but I cannot pass parameters
to the underlying templates for applying the offset only to the first field --%>
<div class="col-sm-2<% if not $Up.Title && $First %> col-sm-offset-3<% end_if %>">
$SmallFieldHolder
</div><% end_loop %><% if $Message %>
<p class="help-block">$Message</p><% end_if %><% if $RightTitle %>
<label class="control-label col-sm-3"<% if $ID %> for="$ID"<% end_if %>>$RightTitle</label><% end_if %>
</div>
2 changes: 1 addition & 1 deletion templates/forms/Form.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%--
Originally there was a symlink between forms/Form.ss and Includes/Form.ss
but git or composer seem not able to properly handle symlinks.
but git and composer seem not able to handle symlinks properly.
--%>
<% include Form %>
4 changes: 2 additions & 2 deletions templates/forms/FormAction.ss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<button class="btn<% if $Type=="action" %> btn-primary<% end_if %> $extraClass" $getAttributesHTML('class')><% if $ButtonContent %>
$ButtonContent<% else %>
$Title<% end_if %>
$ButtonContent<% else %>
$Title<% end_if %>
</button>
2 changes: 1 addition & 1 deletion templates/forms/FormField.ss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<input $AttributesHTML<% if $isReadonly %> disabled<% end_if %>>
<input class="form-control $extraClass" $getAttributesHTML('class')<% if $isReadonly %> readonly<% else_if $isDisabled %> disabled<% end_if %>>
Loading

0 comments on commit 1bb925c

Please sign in to comment.