Improve Display::toolbarAction

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent c141b4a803
commit 48202b086e
  1. 11
      app/Resources/public/css/base.css
  2. 43
      main/inc/lib/display.lib.php

@ -498,6 +498,9 @@ header{
.actions a:hover{
text-decoration: none;
}
.actions div.text-right {
text-align: left;
}
.actions img{
padding: 3px;
border: 1px solid #dcdcdc;
@ -6586,7 +6589,13 @@ input.form-control[type="color"] {
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
.actions div.text-right{
text-align: right;
}
.actions .row .text-right a{
margin-left: 10px;
margin-right: 0;
}
}
/* Medium devices (desktops, 992px and up) */

@ -2389,39 +2389,32 @@ class Display
}
/**
* @param int $id
* @param string $id
* @param array $content
* @param int $col
* @param bool|true $right
* @param array $cols Optional. Columns width
* @return string
*/
public static function toolbarAction($id, $content = array(), $col = 2, $right = true)
public static function toolbarAction($id, $content, $cols = [6, 6])
{
$columns = 12/$col;
$html = '';
$html .= '<div id="' . $id . '" class="actions">';
$col = count($content);
$html = '<div id="'.$id.'" class="actions">';
$html .= '<div class="row">';
if ($col > 4) {
$html = '<div class="alert alert-warning" role="alert">
Action toolbar design does not work when exceeding four columns - check Display::toolbarAction()
</div>';
} else {
for ($i = 0; $i < $col; $i++) {
$html .= '<div class="col-md-' . $columns . '">';
if ($col == 2 && $i == 1) {
if ($right === true) {
$html .= '<div class="pull-right">';
$html .= (isset($content[$i]) ? $content[$i] : '');
$html .= '</div>';
} else {
$html .= $content[$i];
}
} else {
$html .= $content[$i];
for ($i = 0; $i < $col; $i++) {
$class = 'col-sm-'.$cols[$i];
if ($col > 1) {
if ($i > 0 && $i < count($content) -1) {
$class .= ' text-center';
} elseif ($i === count($content) - 1) {
$class .= ' text-right';
}
$html .= '</div>';
}
$html .= '<div class="'.$class.'">'.$content[$i].'</div>';
}
$html .= '</div>';
$html .= '</div>';

Loading…
Cancel
Save