~ce-hyperscale/charms/precise/wordpress/arm64-trusty

« back to all changes in this revision

Viewing changes to files/wordpress/natty/script.js

  • Committer: Marco Ceppi
  • Date: 2012-07-11 20:45:43 UTC
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: marco@ceppi.net-20120711204543-t44tb77atidxflll
Removed all OMG! Ubuntu specific stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var ht = []
2
 
var htp = 1
3
 
 
4
 
var hspeed = 800
5
 
var hinter = 7000
6
 
 
7
 
$( function()
8
 
{       
9
 
        bind_links()
10
 
        set_title()
11
 
        set_font()
12
 
 
13
 
        hash = window.location.hash
14
 
        anchor = $("#nav a[href="+hash+"]")
15
 
 
16
 
        if(hash.length > 0 && anchor.length == 1)
17
 
                anchor.click()
18
 
 
19
 
        $("#body #header h1 span").each( function() {   ht.push($(this).text()) })
20
 
        $("#body #header h1 span:gt(0)").remove()
21
 
        setInterval( show_next_ht, hinter );
22
 
})
23
 
 
24
 
function set_font()
25
 
{
26
 
        n = navigator.userAgent
27
 
        if( document.location.search.match('ubuntu') || $.browser.msie || n.match("iPhone") || n.match("iPod") || n.match("iPad") )
28
 
        {
29
 
                $("#body").css("font-family", "Ubuntu, Verdana, Sans, sans-serif").css("font-size","0.9em")
30
 
        }
31
 
}
32
 
 
33
 
function set_title()
34
 
{
35
 
        ti = $(".title")
36
 
        
37
 
        if(ti.length)
38
 
        {
39
 
                $("title").text(ti.text())
40
 
                document.title = ti.text()
41
 
        }
42
 
}
43
 
 
44
 
function show_next_ht()
45
 
{
46
 
        if( htp == ht.length )
47
 
                htp = 0
48
 
 
49
 
        next = ht[htp++]
50
 
 
51
 
        $("#body #header h1").append("<span>"+next+"</span>").animate({"margin-left": "-940px"}, hspeed, function()
52
 
        {
53
 
                $("#body #header h1").css("margin-left", "0px").find("span:first").remove()
54
 
        })
55
 
}
56
 
 
57
 
function bind_links()
58
 
{
59
 
        $("#nav a, .subnav a").unbind("click").bind("click",function()
60
 
        {
61
 
                $(this).blur()
62
 
                url = $(this).attr("href").replace("#","")
63
 
 
64
 
                $("#nav .active").removeClass("active")
65
 
                $("#nav a[href=#"+url+"]").parent().addClass("active")
66
 
                
67
 
                $.get(url + "&ajax", function(data)
68
 
                {
69
 
                        $("#body > *:gt(1)").remove()
70
 
                        $(data).appendTo("#body")
71
 
 
72
 
                        bind_links()
73
 
                        set_title()
74
 
                        scroll_to_top()
75
 
                        set_font()
76
 
                })
77
 
        }).attr("href", function(i,h) { return ("#"+h).replace(/#+/,"#")  })
78
 
}
79
 
 
80
 
function scroll_to_top()
81
 
{
82
 
        if( typeof( window.pageYOffset ) == 'number' ) {
83
 
                //Netscape compliant
84
 
                y = window.pageYOffset;
85
 
                x = window.pageXOffset;
86
 
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
87
 
                //DOM compliant
88
 
                y = document.body.scrollTop;
89
 
                x = document.body.scrollLeft;
90
 
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
91
 
                //IE6 standards compliant mode
92
 
                y = document.documentElement.scrollTop;
93
 
                x = document.documentElement.scrollLeft;
94
 
        }
95
 
 
96
 
        c = 200
97
 
        t = $("#nav").position().top
98
 
 
99
 
        console.log(t)
100
 
 
101
 
        y = Math.max(t, y)
102
 
 
103
 
        if(y <= t) return;
104
 
 
105
 
        window.scrollTo(x, Math.max( t,  y - c))
106
 
        setTimeout(scroll_to_top, 25)
107
 
}
 
 
b'\\ No newline at end of file'