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

📄 editor_template.js

📁 这是一个简单的论坛程序源码
💻 JS
📖 第 1 页 / 共 4 页
字号:
			case "mceCodeEditor":
				var template = new Array();

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

				tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
				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"});
				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;
		}

		return false;
	},
	
	/* COMMUNITY SERVER CUSTOMIZATION: save content after a slight delay */
	
	handleEvent : function(e) {
		if (tinyMCE.selectedInstance && (e.type == "beforedeactivate" || e.type == "blur"))
		{
			/* 
			var bookmark = tinyMCE.selectedInstance.selection.getBookmark();
			tinyMCE.selectedInstance.triggerSave();	
			tinyMCE.selectedInstance.selection.moveToBookmark(bookmark);
			*/
			
			var e, nl = new Array(), i, s;

			tinyMCE.selectedInstance.switchSettings();
			s = tinyMCE.settings;

			// Force hidden tabs visible while serializing
			if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
				e = tinyMCE.selectedInstance.iframeElement;

				do {
					if (e.style && e.style.display == 'none') {
						e.style.display = 'block';
						nl[nl.length] = {elm : e, type : 'style'};
					}

					if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
						e.className = s.display_tab_class;
						nl[nl.length] = {elm : e, type : 'class'};
					}
				} while ((e = e.parentNode) != null)
			}

			tinyMCE.settings['preformatted'] = false;
			
			//tinyMCE._setHTML(tinyMCE.selectedInstance.getDoc(), tinyMCE.selectedInstance.getBody().innerHTML);

			// Remove visual aids when cleanup is disabled
			if (tinyMCE.selectedInstance.settings['cleanup'] == false) {
				tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, false, tinyMCE.selectedInstance);
				tinyMCE._setEventsEnabled(tinyMCE.selectedInstance.getBody(), true);
			}

			tinyMCE._customCleanup(tinyMCE.selectedInstance, "submit_content_dom", tinyMCE.selectedInstance.contentWindow.document.body);
			var htm = tinyMCE._cleanupHTML(tinyMCE.selectedInstance, tinyMCE.selectedInstance.getDoc(), tinyMCE.selectedInstance.settings, tinyMCE.selectedInstance.getBody(), tinyMCE.visualAid, true, true);
			htm = tinyMCE._customCleanup(tinyMCE.selectedInstance, "submit_content", htm);

			if (tinyMCE.settings['save_callback'] != "")
				var content = eval(tinyMCE.settings['save_callback'] + "(tinyMCE.selectedInstance.formTargetElementId,htm,tinyMCE.selectedInstance.getBody());");

			// Use callback content if available
			if ((typeof(content) != "undefined") && content != null)
				htm = content;

			// Replace some weird entities (Bug: #1056343)
			htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
			htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
			htm = tinyMCE.regexpReplace(htm, "&#59;", ";", "gi");
			htm = tinyMCE.regexpReplace(htm, """, """, "gi");
			htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");

			if (tinyMCE.selectedInstance.formElement)
				tinyMCE.selectedInstance.formElement.value = htm;

			if (tinyMCE.isSafari && tinyMCE.selectedInstance.formElement)
				tinyMCE.selectedInstance.formElement.innerText = htm;

			// Hide them again (tabs in MSIE)
			for (i=0; i<nl.length; i++) {
				if (nl[i].type == 'style')
					nl[i].elm.style.display = 'none';
				else
					nl[i].elm.className = s.hidden_tab_class;
			}
		}
		
		return true;
	},
	
	/**
	 * Editor instance template function.
	 */
	getEditorTemplate : function(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;
		}
		
		/* COMMUNITY SERVER CUSTOMIZATION: add plugins/set additional options on the editor */
		settings["handle_event_callback"] = "TinyMCE_CommunityServerTheme.handleEvent";
		
		/* COMMUNITY SERVER CUSTOMIZATION: if loaded via a modal, set the base url to the url of the parent window */
		try
		{
			if (window.parent && window.parent.Telligent_Modal)
			{
				var baseHREF = window.parent.location + "";
				var h = window.parent.location + "";
				var p = h.indexOf('://');
				if (p > 0 && document.location.protocol != "file:") {
					p = h.indexOf('/', p + 3);
					h = h.substring(0, p);

					if (baseHREF.indexOf('://') == -1)
						baseHREF = h + baseHREF;

					settings['document_base_url'] = baseHREF;
					settings['document_base_prefix'] = h;
				}

				// Trim away query part
				if (baseHREF.indexOf('?') != -1)
					baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
					
				settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
			}	
		}
		catch (e)
		{
		}
		
		var template = new Array();
		var deltaHeight = 0;
		var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
		var path = tinyMCE.getParam("theme_advanced_path", false);
		var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&#160;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.CommunityServer._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_CommunityServerTheme._autoImportCSSClasses = false;
		}

		switch(layoutManager) {
			case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
				var toolbarHTML = "";
				var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "top");
				var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "left");
				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,indent,outdent,separator,bullist,numlist,separator,link,unlink,image,contentselector,smiley,separator,cut,copy,paste,pasteword,separator,code",
					theme_advanced_buttons2 : "",
					theme_advanced_buttons3 : ""
				};
				
				// Add accessibility control
				toolbarHTML += '<a tabindex="-1" href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"';

				if (!tinyMCE.getParam("accessibility_focus"))
					toolbarHTML += ' onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"';

				toolbarHTML += '></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;
						
					/* COMMUNITY SERVER CUSTOMIZATION: remove content selector based on options object */
					if (tinyMCE_CommunityServerOptions && !tinyMCE_CommunityServerOptions.ContentSelectorEnabled)
						buttons = removeFromArray(buttons, ['contentselector']);
									
					/* COMMUNITY SERVER CUSTOMIZATION: remove code option based on parameter */								
					if (!tinyMCE.getParam("theme_communityserver_codeenabled", false))
						buttons = removeFromArray(buttons, ['code']);

					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>';

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

				// External toolbar changes
				if (toolbarLocation == "external") {
					var bod = document.body;
					var elm = document.createElement ("div");

					toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
					toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId});

					elm.className = "mceToolbarExternal";
					elm.id = editorId+"_toolbar";
					elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
					bod.appendChild (elm);
					// bod.style.marginTop = elm.offsetHeight + "px";

					deltaHeight = 0;
					tinyMCE.getInstanceById(editorId).toolbarElement = elm;

					//template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
				} else {
					tinyMCE.getInstanceById(editorId).toolbarElement = null;
				}

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

				template['html'] += '</tbody></table>';
				//"SimpleLayout"
			break;

			case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
				template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';

				var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
				var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
				var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");

				//Render Containers:
				for (var i = 0; i < containers.length; i++)
				{
					if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
						template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>';
					else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
					{
						var pathClass = "mceStatusbar";

						if (i == containers.length-1)
						{
							pathClass = "mceStatusbarBottom";
						}
						else if (i == 0)
						{
							pathClass = "mceStatusbar";
						}
						else
						{
							deltaHeight-=2;
						}

						template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
						deltaHeight -= 22;
					} else { // Render normal Container
						var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
						var curContainerHTML = "";
						var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
						var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);

						for (var j=0; j<curContainer.length; j++) {
							curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
						}

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

						template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
					}
				}

				template['html'] += '</tbody></table>';
				//RowLayout
			break;

			case "CustomLayout" : //User defined layout callback...
				var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");

				if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") {
					template = eval(customLayout + "(template);");
				}
			break;
		}

		if (resizing)
			template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';

		template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);

⌨️ 快捷键说明

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