JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / plugins / toolbar / plugin.js
index a936df5..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
@@ -43,8 +43,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                {\r
                                        editor.toolbox.focusCommandExecuted = true;\r
 \r
-                                       // Make the first button focus accessible. (#3417)\r
-                                       if ( CKEDITOR.env.ie )\r
+                                       // Make the first button focus accessible for IE. (#3417)\r
+                                       // Adobe AIR instead need while of delay.\r
+                                       if ( CKEDITOR.env.ie || CKEDITOR.env.air )\r
                                                setTimeout( function(){ editor.toolbox.focus(); }, 100 );\r
                                        else\r
                                                editor.toolbox.focus();\r
@@ -157,9 +158,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        {\r
                                                editor.toolbox = new toolbox();\r
 \r
-                                               var labelId = 'cke_' + CKEDITOR.tools.getNextNumber();\r
+                                               var labelId = CKEDITOR.tools.getNextId();\r
 \r
-                                               var output = [ '<div class="cke_toolbox" role="toolbar" aria-labelledby="', labelId, '"' ],\r
+                                               var output = [ '<div class="cke_toolbox" role="toolbar" aria-labelledby="', labelId, '" onmousedown="return false;"' ],\r
                                                        expanded =  editor.config.toolbarStartupExpanded !== false,\r
                                                        groupStarted;\r
 \r
@@ -187,7 +188,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        if ( !row )\r
                                                                continue;\r
 \r
-                                                       var toolbarId = 'cke_' + CKEDITOR.tools.getNextNumber(),\r
+                                                       var toolbarId = CKEDITOR.tools.getNextId(),\r
                                                                toolbarObj = { id : toolbarId, items : [] };\r
 \r
                                                        if ( groupStarted )\r
@@ -283,25 +284,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                function()\r
                                                                {\r
                                                                        editor.execCommand( 'toolbarCollapse' );\r
-                                                               } );\r
+                                                               });\r
 \r
                                                        editor.on( 'destroy', function () {\r
                                                                        CKEDITOR.tools.removeFunction( collapserFn );\r
-                                                               } );\r
+                                                               });\r
 \r
-                                                       var collapserId = 'cke_' + CKEDITOR.tools.getNextNumber();\r
+                                                       var collapserId = CKEDITOR.tools.getNextId();\r
 \r
                                                        editor.addCommand( 'toolbarCollapse',\r
                                                                {\r
                                                                        exec : function( editor )\r
                                                                        {\r
-                                                                               var collapser = CKEDITOR.document.getById( collapserId );\r
-                                                                               var toolbox = collapser.getPrevious();\r
-                                                                               var contents = editor.getThemeSpace( 'contents' );\r
-                                                                               var toolboxContainer = toolbox.getParent();\r
-                                                                               var contentHeight = parseInt( contents.$.style.height, 10 );\r
-                                                                               var previousHeight = toolboxContainer.$.offsetHeight;\r
-                                                                               var collapsed = !toolbox.isVisible();\r
+                                                                               var collapser = CKEDITOR.document.getById( collapserId ),\r
+                                                                                       toolbox = collapser.getPrevious(),\r
+                                                                                       contents = editor.getThemeSpace( 'contents' ),\r
+                                                                                       toolboxContainer = toolbox.getParent(),\r
+                                                                                       contentHeight = parseInt( contents.$.style.height, 10 ),\r
+                                                                                       previousHeight = toolboxContainer.$.offsetHeight,\r
+                                                                                       collapsed = !toolbox.isVisible();\r
 \r
                                                                                if ( !collapsed )\r
                                                                                {\r
@@ -345,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
@@ -415,8 +435,9 @@ CKEDITOR.config.toolbar_Basic =
  *     ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\r
  *     ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],\r
  *     ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\r
+ *     ['BidiLtr', 'BidiRtl' ],\r
  *     ['Link','Unlink','Anchor'],\r
- *     ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],\r
+ *     ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],\r
  *     '/',\r
  *     ['Styles','Format','Font','FontSize'],\r
  *     ['TextColor','BGColor'],\r
@@ -433,9 +454,9 @@ CKEDITOR.config.toolbar_Full =
        ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\r
        ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],\r
        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\r
-       ['BidiLtr', 'BidiRtl'],\r
+       ['BidiLtr', 'BidiRtl' ],\r
        ['Link','Unlink','Anchor'],\r
-       ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],\r
+       ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],\r
        '/',\r
        ['Styles','Format','Font','FontSize'],\r
        ['TextColor','BGColor'],\r