gbusman
gbusman

Reputation: 167

CKEditor 3 Dialog Positioning

I have checked and tried the method posted here to set where CKEditor dialogs pop up:

Programatically set the position of CKEditor's dialogs

This seems to either be deprecated or incomplete. When attempting this for the 'link' dialog, the dialog box does not format correctly, as if this onShow definition replaces the default action rather than adding to it. Any suggestions to alter this code or a new method to position the link dialog closer to the menu bar?

CKEDITOR.on('dialogDefinition', function(e) {
   var dialogDefinition = e.data.definition;

   dialogDefinition.onShow = function() {
       this.move(200, 100);
   }
})

Upvotes: 4

Views: 925

Answers (1)

oleq
oleq

Reputation: 15895

You're right. Your code is overwriting the basic onShow definition.

What you have to do is simply to save a default (generic) onShow, then overwrite it so it calls the saved one and eventually executes your code:

CKEDITOR.on( 'dialogDefinition', function( event ) {
    var dialogDefinition = event.data.definition,
        genericOnShow = dialogDefinition.onShow;

    dialogDefinition.onShow = function() {
        genericOnShow.apply( this );
        this.move( 10, 10 );
        // ...or anything you want ;)
    }
});

Voilà!

PS. Remember to always pass the context with apply or call.

Upvotes: 4

Related Questions