Ticket #7266: 7266.patch

File 7266.patch, 2.0 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/dialog/plugin.js

     
    9393                }
    9494        }
    9595
     96        // Handle dialog element validation state UI changes.
     97        function handleFieldValidated( isValid, msg )
     98        {
     99                var input = this.getInputElement();
     100                if ( input )
     101                {
     102                        isValid ? input.removeAttribute( 'aria-invalid' )
     103                                : input.setAttribute( 'aria-invalid', true );
     104                }
     105
     106                this.fire( 'validated', { valid : isValid, msg : msg } );
     107        }
     108
     109        function resetField()
     110        {
     111                var input = this.getInputElement();
     112                input.removeAttribute( 'aria-invalid' );
     113        }
     114
     115
    96116        /**
    97117         * This is the base class for runtime dialog objects. An instance of this
    98118         * class represents a single named dialog for a single editor instance.
     
    273293                                        {
    274294                                                if ( item.validate )
    275295                                                {
    276                                                         var isValid = item.validate( this );
     296                                                        var retval = item.validate( this ),
     297                                                                isValid = retval === true ;
    277298
    278                                                         if ( typeof isValid == 'string' )
     299                                                        if ( !isValid )
    279300                                                        {
    280                                                                 alert( isValid );
    281                                                                 isValid = false;
    282                                                         }
    283 
    284                                                         if ( isValid === false )
    285                                                         {
    286301                                                                if ( item.select )
    287302                                                                        item.select();
    288303                                                                else
     
    290305
    291306                                                                evt.data.hide = false;
    292307                                                                evt.stop();
    293                                                                 return true;
    294308                                                        }
     309
     310                                                        handleFieldValidated.call( item, isValid, typeof retval == 'string' ? retval : undefined );
     311                                                        return  !isValid;
    295312                                                }
    296313                                        });
    297314                        }, this, null, 0 );
     
    454471                                dialogElement.removeListener( 'keydown', focusKeydownHandler );
    455472                                if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
    456473                                        dialogElement.removeListener( 'keypress', focusKeyPressHandler );
     474
     475                                // Reset fields state when closing dialog.
     476                                iterContents( function( item ) { resetField.apply( item ); } );
    457477                        } );
    458478                this.on( 'iframeAdded', function( evt )
    459479                        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy