Ticket #5854: 5854.patch

File 5854.patch, 2.0 KB (added by WebSpellChecker.net, 14 years ago)
  • _source/plugins/scayt/plugin.js

     
    2727                }
    2828                return found;
    2929        }
    30 
     30       
     31        function removeClass(o, c) {
     32                var re = new RegExp("(^|\\s)" + c + "(\\s|$)", "g")
     33                o.className = o.className.replace(re, "$1").replace(/\s+/g, " ").replace(/(^ | $)/g, "")
     34        }
     35       
    3136        var onEngineLoad = function()
    3237        {
    3338                var editor = this;
     
    147152                                // Catch on source mode switch off (#5720)
    148153                                else if ( ev.data.name == 'source'  && editor.mode == 'source' )
    149154                                        plugin.markControlRestore( editor );
     155                               
     156                                // Remove SCAYT classes from the body tag on save operation (#5854)
     157                                else if ( ev.data.name == 'save' ) {
     158                                        var scayt = window.scayt;
     159                                        var containerNode;
     160                                        for (var i=0; i<scayt._hash.length; i++) {
     161                                                containerNode = scayt._hash[i].containerNode;
     162                                                if ( typeof containerNode != 'undefined' ) {
     163                                                        removeClass( containerNode, 'scayt-enabled' );
     164                                                        removeClass( containerNode, 'scayt-disabled' );
     165                                                }
     166                                        }
     167                                }
    150168                        });
    151169
    152170                editor.on( 'afterCommandExec', function( ev )
     
    232250                                ev.data.tab = openPage;
    233251                                ev.data.scayt = window.scayt;
    234252                        });
    235 
     253               
     254                // Remove SCAYT classes from the body tag on submit event
     255                var element = editor.element;
     256                if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.is( 'textarea' ) ) {
     257                        var form = element.$.form && new CKEDITOR.dom.element( element.$.form );
     258                        if ( form )
     259                        {
     260                                form.on( 'submit', function (evt) {
     261                                        var scayt_instance = plugin.getScayt( editor );
     262                                        removeClass(scayt_instance.containerNode, 'scayt-disabled');
     263                                        removeClass(scayt_instance.containerNode, 'scayt-enabled');
     264                                        editor.updateElement();
     265                                });
     266                        }
     267                }
     268               
    236269                var dataProcessor = editor.dataProcessor,
    237270                        htmlFilter = dataProcessor && dataProcessor.htmlFilter;
    238271
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy