Path: blob/master/src/view/phui/PHUISegmentBarSegmentView.php
12249 views
<?php12final class PHUISegmentBarSegmentView extends AphrontTagView {34private $width;5private $color;6private $position;7private $tooltip;89public function setWidth($width) {10$this->width = $width;11return $this;12}1314public function getWidth() {15return $this->width;16}1718public function setColor($color) {19$this->color = $color;20return $this;21}2223public function setPosition($position) {24$this->position = $position;25return $this;26}2728public function setTooltip($tooltip) {29$this->tooltip = $tooltip;30return $this;31}3233protected function canAppendChild() {34return false;35}3637protected function getTagAttributes() {38$classes = array(39'phui-segment-bar-segment-view',40);4142if ($this->color) {43$classes[] = $this->color;44}4546// Convert width to a percentage, and round it up slightly so that bars47// are full if they have, e.g., three segments at 1/3 + 1/3 + 1/3.48$width = 100 * $this->width;49$width = ceil(100 * $width) / 100;50$width = sprintf('%.2f%%', $width);5152$left = 100 * $this->position;53$left = floor(100 * $left) / 100;54$left = sprintf('%.2f%%', $left);5556$tooltip = $this->tooltip;57if (strlen($tooltip)) {58Javelin::initBehavior('phabricator-tooltips');5960$sigil = 'has-tooltip';61$meta = array(62'tip' => $tooltip,63'align' => 'E',64);65} else {66$sigil = null;67$meta = null;68}6970return array(71'class' => implode(' ', $classes),72'style' => "left: {$left}; width: {$width};",73'sigil' => $sigil,74'meta' => $meta,75);76}7778}798081