2014-02-10 20:11:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIButtonBarView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $buttons = array();
|
2015-06-29 23:42:29 +02:00
|
|
|
private $borderless;
|
2014-02-10 20:11:36 +01:00
|
|
|
|
|
|
|
public function addButton($button) {
|
|
|
|
$this->buttons[] = $button;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-06-29 23:42:29 +02:00
|
|
|
public function setBorderless($borderless) {
|
|
|
|
$this->borderless = $borderless;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-02-10 20:11:36 +01:00
|
|
|
protected function getTagAttributes() {
|
2015-06-29 23:42:29 +02:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-button-bar';
|
|
|
|
if ($this->borderless) {
|
|
|
|
$classes[] = 'phui-button-bar-borderless';
|
|
|
|
}
|
|
|
|
return array('class' => implode(' ', $classes));
|
2014-02-10 20:11:36 +01:00
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagName() {
|
2015-03-28 00:00:09 +01:00
|
|
|
return 'span';
|
2014-02-10 20:11:36 +01:00
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagContent() {
|
2014-02-10 20:11:36 +01:00
|
|
|
require_celerity_resource('phui-button-css');
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
$j = count($this->buttons);
|
|
|
|
foreach ($this->buttons as $button) {
|
|
|
|
// LeeLoo Dallas Multi-Pass
|
|
|
|
if ($j > 1) {
|
|
|
|
if ($i == 1) {
|
|
|
|
$button->addClass('phui-button-bar-first');
|
2014-06-09 20:36:49 +02:00
|
|
|
} else if ($i == $j) {
|
2014-02-10 20:11:36 +01:00
|
|
|
$button->addClass('phui-button-bar-last');
|
2014-06-09 20:36:49 +02:00
|
|
|
} else if ($j > 1) {
|
2014-02-10 20:11:36 +01:00
|
|
|
$button->addClass('phui-button-bar-middle');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->appendChild($button);
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->renderChildren();
|
|
|
|
}
|
|
|
|
}
|