added onClick() for button
This commit is contained in:
parent
403874b530
commit
d1b0394695
|
@ -641,6 +641,8 @@ class htmlButton extends htmlElement {
|
||||||
private $isEnabled = true;
|
private $isEnabled = true;
|
||||||
/** icon class (CSS) for buttons with icon + text */
|
/** icon class (CSS) for buttons with icon + text */
|
||||||
private $iconClass = null;
|
private $iconClass = null;
|
||||||
|
/** onclick event */
|
||||||
|
private $onClick = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -672,6 +674,8 @@ class htmlButton extends htmlElement {
|
||||||
logNewMessage(LOG_ERR, 'Meta HTML: Requested button in restricted mode.');
|
logNewMessage(LOG_ERR, 'Meta HTML: Requested button in restricted mode.');
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
$fieldTabIndex = ' tabindex="' . $tabindex . '"';
|
||||||
|
$tabindex++;
|
||||||
$style = '';
|
$style = '';
|
||||||
$class = '';
|
$class = '';
|
||||||
$title = '';
|
$title = '';
|
||||||
|
@ -692,11 +696,17 @@ class htmlButton extends htmlElement {
|
||||||
if (!$this->isEnabled) {
|
if (!$this->isEnabled) {
|
||||||
$disabled = ' disabled';
|
$disabled = ' disabled';
|
||||||
}
|
}
|
||||||
|
$type = ' type="submit"';
|
||||||
|
$onClick = '';
|
||||||
|
if ($this->onClick != null) {
|
||||||
|
$type = ' type="button"';
|
||||||
|
$onClick = ' onclick="' . $this->onClick . '"';
|
||||||
|
}
|
||||||
if ($this->isImageButton) {
|
if ($this->isImageButton) {
|
||||||
echo '<input type="submit" id="btn_' . $this->name . '" value=" "' . $name . $style . $class . $title . $disabled . '>';
|
echo '<input type="submit" id="btn_' . $this->name . '" value=" "' . $name . $fieldTabIndex . $style . $class . $title . $disabled . '>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<button id="btn_' . $this->name . '"' . $name . $style . $class . $title . $disabled . '>' . $this->value . '</button>';
|
echo '<button id="btn_' . $this->name . '"' . $name . $fieldTabIndex . $type . $onClick . $style . $class . $title . $disabled . '>' . $this->value . '</button>';
|
||||||
// text buttons get JQuery style
|
// text buttons get JQuery style
|
||||||
$icon = '';
|
$icon = '';
|
||||||
if ($this->iconClass != null) {
|
if ($this->iconClass != null) {
|
||||||
|
@ -739,6 +749,17 @@ class htmlButton extends htmlElement {
|
||||||
$this->iconClass = htmlspecialchars($iconClass);
|
$this->iconClass = htmlspecialchars($iconClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the onclick event code.
|
||||||
|
* This makes this button a simple button that does not submit a form.
|
||||||
|
*
|
||||||
|
* @param String $onClick JS code
|
||||||
|
*/
|
||||||
|
public function setOnClick($onClick) {
|
||||||
|
$this->onClick = $onClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue