Ticket #6589: 6589.patch

File 6589.patch, 2.5 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Proposed patch

  • _source/plugins/iframedialog/plugin.js

     
    1212        requires : [ 'dialog' ],
    1313        onLoad : function()
    1414        {
    15                 CKEDITOR.dialog.addIframe = function( name, title, src, width, height, onContentLoad )
     15                /**
     16                 * An iframe base dialog.
     17                 * @param {String} name Name of the dialog
     18                 * @param {String} title Title of the dialog
     19                 * @param {Number} width Width of the dialog
     20                 * @param {Number} height Height of the dialog
     21                 * @param {Function} [onContentLoad] Function called when the iframe has been loaded.
     22                 * If it isn't specified, the inner frame is notified of the dialog events ('load', 'ok' and 'cancel')
     23                 * on a function called 'onDialogEvent'
     24                 * @param {Object} [userDefinition] Additional properties for the dialog definition
     25                 * @example
     26                 */
     27                CKEDITOR.dialog.addIframe = function( name, title, src, width, height, onContentLoad, userDefinition )
    1628                {
    1729                        var element =
    1830                        {
     
    2436
    2537                        if ( typeof( onContentLoad ) == 'function' )
    2638                                element.onContentLoad = onContentLoad;
     39                        else
     40                                element.onContentLoad = function()
     41                                {
     42                                        var element = this.getElement(),
     43                                                childWindow = element.$.contentWindow;
    2744
     45                                        // If the inner frame has defined a "onDialogEvent" function, setup listeners
     46                                        if ( childWindow.onDialogEvent )
     47                                        {
     48                                                var dialog = this.getDialog(),
     49                                                        notifyEvent = function(e)
     50                                                        {
     51                                                                return childWindow.onDialogEvent(e);
     52                                                        };
     53
     54                                                dialog.on( 'ok', notifyEvent );
     55                                                dialog.on( 'cancel', notifyEvent );
     56
     57                                                // Clear listeners
     58                                                dialog.on( 'hide', function(e)
     59                                                        {
     60                                                                dialog.removeListener( 'ok', notifyEvent );
     61                                                                dialog.removeListener( 'cancel', notifyEvent );
     62
     63                                                                e.removeListener();
     64                                                        } );
     65
     66                                                // Notify child iframe of load:
     67                                                childWindow.onDialogEvent( {
     68                                                                name : 'load',
     69                                                                sender : this,
     70                                                                editor : dialog._.editor
     71                                                        } );
     72                                        }
     73                                };
     74
    2875                        var definition =
    2976                        {
    3077                                title : title,
     
    4188                                ]
    4289                        };
    4390
    44                         return this.add( name, function(){ return definition; } );
     91                        for ( var i in userDefinition )
     92                                definition[i] = userDefinition[i];
     93
     94                        this.add( name, function(){ return definition; } );
    4595                };
    4696
    4797                (function()
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy