Button class updates, logic updates to other files.

This commit is contained in:
Nate 2019-10-23 21:19:37 -06:00
parent df8d0d3ebb
commit ea536d2f6e
8 changed files with 161 additions and 46 deletions

View File

@ -123,10 +123,10 @@
if (permission_exists('access_control_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'access_control_edit.php']);
}
if (permission_exists('access_control_add')) {
if (permission_exists('access_control_add') && $access_controls) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('access_control_delete')) {
if (permission_exists('access_control_delete') && $access_controls) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
@ -148,9 +148,11 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' value='' onclick='list_all_toggle();'>\n";
echo " </th>\n";
if (permission_exists('access_control_add') || permission_exists('access_control_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($access_controls ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('access_control_name', $text['label-access_control_name'], $order_by, $order);
echo th_order_by('access_control_default', $text['label-access_control_default'], $order_by, $order);
echo th_order_by('access_control_description', $text['label-access_control_description'], $order_by, $order, null, "class='hide-xs'");
@ -166,10 +168,12 @@
$list_row_url = "access_control_edit.php?id=".urlencode($row['access_control_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='access_controls[".$x."][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='access_controls[".$x."][uuid]' value='".escape($row['access_control_uuid'])."' />\n";
echo " </td>\n";
if (permission_exists('access_control_add') || permission_exists('access_control_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='access_controls[".$x."][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='access_controls[".$x."][uuid]' value='".escape($row['access_control_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td><a href='".$list_row_url."'>".escape($row['access_control_name'])."</a></td>\n";
echo " <td>".escape($row['access_control_default'])."</td>\n";
echo " <td class='description overflow hide-xs'>".escape($row['access_control_description'])."</td>\n";

View File

@ -147,13 +147,13 @@
if (permission_exists('bridge_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'bridge_edit.php']);
}
if (permission_exists('bridge_add')) {
if (permission_exists('bridge_add') && $bridges) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('bridge_edit')) {
if (permission_exists('bridge_edit') && $bridges) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('bridge_delete')) {
if (permission_exists('bridge_delete') && $bridges) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('bridge_all')) {
@ -183,9 +183,11 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' value='' onclick='list_all_toggle();'>\n";
echo " </th>\n";
if (permission_exists('bridge_add') || permission_exists('bridge_edit') || permission_exists('bridge_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($bridges ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($_GET['show'] == "all" && permission_exists('bridge_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
@ -205,10 +207,12 @@
$list_row_url = "bridge_edit.php?id=".urlencode($row['bridge_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='bridges[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='bridges[$x][uuid]' value='".escape($row['bridge_uuid'])."' />\n";
echo " </td>\n";
if (permission_exists('bridge_add') || permission_exists('bridge_edit') || permission_exists('bridge_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='bridges[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='bridges[$x][uuid]' value='".escape($row['bridge_uuid'])."' />\n";
echo " </td>\n";
}
if ($_GET['show'] == "all" && permission_exists('bridge_all')) {
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
}
@ -221,8 +225,14 @@
}
echo " </td>\n";
echo " <td>".escape($row['bridge_destination'])."</td>\n";
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['bridge_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
if (permission_exists('bridge_edit')) {
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['bridge_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>";
echo $text['label-'.$row['bridge_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['bridge_description'])."</td>\n";
if (permission_exists('bridge_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {

View File

@ -138,13 +138,13 @@
if (permission_exists('call_block_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'call_block_edit.php']);
}
if (permission_exists('call_block_add')) {
if (permission_exists('call_block_add') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('call_block_edit')) {
if (permission_exists('call_block_edit') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('call_block_delete')) {
if (permission_exists('call_block_delete') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
@ -166,9 +166,11 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' value='' onclick='list_all_toggle();'>\n";
echo " </th>\n";
if (permission_exists('call_block_add') || permission_exists('call_block_edit') || permission_exists('call_block_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('call_block_number', $text['label-number'], $order_by, $order);
echo th_order_by('call_block_name', $text['label-name'], $order_by, $order);
echo th_order_by('call_block_count', $text['label-count'], $order_by, $order, '', "class='center'");
@ -188,10 +190,12 @@
$list_row_url = "call_block_edit.php?id=".urlencode($row['call_block_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_blocks[".$x."][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_blocks[".$x."][uuid]' value='".escape($row['call_block_uuid'])."' />\n";
echo " </td>\n";
if (permission_exists('call_block_add') || permission_exists('call_block_edit') || permission_exists('call_block_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_blocks[".$x."][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_blocks[".$x."][uuid]' value='".escape($row['call_block_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>";
if (permission_exists('call_block_edit')) {
echo "<a href='".$list_row_url."'>".escape($row['call_block_number'])."</a>";
@ -203,8 +207,14 @@
echo " <td>".escape($row['call_block_name'])."</td>\n";
echo " <td class='center'>".escape($row['call_block_count'])."</td>\n";
echo " <td>".escape($row['call_block_action'])."</td>\n";
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['call_block_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
if (permission_exists('call_block_edit')) {
echo " <td class='no-link center'>";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['call_block_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>";
echo $text['label-'.$row['call_block_enabled']];
}
echo " </td>\n";
echo " <td>".date("j M Y H:i:s".(defined('TIME_24HR') && TIME_24HR == 1 ? 'a' : null), $row['date_added'])."</td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['call_block_description'])."</td>\n";

View File

@ -153,9 +153,11 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' value='' onclick='list_all_toggle();'>\n";
echo " </th>\n";
if (permission_exists('call_broadcast_add') || permission_exists('call_broadcast_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('broadcast_name', $text['label-name'], $order_by, $order);
echo th_order_by('broadcast_concurrent_limit', $text['label-concurrent-limit'], $order_by, $order);
echo th_order_by('broadcast_description', $text['label-description'], $order_by, $order);
@ -171,10 +173,12 @@
$list_row_url = "call_broadcast_edit.php?id=".urlencode($row['call_broadcast_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_broadcasts[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_broadcasts[$x][uuid]' value='".escape($row['call_broadcast_uuid'])."' />\n";
echo " </td>\n";
if (permission_exists('call_broadcast_add') || permission_exists('call_broadcast_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_broadcasts[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_broadcasts[$x][uuid]' value='".escape($row['call_broadcast_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>";
if (permission_exists('call_broadcast_edit')) {
echo "<a href='".$list_row_url."'>".escape($row['broadcast_name'])."</a>";

View File

@ -478,9 +478,9 @@
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('xml_cdr_delete') && $result_count > 0) {
if (permission_exists('xml_cdr_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' value='' onclick='list_all_toggle();'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
$col_count++;
}

View File

@ -43,8 +43,9 @@ if (!class_exists('button')) {
$button .= "title=\"".($array['title'] ? $array['title'] : $array['label'])."\" ";
}
$button .= $array['onclick'] ? "onclick=\"".$array['onclick']."\" " : null;
$button .= "class='btn btn-".($array['class'] ? $array['class'] : 'default')."' ";
$button .= "class='btn btn-".($array['class'] ? $array['class'] : 'default')." ".($array['disabled'] ? 'disabled' : null)."' ";
$button .= "style='margin-left: 2px; margin-right: 2px; ".($array['style'] ? $array['style'] : null)."' ";
$button .= $array['disabled'] ? "disabled='disabled' " : null;
$button .= ">";
//icon
if ($array['icon'] && (
@ -77,7 +78,12 @@ if (!class_exists('button')) {
$button .= "</button>";
//link
if ($array['link']) {
$button = "<a href='".$array['link']."' target=\"".($array['target'] ? $array['target'] : '_self')."\">".$button."</a>";
$anchor = "<a ";
$anchor .= "href='".$array['link']."' ";
$anchor .= "target=\"".($array['target'] ? $array['target'] : '_self')."\" ";
$anchor .= ($array['disabled'] ? "class='disabled' onclick='return false;'" : null)." ";
$anchor .= ">";
$button = $anchor.$button."</a>";
}
return $button;
unset($button);
@ -87,9 +93,10 @@ if (!class_exists('button')) {
}
/*
//usage
echo button::create(['type'=>'button','label'=>$text['button-label'],'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'javascript','class'=>'name','style'=>'css','title'=>$text['button-label'],'collapse'=>'class']);
echo button::create(['type'=>'button','label'=>$text['button-label'],'icon'=>'icon','name'=>'btn','id'=>'btn','value'=>'value','link'=>'url','target'=>'_blank','onclick'=>'javascript','class'=>'name','style'=>'css','title'=>$text['button-label'],'collapse'=>'class','disabled'=>false]);
echo button::create([
'type'=>'button',
@ -104,9 +111,11 @@ if (!class_exists('button')) {
'class'=>'name',
'style'=>'css',
'title'=>$text['button-label'],
'collapse'=>'class'
'collapse'=>'class',
'disabled'=>false
]);
//options
type 'button' (default) | 'submit' | 'link'
@ -119,6 +128,8 @@ if (!class_exists('button')) {
style css style[s]
title tooltip text (if not set, defaults to value of label)
collapse overide the default hide class ('hide-md-dn')
disabled boolean true/false, or a value that evaluates to a boolean
//notes
@ -129,6 +140,52 @@ if (!class_exists('button')) {
3) setting either collapse (instance or default) to false (boolean) will cause the button label to always be visible
//example: enable/disable buttons with javascript
//javascript
onclick='button_enable('disabled_button');
//button
echo button::create(['type'=>'button', ... ,'id'=>'disabled_button','disabled'=>true]);
//javascript
onclick='button_disable('enabled_button');
//button
echo button::create(['type'=>'button', ... ,'id'=>'enabled_button']);
//enable button class button
echo "<script>\n";
echo " function button_enable(button_id) {\n";
echo " button = document.getElementById(button_id);\n";
echo " button.disabled = false;\n";
echo " button.classList.remove('disabled');\n";
echo " if (button.parentElement.nodeName == 'A') {\n";
echo " anchor = button.parentElement;\n";
echo " anchor.classList.remove('disabled');\n";
echo " anchor.setAttribute('onclick','');\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
//disable button class button
echo "<script>\n";
echo " function button_disable(button_id) {\n";
echo " button = document.getElementById(button_id);\n";
echo " button.disabled = true;\n";
echo " button.classList.add('disabled');\n";
echo " if (button.parentElement.nodeName == 'A') {\n";
echo " anchor = button.parentElement;\n";
echo " anchor.classList.add('disabled');\n";
echo " anchor.setAttribute('onclick','return false;');\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
//note: the javascript functions above are already contained in the template.php file.
*/
?>

View File

@ -712,6 +712,12 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false;
}
<?php } ?>
a.disabled,
button.btn.disabled {
outline: none; /* hides the dotted outline of the anchor tag on focus/active */
cursor: default;
}
/* BREAKPOINTS ****************************************************************/
/* screens = extra small */

View File

@ -387,6 +387,30 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
}
}
//enable button class button
function button_enable(button_id) {
button = document.getElementById(button_id);
button.disabled = false;
button.classList.remove('disabled');
if (button.parentElement.nodeName == 'A') {
anchor = button.parentElement;
anchor.classList.remove('disabled');
anchor.setAttribute('onclick','');
}
}
//disable button class button
function button_disable(button_id) {
button = document.getElementById(button_id);
button.disabled = true;
button.classList.add('disabled');
if (button.parentElement.nodeName == 'A') {
anchor = button.parentElement;
anchor.classList.add('disabled');
anchor.setAttribute('onclick','return false;');
}
}
//list functions
function list_all_toggle() {
var inputs = document.getElementsByTagName('input');