📄 cpanel.js
字号:
var cpanel = {
buttons:{
help:function(o){
X.menus.close();
if(cpanel.fav.runtime.style)cpanel.fav.runtime.style.display='none';
var m = cpanel.buttons.build(
[
{label:__('ShopEx Ambassador'),onclick:"X.go({ctl:'addons',act:'toReg'},{target:'addons:toReg'})"},
{label:__('FAQs'),onclick:"window.open('http://www.shopex.cn/help/help_472/help_shopadv.html')"},
{label:__('System Information'),onclick:"fbox.open({ctl:'addons',act:'sysinfo'})"},
{label:__('About ShopEx'),onclick:"fbox.open({ctl:'addons',act:'about'})"}
]
);
document.body.appendChild(m);
Position.clone(o,m,{setWidth: false,setHeight:false,offsetTop:o.offsetHeight});
X.menus.bind(m,{inClick:false});
m.style.visibility='';
},
pub:function(o){
X.menus.close();
if(cpanel.fav.runtime.style)cpanel.fav.runtime.style.display='none';
var m = cpanel.buttons.build(
[
{label:__('Delete Whole Page Cache'),onclick:"X.go({ctl:'addons',act:'rmPageC'},{target:'__BG__'})"},
{label:__('Delete Template Cache'),onclick:"X.go({ctl:'addons',act:'rmTplC'},{target:'__BG__'})"},
{label:__('Delete Data Cache'),onclick:"X.go({ctl:'addons',act:'rmDataC'},{target:'__BG__'})"}
]
);
document.body.appendChild(m);
Position.clone(o,m,{setWidth: false,setHeight:false,offsetTop:o.offsetHeight});
X.menus.bind(m,{inClick:false});
m.style.visibility='';
},
build:function(a){
var m = Builder.node('ul',{className:'menu',style:"visibility:hidden"});
a.each(
function(e){
m.appendChild(Builder.node('li',{onClick:e.onclick},e.label))
}
);
return m;
}
},
getFavList:function(){
cpanel.favList = {};
l = $('favorite').getElementsByTagName('li');
for(i=0;i<l.length;i++)
cpanel.favList[(l[i].getAttribute('pkg')?l[i].getAttribute('pkg'):'none')+'-'+l[i].getAttribute('ctl')+'-'+l[i].getAttribute('act')]=1;
},
favList:{},
menus:{
init:function(){
/* $('sysmenu').innerHTML='';
Menus.each(
function(m,k){
$('sysmenu').appendChild(
Builder.node('span',{className:'link '+(m.name || ''),menu:k,onMouseover:'cpanel.menus.show(this,true)',onmouseout:"cpanel.menus.out()"},m.label)
);
$('sysmenu').innerHTML+=' ';
}
)*/
cpanel.menus.iframemask1 = Builder.node('iframe',{frameborder:0,scrolling:'no',style:'border:0;scrolling:no;position:absolute;display: none;top:0;left:0;marginwidth:0;height:0;width:0'});
cpanel.menus.iframemask2 = Builder.node('iframe',{frameborder:0,scrolling:'no',style:'border:0;;position:absolute;display: none;top:0;left:0;marginwidth:0;height:0;width:0'});
document.body.appendChild(cpanel.menus.iframemask1);
document.body.appendChild(cpanel.menus.iframemask2);
},
mouseover:function(e){
cpanel.menus.runtime.depth=1;
Event.stop(e);
cpanel.menus.show(Event.element(e));
},
show:function(o,root){
X.menus.close();
if(cpanel.fav.runtime.style)cpanel.fav.runtime.style.display='none';
s = o.getAttribute('menu');
m = cpanel.menus.body(s);
if(m){
// document.body.appendChild(m);
if(root){
Position.clone(o,m,{setWidth: false,setHeight:false,offsetTop:o.offsetHeight});
Position.clone(m,cpanel.menus.iframemask1,{setWidth: true,setHeight:true,offsetTop:0});
cpanel.menus.iframemask1.style.display='block';
}else{
if(Position.cumulativeOffset(o)[0]+o.offsetWidth+m.offsetWidth>document.body.offsetWidth){
Position.clone(o,m,{setWidth: false,setHeight:false,offsetLeft:-m.offsetWidth});
Position.clone(m,cpanel.menus.iframemask2,{setWidth: true,setHeight:true,offsetLeft:0});
cpanel.menus.iframemask2.style.display='block';
}else{
Position.clone(o,m,{setWidth: false,setHeight:false,offsetLeft:o.offsetWidth});
Position.clone(m,cpanel.menus.iframemask2,{setWidth: true,setHeight:true,offsetLeft:0});
cpanel.menus.iframemask2.style.display='block';
}
}
m.style.visibility='';
}
cpanel.menus.clearWithout(s);
},
click:function(o){
o = Event.element(o);
var o = eval('Menus['+(o.getAttribute('menu')+'').replace(/\-/g,'].items[')+']');
cpanel.menus.closeAll();
if(o.href){
X.compact.go(o.href,o.target?o.target:'__INPAGE__',o.label);
}else if(o.ctl){
X.go(o,{autotab:true,target:o.target});
}else if(o.onclick){
eval(o.onclick);
}
Event.stop(o);
},
body:function(a){
var o = eval('Menus['+(a+'').replace(/\-/g,'].items[')+']');
if(o && o.items){
if(!cpanel.menus.runtime.m[a]){
var base = Builder.node('ul',{className:'menu',style:'visibility: hidden;top:0;left:0'});
document.body.appendChild(base);
Event.observe(base,'mouseover',cpanel.menus.over,true);
Event.observe(base,'mouseout',cpanel.menus.out,true);
o.items.each(
function(i,k){
var dm = Builder.node('li',{style:'display:block;width:auto !important;width:auto ',menu:a+'-'+k},i.label);
Event.observe(dm,'mouseover',cpanel.menus.mouseover,true);
if(!i.ctl && !i.href && !i.onclick){
dm.className='disabled';
}else{
Event.observe(dm,'click',cpanel.menus.click,true);
}
base.appendChild(dm);
}
);
cpanel.menus.runtime.m[a]=base;
return base;
}
else{
cpanel.menus.runtime.m[a].style.display='block';
return cpanel.menus.runtime.m[a];
}
}
},
over:function(e){
cpanel.menus.runtime.depth=1;
},
out:function(e){
if(e){
Event.stop(e);
if(Event.element(e).tagName=='LI' || Event.element(e).tagName=='UL'){
cpanel.menus.runtime.depth--;
setTimeout('cpanel.menus.check()',500);
}
}
},
check:function(){
if(cpanel.menus.runtime.depth<1){
cpanel.menus.closeAll();
}
},
closeAll:function(){
for(n in cpanel.menus.runtime.m){
cpanel.menus.runtime.m[n].style.display='none';
/*
for(node=cpanel.menus.runtime.m[n].firstChild;node;node=node.nextSibling){
Event.stopObserving(node,'mouseover',X.menus.mouseover,true);
}
Event.stopObserving(cpanel.menus.runtime.m[n],'mouseout',X.menus.out,true);
removeElement(cpanel.menus.runtime.m[n]);
delete(cpanel.menus.runtime.m[n]);
*/
}
cpanel.menus.iframemask1.style.display='none';
cpanel.menus.iframemask2.style.display='none';
},
clearWithout:function(s){
for(n in cpanel.menus.runtime.m){
if(n.indexOf(s) && s.indexOf(n)){
//removeElement(cpanel.menus.runtime.m[n]);
//delete(cpanel.menus.runtime.m[n]);
cpanel.menus.runtime.m[n].style.display='none';
}
}
},
runtime:{m:{}},
iframemask1:null,
iframemask2:null
},
show:function(){
cpanel.getFavList();
var e = X.tab.$('cpanel');
if(!e){
e = X.tab.create('cpanel');
X.tab.setLabel('cpanel',__('Manage favorite'));
}
e.body.innerHTML='';
desc = Builder.node('div',{className:'c-header'},[
Builder.node('p',{className:'desc'},[__('Click the star behind the menu item and add the menu item to my favorite. No star menu items can not be add to my favorite, and the next version will achieve it.')])
]);
b = Builder.node('div',{className:'cpanel'});
Menus.each(
function(m){
if(!m.items[0].items) return;
r = Builder.node('fieldset',{},[
Builder.node('legend',{},m.label)
]);
m.items.each(
function(i){
c = Builder.node('div');
i.items.each(
function(o){
if(o.href){
c.appendChild(
Builder.node('span',{className:'link item compact',onclick:'X.compact.obj(this)',href:o.href,target:o.target?o.target:'__INPAGE__'},o.label)
)
}else if(o.ctl){
fav = cpanel.favList[(o.pkg?o.pkg:'null')+'-'+o.ctl+'-'+o.act];
c.appendChild(
Builder.node('span',{className:'item'},[
Builder.node('span',{className:'link',ctl:o.ctl?o.ctl:'null',pkg:o.pkg?o.pkg:'',act:o.act?o.act:'index',tab:o.tab?o.tab:'null',onclick:'X.go(this)'},o.label),
Builder.node('b',{className:(fav?'marker fav':'marker'),onclick:'cpanel.fav.toggle(this)'},' ')
])
)
}else{
c.appendChild(
Builder.node('span',{className:'empty item'},o.label)
)
}
}
);
r.appendChild(
Builder.node('div',{className:'part'},[
Builder.node('div',{className:'icon',style:'background-position:-'+(i.icon?i.icon*80:0)+'px 0'}),
Builder.node('label',{},i.label),c
])
);
}
);
b.appendChild(r);
}
);
e.body.appendChild(desc);
e.body.appendChild(b);
X.tab.fg('cpanel');
},
fav:{
toggle:function(obj){
var item ={};
item.pkg = obj.previousSibling.getAttribute('pkg');
item.ctl = obj.previousSibling.getAttribute('ctl');
item.act = obj.previousSibling.getAttribute('act');
tab = item.pkg+item.ctl+':'+item.act;
item.pkg = item.pkg?item.pkg:'null';
if(Element.hasClassName(obj,'fav')){
link = cpanel.fav.getObj(item);
if(link){
removeElement(link);
Element.removeClassName(obj,'fav');
/*if(cpanel.favCount==1){
$('favorite').hide();
}*/
}
X.go({ctl:'profile/setting',act:'delFav',p:[item.pkg,item.ctl,item.act]},{target:'__BG__'});
}else{
var n = Builder.node('li',{ctl:item.ctl,pkg:item.pkg,'tab':tab,act:item.act,onclick:'X.go(this)'},obj.previousSibling.innerHTML)
$('favorite').getElementsByTagName('ul')[0].appendChild(n);
$('favorite').show();
new Effect.Highlight(n)
Element.addClassName(obj,'fav');
X.go({ctl:'profile/setting',act:'addFav',p:[item.pkg,item.ctl,item.act]},{target:'__BG__'});
}
},
getObj:function(o){
l = $('favorite').getElementsByTagName('li');
cpanel.favCount = l.length;
for(i=0;i<l.length;i++)
if(l[i].getAttribute('pkg')==o.pkg && l[i].getAttribute('ctl')==o.ctl && l[i].getAttribute('act')==o.act)
return l[i];
return false;
},
show:function(o,id){
X.menus.close();
if(cpanel.fav.runtime.style)cpanel.fav.runtime.style.display='none';
var m=$(id);
Position.clone(o,m,{setWidth: false,setHeight:false,offsetTop:o.offsetHeight});
m.style.display='block';
cpanel.fav.runtime=m;
Event.observe(document.body,'click',cpanel.fav.close,false);
},
close:function(){
cpanel.fav.runtime.style.display='none';
},
runtime:{m:{}}
},
fatherList:function(){
var i=0;
Menus.each(
function(f){
var a = Builder.node('span',{id:i,onmouseover:'cpanel.childList(this)',onmouseout:'cpanel.childClose(this)',style:'background-color:#666600'},f.label+' | ');
$('fatherMenu').appendChild(a);
i++;
}
);
document.body.appendChild(
Builder.node('input',{id:'menuFlag',value:0},[])
);
},
childList:function(fatherObj){
if($('menuFlag').value == 0){
var i=0;
var top = fatherObj.offsetTop+fatherObj.offsetHeight-3;
var left = fatherObj.offsetLeft+20;
var div = Builder.node('div',{id:'child'+fatherObj.id,onmouseover:'cpanel.setMenuFlag(1)',style:('top:'+top+'px;left:'+left+'px;position:absolute;background-color:#006699')},[]);
Menus.each(
function(m){
if(i==fatherObj.id){
m.items.each(
function(c){
div.appendChild(
Builder.node('li',{},c.label)
)
}
);
}
i++;
}
);
$(fatherObj.id).appendChild(div);
}
},
childClose:function(fatherObj) {
if($('menuFlag').value == 0){
}
},
gradeChildList : function() {
},
setMenuFlag:function(flag){
$('menuFlag').value = flag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -