Changeset 3491

Show
Ignore:
Timestamp:
04/08/08 18:50:19 (9 months ago)
Author:
eblot
Message:

Closes #2871: Firefox 3.0 is now supported.

Javascript w/ SVG has been rewritten within Gecko 1.9, which causes even more issues to jQuery 1.2.3

Files:

Legend:

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

    r3274 r3491  
    66 * 
    77 * Badly hacked & tweaked to support XHTML/XML and SVG for the RevtreePlugin 
    8  * by Emmanuel Blot <emmanuel.blot@free.fr> 2006-2007 
     8 * by Emmanuel Blot <emmanuel.blot@free.fr> 2006-2008 
     9 * 
     10 * You might wonder why the hell regular Javascript functions are mixed with 
     11 * jQuery ones... The trouble is that JQuery exhibits many difficulties with 
     12 * XML documents for now (jQuery 1.2.3) and is sometimes unable to cope with 
     13 * XML+SVG document. The funny part is that code that works on some browsers 
     14 * (Presto, Webkit for ex.) does not work with the lastest releases of Gecko, 
     15 * and vice-versa.   
    916 */ 
    1017 
     
    1219 
    1320(function($){ 
     21     
     22window.JT_get_svganchors = function() { 
     23  if ( (jQuery.browser.mozilla &&  
     24        (parseFloat(jQuery.browser.version) < 1.9)) || 
     25        (jQuery.browser.safari &&  
     26              (parseFloat(jQuery.browser.version) < 523)) ) { 
     27    // Firefox 1.x, 2.x, OmniWeb 5.x 
     28    var vanchors = []; 
     29    jQuery.each($('a[@id^=rev]'), function(index, value) { 
     30      vanchors.push(value); 
     31    }); 
     32    return vanchors; 
     33  } 
     34  else { 
     35    // Firefox 3.x, Opera, Safari, ... 
     36    var anchors; 
     37    anchors = document.getElementsByTagNameNS('http://www.w3.org/2000/svg',  
     38                                              'a'); 
     39    var vanchors = []; 
     40    for(var i in anchors) { 
     41      if ( anchors[i].id && anchors[i].id.substring(0, 3) == 'rev' ) { 
     42          vanchors.push(anchors[i]); 
     43      } 
     44    } 
     45    return vanchors; 
     46  } 
     47} 
    1448 
    1549window.JT_init = function(){ 
    16   $('a[@id^=rev]').hover(function(){JT_show(this)}, 
    17                          function(){jttimer=setTimeout("JT_remove();", 250);}); 
     50  var anchors = JT_get_svganchors(); 
     51  for (var n = 0; n < anchors.length; n++){ 
     52    jQuery(anchors[n]).hover( 
     53           function(){JT_show(this)}, 
     54           function(){jttimer=setTimeout("JT_remove();", 250);} 
     55    ); 
     56  } 
    1857} 
    1958 
    2059window.JT_cancel = function() { 
    21   if (jttimer) { 
    22       clearTimeout(jttimer); 
    23       jttimer = null; 
    24  
     60  if (jttimer) { 
     61    clearTimeout(jttimer); 
     62    jttimer = null; 
     63 
    2564} 
    2665 
    2766window.JT_remove = function() { 
    28   var jt = $('#JT'); 
    29   if ( jt ) { jt.remove(); } 
    30   var jt_connect = $('#JT_connect'); 
    31   if ( jt_connect ) { jt_connect.remove(); } 
     67  var jt = $('#JT'); 
     68  if ( jt ) { jt.remove(); } 
     69  var jt_connect = $('#JT_connect'); 
     70  if ( jt_connect ) { jt_connect.remove(); } 
    3271} 
    3372 
     
    128167 
    129168window.getSvgPosition = function(objectId) { 
    130    // The following loop could be simplified to use JQuery 
    131    // JQuery has some trouble with XML documents for now 
    132    var svg = document.getElementsByTagName('svg')[0]; 
    133    var anodes = svg.getElementsByTagName('a'); 
    134    var object; 
    135         for ( var e = 0; e < anodes.length; e++ ) { 
    136       if ( anodes[e].getAttribute('id') == objectId ) { 
    137          object = anodes[e]; 
    138          break; 
    139       } 
    140    } 
    141    var cnodes = object.childNodes 
    142    var elem; 
    143         for ( var n = 0; n < cnodes.length; n++ ) { 
    144       if ( cnodes[n].tagName == "svg:g" ) { 
    145          elem = cnodes[n] 
    146          break; 
    147       }  
    148    } 
     169  var svg = document.getElementById('svgbox'); 
     170  var anodes = JT_get_svganchors(); 
     171  var object; 
     172  for ( var e = 0; e < anodes.length; e++ ) { 
     173    if ( anodes[e].getAttribute('id') == objectId ) { 
     174      object = anodes[e]; 
     175      break; 
     176    } 
     177  } 
     178  var cnodes = object.childNodes 
     179  var elem; 
     180  for ( var n = 0; n < cnodes.length; n++ ) { 
     181    if ( cnodes[n].tagName == "svg:g" ) { 
     182      elem = cnodes[n] 
     183      break; 
     184    }  
     185  } 
    149186    
    150   var r = Object(); 
    151   var mx = svg.getScreenCTM(); 
    152   var box = elem.getBBox(); 
    153   var svgpos = findPos(svg); 
    154    
    155   // Not sure who's right or wrong here: Opera, Gecko
    156   // Anyway the following hack seems to work. Javascript, oh my... 
    157   if ( jQuery.browser.opera || jQuery.browser.safari ) { 
    158       r.x = Math.floor(box.x*mx.a)+svgpos[0]; 
    159       r.y = Math.floor(box.y*mx.d)+svgpos[1]; 
    160       r.w = Math.floor(box.width*mx.a); 
    161       r.h = Math.floor(box.height*mx.d); 
    162       return r; 
    163  
    164   else { 
    165       var p1 = svg.createSVGPoint(); 
    166       var p2 = svg.createSVGPoint(); 
    167       p1.x = box.x; 
    168       p1.y = box.y; 
    169       p2.x = p1.x + box.width; 
    170       p2.y = p1.y + box.height; 
    171       p1 = p1.matrixTransform(mx); 
    172       p2 = p2.matrixTransform(mx); 
    173       r.x = Math.floor(p1.x)+posLeft(); 
    174       r.y = Math.floor(p1.y)+posTop(); 
    175       r.w = Math.floor(p2.x-p1.x); 
    176       r.h = Math.floor(p2.y-p1.y); 
    177       return r; 
    178  
     187  var r = Object(); 
     188  var mx = svg.getScreenCTM(); 
     189  var box = elem.getBBox(); 
     190  var svgpos = findPos(svg); 
     191   
     192  // Not sure who's right or wrong here: Gecko, Webkit, Presto, ...
     193  // Anyway the following hack seems to work. Javascript, oh my... 
     194  if ( jQuery.browser.opera || jQuery.browser.safari ) { 
     195    r.x = Math.floor(box.x*mx.a)+svgpos[0]; 
     196    r.y = Math.floor(box.y*mx.d)+svgpos[1]; 
     197    r.w = Math.floor(box.width*mx.a); 
     198    r.h = Math.floor(box.height*mx.d); 
     199    return r; 
     200 
     201  else { 
     202    var p1 = svg.createSVGPoint(); 
     203    var p2 = svg.createSVGPoint(); 
     204    p1.x = box.x; 
     205    p1.y = box.y; 
     206    p2.x = p1.x + box.width; 
     207    p2.y = p1.y + box.height; 
     208    p1 = p1.matrixTransform(mx); 
     209    p2 = p2.matrixTransform(mx); 
     210    r.x = Math.floor(p1.x)+posLeft(); 
     211    r.y = Math.floor(p1.y)+posTop(); 
     212    r.w = Math.floor(p2.x-p1.x); 
     213    r.h = Math.floor(p2.y-p1.y); 
     214    return r; 
     215 
    179216} 
    180217 
    181218window.findPos = function(obj) { 
    182        var curleft = curtop = 0; 
    183        if (obj.offsetParent) { 
    184                curleft = obj.offsetLeft 
    185                curtop = obj.offsetTop 
    186                while (obj = obj.offsetParent) { 
    187                        curleft += obj.offsetLeft 
    188                        curtop += obj.offsetTop 
    189                
    190        
    191        return [curleft,curtop]; 
     219  var curleft = curtop = 0; 
     220  if (obj.offsetParent) { 
     221    curleft = obj.offsetLeft 
     222    curtop = obj.offsetTop 
     223    while (obj = obj.offsetParent) { 
     224      curleft += obj.offsetLeft 
     225      curtop += obj.offsetTop 
     226   
     227 
     228  return [curleft,curtop]; 
    192229} 
    193230 
    194231window.posLeft = function() { 
    195   return typeof window.pageXOffset != 'undefined' ?  
    196       window.pageXOffset : 
    197       document.documentElement &&  
    198          document.documentElement.scrollLeft ?  
    199             document.documentElement.scrollLeft :  
    200             document.body.scrollLeft ? document.body.scrollLeft : 0;  
     232  return typeof window.pageXOffset != 'undefined' ?  
     233    window.pageXOffset : 
     234    document.documentElement &&  
     235      document.documentElement.scrollLeft ?  
     236        document.documentElement.scrollLeft :  
     237        document.body.scrollLeft ? document.body.scrollLeft : 0;  
    201238} 
    202239  
    203240window.posTop = function() { 
    204   return typeof window.pageYOffset != 'undefined' ?   
    205       window.pageYOffset :  
    206       document.documentElement &&  
    207          document.documentElement.scrollTop ?  
    208             document.documentElement.scrollTop :  
    209             document.body.scrollTop ? document.body.scrollTop : 0; 
     241  return typeof window.pageYOffset != 'undefined' ?   
     242    window.pageYOffset :  
     243    document.documentElement &&  
     244      document.documentElement.scrollTop ?  
     245        document.documentElement.scrollTop :  
     246        document.body.scrollTop ? document.body.scrollTop : 0; 
    210247}  
    211248 
  • revtreeplugin/0.11/revtree/SVGdraw.py

    r1911 r3491  
    5757is available from www.adobe.com""" 
    5858 
    59 # Note: Emmanuel Blot, 2007
     59# Note: Emmanuel Blot, 2007, 2008
    6060# The version has been updated to reflect the small changes made to 
    6161# support SVG 1.1 and the hack to support inline SVG (in XHTML host document) 
    62 __version__="1.0a
     62__version__="1.0b
    6363 
    6464# there are two possibilities to generate svg: 
     
    886886        ns = svgns and 'xmlns:svg' or 'xmlns' 
    887887        self.namespace = { ns: "http://www.w3.org/2000/svg", 
    888                            'xmlns:xlink': "http://www.w3.org/1999/xlink" } 
     888                           'xmlns:xlink': "http://www.w3.org/1999/xlink", 
     889                           'version': '1.1' } 
    889890                            
    890891    def toXml(self,level,f): 
  • revtreeplugin/0.11/revtree/svgview.py

    r2832 r3491  
    11# -*- coding: utf-8 -*- 
    22# 
    3 # Copyright (C) 2006-2007 Emmanuel Blot <emmanuel.blot@free.fr> 
     3# Copyright (C) 2006-2008 Emmanuel Blot <emmanuel.blot@free.fr> 
    44# All rights reserved. 
    55# 
     
    936936        self._svg = SVG.svg((0, 0, self._extent[0], self._extent[1]), 
    937937                            scale*self._extent[0], scale*self._extent[1], 
    938                             True
     938                            True, id='svgbox'
    939939        self._arrows.render() 
    940940        # FIXME: only two levels for enhancers (background, foreground) 
  • revtreeplugin/0.11/revtree/templates/revtree.html

    r3274 r3491  
    2727          updateLimits();  
    2828      }); 
    29       JT_init(); 
    30       updateLimits(); 
     29      window.JT_init(); 
     30      window.updateLimits(); 
    3131      // the following function is required for Safari to operate properly 
    3232      $(window).unload(function(){JT_hide()}); 
  • revtreeplugin/0.11/revtree/web_ui.py

    r2920 r3491  
    11# -*- coding: utf-8 -*- 
    22# 
    3 # Copyright (C) 2006-2007 Emmanuel Blot <emmanuel.blot@free.fr> 
     3# Copyright (C) 2006-2008 Emmanuel Blot <emmanuel.blot@free.fr> 
    44# All rights reserved. 
    55# 
  • revtreeplugin/0.11/setup.py

    r3274 r3491  
    22# -*- coding: utf-8 -*- 
    33# 
    4 # Copyright (C) 2006-2007 Emmanuel Blot <emmanuel.blot@free.fr> 
     4# Copyright (C) 2006-2008 Emmanuel Blot <emmanuel.blot@free.fr> 
    55# All rights reserved. 
    66# 
     
    1616 
    1717PACKAGE = 'TracRevtreePlugin' 
    18 VERSION = '0.5.14
     18VERSION = '0.5.15
    1919 
    2020setup (