confirm profile loading for existing accounts
This commit is contained in:
parent
b32c965786
commit
e930b134d7
|
@ -831,6 +831,8 @@ class htmlButton extends htmlElement {
|
|||
private $iconClass = null;
|
||||
/** onclick event */
|
||||
private $onClick = null;
|
||||
/** button type (default: "submit" if no onClick and "button" with onClick) */
|
||||
private $type = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -889,10 +891,17 @@ class htmlButton extends htmlElement {
|
|||
if (!$this->isEnabled) {
|
||||
$disabled = ' disabled';
|
||||
}
|
||||
$type = ' type="submit"';
|
||||
if ($this->type == null) {
|
||||
$type = ' type="submit"';
|
||||
}
|
||||
else {
|
||||
$type = ' type="' . $this->type . '"';
|
||||
}
|
||||
$onClick = '';
|
||||
if ($this->onClick != null) {
|
||||
$type = ' type="button"';
|
||||
if ($this->type == null) {
|
||||
$type = ' type="button"';
|
||||
}
|
||||
$onClick = ' onclick="' . $this->onClick . '"';
|
||||
}
|
||||
$id = ' id="btn_' . preg_replace('/[^a-zA-Z0-9_-]/', '', $this->name) . '"';
|
||||
|
@ -951,7 +960,13 @@ class htmlButton extends htmlElement {
|
|||
$this->onClick = $onClick;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows to override the default button type ("submit" if no onClick and "button" with onClick).
|
||||
*/
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1212,6 +1212,10 @@ class accountContainer {
|
|||
$rightGroup->addElement(new htmlSelect('accountContainerSelectLoadProfile', $profilelist, array($this->lastLoadedProfile)));
|
||||
$profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile'));
|
||||
$profileButton->setIconClass('loadProfileButton');
|
||||
if (!$this->isNewAccount) {
|
||||
$profileButton->setType('submit');
|
||||
$profileButton->setOnClick('confirmOrStopProcessing(\'' . _('This may overwrite existing values with profile data. Continue?') . '\', event);');
|
||||
}
|
||||
$rightGroup->addElement($profileButton);
|
||||
$rightGroup->addElement(new htmlSpacer('1px', null));
|
||||
$rightGroup->addElement(new htmlHelpLink('401'));
|
||||
|
|
|
@ -322,6 +322,26 @@ function showConfirmationDialog(title, okText, cancelText, dialogDiv, formName,
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a simple confirmation dialog.
|
||||
* If the user presses Cancel then the current action is stopped (event.preventDefault()).
|
||||
*
|
||||
* @param text dialog text
|
||||
* @param e event
|
||||
*/
|
||||
function confirmOrStopProcessing(text, e) {
|
||||
if (!confirm(text)) {
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.returnValue) {
|
||||
e.returnValue = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alines the elements with the given IDs to the same width.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue