~ubuntu-branches/ubuntu/oneiric/moin/oneiric-security

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/_source/commandclasses/fckshowblocks.js

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-03-30 12:55:34 UTC
  • mfrom: (0.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100330125534-4c2ufc1rok24447l
Tags: 1.9.2-2ubuntu1
* Merge from Debian testing (LP: #521834). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason for us
   to pull this in by default currently. Note: This isn't necessary anymore
   but needs a MIR for fckeditor, so postpone dropping this change until
   lucid+1
* debian/rules:
  - Replace hardcoded python2.5 with python* and hardcore python2.6 for ln
* debian/control.in: drop versioned depends on cdbs

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 * FCKShowBlockCommand Class: the "Show Blocks" command.
22
 
 */
23
 
 
24
 
var FCKShowBlockCommand = function( name, defaultState )
25
 
{
26
 
        this.Name = name ;
27
 
        if ( defaultState != undefined )
28
 
                this._SavedState = defaultState ;
29
 
        else
30
 
                this._SavedState = null ;
31
 
}
32
 
 
33
 
FCKShowBlockCommand.prototype.Execute = function()
34
 
{
35
 
        var state = this.GetState() ;
36
 
 
37
 
        if ( state == FCK_TRISTATE_DISABLED )
38
 
                return ;
39
 
 
40
 
        var body = FCK.EditorDocument.body ;
41
 
 
42
 
        if ( state == FCK_TRISTATE_ON )
43
 
                body.className = body.className.replace( /(^| )FCK__ShowBlocks/g, '' ) ;
44
 
        else
45
 
                body.className += ' FCK__ShowBlocks' ;
46
 
 
47
 
        if ( FCKBrowserInfo.IsIE )
48
 
        {
49
 
                try
50
 
                {
51
 
                        FCK.EditorDocument.selection.createRange().select() ;
52
 
                }
53
 
                catch ( e )
54
 
                {}
55
 
        }
56
 
        else
57
 
        {
58
 
                var focus = FCK.EditorWindow.getSelection().focusNode ;
59
 
                if ( focus )
60
 
                {
61
 
                        if ( focus.nodeType != 1 )
62
 
                                focus = focus.parentNode ;
63
 
                        FCKDomTools.ScrollIntoView( focus, false ) ;
64
 
                }
65
 
        }
66
 
 
67
 
        FCK.Events.FireEvent( 'OnSelectionChange' ) ;
68
 
}
69
 
 
70
 
FCKShowBlockCommand.prototype.GetState = function()
71
 
{
72
 
        if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
73
 
                return FCK_TRISTATE_DISABLED ;
74
 
 
75
 
        // On some cases FCK.EditorDocument.body is not yet available
76
 
        if ( !FCK.EditorDocument )
77
 
                return FCK_TRISTATE_OFF ;
78
 
 
79
 
        if ( /FCK__ShowBlocks(?:\s|$)/.test( FCK.EditorDocument.body.className ) )
80
 
                return FCK_TRISTATE_ON ;
81
 
 
82
 
        return FCK_TRISTATE_OFF ;
83
 
}
84
 
 
85
 
FCKShowBlockCommand.prototype.SaveState = function()
86
 
{
87
 
        this._SavedState = this.GetState() ;
88
 
}
89
 
 
90
 
FCKShowBlockCommand.prototype.RestoreState = function()
91
 
{
92
 
        if ( this._SavedState != null && this.GetState() != this._SavedState )
93
 
                this.Execute() ;
94
 
}