1 | /* |
---|
2 | * FCKeditor - The text editor for internet |
---|
3 | * Copyright (C) 2003-2006 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
7 | * |
---|
8 | * For further information visit: |
---|
9 | * http://www.fckeditor.net/ |
---|
10 | * |
---|
11 | * "Support Open Source software. What about a donation today?" |
---|
12 | * |
---|
13 | * File Name: fckplugin.js |
---|
14 | * This is a sample plugin definition file. |
---|
15 | * |
---|
16 | * File Authors: |
---|
17 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
18 | */ |
---|
19 | |
---|
20 | // Here we define our custom Style combo, with custom widths. |
---|
21 | var oMyBigStyleCombo = new FCKToolbarStyleCombo() ; |
---|
22 | oMyBigStyleCombo.FieldWidth = 250 ; |
---|
23 | oMyBigStyleCombo.PanelWidth = 300 ; |
---|
24 | FCKToolbarItems.RegisterItem( 'My_BigStyle', oMyBigStyleCombo ) ; |
---|
25 | |
---|
26 | |
---|
27 | // ##### Defining a custom context menu entry. |
---|
28 | |
---|
29 | // ## 1. Define the command to be executed when selecting the context menu item. |
---|
30 | var oMyCMCommand = new Object() ; |
---|
31 | oMyCMCommand.Name = 'OpenImage' ; |
---|
32 | |
---|
33 | // This is the standard function used to execute the command (called when clicking in the context menu item). |
---|
34 | oMyCMCommand.Execute = function() |
---|
35 | { |
---|
36 | // This command is called only when an image element is selected (IMG). |
---|
37 | // Get image URL (src). |
---|
38 | var sUrl = FCKSelection.GetSelectedElement().src ; |
---|
39 | |
---|
40 | // Open the URL in a new window. |
---|
41 | window.top.open( sUrl ) ; |
---|
42 | } |
---|
43 | |
---|
44 | // This is the standard function used to retrieve the command state (it could be disabled for some reason). |
---|
45 | oMyCMCommand.GetState = function() |
---|
46 | { |
---|
47 | // Let's make it always enabled. |
---|
48 | return FCK_TRISTATE_OFF ; |
---|
49 | } |
---|
50 | |
---|
51 | // ## 2. Register our custom command. |
---|
52 | FCKCommands.RegisterCommand( 'OpenImage', oMyCMCommand ) ; |
---|
53 | |
---|
54 | // ## 3. Define the context menu "listener". |
---|
55 | var oMyContextMenuListener = new Object() ; |
---|
56 | |
---|
57 | // This is the standard function called right before sowing the context menu. |
---|
58 | oMyContextMenuListener.AddItems = function( contextMenu, tag, tagName ) |
---|
59 | { |
---|
60 | // Let's show our custom option only for images. |
---|
61 | if ( tagName == 'IMG' ) |
---|
62 | { |
---|
63 | contextMenu.AddSeparator() ; |
---|
64 | contextMenu.AddItem( 'OpenImage', 'Open image in a new window (Custom)' ) ; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | // ## 4. Register our context menu listener. |
---|
69 | FCK.ContextMenu.RegisterListener( oMyContextMenuListener ) ; |
---|