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

📄 context-menu.js

📁 Typo3, 开源里边最强大的
💻 JS
📖 第 1 页 / 共 2 页
字号:
/****************************************************************  Copyright notice**  Copyright (c) 2003 dynarch.com. Authored by Mihai Bazon. Sponsored by www.americanbible.org.*  Copyright (c) 2004, 2005 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>*  All rights reserved**  This script is part of the TYPO3 project. The TYPO3 project is*  free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  The GNU General Public License can be found at*  http://www.gnu.org/copyleft/gpl.html.*  A copy is found in the textfile GPL.txt and important notices to the license*  from the author is found in LICENSE.txt distributed with these scripts.***  This script is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  This script is a modified version of a script published under the htmlArea License.*  A copy of the htmlArea License may be found in the textfile HTMLAREA_LICENSE.txt.**  This copyright notice MUST APPEAR in all copies of the script!***************************************************************//* * Context Menu Plugin for TYPO3 htmlArea RTE * * TYPO3 CVS ID: $Id: context-menu.js 1421 2006-04-10 09:27:15Z mundaun $ */ContextMenu = function(editor) {	this.editor = editor;	this.currentMenu = null;	this.keys = [];	this.eventHandlers = {};};ContextMenu.I18N = ContextMenu_langArray;ContextMenu._pluginInfo = {	name          : "ContextMenu",	version       : "1.8",	developer     : "Mihai Bazon & Stanislas Rolland",	developer_url : "http://www.fructifor.ca/",	c_owner       : "dynarch.com & Stanislas Rolland",	sponsor       : "American Bible Society & Fructifor Inc.",	sponsor_url   : "http://www.fructifor.ca/",	license       : "GPL"};ContextMenu.prototype.onGenerate = function() {	if (!HTMLArea.is_opera) {		this.editor.eventHandlers["contextMenu"] = ContextMenu.contextMenuHandler(this);		HTMLArea._addEvent((HTMLArea.is_ie ? this.editor._doc.body : this.editor._doc), "contextmenu", this.editor.eventHandlers["contextMenu"]);	} else {		this.editor.eventHandlers["mousedown"] = ContextMenu.contextMenuHandler(this);		HTMLArea._addEvent(this.editor._doc, "mousedown", this.editor.eventHandlers["mousedown"]);	}};ContextMenu.contextMenuHandler = function(instance) {	return (function(ev) {		if (!HTMLArea.is_opera || (HTMLArea.is_opera && ev.button >= 2)) instance.popupMenu(ev);			else return false;	});};ContextMenu.tableOperationsHandler = function(editor,tbo,opcode) {	return (function() {		tbo.buttonPress(editor,opcode);	});};ContextMenu.imageHandler = function(editor,img) {	return (function() {		editor._insertImage(img);	});};ContextMenu.linkHandler = function(editor,link,opcode) {	switch (opcode) {		case "MakeLink":		case "ModifyLink":			return (function() {				editor.execCommand("CreateLink", true);			});		case "CheckLink":			return (function() {				window.open(link.href);			});		case "RemoveLink":			return (function() {				if (confirm(ContextMenu.I18N["Please confirm unlink"] + "\n" +					ContextMenu.I18N["Link points to:"] + " " + link.href)) {						if(typeof(editor.plugins["TYPO3Browsers"]) != "undefined") {							editor.renderPopup_unLink();						} else {							while(link.firstChild) link.parentNode.insertBefore(link.firstChild, link);							link.parentNode.removeChild(link);						}				}			});	}};ContextMenu.execCommandHandler = function(editor,opcode) {	return (function() {		editor.execCommand(opcode);	});};ContextMenu.insertParagraphHandler = function(editor,currentTarget,after) {	return (function() {		var el = currentTarget;		var par = el.parentNode;		var p = editor._doc.createElement("p");		p.appendChild(editor._doc.createElement("br"));		par.insertBefore(p, after ? el.nextSibling : el);		var sel = editor._getSelection();		var range = editor._createRange(sel);		if(HTMLArea.is_gecko) {			range.selectNodeContents(p);			range.collapse(true);			if(HTMLArea.is_safari) {				sel.empty();				sel.setBaseAndExtent(range.startContainer,range.startOffset,range.endContainer,range.endOffset);			} else {				sel.removeAllRanges();				sel.addRange(range);			}		} else {			range.moveToElementText(p);			range.collapse(true);			range.select();		}	});};ContextMenu.deleteElementHandler = function(editor,tmp,table) {	return (function() {		if(confirm(ContextMenu.I18N["Please confirm remove"] + " " + tmp.tagName.toLowerCase())) {			var el = tmp;			var p = el.parentNode;			p.removeChild(el);			if(HTMLArea.is_gecko) {				if(p.tagName.toLowerCase() == "td" && !p.hasChildNodes()) p.appendChild(editor._doc.createElement("br"));				editor.forceRedraw();				editor.focusEditor();				editor.updateToolbar();				if(table) {					var save_collapse = table.style.borderCollapse;					table.style.borderCollapse = "collapse";					table.style.borderCollapse = "separate";					table.style.borderCollapse = save_collapse;				}			}		}	});};ContextMenu.prototype.pushOperations = function(opcodes,elmenus,tbo) {	var editor = this.editor;	var toolbarObjects = editor._toolbarObjects;	var i18n = ContextMenu.I18N;	var btnList = editor.config.btnList;	var enabled = false, opcode, opEnabled = [], i = opcodes.length;	for (i; i > 0;) {		opcode = opcodes[--i];		opEnabled[opcode] = toolbarObjects[opcode]  && toolbarObjects[opcode].enabled;		enabled = enabled || opEnabled[opcode];	}	if (enabled && elmenus.length) elmenus.push(null);	for (i = opcodes.length; i > 0;) {		opcode = opcodes[--i];		if(opEnabled[opcode]) elmenus.push([i18n[opcode + "-title"],				(tbo ? ContextMenu.tableOperationsHandler(editor, tbo, opcode) : ContextMenu.execCommandHandler(editor, opcode)),				i18n[opcode + "-tooltip"],				btnList[opcode][1], opcode]);	}};ContextMenu.prototype.getContextMenu = function(target) {	var editor = this.editor;	var toolbarObjects = editor._toolbarObjects;	var i18n = ContextMenu.I18N;	var config = editor.config;	var btnList = config.btnList;	var menu = [], opcode;	var tbo = this.editor.plugins["TableOperations"];	if(tbo) tbo = tbo.instance;	var selection = editor.hasSelectedText();	if(selection) {		if (toolbarObjects['Cut'] && toolbarObjects['Cut'].enabled)  {			opcode = "Cut";			menu.push([i18n[opcode], ContextMenu.execCommandHandler(editor, opcode), null, btnList[opcode][1], opcode]);		}		if (toolbarObjects['Copy'] && toolbarObjects['Copy'].enabled) {			opcode = "Copy";			menu.push([i18n[opcode], ContextMenu.execCommandHandler(editor, opcode), null, btnList[opcode][1], opcode]);		}	}	if (toolbarObjects['Paste'] && toolbarObjects['Paste'].enabled) {		opcode = "Paste";		menu.push([i18n[opcode], ContextMenu.execCommandHandler(editor, opcode), null, btnList[opcode][1], opcode]);	}		var currentTarget = target,		tmp, tag, link = false,		table = null, tr = null, td = null, img = null, list = null, div = null;		for(; target; target = target.parentNode) {		tag = target.tagName;		if(!tag) continue;		tag = tag.toLowerCase();		switch (tag) {		    case "img":			img = target;			if (toolbarObjects["InsertImage"] && toolbarObjects["InsertImage"].enabled)  {				if (menu.length) menu.push(null);				menu.push(					[i18n["Image Properties"],						ContextMenu.imageHandler(editor, img),						i18n["Show the image properties dialog"],						btnList["InsertImage"][1], "InsertImage"]				);			}			break;		    case "a":			link = target;			if (toolbarObjects["CreateLink"])  {				if (menu.length) menu.push(null);				menu.push(					[i18n["Modify Link"],						ContextMenu.linkHandler(editor, link, "ModifyLink"),						i18n["Current URL is"] + ': ' + link.href,						btnList["CreateLink"][1], "CreateLink"],					[i18n["Check Link"],						ContextMenu.linkHandler(editor, link, "CheckLink"),						i18n["Opens this link in a new window"],						null, null],					[i18n["Remove Link"],						ContextMenu.linkHandler(editor, link, "RemoveLink"),						i18n["Unlink the current element"],						editor.imgURL("ed_unlink.gif"), "UnLink"]				);			}			break;		    case "td":		    case "th":			td = target;			if(!tbo) break;			this.pushOperations(["TO-cell-split", "TO-cell-delete", "TO-cell-insert-after", "TO-cell-insert-before", "TO-cell-prop"], menu, tbo);			break;		    case "tr":			tr = target;			if(!tbo) break;			opcode = "TO-cell-merge";			if(toolbarObjects[opcode]  && toolbarObjects[opcode].enabled)				menu.push([i18n[opcode + "-title"],				ContextMenu.tableOperationsHandler(editor,tbo,opcode),				i18n[opcode + "-tooltip"],				btnList[opcode][1], opcode]);			this.pushOperations(["TO-row-split", "TO-row-delete", "TO-row-insert-under", "TO-row-insert-above", "TO-row-prop"], menu, tbo);			break;		    case "table":			table = target;			if(!tbo) break;			this.pushOperations(["TO-toggle-borders", "TO-table-prop", "TO-col-split", "TO-col-delete", "TO-col-insert-after", "TO-col-insert-before"], menu, tbo);			break;		    case "ol":		    case "ul":		    case "dl":			list = target;			break;

⌨️ 快捷键说明

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