2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2009 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* FCKShowBlockCommand Class: the "Show Blocks" command.
24
var FCKShowBlockCommand = function( name, defaultState )
27
if ( defaultState != undefined )
28
this._SavedState = defaultState ;
30
this._SavedState = null ;
33
FCKShowBlockCommand.prototype.Execute = function()
35
var state = this.GetState() ;
37
if ( state == FCK_TRISTATE_DISABLED )
40
var body = FCK.EditorDocument.body ;
42
if ( state == FCK_TRISTATE_ON )
43
body.className = body.className.replace( /(^| )FCK__ShowBlocks/g, '' ) ;
45
body.className += ' FCK__ShowBlocks' ;
47
if ( FCKBrowserInfo.IsIE )
51
FCK.EditorDocument.selection.createRange().select() ;
58
var focus = FCK.EditorWindow.getSelection().focusNode ;
61
if ( focus.nodeType != 1 )
62
focus = focus.parentNode ;
63
FCKDomTools.ScrollIntoView( focus, false ) ;
67
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
70
FCKShowBlockCommand.prototype.GetState = function()
72
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
73
return FCK_TRISTATE_DISABLED ;
75
// On some cases FCK.EditorDocument.body is not yet available
76
if ( !FCK.EditorDocument )
77
return FCK_TRISTATE_OFF ;
79
if ( /FCK__ShowBlocks(?:\s|$)/.test( FCK.EditorDocument.body.className ) )
80
return FCK_TRISTATE_ON ;
82
return FCK_TRISTATE_OFF ;
85
FCKShowBlockCommand.prototype.SaveState = function()
87
this._SavedState = this.GetState() ;
90
FCKShowBlockCommand.prototype.RestoreState = function()
92
if ( this._SavedState != null && this.GetState() != this._SavedState )