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

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/forms/dialogs/select.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.dialog.add'select', function( editor )
{
	    // Add a new option to a SELECT object (combo or list).
	    function addOptioncombooptionTextoptionValuedocumentObjectindex )
	    {
		        combo getSelectcombo );
		        var oOption;
		        if ( documentObject )
		            oOption documentObject.createElement"OPTION" );
		        else
		            oOption document.createElement"OPTION" );
		        if ( combo && oOption && oOption.getName() == 'option' )
		        {
			            if ( CKEDITOR.env.ie ) {
				                if ( !isNaNparseIntindex10) ) )
				                    combo.$.options.addoOption.$, index );
				                else
				                    combo.$.options.addoOption.$ );
				                oOption.$.innerHTML optionText.length optionText '';
				                oOption.$.value     optionValue;
				            }
			            else
			            {
				                if ( index !== null && index combo.getChildCount() )
				                    combo.getChildindex index ).insertBeforeMeoOption );
				                else
				                    combo.appendoOption );
				                oOption.setTextoptionText.length optionText '' );
				                oOption.setValueoptionValue );
				            }
			        }
		        else
		            return false;
		        return oOption;
		    }
	    // Remove all selected options from a SELECT object.
	    function removeSelectedOptionscombo )
	    {
		        combo getSelectcombo );
		        // Save the selected index
		        var iSelectedIndex getSelectedIndexcombo );
		        // Remove all selected options.
		        for ( var combo.getChildren().count() - ;
		 >= ;
		 i-- )
		        {
			            if ( combo.getChild).$.selected )
			                combo.getChild).remove();
			        }
		        // Reset the selection based on the original selected index.
		        setSelectedIndexcomboiSelectedIndex );
		    }
	    //Modify option  from a SELECT object.
	    function modifyOptioncomboindextitlevalue )
	    {
		        combo getSelectcombo );
		        if ( index )
		            return false;
		        var child combo.getChildindex );
		        child.setTexttitle );
		        child.setValuevalue );
		        return child;
		    }
	    function removeAllOptionscombo )
	    {
		        combo getSelectcombo );
		        while ( combo.getChild) && combo.getChild).remove() )
		        { /*jsl:pass*/
			}
		    }
	    // Moves the selected option by a number of steps (also negative).
	    function changeOptionPositioncombostepsdocumentObject )
	    {
		        combo getSelectcombo );
		        var iActualIndex getSelectedIndexcombo );
		        if ( iActualIndex )
		            return false;
		        var iFinalIndex iActualIndex steps;
		        iFinalIndex = ( iFinalIndex ) ? iFinalIndex;
		        iFinalIndex = ( iFinalIndex >= combo.getChildCount() ) ? combo.getChildCount() - iFinalIndex;
		        if ( iActualIndex == iFinalIndex )
		            return false;
		        var oOption combo.getChildiActualIndex ),
		            sText    oOption.getText(),
		            sValue    oOption.getValue();
		        oOption.remove();
		        oOption addOptioncombosTextsValue, ( !documentObject ) ? null documentObjectiFinalIndex );
		        setSelectedIndexcomboiFinalIndex );
		        return oOption;
		    }
	    function getSelectedIndexcombo )
	    {
		        combo getSelectcombo );
		        return combo combo.$.selectedIndex : -1;
		    }
	    function setSelectedIndexcomboindex )
	    {
		        combo getSelectcombo );
		        if ( index )
		            return null;
		        var count combo.getChildren().count();
		        combo.$.selectedIndex = ( index >= count ) ? ( count ) : index;
		        return combo;
		    }
	    function getOptionscombo )
	    {
		        combo getSelectcombo );
		        return combo combo.getChildren() : false;
		    }
	    function getSelectobj )
	    {
		        if ( obj && obj.domId && obj.getInputElement().$ )                // Dialog element.
		            return  obj.getInputElement();
		        else if ( obj && obj.$ )
		            return obj;
		        return false;
		    }
	    return {
		        title editor.lang.select.title,
		        minWidth CKEDITOR.env.ie 460 395,
		        minHeight CKEDITOR.env.ie 320 300,
		        onShow : function()
		        {
			            delete this.selectBox;
			            this.setupContent'clear' );
			            var element this.getParentEditor().getSelection().getSelectedElement();
			            if ( element && element.getName() == "select" )
			            {
				                this.selectBox element;
				                this.setupContentelement.getName(), element );
				                // Load Options into dialog.
				                var objOptions getOptionselement );
				                for ( var ;
				 objOptions.count() ;
				 i++ )
				                    this.setupContent'option'objOptions.getItem) );
				            }
			        },
		        onOk : function()
		        {
			            var editor this.getParentEditor(),
			                element this.selectBox,
			                isInsertMode = !element;
			            if ( isInsertMode )
			                element editor.document.createElement'select' );
			            this.commitContentelement );
			            if ( isInsertMode )
			            {
				                editor.insertElementelement );
				                if ( CKEDITOR.env.ie )
				                {
					                    var sel editor.getSelection(),
					                        bms sel.createBookmarks();
					                    setTimeout(function()
					                    {
						                        sel.selectBookmarksbms );
						                    }, );
					                }
				            }
			        },
		        contents : [
		            {
			                id 'info',
			                label editor.lang.select.selectInfo,
			                title editor.lang.select.selectInfo,
			                accessKey '',
			                elements : [
			                    {
				                        id 'txtName',
				                        type 'text',
				                        widths : [ '25%','75%' ],
				                        labelLayout 'horizontal',
				                        label editor.lang.common.name,
				                        'default' '',
				                        accessKey 'N',
				                        align 'center',
				                        style 'width:350px',
				                        setup : function( nameelement )
				                        {
					                            if ( name == 'clear' )
					                                this.setValuethis['default'] || '' );
					                            else if ( name == 'select' )
					                            {
						                                this.setValue(
						                                        element.getAttribute'_cke_saved_name' ) ||
						                                        element.getAttribute'name' ) ||
						                                        '' );
						                            }
					                        },
				                        commit : function( element )
				                        {
					                            if ( this.getValue() )
					                                element.setAttribute'_cke_saved_name'this.getValue() );
					                            else
					                            {
						                                element.removeAttribute'_cke_saved_name' ) ;
						                                element.removeAttribute'name' );
						                            }
					                        }
				                    },
			                    {
				                        id 'txtValue',
				                        type 'text',
				                        widths : [ '25%','75%' ],
				                        labelLayout 'horizontal',
				                        label editor.lang.select.value,
				                        style 'width:350px',
				                        'default' '',
				                        className 'cke_disabled',
				                        onLoad : function()
				                        {
					                            this.getInputElement().setAttribute'readOnly'true );
					                        },
				                        setup : function( nameelement )
				                        {
					                            if ( name == 'clear' )
					                                this.setValue'' );
					                            else if ( name == 'option' && element.getAttribute'selected' ) )
					                                this.setValueelement.$.value );
					                        }
				                    },
			                    {
				                        type 'hbox',
				                        widths : [ '175px''170px' ],
				                        align 'center',
				                        children :
				                        [
				                            {
					                                id 'txtSize',
					                                type 'text',
					                                align 'center',
					                                labelLayout 'horizontal',
					                                label editor.lang.select.size,
					                                'default' '',
					                                accessKey 'S',
					                                style 'width:175px',
					                                validate: function()
					                                {
						                                    var func CKEDITOR.dialog.validate.integereditor.lang.common.validateNumberFailed );
						                                    return ( ( this.getValue() === '' ) || func.applythis ) );
						                                },
					                                setup : function( nameelement )
					                                {
						                                    if ( name == 'select' )
						                                        this.setValueelement.getAttribute'size' ) || '' );
						                                    if ( CKEDITOR.env.webkit )
						                                        this.getInputElement().setStyle'width''86px' );
						                                },
					                                commit : function( element )
					                                {
						                                    if ( this.getValue() )
						                                        element.setAttribute'size'this.getValue() );
						                                    else
						                                        element.removeAttribute'size' );
						                                }
					                            },
				                            {
					                                type 'html',
					                                html '<span>' CKEDITOR.tools.htmlEncodeeditor.lang.select.lines ) + '</span>'
					                            }
				                        ]
				                    },
			                    {
				                        type 'html',
				                        html '<span>' CKEDITOR.tools.htmlEncodeeditor.lang.select.opAvail ) + '</span>'
				                    },
			                    {
				                        type 'hbox',
				                        widths : [ '115px''115px' ,'100px' ],
				                        align 'top',
				                        children :
				                        [
				                            {
					                                type 'vbox',
					                                children :
					                                [
					                                    {
						                                        id 'txtOptName',
						                                        type 'text',
						                                        label editor.lang.select.opText,
						                                        style 'width:115px',
						                                        setup : function( nameelement )
						                                        {
							                                            if ( name == 'clear' )
							                                                this.setValue"" );
							                                        }
						                                    },
					                                    {
						                                        type 'select',
						                                        id 'cmbName',
						                                        label '',
						                                        title '',
						                                        size 5,
						                                        style 'width:115px;
						height:75px',
						                                        items [],
						                                        onChange : function()
						                                        {
							                                            var dialog this.getDialog(),
							                                                values dialog.getContentElement'info''cmbValue' ),
							                                                optName dialog.getContentElement'info''txtOptName' ),
							                                                optValue dialog.getContentElement'info''txtOptValue' ),
							                                                iIndex getSelectedIndexthis );
							                                            setSelectedIndexvaluesiIndex );
							                                            optName.setValuethis.getValue() );
							                                            optValue.setValuevalues.getValue() );
							                                        },
						                                        setup : function( nameelement )
						                                        {
							                                            if ( name == 'clear' )
							                                                removeAllOptionsthis );
							                                            else if ( name == 'option' )
							                                                addOptionthiselement.getText(), element.getText(),
							                                                    this.getDialog().getParentEditor().document );
							                                        },
						                                        commit : function( element )
						                                        {
							                                            var dialog this.getDialog(),
							                                                optionsNames getOptionsthis ),
							                                                optionsValues getOptionsdialog.getContentElement'info''cmbValue' ) ),
							                                                selectValue dialog.getContentElement'info''txtValue' ).getValue();
							                                            removeAllOptionselement );
							                                            for ( var ;
							 optionsNames.count() ;
							 i++ )
							                                            {
								                                                var oOption addOptionelementoptionsNames.getItem).getValue(),
								                                                    optionsValues.getItem).getValue(), dialog.getParentEditor().document );
								                                                if ( optionsValues.getItem).getValue() == selectValue )
								                                                {
									                                                    oOption.setAttribute'selected''selected' );
									                                                    oOption.selected true;
									                                                }
								                                            }
							                                        }
						                                    }
					                                ]
					                            },
				                            {
					                                type 'vbox',
					                                children :
					                                [
					                                    {
						                                        id 'txtOptValue',
						                                        type 'text',
						                                        label editor.lang.select.opValue,
						                                        style 'width:115px',
						                                        setup : function( nameelement )
						                                        {
							                                            if ( name == 'clear' )
							                                                this.setValue"" );
							                                        }
						                                    },
					                                    {
						                                        type 'select',
						                                        id 'cmbValue',
						                                        label '',
						                                        size 5,
						                                        style 'width:115px;
						height:75px',
						                                        items [],
						                                        onChange : function()
						                                        {
							                                            var dialog this.getDialog(),
							                                                names dialog.getContentElement'info''cmbName' ),
							                                                optName dialog.getContentElement'info''txtOptName' ),
							                                                optValue dialog.getContentElement'info''txtOptValue' ),
							                                                iIndex getSelectedIndexthis );
							                                            setSelectedIndexnamesiIndex );
							                                            optName.setValuenames.getValue() );
							                                            optValue.setValuethis.getValue() );
							                                        },
						                                        setup : function( nameelement )
						                                        {
							                                            if ( name == 'clear' )
							                                                removeAllOptionsthis );
							                                            else if ( name == 'option' )
							                                            {
								                                                var oValue    element.getValue();
								                                                addOptionthisoValueoValue,
								                                                    this.getDialog().getParentEditor().document );
								                                                if ( element.getAttribute'selected' ) == 'selected' )
								                                                    this.getDialog().getContentElement'info''txtValue' ).setValueoValue );
								                                            }
							                                        }
						                                    }
					                                ]
					                            },
				                            {
					                                type 'vbox',
					                                padding 5,
					                                children :
					                                [
					                                    {
						                                        type 'button',
						                                        style '',
						                                        label editor.lang.select.btnAdd,
						                                        title editor.lang.select.btnAdd,
						                                        style 'width:100%;
						',
						                                        onClick : function()
						                                        {
							                                            //Add new option.
							                                            var dialog this.getDialog(),
							                                                parentEditor dialog.getParentEditor(),
							                                                optName dialog.getContentElement'info''txtOptName' ),
							                                                optValue dialog.getContentElement'info''txtOptValue' ),
							                                                names dialog.getContentElement'info''cmbName' ),
							                                                values dialog.getContentElement'info''cmbValue' );
							                                            addOption(namesoptName.getValue(), optName.getValue(), dialog.getParentEditor().document );
							                                            addOption(valuesoptValue.getValue(), optValue.getValue(), dialog.getParentEditor().document );
							                                            optName.setValue"" );
							                                            optValue.setValue"" );
							                                        }
						                                    },
					                                    {
						                                        type 'button',
						                                        label editor.lang.select.btnModify,
						                                        title editor.lang.select.btnModify,
						                                        style 'width:100%;
						',
						                                        onClick : function()
						                                        {
							                                            //Modify selected option.
							                                            var dialog this.getDialog(),
							                                                optName dialog.getContentElement'info''txtOptName' ),
							                                                optValue dialog.getContentElement'info''txtOptValue' ),
							                                                names dialog.getContentElement'info''cmbName' ),
							                                                values dialog.getContentElement'info''cmbValue' ),
							                                                iIndex getSelectedIndexnames );
							                                            if ( iIndex >= )
							                                            {
								                                                modifyOptionnamesiIndexoptName.getValue(), optName.getValue() );
								                                                modifyOptionvaluesiIndexoptValue.getValue(), optValue.getValue() );
								                                            }
							                                        }
						                                    },
					                                    {
						                                        type 'button',
						                                        style 'width:100%;
						',
						                                        label editor.lang.select.btnUp,
						                                        title editor.lang.select.btnUp,
						                                        onClick : function()
						                                        {
							                                            //Move up.
							                                            var dialog this.getDialog(),
							                                                names dialog.getContentElement'info''cmbName' ),
							                                                values dialog.getContentElement'info''cmbValue' );
							                                            changeOptionPositionnames, -1dialog.getParentEditor().document );
							                                            changeOptionPositionvalues, -1dialog.getParentEditor().document );
							                                        }
						                                    },
					                                    {
						                                        type 'button',
						                                        style 'width:100%;
						',
						                                        label editor.lang.select.btnDown,
						                                        title editor.lang.select.btnDown,
						                                        onClick : function()
						                                        {
							                                            //Move down.
							                                            var dialog this.getDialog(),
							                                                names dialog.getContentElement'info''cmbName' ),
							                                                values dialog.getContentElement'info''cmbValue' );
							                                            changeOptionPositionnames1dialog.getParentEditor().document );
							                                            changeOptionPositionvalues1dialog.getParentEditor().document );
							                                        }
						                                    }
					                                ]
					                            }
				                        ]
				                    },
			                    {
				                        type 'hbox',
				                        widths : [ '40%''20%''40%' ],
				                        children :
				                        [
				                            {
					                                type 'button',
					                                label editor.lang.select.btnSetValue,
					                                title editor.lang.select.btnSetValue,
					                                onClick : function()
					                                {
						                                    //Set as default value.
						                                    var dialog this.getDialog(),
						                                        values dialog.getContentElement'info''cmbValue' ),
						                                        txtValue dialog.getContentElement'info''txtValue' );
						                                    txtValue.setValuevalues.getValue() );
						                                }
					                            },
				                            {
					                                type 'button',
					                                label editor.lang.select.btnDelete,
					                                title editor.lang.select.btnDelete,
					                                onClick : function()
					                                {
						                                    // Delete option.
						                                    var dialog this.getDialog(),
						                                        names dialog.getContentElement'info''cmbName' ),
						                                        values dialog.getContentElement'info''cmbValue' ),
						                                        optName dialog.getContentElement'info''txtOptName' ),
						                                        optValue dialog.getContentElement'info''txtOptValue' );
						                                    removeSelectedOptionsnames );
						                                    removeSelectedOptionsvalues );
						                                    optName.setValue"" );
						                                    optValue.setValue"" );
						                                }
					                            },
				                            {
					                                id 'chkMulti',
					                                type 'checkbox',
					                                label editor.lang.select.chkMulti,
					                                'default' '',
					                                accessKey 'M',
					                                value "checked",
					                                setup : function( nameelement )
					                                {
						                                    if ( name == 'select' )
						                                        this.setValueelement.getAttribute'multiple' ) );
						                                    if ( CKEDITOR.env.webkit )
						                                        this.getElement().getParent().setStyle'vertical-align''middle' );
						                                },
					                                commit : function( element )
					                                {
						                                    if ( this.getValue() )
						                                        element.setAttribute'multiple'this.getValue() );
						                                    else
						                                        element.removeAttribute'multiple' );
						                                }
					                            }
				                        ]
				                    }
			                ]
			            }
		        ]
		    };
	});





PHP Demo Source Code Index