本文整理汇总了PHP中Tag::addClasses方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::addClasses方法的具体用法?PHP Tag::addClasses怎么用?PHP Tag::addClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::addClasses方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param array $config Configuration options
* @param string $config['name'] HTML input name (default: '')
* @param string $config['value'] Input value (default: '')
* @param string $config['dir'] The directionality of the input (ltr/rtl)
*/
public function __construct(array $config = [])
{
// Parent constructor
parent::__construct($config);
// Properties
$this->input = $this->getInputElement($config);
// Traits
$this->initializeFlaggedElement(array_merge($config, ['flagged' => $this]));
$this->initializeTabIndexedElement(array_merge($config, ['tabIndexed' => $this->input]));
$this->initializeTitledElement(array_merge($config, ['titled' => $this->input]));
$this->initializeAccessKeyedElement(array_merge($config, ['accessKeyed' => $this->input]));
// Initialization
if (isset($config['name'])) {
$this->input->setAttributes(['name' => $config['name']]);
}
if ($this->isDisabled()) {
$this->input->setAttributes(['disabled' => 'disabled']);
}
$this->addClasses(['oo-ui-inputWidget'])->appendContent($this->input);
$this->input->addClasses(['oo-ui-inputWidget-input']);
$this->setValue(isset($config['value']) ? $config['value'] : null);
if (isset($config['dir'])) {
$this->setDir($config['dir']);
}
}
示例2: __construct
/**
* @param array $config Configuration options
* @param bool|int $config['progress'] The type of progress bar (determinate or indeterminate).
* To create a determinate progress bar,specify a number
* that reflects the initial percent complete.
* By default, the progress bar is indeterminate.
*/
public function __construct(array $config = [])
{
parent::__construct($config);
$this->bar = new Tag('div');
$this->bar->addClasses(['oo-ui-progressBarWidget-bar']);
$this->setProgress(array_key_exists('progress', $config) ? $config['progress'] : false);
$this->setAttributes(['role' => 'progressbar', 'aria-valuemin' => 0, 'aria-valuemax' => 100])->addClasses(['oo-ui-progressBarWidget'])->appendContent($this->bar);
}
示例3: setRTL
/**
* Sets the direction of the current input, either RTL or LTR
*
* @param boolean $isRTL
*/
public function setRTL($isRTL)
{
if ($isRTL) {
$this->input->removeClasses(array('oo-ui-ltr'));
$this->input->addClasses(array('oo-ui-rtl'));
} else {
$this->input->removeClasses(array('oo-ui-rtl'));
$this->input->addClasses(array('oo-ui-ltr'));
}
}
示例4: setIcon
/**
* Set icon name.
*
* @param string|null $icon Symbolic icon name
* @return $this
*/
public function setIcon($icon = null)
{
if ($this->iconName !== null) {
$this->icon->removeClasses(['oo-ui-icon-' . $this->iconName]);
}
if ($icon !== null) {
$this->icon->addClasses(['oo-ui-icon-' . $icon]);
}
$this->iconName = $icon;
$this->toggleClasses(['oo-ui-iconElement'], (bool) $this->iconName);
return $this;
}
示例5: setIndicator
/**
* Set indicator name.
*
* @param string|null $indicator Symbolic name of indicator to use or null for no indicator
* @return $this
*/
public function setIndicator($indicator = null)
{
if ($this->indicatorName !== null) {
$this->indicator->removeClasses(['oo-ui-indicator-' . $this->indicatorName]);
}
if ($indicator !== null) {
$this->indicator->addClasses(['oo-ui-indicator-' . $indicator]);
}
$this->indicatorName = $indicator;
$this->toggleClasses(['oo-ui-indicatorElement'], (bool) $this->indicatorName);
return $this;
}
示例6: initializeLabelElement
/**
* @param array $config Configuration options
* @param string|HtmlSnippet $config['label'] Label text
*/
public function initializeLabelElement(array $config = [])
{
// Properties
// FIXME 'labelElement' is a very stupid way to call '$label'
$this->label = isset($config['labelElement']) ? $config['labelElement'] : new Tag('span');
// Initialization
$this->label->addClasses(['oo-ui-labelElement-label']);
$this->setLabel(isset($config['label']) ? $config['label'] : null);
$this->registerConfigCallback(function (&$config) {
if ($this->labelValue !== null) {
$config['label'] = $this->labelValue;
}
});
}
示例7: initializeButtonElement
/**
* @param array $config Configuration options
* @param boolean $config['framed'] Render button with a frame (default: true)
*/
public function initializeButtonElement(array $config = [])
{
// Properties
if (!$this instanceof Element) {
throw new Exception("ButtonElement trait can only be used on Element instances");
}
$target = isset($config['button']) ? $config['button'] : new Tag('a');
$this->button = $target;
// Initialization
$this->addClasses(['oo-ui-buttonElement']);
$this->button->addClasses(['oo-ui-buttonElement-button']);
$this->toggleFramed(isset($config['framed']) ? $config['framed'] : true);
// Add `role="button"` on `<a>` elements, where it's needed
if (strtolower($this->button->getTag()) === 'a') {
$this->button->setAttributes(['role' => 'button']);
}
$this->registerConfigCallback(function (&$config) {
if ($this->framed !== true) {
$config['framed'] = $this->framed;
}
});
}