add new methods getModelBox() and getModelBoxLink()

This commit is contained in:
Uwe Steinmann 2020-10-22 12:30:49 +02:00
parent 27d85cd156
commit 16836bf283

View File

@ -1089,6 +1089,53 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
}
} /* }}} */
/**
* Get html for button opening a modal box
*
* @param array $config contains elements
* target: id of modal box
* remote: URL of data to be loaded into box
* title: text on button
* @return string
*/
function getModalBoxLink($config) { /* {{{ */
$content = '';
$content .= "<a data-target=\"#".$config['target']."\" href=\"".$config['remote']."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".$config['title']."…</a>\n";
return $content;
} /* }}} */
/**
* Get html for a modal box with buttons
*
* @param array $config contains elements
* id: id of modal box (must match target of getModalBoxLink())
* title: title of modal box
* buttons: array of buttons, each having a title and an optional id
* @return string
*/
function getModalBox($config) { /* {{{ */
$content = '
<div class="modal hide" id="'.$config['id'].'" tabindex="-1" role="dialog" aria-labelledby="'.$config['id'].'Label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="'.$config['id'].'Label">'.$config['title'].'</h3>
</div>
<div class="modal-body">
<p>'.getMLText('tree_loading').'</p>
</div>
<div class="modal-footer">
';
if($config['buttons']) {
foreach($config['buttons'] as $button)
$content .= '<button class="btn" '.(!empty($button['id']) ? 'id="'.$button['id'].'"': '').'data-dismiss="modal" aria-hidden="true">'.$button['title'].'</button>';
}
$content .= '
</div>
</div>
';
return $content;
} /* }}} */
function printFileChooserJs() { /* {{{ */
?>
$(document).ready(function() {