Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / showblocks / plugin.js
blobbf5db921114bf86b3af0b2ba8f11ba8c42bf4df7
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 /**
7  * @fileOverview The "showblocks" plugin. Enable it will make all block level
8  *               elements being decorated with a border and the element name
9  *               displayed on the left-right corner.
10  */
12 (function()
14         var cssTemplate = '.%2 p,'+
15                 '.%2 div,'+
16                 '.%2 pre,'+
17                 '.%2 address,'+
18                 '.%2 blockquote,'+
19                 '.%2 h1,'+
20                 '.%2 h2,'+
21                 '.%2 h3,'+
22                 '.%2 h4,'+
23                 '.%2 h5,'+
24                 '.%2 h6'+
25                 '{'+
26                         'background-repeat: no-repeat;'+
27                         'background-position: top %3;'+
28                         'border: 1px dotted gray;'+
29                         'padding-top: 8px;'+
30                         'padding-%3: 8px;'+
31                 '}'+
33                 '.%2 p'+
34                 '{'+
35                         '%1p.png);'+
36                 '}'+
38                 '.%2 div'+
39                 '{'+
40                         '%1div.png);'+
41                 '}'+
43                 '.%2 pre'+
44                 '{'+
45                         '%1pre.png);'+
46                 '}'+
48                 '.%2 address'+
49                 '{'+
50                         '%1address.png);'+
51                 '}'+
53                 '.%2 blockquote'+
54                 '{'+
55                         '%1blockquote.png);'+
56                 '}'+
58                 '.%2 h1'+
59                 '{'+
60                         '%1h1.png);'+
61                 '}'+
63                 '.%2 h2'+
64                 '{'+
65                         '%1h2.png);'+
66                 '}'+
68                 '.%2 h3'+
69                 '{'+
70                         '%1h3.png);'+
71                 '}'+
73                 '.%2 h4'+
74                 '{'+
75                         '%1h4.png);'+
76                 '}'+
78                 '.%2 h5'+
79                 '{'+
80                         '%1h5.png);'+
81                 '}'+
83                 '.%2 h6'+
84                 '{'+
85                         '%1h6.png);'+
86                 '}';
88         var cssTemplateRegex = /%1/g, cssClassRegex = /%2/g, backgroundPositionRegex = /%3/g;
90         var commandDefinition =
91         {
92                 preserveState : true,
93                 editorFocus : false,
95                 exec : function ( editor )
96                 {
97                         this.toggleState();
98                         this.refresh( editor );
99                 },
101                 refresh : function( editor )
102                 {
103                         var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
104                         editor.document.getBody()[ funcName ]( 'cke_show_blocks' );
105                 }
106         };
108         CKEDITOR.plugins.add( 'showblocks',
109         {
110                 requires : [ 'wysiwygarea' ],
112                 init : function( editor )
113                 {
114                         var command = editor.addCommand( 'showblocks', commandDefinition );
115                         command.canUndo = false;
117                         if ( editor.config.startupOutlineBlocks )
118                                 command.setState( CKEDITOR.TRISTATE_ON );
120                         editor.addCss( cssTemplate
121                                 .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
122                                 .replace( cssClassRegex, 'cke_show_blocks ' )
123                                 .replace( backgroundPositionRegex, editor.lang.dir == 'rtl' ? 'right' : 'left' ) );
125                         editor.ui.addButton( 'ShowBlocks',
126                                 {
127                                         label : editor.lang.showBlocks,
128                                         command : 'showblocks'
129                                 });
131                         // Refresh the command on setData.
132                         editor.on( 'mode', function()
133                                 {
134                                         if ( command.state != CKEDITOR.TRISTATE_DISABLED )
135                                                 command.refresh( editor );
136                                 });
138                         // Refresh the command on setData.
139                         editor.on( 'contentDom', function()
140                                 {
141                                         if ( command.state != CKEDITOR.TRISTATE_DISABLED )
142                                                 command.refresh( editor );
143                                 });
144                 }
145         });
146 } )();
149  * Whether to automaticaly enable the "show block" command when the editor
150  * loads. (StartupShowBlocks in FCKeditor)
151  * @name CKEDITOR.config.startupOutlineBlocks
152  * @type Boolean
153  * @default false
154  * @example
155  * config.startupOutlineBlocks = true;
156  */