Plugin position implemented, fix in pagination

This commit is contained in:
Diego Najar 2018-07-20 18:36:47 +02:00
parent 92a86c4fa7
commit 33c89e8bd7
11 changed files with 87 additions and 43 deletions

View File

@ -61,6 +61,10 @@ code {
color: #444; color: #444;
} }
.list-group-sortable {
cursor: pointer;
}
/* /*
LOGIN LOGIN
*/ */

View File

@ -28,6 +28,7 @@
'jquery-auto-complete.min.js', 'jquery-auto-complete.min.js',
'jquery.datetimepicker.full.min.js' 'jquery.datetimepicker.full.min.js'
), DOMAIN_ADMIN_THEME_JS); ), DOMAIN_ADMIN_THEME_JS);
echo Theme::jsSortable();
?> ?>
<!-- Plugins --> <!-- Plugins -->

View File

@ -344,4 +344,18 @@ EOF;
{ {
return '<input type="hidden" id="js'.$args['name'].'" name="'.$args['name'].'" value="'.$args['value'].'">'; return '<input type="hidden" id="js'.$args['name'].'" name="'.$args['name'].'" value="'.$args['value'].'">';
} }
public static function alert($args)
{
$class = 'alert';
if (!empty($args['class'])) {
$class = $class.' '.$args['class'];
}
$text = $args['text'];
return <<<EOF
<div class="$class" role="alert">$text</div>
EOF;
}
} }

View File

@ -165,7 +165,7 @@ function table($type) {
<ul class="pagination flex-wrap justify-content-center"> <ul class="pagination flex-wrap justify-content-center">
<!-- First button --> <!-- First button -->
<li class="page-item"> <li class="page-item <?php if (!Paginator::showPrev()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::firstPageUrl() ?>"><span class="align-middle oi oi-media-skip-backward"></span> <?php echo $Language->get('First'); ?></a> <a class="page-link" href="<?php echo Paginator::firstPageUrl() ?>"><span class="align-middle oi oi-media-skip-backward"></span> <?php echo $Language->get('First'); ?></a>
</li> </li>
@ -180,7 +180,7 @@ function table($type) {
</li> </li>
<!-- Last button --> <!-- Last button -->
<li class="page-item"> <li class="page-item <?php if (!Paginator::showNext()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::lastPageUrl() ?>"><?php echo $Language->get('Last'); ?> <span class="align-middle oi oi-media-skip-forward"></span></a> <a class="page-link" href="<?php echo Paginator::lastPageUrl() ?>"><?php echo $Language->get('Last'); ?> <span class="align-middle oi oi-media-skip-forward"></span></a>
</li> </li>

View File

@ -1,38 +1,53 @@
<?php <?php defined('BLUDIT') or die('Bludit CMS.');
HTML::title(array('title'=>$L->g('Plugins Position'), 'icon'=>'puzzle-piece')); echo Bootstrap::pageTitle(array('title'=>$L->g('Plugin position'), 'icon'=>'tags'));
echo '<div class="hint">'.$L->g('drag-and-drop-to-set-the-position-of-the-plugin').'</div>'; echo Bootstrap::alert(array('class'=>'alert-primary', 'text'=>$L->g('Drag and Drop to sort the plugins')));
echo '<form class="uk-form" method="post" action="" autocomplete="off">'; echo Bootstrap::formOpen(array('id'=>'jsform'));
HTML::formInputHidden(array( // Token CSRF
echo Bootstrap::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$security->getTokenCSRF() 'value'=>$security->getTokenCSRF()
)); ));
echo '<div class="uk-sortable" data-uk-sortable>'; echo Bootstrap::formInputHidden(array(
'name'=>'plugin-list',
'value'=>''
));
foreach ($plugins['siteSidebar'] as $Plugin) { echo '<ul class="list-group list-group-sortable">';
echo '<div class="plugin-position" data-plugin="'.$Plugin->className().'"><i class="uk-icon-bars"></i> '.$Plugin->name().'</div>'; foreach ($plugins['siteSidebar'] as $Plugin) {
} echo '<li class="list-group-item" data-plugin="'.$Plugin->className().'"><span class="oi oi-move"></span> '.$Plugin->name().'</li>';
}
echo '</ul>';
echo '
<div class="form-group mt-3">
<button type="button" class="jsbuttonSave btn btn-primary">'.$L->g('Save').'</button>
<a href="'.HTML_PATH_ADMIN_ROOT.'plugins" class="btn btn-secondary">'.$L->g('Cancel').'</a>
</div>
';
echo Bootstrap::formClose();
echo '</div>';
echo '<input id="plugin-list" name="plugin-list" type="text" value="" hidden/>';
echo '<button class="uk-button uk-button-primary" type="button" id="jsSave">'.$L->g('Save').'</button>';
echo '</form>';
?> ?>
<script> <script>
$( document ).ready(function() { $(document).ready(function() {
$("#jsSave").on("click", function() {
$('.list-group-sortable').sortable({
placeholderClass: 'list-group-item'
});
$(".jsbuttonSave").on("click", function() {
var tmp = []; var tmp = [];
$( "div.plugin-position" ).each(function() { $("li.list-group-item").each(function() {
tmp.push( $(this).attr("data-plugin") ); tmp.push( $(this).attr("data-plugin") );
}); });
console.log( tmp.join(",") ); $("#jsplugin-list").attr("value", tmp.join(",") );
$("#plugin-list").attr("value", tmp.join(",") ); $("#jsform").submit();
$(".uk-form").submit();
}); });
}); });
</script> </script>

