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. 41
      main/inc/lib/display.lib.php

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

@ -2389,39 +2389,32 @@ class Display
} }
/** /**
* @param int $id * @param string $id
* @param array $content * @param array $content
* @param int $col * @param array $cols Optional. Columns width
* @param bool|true $right
* @return string * @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; $col = count($content);
$html = '';
$html .= '<div id="' . $id . '" class="actions">'; $html = '<div id="'.$id.'" class="actions">';
$html .= '<div class="row">'; $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++) { for ($i = 0; $i < $col; $i++) {
$html .= '<div class="col-md-' . $columns . '">'; $class = 'col-sm-'.$cols[$i];
if ($col == 2 && $i == 1) {
if ($right === true) { if ($col > 1) {
$html .= '<div class="pull-right">'; if ($i > 0 && $i < count($content) -1) {
$html .= (isset($content[$i]) ? $content[$i] : ''); $class .= ' text-center';
$html .= '</div>'; } elseif ($i === count($content) - 1) {
} else { $class .= ' text-right';
$html .= $content[$i];
}
} else {
$html .= $content[$i];
} }
$html .= '</div>';
} }
$html .= '<div class="'.$class.'">'.$content[$i].'</div>';
} }
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';

Loading…
Cancel
Save