Skip to content
Permalink
Browse files

Merge branch 't/8031' into major

  • Loading branch information
Reinmar committed Jul 8, 2013
2 parents f9bbe1b + 38b74ba commit 385a822e654665c4e7adf959a3288dd84e530e10
Showing with 42 additions and 7 deletions.
  1. +42 −7 core/creators/themedui.js
@@ -245,11 +245,16 @@ CKEDITOR.replaceClass = 'ckeditor';
// Create the editor instance.
var editor = new CKEDITOR.editor( config, element, mode );

// Do not replace the textarea right now, just hide it. The effective
// replacement will be done later in the editor creation lifecycle.
if ( mode == CKEDITOR.ELEMENT_MODE_REPLACE )
if ( mode == CKEDITOR.ELEMENT_MODE_REPLACE ) {
// Do not replace the textarea right now, just hide it. The effective
// replacement will be done later in the editor creation lifecycle.
element.setStyle( 'visibility', 'hidden' );

// #8031 Remember if textarea was required and remove the attribute.
editor._.required = element.hasAttribute( 'required' );
element.removeAttribute( 'required' );
}

data && editor.setData( data, null, true );

// Once the editor is loaded, start the UI.
@@ -286,7 +291,11 @@ CKEDITOR.replaceClass = 'ckeditor';

if ( element ) {
element.clearCustomData();
editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.show();
if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) {
element.show();
if ( editor._.required )
element.setAttribute( 'required', 'required' );
}
delete editor.element;
}
}
@@ -370,17 +379,22 @@ CKEDITOR.replaceClass = 'ckeditor';
if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.is( 'textarea' ) ) {
var form = element.$.form && new CKEDITOR.dom.element( element.$.form );
if ( form ) {
function onSubmit() {
function onSubmit( evt ) {
editor.updateElement();

// #8031 If textarea had required attribute and editor is empty fire 'required' event and if
// it was cancelled, prevent submitting the form.
if ( editor._.required && !element.getValue() && editor.fire( 'required' ) === false )
evt.data.preventDefault();
}
form.on( 'submit', onSubmit );

// Setup the submit function because it doesn't fire the
// "submit" event.
if ( !form.$.submit.nodeName && !form.$.submit.length ) {
form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit ) {
return function() {
editor.updateElement();
return function( evt ) {
onSubmit( new CKEDITOR.dom.event( evt ) );

// For IE, the DOM submit function is not a
// function, so we need third check.
@@ -432,13 +446,15 @@ CKEDITOR.config.startupMode = 'wysiwyg';
* the {@link CKEDITOR.editor#method-resize} method.
*
* @event resize
* @param {CKEDITOR.editor} editor This editor instance.
*/

/**
* Event fired before changing the editing mode. See also
* {@link #beforeSetMode} and {@link #event-mode}.
*
* @event beforeModeUnload
* @param {CKEDITOR.editor} editor This editor instance.
*/

/**
@@ -447,11 +463,30 @@ CKEDITOR.config.startupMode = 'wysiwyg';
*
* @since 3.5.3
* @event beforeSetMode
* @param {CKEDITOR.editor} editor This editor instance.
* @param {String} data The name of the mode which is about to be set.
*/

/**
* Fired after setting the editing mode. See also {@link #beforeSetMode} and {@link #beforeModeUnload}
*
* @event mode
* @param {CKEDITOR.editor} editor This editor instance.
*/

/**
* Fired when editor (replacing textarea which has a `required` attribute) is empty during form submitting.
*
* This event replaces native required fields validation which browsers cannot
* perform when CKEditor replaces `textarea` elements.
*
* You can cancel this event to prevent from submitting data.
*
* editor.on( 'required', function( evt ) {
* alert( 'Article content is required.' );
* evt.cancel();
* } );
*
* @event required
* @param {CKEDITOR.editor} editor This editor instance.
*/

0 comments on commit 385a822

Please sign in to comment.
You can’t perform that action at this time.