Skip to content

Commit b154b45

Browse files
author
Piotr Jasiun
committed
Merge branch 't/10689'
2 parents a7609c3 + 4a3a9dc commit b154b45

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CKEditor 4 Changelog
33

44
## CKEditor 4.2.1
55

6+
* [#10689](http://dev.ckeditor.com/ticket/10689): Save toolbar button saves only first instance.
67
* [#10368](http://dev.ckeditor.com/ticket/10368): Move language reading direction definition ("dir") from main language file to core.
78
* [#9330](http://dev.ckeditor.com/ticket/9330): Fixed pasting anchors from MS Word.
89
* [#8103](http://dev.ckeditor.com/ticket/8103): Fixed pasting nested lists from MS Word.

core/editor.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,22 +677,34 @@
677677

678678
// #8031 If textarea had required attribute and editor is empty fire 'required' event and if
679679
// 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.
681684
evt.data.preventDefault();
685+
}
682686
}
683687
form.on( 'submit', onSubmit );
684688

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.
688700
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();
691703

692704
// For IE, the DOM submit function is not a
693705
// function, so we need third check.
694706
if ( originalSubmit.apply )
695-
originalSubmit.apply( this, arguments );
707+
originalSubmit.apply( this );
696708
else
697709
originalSubmit();
698710
};

0 commit comments

Comments
 (0)