JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6
[ckeditor.git] / _source / plugins / editingblock / plugin.js
index 05d78b6..8feabcd 100644 (file)
@@ -10,11 +10,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 (function()\r
 {\r
-       var getMode = function( editor, mode )\r
-       {\r
-               return editor._.modes && editor._.modes[ mode || editor.mode ];\r
-       };\r
-\r
        // This is a semaphore used to avoid recursive calls between\r
        // the following data handling functions.\r
        var isHandlingData;\r
@@ -49,7 +44,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                function setData()\r
                                                {\r
                                                        isHandlingData = true;\r
-                                                       getMode( editor ).loadData( editor.getData() );\r
+                                                       editor.getMode().loadData( editor.getData() );\r
                                                        isHandlingData = false;\r
                                                }\r
 \r
@@ -59,8 +54,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                {\r
                                                        editor.on( 'mode', function()\r
                                                                {\r
-                                                                       setData();\r
-                                                                       editor.removeListener( 'mode', arguments.callee );\r
+                                                                       if ( editor.mode )\r
+                                                                       {\r
+                                                                               setData();\r
+                                                                               editor.removeListener( 'mode', arguments.callee );\r
+                                                                       }\r
                                                                });\r
                                                }\r
                                        }\r
@@ -71,7 +69,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        if ( !isHandlingData && editor.mode )\r
                                        {\r
                                                isHandlingData = true;\r
-                                               editor.setData( getMode( editor ).getData(), null, 1 );\r
+                                               editor.setData( editor.getMode().getData(), null, 1 );\r
                                                isHandlingData = false;\r
                                        }\r
                                });\r
@@ -79,13 +77,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        editor.on( 'getSnapshot', function( event )\r
                                {\r
                                        if ( editor.mode )\r
-                                               event.data = getMode( editor ).getSnapshotData();\r
+                                               event.data = editor.getMode().getSnapshotData();\r
                                });\r
 \r
                        editor.on( 'loadSnapshot', function( event )\r
                                {\r
                                        if ( editor.mode )\r
-                                               getMode( editor ).loadSnapshotData( event.data );\r
+                                               editor.getMode().loadSnapshotData( event.data );\r
                                });\r
 \r
                        // For the first "mode" call, we'll also fire the "instanceReady"\r
@@ -167,7 +165,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                        this.fire( 'beforeModeUnload' );\r
 \r
-                       var currentMode = getMode( this );\r
+                       var currentMode = this.getMode();\r
                        data = currentMode.getData();\r
                        currentMode.unload( holderElement );\r
                        this.mode = '';\r
@@ -176,7 +174,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                holderElement.setHtml( '' );\r
 \r
                // Load required mode.\r
-               var modeEditor = getMode( this, mode );\r
+               var modeEditor = this.getMode( mode );\r
                if ( !modeEditor )\r
                        throw '[CKEDITOR.editor.setMode] Unknown mode "' + mode + '".';\r
 \r
@@ -193,12 +191,23 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        };\r
 \r
        /**\r
+        * Gets the current or any of the objects that represent the editing\r
+        * area modes. The two most common editing modes are "wysiwyg" and "source".\r
+        * @param {String} [mode] The mode to be retrieved. If not specified, the\r
+        *              current one is returned.\r
+        */\r
+       CKEDITOR.editor.prototype.getMode = function( mode )\r
+       {\r
+               return this._.modes && this._.modes[ mode || this.mode ];\r
+       };\r
+\r
+       /**\r
         * Moves the selection focus to the editing are space in the editor.\r
         */\r
        CKEDITOR.editor.prototype.focus = function()\r
        {\r
                this.forceNextSelectionCheck();\r
-               var mode = getMode( this );\r
+               var mode = this.getMode();\r
                if ( mode )\r
                        mode.focus();\r
        };\r