forked from LeaVerou/prefixfree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·48 lines (34 loc) · 912 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Scripts for the demo page of -prefix-free
function $(id) { return document.getElementById(id) }
(function(){
if(window.PrefixFree) {
var source = $('source'),
prefixed = $('prefixed');
(source.oninput = function() {
prefixed.value = PrefixFree.prefixCSS(source.value, true);
})();
source.onscroll = function() {
prefixed.scrollTop = source.scrollTop;
}
}
(window.onhashchange = function() {
var target, page, previousPage;
if(location.hash) {
page = target = document.querySelector(location.hash);
while(page && page.className != 'page') {
page = page.parentNode;
}
}
(previousPage = document.querySelector('.current.page')) && (previousPage.className = 'page');
if(page) {
page.className = 'current page';
document.body.className = 'in-page';
}
else {
document.body.className = 'home';
}
if(target) {
target.scrollIntoView(true);
}
})();
})();