onclick for span
This commit is contained in:
parent
e8d421ae04
commit
9936c834db
|
@ -3644,6 +3644,8 @@ class htmlSpan extends htmlElement {
|
||||||
|
|
||||||
/** htmlElement that generates inner content */
|
/** htmlElement that generates inner content */
|
||||||
private $content = null;
|
private $content = null;
|
||||||
|
/** onclick handler */
|
||||||
|
private $onclick = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -3674,13 +3676,27 @@ class htmlSpan extends htmlElement {
|
||||||
if (($this->cssClasses != null) && (sizeof($this->cssClasses) > 0)) {
|
if (($this->cssClasses != null) && (sizeof($this->cssClasses) > 0)) {
|
||||||
$classesValue = ' class="' . implode(' ', $this->cssClasses) . '"';
|
$classesValue = ' class="' . implode(' ', $this->cssClasses) . '"';
|
||||||
}
|
}
|
||||||
echo '<span' . $classesValue . '>';
|
$onclickHandler = '';
|
||||||
|
if (!empty($this->onclick)) {
|
||||||
|
$onclickHandler = ' onclick="' . $this->onclick . '"';
|
||||||
|
}
|
||||||
|
echo '<span' . $classesValue . $onclickHandler . '>';
|
||||||
if ($this->content != null) {
|
if ($this->content != null) {
|
||||||
$return = $this->content->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
$return = $this->content->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
||||||
}
|
}
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the onclick event.
|
||||||
|
*
|
||||||
|
* @param string $event event handler code
|
||||||
|
*/
|
||||||
|
public function setOnclick($event) {
|
||||||
|
$this->onclick = $event;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4715,6 +4731,8 @@ class htmlResponsiveInputCheckbox extends htmlInputCheckbox {
|
||||||
private $renderParentHtml = false;
|
private $renderParentHtml = false;
|
||||||
/** long label */
|
/** long label */
|
||||||
private $longLabel = false;
|
private $longLabel = false;
|
||||||
|
/** label after checkbox */
|
||||||
|
private $labelAfterCheckbox = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -4751,14 +4769,23 @@ class htmlResponsiveInputCheckbox extends htmlInputCheckbox {
|
||||||
$row = new htmlResponsiveRow();
|
$row = new htmlResponsiveRow();
|
||||||
$tabletColumnsLabel = 6;
|
$tabletColumnsLabel = 6;
|
||||||
$tabletColumnsBox = 6;
|
$tabletColumnsBox = 6;
|
||||||
|
$mobileColumnsLabel = 10;
|
||||||
|
$mobileColumnsBox = 2;
|
||||||
if ($this->longLabel) {
|
if ($this->longLabel) {
|
||||||
$tabletColumnsLabel = 10;
|
$tabletColumnsLabel = 10;
|
||||||
$tabletColumnsBox = 2;
|
$tabletColumnsBox = 2;
|
||||||
}
|
}
|
||||||
|
if ($this->labelAfterCheckbox) {
|
||||||
|
$tmp = $mobileColumnsLabel;
|
||||||
|
$mobileColumnsLabel = $mobileColumnsLabel;
|
||||||
|
$mobileColumnsBox = $mobileColumnsLabel;
|
||||||
|
$tmp = $tabletColumnsLabel;
|
||||||
|
$tabletColumnsLabel = $tabletColumnsBox;
|
||||||
|
$tabletColumnsBox = $tabletColumnsLabel;
|
||||||
|
}
|
||||||
// label text
|
// label text
|
||||||
$labelGroup = new htmlGroup();
|
$text = new htmlSpan(new htmlOutputText($this->label));
|
||||||
$labelGroup->addElement(new htmlOutputText($this->label));
|
$text->setOnclick('jQuery(\'#' . $this->name . '\').prop(\'checked\',!jQuery(\'#' . $this->name . '\').prop(\'checked\')); jQuery(\'#' . $this->name . '\').change();');
|
||||||
$row->add($labelGroup, 10, $tabletColumnsLabel, $tabletColumnsLabel, 'responsiveLabel');
|
|
||||||
// input field
|
// input field
|
||||||
$fieldGroup = new htmlGroup();
|
$fieldGroup = new htmlGroup();
|
||||||
$fieldGroup->addElement($this);
|
$fieldGroup->addElement($this);
|
||||||
|
@ -4767,7 +4794,14 @@ class htmlResponsiveInputCheckbox extends htmlInputCheckbox {
|
||||||
$helpLink->setCSSClasses(array('margin-left5 align-unset-img'));
|
$helpLink->setCSSClasses(array('margin-left5 align-unset-img'));
|
||||||
$fieldGroup->addElement($helpLink);
|
$fieldGroup->addElement($helpLink);
|
||||||
}
|
}
|
||||||
$row->add($fieldGroup, 2, $tabletColumnsBox, $tabletColumnsBox, 'responsiveField nowrap');
|
if ($this->labelAfterCheckbox) {
|
||||||
|
$row->add($fieldGroup, $mobileColumnsBox, $tabletColumnsBox, $tabletColumnsBox, 'responsiveLabel nowrap');
|
||||||
|
$row->add($text, $mobileColumnsLabel, $tabletColumnsLabel, $tabletColumnsLabel, 'responsiveField');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$row->add($text, $mobileColumnsLabel, $tabletColumnsLabel, $tabletColumnsLabel, 'responsiveLabel');
|
||||||
|
$row->add($fieldGroup, $mobileColumnsBox, $tabletColumnsBox, $tabletColumnsBox, 'responsiveField nowrap');
|
||||||
|
}
|
||||||
return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4779,6 +4813,15 @@ class htmlResponsiveInputCheckbox extends htmlInputCheckbox {
|
||||||
return '.row';
|
return '.row';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the label should be shown after the checkbox instead before it.
|
||||||
|
*
|
||||||
|
* @param bool $labelAfterCheckbox show label after box
|
||||||
|
*/
|
||||||
|
public function setLabelAfterCheckbox($labelAfterCheckbox = true) {
|
||||||
|
$this->labelAfterCheckbox = $labelAfterCheckbox;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue