File: //home/bk/efi/eficenter.ru/newTpl/modules_tree.js
function ModulesGetInfo() { } // не удалять, все нужно. моментоморе...
var protModGet = new ModulesGetInfo();
$("#click_div_blocks").click(function(){
$("#div_blocks").css("display", "block");
$("#div_all_parametr").css("display", "none");
$(this).addClass("current");
$("#click_div_all_parametr").removeClass("current");
});
$("#click_div_all_parametr").click(function(){
$("#div_all_parametr").css("display", "block");
$("#div_blocks").css("display", "none");
$(this).addClass("current");
$("#click_div_blocks").removeClass("current");
});
// ######################################## //
if($.cookie('vladweb_showhiddenblock') == null) {
$("#modules_tree_dunamic_div").attr("class", "");
$("#modules_tree_dunamic_div").addClass("right_float_block_open");
} else {
$("#modules_tree_dunamic_div").attr("class", "");
$("#modules_tree_dunamic_div").addClass("right_float_block_close");
}
$("#show_hidden_block").click(function(){ save_cookie_and_animate_block(); });
function save_cookie_and_animate_block() {
var el = $("#modules_tree_dunamic_div");
var wid = 0;
var imgs = "modules_close.gif";
var class_style = "right_float_block_close";
if(el.width() > 30) {
wid = 30;
$("#div_blocks, #div_all_parametr").css("display", "none");
class_style = "right_float_block_close";
$.cookie('vladweb_showhiddenblock', '_true', {expires: (60*60*24*60), path: '/'});
imgs = "modules_close.gif";
} else {
wid = 330;
class_style = "right_float_block_open";
$.cookie('vladweb_showhiddenblock', null);
$("#div_blocks").css("display", "block");
$("#click_div_blocks").addClass("current");
$("#click_div_all_parametr").removeClass("current");
imgs = "modules_open.gif";
}
$("#show_hidden_block_img").attr("src", img_path + imgs);
$("#modules_tree_dunamic_div").animate({width: wid}, function(){
el.attr("class", "");
el.css("display", "");
el.addClass(class_style);
});
}
// ######################################## //
var site_need_path = 'admin.php?name=pages&cmd=ajax&pageblock=ok&rand=';
var ms = new Array('nm_block_', 'nm_block_global', '0');
var lang = { block_full:'Данный блок может иметь не более одного модуля.', edit_error:'Сохраните дерево блоков и попробуйте еще раз.' };
$("#message_save_tree").click(function() {
$("#save_status_bar").css('display', '');
blocks_0.lockTree(true);
var data = { bldata: blocks_0.serializeTreeToJSON(), page_id:$("#idPages").val() };
$("#block_message_save_tree").css('display', 'none');
$.post(site_uri + 'admin.php?name=pages&cmd=ajax&pageblock=ok&rand=' + ( Math.random()), data, function(data) {
metaBlockData.reload_tree();
blocks_0.deleteChildItems(0);
blocks_0.loadXML(site_uri + 'admin.php?name=pages&cmd=ajax&load_page_block=ok&id='+ $("#idPages").val()+'&rand='+ ( Math.random()) );
});
});
function prow_deleted_item(id) {
var proverc = true;
if( id == ms[1] || id == ms[2] ) proverc = false;
if( id.indexOf(ms[0]) != -1 ) proverc = false;
return proverc;
}
function chils() { alert( blocks_0.getAllSubItems('nm_block_0') ); }
function retNumberChild(id) {
var number = 0;
var kop = blocks_0.getAllSubItems(id);
var spliti = kop.split(',');
if( kop == '' ) return number;
return spliti.length;
}
//var ms = new Array('nm_block_', 'nm_block_global', '0');
function sendBlockServer(nodeId, parentId) {
var pos = true;
//alert(nodeId); return false;
if(parentId == ms[1] || parentId == ms[2] || nodeId == 1) { pos = false; return pos; }
if( parentId == 'nm_block_0' && retNumberChild('nm_block_0') >= 1 ) { pos = false; alert(lang.block_full); return pos; }
if( nodeId.indexOf(ms[0]) != -1) { pos = false; return pos; }
if( parentId.indexOf('block_') == -1 ) { pos = false; return pos; }
$("#block_message_save_tree").css('display', '');
return pos;
}
function delited_item(id) {
if( id.indexOf('old_') == -1 ) return false;
$("#save_status_bar").css('display', '');
var data = { id_del_block:id };
$.post(site_uri + 'admin.php?name=pages&cmd=ajax&delpageblock=ok&rand='+ ( Math.random()), data, function(){
metaBlockData.reload_tree();
$("#save_status_bar").css('display', 'none');
});
}
function getModules(id) {
//modules_item
if(id.indexOf('block_') != -1) return false;
if(id.indexOf('old_') == -1) { alert(lang.edit_error); return false; }
var property1 = blocks_0.getUserData(id, 'modules_item');
if(property1 == undefined) return false;
var spl = property1.split("|"); //article|6
window.frames.div_frame_modules.location = site_uri + modules_frame_open.check(spl[0], spl[1]);
}
function open_win_and_edit_par(id) {
if( id.indexOf('old_') == -1 ) { alert(lang.edit_error); return false; }
var tplPath = site_uri +'newTpl/evolution_'+ blocks_0.getItemTooltip(id) +'_block_properties.html';
var dSp = id.split("_");
$("#selectBlock").val(dSp[1]);
$("#saveMenuParametr").attr("disabled", false);
var iW = $(document).width();
var iH = $(document).height();
var mo = Math.ceil( ( iW / 2 ) - 350 );
pngZadnick.show({zIndex:99});
$("#parent_div_other_parametr").css({display:'', zIndex:100 });
$("#other_parametr_block").css({width:700, left:mo, top:( $(document).scrollTop() + 100 )});
$("#infoBlock").load( tplPath, function() {
$("#blockTitle").append("Свойства блока ("+ blocks_0.getItemText(id) +"):");
$("#site_target").append( "<option>"+ format_site_lang +"</option>" );
var nameMod = blocks_0.getItemTooltip(id); //lert( protModGet.nameMod.get() ); //saveMenuParametr
var bn = "protModGet."+ nameMod +".get()";
var vb = "protModGet."+ nameMod +".save";
$("#saveMenuParametr").click( eval(vb) );
eval( bn );
});
return true;
}
$("#parExit, #closeMenuParametr").click(function(){ close_dop_munu(); });
function close_dop_munu() {
$("#saveMenuParametr").unbind("click")
pngZadnick.hidden();
$("#parent_div_other_parametr").css({display:'none', width:700, height:400});
$("#infoBlock").empty();
$("#selectBlock").val('');
}
function onButtonClick(menuitemId, type) {
var id = blocks_0.contextID;
if(menuitemId == 'deleted_item') if(prow_deleted_item(id) && confirm('Вы уверены?')) { blocks_0.deleteItem(id); delited_item(id); }
if(menuitemId == 'edit_item') if(prow_deleted_item(id)) open_win_and_edit_par(id);
}
function loadImgAndJSfiles() {
var it = blocks_0.getAllSubItems(0);
var spl = it.split(',');
var zaload_mod = "";
for(var i = 0; i < spl.length; i++) {
if( spl[i].indexOf('old_') != -1 ) {
var modName = blocks_0.getItemTooltip(spl[i]);
var jsPath = site_uri +'newTpl/evolution_'+ modName +'_block_properties.js';
if( zaload_mod.indexOf(modName) == -1 ) $.getScript( jsPath );
zaload_mod += modName + ",";
}
}
$("#save_status_bar").css('display', 'none');
messgBlock.hidden();
blocks_0.lockTree(false);
}
var metaBlockData = {
get:function(){
$.get(site_uri + "admin.php?name=pages&cmd=ajax&metadata=ok&id="+ $("#idPages").val(), function(data){
var dXML = data;
var tpl = "";
var sid = 0;
$(dXML).find("template").each(function(){
var t = $(this);
//<template img="i/adminx/tpl/ru/tmpl1.gif" text="Шаблон главной страницы" id="1"/>
tpl += "<option value='"+t.attr("id")+"'>"+t.attr("text")+"</option>";
});
$(dXML).find("metablock").each(function(){
var d = $(this);
sid = d.attr("tlpid");
var per_type = ( d.attr("permission_type") ? d.attr("permission_type") : '2');
if( per_type > 2 ) per_type = 2;
$("#title").val(d.attr("title"));
$("#link").val(d.attr("link")); //index
$("#keywords").val(d.attr("keywords"));
$("#description").val(d.attr("description"));
$("#alt_title").val(d.attr("alt_title"));
$("#meta").val(d.text());
$("#redirect_url").val(d.attr("redirect_url"));
$("#targetlist_href option[value='"+d.attr("target")+"']").attr("selected", true);
//$("#div_block_img").css("backgroundImage", "url("+ d.attr("tpl_image") +")");
$("#div_block_img").attr("src", d.attr("tpl_image"));
$("#div_block_img").css({display: "block"});
$("input[name='permission_type'][value='"+ per_type +"']").attr("checked", true);
});
$("#tpl_list_meta").html(tpl);
$("#tpl_list_meta option[value='"+sid+"']").attr("selected", true);
if($("#link").val() == "index") $("#link").attr("readonly", true); else $("#link").attr("readonly", false);
if($("#title").val() == "Главная страница") $("#title").attr("readonly", true); else $("#title").attr("readonly", false);
});
},
save:function(){
$('#save_form_server').attr('disabled', true);
$('#save_form_server').attr('value', 'Сохраняю...');
var save_uri = site_uri + 'admin.php?name=pages&cmd=ajax&page_info=ok';
var user_data = { title:$("#title").val(), link:$("#link").val(), permission_type:$("input[@name='permission_type']:checked").val(),
keywords:$("#keywords").val(), description:$("#description").val(),
alt_title:$("#alt_title").val(), meta:$("#meta").val(),
redirect_url:$("#redirect_url").val(), id:$("#idPages").val(), target:$("#targetlist_href option:selected").val(),
tplid:$("#tpl_list_meta option:selected").val() };
$.post(save_uri, user_data, function(data){
$('#save_form_server').attr('disabled', false);
$('#save_form_server').attr('value', 'Сохранено успешно.');
setTimeout( function(){$('#save_form_server').attr('value', 'Сохранить');}, 2000 );
});
},
reload_tree:function(){
//alert(getCookies('treeOpenStatextreecookie='));
global_tree.deleteChildItems(0);
global_tree.loadXML('admin.php?name=pages&cmd=ajax&mns=allformat&open=ok&gen='+(Math.random()));
//global_tree.openItemsDynamic( getCookies('treeOpenStatextreecookie='), false);
}
}
nms = new dhtmlXMenuObject(null,"standard");
nms.setImagePath("/js/codebase/imgs/");
//nms.setIconsPath("/js/codebase/imgs/");
nms.renderAsContextMenu();
nms.setOpenMode("web");
nms.attachEvent("onClick", onButtonClick);
nms.loadXML(site_uri + "js/codebase/dhtmlxmenu.xml");
/* list modules */
mod_tree = new dhtmlXTreeObject("modules_tree","100%","",0);
mod_tree.setImagePath("js/codebase/imgs/csh_vista/");
mod_tree.enableDragAndDrop(true);
mod_tree.enableMercyDrag(true);
mod_tree.setDragHandler(function(){ return false; });
mod_tree.setSiteUri(site_uri);
mod_tree.setDragBehavior("complex");
mod_tree.setStdImages("mod_def.gif","mod_def.gif","mod_def.gif");
mod_tree.setOnOpenHandler(function(id){
if(id == 1) ( blocks_0.getOpenState("nm_block_global") == 1 ? blocks_0.closeItem("nm_block_global") : blocks_0.openItem("nm_block_global") ); return true;
});
//global_tree.setOnClickHandler(function(id) { window.frames.main_block.location = 'admin.php?global_frame=show&name=pages&cmd=edit&id='+ id; });
mod_tree.loadXML(site_uri + 'admin.php?name=pages&cmd=ajax&xmlmodules=ok&rand='+ ( Math.random() ));
/* end list modules */
/* global block all trees 0 */
blocks_0 = new dhtmlXTreeObject("block_0","100%","",0);
blocks_0.setImagePath("js/codebase/imgs/csh_vista/");
blocks_0.enableDragAndDrop(true);
blocks_0.setLockedIcons("lock.gif","lock.gif","lock.gif");
blocks_0.setSiteUri(site_uri);
blocks_0.enableContextMenu(nms);
blocks_0.setDragHandler(sendBlockServer);
blocks_0.setOnClickHandler(getModules);
blocks_0.setDragBehavior("complex");
blocks_0.setOnLoadingEnd(loadImgAndJSfiles);
blocks_0.setOnOpenHandler(function(id){
if(id == "nm_block_global") ( mod_tree.getOpenState(1) == 1 ? mod_tree.closeItem(1) : mod_tree.openItem(1) ); return true;
});
//global_tree.setOnClickHandler(function(id) { window.frames.main_block.location = 'admin.php?global_frame=show&name=pages&cmd=edit&id='+ id; });
blocks_0.loadXML(site_uri + 'admin.php?global_frame=show&name=pages&cmd=ajax&load_page_block=ok&id='+ $("#idPages").val()+'&rand='+ ( Math.random()) );
/* end block 0 */
metaBlockData.get();
$("#save_form_server").click(metaBlockData.save);