📄 menuitem.js
字号:
{
var crtDiv = document.createElement('DIV');
crtDiv.className = this.className;
crtDiv.id = '______Weis_'+this.Key+'____';
crtDiv.setAttribute('onmouseover',this.onMouseOver);
crtDiv.setAttribute('onmouseout',this.onMouseOut);
//~~~~~~~~~~~~~~~~~~Select~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MenuItems.Select.Key = this.Key;
MenuItems.Select.crtDiv = crtDiv;
MenuItems.Select.Width = 75;
MenuItems.Select.Title = WeisLang.FONTNAME.Title;
var tblKey = '__'+MenuItems.Select.Key+'___Select_Tbl__';
MenuItems.Select.onClick = 'if(Editor.Config.WEditorMode)MenuItems.Select.ListPanel("'+tblKey+'","'+this.Key+'",125);';
crtDiv.innerHTML = MenuItems.Select.Load(tblKey);
//MenuItems.Select.Items = {};
MenuItems.Select.ItemAdd(this.Key+'1','Editor.formatblock(\'fontname\',\'\');','字体名称');
MenuItems.Select.ItemAdd(this.Key+'2','Editor.formatblock(\'fontname\',\'宋体\');','<font style=\'font-family:宋体;\' >宋体</font>');
MenuItems.Select.ItemAdd(this.Key+'3','Editor.formatblock(\'fontname\',\'黑体\');','<font style=\'font-family:黑体;\' >黑体</font>');
MenuItems.Select.ItemAdd(this.Key+'4','Editor.formatblock(\'fontname\',\'楷体_GB2312\');','<font style=\'font-family:楷体_GB2312;\' >楷体</font>');
MenuItems.Select.ItemAdd(this.Key+'5','Editor.formatblock(\'fontname\',\'仿宋_GB2312\');','<font style=\'font-family:仿宋_GB2312;\' >仿宋</font>');
MenuItems.Select.ItemAdd(this.Key+'6','Editor.formatblock(\'fontname\',\'隶书\');','<font style=\'font-family:隶书;\' >隶书</font>');
MenuItems.Select.ItemAdd(this.Key+'6','Editor.formatblock(\'fontname\',\'幼圆\');','<font style=\'font-family:幼圆;\' >幼圆</font>');
MenuItems.Select.ItemAdd(this.Key+'7','Editor.formatblock(\'fontname\',\'Arial\');','<font style=\'font-family:Arial;\' >Arial</font>');
MenuItems.Select.ItemAdd(this.Key+'8','Editor.formatblock(\'fontname\',\'Arial Black\');','<font style=\'font-family:Arial Black;\' >Arial Black</font>');
MenuItems.Select.ItemAdd(this.Key+'9','Editor.formatblock(\'fontname\',\'Arial Narrow\');','<font style=\'font-family:Arial Narrow;\' >Arial Narrow</font>');
MenuItems.Select.ItemAdd(this.Key+'10','Editor.formatblock(\'fontname\',\'Brush Script	MT\');','<font style=\'font-family:Brush Script	MT;\' >Brush Script MT</font>');
MenuItems.Select.ItemAdd(this.Key+'11','Editor.formatblock(\'fontname\',\'Century Gothic\');','<font style=\'font-family:Century Gothic;\' >Century Gothic</font>');
MenuItems.Select.ItemAdd(this.Key+'12','Editor.formatblock(\'fontname\',\'Comic Sans MS\');','<font style=\'font-family:Comic Sans MS;\' >Comic Sans MS</font>');
MenuItems.Select.ItemAdd(this.Key+'13','Editor.formatblock(\'fontname\',\'Courier\');','<font style=\'font-family:Courier;\' >Courier</font>');
MenuItems.Select.ItemAdd(this.Key+'14','Editor.formatblock(\'fontname\',\'Courier New\');','<font style=\'font-family:Courier New;\' >Courier New</font>');
MenuItems.Select.ItemAdd(this.Key+'15','Editor.formatblock(\'fontname\',\'MS Sans Serif\');','<font style=\'font-family:MS Sans Serif;\' >MS Sans Serif</font>');
MenuItems.Select.ItemAdd(this.Key+'16','Editor.formatblock(\'fontname\',\'Script\');','<font style=\'font-family:Script;\' >Script</font>');
MenuItems.Select.ItemAdd(this.Key+'17','Editor.formatblock(\'fontname\',\'System\');','<font style=\'font-family:System;\' >System</font>');
MenuItems.Select.ItemAdd(this.Key+'18','Editor.formatblock(\'fontname\',\'Times New Roman\');','<font style=\'font-family:Times New Roman;\'>Times New Roman</font>');
MenuItems.Select.ItemAdd(this.Key+'19','Editor.formatblock(\'fontname\',\'Verdana\');','<font style=\'font-family:Verdana;\' >Verdana</font>');
MenuItems.Select.ItemAdd(this.Key+'20','Editor.formatblock(\'fontname\',\'Wide	Latin\');','<font style=\'font-family:Wide	Latin;\' >Wide Latin</font>');
MenuItems.Select.ItemAdd(this.Key+'21','Editor.formatblock(\'fontname\',\'Wingdings\');','<font style=\'font-family:Wingdings;\'>Wingdings</font>');
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var outDiv = document.createElement('DIV');
outDiv.appendChild(crtDiv);
return outDiv.innerHTML;
}
}, //FONTNAME
ABOUT:{
Key:"ABOUT",
onMouseOver:"this.className='MouseOver'",
onMouseOut:"this.className='emlCss'",
className:"emlCss",
Show:function()
{
var crtDiv = document.createElement('DIV');
crtDiv.className = this.className;
crtDiv.id = '______Weis_'+this.Key+'____';
crtDiv.setAttribute('onmouseover',this.onMouseOver);
crtDiv.setAttribute('onmouseout',this.onMouseOut);
crtDiv.setAttribute('onclick', "Editor.AboutEditor();");
crtDiv.setAttribute('unselectable','on');
crtDiv.innerHTML = '<img src="EditImg/about.gif" alt="'+WeisLang.TitleAlt.About+'" title="'+WeisLang.TitleAlt.About+'" />';
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var outDiv = document.createElement('DIV');
outDiv.appendChild(crtDiv);
return outDiv.innerHTML;
}
}, //ABOUT,
FONTB:{
Key:"FONTB",
onMouseOver:"this.className='MouseOver'",
onMouseOut:"this.className='emlCss'",
className:"emlCss",
Show:function()
{
var crtDiv = document.createElement('DIV');
crtDiv.className = this.className;
crtDiv.id = '______Weis_'+this.Key+'____';
crtDiv.setAttribute('onmouseover',this.onMouseOver);
crtDiv.setAttribute('onmouseout',this.onMouseOut);
crtDiv.setAttribute('onclick', "if(Editor.Config.WEditorMode)MenuItems.FieldArea.FieldLoad(this.id,240,'"+this.Key+"');");
crtDiv.setAttribute('unselectable','on');
crtDiv.innerHTML = '<img src="EditImg/font.gif" alt="'+WeisLang.TitleAlt.FontColor+'" title="'+WeisLang.TitleAlt.FontColor+'" />';
//~~~~~~~~~~~~~~~~outWidth,sp,N(col)~~~~~~~~~~~~~~~
var sp = WeisConfig.FontColors.split(',');
var html = MenuItems.FieldArea.FieldHTML('STYLE',sp,24,10,16,'background'); //sp,ow,N,w
/////////////////////////////////////////////
MenuItems.FieldArea.ItemAdd(this.Key,html);
var outDiv = document.createElement('DIV');
outDiv.appendChild(crtDiv);
return outDiv.innerHTML;
}
}, //FONTB
EMOTB:{
Key:"EMOTB",
onMouseOver:"this.className='MouseOver'",
onMouseOut:"this.className='emlCss'",
className:"emlCss",
Show:function()
{
var crtDiv = document.createElement('DIV');
crtDiv.className = this.className;
crtDiv.id = '______Weis_'+this.Key+'____';
crtDiv.setAttribute('onmouseover',this.onMouseOver);
crtDiv.setAttribute('onmouseout',this.onMouseOut);
crtDiv.setAttribute('onclick', "if(Editor.Config.WEditorMode)MenuItems.FieldArea.FieldLoad(this.id,232,'"+this.Key+"');");
crtDiv.setAttribute('unselectable','on');
crtDiv.innerHTML = '<img src="EditImg/emot.gif" alt="'+WeisLang.TitleAlt.Emot+'" title="'+WeisLang.TitleAlt.Emot+'" />';
//~~~~~~~~~~~~~~~~outWidth,sp,N(col)~~~~~~~~~~~~~~~
var sp = WeisConfig.Emots.split(',');
var html = MenuItems.FieldArea.FieldHTML('EMOT',sp,26,8,26,''); //sp,ow,N,w
/////////////////////////////////////////////
MenuItems.FieldArea.ItemAdd(this.Key,html);
var outDiv = document.createElement('DIV');
outDiv.appendChild(crtDiv);
return outDiv.innerHTML;
}
} //FONTB
}
MenuItems.Select = {
Key:"",
crtDiv:null,
Width:0,
Height:21,
Title:"",
Items:{},
onClick:"",
ItemAdd:function(key,value,Text)
{
MenuItems.Select.Items[key] = MenuItems.Select.listItem(value,Text);
},
Load:function(tblKey)
{
//var tblKey = '__'+MenuItems.Select.Key+'___Select_Tbl__';
var html = '';
html = '<table id=\''+tblKey+'\' width=\''+MenuItems.Select.Width+'\' ';
html += ' height=\''+MenuItems.Select.Height+'\' rules=\'all\' onmouseover="if(Editor.Config.WEditorMode)this.style.borderColor=\'blue\';else this.style.borderColor=\'#ccc\'; " ';
html += ' onmouseout="if(Editor.Config.WEditorMode)this.style.borderColor=\'#ccc\';else this.style.borderColor=\'#ccc\';" '
html += ' style=\'border-collapse:collapse;margin:0px;border:1px solid #ccc;\'>';
html += '<tr>';
html += '<td style=\'border-right:1px solid #ccc;line-height:19px;padding-left:3px;background:#ffffff;\' ';
html += ' onmouseover="if(Editor.Config.WEditorMode)this.style.borderColor=\'blue\';else this.style.borderColor=\'#ccc\';" onclick=\''+MenuItems.Select.onClick+'\' ';
html += ' onmouseout="if(Editor.Config.WEditorMode)this.style.borderColor=\'#ccc\';else this.style.borderColor=\'#ccc\';" unselectable=\'on\'>'+MenuItems.Select.Title+'</td>';
html += '<td width=\'10\' onclick=\''+MenuItems.Select.onClick+'\' onmouseover="if(Editor.Config.WEditorMode)this.style.borderColor=\'blue\';else this.style.borderColor=\'#ccc\';" ';
html += ' onmouseout="if(Editor.Config.WEditorMode)this.style.borderColor=\'#ccc\';else this.style.borderColor=\'#ccc\';" style=\'border-left:1px solid #ccc;line-height:19px;\' unselectable=\'on\'>↓</td>';
html += '</tr>';
html += '</table>';
return html;
},
ListPanel:function(tblKey,key,W)
{
var XY = MenuItems.Func.GetIDXY(tblKey);
//if ($('______crt___PANEL__List____'))$('______crt___PANEL__List____').style.display='none';
MenuItems.Func.CheckIsExist();
var _panel = window.PDocument.createElement('DIV');
_panel.id = '______crt___PANEL__List____';
//_panel.setAttribute('style','position:absolute;top:'+(XY.Top+21)+'px;left:'+XY.Left+'px;width:'+MenuItems.Select.Width+'px;height:22px;');
_panel.style.position = "absolute";
_panel.style.top = (XY.Top+21)+"px";
_panel.style.left = XY.Left+"px";
if (window.isIE)_panel.style.left = (XY.Left+1)+"px";
_panel.style.width = W + "px";
_panel.style.height = "auto";
_panel.style.border = "1px solid #333";
_panel.style.backgroundColor = '#fff';
_panel.style.overflow = "auto";
_panel.setAttribute('class','__53jlsfsfsd__________');
var html = '';
for(var itm in MenuItems.Select.Items)
{
if (itm.indexOf(key)==0)
html += MenuItems.Select.Items[itm];
}
//_panel.innerHTML = html;
var F = MenuItems.Func.CreateIFM(html);
_panel.appendChild(F);
window.PDocument.body.appendChild(_panel);
},
listItem:function(value,Text)
{
var crtItem = window.PDocument.createElement('DIV');
crtItem.style.width = '100%';
crtItem.style.height = '22px';
crtItem.style.padding = '0px';
crtItem.style.lineHeight = '22px';
if (window.isIE)
crtItem.style.cursor = 'hand';
else
crtItem.style.cursor = 'pointer';
Text = Text.replace(/<(\w+)\s([^>]*?)>/gi,'<$1 $2 unselectable=\'on\'>');
crtItem.innerHTML = "◇"+Text;
crtItem.setAttribute('onclick',value+';MenuItems.Func.CheckIsExist();');
crtItem.setAttribute('onmouseover','this.style.background=\'blue\';this.style.color=\'#fff\';');
crtItem.setAttribute('onmouseout','this.style.background=\'#fff\';this.style.color=\'#000\';');
crtItem.setAttribute('unselectable','on');
var outerDiv = window.PDocument.createElement('DIV');
outerDiv.appendChild(crtItem);
return outerDiv.innerHTML;
}
}
//域区
MenuItems.FieldArea = {
ItmHTMLs:{},
ItemAdd:function(key,html)
{
this.ItmHTMLs[key] = html;
},
FieldLoad:function(objDiv,WH,key)
{
var XY = MenuItems.Func.GetIDXY(objDiv);
MenuItems.Func.CheckIsExist();
var _panel = window.PDocument.createElement('DIV');
_panel.id = '______crt___PANEL__List____';
_panel.style.position = "absolute";
_panel.style.top = (XY.Top+21)+"px";
_panel.style.left = XY.Left+"px";
if (window.isIE)_panel.style.left = (XY.Left+1)+"px";
_panel.style.width = WH + "px"
_panel.style.height = "0";
_panel.style.border = "0px solid #4682B4";
_panel.style.backgroundColor = '#ddd';
//_panel.style.visibility = "hidden";
_panel.style.zIndex = 10000;
_panel.setAttribute('class','__53jlsfsfsd__________');
var html = '';
for(var itm in MenuItems.FieldArea.ItmHTMLs)
{
if (itm.indexOf(key)==0)
html = MenuItems.FieldArea.ItmHTMLs[itm];
}
//_panel.innerHTML = html;
var F = MenuItems.Func.CreateIFM(html);
_panel.appendChild(F);
window.PDocument.body.appendChild(_panel);
},
FieldItem:function(type,typeEL,w,ow,value) //style Big
{
//Style,background,#fff,20,24,Editor.SomeFunc();
//Emot ,src,imgurl,20,24,Editor.SomeFunc();
var itmDiv = document.createElement('DIV');
var cssText;
var cssText2;
var marginWidth = (ow - w) / 2;
cssText = "width:"+w+"px;height:"+w+"px;margin:"+marginWidth+"px auto;padding:0px;";//mouseout
cssText2 = "width:"+w+"px;height:"+w+"px;margin:"+marginWidth+"px auto;padding:0px;";//mouseover
switch(type)
{
case "STYLE":
cssText += "border:1px solid #1E90FF;" + typeEL + ":#" + value + ";";
cssText2 += "border:1px solid #FA8072;" + typeEL + ":#" + value + ";";
itmDiv.setAttribute('onclick', 'Editor.FontColor(\'#'+value+'\');MenuItems.Func.CheckIsExist();');
break;
case "EMOT":
value = Math.floor(Math.random() * 80+1);
cssText += "border:0px solid #ddd;background:#fff;cursor:hand;cursor:pointer;";
cssText2 += "border:0px solid #ddd;background:#f3f3f3;cursor:hand;cursor:pointer;";
itmDiv.innerHTML = '<img src=\''+WeisConfig.EditorPath+'weisEmot\/'+value+'.gif\' align=\'middle\' style=\'margin:4px 0 0 0;\'/>';
itmDiv.setAttribute('onclick', 'Editor.emoticon('+value+');MenuItems.Func.CheckIsExist();');
break;
}
itmDiv.setAttribute('onmouseover','this.style.cssText=\''+cssText2+'\'');
itmDiv.setAttribute('onmouseout','this.style.cssText=\''+cssText+'\'');
itmDiv.setAttribute('unselectable','on');
itmDiv.style.cssText = cssText;
var outDiv = document.createElement('DIV');
outDiv.appendChild(itmDiv);
return outDiv.innerHTML;
},
FieldHTML:function(type,sp,ow,N,w,typeEL) //Config Items Array,outerWidth(TD),N(Col),w(Item width)
{
var html = '<div style=\'width:auto;height:auto;background:#fff;float:left;border:1px solid #333;padding:2px;margin:0px;\'>';
html += '<table cellpadding=\'0\' cellspacing=\'2\' border=\'0\' align=\'left\' style=\'margin:0px;padding:0px;\'><tr>';
var col = 0;
for (var i=0;i<=sp.length-1;i++)
{
col++;
html += '<td style=\'text-align:center;\' width=\''+ow+'\' height=\''+ow+'\'>'+MenuItems.FieldArea.FieldItem(type,typeEL,w,ow,sp[i])+'</td>'; //Style,background,#fff,20,24
if ((col % N) == 0)
html += '<\/tr><tr>';
}
if ((sp.length % N) != 0)
{
var y = sp.length % N;
for (var i=1;i<=y;i++)
html += '<td style=\'\' width=\''+ow+'\' height=\''+ow+'\'> </td>';
}
html += '</tr><\/table><\/div>';
return html;
}
}
MenuItems.Func = {
GetIDXY:function(tblKey)
{
var e = $(tblKey);
var left = 0,top = 0;
left += MenuItems.Func.GetLeftTop(e).Left;
top += MenuItems.Func.GetLeftTop(e).Top;
var w = window;
while (w && w.parent != w)
{
if (w.parent&&w.parent.document.getElementsByTagName('frameset').length>0)
break;
if (w.frameElement)
{
var f = w.frameElement;
left += MenuItems.Func.GetLeftTop(f).Left;
top += MenuItems.Func.GetLeftTop(f).Top;
}
w = w.parent;
}
//alert(left + ' ' + top);
return {Left:left,Top:top};
},
GetLeftTop:function(e)
{
var top=e.offsetTop;
var left=e.offsetLeft;
var width=e.offsetWidth;
var height=e.offsetHeight;
while(e=e.offsetParent)
{
top+=e.offsetTop;
left+=e.offsetLeft;
}
return {Left:left,Top:top};
},
CreateIFM:function(html)
{
var F = $P('ifrSelect');
if(!F) F=window.PDocument.createElement('iframe');
F.style.display = '';
F.id = 'ifrSelect';
F.src = WeisConfig.EditorPath + 'js/select.html?e='+Math.random();
F.width = '100%';
F.height = '100%';
F.frameBorder = '0';
F.hspace = '0';
F.vspace = '0';
F.scrolling = 'no';
F.unselectable = 'on';
F.FuncType = '';
F.CSWindow = {Editor:window,ListHTML:html};
return F;
},
CheckIsExist:function()
{
if ($P('______crt___PANEL__List____'))$P('______crt___PANEL__List____').parentNode.removeChild($P('______crt___PANEL__List____'));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -