JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / button / plugin.js
index 54016fb..c0c8208 100644 (file)
@@ -70,7 +70,7 @@ CKEDITOR.ui.button.prototype =
        render : function( editor, output )\r
        {\r
                var env = CKEDITOR.env,\r
-                       id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber(),\r
+                       id = this._.id = CKEDITOR.tools.getNextId(),\r
                        classes = '',\r
                        command = this.command, // Get the command name.\r
                        clickFn,\r
@@ -98,11 +98,22 @@ CKEDITOR.ui.button.prototype =
 \r
                instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1;\r
 \r
+               // Indicate a mode sensitive button.\r
                if ( this.modes )\r
                {\r
+                       var modeStates = {};\r
+                       editor.on( 'beforeModeUnload', function()\r
+                               {\r
+                                       modeStates[ editor.mode ] = this._.state;\r
+                               }, this );\r
+\r
                        editor.on( 'mode', function()\r
                                {\r
-                                       this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );\r
+                                       var mode = editor.mode;\r
+                                       // Restore saved button state.\r
+                                       this.setState( this.modes[ mode ] ?\r
+                                               modeStates[ mode ] != undefined ? modeStates[ mode ] :\r
+                                                       CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );\r
                                }, this);\r
                }\r
                else if ( command )\r
@@ -134,7 +145,7 @@ CKEDITOR.ui.button.prototype =
                        '<span class="cke_button">',\r
                        '<a id="', id, '"' +\r
                                ' class="', classes, '"',\r
-                               env.gecko && env.version >= 10900 && !env.hc  ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'"+ '' )+ '\')"',\r
+                               env.gecko && env.version >= 10900 && !env.hc  ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'", '' )+ '\')"',\r
                                ' title="', this.title, '"' +\r
                                ' tabindex="-1"' +\r
                                ' hidefocus="true"' +\r
@@ -172,7 +183,7 @@ CKEDITOR.ui.button.prototype =
                }\r
 \r
                output.push(\r
-                                       '></span>' +\r
+                                       '>&nbsp;</span>' +\r
                                        '<span id="', id, '_label" class="cke_label">', this.label, '</span>' );\r
 \r
                if ( this.hasArrow )\r
@@ -180,7 +191,7 @@ CKEDITOR.ui.button.prototype =
                        output.push(\r
                                        '<span class="cke_buttonarrow">'\r
                                        // BLACK DOWN-POINTING TRIANGLE\r
-                                       + ( CKEDITOR.env.hc ? '&#9660;' : '' )\r
+                                       + ( CKEDITOR.env.hc ? '&#9660;' : '&nbsp;' )\r
                                        + '</span>' );\r
                }\r
 \r
@@ -270,3 +281,8 @@ CKEDITOR.ui.prototype.addButton = function( name, definition )
 {\r
        this.add( name, CKEDITOR.UI_BUTTON, definition );\r
 };\r
+\r
+CKEDITOR.on( 'reset', function()\r
+       {\r
+               CKEDITOR.ui.button._.instances = [];\r
+       });\r