Ticket #2803: 2803.patch

File 2803.patch, 7.9 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/dialog/plugin.js

     
    441441                // Execute onLoad for the first show.
    442442                this.fireOnce( 'load', {} );
    443443                this.fire( 'show', {} );
     444
     445                // Save the initial values of the dialog.
     446                this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
    444447        },
    445448
    446449        /**
     
    469472        })(),
    470473
    471474        /**
    472          * Pushes the current values of all inputs in the dialog into the default stack.
    473          * @example
    474          * dialogObj.pushDefault();
    475          * @returns {CKEDITOR.dialog} The current dialog object.
    476          */
    477         pushDefault : (function()
    478         {
    479                 var fn = function( widget ){ if ( widget.pushDefault ) widget.pushDefault(); };
    480                 return function(){ this.foreach( fn ); return this; };
    481         })(),
    482 
    483         /**
    484          * Pops the current default values of all inputs in the dialog.
    485          * @example
    486          * dialogObj.popDefault();
    487          * @returns {CKEDITOR.dialog} The current dialog object.
    488          */
    489         popDefault : (function()
    490         {
    491                 var fn = function( widget ){ if ( widget.popDefault ) widget.popDefault(); };
    492                 return function(){ this.foreach( fn ); return this; };
    493         })(),
    494 
    495         /**
    496475         * Hides the dialog box.
    497476         * @example
    498477         * dialogObj.hide();
     
    535514                        CKEDITOR.dialog._.currentZIndex -= 10;
    536515
    537516                this.fire( 'hide', {} );
     517
     518                // Reset the initial values of the dialog.
     519                this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } );
    538520        },
    539521
    540522        /**
  • _source/plugins/dialogui/plugin.js

     
    1212        var initPrivateObject = function( elementDefinition )
    1313        {
    1414                this._ || ( this._ = {} );
    15                 this._['default'] = [ elementDefinition['default'] || '' ];
     15                this._['default'] = this._.initValue = elementDefinition['default'] || '' ;
    1616                var args = [ this._ ];
    1717                for ( var i = 1 ; i < arguments.length ; i++ )
    1818                        args.push( arguments[i] );
     
    3838        {
    3939                isChanged : function()
    4040                {
    41                         return this.getValue() != this.getDefault();
     41                        return this.getValue() != this.getInitValue();
    4242                },
    4343
    4444                reset : function()
    4545                {
    46                         this.setValue( this.getDefault() );
     46                        this.setValue( this.getInitValue() );
    4747                },
    4848
    49                 getDefault : function()
     49                setInitValue : function()
    5050                {
    51                         var defs = this._['default'];
    52                         return defs[ defs.length - 1 ];
     51                        this._.initValue = this.getValue();
    5352                },
    5453
    55                 pushDefault : function()
     54                resetInitValue : function()
    5655                {
    57                         this._['default'].push( this.getValue() );
     56                        this._.initValue = this._['default'];
    5857                },
    5958
    60                 popDefault : function()
     59                getInitValue : function()
    6160                {
    62                         this._['default'].pop();
     61                        return this._.initValue;
    6362                }
    6463        },
    6564        commonEventProcessors = CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
     
    276275                                        var html = [ '<div class="cke_dialog_ui_input_textarea"><textarea class="cke_dialog_ui_input_textarea" id="', domId, '" ' ];
    277276                                        for ( var i in attributes )
    278277                                                html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" ' );
    279                                         html.push( '>', CKEDITOR.tools.htmlEncode( me.getDefault() ), '</textarea></div>' );
     278                                        html.push( '>', CKEDITOR.tools.htmlEncode( me._['default'] ), '</textarea></div>' );
    280279                                        return html.join( '' );
    281280                                }
    282281                                CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
     
    356355                                        return;
    357356
    358357                                initPrivateObject.call( this, elementDefinition );
    359                                 if ( this.getDefault() == '' )
    360                                         this._['default'] = [ elementDefinition.items[0][1] ] ;
     358                                if ( this._['default'] == '' )
     359                                        this._['default'] = this._.initValue = elementDefinition.items[0][1] ;
    361360                                if ( elementDefinition.validate )
    362361                                        this.validate = elementDefinition.valdiate;
    363362                                var children = [], me = this;
     
    392391                                                                name : commonName,
    393392                                                                value : value
    394393                                                        };
    395                                                 if ( me.getDefault() == value )
     394                                                if ( me._['default'] == value )
    396395                                                        inputAttributes.checked = 'checked';
    397396                                                cleanInnerDefinition( inputDefinition );
    398397                                                cleanInnerDefinition( labelDefinition );
  • _source/plugins/flash/dialogs/flash.js

     
    298298
    299299                        // Don't call onChange before onShow.
    300300                        this.allowOnChange = false;
    301 
    302                         // Pop the default values from default value set that are pushed in onShow().
    303                         this.popDefault();
    304301                },
    305302                onShow : function()
    306303                {
     
    358355                        updatePreview( this );
    359356
    360357                        this.allowOnChange = true;
    361                         this.pushDefault();
    362358                        this.getContentElement( 'info', 'txtUrl' ).focus();
    363359                },
    364360                onOk : function()
  • _source/plugins/forms/dialogs/select.js

     
    101101                                this.editObj = this.getParentEditor().document.createElement( 'select' );
    102102                        }
    103103
    104                         this.pushDefault();
    105104                        this.getContentElement( 'info', 'txtName' ).focus();
    106105                },
    107106                onOk : function()
  • _source/plugins/image/dialogs/image.js

     
    618618                        }
    619619
    620620                        this.allowOnChange = true;
    621                         this.pushDefault();
    622621                        this.getContentElement( 'info', 'txtUrl' ).focus();
    623622                },
    624623                onLoad : function()
     
    688687
    689688                        // Don't call onChange before onShow.
    690689                        this.allowOnChange = false;
    691 
    692                         // Pop the default values from default value set that are pushed in onShow().
    693                         this.popDefault();
    694690                },
    695691                contents : [
    696692                        {
  • _source/plugins/link/dialogs/anchor.js

     
    7474                                        this.saveSelection();
    7575                                }
    7676                        }
    77                         this.pushDefault();
    7877                        this.getContentElement( 'info', 'txtName' ).focus();
    7978                },
    8079                onHide : function()
    8180                {
    82                         // Pop the default values from default value set that are pushed in onShow().
    83                         this.popDefault();
    8481                },
    8582                contents : [
    8683                        {
  • _source/plugins/link/dialogs/link.js

     
    710710                                }
    711711                        }
    712712
    713                         // Push the current values into the dialog default value stack.
    714                         this.pushDefault();
    715 
    716713                        // Put focus into the first most likely used input.
    717714                        var linkType = this.getValueOf( 'info', 'linkType' );
    718715                        if ( linkType == 'url' )
     
    862859                },
    863860                onHide : function()
    864861                {
    865                         // Pop the default values from default value set that are pushed in onShow().
    866                         this.popDefault();
    867862                }
    868863        };
    869864} );
  • _source/plugins/table/dialogs/table.js

     
    6969
    7070                                // Save a reference to the selected table, and push a new set of default values.
    7171                                this._.selectedElement = selectedTable;
    72                                 this.pushDefault();
    7372                        }
    7473                        else
    7574                        {
     
    8382                },
    8483                onHide : function()
    8584                {
    86                         if ( this._.selectedElement )
    87                                 this.popDefault();
    8885                },
    8986                onOk : function()
    9087                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy