JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.6.1
[ckeditor.git] / _source / plugins / liststyle / plugin.js
index e63905f..8d4f575 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -7,19 +7,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 {\r
        CKEDITOR.plugins.liststyle =\r
        {\r
+               requires : [ 'dialog' ],\r
                init : function( editor )\r
                {\r
-\r
                        editor.addCommand( 'numberedListStyle', new CKEDITOR.dialogCommand( 'numberedListStyle' ) );\r
                        CKEDITOR.dialog.add( 'numberedListStyle', this.path + 'dialogs/liststyle.js' );\r
                        editor.addCommand( 'bulletedListStyle', new CKEDITOR.dialogCommand( 'bulletedListStyle' ) );\r
                        CKEDITOR.dialog.add( 'bulletedListStyle', this.path + 'dialogs/liststyle.js' );\r
 \r
-                       //Register map group;\r
-                       editor.addMenuGroup("list", 108);\r
                        // If the "menu" plugin is loaded, register the menu items.\r
                        if ( editor.addMenuItems )\r
                        {\r
+                               //Register map group;\r
+                               editor.addMenuGroup("list", 108);\r
+\r
                                editor.addMenuItems(\r
                                        {\r
                                                numberedlist :\r
@@ -42,14 +43,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        {\r
                                editor.contextMenu.addListener( function( element, selection )\r
                                        {\r
-                                               if ( !element )\r
+                                               if ( !element || element.isReadOnly() )\r
                                                        return null;\r
 \r
-                                               if ( element.getAscendant( 'ol') )\r
-                                                       return { numberedlist: CKEDITOR.TRISTATE_OFF };\r
+                                               while ( element )\r
+                                               {\r
+                                                       var name = element.getName();\r
+                                                       if ( name == 'ol' )\r
+                                                               return { numberedlist: CKEDITOR.TRISTATE_OFF };\r
+                                                       else if ( name == 'ul' )\r
+                                                               return { bulletedlist: CKEDITOR.TRISTATE_OFF };\r
 \r
-                                               if ( element.getAscendant( 'ul' ) )\r
-                                                       return { bulletedlist: CKEDITOR.TRISTATE_OFF };\r
+                                                       element = element.getParent();\r
+                                               }\r
+                                               return null;\r
                                        });\r
                        }\r
                }\r