JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / plugins / toolbar / plugin.js
index 4f4cd09..891b450 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -346,6 +346,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        }\r
                                });\r
 \r
+                       editor.on( 'destroy', function()\r
+                       {\r
+                               var toolbars, index = 0, i,\r
+                                               items, instance;\r
+                               toolbars = this.toolbox.toolbars;\r
+                               for ( ; index < toolbars.length; index++ )\r
+                               {\r
+                                       items = toolbars[ index ].items;\r
+                                       for ( i = 0; i < items.length; i++ )\r
+                                       {\r
+                                               instance = items[ i ];\r
+                                               if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );\r
+                                               if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );\r
+\r
+                                               if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;\r
+                                       }\r
+                               }\r
+                       });\r
+\r
                        editor.addCommand( 'toolbarFocus', commands.toolbarFocus );\r
                }\r
        });\r