includes/clientside/tinymce/plugins/contextmenu/editor_plugin_src.js
author Dan
Sun, 04 Oct 2009 03:59:50 -0400
changeset 1128 a5aaa7512155
parent 588 20484deb89cd
permissions -rw-r--r--
Merged from accidental split
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
/**
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
     2
 * $Id: editor_plugin_src.js 848 2008-05-15 11:54:40Z spocke $
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * @author Moxiecode
395
fa4c5ecb7c9a Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents: 335
diff changeset
     5
 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
     8
(function() {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
     9
	var Event = tinymce.dom.Event, each = tinymce.each, DOM = tinymce.DOM;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    11
	tinymce.create('tinymce.plugins.ContextMenu', {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    12
		init : function(ed) {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    13
			var t = this;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    15
			t.editor = ed;
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    16
			t.onContextMenu = new tinymce.util.Dispatcher(this);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    18
			ed.onContextMenu.add(function(ed, e) {
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    19
				if (!e.ctrlKey) {
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    20
					t._getMenu(ed).showMenu(e.clientX, e.clientY);
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
    21
					Event.add(ed.getDoc(), 'click', hide);
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    22
					Event.cancel(e);
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    23
				}
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    24
			});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    26
			function hide() {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    27
				if (t._menu) {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    28
					t._menu.removeAll();
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    29
					t._menu.destroy();
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
    30
					Event.remove(ed.getDoc(), 'click', hide);
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    31
				}
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    32
			};
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    34
			ed.onMouseDown.add(hide);
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    35
			ed.onKeyDown.add(hide);
543
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    36
		},
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    37
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    38
		getInfo : function() {
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    39
			return {
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    40
				longname : 'Contextmenu',
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    41
				author : 'Moxiecode Systems AB',
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    42
				authorurl : 'http://tinymce.moxiecode.com',
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    43
				infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu',
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    44
				version : tinymce.majorVersion + "." + tinymce.minorVersion
dffcbfbc4e59 Upgraded TinyMCE to version 3.0.8
Dan
parents: 459
diff changeset
    45
			};
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    46
		},
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    48
		_getMenu : function(ed) {
459
31c23016ab62 Upgraded tinyMCE to 3.0.1 in hopes of fixing IE race conditions. Fixed a couple minor syntax errors in Javascript objects declared in various places.
Dan
parents: 395
diff changeset
    49
			var t = this, m = t._menu, se = ed.selection, col = se.isCollapsed(), el = se.getNode() || ed.getBody(), am, p1, p2;
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    50
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    51
			if (m) {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    52
				m.removeAll();
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    53
				m.destroy();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    54
			}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    56
			p1 = DOM.getPos(ed.getContentAreaContainer());
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    57
			p2 = DOM.getPos(ed.getContainer());
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    58
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    59
			m = ed.controlManager.createDropMenu('contextmenu', {
588
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
    60
				offset_x : p1.x + ed.getParam('contextmenu_offset_x', 0),
20484deb89cd Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents: 543
diff changeset
    61
				offset_y : p1.y + ed.getParam('contextmenu_offset_y', 0),
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    62
				constrain : 1
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    63
			});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    65
			t._menu = m;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    66
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    67
			m.add({title : 'advanced.cut_desc', icon : 'cut', cmd : 'Cut'}).setDisabled(col);
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    68
			m.add({title : 'advanced.copy_desc', icon : 'copy', cmd : 'Copy'}).setDisabled(col);
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    69
			m.add({title : 'advanced.paste_desc', icon : 'paste', cmd : 'Paste'});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    71
			if ((el.nodeName == 'A' && !ed.dom.getAttrib(el, 'name')) || !col) {
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    72
				m.addSeparator();
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    73
				m.add({title : 'advanced.link_desc', icon : 'link', cmd : ed.plugins.advlink ? 'mceAdvLink' : 'mceLink', ui : true});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    74
				m.add({title : 'advanced.unlink_desc', icon : 'unlink', cmd : 'UnLink'});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    75
			}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    77
			m.addSeparator();
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    78
			m.add({title : 'advanced.image_desc', icon : 'image', cmd : ed.plugins.advimage ? 'mceAdvImage' : 'mceImage', ui : true});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    80
			m.addSeparator();
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    81
			am = m.addMenu({title : 'contextmenu.align'});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    82
			am.add({title : 'contextmenu.left', icon : 'justifyleft', cmd : 'JustifyLeft'});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    83
			am.add({title : 'contextmenu.center', icon : 'justifycenter', cmd : 'JustifyCenter'});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    84
			am.add({title : 'contextmenu.right', icon : 'justifyright', cmd : 'JustifyRight'});
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    85
			am.add({title : 'contextmenu.full', icon : 'justifyfull', cmd : 'JustifyFull'});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    86
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    87
			t.onContextMenu.dispatch(t, m, el, col);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    89
			return m;
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    90
		}
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    91
	});
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
335
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    93
	// Register plugin
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    94
	tinymce.PluginManager.add('contextmenu', tinymce.plugins.ContextMenu);
67bd3121a12e Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents: 1
diff changeset
    95
})();