Mercurial > repos > marcel > caddsuite_mac10_6
annotate CADDSuite-1.5/data/OpenBabel/svgformat.script @ 7:bfab27640f5e draft
CADDSuite version 1.5
author | Marcel Schumann <schumann.marcel@gmail.com> |
---|---|
date | Tue, 24 Jul 2012 11:13:59 -0400 |
parents | |
children |
rev | line source |
---|---|
7
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
1 <script type="text/ecmascript"> |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
2 <![CDATA[ |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
3 addEventListener('DOMMouseScroll', wheel, false); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
4 onmousewheel = wheel; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
5 var svgEl = document.getElementById("topsvg"); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
6 var startx=0; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
7 var starty=0; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
8 function wheel(evt){ |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
9 evt = evt ? evt : window.event; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
10 var normal = evt.detail ? evt.detail * -1 : evt.wheelDelta / 40; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
11 var vb = new Array(4); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
12 var vbtext = svgEl.getAttributeNS(null,"viewBox"); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
13 vb = vbtext.split(" "); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
14 var zoom = (normal<0)? 1.41 : 0.71; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
15 //var dwidth = parseFloat(Math.max(vb[2],vb[3])) * (1-zoom); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
16 vb[0] = parseFloat(vb[0]) + parseFloat(vb[2])*(1-zoom) * evt.clientX/innerWidth; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
17 vb[1] = parseFloat(vb[1]) + parseFloat(vb[3])*(1-zoom) * evt.clientY/innerHeight; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
18 vb[2] = parseFloat(vb[2]) * zoom; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
19 vb[3] = parseFloat(vb[3]) * zoom; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
20 svgEl.setAttributeNS(null, "viewBox", vb.join(" ")); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
21 if (evt.preventDefault) |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
22 evt.preventDefault(); // Don't scroll the page when zooming |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
23 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
24 onmousedown = function(evt) { |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
25 startx = evt.clientX; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
26 starty = evt.clientY; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
27 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
28 onmousemove=function(evt) { |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
29 if(startx!=0 && starty!=0 |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
30 && ((evt.clientX - startx)*(evt.clientX - startx)+(evt.clientY - starty)*(evt.clientY - starty)>100)) |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
31 { |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
32 var vbtext = svgEl.getAttributeNS(null,"viewBox"); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
33 vb = vbtext.split(" "); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
34 var maxwh = Math.max(parseFloat(vb[2]),parseFloat(vb[3])); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
35 vb[0] = parseFloat(vb[0]) - (evt.clientX - startx)*maxwh/innerWidth; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
36 vb[1] = parseFloat(vb[1]) - (evt.clientY - starty)*maxwh/innerHeight; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
37 svgEl.setAttributeNS(null, "viewBox", vb.join(" ")); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
38 startx = evt.clientX; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
39 starty = evt.clientY; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
40 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
41 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
42 onmouseup=function() { |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
43 startx=0; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
44 starty=0; |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
45 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
46 ondblclick=function() { |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
47 location.reload(); |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
48 } |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
49 ]]> |
bfab27640f5e
CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff
changeset
|
50 </script> |