Revert "Simplify style switcher" as it doesn't work with Chrome like this

This reverts commit 98e913c933.
This commit is contained in:
Matthias Schiffer 2012-06-16 15:49:35 +02:00
parent fd41f11f6c
commit e2347fa020
2 changed files with 25 additions and 10 deletions

View file

@ -1,3 +1,19 @@
var style;
function switch_style(s) {
var el = document.getElementsByTagName("link")
for (var i = 0; i < el.length; i++ ) {
if (el[i].getAttribute("rel").indexOf("style") != -1
&& el[i].getAttribute("title")) {
if (el[i].getAttribute("title") == s) {
style_btn.text(s)
el[i].disabled = false
} else
el[i].disabled = true
}
}
}
function getOffset( el ) {
var _x = 0, _y = 0
@ -34,16 +50,15 @@ function resize() {
}
function next_style() {
var n = document.styleSheetSets.length
var i;
for (i = 0; i < n; i++) {
if (document.styleSheetSets[i] == document.selectedStyleSheetSet)
break
}
var s;
if (style !== undefined)
s = d3.select("head link[title=" + style + "] + link")
var s = document.styleSheetSets[(i+1) % n]
style_btn.text(s)
document.selectedStyleSheetSet = s
if (s == null || s[0][0] == null)
s = d3.select("head link[title]")
style = s[0][0].getAttribute("title")
switch_style(style)
}
var cp = d3.select("header").append("div")

View file

@ -5,7 +5,7 @@
<title>Freifunk Lübeck - Knotengraph</title>
<link href='style.css' rel='stylesheet' type='text/css' />
<link href='force.css' rel='stylesheet' type='text/css' />
<link href='force-big.css' rel='alternate stylesheet' type='text/css' title='big'/>
<link href='force-big.css' rel='alternate stylesheet' type='text/css' title='big' disabled/>
<link href='force-light.css' rel='stylesheet' type='text/css' title='light'/>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="d3.v2.js"></script>