Plugin position implemented, fix in pagination
This commit is contained in:
parent
92a86c4fa7
commit
33c89e8bd7
|
@ -61,6 +61,10 @@ code {
|
||||||
color: #444;
|
color: #444;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list-group-sortable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LOGIN
|
LOGIN
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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 -->
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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'=>''
|
||||||
|
));
|
||||||
|
|
||||||
|
echo '<ul class="list-group list-group-sortable">';
|
||||||
foreach ($plugins['siteSidebar'] as $Plugin) {
|
foreach ($plugins['siteSidebar'] as $Plugin) {
|
||||||
echo '<div class="plugin-position" data-plugin="'.$Plugin->className().'"><i class="uk-icon-bars"></i> '.$Plugin->name().'</div>';
|
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>
|
|
@ -257,6 +257,7 @@ function changePluginsPosition($pluginClassList) {
|
||||||
'notes'=>''
|
'notes'=>''
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Alert::set($Language->g('The changes have been saved'));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -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(" ");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);
|
|
@ -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">◀ <?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'); ?> ►</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -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">◀ <?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'); ?> ►</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue