Changeset 2294

Show
Ignore:
Timestamp:
06/12/07 17:03:32 (1 year ago)
Author:
eblot
Message:

RevtreePlugin:

Improve compatibility with several browsers:

  • Do not use jQuery to build changeset info tips (issue w/ XML doc type)
  • Code clean up
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • revtreeplugin/0.11/revtree/htdocs/css/revtree.css

    r2280 r2294  
    7777#JT { 
    7878 position: absolute; 
    79  z-index:100; 
     79 z-index: 100; 
    8080 border: 2px solid #CCCCCC; 
    8181 background-color: #fff; 
     
    8383#JT_connect { 
    8484 position: absolute; 
    85  z-index:90; 
     85 z-index: 90; 
    8686 width: 17px; 
    8787} 
    8888#JT_copy { 
    89  padding:10px 10px 10px 10px; 
    90  color:#333333; 
     89 padding: 10px 10px 10px 10px; 
     90 color: #333333; 
    9191} 
    9292#JT_loader { 
     
    9494 background-repeat: no-repeat; 
    9595 background-position: left center; 
    96  width:100%; 
    97  height:18px; 
     96 width: 100%; 
     97 height: 18px; 
    9898} 
    9999#JT_loader #loading { 
  • revtreeplugin/0.11/revtree/htdocs/js/svgtip.js

    r2280 r2294  
    99 */ 
    1010 
    11 var jttimeout = null; 
     11var jttimer = null; 
    1212function JT_init(){ 
    1313  $('a[@id^=rev]').hover(function(){JT_show(this)}, 
    14                          function(){jttimeout=setTimeout("JT_remove();", 250);}); 
     14                         function(){jttimer=setTimeout("JT_remove();", 250);}); 
    1515} 
    1616 
    1717function JT_cancel() { 
    18    if (jttimeout) { 
    19       clearTimeout(jttimeout); 
    20       jttimeout = null; 
     18   if (jttimer) { 
     19      clearTimeout(jttimer); 
     20      jttimer = null; 
    2121   } 
    2222} 
     
    4747  var fgc = colors[0].replace(/^.*color:/,''); 
    4848  var bgc = colors[1].replace(/^.*color:/,''); 
    49   var title = id.replace(/^rev/, 'Changeset <a href="'+url+'">[') + ']</a>'
     49  var rev = id.replace(/^rev/, '')
    5050  var box = getSvgPosition(id); 
    51   if(title == false)title=' '; 
    5251  var de = document.documentElement; 
    5352  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; 
    5453  var hasArea = w - box.x; 
    5554  var clickElementy = box.y + (box.h/2); 
    56   var queryString = url.replace(/^[^\?]+\??/,''); 
    57   var params = parseQuery( queryString ); 
    58   if(params['width'] === undefined){params['width'] = 250}; 
     55  var tipw = 250; 
    5956     
    60   if(hasArea>((params['width']*1)+box.w))
     57  if( hasArea > (tipw+box.w) )
    6158     var clickElementx = box.x + box.w + 20; 
    6259     var connectx = box.x + box.w; 
    6360     var side = 'left'; 
    6461  } else { 
    65      var clickElementx = box.x - (params['width']*1) - 21; 
     62     var clickElementx = box.x - tipw - 21; 
    6663     var connectx = box.x - 20; 
    6764     var side = 'right'; 
    6865  } 
    6966 
    70   $('body').append('<div id="JT" style="width:'+params['width']*1+'px; '+ 
    71                                        'left:'+clickElementx+'px; ' + 
    72                                        'top:'+(clickElementy-13)+'px; ' + 
    73                                        'border: 2px solid '+fgc+'">' + 
    74                                        '</div>'); 
    75   $('body').append('<div id="JT_connect" style="' + 
    76                       'left:'+connectx+'px; ' + 
    77                       'top:'+(clickElementy-1)+'px; ' + 
    78                       'border: 2px solid '+fgc+'">' + 
    79                       '</div>'); 
    80   $('#JT').hover(function(){JT_cancel();}, 
    81                  function(){JT_remove();}); 
    82  
    83   var style=''; 
    84   if (side=='right'){style='style="left:'+((params['width']*1)+1)+'px;"'} 
    85   $('#JT').append('<div id="JT_title" style="background-color:'+bgc+ 
    86                     '" class="changeset"><span>'+title+'</span></div>' + 
    87                   '<div id="JT_copy"><div id="JT_loader">' + 
    88                   '<span id="loading">loading changeset&#8230;</span>' + 
    89                   '</div></div>'); 
     67  // cannot use jQuery .append() because the document type is  
     68  // application/xhtml+xml; need to use the verbose solution 
     69  var ns = 'http://www.w3.org/1999/xhtml'; 
     70  var jt = document.createElementNS(ns, 'div'); 
     71  jt.setAttribute('id', 'JT'); 
     72  jt.setAttribute('style', 'width:' + tipw + 'px;' + 
     73                           'left:' + clickElementx+'px;' + 
     74                           'top:' + (clickElementy-13) + 'px;' + 
     75                           'border: 2px solid ' + fgc); 
     76  var jt_connect = document.createElementNS(ns, 'div'); 
     77  jt_connect.setAttribute('id', 'JT_connect'); 
     78  jt_connect.setAttribute('style', 'left:' + connectx + 'px; ' + 
     79                                   'top:' + (clickElementy-1) + 'px; ' + 
     80                                   'border: 2px solid ' + fgc); 
     81  var jt_title = document.createElementNS(ns, 'div'); 
     82  jt_title.setAttribute('id', 'JT_title'); 
     83  jt_title.setAttribute('class', 'changeset'); 
     84  jt_title.setAttribute('style', 'background-color:' + bgc); 
     85  var title = document.createElementNS(ns, 'span'); 
     86  title.appendChild(document.createTextNode('Changeset ')); 
     87  var titlelink = document.createElementNS(ns, 'a'); 
     88  titlelink.setAttribute('href', url); 
     89  titlelink.appendChild(document.createTextNode('[' + rev +']')); 
     90  title.appendChild(titlelink); 
     91  jt_title.appendChild(title); 
     92  var jt_copy = document.createElementNS(ns, 'div'); 
     93  jt_copy.setAttribute('id', 'JT_copy'); 
     94  var jt_loader = document.createElementNS(ns, 'div'); 
     95  jt_loader.setAttribute('id', 'JT_loader'); 
     96  var span2 = document.createElementNS(ns, 'span'); 
     97  span2.setAttribute('id', 'loading'); 
     98  var hellip = String.fromCharCode(8230); 
     99  span2.appendChild(document.createTextNode('loading changeset info' +  
     100                                            hellip)); 
     101  jt_loader.appendChild(span2); 
     102  jt_copy.appendChild(jt_loader); 
     103  jt.appendChild(jt_title); 
     104  jt.appendChild(jt_copy); 
     105                            
     106  $('body').append(jt); 
     107  $('body').append(jt_connect); 
     108 
     109  $('#JT').hover(function() { JT_cancel(); }, function() { JT_remove(); }); 
     110  $('#JT_connect').show(); 
    90111  $('#JT').show(); 
    91   $('#JT_connect').show(); 
    92   $('#JT_copy').load(logurl); 
     112  // we want text result from the XHTML+XML server response for use  
     113  // wtih innerHTML, as load() does not work for some reason (why?)   
     114  // cannot use $.get(), need to go with $.ajax() 
     115  $.ajax({async: true, type: "GET", dataType: 'html',  
     116          url: logurl, success: updateJT}); 
     117
     118 
     119function updateJT(data) { 
     120  // cannot use innerHTML with jQuery 
     121  var copy = document.getElementById('JT_copy'); 
     122  // why innerHTML work with application/xhtml+xml doctype here? 
     123  copy.innerHTML = data; 
    93124} 
    94125 
     
    121152   // Not sure who's right or wrong here: Opera, Gecko ? 
    122153   // Anyway the following hack seems to work. Javascript, oh my... 
    123    if ( jQuery.browser.opera || jQuery.browser.safari ) 
    124    { 
     154   if ( jQuery.browser.opera || jQuery.browser.safari ) { 
    125155      r.x = Math.floor(box.x*mx.a)+svgpos[0]; 
    126156      r.y = Math.floor(box.y*mx.d)+svgpos[1]; 
     
    129159      return r; 
    130160   } 
    131    else 
    132    { 
     161   else { 
    133162      var p1 = svg.createSVGPoint(); 
    134163      var p2 = svg.createSVGPoint(); 
     
    177206            document.body.scrollTop ? document.body.scrollTop : 0; 
    178207}  
    179  
    180 function parseQuery (query) { 
    181   var Params = new Object (); 
    182   if ( ! query ) return Params; // return empty object 
    183   var Pairs = query.split(/[;&]/); 
    184   for ( var i = 0; i < Pairs.length; i++ ) { 
    185      var KeyVal = Pairs[i].split('='); 
    186      if ( ! KeyVal || KeyVal.length != 2 ) continue; 
    187      var key = unescape( KeyVal[0] ); 
    188      var val = unescape( KeyVal[1] ); 
    189      val = val.replace(/\+/g, ' '); 
    190      Params[key] = val; 
    191   } 
    192   return Params; 
    193 } 
    194  
    195 function blockEvents(evt) { 
    196   if(evt.target){ 
    197     evt.preventDefault(); 
    198   }else{ 
    199     evt.returnValue = false; 
    200   } 
    201 } 
  • revtreeplugin/0.11/setup.py

    r2280 r2294  
    1616 
    1717PACKAGE = 'TracRevtreePlugin' 
    18 VERSION = '0.5.4
     18VERSION = '0.5.5
    1919 
    2020setup (