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

📄 editor_template_src.js

📁 php邮件模块
💻 JS
📖 第 1 页 / 共 3 页
字号:
/* Import theme specific language pack */
tinyMCE.importThemeLanguagePack('advanced');

// Variable declarations
var TinyMCE_advanced_autoImportCSSClasses = true;
var TinyMCE_advanced_resizer = new Object();
var TinyMCE_advanced_buttons = [
	// Control id, button img, button title, command, user_interface, value
	['bold', '{$lang_bold_img}', '{$lang_bold_desc}', 'Bold'],
	['italic', '{$lang_italic_img}', '{$lang_italic_desc}', 'Italic'],
	['underline', '{$lang_underline_img}', '{$lang_underline_desc}', 'Underline'],
	['strikethrough', 'strikethrough.gif', '{$lang_striketrough_desc}', 'Strikethrough'],
	['justifyleft', 'justifyleft.gif', '{$lang_justifyleft_desc}', 'JustifyLeft'],
	['justifycenter', 'justifycenter.gif', '{$lang_justifycenter_desc}', 'JustifyCenter'],
	['justifyright', 'justifyright.gif', '{$lang_justifyright_desc}', 'JustifyRight'],
	['justifyfull', 'justifyfull.gif', '{$lang_justifyfull_desc}', 'JustifyFull'],
	['bullist', 'bullist.gif', '{$lang_bullist_desc}', 'InsertUnorderedList'],
	['numlist', 'numlist.gif', '{$lang_numlist_desc}', 'InsertOrderedList'],
	['outdent', 'outdent.gif', '{$lang_outdent_desc}', 'Outdent'],
	['indent', 'indent.gif', '{$lang_indent_desc}', 'Indent'],
	['cut', 'cut.gif', '{$lang_cut_desc}', 'Cut'],
	['copy', 'copy.gif', '{$lang_copy_desc}', 'Copy'],
	['paste', 'paste.gif', '{$lang_paste_desc}', 'Paste'],
	['undo', 'undo.gif', '{$lang_undo_desc}', 'Undo'],
	['redo', 'redo.gif', '{$lang_redo_desc}', 'Redo'],
	['link', 'link.gif', '{$lang_link_desc}', 'mceLink', true],
	['unlink', 'unlink.gif', '{$lang_unlink_desc}', 'unlink'],
	['image', 'image.gif', '{$lang_image_desc}', 'mceImage', true],
	['cleanup', 'cleanup.gif', '{$lang_cleanup_desc}', 'mceCleanup'],
	['help', 'help.gif', '{$lang_help_desc}', 'mceHelp'],
	['code', 'code.gif', '{$lang_theme_code_desc}', 'mceCodeEditor'],
	['hr', 'hr.gif', '{$lang_theme_hr_desc}', 'inserthorizontalrule'],
	['removeformat', 'removeformat.gif', '{$lang_theme_removeformat_desc}', 'removeformat'],
	['sub', 'sub.gif', '{$lang_theme_sub_desc}', 'subscript'],
	['sup', 'sup.gif', '{$lang_theme_sup_desc}', 'superscript'],
	['forecolor', 'forecolor.gif', '{$lang_theme_forecolor_desc}', 'mceForeColor', true],
	['backcolor', 'backcolor.gif', '{$lang_theme_backcolor_desc}', 'mceBackColor', true],
	['charmap', 'charmap.gif', '{$lang_theme_charmap_desc}', 'mceCharMap'],
	['visualaid', 'visualaid.gif', '{$lang_theme_visualaid_desc}', 'mceToggleVisualAid'],
	['anchor', 'anchor.gif', '{$lang_theme_anchor_desc}', 'mceInsertAnchor'],
	['newdocument', 'newdocument.gif', '{$lang_newdocument_desc}', 'mceNewDocument']
];

/**
 * Returns HTML code for the specificed control.
 */
