[wp-trac] [WordPress Trac] #9161: edInsertContent doesn't remember scrollTop property

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 18 04:56:58 GMT 2009


#9161: edInsertContent doesn't remember scrollTop property
--------------------------+-------------------------------------------------
 Reporter:  gmpfree       |       Owner:  azaozz
     Type:  defect (bug)  |      Status:  new   
 Priority:  normal        |   Milestone:  2.7.2 
Component:  JavaScript    |     Version:        
 Severity:  trivial       |    Keywords:        
--------------------------+-------------------------------------------------
 in wp-includes/js/quicktags.js

 original:

 {{{
 function edInsertContent(myField, myValue) {
         //IE support
         if (document.selection) {
                 myField.focus();
                 sel = document.selection.createRange();
                 sel.text = myValue;
                 myField.focus();
         }
         //MOZILLA/NETSCAPE support
         else if (myField.selectionStart || myField.selectionStart == '0')
 {
                 var startPos = myField.selectionStart;
                 var endPos = myField.selectionEnd;
                 myField.value = myField.value.substring(0, startPos)
                               + myValue
                       + myField.value.substring(endPos,
 myField.value.length);
                 myField.focus();
                 myField.selectionStart = startPos + myValue.length;
                 myField.selectionEnd = startPos + myValue.length;
         } else {
                 myField.value += myValue;
                 myField.focus();
         }
 }
 }}}

 fixed:

 {{{
 function edInsertContent(myField, myValue) {
         //IE support
         if (document.selection) {
                 myField.focus();
                 sel = document.selection.createRange();
                 sel.text = myValue;
                 myField.focus();
         }
         //MOZILLA/NETSCAPE support
         else if (myField.selectionStart || myField.selectionStart == '0')
 {
                 var startPos = myField.selectionStart;
                 var endPos = myField.selectionEnd;
                 '''var scrollTop = myField.scrollTop;'''

                 myField.value = myField.value.substring(0, startPos)
                               + myValue
                       + myField.value.substring(endPos,
 myField.value.length);

                 myField.focus();
                 myField.selectionStart = startPos + myValue.length;
                 myField.selectionEnd = startPos + myValue.length;
                 '''myField.scrollTop = scrollTop;'''
         } else {
                 myField.value += myValue;
                 myField.focus();
         }
 }
 }}}

 now insert image(via quicktag or upload manager) in plaintxt mode won't
 reset textarea scroll.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9161>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list