View File

@ -257,6 +257,7 @@ function changePluginsPosition($pluginClassList) {
'notes'=>'' 'notes'=>''
)); ));
Alert::set($Language->g('The changes have been saved'));
return true; return true;
} }

View File

@ -205,6 +205,12 @@ class Theme {
{ {
return '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_CSS.'bootstrap.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL; return '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_CSS.'bootstrap.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL;
} }
public static function jsSortable()
{
// https://github.com/psfpro/bootstrap-html5sortable
return '<script charset="utf-8" src="'.DOMAIN_CORE_JS.'jquery.sortable.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
}
} }
?> ?>

1
bl-kernel/js/jquery.sortable.min.js vendored Executable file
View File

@ -0,0 +1 @@
(function(n){var t,i=n();n.fn.sortable=function(r){var u=String(r);return r=n.extend({connectWith:!1},r),this.each(function(){var o,s,h,e,f;if(/^enable|disable|destroy$/.test(u)){e=n(this).children(n(this).data("items")).attr("draggable",u=="enable");u=="destroy"&&e.add(this).removeData("connectWith items").off("dragstart.h5s dragend.h5s selectstart.h5s dragover.h5s dragenter.h5s drop.h5s");return}e=n(this).children(r.items);f=n("<"+(/^ul|ol$/i.test(this.tagName)?"li":/^tbody$/i.test(this.tagName)?"tr":"div")+' class="sortable-placeholder '+r.placeholderClass+'">').html("&nbsp;");e.find(r.handle).mousedown(function(){o=!0}).mouseup(function(){o=!1});n(this).data("items",r.items);i=i.add(f);r.connectWith&&n(r.connectWith).add(this).data("connectWith",r.connectWith);e.attr("draggable","true").on("dragstart.h5s",function(i){if(r.handle&&!o)return!1;o=!1;var u=i.originalEvent.dataTransfer;u.effectAllowed="move";u.setData("Text","dummy");h=(t=n(this)).addClass("sortable-dragging").index();s=t.parent()}).on("dragend.h5s",function(){t&&(t.removeClass("sortable-dragging").show(),i.detach(),h!=t.index()&&t.parent().trigger("sortupdate",{item:t}),t.parent().is(s)||t.parent().trigger("sortconnect",{item:t}),t=null)}).not("a[href], img").on("selectstart.h5s",function(){return this.dragDrop&&this.dragDrop(),!1}).end().add([this,f]).on("dragover.h5s dragenter.h5s drop.h5s",function(u){return!e.is(t)&&r.connectWith!==n(t).parent().data("connectWith")?!0:u.type=="drop"?(u.stopPropagation(),i.filter(":visible").after(t),t.trigger("dragend.h5s"),!1):(u.preventDefault(),u.originalEvent.dataTransfer.dropEffect="move",e.is(this)?(r.forcePlaceholderSize&&f.height(t.outerHeight()),t.hide(),n(this)[f.index()<n(this).index()?"after":"before"](f),i.not(f).detach()):i.is(this)||n(this).children(r.items).length||(i.detach(),n(this).append(f)),!1)})})}})(jQuery);

