CollapsibleFieldsetLayout.php 782 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class CollapsibleFieldsetLayout extends OOUI\FieldsetLayout {
  3. public function __construct( array $config = [] ) {
  4. parent::__construct( $config );
  5. $this->addClasses( [ 'mw-collapsible' ] );
  6. if ( isset( $config[ 'collapsed' ] ) && $config[ 'collapsed' ] ) {
  7. $this->addClasses( [ 'mw-collapsed' ] );
  8. }
  9. $this->header->addClasses( [ 'mw-collapsible-toggle' ] );
  10. $this->group->addClasses( [ 'mw-collapsible-content' ] );
  11. $this->header->appendContent(
  12. new OOUI\IconWidget( [
  13. 'icon' => 'expand',
  14. 'label' => wfMessage( 'collapsible-expand' )->text(),
  15. ] ),
  16. new OOUI\IconWidget( [
  17. 'icon' => 'collapse',
  18. 'label' => wfMessage( 'collapsible-collapse' )->text(),
  19. ] )
  20. );
  21. $this->header->setAttributes( [
  22. 'role' => 'button',
  23. ] );
  24. }
  25. }