Ticket #8331 (confirmed New Feature)

Opened 3 years ago

Last modified 14 months ago

Ability to ignore "Confirm Cancel"-warning on dialogs

Reported by: Helmø 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

comment:1 Changed 3 years ago by Helmø

  • Type changed from Bug to New Feature

comment:2 Changed 3 years ago by j.swiderski

  • Status changed from new to confirmed
  • Keywords HasPatch added

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 14 months ago by inghamc

  • 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

Last edited 14 months ago by inghamc (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy