1 /* 2 Copyright (c) 2003-2009, 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 ) 6 { 7 return { 8 title : editor.lang.hidden.title, 9 minWidth : 350, 10 minHeight : 110, 11 onShow : function() 12 { 13 delete this.hiddenField; 14 15 var element = this.getParentEditor().getSelection().getSelectedElement(); 16 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "checkbox" ) 17 { 18 this.hiddenField = element; 19 this.setupContent( element ); 20 } 21 }, 22 onOk : function() 23 { 24 var editor, 25 element = this.hiddenField, 26 isInsertMode = !element; 27 28 if ( isInsertMode ) 29 { 30 editor = this.getParentEditor(); 31 element = editor.document.createElement( 'input' ); 32 element.setAttribute( 'type', 'hidden' ); 33 } 34 35 if ( isInsertMode ) 36 editor.insertElement( element ); 37 this.commitContent( element ); 38 }, 39 contents : [ 40 { 41 id : 'info', 42 label : editor.lang.hidden.title, 43 title : editor.lang.hidden.title, 44 elements : [ 45 { 46 id : '_cke_saved_name', 47 type : 'text', 48 label : editor.lang.hidden.name, 49 'default' : '', 50 accessKey : 'N', 51 setup : function( element ) 52 { 53 this.setValue( 54 element.getAttribute( '_cke_saved_name' ) || 55 element.getAttribute( 'name' ) || 56 '' ); 57 }, 58 commit : function( element ) 59 { 60 if ( this.getValue() ) 61 element.setAttribute( '_cke_saved_name', this.getValue() ); 62 else 63 { 64 element.removeAttribute( '_cke_saved_name' ); 65 element.removeAttribute( 'name' ); 66 } 67 } 68 }, 69 { 70 id : 'value', 71 type : 'text', 72 label : editor.lang.hidden.value, 73 'default' : '', 74 accessKey : 'V', 75 setup : function( element ) 76 { 77 this.setValue( element.getAttribute( 'value' ) || '' ); 78 }, 79 commit : function( element ) 80 { 81 if ( this.getValue() ) 82 element.setAttribute( 'value', this.getValue() ); 83 else 84 element.removeAttribute( 'value' ); 85 } 86 } 87 ] 88 } 89 ] 90 }; 91 }); 92