+ var onOk = function()\r
+ {\r
+ releaseHandlers( this );\r
+ callback( this, this._.parentDialog );\r
+ this._.parentDialog.changeFocus( true );\r
+ };\r
+ var onCancel = function()\r
+ {\r
+ releaseHandlers( this );\r
+ this._.parentDialog.changeFocus();\r
+ };\r
+ var releaseHandlers = function( dialog )\r
+ {\r
+ dialog.removeListener( 'ok', onOk );\r
+ dialog.removeListener( 'cancel', onCancel );\r
+ };\r
+ var bindToDialog = function( dialog )\r
+ {\r
+ dialog.on( 'ok', onOk );\r
+ dialog.on( 'cancel', onCancel );\r
+ };\r
+ editor.execCommand( dialogName );\r
+ if ( editor._.storedDialogs.colordialog )\r
+ bindToDialog( editor._.storedDialogs.colordialog );\r
+ else\r
+ {\r
+ CKEDITOR.on( 'dialogDefinition', function( e )\r
+ {\r
+ if ( e.data.name != dialogName )\r
+ return;\r
+\r
+ var definition = e.data.definition;\r
+\r
+ e.removeListener();\r
+ definition.onLoad = CKEDITOR.tools.override( definition.onLoad, function( orginal )\r
+ {\r
+ return function()\r
+ {\r
+ bindToDialog( this );\r
+ definition.onLoad = orginal;\r
+ if ( typeof orginal == 'function' )\r
+ orginal.call( this );\r
+ };\r
+ } );\r
+ });\r
+ }\r