CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/flash/dialogs/flash.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
	    /*
	     * It is possible to set things in three different places.
	     * 1. As attributes in the object tag.
	     * 2. As param tags under the object tag.
	     * 3. As attributes in the embed tag.
	     * It is possible for a single attribute to be present in more than one place.
	     * So let's define a mapping between a sementic attribute and its syntactic
	     * equivalents.
	     * Then we'll set and retrieve attribute values according to the mapping,
	     * instead of having to check and set each syntactic attribute every time.
	     *
	     * Reference: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701
	     */
	    var ATTRTYPE_OBJECT 1,
	        ATTRTYPE_PARAM 2,
	        ATTRTYPE_EMBED 4;
	    var attributesMap =
	    {
		        id : [ { type ATTRTYPE_OBJECTname :  'id'
			} ],
		        classid : [ { type ATTRTYPE_OBJECTname 'classid'
			} ],
		        codebase : [ { type ATTRTYPE_OBJECTname 'codebase'} ],
		        pluginspage : [ { type ATTRTYPE_EMBEDname 'pluginspage'
			} ],
		        src : [ { type ATTRTYPE_PARAMname 'movie'
			}, { type ATTRTYPE_EMBEDname 'src'
			} ],
		        name : [ { type ATTRTYPE_EMBEDname 'name'
			} ],
		        align : [ { type ATTRTYPE_OBJECTname 'align'
			} ],
		        title : [ { type ATTRTYPE_OBJECTname 'title'
			}, { type ATTRTYPE_EMBEDname 'title'
			} ],
		        'class' : [ { type ATTRTYPE_OBJECTname 'class'
			}, { type ATTRTYPE_EMBEDname 'class'} ],
		        width : [ { type ATTRTYPE_OBJECTname 'width'
			}, { type ATTRTYPE_EMBEDname 'width'
			} ],
		        height : [ { type ATTRTYPE_OBJECTname 'height'
			}, { type ATTRTYPE_EMBEDname 'height'
			} ],
		        hSpace : [ { type ATTRTYPE_OBJECTname 'hSpace'
			}, { type ATTRTYPE_EMBEDname 'hSpace'
			} ],
		        vSpace : [ { type ATTRTYPE_OBJECTname 'vSpace'
			}, { type ATTRTYPE_EMBEDname 'vSpace'
			} ],
		        style : [ { type ATTRTYPE_OBJECTname 'style'
			}, { type ATTRTYPE_EMBEDname 'style'
			} ],
		        type : [ { type ATTRTYPE_EMBEDname 'type'
			} ]
		    };
	    var names = [ 'play''loop''menu''quality''scale''salign''wmode''bgcolor''base''flashvars''allowScriptAccess',
	        'allowFullScreen' ];
	    for ( var ;
	 names.length ;
	 i++ )
	        attributesMapnames[i] ] = [ { type ATTRTYPE_EMBEDname names[i]
		}, { type ATTRTYPE_PARAMname names[i]
		} ];
	    names = [ 'allowFullScreen''play''loop''menu' ];
	    for ( ;
	 names.length ;
	 i++ )
	        attributesMapnames[i] ][0]['default'] = attributesMapnames[i] ][1]['default'] = true;
	    function loadValueobjectNodeembedNodeparamMap )
	    {
		        var attributes attributesMapthis.id ];
		        if ( !attributes )
		            return;
		        var isCheckbox = ( this instanceof CKEDITOR.ui.dialog.checkbox );
		        for ( var ;
		 attributes.length ;
		 i++ )
		        {
			            var attrDef attributes];
			            switch ( attrDef.type )
			            {
				                case ATTRTYPE_OBJECT:
				                    if ( !objectNode )
				                        continue;
				                    if ( objectNode.getAttributeattrDef.name ) !== null )
				                    {
					                        var value objectNode.getAttributeattrDef.name );
					                        if ( isCheckbox )
					                            this.setValuevalue.toLowerCase() == 'true' );
					                        else
					                            this.setValuevalue );
					                        return;
					                    }
				                    else if ( isCheckbox )
				                        this.setValue( !!attrDef'default' ] );
				                    break;
				                case ATTRTYPE_PARAM:
				                    if ( !objectNode )
				                        continue;
				                    if ( attrDef.name in paramMap )
				                    {
					                        value paramMapattrDef.name ];
					                        if ( isCheckbox )
					                            this.setValuevalue.toLowerCase() == 'true' );
					                        else
					                            this.setValuevalue );
					                        return;
					                    }
				                    else if ( isCheckbox )
				                        this.setValue( !!attrDef'default' ] );
				                    break;
				                case ATTRTYPE_EMBED:
				                    if ( !embedNode )
				                        continue;
				                    if ( embedNode.getAttributeattrDef.name ) )
				                    {
					                        value embedNode.getAttributeattrDef.name );
					                        if ( isCheckbox )
					                            this.setValuevalue.toLowerCase() == 'true' );
					                        else
					                            this.setValuevalue );
					                        return;
					                    }
				                    else if ( isCheckbox )
				                        this.setValue( !!attrDef'default' ] );
				            }
			        }
		    }
	    function commitValueobjectNodeembedNodeparamMap )
	    {
		        var attributes attributesMapthis.id ];
		        if ( !attributes )
		            return;
		        var isRemove = ( this.getValue() === '' ),
		            isCheckbox = ( this instanceof CKEDITOR.ui.dialog.checkbox );
		        for ( var ;
		 attributes.length ;
		 i++ )
		        {
			            var attrDef attributes[i];
			            switch ( attrDef.type )
			            {
				                case ATTRTYPE_OBJECT:
				                    if ( !objectNode )
				                        continue;
				                    var value this.getValue();
				                    if ( isRemove || isCheckbox && value === attrDef'default' ] )
				                        objectNode.removeAttributeattrDef.name );
				                    else
				                        objectNode.setAttributeattrDef.namevalue );
				                    break;
				                case ATTRTYPE_PARAM:
				                    if ( !objectNode )
				                        continue;
				                    value this.getValue();
				                    if ( isRemove || isCheckbox && value === attrDef'default' ] )
				                    {
					                        if ( attrDef.name in paramMap )
					                            paramMapattrDef.name ].remove();
					                    }
				                    else
				                    {
					                        if ( attrDef.name in paramMap )
					                            paramMapattrDef.name ].setAttribute'value'value );
					                        else
					                        {
						                            var param CKEDITOR.dom.element.createFromHtml'<cke:param></cke:param>'objectNode.getDocument() );
						                            param.setAttributes( { name attrDef.namevalue value
							} );
						                            if ( objectNode.getChildCount() < )
						                                param.appendToobjectNode );
						                            else
						                                param.insertBeforeobjectNode.getFirst() );
						                        }
					                    }
				                    break;
				                case ATTRTYPE_EMBED:
				                    if ( !embedNode )
				                        continue;
				                    value this.getValue();
				                    if ( isRemove || isCheckbox && value === attrDef'default' ])
				                        embedNode.removeAttributeattrDef.name );
				                    else
				                        embedNode.setAttributeattrDef.namevalue );
				            }
			        }
		    }
	    CKEDITOR.dialog.add'flash', function( editor )
	    {
		        var makeObjectTag = !editor.config.flashEmbedTagOnly,
		            makeEmbedTag editor.config.flashAddEmbedTag || editor.config.flashEmbedTagOnly;
		        var previewPreloader,
		            previewAreaHtml '<div>' CKEDITOR.tools.htmlEncodeeditor.lang.common.preview ) +'<br>' +
		            '<div id="cke_FlashPreviewLoader' CKEDITOR.tools.getNextNumber() + '" style="display:none"><div class="loading">&nbsp;
		</div></div>' +
		            '<div id="cke_FlashPreviewBox' CKEDITOR.tools.getNextNumber() + '" class="FlashPreviewBox"></div></div>';
		        return {
			            title editor.lang.flash.title,
			            minWidth 420,
			            minHeight 310,
			            onShow : function()
			            {
				                // Clear previously saved elements.
				                this.fakeImage this.objectNode this.embedNode null;
				                previewPreloader = new CKEDITOR.dom.element'embed'editor.document );
				                // Try to detect any embed or object tag that has Flash parameters.
				                var fakeImage this.getSelectedElement();
				                if ( fakeImage && fakeImage.getAttribute'_cke_real_element_type' ) && fakeImage.getAttribute'_cke_real_element_type' ) == 'flash' )
				                {
					                    this.fakeImage fakeImage;
					                    var realElement editor.restoreRealElementfakeImage ),
					                        objectNode nullembedNode nullparamMap {};
					                    if ( realElement.getName() == 'cke:object' )
					                    {
						                        objectNode realElement;
						                        var embedList objectNode.getElementsByTag'embed''cke' );
						                        if ( embedList.count() > )
						                            embedNode embedList.getItem);
						                        var paramList objectNode.getElementsByTag'param''cke' );
						                        for ( var 0length paramList.count() ;
						 length ;
						 i++ )
						                        {
							                            var item paramList.getItem),
							                                name item.getAttribute'name' ),
							                                value item.getAttribute'value' );
							                            paramMapname ] = value;
							                        }
						                    }
					                    else if ( realElement.getName() == 'cke:embed' )
					                        embedNode realElement;
					                    this.objectNode objectNode;
					                    this.embedNode embedNode;
					                    this.setupContentobjectNodeembedNodeparamMapfakeImage );
					                }
				            },
			            onOk : function()
			            {
				                // If there's no selected object or embed, create one. Otherwise, reuse the
				                // selected object and embed nodes.
				                var objectNode null,
				                    embedNode null,
				                    paramMap null;
				                if ( !this.fakeImage )
				                {
					                    if ( makeObjectTag )
					                    {
						                        objectNode CKEDITOR.dom.element.createFromHtml'<cke:object></cke:object>'editor.document );
						                        var attributes = {
							                            classid 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
							                            codebase 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'
							                        };
						                        objectNode.setAttributesattributes );
						                    }
					                    if ( makeEmbedTag )
					                    {
						                        embedNode CKEDITOR.dom.element.createFromHtml'<cke:embed></cke:embed>'editor.document );
						                        embedNode.setAttributes(
						                            {
							                                type 'application/x-shockwave-flash',
							                                pluginspage 'http://www.macromedia.com/go/getflashplayer'
							                            } );
						                        if ( objectNode )
						                            embedNode.appendToobjectNode );
						                    }
					                }
				                else
				                {
					                    objectNode this.objectNode;
					                    embedNode this.embedNode;
					                }
				                // Produce the paramMap if there's an object tag.
				                if ( objectNode )
				                {
					                    paramMap {};
					                    var paramList objectNode.getElementsByTag'param''cke' );
					                    for ( var 0length paramList.count() ;
					 length ;
					 i++ )
					                        paramMapparamList.getItem).getAttribute'name' ) ] = paramList.getItem);
					                }
				                // A subset of the specified attributes/styles
				                // should also be applied on the fake element to
				                // have better visual effect. (#5240)
				                var extraStyles {}extraAttributes {};
				                this.commitContentobjectNodeembedNodeparamMapextraStylesextraAttributes );
				                // Refresh the fake image.
				                var newFakeImage editor.createFakeElementobjectNode || embedNode'cke_flash''flash'true );
				                newFakeImage.setAttributesextraAttributes );
				                newFakeImage.setStylesextraStyles );
				                if ( this.fakeImage )
				                {
					                    newFakeImage.replacethis.fakeImage );
					                    editor.getSelection().selectElementnewFakeImage );
					                }
				                else
				                    editor.insertElementnewFakeImage );
				            },
			            onHide : function()
			            {
				                if ( this.preview )
				                    this.preview.setHtml('');
				            },
			            contents : [
			                {
				                    id 'info',
				                    label editor.lang.common.generalTab,
				                    accessKey 'I',
				                    elements :
				                    [
				                        {
					                            type 'vbox',
					                            padding 0,
					                            children :
					                            [
					                                {
						                                    type 'hbox',
						                                    widths : [ '280px''110px' ],
						                                    align 'right',
						                                    children :
						                                    [
						                                        {
							                                            id 'src',
							                                            type 'text',
							                                            label editor.lang.common.url,
							                                            required true,
							                                            validate CKEDITOR.dialog.validate.notEmptyeditor.lang.flash.validateSrc ),
							                                            setup loadValue,
							                                            commit commitValue,
							                                            onLoad : function()
							                                            {
								                                                var dialog this.getDialog(),
								                                                updatePreview = function( src ){
									                                                    // Query the preloader to figure out the url impacted by based href.
									                                                    previewPreloader.setAttribute'src'src );
									                                                    dialog.preview.setHtml'<embed height="100%" width="100%" src="'
									                                                        CKEDITOR.tools.htmlEncodepreviewPreloader.getAttribute'src' ) )
									                                                        + '" type="application/x-shockwave-flash"></embed>' );
									                                                };
								                                                // Preview element
								                                                dialog.preview dialog.getContentElement'info''preview' ).getElement().getChild);
								                                                // Sync on inital value loaded.
								                                                this.on'change', function( evt ){
									                                                        if ( evt.data && evt.data.value )
									                                                            updatePreviewevt.data.value );
									                                                    } );
								                                                // Sync when input value changed.
								                                                this.getInputElement().on'change', function( evt ){
									                                                    updatePreviewthis.getValue() );
									                                                }, this );
								                                            }
							                                        },
						                                        {
							                                            type 'button',
							                                            id 'browse',
							                                            filebrowser 'info:src',
							                                            hidden true,
							                                            // v-align with the 'src' field.
							                                            // TODO: We need something better than a fixed size here.
							                                            style 'display:inline-block;
							margin-top:10px;
							',
							                                            label editor.lang.common.browseServer
							                                        }
						                                    ]
						                                }
					                            ]
					                        },
				                        {
					                            type 'hbox',
					                            widths : [ '25%''25%''25%''25%''25%' ],
					                            children :
					                            [
					                                {
						                                    type 'text',
						                                    id 'width',
						                                    style 'width:95px',
						                                    label editor.lang.flash.width,
						                                    validate CKEDITOR.dialog.validate.integereditor.lang.flash.validateWidth ),
						                                    setup : function( objectNodeembedNodeparamMapfakeImage )
						                                    {
							                                        loadValue.applythisarguments );
							                                        if ( fakeImage )
							                                        {
								                                            var fakeImageWidth parseIntfakeImage.$.style.width10 );
								                                            if ( !isNaNfakeImageWidth ) )
								                                                this.setValuefakeImageWidth );
								                                        }
							                                    },
						                                    commit : function( objectNodeembedNodeparamMapextraStyles )
						                                    {
							                                        commitValue.applythisarguments );
							                                        if ( this.getValue() )
							                                            extraStyles.width this.getValue() + 'px';
							                                    }
						                                },
					                                {
						                                    type 'text',
						                                    id 'height',
						                                    style 'width:95px',
						                                    label editor.lang.flash.height,
						                                    validate CKEDITOR.dialog.validate.integereditor.lang.flash.validateHeight ),
						                                    setup : function( objectNodeembedNodeparamMapfakeImage )
						                                    {
							                                        loadValue.applythisarguments );
							                                        if ( fakeImage )
							                                        {
								                                            var fakeImageHeight parseIntfakeImage.$.style.height10 );
								                                            if ( !isNaNfakeImageHeight ) )
								                                                this.setValuefakeImageHeight );
								                                        }
							                                    },
						                                    commit : function( objectNodeembedNodeparamMapextraStyles )
						                                    {
							                                        commitValue.applythisarguments );
							                                        if ( this.getValue() )
							                                            extraStyles.height this.getValue() + 'px';
							                                    }
						                                },
					                                {
						                                    type 'text',
						                                    id 'hSpace',
						                                    style 'width:95px',
						                                    label editor.lang.flash.hSpace,
						                                    validate CKEDITOR.dialog.validate.integereditor.lang.flash.validateHSpace ),
						                                    setup loadValue,
						                                    commit commitValue
						                                },
					                                {
						                                    type 'text',
						                                    id 'vSpace',
						                                    style 'width:95px',
						                                    label editor.lang.flash.vSpace,
						                                    validate CKEDITOR.dialog.validate.integereditor.lang.flash.validateVSpace ),
						                                    setup loadValue,
						                                    commit commitValue
						                                }
					                            ]
					                        },
				                        {
					                            type 'vbox',
					                            children :
					                            [
					                                {
						                                    type 'html',
						                                    id 'preview',
						                                    style 'width:95%;
						',
						                                    html previewAreaHtml
						                                }
					                            ]
					                        }
				                    ]
				                },
			                {
				                    id 'Upload',
				                    hidden true,
				                    filebrowser 'uploadButton',
				                    label editor.lang.common.upload,
				                    elements :
				                    [
				                        {
					                            type 'file',
					                            id 'upload',
					                            label editor.lang.common.upload,
					                            size 38
					                        },
				                        {
					                            type 'fileButton',
					                            id 'uploadButton',
					                            label editor.lang.common.uploadSubmit,
					                            filebrowser 'info:src',
					                            'for' : [ 'Upload''upload' ]
					                        }
				                    ]
				                },
			                {
				                    id 'properties',
				                    label editor.lang.flash.propertiesTab,
				                    elements :
				                    [
				                        {
					                            type 'hbox',
					                            widths : [ '50%''50%' ],
					                            children :
					                            [
					                                {
						                                    id 'scale',
						                                    type 'select',
						                                    label editor.lang.flash.scale,
						                                    'default' '',
						                                    style 'width : 100%;
						',
						                                    items :
						                                    [
						                                        [ editor.lang.common.notSet ''],
						                                        [ editor.lang.flash.scaleAll'showall' ],
						                                        [ editor.lang.flash.scaleNoBorder'noborder' ],
						                                        [ editor.lang.flash.scaleFit'exactfit' ]
						                                    ],
						                                    setup loadValue,
						                                    commit commitValue
						                                },
					                                {
						                                    id 'allowScriptAccess',
						                                    type 'select',
						                                    label editor.lang.flash.access,
						                                    'default' '',
						                                    style 'width : 100%;
						',
						                                    items :
						                                    [
						                                        [ editor.lang.common.notSet ''],
						                                        [ editor.lang.flash.accessAlways'always' ],
						                                        [ editor.lang.flash.accessSameDomain'samedomain' ],
						                                        [ editor.lang.flash.accessNever'never' ]
						                                    ],
						                                    setup loadValue,
						                                    commit commitValue
						                                }
					                            ]
					                        },
				                        {
					                            type 'hbox',
					                            widths : [ '50%''50%' ],
					                            children :
					                            [
					                                {
						                                    id 'wmode',
						                                    type 'select',
						                                    label editor.lang.flash.windowMode,
						                                    'default' '',
						                                    style 'width : 100%;
						',
						                                    items :
						                                    [
						                                        [ editor.lang.common.notSet '' ],
						                                        [ editor.lang.flash.windowModeWindow'window' ],
						                                        [ editor.lang.flash.windowModeOpaque'opaque' ],
						                                        [ editor.lang.flash.windowModeTransparent'transparent' ]
						                                    ],
						                                    setup loadValue,
						                                    commit commitValue
						                                },
					                                {
						                                    id 'quality',
						                                    type 'select',
						                                    label editor.lang.flash.quality,
						                                    'default' 'high',
						                                    style 'width : 100%;
						',
						                                    items :
						                                    [
						                                        [ editor.lang.common.notSet '' ],
						                                        [ editor.lang.flash.qualityBest'best' ],
						                                        [ editor.lang.flash.qualityHigh'high' ],
						                                        [ editor.lang.flash.qualityAutoHigh'autohigh' ],
						                                        [ editor.lang.flash.qualityMedium'medium' ],
						                                        [ editor.lang.flash.qualityAutoLow'autolow' ],
						                                        [ editor.lang.flash.qualityLow'low' ]
						                                    ],
						                                    setup loadValue,
						                                    commit commitValue
						                                }
					                            ]
					                        },
				                        {
					                            type 'hbox',
					                            widths : [ '50%''50%' ],
					                            children :
					                            [
					                                {
						                                    id 'align',
						                                    type 'select',
						                                    label editor.lang.flash.align,
						                                    'default' '',
						                                    style 'width : 100%;
						',
						                                    items :
						                                    [
						                                        [ editor.lang.common.notSet ''],
						                                        [ editor.lang.flash.alignLeft 'left'],
						                                        [ editor.lang.flash.alignAbsBottom 'absBottom'],
						                                        [ editor.lang.flash.alignAbsMiddle 'absMiddle'],
						                                        [ editor.lang.flash.alignBaseline 'baseline'],
						                                        [ editor.lang.flash.alignBottom 'bottom'],
						                                        [ editor.lang.flash.alignMiddle 'middle'],
						                                        [ editor.lang.flash.alignRight 'right'],
						                                        [ editor.lang.flash.alignTextTop 'textTop'],
						                                        [ editor.lang.flash.alignTop 'top']
						                                    ],
						                                    setup loadValue,
						                                    commit : function( objectNodeembedNodeparamMapextraStylesextraAttributes )
						                                    {
							                                        var value this.getValue();
							                                        commitValue.applythisarguments );
							                                        value && ( extraAttributes.align value );
							                                    }
						                                },
					                                {
						                                    type 'html',
						                                    html '<div></div>'
						                                }
					                            ]
					                        },
				                        {
					                            type 'fieldset',
					                            label CKEDITOR.tools.htmlEncodeeditor.lang.flash.flashvars ),
					                            children :
					                            [
					                                {
						                                    type 'vbox',
						                                    padding 0,
						                                    children :
						                                    [
						                                        {
							                                            type 'checkbox',
							                                            id 'menu',
							                                            label editor.lang.flash.chkMenu,
							                                            'default' true,
							                                            setup loadValue,
							                                            commit commitValue
							                                        },
						                                        {
							                                            type 'checkbox',
							                                            id 'play',
							                                            label editor.lang.flash.chkPlay,
							                                            'default' true,
							                                            setup loadValue,
							                                            commit commitValue
							                                        },
						                                        {
							                                            type 'checkbox',
							                                            id 'loop',
							                                            label editor.lang.flash.chkLoop,
							                                            'default' true,
							                                            setup loadValue,
							                                            commit commitValue
							                                        },
						                                        {
							                                            type 'checkbox',
							                                            id 'allowFullScreen',
							                                            label editor.lang.flash.chkFull,
							                                            'default' true,
							                                            setup loadValue,
							                                            commit commitValue
							                                        }
						                                    ]
						                                }
					                            ]
					                        }
				                    ]
				                },
			                {
				                    id 'advanced',
				                    label editor.lang.common.advancedTab,
				                    elements :
				                    [
				                        {
					                            type 'hbox',
					                            widths : [ '45%''55%' ],
					                            children :
					                            [
					                                {
						                                    type 'text',
						                                    id 'id',
						                                    label editor.lang.common.id,
						                                    setup loadValue,
						                                    commit commitValue
						                                },
					                                {
						                                    type 'text',
						                                    id 'title',
						                                    label editor.lang.common.advisoryTitle,
						                                    setup loadValue,
						                                    commit commitValue
						                                }
					                            ]
					                        },
				                        {
					                            type 'hbox',
					                            widths : [ '45%''55%' ],
					                            children :
					                            [
					                                {
						                                    type 'text',
						                                    id 'bgcolor',
						                                    label editor.lang.flash.bgcolor,
						                                    setup loadValue,
						                                    commit commitValue
						                                },
					                                {
						                                    type 'text',
						                                    id 'class',
						                                    label editor.lang.common.cssClass,
						                                    setup loadValue,
						                                    commit commitValue
						                                }
					                            ]
					                        },
				                        {
					                            type 'text',
					                            id 'style',
					                            label editor.lang.common.cssStyle,
					                            setup loadValue,
					                            commit commitValue
					                        }
				                    ]
				                }
			            ]
			        };
		    } );
	})();





PHP Demo Source Code Index