📄 yqweditor.js
字号:
this.controlobj.onmouseover = YQW_Popup_Events.prototype.controlobj_onmouseover;
}
};
/**
* Init the popup menu object
*/
YQW_Popup_Menu.prototype.init_menu = function(){
this.menuobj = document.getElementById(this.menuname);
if (this.menuobj && !this.menuobj.initialized){
this.menuobj.initialized = true;
this.menuobj.onclick = e_by_gum;
this.menuobj.style.position = 'absolute';
this.menuobj.style.zIndex = 50;
if (is_ie && !is_mac){
this.menuobj.style.filter += "progid:DXImageTransform.Microsoft.alpha(enabled=1,opacity=100)";
this.menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#8E8E8E,strength=3)";
}
this.init_menu_contents();
}
};
/**
* Init the popup menu contents
*/
YQW_Popup_Menu.prototype.init_menu_contents = function(){
var tds = getTags(this.menuobj, 'td');
for (var i = 0; i < tds.length; i++){
if (tds[i].className == 'YQWmenu_option'){
if (tds[i].title && tds[i].title == 'nohilite'){
// not an active cell
tds[i].title = '';
}else{
tds[i].controlkey = this.controlkey;
tds[i].onmouseover = YQW_Popup_Events.prototype.menuoption_onmouseover;
tds[i].onmouseout = YQW_Popup_Events.prototype.menuoption_onmouseout;
var links = getTags(tds[i], 'a');
if (links.length == 1){
/* Ok we have a link, we should use this if
1. There is no onclick event in the link
2. There is no onclick event on the cell
3. The onclick event for the cell should equal the link if the above are true
If we find a browser thats gets confused we may need to set remove_link to true for it.
*/
tds[i].className = tds[i].className + ' YQWmenu_option_alink';
tds[i].islink = true;
var linkobj = links[0];
var remove_link = false;
if (typeof linkobj.onclick == 'function'){
tds[i].ofunc = linkobj.onclick;
tds[i].onclick = YQW_Popup_Events.prototype.menuoption_onclick_function;
remove_link = true;
}else if (typeof tds[i].onclick == 'function'){
tds[i].ofunc = tds[i].onclick;
tds[i].onclick = YQW_Popup_Events.prototype.menuoption_onclick_function;
remove_link = true;
}else{
tds[i].href = linkobj.href;
tds[i].onclick = YQW_Popup_Events.prototype.menuoption_onclick_link;
}
if (remove_link){
var myspan = document.createElement('span');
myspan.innerHTML = linkobj.innerHTML;
tds[i].insertBefore(myspan, linkobj);
tds[i].removeChild(linkobj);
}
}else if (typeof tds[i].onclick == 'function'){
tds[i].ofunc = tds[i].onclick;
tds[i].onclick = YQW_Popup_Events.prototype.menuoption_onclick_function;
}
}
}
}
};
/**
* Show the menu
*
* @param object The control object calling the menu
* @param boolean Use slide (false) or open instantly? (true)
*/
YQW_Popup_Menu.prototype.show = function(obj, instant){
if (!YQWmenu.active){
return false;
}else if (!this.menuobj){
this.init_menu();
}
if (!this.menuobj){
return false;
}
if (YQWmenu.activemenu != null){
YQWmenu.menus[YQWmenu.activemenu].hide();
}
YQWmenu.activemenu = this.controlkey;
this.menuobj.style.display = '';
if (this.slide_open){
this.menuobj.style.clip = 'rect(auto, 0px, 0px, auto)';
}
this.pos = this.fetch_offset(obj);
this.leftpx = this.pos['left'];
this.toppx = this.pos['top'] + obj.offsetHeight;
if ((this.leftpx + this.menuobj.offsetWidth) >= document.body.clientWidth && (this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth) > 0){
this.leftpx = this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth;
this.direction = 'right';
}else{
this.direction = 'left'
}
this.menuobj.style.left = this.leftpx + 'px';
this.menuobj.style.top = this.toppx + 'px';
if (!instant && this.slide_open){
this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps);
this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps);
this.slide((this.direction == 'left' ? 0 : this.menuobj.offsetWidth), 0, 0);
}else if (this.menuobj.style.clip && this.slide_open){
this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
}
// deal with IE putting <select> elements on top of everything
this.handle_overlaps(true);
if (this.controlobj.editorId){
this.controlobj.state = true;
//this.controlobj.editor.menu_context(this.controlobj, 'mousedown');
YeQiangWei_Editor[this.controlobj.editorId].menuContext(this.controlobj, 'mousedown');
}
};
/**
* Hide the menu
*/
YQW_Popup_Menu.prototype.hide = function(e){
if (e && e.button && e.button != 1){
// get around some context menu issues etc.
return true;
}
this.stop_slide();
this.menuobj.style.display = 'none';
this.handle_overlaps(false);
if (this.controlobj.editorId){
this.controlobj.state = false;
//this.controlobj.editor.menu_context(this.controlobj, 'mouseout');
YeQiangWei_Editor[this.controlobj.editorId].menuContext(this.controlobj, 'mouseout');
}
YQWmenu.activemenu = null;
};
/**
* Hover behaviour for control object
*/
YQW_Popup_Menu.prototype.hover = function(obj){
if (YQWmenu.activemenu != null){
if (YQWmenu.menus[YQWmenu.activemenu].controlkey != this.id){
this.show(obj, true);
}
}
};
/**
* Slides menu open
*
* @param integer Clip X
* @param integer Clip Y
* @param integer Opacity (0-100)
*/
YQW_Popup_Menu.prototype.slide = function(clipX, clipY, opacity){
if (this.direction == 'left' && (clipX < this.menuobj.offsetWidth || clipY < this.menuobj.offsetHeight)){
if (YQWmenu.open_fade && is_ie){
opacity += 10;
this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
}
clipX += this.intervalX;
clipY += this.intervalY;
this.menuobj.style.clip = "rect(auto, " + clipX + "px, " + clipY + "px, auto)";
this.slidetimer = setTimeout("YQWmenu.menus[YQWmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
}else if (this.direction == 'right' && (clipX > 0 || clipY < this.menuobj.offsetHeight)){
if (YQWmenu.open_fade && is_ie){
opacity += 10;
menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
}
clipX -= this.intervalX;
clipY += this.intervalY;
this.menuobj.style.clip = "rect(auto, " + this.menuobj.offsetWidth + "px, " + clipY + "px, " + clipX + "px)";
this.slidetimer = setTimeout("YQWmenu.menus[YQWmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
}else{
this.stop_slide();
}
};
/**
* Abort menu slider
*/
YQW_Popup_Menu.prototype.stop_slide = function(){
clearTimeout(this.slidetimer);
this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
if (YQWmenu.open_fade && is_ie){
this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = 100;
}
};
/**
* Fetch offset of an object
*
* @param object The object to be measured
*
* @return array The measured offsets left/top
*/
YQW_Popup_Menu.prototype.fetch_offset = function(obj){
var left_offset = obj.offsetLeft;
var top_offset = obj.offsetTop;
while ((obj = obj.offsetParent) != null){
left_offset += obj.offsetLeft;
top_offset += obj.offsetTop;
}
return { 'left' : left_offset, 'top' : top_offset };
};
/**
* Detect an overlap of an object and a menu
*
* @param object Object to be tested for overlap
* @param array Array of dimensions for menu object
*
* @return boolean True if overlap
*/
YQW_Popup_Menu.prototype.overlaps = function(obj, m){
var s = new Array();
var pos = this.fetch_offset(obj);
s['L'] = pos['left'];
s['T'] = pos['top'];
s['R'] = s['L'] + obj.offsetWidth;
s['B'] = s['T'] + obj.offsetHeight;
if (s['L'] > m['R'] || s['R'] < m['L'] || s['T'] > m['B'] || s['B'] < m['T']){
return false;
}
return true;
};
/**
* Handle IE overlapping <select> elements
*
* @param boolean Hide (true) or show (false) overlapping <select> elements
*/
YQW_Popup_Menu.prototype.handle_overlaps = function(dohide){
if (is_ie){
var selects = getTags(document, 'select');
if (dohide){
var menuarea = new Array(); menuarea = {
'L' : this.leftpx,
'R' : this.leftpx + this.menuobj.offsetWidth,
'T' : this.toppx,
'B' : this.toppx + this.menuobj.offsetHeight
};
for (var i = 0; i < selects.length; i++){
if (this.overlaps(selects[i], menuarea)){
var hide = true;
var s = selects[i];
while (s = s.parentNode){
if (s.className == 'YQWmenu_popup'){
hide = false;
break;
}
}
if (hide){
selects[i].style.visibility = 'hidden';
array_push(YQWmenu.hidden_selects, i);
}
}
}
}else{
while (true){
var i = array_pop(YQWmenu.hidden_selects);
if (typeof i == 'undefined' || i == null){
break;
}else{
selects[i].style.visibility = 'visible';
}
}
}
}
};
// #############################################################################
// Menu event handler functions
/**
* Class containing menu popup event handlers
*/
function YQW_Popup_Events(){};
/**
* Handles control object click events
*/
YQW_Popup_Events.prototype.controlobj_onclick = function(e){
if (typeof doEvent == 'function'){
doEvent(e);
if (YQWmenu.activemenu == null || YQWmenu.menus[YQWmenu.activemenu].controlkey != this.id){
YQWmenu.menus[this.id].show(this);
}else{
YQWmenu.menus[this.id].hide();
}
}
};
/**
* Handles control object mouseover events
*/
YQW_Popup_Events.prototype.controlobj_onmouseover = function(e){
if (typeof doEvent == 'function'){
doEvent(e);
YQWmenu.menus[this.id].hover(this);
}
};
/**
* Handles menu option click events for options with onclick events
*/
YQW_Popup_Events.prototype.menuoption_onclick_function = function(e){
this.ofunc(e);
YQWmenu.menus[this.controlkey].hide();
};
/**
* Handles menu option click events for options containing links
*/
YQW_Popup_Events.prototype.menuoption_onclick_link = function(e){
e = e ? e : window.event;
if (e.shiftKey){
window.open(this.href);
}else{
window.location = this.href;
}
// Safari has "issues" with resetting what was clicked on, super minor and I dont care
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
if (e.preventDefault) e.preventDefault();
YQWmenu.menus[this.controlkey].hide();
return false;
};
/**
* Handles menu option mouseover events
*/
YQW_Popup_Events.prototype.menuoption_onmouseover = function(e){
this.className = 'YQWmenu_hilite' + (this.islink ? ' YQWmenu_hilite_alink' : '');
this.style.cursor = pointer_cursor;
};
/**
* Handles menu option mouseout events
*/
YQW_Popup_Events.prototype.menuoption_onmouseout = function(e){
this.className = 'YQWmenu_option' + (this.islink ? ' YQWmenu_option_alink' : '');
this.style.cursor = 'default';
};
function YQWmenu_register(controlid, noimage, datefield){
if (typeof YQWmenu == 'object'){
return YQWmenu.register(controlid, noimage);
}
}
/* menu end */
function setUnSelectTable(obj){
if (!is_ie4 && typeof obj.tagName != 'undefined'){
if (obj.hasChildNodes()){
for (var i = 0; i < obj.childNodes.length; i++){
setUnSelectTable(obj.childNodes[i]);
}
}
obj.unselectable = 'on';
}
}
var YeQiangWei_Editor = new Array();
var fontoptions = new Array("黑体", "仿宋_GB2312", "楷体_GB2312", "幼圆", "宋体", "新宋体", "新細明體", "Arial", "Arial Black", "Arial Narrow", "Book Antiqua", "Century Gothic", "Comic Sans MS", "Courier New", "Fixedsys", "Franklin Gothic Medium", "Garamond", "Georgia", "Impact", "Lucida Console", "Lucida Sans Unicode", "Microsoft Sans Serif", "Palatino Linotype", "System", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
var sizeoptions = new Array(1,2,3,4,5,6,7);
var istyles = new Array();
istyles = { "pi_button_down" : [ "#98B5E2", "#000000", "0px", "1px solid #316AC5" ]
, "pi_button_hover" : [ "#C1D2EE", "#000000", "0px", "1px solid #316AC5" ]
, "pi_button_normal" : [ "#D4D0C8", "#000000", "0px", "1px solid #D4D0C8" ]
, "pi_button_selected" : [ "#F1F6F8", "#000000", "0px", "1px solid #316AC5" ]
, "pi_menu_down" : [ "#98B5E2", "#316AC5", "0px", "1px solid #316AC5" ]
, "pi_menu_hover" : [ "#C1D2EE", "#316AC5", "0px", "1px solid #316AC5" ]
, "pi_menu_normal" : [ "#FFFFFF", "#000000", "0px", "1px solid #FFFFFF" ]
, "pi_popup_down" : [ "#98B5E2", "#000000", "0px", "1px solid #316AC5" ]
};
var contextcontrols = new Array(
'bold',
'italic',
'underline',
'justifyleft',
'justifycenter',
'justifyright',
'insertorderedlist',
'insertunorderedlist'
);
var coloroptions = new Array();
coloroptions = {
'#000000' : 'black',
'#A0522D' : 'sienna',
'#556B2F' : 'darkoliveGreen',
'#006400' : 'darkGreen',
'#483D8B' : 'darkSlateBlue',
'#000080' : 'navy',
'#4B0082' : 'indigo',
'#2F4F4F' : 'darkSlateGray',
'#8B0000' : 'darkRed',
'#FF8C00' : 'darkOrange',
'#808000' : 'olive',
'#008000' : 'green',
'#008080' : 'teal',
'#0000FF' : 'blue',
'#708090' : 'slateGray',
'#696969' : 'dimGray',
'#FF0000' : 'red',
'#F4A460' : 'sandyBrown',
'#9ACD32' : 'yellowGreen',
'#2E8B57' : 'seaGreen',
'#48D1CC' : 'mediumTurquoise',
'#4169E1' : 'royalBlue',
'#800080' : 'purple',
'#808080' : 'gray',
'#FF00FF' : 'magenta',
'#FFA500' : 'orange',
'#FFFF00' : 'yellow',
'#00FF00' : 'lime',
'#00FFFF' : 'cyan',
'#00BFFF' : 'deepSkyBlue',
'#9932CC' : 'darkOrchid',
'#C0C0C0' : 'silver',
'#FFC0CB' : 'pink',
'#F5DEB3' : 'wheat',
'#FFFACD' : 'lemonChiffon',
'#98FB98' : 'paleGreen',
'#AFEEEE' : 'paleTurquoise',
'#ADD8E6' : 'lightBlue',
'#DDA0DD' : 'plum',
'#FFFFFF' : 'white'
};
var smilieoptions = new Array();
smilieoptions = {'标准表情图标' : {
'17' : new Array('images/smilies/ft.gif', ':ft:', '狂晕'),
'16' : new Array('images/smilies/cry.gif', ':cry:', '大哭')
}};
/**
* Checks that a message is valid for submission to PHP
* @param string Message text
* @param mixed Either subject text (if you want to make sure it exists) or 0 if you don't care
* @param integer Minimum acceptable character limit for the message
* @return boolean
*/
function validateMessage(messagetext, subjecttext, minchars){
if (is_kon || is_saf || is_webtv){
return true;
}
/* 验证标题
else if (subjecttext.length < 1)
{
alert(vbphrase['must_enter_subject']);
return false;
}
*/
else{
var stripped = JAVA.trim(stripcode(subjecttext, false, ignorequotechars));
/* 验证最少字数 主题和内容均不够要求字数 */
if (stripped.length < minchars){
//alert(constructPhrase(vbphrase['message_too_short']+"主题和回复最少字数为:"+minchars, minchars));
//return false;
}
/* 带验证码
else if (typeof(document.forms.Gforms) != 'undefined' && typeof(document.forms.Gforms.imagestamp) != 'undefined')
{
if (document.forms.Gforms.imagestamp.value.length != 6)
{
alert(vbphrase['complete_image_verification']);
document.forms.Gforms.imagestamp.focus();
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -