From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- vendor/oojs/oojs-ui/php/mixins/LabelElement.php | 77 +++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 vendor/oojs/oojs-ui/php/mixins/LabelElement.php (limited to 'vendor/oojs/oojs-ui/php/mixins/LabelElement.php') diff --git a/vendor/oojs/oojs-ui/php/mixins/LabelElement.php b/vendor/oojs/oojs-ui/php/mixins/LabelElement.php new file mode 100644 index 00000000..d5cf7bee --- /dev/null +++ b/vendor/oojs/oojs-ui/php/mixins/LabelElement.php @@ -0,0 +1,77 @@ +target->addClasses( array( 'oo-ui-labelElement-label' ) ); + $this->setLabel( isset( $config['label'] ) ? $config['label'] : null ); + } + + /** + * Set the label. + * + * An empty string will result in the label being hidden. A string containing only whitespace will + * be converted to a single ` `. + * + * @param string|HtmlSnippet|null $label Label text + * @chainable + */ + public function setLabel( $label ) { + $this->label = $label; + + $this->target->clearContent(); + if ( $this->label !== null ) { + if ( is_string( $this->label ) && $this->label !== '' && trim( $this->label ) === '' ) { + $this->target->appendContent( new HtmlSnippet( ' ' ) ); + } else { + $this->target->appendContent( $label ); + } + } + + $this->element->toggleClasses( array( 'oo-ui-labelElement' ), !!$this->label ); + + return $this; + } + + /** + * Get the label. + * + * @return string|HtmlSnippet|null Label text + */ + public function getLabel() { + return $this->label; + } + + public function getConfig( &$config ) { + if ( $this->label !== null ) { + $config['label'] = $this->label; + } + return parent::getConfig( $config ); + } +} -- cgit v1.2.2