Opened 13 years ago

Last modified 11 years ago

#8331 confirmed New Feature

Ability to ignore "Confirm Cancel"-warning on dialogs

Reported by: Henrik Helmø Larsen Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: HasPatch Cc: chris.ingham@…

Description

If changes have been made to a dialog and the cancel button is pressed an annoying "Confirm Cancel" warning is displayed. It would be nice to toggle weather you want this warning or not.

The new "on cancel event" on the dialog will look like:

this.on( 'cancel', function( evt ) {
  if (!editor.config.ignoreConfirmCancel)
    iterContents( function( item ) {
      if ( item.isChanged() ) {
        if ( !confirm( editor.lang.common.confirmCancel ) )
          evt.data.hide = false;
        return true;
      }
    });
}, this, null, 0 );

The only line added is:

if (!editor.config.ignoreConfirmCancel)

which is in line 323 of the plugin.js in the dialog folder. This is just before the iterContents( function( item )... is called - thus ignoring this check if the ignoreConfirmCancel is set in the editors config.

In order to toggle the warning add the following line to the editors config:

config.ignoreConfirmCancel = true;

Change History (3)

comment:1 Changed 13 years ago by Henrik Helmø Larsen

Type: BugNew Feature

comment:2 Changed 13 years ago by Jakub Ś

Keywords: HasPatch added
Status: newconfirmed

IMO it can be annoying after some time of working with dialogs, so the option to choose whether you want these confirmations or not is a very good idea (at least for me).

comment:3 Changed 11 years ago by Chris Ingham

Cc: chris.ingham@… added

Until this ticket is resolved, the following works for me (as of version 4.0.1.1):

CKEDITOR.on('dialogDefinition', function(dialogDefinitionEvent) {
//if ('link' == dialogDefinitionEvent.data.name) {
      var dialogDefinition = dialogDefinitionEvent.data.definition;
      // Get rid of annoying confirmation dialog on cancel
      dialogDefinition.dialog.on('cancel', function(cancelEvent) {
          return false;
      }, this, null, -1);
    //}
});

The commented if statement that would limit the confirmation removal to just the link dialog.

The -1 argument sneakily* inserts this cancel handler before the dialog plugin's default handler, which will never be invoked by returning false.

*thanks to alfonsoml for his 2009 blog post

Version 1, edited 11 years ago by Chris Ingham (previous) (next) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy