ver 0.262 - pages module refactor and admin UX fixes
This commit is contained in:
@@ -1,48 +1,57 @@
|
||||
<?
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
ob_start();
|
||||
if ( is_array( $this -> menus ) ) foreach ( $this -> menus as $menu )
|
||||
{
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>" menu-id="<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$menu['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i>';?>
|
||||
Menu: <b><?= $menu['name'];?></b>
|
||||
</div>
|
||||
<?= \admin\view\Pages::subpages_browse_list( \admin\factory\Pages::menu_pages( $menu['id'] ) );?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
$menus = is_array($this->menus ?? null) ? $this->menus : [];
|
||||
$modal = !empty($this->modal);
|
||||
$cookiePages = is_array($this->cookie_pages ?? null) ? $this->cookie_pages : [];
|
||||
$cookieMenus = is_array($this->cookie_menus ?? null) ? $this->cookie_menus : [];
|
||||
|
||||
ob_start();
|
||||
foreach ($menus as $menu):
|
||||
$menuId = (int)($menu['id'] ?? 0);
|
||||
$menuName = (string)($menu['name'] ?? '');
|
||||
$menuStatus = (int)($menu['status'] ?? 0);
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menuId; ?>" menu-id="<?= $menuId; ?>">
|
||||
<li id="list_<?= $menuId; ?>" class="menu_<?= $menuId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<?php if ($menuStatus !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i><?php endif; ?>
|
||||
Menu: <b><?= htmlspecialchars($menuName, ENT_QUOTES, 'UTF-8'); ?></b>
|
||||
</div>
|
||||
<?= \Tpl::view('pages/subpages-browse-list', [
|
||||
'pages' => $menu['pages'] ?? [],
|
||||
'step' => 1,
|
||||
]); ?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'pages-list';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Lista stron';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = $out;
|
||||
$grid->id = 'pages-list';
|
||||
$grid->gdb_opt = $gdb;
|
||||
$grid->include_plugins = true;
|
||||
$grid->title = 'Lista stron';
|
||||
$grid->default_buttons = false;
|
||||
$grid->external_code = $out;
|
||||
|
||||
echo $grid -> draw();
|
||||
echo $grid->draw();
|
||||
?>
|
||||
<style type="text/css">
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> body.sb-top.sb-top-sm .navbar.navbar-fixed-top + #sidebar_left + #content_wrapper {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> body.sb-top.sb-top-sm .navbar.navbar-fixed-top + #sidebar_left + #content_wrapper {
|
||||
padding-top: 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content {
|
||||
padding: 27px 0 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content > .row {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content > .row {
|
||||
margin: 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content > .row > .col-lg-9 {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content > .row > .col-lg-9 {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
float: none;
|
||||
@@ -50,113 +59,88 @@ echo $grid -> draw();
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
var menu_id = 0;
|
||||
|
||||
function getUrlParam(paramName)
|
||||
{
|
||||
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
|
||||
var cookiePages = <?= json_encode($cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
var cookieMenus = <?= json_encode($cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
|
||||
function getUrlParam(paramName) {
|
||||
var reParam = new RegExp('(?:[\\?&]|&)' + paramName + '=([^&]+)', 'i');
|
||||
var match = window.location.search.match(reParam);
|
||||
|
||||
return (match && match.length > 1) ? match[1] : '';
|
||||
}
|
||||
|
||||
$( document ).ready( function()
|
||||
{
|
||||
<? if ( !$this -> modal ):?>
|
||||
$( '#sidebar_left, .navbar-fixed-top' ).hide();
|
||||
<? endif;?>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
<?php if (!$modal): ?>
|
||||
$('#sidebar_left, .navbar-fixed-top').hide();
|
||||
<?php endif; ?>
|
||||
|
||||
var funcNum = getUrlParam('CKEditorFuncNum');
|
||||
|
||||
$( 'body' ).on( 'click', '.button', function()
|
||||
{
|
||||
if ( funcNum )
|
||||
{
|
||||
window.opener.CKEDITOR.tools.callFunction(funcNum, $( this ).attr( 'url' ) );
|
||||
|
||||
$('body').on('click', '.button', function() {
|
||||
if (funcNum) {
|
||||
window.opener.CKEDITOR.tools.callFunction(funcNum, $(this).attr('url'));
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
stop: function() {
|
||||
save_pages_order();
|
||||
}
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( ".sortable *" ).mousedown( function(e)
|
||||
{
|
||||
menu_id = $( this ).parents( 'ol.sortable' ).attr( 'menu-id' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e)
|
||||
{
|
||||
if ( e.which === 1 ) {
|
||||
if ( $( this ).parent( 'div' ).hasClass( 'content_menu' ) )
|
||||
{
|
||||
var menu_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'menu' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_menus',
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var page_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_pages',
|
||||
page_id: page_id
|
||||
}
|
||||
});
|
||||
}
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: 0.9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
$(this).closest('li').toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(this).parent('div').hasClass('content_menu')) {
|
||||
var menuId = $(this).parent('div').parent('li').attr('menu');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookieMenus/',
|
||||
data: { menu_id: menuId }
|
||||
});
|
||||
} else {
|
||||
var pageId = $(this).parent('div').parent('li').attr('id').replace('list_', '');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookiePages/',
|
||||
data: { page_id: pageId }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(cookiePages || {}).forEach(function(key) {
|
||||
if (String(cookiePages[key]) === '1') {
|
||||
$('.list_' + key).children('div').children('span.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(cookieMenus || {}).forEach(function(key) {
|
||||
if (String(cookieMenus[key]) === '1') {
|
||||
$('.menu_' + key).children('div').children('span.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user