function TinyMCE_advanced_getControlHTML(button_name)
{
	var buttonTileMap = new Array('anchor.gif','backcolor.gif','bullist.gif','justifycenter.gif',
											'charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif',
											'cut.gif','forecolor.gif','justifyfull.gif','help.gif','hr.gif',
											'image.gif','indent.gif','justifyleft.gif','link.gif','numlist.gif',
											'outdent.gif','paste.gif','redo.gif','removeformat.gif',
											'justifyright.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif',
											'unlink.gif','visualaid.gif');

	// Lookup button in button list
	for (var i=0; i<TinyMCE_advanced_buttons.length; i++)
	{
		var but = TinyMCE_advanced_buttons[i];

		if (but[0] == button_name)
		{
			// Check for it in tilemap
			if (tinyMCE.settings['button_tile_map'])
			{
				for (var x=0; !tinyMCE.isMSIE && x<buttonTileMap.length; x++)
				{
					if (buttonTileMap[x] == but[1])
					{
						var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\',' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ',\'' + but[5] + '\'' : '') + ')';
						return '<a href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_' + but[0] +'" src="{$themeurl}/images/spacer.gif" style="background-image:url({$themeurl}/images/buttons.gif); background-position: ' + (0-(x*20)) + 'px 0px" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
					}
				}
			}

			// Old style
			var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\',' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ',\'' + but[5] + '\'' : '') + ')';
			return '<a href="javascript:' + cmd + '" onclick="' + cmd + ';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_' + but[0] + '" src="{$themeurl}/images/' + but[1] + '" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
		}
	}

	// Custom controlls other than buttons
	switch (button_name)
	{
		case "formatselect":
			var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
			var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
			var lookup = [
				['p', '{$lang_theme_paragraph}'],
				['address', '{$lang_theme_address}'],
				['pre', '{$lang_theme_pre}'],
				['h1', '{$lang_theme_h1}'],
				['h2', '{$lang_theme_h2}'],
				['h3', '{$lang_theme_h3}'],
				['h4', '{$lang_theme_h4}'],
				['h5', '{$lang_theme_h5}'],
				['h6', '{$lang_theme_h6}']
			];

			html += '<option value="">{$lang_theme_block}</option>';

			// Build format select
			for (var i=0; i<formats.length; i++)
			{
				for (var x=0; x<lookup.length; x++)
				{
					if (formats[i] == lookup[x][0])
					{
						html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';
					}
				}
			}

			html += '</select>';
			//formatselect
		return html;

		case "styleselect":
			//styleselect
		return '<select id="{$editor_id}_styleSelect" onmousedown="TinyMCE_advanced_setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';

		case "fontselect":
			var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
			var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
			var nFonts = 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
			var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
			for (var i=0; i<fonts.length; i++) {
				if (fonts[i] != '') {
					var parts = fonts[i].split('=');
					fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
				}
			}

			fontHTML += '</select>';
			return fontHTML;

		case "fontsizeselect":
			//fontsizeselect
		return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
		<option value="0">{$lang_theme_font_size}</option>\
		<option value="1">1 (8 pt)</option>\
		<option value="2">2 (10 pt)</option>\
		<option value="3">3 (12 pt)</option>\
		<option value="4">4 (14 pt)</option>\
		<option value="5">5 (18 pt)</option>\
		<option value="6">6 (24 pt)</option>\
		<option value="7">7 (36 pt)</option>\
		</select>';

		case "|":
		case "separator":
		return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';

		case "spacer":
		return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';

		case "rowseparator":
		return '<br />';
	}

	return "";
}

/**
 * Theme specific exec command handeling.
 */
