Ticket #2803: 2803_2.patch

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

     
    469469                        // Execute onLoad for the first show.
    470470                        this.fireOnce( 'load', {} );
    471471                        this.fire( 'show', {} );
     472
     473                        // Save the initial values of the dialog.
     474                        this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } );
    472475                },
    473476
    474477                /**
     
    498501                        return function(){ this.foreach( fn ); return this; };
    499502                })(),
    500503
    501                 /**
    502                  * Pushes the current values of all inputs in the dialog into the default stack.
    503                  * @example
    504                  * dialogObj.pushDefault();
    505                  * @returns {CKEDITOR.dialog} The current dialog object.
    506                  */
    507                 pushDefault : (function()
    508                 {
    509                         var fn = function( widget ){ if ( widget.pushDefault ) widget.pushDefault(); };
    510                         return function(){ this.foreach( fn ); return this; };
    511                 })(),
    512 
    513                 /**
    514                  * Pops the current default values of all inputs in the dialog.
    515                  * @example
    516                  * dialogObj.popDefault();
    517                  * @returns {CKEDITOR.dialog} The current dialog object.
    518                  */
    519                 popDefault : (function()
    520                 {
    521                         var fn = function( widget ){ if ( widget.popDefault ) widget.popDefault(); };
    522                         return function(){ this.foreach( fn ); return this; };
    523                 })(),
    524 
    525504                setupContent : function()
    526505                {
    527506                        var args = arguments;
     
    585564                                CKEDITOR.dialog._.currentZIndex -= 10;
    586565
    587566                        this.fire( 'hide', {} );
     567
     568                        // Reset the initial values of the dialog.
     569                        this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } );
    588570                },
    589571
    590572                /**
  • _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 );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy