Ticket #7946: 7946.patch

File 7946.patch, 2.4 KB (added by Teresa Monahan, 12 years ago)

Potential fix for this issue

  • element.js

     
    14011401                        // Get the element window.
    14021402                        var win = this.getWindow(),
    14031403                                winHeight = win.getViewPaneSize().height;
     1404                               
     1405                        // Get the browser window.
     1406                        var browserWindow = new CKEDITOR.dom.window (window),
     1407                                browserWinHeight = browserWindow.getViewPaneSize().height;
     1408                               
     1409                        // Get the editor document
     1410                        var editorDocument = this.getDocument();
     1411                       
     1412                        //Find the current instance of the editor  - is there an easier way to get the current editor instance?
     1413                        var ckInstances = CKEDITOR.instances;
     1414                        var currentInstance;
     1415                        for (var i in ckInstances){
     1416                                if (ckInstances[i].document.equals(editorDocument)){
     1417                                        currentInstance = i;
     1418                                        break;
     1419                                }                               
     1420                        }
     1421                       
     1422                        //find the iframe element of the current instance and gets it's document position i.e. the position of the iframe in the HTML page - is there a better way to get the iframe element?
     1423                        var iframePosition = ckInstances[currentInstance].container.getElementsByTag('iframe').getItem(0).getDocumentPosition();
    14041424
    14051425                        // Starts from the offset that will be scrolled with the negative value of
    14061426                        // the visible window height.
     
    14221442                        // Append the offsets for the entire element hierarchy.
    14231443                        var elementPosition = this.getDocumentPosition();
    14241444                        offset += elementPosition.y;
    1425 
    1426                         // offset value might be out of range(nagative), fix it(#3692).
    1427                         offset = offset < 0 ? 0 : offset;
    1428 
     1445                       
    14291446                        // Scroll the window to the desired position, if not already visible(#3795).
    14301447                        var currentScroll = win.getScrollPosition().y;
    14311448                        if ( offset > currentScroll || offset < currentScroll - winHeight )
    1432                                 win.$.scrollTo( 0, offset );
     1449                                win.$.scrollTo( 0, offset > 0 ? offset : 0  );  // offset value might be out of range(nagative), fix it(#3692).
     1450                       
     1451                       
     1452                        // Scroll the browser window to the desired position, if not already visible
     1453                        var browserOffset = iframePosition.y + (elementPosition.y - win.getScrollPosition().y);                 
     1454                        var currentBrowserScroll = browserWindow.getScrollPosition().y;
     1455                        if (browserOffset < currentBrowserScroll || browserOffset > (currentBrowserScroll + browserWinHeight))
     1456                                browserWindow.$.scrollTo( 0, browserOffset);                   
     1457                       
    14331458                },
    14341459
    14351460                setState : function( state )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy