JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / panel / plugin.js
index c7c6adb..cb0a615 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
@@ -16,7 +16,7 @@ CKEDITOR.plugins.add( 'panel',
  * @constant\r
  * @example\r
  */\r
-CKEDITOR.UI_PANEL = 2;\r
+CKEDITOR.UI_PANEL = 'panel';\r
 \r
 CKEDITOR.ui.panel = function( document, definition )\r
 {\r
@@ -31,7 +31,7 @@ CKEDITOR.ui.panel = function( document, definition )
                        css : []\r
                });\r
 \r
-       this.id = CKEDITOR.tools.getNextNumber();\r
+       this.id = CKEDITOR.tools.getNextId();\r
        this.document = document;\r
 \r
        this._ =\r
@@ -73,7 +73,7 @@ CKEDITOR.ui.panel.prototype =
         */\r
        render : function( editor, output )\r
        {\r
-               var id = 'cke_' + this.id;\r
+               var id = this.id;\r
 \r
                output.push(\r
                        '<div class="', editor.skinClass ,'"' +\r
@@ -130,18 +130,12 @@ CKEDITOR.ui.panel.prototype =
                {\r
                        if ( this.forceIFrame || this.css.length )\r
                        {\r
-                               var iframe = this.document.getById( 'cke_' + this.id + '_frame' ),\r
+                               var iframe = this.document.getById( this.id + '_frame' ),\r
                                        parentDiv = iframe.getParent(),\r
                                        dir = parentDiv.getAttribute( 'dir' ),\r
                                        className = parentDiv.getParent().getAttribute( 'class' ),\r
                                        langCode = parentDiv.getParent().getAttribute( 'lang' ),\r
                                        doc = iframe.getFrameDocument();\r
-                               // Initialize the IFRAME document body.\r
-                               doc.$.open();\r
-\r
-                               // Support for custom document.domain in IE.\r
-                               if ( CKEDITOR.env.isCustomDomain() )\r
-                                       doc.$.domain = document.domain;\r
 \r
                                var onLoad = CKEDITOR.tools.addFunction( CKEDITOR.tools.bind( function( ev )\r
                                        {\r
@@ -150,7 +144,7 @@ CKEDITOR.ui.panel.prototype =
                                                        this.onLoad();\r
                                        }, this ) );\r
 \r
-                               doc.$.write(\r
+                               var data =\r
                                        '<!DOCTYPE html>' +\r
                                        '<html dir="' + dir + '" class="' + className + '_container" lang="' + langCode + '">' +\r
                                                '<head>' +\r
@@ -162,18 +156,20 @@ CKEDITOR.ui.panel.prototype =
                                                // after <body>, so it (body) becames immediatelly\r
                                                // available. (#3031)\r
                                                CKEDITOR.tools.buildStyleHtml( this.css ) +\r
-                                       '<\/html>' );\r
-                               doc.$.close();\r
+                                       '<\/html>';\r
+\r
+                               doc.write( data );\r
 \r
                                var win = doc.getWindow();\r
 \r
                                // Register the CKEDITOR global.\r
                                win.$.CKEDITOR = CKEDITOR;\r
 \r
-                               doc.on( 'keydown', function( evt )\r
+                               // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (#4534).\r
+                               doc.on( 'key' + ( CKEDITOR.env.opera? 'press':'down' ), function( evt )\r
                                        {\r
                                                var keystroke = evt.data.getKeystroke(),\r
-                                                       dir = this.document.getById( 'cke_' + this.id ).getAttribute( 'dir' );\r
+                                                       dir = this.document.getById( this.id ).getAttribute( 'dir' );\r
 \r
                                                // Delegate key processing to block.\r
                                                if ( this._.onKeyDown && this._.onKeyDown( keystroke ) === false )\r
@@ -186,16 +182,17 @@ CKEDITOR.ui.panel.prototype =
                                                if ( keystroke == 27 || keystroke == ( dir == 'rtl' ? 39 : 37 ) )\r
                                                {\r
                                                        if ( this.onEscape && this.onEscape( keystroke ) === false )\r
-                                                               evt.data.preventDefault( );\r
+                                                               evt.data.preventDefault();\r
                                                }\r
                                        },\r
                                        this );\r
 \r
                                holder = doc.getBody();\r
                                holder.unselectable();\r
+                               CKEDITOR.env.air && CKEDITOR.tools.callFunction( onLoad );\r
                        }\r
                        else\r
-                               holder = this.document.getById( 'cke_' + this.id );\r
+                               holder = this.document.getById( this.id );\r
 \r
                        this._.holder = holder;\r
                }\r
@@ -225,7 +222,7 @@ CKEDITOR.ui.panel.prototype =
                        block = blocks[ name ],\r
                        current = this._.currentBlock,\r
                        holder = this.forceIFrame ?\r
-                               this.document.getById( 'cke_' + this.id + '_frame' )\r
+                               this.document.getById( this.id + '_frame' )\r
                                : this._.holder;\r
 \r
                // Disable context menu for block panel.\r
@@ -317,7 +314,7 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
 \r
                        // Safari need focus on the iframe window first(#3389), but we need\r
                        // lock the blur to avoid hiding the panel.\r
-                       if ( CKEDITOR.env.webkit )\r
+                       if ( CKEDITOR.env.webkit || CKEDITOR.env.opera )\r
                                item.getDocument().getWindow().focus();\r
                        item.focus();\r
 \r
@@ -383,11 +380,12 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
                                        return false;\r
 \r
                                case 'click' :\r
+                               case 'mouseup' :\r
                                        index = this._.focusIndex;\r
                                        link = index >= 0 && this.element.getElementsByTag( 'a' ).getItem( index );\r
 \r
                                        if ( link )\r
-                                               link.$.click ? link.$.click() : link.$.onclick();\r
+                                               link.$[ keyAction ] ? link.$[ keyAction ]() : link.$[ 'on' + keyAction ]();\r
 \r
                                        return false;\r
                        }\r
@@ -396,3 +394,10 @@ CKEDITOR.ui.panel.block = CKEDITOR.tools.createClass(
                }\r
        }\r
 });\r
+\r
+/**\r
+ * Fired when a panel is added to the document\r
+ * @name CKEDITOR#ariaWidget\r
+ * @event\r
+ * @param {Object} holder The element wrapping the panel\r
+ */\r