1 /* 2 * Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. 3 * For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 function placeholderDialog( editor, isEdit ) 9 { 10 11 var lang = editor.lang.placeholder, 12 generalLabel = editor.lang.common.generalTab; 13 return { 14 title : lang.title, 15 minWidth : 300, 16 minHeight : 80, 17 contents : 18 [ 19 { 20 id : 'info', 21 label : generalLabel, 22 title : generalLabel, 23 elements : 24 [ 25 { 26 id : 'text', 27 type : 'text', 28 style : 'width: 100%;', 29 label : lang.text, 30 'default' : '', 31 required : true, 32 validate : CKEDITOR.dialog.validate.notEmpty( lang.textMissing ), 33 setup : function( element ) 34 { 35 if ( isEdit ) 36 this.setValue( element.getText().slice( 2, -2 ) ); 37 }, 38 commit : function( element ) 39 { 40 var text = '[[' + this.getValue() + ']]'; 41 // The placeholder must be recreated. 42 CKEDITOR.plugins.placeholder.createPlaceholder( editor, element, text ); 43 } 44 } 45 ] 46 } 47 ], 48 onShow : function() 49 { 50 if ( isEdit ) 51 this._element = CKEDITOR.plugins.placeholder.getSelectedPlaceHoder( editor ); 52 53 this.setupContent( this._element ); 54 }, 55 onOk : function() 56 { 57 this.commitContent( this._element ); 58 delete this._element; 59 } 60 }; 61 } 62 63 CKEDITOR.dialog.add( 'createplaceholder', function( editor ) 64 { 65 return placeholderDialog( editor ); 66 }); 67 CKEDITOR.dialog.add( 'editplaceholder', function( editor ) 68 { 69 return placeholderDialog( editor, 1 ); 70 }); 71 } )(); 72