mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
35fb0cd0c5
FEATURE Refactored MoreLessField->ToggleField FEATURE Refactored TogglePanel->ToggleCompositeField FEATURE Degrading gracefully (javascript), using behaviour+classes+prototype, partially i18ned, improved markup git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43660 467b73ca-7a2a-4603-9d3b-597d59a354a9
51 lines
1.1 KiB
PHP
Executable File
51 lines
1.1 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Allows visibility of a group of fields to be toggled using '+' and '-' icons
|
|
*/
|
|
class ToggleCompositeField extends CompositeField {
|
|
|
|
/**
|
|
* @var $headingLevel int
|
|
*/
|
|
public $headingLevel = 2;
|
|
|
|
function __construct($title, $children) {
|
|
$this->title = $title;
|
|
$this->name = ereg_replace('[^A-Za-z0-9]','',$this->title);
|
|
|
|
$this->startClosed(true);
|
|
|
|
parent::__construct($children);
|
|
}
|
|
|
|
public function FieldHolder() {
|
|
Requirements::javascript("jsparty/prototype.js");
|
|
Requirements::javascript("jsparty/behaviour.js");
|
|
Requirements::javascript("jsparty/prototype_improvements.js");
|
|
Requirements::javascript("sapphire/javascript/ToggleCompositeField.js");
|
|
|
|
return $this->renderWith("ToggleCompositeField");
|
|
}
|
|
|
|
/**
|
|
* Determines if the field should render open or closed by default.
|
|
*
|
|
* @param boolean
|
|
*/
|
|
public function startClosed($bool) {
|
|
($bool) ? $this->addExtraClass('startClosed') : $this->removeExtraClass('startClosed');
|
|
}
|
|
|
|
/**
|
|
* @return String
|
|
*/
|
|
public function HeadingLevel() {
|
|
return $this->headingLevel;
|
|
}
|
|
|
|
public function Type() {
|
|
return ' toggleCompositeField';
|
|
}
|
|
}
|
|
|
|
?>
|