View File

@ -49,20 +49,20 @@
<ul class="pagination flex-wrap justify-content-center"> <ul class="pagination flex-wrap justify-content-center">
<!-- Previous button --> <!-- Previous button -->
<li class="page-item <?php if (!Paginator::showPrev()) echo 'disabled' ?>"> <li class="page-item mr-2 <?php if (!Paginator::showPrev()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1"><?php echo $Language->get('Previous'); ?></a> <a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1">&#9664; <?php echo $Language->get('Previous'); ?></a>
</li> </li>
<!-- List of pages --> <!-- Home button -->
<?php for ($i = 1; $i <= Paginator::amountOfPages(); $i++): ?> <?php if (Paginator::currentPage() > 1): ?>
<li class="page-item <?php if ($i==Paginator::currentPage()) echo 'active' ?>"> <li class="page-item">
<a class="page-link" href="<?php echo Paginator::numberUrl($i) ?>"><?php echo $i ?></a> <a class="page-link" href="<?php echo $site->url() ?>">Home</a>
</li> </li>
<?php endfor ?> <?php endif ?>
<!-- Next button --> <!-- Next button -->
<li class="page-item <?php if (!Paginator::showNext()) echo 'disabled' ?>"> <li class="page-item ml-2 <?php if (!Paginator::showNext()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $Language->get('Next'); ?></a> <a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $Language->get('Next'); ?> &#9658;</a>
</li> </li>
</ul> </ul>

View File

@ -41,24 +41,22 @@
<!-- Pagination --> <!-- Pagination -->
<?php if (Paginator::amountOfPages()>1): ?> <?php if (Paginator::amountOfPages()>1): ?>
<nav class="my-4" aria-label="Page navigation"> <nav class="paginator">
<ul class="pagination flex-wrap"> <ul class="pagination flex-wrap">
<!-- Previous button --> <!-- Previous button -->
<li class="page-item <?php if (!Paginator::showPrev()) echo 'disabled' ?>"> <li class="page-item mr-2 <?php if (!Paginator::showPrev()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1"><?php echo $Language->get('Previous'); ?></a> <a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1">&#9664; <?php echo $Language->get('Previous'); ?></a>
</li> </li>
<!-- List of pages --> <!-- Home button -->
<?php for ($i = 1; $i <= Paginator::amountOfPages(); $i++): ?> <li class="page-item <?php if (Paginator::currentPage()==1) echo 'disabled' ?>">
<li class="page-item <?php if ($i==Paginator::currentPage()) echo 'active' ?>"> <a class="page-link" href="<?php echo $site->url() ?>">Home</a>
<a class="page-link" href="<?php echo Paginator::numberUrl($i) ?>"><?php echo $i ?></a>
</li> </li>
<?php endfor ?>
<!-- Next button --> <!-- Next button -->
<li class="page-item <?php if (!Paginator::showNext()) echo 'disabled' ?>"> <li class="page-item ml-2 <?php if (!Paginator::showNext()) echo 'disabled' ?>">
<a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $Language->get('Next'); ?></a> <a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $Language->get('Next'); ?> &#9658;</a>
</li> </li>
</ul> </ul>

View File

@ -40,3 +40,7 @@ if ($url->whereAmI()==='admin') {
else { else {
require(PATH_BOOT.'site.php'); require(PATH_BOOT.'site.php');
} }
$endLoadTime = microtime(true);
$time = $endLoadTime - $loadTime;
var_dump($time);