Files
AtomicOld/simpla/design/html/pages.tpl
2026-02-14 19:50:25 +03:00

176 lines
5.0 KiB
Smarty
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{* Вкладки *}
{capture name=tabs}
{if in_array('pages', $manager->permissions)}
{foreach from=$menus item=m}
{if $m->id != 3}
<li {if $m->id == $menu->id}class="active"{/if}><a href="{url module=PagesAdmin menu_id=$m->id}">{$m->name}</a></li>
{/if}
{/foreach}
{/if}
{/capture}
{* Title *}
{$meta_title = {$menu->name} scope=parent}
{* Заголовок *}
<div id="header">
<h1>{$menu->name}</h1>
<a class="add" href="{url module=PageAdmin}">Добавить страницу</a>
</div>
{if $pages}
<div id="main_list">
<form id="list_form" method="post">
<input type="hidden" name="session_id" value="{$smarty.session.id}">
<div id="list">
{foreach $pages as $page}
<div class="{if !$page->visible}invisible{/if} row">
<input type="hidden" name="positions[{$page->id}]" value="{$page->position}">
<div class="move cell"><div class="move_zone"></div></div>
<div class="checkbox cell">
<input type="checkbox" name="check[]" value="{$page->id}" />
</div>
<div class="name cell">
<a href="{url module=PageAdmin id=$page->id return=$smarty.server.REQUEST_URI}">{$page->header|escape}</a>
</div>
<div class="icons cell">
<a class="preview" title="Предпросмотр в новом окне" href="{$page->parentUrl}{$page->url}/" target="_blank"></a>
<a class="enable" title="Активна" href="#"></a>
<a class="delete" title="Удалить" href="#"></a>
</div>
<div class="clear"></div>
</div>
{/foreach}
</div>
<div id="action">
<label id="check_all" class="dash_link">Выбрать все</label>
<span id="select">
<select name="action">
<option value="enable">Сделать видимыми</option>
<option value="disable">Сделать невидимыми</option>
<option value="delete">Удалить</option>
</select>
</span>
<input id="apply_action" class="button_green" type="submit" value="Применить">
</div>
</form>
</div>
{else}
Нет страниц
{/if}
{* On document load *}
{literal}
<script>
$(function() {
// Сортировка списка
$("#list").sortable({
items: ".row",
tolerance: "pointer",
handle: ".move_zone",
scrollSensitivity: 40,
opacity: 0.7,
forcePlaceholderSize: true,
axis: 'y',
helper: function(event, ui){
if($('input[type="checkbox"][name*="check"]:checked').size()<1) return ui;
var helper = $('<div/>');
$('input[type="checkbox"][name*="check"]:checked').each(function(){
var item = $(this).closest('.row');
helper.height(helper.height()+item.innerHeight());
if(item[0]!=ui[0]) {
helper.append(item.clone());
$(this).closest('.row').remove();
}
else {
helper.append(ui.clone());
item.find('input[type="checkbox"][name*="check"]').attr('checked', false);
}
});
return helper;
},
start: function(event, ui) {
if(ui.helper.children('.row').size()>0)
$('.ui-sortable-placeholder').height(ui.helper.height());
},
beforeStop:function(event, ui){
if(ui.helper.children('.row').size()>0){
ui.helper.children('.row').each(function(){
$(this).insertBefore(ui.item);
});
ui.item.remove();
}
},
update:function(event, ui)
{
$("#list_form input[name*='check']").attr('checked', false);
$("#list_form").ajaxSubmit(function() {
colorize();
});
}
});
// Раскраска строк
function colorize()
{
$(".row:even").addClass('even');
$(".row:odd").removeClass('even');
}
// Раскрасить строки сразу
colorize();
// Выделить все
$("#check_all").click(function() {
$('#list input[type="checkbox"][name*="check"]').attr('checked', $('#list input[type="checkbox"][name*="check"]:not(:checked)').length>0);
});
// Удалить
$("a.delete").click(function() {
$('#list_form input[type="checkbox"][name*="check"]').attr('checked', false);
$(this).closest(".row").find('input[type="checkbox"][name*="check"]').attr('checked', true);
$(this).closest("form").find('select[name="action"] option[value=delete]').attr('selected', true);
$(this).closest("form").submit();
});
// Показать
$("a.enable").click(function() {
var icon = $(this);
var line = icon.closest(".row");
var id = line.find('input[type="checkbox"][name*="check"]').val();
var state = line.hasClass('invisible')?1:0;
icon.addClass('loading_icon');
$.ajax({
type: 'POST',
url: 'ajax/update_object.php',
data: {'object': 'page', 'id': id, 'values': {'visible': state}, 'session_id': '{/literal}{$smarty.session.id}{literal}'},
success: function(data){
icon.removeClass('loading_icon');
if(state)
line.removeClass('invisible');
else
line.addClass('invisible');
},
dataType: 'json'
});
return false;
});
$("form").submit(function() {
if($('select[name="action"]').val()=='delete' && !confirm('Подтвердите удаление'))
return false;
});
});
</script>
{/literal}