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 : 400, 10 minHeight : 200, 11 onShow : function() 12 { 13 // IE BUG: Selection must be in the editor for getSelectedElement() 14 // to work. 15 this.restoreSelection(); 16 17 var element = this.getParentEditor().getSelection().getSelectedElement(); 18 if ( element && element.getName() == "input" && element.getAttribute( 'type' ) == "checkbox" ) 19 { 20 this._element = element; 21 this.setupContent( element ); 22 } 23 }, 24 onOk : function() 25 { 26 var editor, 27 element = this._element, 28 isInsertMode = !element; 29 30 if ( isInsertMode ) 31 { 32 editor = this.getParentEditor(); 33 element = editor.document.createElement( 'input' ); 34 element.setAttribute( 'type', 'hidden' ); 35 } 36 this.commitContent( element ); 37 38 if ( isInsertMode ) 39 { 40 this.restoreSelection(); 41 this.clearSavedSelection(); 42 editor.insertElement( element ); 43 } 44 }, 45 contents : [ 46 { 47 id : 'info', 48 label : editor.lang.hidden.title, 49 title : editor.lang.hidden.title, 50 elements : [ 51 { 52 id : 'txtName', 53 type : 'text', 54 label : editor.lang.hidden.name, 55 'default' : '', 56 accessKey : 'N', 57 setup : function( element ) 58 { 59 this.setValue( element.getAttribute( 'name' ) ); 60 this.focus(); 61 }, 62 commit : function( element ) 63 { 64 if ( this.getValue() != '' || this.isChanged() ) 65 element.setAttribute( 'name', this.getValue() ); 66 } 67 }, 68 { 69 id : 'txtValue', 70 type : 'text', 71 label : editor.lang.hidden.value, 72 'default' : '', 73 accessKey : 'V', 74 setup : function( element ) 75 { 76 this.setValue( element.getAttribute( 'value' ) ); 77 }, 78 commit : function( element ) 79 { 80 if ( this.getValue() != '' || this.isChanged() ) 81 element.setAttribute( 'value', this.getValue() ); 82 } 83 } 84 ] 85 } 86 ] 87 }; 88 }); 89