/* [Discuz!] (C)2001-2099 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: space_diy.js 23838 2011-08-11 06:51:58Z monkey $ */ var drag = new Drag(); drag.extend({ setDefalutMenu : function () { this.addMenu('default', '删除', 'drag.removeBlock(event)'); this.addMenu('block', '属性', 'drag.openBlockEdit(event)'); }, removeBlock : function (e) { if ( typeof e !== 'string') { e = Util.event(e); id = e.aim.id.replace('cmd_',''); } else { id = e; } if (!confirm('您确实要删除吗,删除以后将不可恢复')) return false; $(id).parentNode.removeChild($(id)); var el = $('chk'+id); if (el != null) el.className = ''; this.initPosition(); this.initChkBlock(); }, initChkBlock : function (data) { if (typeof name == 'undefined' || data == null ) data = this.data; if ( data instanceof Frame) { this.initChkBlock(data['columns']); } else if (data instanceof Block) { var el = $('chk'+data.name); if (el != null) el.className = 'activity'; } else if (typeof data == 'object') { for (var i in data) { this.initChkBlock(data[i]); } } }, toggleBlock : function (blockname) { var el = $('chk'+blockname); if (el != null) { if (el.className == '') { this.getBlockData(blockname); el.className = 'activity'; } else { this.removeBlock(blockname); this.initPosition(); } this.setClose(); } }, getBlockData : function (blockname) { var el = $(blockname); if (el != null) { Util.show(blockname); } else { var x = new Ajax(); x.get('home.php?mod=spacecp&ac=index&op=getblock&blockname='+blockname+'&inajax=1',function(s) { if (s) { el = document.createElement("div"); el.className = drag.blockClass + ' ' + drag.moveableObject; el.id = blockname; s = s.replace(/\/ig,' [javascript脚本保存后显示] '); el.innerHTML = s; var id = drag.data['diypage'][0]['columns']['frame1_left']['children'][0]['name']; $('frame1_left').insertBefore(el,$(id)); drag.initPosition(); } }); } }, openBlockEdit : function (e) { e = Util.event(e); var blockname = e.aim.id.replace('cmd_',''); this.removeMenu(); showWindow('showblock', 'home.php?mod=spacecp&ac=index&op=edit&blockname='+blockname,'get',0); } }); var spaceDiy = new DIY(); spaceDiy.extend({ save:function () { drag.clearClose(); document.diyform.spacecss.value = this.getSpacecssStr(); document.diyform.style.value = this.style; document.diyform.layoutdata.value = drag.getPositionStr(); document.diyform.currentlayout.value = this.currentLayout; document.diyform.submit(); }, getdiy : function (type) { var type_ = type == 'image' ? 'diy' : type; if (type_) { var nav = $('controlnav').children; for (var i in nav) { if (nav[i].className == 'current') { nav[i].className = ''; } } $('nav'+type_).className = 'current'; var para = '&op='+type; if (arguments.length > 1) { for (i = 1; i < arguments.length; i++) { para += '&' + arguments[i] + '=' + arguments[++i]; } } var ajaxtarget = type == 'image' ? 'diyimages' : ''; var x = new Ajax(); x.showId = ajaxtarget; x.get('home.php?mod=spacecp&ac=index'+para+'&inajax=1&ajaxtarget='+ajaxtarget,function(s) { if (s) { drag.deleteFrame(['pb', 'bpb', 'tpb', 'lpb']); if (type == 'image') { $('diyimages').innerHTML = s; } else { $('controlcontent').innerHTML = s; x.showId = 'controlcontent'; } if (type_ == 'block') { drag.initPosition(); drag.initChkBlock(); } else if (type_ == 'layout') { $('layout'+spaceDiy.currentLayout).className = 'activity'; } else if (type_ == 'diy' && type != 'image') { spaceDiy.setCurrentDiy(spaceDiy.currentDiy); if (spaceDiy.styleSheet.rules.length > 0) { Util.show('recover_button'); } } var evaled = false; if(s.indexOf('ajaxerror') != -1) { evalscript(s); evaled = true; } if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) { if(x.showId) { ajaxupdateevents($(x.showId)); } } if(!evaled) evalscript(s); } }); } }, menuChange : function (tabs, menu) { var tabobj = $(tabs); var aobj = tabobj.getElementsByTagName("li"); for(i=0; i