1CKEDITOR.dialog.add( 'noteDialog', function( editor ) {
2    return {
3        title: 'Note Properties',
4        minWidth: 400,
5        minHeight: 200,
6        contents: [
7			{
8                id: 'tab-basic',
9                label: 'Basic Note',
10                elements: [
11                    {
12						type: 'radio',
13						id: 'notetype',
14						label: editor.lang.note.selectOption,
15						items: [ [ '<img src="' + DOKU_BASE+ 'lib/plugins/ckgedit/ckeditor/plugins/note/icons/note_basic.png" alt="'+editor.lang.note.basic +'">', 'basic' ], [ '<img src="' + DOKU_BASE+ 'lib/plugins/ckgedit/ckeditor/plugins/note/icons/note_important.png" alt="'+editor.lang.note.important+'">', 'important' ] , [ '<img src="' + DOKU_BASE+ 'lib/plugins/ckgedit/ckeditor/plugins/note/icons/note_tip.png" alt="'+editor.lang.note    .tip+'">', 'tip' ] , [ '<img src="' + DOKU_BASE+ 'lib/plugins/ckgedit/ckeditor/plugins/note/icons/note_warning.png" alt="'+editor.lang.note.warning+'">', 'warning' ] ],
16						style: 'color: black',
17						'default': 'basic',
18					},
19					{
20                        type: 'text',
21                        id: 'note',
22                        label: editor.lang.note.content,
23              			'default': ''
24                    }
25                ]
26            }
27        ],
28		// Invoked when the dialog is loaded.
29		onShow: function() {
30			// Get the selection from the editor.
31		    var text = editor.getSelection().getSelectedText();
32            if(text) {
33                this.getContentElement( 'tab-basic', 'note').disable();
34                this.setValueOf( 'tab-basic', 'note',text);
35            }
36               else this.text = false;
37		},
38
39        onOk: function() {
40            var dialog = this;
41
42          //    var note = editor.document.createElement( 'note' );
43          //  note.setAttribute( 'title', dialog.getValueOf( 'tab-basic', 'note' ) );
44
45			//get the note type
46			var noteTypeValue = dialog.getValueOf( 'tab-basic', 'notetype' );
47
48
49			if (noteTypeValue == 'basic') {
50				noteTypeValue = '<note>';
51			} else {
52				noteTypeValue = '<note ' + noteTypeValue + '>';
53			}
54
55			//get the note text
56			var noteText = this.text ? this.text: dialog.getValueOf( 'tab-basic', 'note' );
57            if(!noteText) {
58                alert("Note cannot be left empty");
59                return false;
60            }
61			//insert the note
62			editor.insertText ( noteTypeValue + noteText + '</note>' )
63
64        }
65    };
66});
67