Simplify style switcher
This commit is contained in:
parent
cb716e297d
commit
98e913c933
|
@ -1,19 +1,3 @@
|
||||||
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 ) {
|
function getOffset( el ) {
|
||||||
var _x = 0, _y = 0
|
var _x = 0, _y = 0
|
||||||
|
|
||||||
|
@ -50,15 +34,16 @@ function resize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function next_style() {
|
function next_style() {
|
||||||
var s;
|
var n = document.styleSheetSets.length
|
||||||
if (style !== undefined)
|
var i;
|
||||||
s = d3.select("head link[title=" + style + "] + link")
|
for (i = 0; i < n; i++) {
|
||||||
|
if (document.styleSheetSets[i] == document.selectedStyleSheetSet)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if (s == null || s[0][0] == null)
|
var s = document.styleSheetSets[(i+1) % n]
|
||||||
s = d3.select("head link[title]")
|
style_btn.text(s)
|
||||||
|
document.selectedStyleSheetSet = s
|
||||||
style = s[0][0].getAttribute("title")
|
|
||||||
switch_style(style)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var cp = d3.select("header").append("div")
|
var cp = d3.select("header").append("div")
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<title>Freifunk Lübeck - Knotengraph</title>
|
<title>Freifunk Lübeck - Knotengraph</title>
|
||||||
<link href='style.css' rel='stylesheet' type='text/css' />
|
<link href='style.css' rel='stylesheet' type='text/css' />
|
||||||
<link href='force.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' disabled/>
|
<link href='force-big.css' rel='alternate stylesheet' type='text/css' title='big'/>
|
||||||
<link href='force-light.css' rel='stylesheet' type='text/css' title='light'/>
|
<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="jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="d3.v2.js"></script>
|
<script type="text/javascript" src="d3.v2.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue