JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / flash / dialogs / flash.js
index 2359b1b..8cdf10e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, 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
@@ -24,11 +24,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        var attributesMap =\r
        {\r
-               id : [ { type : ATTRTYPE_OBJECT, name : CKEDITOR.env.ie ? '_cke_saved_id' : 'id' } ],\r
+               id : [ { type : ATTRTYPE_OBJECT, name :  'id' } ],\r
                classid : [ { type : ATTRTYPE_OBJECT, name : 'classid' } ],\r
                codebase : [ { type : ATTRTYPE_OBJECT, name : 'codebase'} ],\r
                pluginspage : [ { type : ATTRTYPE_EMBED, name : 'pluginspage' } ],\r
-               src : [ { type : ATTRTYPE_PARAM, name : 'movie' }, { type : ATTRTYPE_EMBED, name : 'src' } ],\r
+               src : [ { type : ATTRTYPE_PARAM, name : 'movie' }, { type : ATTRTYPE_EMBED, name : 'src' }, { type : ATTRTYPE_OBJECT, name :  'data' } ],\r
                name : [ { type : ATTRTYPE_EMBED, name : 'name' } ],\r
                align : [ { type : ATTRTYPE_OBJECT, name : 'align' } ],\r
                title : [ { type : ATTRTYPE_OBJECT, name : 'title' }, { type : ATTRTYPE_EMBED, name : 'title' } ],\r
@@ -49,6 +49,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        for ( i = 0 ; i < names.length ; i++ )\r
                attributesMap[ names[i] ][0]['default'] = attributesMap[ names[i] ][1]['default'] = true;\r
 \r
+       var defaultToPixel = CKEDITOR.tools.cssLength;\r
+\r
        function loadValue( objectNode, embedNode, paramMap )\r
        {\r
                var attributes = attributesMap[ this.id ];\r
@@ -124,7 +126,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        switch ( attrDef.type )\r
                        {\r
                                case ATTRTYPE_OBJECT:\r
-                                       if ( !objectNode )\r
+                                       // Avoid applying the data attribute when not needed (#7733)\r
+                                       if ( !objectNode || ( attrDef.name == 'data' && embedNode && !objectNode.hasAttribute( 'data' ) ) )\r
                                                continue;\r
                                        var value = this.getValue();\r
                                        if ( isRemove || isCheckbox && value === attrDef[ 'default' ] )\r
@@ -173,9 +176,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                var makeObjectTag = !editor.config.flashEmbedTagOnly,\r
                        makeEmbedTag = editor.config.flashAddEmbedTag || editor.config.flashEmbedTagOnly;\r
 \r
-               var previewAreaHtml = '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.image.preview ) +'<br>' +\r
-                       '<div id="FlashPreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>' +\r
-                       '<div id="FlashPreviewBox"></div></div>';\r
+               var previewPreloader,\r
+                       previewAreaHtml = '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) +'<br>' +\r
+                       '<div id="cke_FlashPreviewLoader' + CKEDITOR.tools.getNextNumber() + '" style="display:none"><div class="loading">&nbsp;</div></div>' +\r
+                       '<div id="cke_FlashPreviewBox' + CKEDITOR.tools.getNextNumber() + '" class="FlashPreviewBox"></div></div>';\r
 \r
                return {\r
                        title : editor.lang.flash.title,\r
@@ -185,10 +189,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        {\r
                                // Clear previously saved elements.\r
                                this.fakeImage = this.objectNode = this.embedNode = null;\r
+                               previewPreloader = new CKEDITOR.dom.element( 'embed', editor.document );\r
 \r
                                // Try to detect any embed or object tag that has Flash parameters.\r
                                var fakeImage = this.getSelectedElement();\r
-                               if ( fakeImage && fakeImage.getAttribute( '_cke_real_element_type' ) && fakeImage.getAttribute( '_cke_real_element_type' ) == 'flash' )\r
+                               if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'flash' )\r
                                {\r
                                        this.fakeImage = fakeImage;\r
 \r
@@ -263,15 +268,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                paramMap[ paramList.getItem( i ).getAttribute( 'name' ) ] = paramList.getItem( i );\r
                                }\r
 \r
-                               // Apply or remove flash parameters.\r
-                               var extraStyles = {};\r
-                               this.commitContent( objectNode, embedNode, paramMap, extraStyles );\r
+                               // A subset of the specified attributes/styles\r
+                               // should also be applied on the fake element to\r
+                               // have better visual effect. (#5240)\r
+                               var extraStyles = {}, extraAttributes = {};\r
+                               this.commitContent( objectNode, embedNode, paramMap, extraStyles, extraAttributes );\r
 \r
                                // Refresh the fake image.\r
                                var newFakeImage = editor.createFakeElement( objectNode || embedNode, 'cke_flash', 'flash', true );\r
+                               newFakeImage.setAttributes( extraAttributes );\r
                                newFakeImage.setStyles( extraStyles );\r
                                if ( this.fakeImage )\r
+                               {\r
                                        newFakeImage.replace( this.fakeImage );\r
+                                       editor.getSelection().selectElement( newFakeImage );\r
+                               }\r
                                else\r
                                        editor.insertElement( newFakeImage );\r
                        },\r
@@ -295,10 +306,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        children :\r
                                                        [\r
                                                                {\r
-                                                                       type : 'html',\r
-                                                                       html : '<span>' + CKEDITOR.tools.htmlEncode( editor.lang.image.url ) + '</span>'\r
-                                                               },\r
-                                                               {\r
                                                                        type : 'hbox',\r
                                                                        widths : [ '280px', '110px' ],\r
                                                                        align : 'right',\r
@@ -307,7 +314,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                {\r
                                                                                        id : 'src',\r
                                                                                        type : 'text',\r
-                                                                                       label : '',\r
+                                                                                       label : editor.lang.common.url,\r
+                                                                                       required : true,\r
                                                                                        validate : CKEDITOR.dialog.validate.notEmpty( editor.lang.flash.validateSrc ),\r
                                                                                        setup : loadValue,\r
                                                                                        commit : commitValue,\r
@@ -315,9 +323,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                        {\r
                                                                                                var dialog = this.getDialog(),\r
                                                                                                updatePreview = function( src ){\r
-\r
+                                                                                                       // Query the preloader to figure out the url impacted by based href.\r
+                                                                                                       previewPreloader.setAttribute( 'src', src );\r
                                                                                                        dialog.preview.setHtml( '<embed height="100%" width="100%" src="'\r
-                                                                                                               + CKEDITOR.tools.htmlEncode( src )\r
+                                                                                                               + CKEDITOR.tools.htmlEncode( previewPreloader.getAttribute( 'src' ) )\r
                                                                                                                + '" type="application/x-shockwave-flash"></embed>' );\r
                                                                                                };\r
                                                                                                // Preview element\r
@@ -341,7 +350,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                        id : 'browse',\r
                                                                                        filebrowser : 'info:src',\r
                                                                                        hidden : true,\r
-                                                                                       align : 'center',\r
+                                                                                       // v-align with the 'src' field.\r
+                                                                                       // TODO: We need something better than a fixed size here.\r
+                                                                                       style : 'display:inline-block;margin-top:10px;',\r
                                                                                        label : editor.lang.common.browseServer\r
                                                                                }\r
                                                                        ]\r
@@ -357,47 +368,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        type : 'text',\r
                                                                        id : 'width',\r
                                                                        style : 'width:95px',\r
-                                                                       label : editor.lang.flash.width,\r
-                                                                       validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateWidth ),\r
-                                                                       setup : function( objectNode, embedNode, paramMap, fakeImage )\r
-                                                                       {\r
-                                                                               loadValue.apply( this, arguments );\r
-                                                                               if ( fakeImage )\r
-                                                                               {\r
-                                                                                       var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );\r
-                                                                                       if ( !isNaN( fakeImageWidth ) )\r
-                                                                                               this.setValue( fakeImageWidth );\r
-                                                                               }\r
-                                                                       },\r
-                                                                       commit : function( objectNode, embedNode, paramMap, extraStyles )\r
-                                                                       {\r
-                                                                               commitValue.apply( this, arguments );\r
-                                                                               if ( this.getValue() )\r
-                                                                                       extraStyles.width = this.getValue() + 'px';\r
-                                                                       }\r
+                                                                       label : editor.lang.common.width,\r
+                                                                       validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.width ) ),\r
+                                                                       setup : loadValue,\r
+                                                                       commit : commitValue\r
                                                                },\r
                                                                {\r
                                                                        type : 'text',\r
                                                                        id : 'height',\r
                                                                        style : 'width:95px',\r
-                                                                       label : editor.lang.flash.height,\r
-                                                                       validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateHeight ),\r
-                                                                       setup : function( objectNode, embedNode, paramMap, fakeImage )\r
-                                                                       {\r
-                                                                               loadValue.apply( this, arguments );\r
-                                                                               if ( fakeImage )\r
-                                                                               {\r
-                                                                                       var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );\r
-                                                                                       if ( !isNaN( fakeImageHeight ) )\r
-                                                                                               this.setValue( fakeImageHeight );\r
-                                                                               }\r
-                                                                       },\r
-                                                                       commit : function( objectNode, embedNode, paramMap, extraStyles )\r
-                                                                       {\r
-                                                                               commitValue.apply( this, arguments );\r
-                                                                               if ( this.getValue() )\r
-                                                                                       extraStyles.height = this.getValue() + 'px';\r
-                                                                       }\r
+                                                                       label : editor.lang.common.height,\r
+                                                                       validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.height ) ),\r
+                                                                       setup : loadValue,\r
+                                                                       commit : commitValue\r
                                                                },\r
                                                                {\r
                                                                        type : 'text',\r
@@ -550,24 +533,29 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                {\r
                                                                        id : 'align',\r
                                                                        type : 'select',\r
-                                                                       label : editor.lang.flash.align,\r
+                                                                       label : editor.lang.common.align,\r
                                                                        'default' : '',\r
                                                                        style : 'width : 100%;',\r
                                                                        items :\r
                                                                        [\r
                                                                                [ editor.lang.common.notSet , ''],\r
-                                                                               [ editor.lang.image.alignLeft , 'left'],\r
-                                                                               [ editor.lang.image.alignAbsBottom , 'absBottom'],\r
-                                                                               [ editor.lang.image.alignAbsMiddle , 'absMiddle'],\r
-                                                                               [ editor.lang.image.alignBaseline , 'baseline'],\r
-                                                                               [ editor.lang.image.alignBottom , 'bottom'],\r
-                                                                               [ editor.lang.image.alignMiddle , 'middle'],\r
-                                                                               [ editor.lang.image.alignRight , 'right'],\r
-                                                                               [ editor.lang.image.alignTextTop , 'textTop'],\r
-                                                                               [ editor.lang.image.alignTop , 'top']\r
+                                                                               [ editor.lang.common.alignLeft , 'left'],\r
+                                                                               [ editor.lang.flash.alignAbsBottom , 'absBottom'],\r
+                                                                               [ editor.lang.flash.alignAbsMiddle , 'absMiddle'],\r
+                                                                               [ editor.lang.flash.alignBaseline , 'baseline'],\r
+                                                                               [ editor.lang.common.alignBottom , 'bottom'],\r
+                                                                               [ editor.lang.common.alignMiddle , 'middle'],\r
+                                                                               [ editor.lang.common.alignRight , 'right'],\r
+                                                                               [ editor.lang.flash.alignTextTop , 'textTop'],\r
+                                                                               [ editor.lang.common.alignTop , 'top']\r
                                                                        ],\r
                                                                        setup : loadValue,\r
-                                                                       commit : commitValue\r
+                                                                       commit : function( objectNode, embedNode, paramMap, extraStyles, extraAttributes )\r
+                                                                       {\r
+                                                                               var value = this.getValue();\r
+                                                                               commitValue.apply( this, arguments );\r
+                                                                               value && ( extraAttributes.align = value );\r
+                                                                       }\r
                                                                },\r
                                                                {\r
                                                                        type : 'html',\r
@@ -576,45 +564,48 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        ]\r
                                                },\r
                                                {\r
-                                                       type : 'vbox',\r
-                                                       padding : 0,\r
+                                                       type : 'fieldset',\r
+                                                       label : CKEDITOR.tools.htmlEncode( editor.lang.flash.flashvars ),\r
                                                        children :\r
                                                        [\r
                                                                {\r
-                                                                       type : 'html',\r
-                                                                       html : CKEDITOR.tools.htmlEncode( editor.lang.flash.flashvars )\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'menu',\r
-                                                                       label : editor.lang.flash.chkMenu,\r
-                                                                       'default' : true,\r
-                                                                       setup : loadValue,\r
-                                                                       commit : commitValue\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'play',\r
-                                                                       label : editor.lang.flash.chkPlay,\r
-                                                                       'default' : true,\r
-                                                                       setup : loadValue,\r
-                                                                       commit : commitValue\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'loop',\r
-                                                                       label : editor.lang.flash.chkLoop,\r
-                                                                       'default' : true,\r
-                                                                       setup : loadValue,\r
-                                                                       commit : commitValue\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'allowFullScreen',\r
-                                                                       label : editor.lang.flash.chkFull,\r
-                                                                       'default' : true,\r
-                                                                       setup : loadValue,\r
-                                                                       commit : commitValue\r
+                                                                       type : 'vbox',\r
+                                                                       padding : 0,\r
+                                                                       children :\r
+                                                                       [\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'menu',\r
+                                                                                       label : editor.lang.flash.chkMenu,\r
+                                                                                       'default' : true,\r
+                                                                                       setup : loadValue,\r
+                                                                                       commit : commitValue\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'play',\r
+                                                                                       label : editor.lang.flash.chkPlay,\r
+                                                                                       'default' : true,\r
+                                                                                       setup : loadValue,\r
+                                                                                       commit : commitValue\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'loop',\r
+                                                                                       label : editor.lang.flash.chkLoop,\r
+                                                                                       'default' : true,\r
+                                                                                       setup : loadValue,\r
+                                                                                       commit : commitValue\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'allowFullScreen',\r
+                                                                                       label : editor.lang.flash.chkFull,\r
+                                                                                       'default' : true,\r
+                                                                                       setup : loadValue,\r
+                                                                                       commit : commitValue\r
+                                                                               }\r
+                                                                       ]\r
                                                                }\r
                                                        ]\r
                                                }\r