-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
046b846
commit 45ac1d0
Showing
11 changed files
with
232 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Toggle Component | ||
===================================================================================================================== */ | ||
|
||
import $ from 'jquery'; | ||
|
||
$(function() { | ||
|
||
// Handle Toggle Components: | ||
|
||
$('.togglecomponent').each(function() { | ||
|
||
var $self = $(this); | ||
var $header = $self.find('header'); | ||
|
||
// Detect Start Open Status: | ||
|
||
if ($self.data('start-open')) { | ||
$header.addClass('opened'); | ||
} | ||
|
||
// Handle Header Click: | ||
|
||
$header.on('click', function() { | ||
$(this).toggleClass('opened'); | ||
}); | ||
|
||
// Handle Header Link Click: | ||
|
||
$header.find('a').on('click', function(e) { | ||
e.stopPropagation(); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* Toggle Component Styles | ||
===================================================================================================================== */ | ||
|
||
.togglecomponent { | ||
|
||
margin: 0 0 $spacer; | ||
border: $border-width solid $border-color; | ||
|
||
> header { | ||
|
||
cursor: pointer; | ||
padding: $spacer; | ||
transition: $transition-base; | ||
|
||
> * { | ||
|
||
margin: 0; | ||
font-size: inherit; | ||
|
||
&:before { | ||
opacity: 0.75; | ||
content: "\f0fe"; | ||
display: inline-block; | ||
padding-right: $spacer-half; | ||
font-family: 'FontAwesome'; | ||
} | ||
|
||
} | ||
|
||
&.opened { | ||
|
||
> *:before { | ||
content: "\f146"; | ||
} | ||
|
||
} | ||
|
||
&.opened + div.content { | ||
display: block; | ||
} | ||
|
||
@include hover-focus { | ||
background-color: rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
} | ||
|
||
> div.content { | ||
|
||
display: none; | ||
padding: $spacer; | ||
|
||
border-top-width: $border-width; | ||
border-top-style: dotted; | ||
border-top-color: inherit; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of SilverWare. | ||
* | ||
* PHP version >=5.6.0 | ||
* | ||
* For full copyright and license information, please view the | ||
* LICENSE.md file that was distributed with this source code. | ||
* | ||
* @package SilverWare\Components | ||
* @author Colin Tucker <colin@praxis.net.au> | ||
* @copyright 2018 Praxis Interactive | ||
* @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause | ||
* @link https://github.com/praxisnetau/silverware | ||
*/ | ||
|
||
namespace SilverWare\Components; | ||
|
||
use SilverStripe\Forms\CheckboxField; | ||
use SilverWare\Forms\FieldSection; | ||
|
||
/** | ||
* An extension of the content component class for a toggle component. | ||
* | ||
* @package SilverWare\Components | ||
* @author Colin Tucker <colin@praxis.net.au> | ||
* @copyright 2018 Praxis Interactive | ||
* @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause | ||
* @link https://github.com/praxisnetau/silverware | ||
*/ | ||
class ToggleComponent extends ContentComponent | ||
{ | ||
/** | ||
* Human-readable singular name. | ||
* | ||
* @var string | ||
* @config | ||
*/ | ||
private static $singular_name = 'Toggle Component'; | ||
|
||
/** | ||
* Human-readable plural name. | ||
* | ||
* @var string | ||
* @config | ||
*/ | ||
private static $plural_name = 'Toggle Components'; | ||
|
||
/** | ||
* Description of this object. | ||
* | ||
* @var string | ||
* @config | ||
*/ | ||
private static $description = 'A component to show a toggleable block of content'; | ||
|
||
/** | ||
* Icon file for this object. | ||
* | ||
* @var string | ||
* @config | ||
*/ | ||
private static $icon = 'silverware/silverware: admin/client/dist/images/icons/ToggleComponent.png'; | ||
|
||
/** | ||
* Defines the table name to use for this object. | ||
* | ||
* @var string | ||
* @config | ||
*/ | ||
private static $table_name = 'SilverWare_ToggleComponent'; | ||
|
||
/** | ||
* Maps field names to field types for this object. | ||
* | ||
* @var array | ||
* @config | ||
*/ | ||
private static $db = [ | ||
'StartOpen' => 'Boolean' | ||
]; | ||
|
||
/** | ||
* Defines the default values for the fields of this object. | ||
* | ||
* @var array | ||
* @config | ||
*/ | ||
private static $defaults = [ | ||
'StartOpen' => 0 | ||
]; | ||
|
||
/** | ||
* Answers an array of HTML tag attributes for the object. | ||
* | ||
* @return array | ||
*/ | ||
public function getAttributes() | ||
{ | ||
$attributes = array_merge( | ||
parent::getAttributes(), | ||
[ | ||
'data-start-open' => $this->dbObject('StartOpen')->NiceAsBoolean() | ||
] | ||
); | ||
|
||
return $attributes; | ||
} | ||
|
||
/** | ||
* Event method called before the receiver is written to the database. | ||
* | ||
* @return void | ||
*/ | ||
public function onBeforeWrite() | ||
{ | ||
// Call Parent Event: | ||
|
||
parent::onBeforeWrite(); | ||
|
||
// Enforce Visible Title: | ||
|
||
$this->HideTitle = 0; | ||
} | ||
} |