Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / forms / dialogs / hiddenfield.js
blobd717f9ef8fbbbb7d09194466c1947a7c691928ce
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
5 CKEDITOR.dialog.add( 'hiddenfield', function( editor )
7         return {
8                 title : editor.lang.hidden.title,
9                 hiddenField : null,
10                 minWidth : 350,
11                 minHeight : 110,
12                 onShow : function()
13                 {
14                         delete this.hiddenField;
16                         var editor = this.getParentEditor(),
17                                 selection = editor.getSelection(),
18                                 element = selection.getSelectedElement();
20                         if ( element && element.data( 'cke-real-element-type' ) && element.data( 'cke-real-element-type' ) == 'hiddenfield' )
21                         {
22                                 this.hiddenField = element;
23                                 element = editor.restoreRealElement( this.hiddenField );
24                                 this.setupContent( element );
25                                 selection.selectElement( this.hiddenField );
26                         }
27                 },
28                 onOk : function()
29                 {
30                         var name = this.getValueOf( 'info', '_cke_saved_name' ),
31                                 value = this.getValueOf( 'info', 'value' ),
32                                 editor = this.getParentEditor(),
33                                 element = CKEDITOR.env.ie ? editor.document.createElement( '<input name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) : editor.document.createElement( 'input' );
35                         element.setAttribute( 'type', 'hidden' );
36                         this.commitContent( element );
37                         var fakeElement = editor.createFakeElement( element, 'cke_hidden', 'hiddenfield' );
38                         if ( !this.hiddenField )
39                                 editor.insertElement( fakeElement );
40                         else
41                         {
42                                 fakeElement.replace( this.hiddenField );
43                                 editor.getSelection().selectElement( fakeElement );
44                         }
45                         return true;
46                 },
47                 contents : [
48                         {
49                                 id : 'info',
50                                 label : editor.lang.hidden.title,
51                                 title : editor.lang.hidden.title,
52                                 elements : [
53                                         {
54                                                 id : '_cke_saved_name',
55                                                 type : 'text',
56                                                 label : editor.lang.hidden.name,
57                                                 'default' : '',
58                                                 accessKey : 'N',
59                                                 setup : function( element )
60                                                 {
61                                                         this.setValue(
62                                                                         element.data( 'cke-saved-name' ) ||
63                                                                         element.getAttribute( 'name' ) ||
64                                                                         '' );
65                                                 },
66                                                 commit : function( element )
67                                                 {
68                                                         if ( this.getValue() )
69                                                                 element.setAttribute( 'name', this.getValue() );
70                                                         else
71                                                         {
72                                                                 element.removeAttribute( 'name' );
73                                                         }
74                                                 }
75                                         },
76                                         {
77                                                 id : 'value',
78                                                 type : 'text',
79                                                 label : editor.lang.hidden.value,
80                                                 'default' : '',
81                                                 accessKey : 'V',
82                                                 setup : function( element )
83                                                 {
84                                                         this.setValue( element.getAttribute( 'value' ) || '' );
85                                                 },
86                                                 commit : function( element )
87                                                 {
88                                                         if ( this.getValue() )
89                                                                 element.setAttribute( 'value', this.getValue() );
90                                                         else
91                                                                 element.removeAttribute( 'value' );
92                                                 }
93                                         }
94                                 ]
95                         }
96                 ]
97         };
98 });