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