Ticket #3279: 3279.patch

File 3279.patch, 1.6 KB (added by Artur Formella, 15 years ago)
  • _source/plugins/save/plugin.js

     
    1313        {
    1414                modes : { wysiwyg:1, source:1 },
    1515
     16                getForm : function( element )           // Find the form element.
     17                {
     18                        var form = element.$.form;
     19
     20                        if ( form )
     21                                return form;
     22
     23                        while ( element = element.getParent() )
     24                        {
     25                                if ( element.getName() == 'form' )
     26                                        return element.$;
     27                        };
     28
     29                        return null;
     30                },
     31
    1632                exec : function( editor )
    1733                {
    18                         var $form = editor.element.$.form;
     34                        // Get the form element.
     35                        var form = this.getForm( editor.element );
    1936
    20                         if ( $form )
     37                        if ( form )
    2138                        {
    2239                                try
    2340                                {
    24                                         $form.submit();
     41                                        form.submit();
    2542                                }
    2643                                catch( e )
    2744                                {
    2845                                        // If there's a button named "submit" then the form.submit
    2946                                        // function is masked and can't be called in IE/FF, so we
    3047                                        // call the click() method of that button.
    31                                         if ( $form.submit.click )
    32                                                 $form.submit.click();
     48                                        if ( form.submit.click )
     49                                                form.submit.click();
    3350                                }
    3451                        }
    3552                }
     
    4259        {
    4360                init : function( editor )
    4461                {
    45                         var command = editor.addCommand( pluginName, saveCmd );
    46                         command.modes = { wysiwyg : !!( editor.element.$.form ) };
     62                        var command = editor.addCommand( pluginName, saveCmd ),
     63                                formExists = !!saveCmd.getForm( editor.element );
    4764
     65                        command.modes = { wysiwyg : formExists, source : formExists };
     66
    4867                        editor.ui.addButton( 'Save',
    4968                                {
    5069                                        label : editor.lang.save,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy