|
677 | 677 |
|
678 | 678 | // #8031 If textarea had required attribute and editor is empty fire 'required' event and if
|
679 | 679 | // it was cancelled, prevent submitting the form.
|
680 |
| - if ( editor._.required && !element.getValue() && editor.fire( 'required' ) === false ) |
| 680 | + if ( editor._.required && !element.getValue() && editor.fire( 'required' ) === false ) { |
| 681 | + // When user press save button event (evt) is undefined (see save plugin). |
| 682 | + // This method works because it throws error so originalSubmit won't be called. |
| 683 | + // Also this error won't be shown because it will be caught in save plugin. |
681 | 684 | evt.data.preventDefault();
|
| 685 | + } |
682 | 686 | }
|
683 | 687 | form.on( 'submit', onSubmit );
|
684 | 688 |
|
685 |
| - // Setup the submit function because it doesn't fire the |
686 |
| - // "submit" event. |
687 |
| - if ( !form.$.submit.nodeName && !form.$.submit.length ) { |
| 689 | + function isFunction( f ) { |
| 690 | + // For IE8 typeof fun == object so we cannot use it. |
| 691 | + return !!( f && f.call && f.apply ); |
| 692 | + }; |
| 693 | + |
| 694 | + // Check if there is no element/elements input with name == "submit". |
| 695 | + // If they exists they will overwrite form submit function (form.$.submit). |
| 696 | + // If form.$.submit is overwritten we can not do anything with it. |
| 697 | + if ( isFunction( form.$.submit ) ) { |
| 698 | + // Setup the submit function because it doesn't fire the |
| 699 | + // "submit" event. |
688 | 700 | form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit ) {
|
689 |
| - return function( evt ) { |
690 |
| - onSubmit( new CKEDITOR.dom.event( evt ) ); |
| 701 | + return function() { |
| 702 | + onSubmit(); |
691 | 703 |
|
692 | 704 | // For IE, the DOM submit function is not a
|
693 | 705 | // function, so we need third check.
|
694 | 706 | if ( originalSubmit.apply )
|
695 |
| - originalSubmit.apply( this, arguments ); |
| 707 | + originalSubmit.apply( this ); |
696 | 708 | else
|
697 | 709 | originalSubmit();
|
698 | 710 | };
|
|
0 commit comments