} else {
newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
}
+
+ if (placeholder.tooltip) {
+ newElement.attr('title', placeholder.tooltip);
+ }
+
highlightInput(newElement);
$td.append(newElement);
return newElement;
/** @var string human-readable parameter text */
private $text;
+ /** @var string human-readable parameter tooltip */
+ private $tooltip = '';
+
/** @var int value type, see self::VALUE_* constants */
private $type = self::VALUE_TEXT;
return (bool)($this->flags & $flag);
}
+ /**
+ * @return string
+ */
+ public function getTooltip(): string {
+ return $this->tooltip;
+ }
+
+ /**
+ * @param string $tooltip
+ * @return self
+ */
+ public function setTooltip(string $tooltip) {
+ $this->tooltip = $tooltip;
+ return $this;
+ }
+
/**
* Serialize into JSON for client-side JS
*
return [
'value' => $this->getText(),
'flags' => $this->getFlags(),
- 'type' => $this->getType()
+ 'type' => $this->getType(),
+ 'tooltip' => $this->getTooltip(),
];
}
$this->assertEquals([
'value' => 'bar',
'flags' => 0,
- 'type' => 0
+ 'type' => 0,
+ 'tooltip' => '',
], $param->jsonSerialize());
$param->setType(Param::VALUE_BOOLEAN);
$this->assertEquals([
'value' => 'bar',
'flags' => 0,
- 'type' => Param::VALUE_BOOLEAN
+ 'type' => Param::VALUE_BOOLEAN,
+ 'tooltip' => '',
], $param->jsonSerialize());
$param->setType(Param::VALUE_PASSWORD);
$this->assertEquals([
'value' => 'bar',
'flags' => Param::FLAG_OPTIONAL,
- 'type' => Param::VALUE_PASSWORD
+ 'type' => Param::VALUE_PASSWORD,
+ 'tooltip' => '',
], $param->jsonSerialize());
$param->setType(Param::VALUE_HIDDEN);
$this->assertEquals([
'value' => 'bar',
'flags' => Param::FLAG_NONE,
- 'type' => Param::VALUE_HIDDEN
+ 'type' => Param::VALUE_HIDDEN,
+ 'tooltip' => '',
], $param->jsonSerialize());
}