function TinyMCE_advanced_execCommand(editor_id, element, command, user_interface, value)
{
	switch (command)
	{
		case "mceForeColor":
			var template = new Array();
			var elm = tinyMCE.selectedInstance.getFocusElement();
			var inputColor = tinyMCE.getAttrib(elm, "color");

			if (inputColor == '')
				inputColor = elm.style.color;

			if (!inputColor)
				inputColor = "#000000";

			template['file'] = 'color_picker.htm';
			template['width'] = 220;
			template['height'] = 190;

			tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
		return true;

		case "mceBackColor":
			var template = new Array();
			var elm = tinyMCE.selectedInstance.getFocusElement();
			var inputColor = elm.style.backgroundColor;

			if (!inputColor)
				inputColor = "#000000";

			template['file'] = 'color_picker.htm';
			template['width'] = 220;
			template['height'] = 190;

			template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
			template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);

			tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
			//mceBackColor
		return true;

		case "mceColorPicker":
			if (user_interface) {
				var template = new Array();
				var inputColor = value['document'].getElementById(value['element_id']).value;

				template['file'] = 'color_picker.htm';
				template['width'] = 220;
				template['height'] = 190;
				template['close_previous'] = "no";

				template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
				template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);

				if (typeof(value['store_selection']) == "undefined")
					value['store_selection'] = true;

				tinyMCE.lastColorPickerValue = value;
				tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
			} else {
				var savedVal = tinyMCE.lastColorPickerValue;
				var elm = savedVal['document'].getElementById(savedVal['element_id']);
				elm.value = value;
				eval('elm.onchange();');
			}
		return true;

		case "mceCodeEditor":
			var template = new Array();

			template['file'] = 'source_editor.htm';
			template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 500));
			template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 400));

			tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
			//mceCodeEditor
		return true;

		case "mceCharMap":
			var template = new Array();

			template['file'] = 'charmap.htm';
			template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
			template['height'] = 250;

			template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
			template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);

			tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
			//mceCharMap
		return true;

		case "mceInsertAnchor":
			var template = new Array();

			template['file'] = 'anchor.htm';
			template['width'] = 320;
			template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);

			template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
			template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);

			tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
		return true;

		case "mceNewDocument":
			if (confirm(tinyMCE.getLang('lang_newdocument')))
				tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, '');

			return true;
	}

	// Default behavior
	return false;
}

/**
 * Editor instance template function.
 */
function TinyMCE_advanced_getEditorTemplate(settings, editorId)
{
	function removeFromArray(in_array, remove_array)
	{
		var outArray = new Array();
		
		for (var i=0; i<in_array.length; i++)
		{
			skip = false;

			for (var j=0; j<remove_array.length; j++)
			{
				if (in_array[i] == remove_array[j])
				{
					skip = true;
				}
			}

			if (!skip)
			{
				outArray[outArray.length] = in_array[i];
			}
		}

		return outArray;
	}

	function addToArray(in_array, add_array)
	{
		for (var i=0; i<add_array.length; i++)
		{
			in_array[in_array.length] = add_array[i];
		}

		return in_array;
	}

	var template = new Array();
	var deltaHeight = 0;

	var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
	var path = tinyMCE.getParam("theme_advanced_path", true);
	var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
	var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");

	// Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
	var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
	if (settings['theme_advanced_styles']) {
		var stylesAr = settings['theme_advanced_styles'].split(';');
		
		for (var i=0; i<stylesAr.length; i++) {
			var key, value;

			key = stylesAr[i].split('=')[0];
			value = stylesAr[i].split('=')[1];

			styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
		}

		TinyMCE_advanced_autoImportCSSClasses = false;
	}

	switch(layoutManager) {
		case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
			var toolbarHTML = "";
			var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
			var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
			var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity
			var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
			var defVals = {
				theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
				theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
				theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
			};

			// Add accessibility control
			toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"></a>';

			// Render rows
			for (var i=1; i<100; i++) {
				var def = defVals["theme_advanced_buttons" + i];

				var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
				if (buttons.length == 0)
					break;

				buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
				buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
				buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);

				for (var b=0; b<buttons.length; b++)
					toolbarHTML += tinyMCE.getControlHTML(buttons[b]);

				if (buttons.length > 0) {
					toolbarHTML += "<br />";
					deltaHeight -= 23;
				}
			}

			// Add accessibility control
			toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';

			// Setup template html
			template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';

			if (toolbarLocation == "top")
			{
				template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
			}

			if (statusbarLocation == "top")
			{
				template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
				deltaHeight -= 23;
			}

			template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';

⌨️ 快捷键说明

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