⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yqweditor.js

📁 JSP购物车(SQLserver版) ================== 简单的JSP电子商务网站购物车 带结算功能,带注册系统 大二时自己编写的,供大家参考学习 功能不是很详尽,美工
💻 JS
📖 第 1 页 / 共 5 页
字号:
			}
			else
			{
				return true;
			}
		}
		*/
		else if (typeof(document.forms.Gforms) != 'undefined'){	
			return true;
		}else{
			return true;
		}
		return true;
	}
}
function constructPhrase(){
	if (!arguments || arguments.length < 1 || !is_regexp){
		return false;
	}
	var args = arguments;
	var str = args[0];
	var re;
	for (var i = 1; i < args.length; i++){
		re = new RegExp("%" + i + "\\$s", 'gi');
		str = str.replace(re, args[i]);
	}
	return str;
}
var vbphrase = new Array();
vbphrase["wysiwyg_please_wait"]          = "请等待所见即所得编辑器读取完成...";
vbphrase["wysiwyg_initialized"]          = "所见即所得编辑器初始化 需要 10 秒钟。";
vbphrase["wysiwyg_command_invalid"]      = "此命令无效或者没有被执行。";
vbphrase["moz_must_select_text"]         = "Mozilla 需要您首先选择一些文字来使用此功能。";
vbphrase["moz_edit_config_file"]         = "您需要编辑您的 Mozilla 配置文件以允许此操作。";
vbphrase["enter_tag_option"]             = "请输入标签的选项:";
vbphrase["must_select_text_to_use"]      = "您在使用该功能前必须选择一些文本。";
vbphrase["browser_is_safari_no_wysiwyg"] = "Safari 浏览器不支持即见即所得模式。";
vbphrase["enter_option_x_tag"]           = "请输入标签 [%1$s] 的选项:";
vbphrase["enter_text_to_be_formatted"]   = "输入格式化的字符";
vbphrase["enter_link_text"]              = "输入此链接显示的文字(可不填):";
vbphrase["enter_list_type"]              = "您想要什么类型的列表? 输入“1”为数字列表,输入“a”为字母列表,或者留空为大圆点列表:";
vbphrase["enter_list_item"]              = "输入一个列表项目。\r\n留空或者点击“取消”完成此列表。";
vbphrase["must_enter_subject"]           = "您必须输入一个主题/标题!";
vbphrase["message_too_short"]            = "您输入的信息太短啦!";
vbphrase["enter_link_url"]               = "请输入链接的地址:";
vbphrase["enter_image_url"]              = "请输入图片链接地址:";
vbphrase["enter_email_link"]             = "请输入此链接的邮箱地址:";
vbphrase["complete_image_verification"]  = "您没有完成图像验证";
vbphrase["iespell_not_installed"]        = "ieSpell 是 Internet Explorer 的拼写检查工具。\r\n\r\n如果您想下载 ieSpell,请点击“确定”,否则点击“取消”。\r\n\r\nieSpell 可以从 http://www.iespell.com 下载。";
vbphrase["click_quick_reply_icon"]       = "";
vbphrase["insert_all"]                   = "插入全部";
vbphrase["enter_music_url"]             = "请输入Windows Media Player支持的播放格式的音乐文件(如mp3,wam)文件地址:";
vbphrase["enter_media_url"]             = "请输入Windows Media Player支持的播放格式的视频文件地址(如wmv,avi,wav):";
vbphrase["enter_real_url"]              = "请输入Real支持的播放格式的视频文件地址:";
vbphrase["enter_flash_url"]             = "请输入Flash文件地址:";
var AJAX_Compatible = false;
function doEvent(eventobj){
	if (!eventobj || is_ie){
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	}else{
		eventobj.stopPropagation();
		eventobj.preventDefault();
		return eventobj;
	}
}
function YeQiangWeiEditor(editorId, w, h, mode, initial_text){ 
	this.initialized = false;
	this.editorId = editorId;
	this.wysiwygMode = parseInt(mode, 10) ? 1 : 0;
	this.textObj = c.o(this.editorId + '_textarea');
	//this.parsesmilies = (typeof parsesmilies == 'undefined' ? 1 : parsesmilies);
	this.popupmode = (typeof YQWmenu == 'undefined' ? false : true);
	this.controlBar = c.o(this.editorId + '_controls');
	this.buttons = new Array();
	this.popups = new Array();
	this.fontstate = null;
	this.sizestate = null;
	this.colorstate = null;
	this.clipboard = '';
	this.disabled = false;
	this.history = new YeQiangWeiHistory();
	this.influx = 0;
	this.init = function(){
		this.textObj.disabled = false;
		if (this.tempiframe)
		{
			this.tempiframe.parentNode.removeChild(this.tempiframe);
		}
		c.o(this.editorId).style.width=w;
		this.setEditorContents(initial_text);
		this.setEditorFunctions();
		this.initControls();
		//this.initSmilies(c.o(this.editorId + '_smiliebox'));
		this.initialized = true;
	};
	/**
	* Init button controls for the editor
	*/
	this.initControls = function(){
		var controls = new Array();
		if (this.controlBar == null){return;}
		var buttons = getTags(this.controlBar, 'div');
		for (var i = 0; i < buttons.length; i++){
			if (buttons[i].className=='imageButton' && buttons[i].id){
				controls[controls.length] = buttons[i].id;
			}
		}
		for (var i = 0; i < controls.length; i++){
			var control = c.o(controls[i]);
			if (control.id.indexOf(this.editorId + '_cmd_') != -1){
				this.initCommandButton(control);
			}else if (control.id.indexOf(this.editorId + '_popup_') != -1){
				this.initPopupButton(control);
			}
		}
		setUnSelectTable(this.controlBar);
	};
	
	/**
	* Init Smilies
	*/
	this.initSmilies = function(smilie_container){
		if (smilie_container != null){
			var smilies = getTags(smilie_container, 'img');
			for (var i = 0; i < smilies.length; i++){
				if (smilies[i].id && smilies[i].id.indexOf('_smilie_') != false){
					smilies[i].style.cursor = pointer_cursor;
					smilies[i].editorId = this.editorId;
					smilies[i].onclick = YeQiangWeiEditor_Events.prototype.smilie_onclick;
					smilies[i].unselectable = 'on';
				}
			}
		}
	}
	
	/**
	* Check if we need to refocus the editor window
	*/
	this.checkFocus = function(){
		if (!this.editWin.hasfocus)	{
			this.editWin.focus();
			if (is_opera){this.editWin.focus();}
		}	
	}
	/**
	* Init command button (b, i, u etc.)
	*
	* @param	object	Current HTML button node
	*/
	this.initCommandButton = function(obj){	
		obj.cmd = obj.id.substr(obj.id.indexOf('_cmd_') + 5);
		obj.editorId = this.editorId;
		this.buttons[obj.cmd] = obj;	
		if (obj.cmd == 'switchmode'){
			if (AJAX_Compatible){
				obj.state = this.wysiwygMode ? true : false;
				this.setControlStyle(obj, 'button', this.wysiwygMode ? 'selected' : 'normal');
			}else{
				obj.parentNode.removeChild(obj);
			}
		}else{
			obj.state = false;
			obj.mode = 'normal';
		}
		obj.onclick = obj.onmousedown = obj.onmouseover = obj.onmouseout = YeQiangWeiEditor_Events.prototype.command_button_onmouseevent;
	}
	
	/**
	* Init popup button (forecolor, fontname etc.)
	*
	* @param	object	Current HTML button node
	*/
	this.initPopupButton = function(obj){
		obj.cmd = obj.id.substr(obj.id.indexOf('_popup_') + 7);
		if (this.popupmode){
			YQWmenu.register(obj.id, true);
			YQWmenu.menus[obj.id].open_steps = 5;
			obj.editorId = this.editorId;
			obj.state = false;
			this.buttons[obj.cmd] = obj;
			if (obj.cmd == 'fontname'){
				this.fontout = c.o(this.editorId + '_font_out');
				this.fontout.innerHTML = obj.title;
				this.fontoptions = {'' : this.fontout};
				for (var option in fontoptions){
					var div = document.createElement('div');
					div.id = this.editorId + '_fontoption_' + fontoptions[option];
					div.style.width = this.fontout.style.width;
					div.style.display = 'none';
					div.innerHTML = fontoptions[option];
					this.fontoptions[fontoptions[option]] = this.fontout.parentNode.appendChild(div);
				}
			}else if (obj.cmd == 'fontsize'){
				this.sizeout = c.o(this.editorId + '_size_out');
				this.sizeout.innerHTML = obj.title;
				this.sizeoptions = {'' : this.sizeout};
				for (var option in sizeoptions){
					var div = document.createElement('div');
						div.id = this.editorId + '_sizeoption_' + sizeoptions[option];
						div.style.width = this.sizeout.style.width;
						div.style.display = 'none';
						div.innerHTML = sizeoptions[option];
						this.sizeoptions[sizeoptions[option]] = this.sizeout.parentNode.appendChild(div);
				}
			}
			// extend onmouseover
			obj._onmouseover = obj.onmouseover;
			// extend onclick
			obj._onclick = obj.onclick;
			// event handlers
			obj.onmouseover = obj.onmouseout = obj.onclick = YeQiangWeiEditor_Events.prototype.popup_button_onmouseevent;
			// extend menu show
			YQWmenu.menus[obj.id]._show = YQWmenu.menus[obj.id].show;
			YQWmenu.menus[obj.id].show = YeQiangWeiEditor_Events.prototype.popup_button_show;
		}else{
			this.buildSelect(obj);
		}
	}
	/**
	* Replace the popup controls with <select> menus for rubbish browsers
	*
	* @param	object	The popup control element
	*/
	this.buildSelect = function(obj){
		var sel = document.createElement('select');
		sel.id = this.editorId + '_select_' + obj.cmd;
		sel.editorId = this.editorId;
		sel.cmd = obj.cmd;
		var opt = document.createElement('option');
		opt.value = '';
		opt.text = obj.title;
		sel.add(opt, is_ie ? sel.options.length : null);
		var opt = document.createElement('option');
		opt.value = '';
		opt.text = ' ';
		sel.add(opt, is_ie ? sel.options.length : null);
		switch (obj.cmd){
			case 'fontname':
			{
				for (var i = 0; i < fontoptions.length; i++)
				{
					var opt = document.createElement('option');
					opt.value = fontoptions[i];
					opt.text = (fontoptions[i].length > 10 ? (fontoptions[i].substr(0, 10) + '...') : fontoptions[i]);
					sel.add(opt, is_ie ? sel.options.length : null);
				}
				sel.onchange = YeQiangWeiEditor_Events.prototype.formatting_select_onchange;
				break;
			}
			case 'fontsize':
			{
				for (var i = 0; i < sizeoptions.length; i++){
					var opt = document.createElement('option');
					opt.value = sizeoptions[i];
					opt.text = sizeoptions[i];
					sel.add(opt, is_ie ? sel.options.length : null);
				}
				sel.onchange = YeQiangWeiEditor_Events.prototype.formatting_select_onchange;
				break;
			}case 'forecolor':
			{
				for (var i in coloroptions)
				{
					var opt = document.createElement('option');
					opt.value = coloroptions[i];
					opt.text = JAVA.trim((coloroptions[i].length > 5 ? (coloroptions[i].substr(0, 5) + '...') : coloroptions[i]).replace(new RegExp('([A-Z])', 'g'), ' $1'));
					opt.style.backgroundColor = i;
					sel.add(opt, is_ie ? sel.options.length : null);
				}
				sel.onchange = YeQiangWeiEditor_Events.prototype.formatting_select_onchange;
				break;
			}
			/*
			case 'smilie':
			{
				for (var cat in smilieoptions)
				{
					for (var smilieid in smilieoptions[cat])
					{
						if (smilieid != 'more')
						{
							var opt = document.createElement('option');
							opt.value = smilieoptions[cat][smilieid][1];
							opt.text = smilieoptions[cat][smilieid][1];
							opt.smilieid = smilieid;
							opt.smiliepath = smilieoptions[cat][smilieid][0];
							opt.smilietitle = smilieoptions[cat][smilieid][2];
							sel.add(opt, is_ie ? sel.options.length : null);
						}
					}
				}
				sel.onchange = YeQiangWeiEditor_Events.prototype.smilieselect_onchange;
				break;
			}
			case 'attach':
			{
				sel.onmouseover = YeQiangWeiEditor_Events.prototype.attachselect_onmouseover;
				sel.onchange = YeQiangWeiEditor_Events.prototype.attachselect_onchange;
				break;
			}
			*/
		}
		while (obj.hasChildNodes())
		{
			obj.removeChild(obj.firstChild);
		}
		this.buttons[obj.cmd] = obj.appendChild(sel);
	}

	/**
	* Init menu controls for the editor
	*
	* @param	object	HTML menu node
	*/
	this.initPopupMenu = function(obj)
	{
		if (this.disabled)
		{
			return;
		}
		
		switch (obj.cmd)
		{
			case 'fontname':
			{
				var menu = this.initMenuContainer('fontname', 'auto', '200px', 'auto');
				this.buildFontnamePopup(obj, menu);
				break;
			}
			case 'fontsize':
			{
				var menu = this.initMenuContainer('fontsize', 'auto', 'auto', 'visible');
				this.buildFontsizePopup(obj, menu);
				break;
			}
			case 'forecolor':
			{
				var menu = this.initMenuContainer('forecolor', 'auto', 'auto', 'visible');
				this.buildForecolorPopup(obj, menu);
				break;
			}
			/*
			case 'smilie':
			{
				var menu = this.initMenuContainer('smilie', '175px', '250px', 'auto');
				this.build_smilie_popup(obj, menu);
				break;
			}
			case 'attach':
			{
				if (typeof vB_Attachments != 'undefined' && vB_Attachments.has_attachments())
				{
					var menu = this.initMenuContainer('attach', 'auto', 'auto', 'visible');
					this.build_attachments_popup(menu, obj);
				}
				else
				{
					return c.o('manage_attachments_button').onclick();
				}
			}
			*/
		}
		this.popups[obj.cmd] = this.controlBar.appendChild(menu);
		setUnSelectTable(menu);
	};


	/**
	* Init Menu Container DIV
	*
	* @param	string	Command string (forecolor, fontname etc.)
	* @param	string	CSS width for the menu
	* @param	string	CSS height for the menu
	* @param	string	CSS overflow for the menu
	*
	* @return	object	Newly created menu element
	*/
	this.initMenuContainer = function(cmd, width, height, overflow)
	{
		var menu = document.createElement('div');
		menu.id = this.editorId + '_popup_' + cmd + '_menu';
		menu.className = 'YQWmenu_popup';
		menu.style.display = 'none';
		menu.style.cursor = 'default';
		menu.style.padding = '0px';
		menu.style.width = width;
		menu.style.height = height;
		menu.style.overflow = overflow;
		return menu;
	}

	/**
	* Build Font Name Popup Contents
	*
	* @param	object	The control object for the menu
	* @param	object	The menu container object
	*/
	this.buildFontnamePopup = function(obj, menu)
	{
		for (var n in fontoptions)
		{
			var option = document.createElement('div');
			option.innerHTML = '<font face="' + fontoptions[n] + '">' + fontoptions[n] + '</font>';
			option.className = 'ofont';
			option.style.textAlign = 'left';
			option.title = fontoptions[n];
			option.cmd = obj.cmd;
			option.controlkey = obj.id;
			option.editorId = this.editorId;
			option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = YeQiangWeiEditor_Events.prototype.menuoption_onmouseevent;
			option.onclick = YeQiangWeiEditor_Events.prototype.formatting_option_onclick;
			menu.appendChild(option);
		}
	}


	/**
	* Build Font Size Popup Contents
	*
	* @param	object	The control object for the menu
	* @param	object	The menu container object
	*/
	this.buildFontsizePopup = function(obj, menu)
	{
		//for (var n in sizeoptions)
		for(var n=0; n<sizeoptions.length; n++)
		{
			var option = document.createElement('div');
			option.innerHTML = '<font size="' + sizeoptions[n] + '">' + sizeoptions[n] + '</font>';
			option.className = 'osize';
			option.style.textAlign = 'center';
			option.title = sizeoptions[n];
			option.cmd = obj.cmd;
			option.controlkey = obj.id;
			option.editorId = this.editorId;
			option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = YeQiangWeiEditor_Events.prototype.menuoption_onmouseevent;
			option.onclick = YeQiangWeiEditor_Events.prototype.formatting_option_onclick;
			menu.appendChild(option);
		}
	}

	
	/**
	* Build ForeColor Popup Contents
	*
	* @param	object	The control object for the menu
	* @param	object	The menu container object
	*/
	this.buildForecolorPopup = function(obj, menu)
	{	
		var colorout = c.o(this.editorId + '_color_out');
		colorout.editorId = this.editorId;
		colorout.onclick = YeQiangWeiEditor_Events.prototype.colorout_onclick;
		var table = document.createElement('table');
		table.cellPadding = 0;
		table.cellSpacing = 0;
		table.border = 0;
		var i = 0;
		for (var hex in coloroptions)
		{
			if(hex=="toJSONString"){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -