From eaae7c3ef2e403f65b79f67707fb6200175b7916 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Tue, 19 May 2009 18:46:21 +0200 Subject: [PATCH] [svn r20842] FS#2867 - The FCKEditor: Making the "Save" command/button to be compatible with the new "nice buttons" in Dokeos forms. This is necessary when the command "Save" scans the form to identify submit-type button and to "click" it. Previously, a problem was noticed in Wiki and forums (probably it existed in other places too). When "Save" button from the editor was clicked, the updated editor's content was not saved. --- .../plugins/customizations/fckplugin.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin.js b/main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin.js index 2428270b4f..cdcadfbaac 100644 --- a/main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin.js +++ b/main/inc/lib/fckeditor/editor/plugins/customizations/fckplugin.js @@ -556,6 +556,51 @@ FCKToolbarItems.GetItem = function( itemName ) } +// A modification of the "Save" command in order "nice buttons" in Dokeos +// forms to be supported (to be "clicked" when this command executes). +FCKSaveCommand.prototype.Execute = function() +{ + // Get the linked field form. + var oForm = FCK.GetParentForm() ; + + if ( typeof( oForm.onsubmit ) == 'function' ) + { + var bRet = oForm.onsubmit() ; + if ( bRet != null && bRet === false ) + return ; + } + + // Next, we will try to scan all styled buttons within the form and to find + // the button that means "Save", "Ok" "Submit", or something similar. + // The way of searching may be not accurate enough, it will be made more + // precise if problems are reported. + for ( var i = 0 ; i < oForm.elements.length ; i++) + { + if ( oForm.elements[i].type == 'submit' ) + { + // Let us check whether the buton is styled, i.e. whether it is "nice". + if ( oForm.elements[i].getAttribute( 'class' ) ) + { + try + { + // "Clicking" the found button. + oForm.elements[i].click() ; + } catch ( ex ) { } + return ; + } + } + } + + // An attempt for submitting the form that has no proper styled button detected. + // If there's a button named "submit" then the form.submit() function is masked and + // can't be called in Mozilla, so we call the click() method of that button. + if ( typeof( oForm.submit ) == 'function' ) + oForm.submit() ; + else + oForm.submit.click() ; +} + + /* ************************************************************************************** * Dialog system