~automne-team/automne/4.2

« back to all changes in this revision

Viewing changes to automne/fckeditor/automnePlugin/polymod/fckplugin.js

  • Committer: sebastien
  • Date: 2008-11-26 17:12:36 UTC
  • Revision ID: sebastien_sebastien-20081126171236-16r3kxfuz2kmq2qe
Tags: V4_0_0a0
4.0.0a0 :
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim: set expandtab tabstop=4 shiftwidth=4: */
 
2
// +----------------------------------------------------------------------+
 
3
// | Automne (TM)                                                         |
 
4
// +----------------------------------------------------------------------+
 
5
// | Copyright (c) 2000-2004 WS Interactive                               |
 
6
// | Copyright (c) 2000-2004 Antoine Pouch                                |
 
7
// +----------------------------------------------------------------------+
 
8
// | This source file is subject to version 2.0 of the GPL license,       |
 
9
// | or (at your discretion) to version 3.0 of the PHP license.           |
 
10
// | The first is bundled with this package in the file LICENSE-GPL, and  |
 
11
// | is available at through the world-wide-web at                        |
 
12
// | http://www.gnu.org/copyleft/gpl.html.                                |
 
13
// | The later is bundled with this package in the file LICENSE-PHP, and  |
 
14
// | is available at through the world-wide-web at                        |
 
15
// | http://www.php.net/license/3_0.txt.                                  |
 
16
// +----------------------------------------------------------------------+
 
17
// | Author: S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr>      |
 
18
// +----------------------------------------------------------------------+
 
19
//
 
20
// $Id: fckplugin.js,v 1.1.1.1 2008/11/26 17:12:14 sebastien Exp $
 
21
 
 
22
/**
 
23
  * Javascript Polymod plugin for FCKeditor
 
24
  * Allow usage of all Polymod wysiwyg plugins
 
25
  *
 
26
  * @package CMS
 
27
  * @subpackage admin
 
28
  * @author S�bastien Pauchet <sebastien.pauchet@ws-interactive.fr>
 
29
  */
 
30
 
 
31
// Register the related commands.
 
32
FCKCommands.RegisterCommand( 'polymod'          , new FCKDialogCommand( FCKLang['DlgPolymodTitle']      , FCKLang['DlgPolymodTitle']            , FCKConfig.PluginsPath + 'polymod/polymod.php' , 750, 550 ) ) ;
 
33
 
 
34
// Create the "automneLinks" toolbar button.
 
35
var oPolymod            = new FCKToolbarButton( 'polymod', FCKLang['DlgPolymodTitle'] ) ;
 
36
oPolymod.IconPath       = FCKConfig.PluginsPath + 'polymod/polymod.gif' ;
 
37
 
 
38
FCKToolbarItems.RegisterItem( 'polymod', oPolymod ) ;                   // 'polymod' is the name used in the Toolbar config.
 
39
 
 
40
 
 
41
// ##### Define "Edit input" context menu entry.
 
42
 
 
43
// ## 1. Define the command to be executed when selecting the context menu item.
 
44
var oEditPolyCommand = new Object() ;
 
45
oEditPolyCommand.Name = 'polyEdit' ;
 
46
 
 
47
// This is the standard function used to execute the command (called when clicking in the context menu item).
 
48
oEditPolyCommand.Execute = function() {
 
49
        FCKDialog.OpenDialog( 'FCKDialog_poly_edit', FCKLang['DlgPolymodTitle'], FCKConfig.PluginsPath + 'polymod/polymod.php'  , 750, 550 ) ;
 
50
}
 
51
 
 
52
// This is the standard function used to retrieve the command state (it could be disabled for some reason).
 
53
oEditPolyCommand.GetState = function() {
 
54
        // Let's make it always enabled.
 
55
        return FCK_TRISTATE_OFF ;
 
56
}
 
57
 
 
58
// ## 2. Register our custom command.
 
59
FCKCommands.RegisterCommand( 'polyEdit', oEditPolyCommand ) ;
 
60
 
 
61
// ## 3. Define the context menu "listener".
 
62
var oEditPolyContextMenuListener = new Object() ;
 
63
 
 
64
// This is the standard function called right before sowing the context menu.
 
65
oEditPolyContextMenuListener.AddItems = function( contextMenu, tag, tagName ) {
 
66
        // Let's show our custom option only for form fields.
 
67
        if ( tagName == 'SPAN'  || FCKSelection.HasAncestorNode( 'SPAN' )) {
 
68
                // Go up to the span to test its properties
 
69
                var oSpan = FCKSelection.MoveToAncestorNode( 'SPAN' ) ;
 
70
                if (oSpan.className == 'polymod') {
 
71
                        contextMenu.AddSeparator() ;
 
72
                        contextMenu.AddItem( 'polyEdit', FCKLang['DlgPolymodEditTitle'], FCKConfig.PluginsPath + 'polymod/polymod.gif' ) ;
 
73
                }
 
74
        }
 
75
}
 
76
 
 
77
// ## 4. Register our context menu listener.
 
78
FCK.ContextMenu.RegisterListener( oEditPolyContextMenuListener ) ;
 
79
 
 
80
// Open the Placeholder dialog on double click.
 
81
oEditPolyCommand.OnDoubleClick = function( span ) {
 
82
        // Let's show our custom option only for form fields.
 
83
        if ( span.tagName == 'SPAN'  || FCKSelection.HasAncestorNode( 'SPAN' )) {
 
84
                // Go up to the span to test its properties
 
85
                var oSpan = FCKSelection.MoveToAncestorNode( 'SPAN' ) ;
 
86
                if (oSpan.className == 'polymod') {
 
87
                        FCKCommands.GetCommand( 'polyEdit' ).Execute() ;
 
88
                }
 
89
        }
 
90
}
 
91
FCK.RegisterDoubleClickHandler( oEditPolyCommand.OnDoubleClick, 'SPAN' ) ;
 
 
b'\\ No newline at end of file'