From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php | 166 +++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php (limited to 'vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php') diff --git a/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php b/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php new file mode 100644 index 00000000..f26608b1 --- /dev/null +++ b/vendor/oojs/oojs-ui/php/widgets/ButtonWidget.php @@ -0,0 +1,166 @@ +mixin( new ButtonElement( $this, $config ) ); + $this->mixin( new IconElement( $this, $config ) ); + $this->mixin( new IndicatorElement( $this, $config ) ); + $this->mixin( new LabelElement( $this, $config ) ); + $this->mixin( new TitledElement( $this, + array_merge( $config, array( 'titled' => $this->button ) ) ) ); + $this->mixin( new FlaggedElement( $this, $config ) ); + $this->mixin( new TabIndexedElement( $this, + array_merge( $config, array( 'tabIndexed' => $this->button ) ) ) ); + + // Initialization + $this->button->appendContent( $this->icon, $this->label, $this->indicator ); + $this + ->addClasses( array( 'oo-ui-buttonWidget' ) ) + ->appendContent( $this->button ); + + $this->setHref( isset( $config['href'] ) ? $config['href'] : null ); + $this->setTarget( isset( $config['target'] ) ? $config['target'] : null ); + $this->setNoFollow( isset( $config['noFollow'] ) ? $config['noFollow'] : true ); + } + + /** + * Get hyperlink location. + * + * @return string Hyperlink location + */ + public function getHref() { + return $this->href; + } + + /** + * Get hyperlink target. + * + * @return string Hyperlink target + */ + public function getTarget() { + return $this->target; + } + + /** + * Get search engine traversal hint. + * + * @return boolean Whether search engines should avoid traversing this hyperlink + */ + public function getNoFollow() { + return $this->noFollow; + } + + /** + * Set hyperlink location. + * + * @param string|null $href Hyperlink location, null to remove + */ + public function setHref( $href ) { + $this->href = is_string( $href ) ? $href : null; + + $this->updateHref(); + + return $this; + } + + /** + * Update the href attribute, in case of changes to href or disabled + * state. + * + * @chainable + */ + public function updateHref() { + if ( $this->href !== null && !$this->isDisabled() ) { + $this->button->setAttributes( array( 'href' => $this->href ) ); + } else { + $this->button->removeAttributes( array( 'href' ) ); + } + return $this; + } + + /** + * Set hyperlink target. + * + * @param string|null $target Hyperlink target, null to remove + */ + public function setTarget( $target ) { + $this->target = is_string( $target ) ? $target : null; + + if ( $this->target !== null ) { + $this->button->setAttributes( array( 'target' => $target ) ); + } else { + $this->button->removeAttributes( array( 'target' ) ); + } + + return $this; + } + + /** + * Set search engine traversal hint. + * + * @param boolean $noFollow True if search engines should avoid traversing this hyperlink + */ + public function setNoFollow( $noFollow ) { + $this->noFollow = is_bool( $noFollow ) ? $noFollow : true; + + if ( $this->noFollow ) { + $this->button->setAttributes( array( 'rel' => 'nofollow' ) ); + } else { + $this->button->removeAttributes( array( 'rel' ) ); + } + + return $this; + } + + public function getConfig( &$config ) { + if ( $this->href !== null ) { + $config['href'] = $this->href; + } + if ( $this->target !== null ) { + $config['target'] = $this->target; + } + if ( $this->noFollow !== true ) { + $config['noFollow'] = $this->noFollow; + } + return parent::getConfig( $config ); + } +} -- cgit v1.2.3-54-g00ecf