Changeset 1370 for trunk


Ignore:
Timestamp:
02/06/18 05:17:18 (19 months ago)
Author:
gogo
Message:

#1578 Fixes for ColorPicker? positioning with regard to scrolling in Standards, Quirks and Almost Standards. Add a developer warning if the Xinha is in a scrolled div which isn't positioned (bad idea).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/ColorPicker/ColorPicker.js

    r1237 r1370  
    366366      var top  = 0; 
    367367      var left = 0; 
     368       
     369      // Check for overflow:scroll elements which do not have position:relative 
     370      while(e.parentNode) 
     371      { 
     372        e = e.parentNode; 
     373        if(typeof e.tagName != 'undefined' && !e.tagName.toLowerCase().match(/body|html/)) 
     374        { 
     375          if( ( e.scrollTop || e.scrollLeft ) && !e.style.position.match(/fixed|absolute|relative/)) 
     376          { 
     377            Xinha.debugMsg('Warning, the Xinha editor is included in a '+e.tagName+' which has scroll (overflow) but is not positioned relative, absolute, or fixed.  The ColorPicker plugin may not display in the correct location.', 'warn'); 
     378          } 
     379        } 
     380      } 
     381      e = element; 
     382       
    368383      do 
    369384      { 
     
    372387          this.table.style.position = 'fixed'; 
    373388        } 
    374         top += e.offsetTop - e.scrollTop; 
    375         left += e.offsetLeft - e.scrollLeft; 
    376  
     389         
     390        if(e.tagName.toLowerCase() == 'body') 
     391        { 
     392                              // I don't think we need adjust for scroll at all on body 
     393                              // In standards these would be 0 for the body (vs document.documentElement.scrollTop/Left) 
     394                              // in quirks they are not, and it doesn't work in quirks with them. 
     395          top += e.offsetTop;  // - e.scrollTop; 
     396          left += e.offsetLeft;// - e.scrollLeft; 
     397        } 
     398        else 
     399        { 
     400          // Caution, unless an element is positioned (position: fixed/relative/absolute)  
     401          // then it will not be considered because it is not an offsetParent 
     402          // so if you haev an overflow:scroll; div containing your Xinha, then you 
     403          // must set position:relative;  (or other position) on it in order to get it  
     404          // to be considered. 
     405          top += e.offsetTop - e.scrollTop; 
     406          left += e.offsetLeft - e.scrollLeft; 
     407        } 
     408         
    377409        e = e.offsetParent; 
    378410      } 
Note: See TracChangeset for help on using the changeset viewer.