]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blame - static/js/site.js
add spacing and menu on mobile
[people/shoehn/ipfire.org.git] / static / js / site.js
CommitLineData
1e5bc9c9
S
1$(document).ready(function () {
2 $(window).scroll(function () {
3 if ($(document).scrollTop() > 100) {
4 $(".fixed-top").addClass("scrolled");
ccd81281 5 $(".menu-text").addClass("hidden");
1e5bc9c9
S
6 } else {
7 $(".fixed-top").removeClass("scrolled");
ccd81281 8 $(".menu-text").removeClass("hidden");
1e5bc9c9
S
9 }
10 });
11});
12
60b0917c
MT
13//jQuery to collapse the navbar on scroll
14$(window).scroll(function() {
15 if ($(".navbar").offset().top > 50) {
16 $(".navbar-fixed-top").addClass("top-nav-collapse");
17 } else {
18 $(".navbar-fixed-top").removeClass("top-nav-collapse");
19 }
20});
21
b6d1f3b7
S
22$("#scrollto").click(function() {
23 $('html, body').animate({
24 scrollTop: $("#features").offset().top - $('.fixed-top').height()
25 }, 1500, 'easeInOutExpo');
60b0917c
MT
26});
27
60024cc8
MT
28$.query = function(name){
29 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
30 return results[1] || 0;
31}
32
33$("a.download-splash").click(function(event) {
34 event.preventDefault();
35 linkLocation = this.href;
36
37 window.location = "http://downloads.ipfire.org/download-splash?file="+linkLocation;
38});
39
9b5ac075
MT
40var $window = $(window);
41
42$(".sidenav").affix({
43 offset: {
66f34dde 44 top: function () { return $window.width() <= 980 ? 290 : 240 }
9b5ac075
MT
45 , bottom: 270
46 }
47});
48
60024cc8
MT
49if (/.*download-splash.*/i.test(window.location.href)) {
50 $("p.download-path").ready(function(){
51 var valid = false;
52 var allowed_prefixes = [
53 "http://downloads.ipfire.org/",
54 ]
55
56 var file_url = $.query("file");
57
58 // Only accept URLs beginning with our known prefix.
59 for (i in allowed_prefixes) {
60 prefix = allowed_prefixes[i];
61 if (file_url.substring(0, prefix.length) == prefix) {
62 valid = true;
63 }
64 }
65
66 if (valid) {
67 $("p.download-path").prepend($("<a>", {
68 href: encodeURI(file_url),
69 text: file_url
70 }))
71 setTimeout(function() { window.location = file_url }, "2000");
72 }
73 });
74}
0e824faf 75
c9275d4e 76/* $(".planet-search-autocomplete").typeahead({
a3e3c96d 77 source: function(query, process) {
8876f3df 78 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
a3e3c96d
MT
79 if (data.query == query) {
80 process(data.results);
81 }
82 });
83 },
c9275d4e 84}); */
a3e3c96d 85
0e824faf
MT
86function getCookie(name) {
87 var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
88 return r ? r[1] : undefined;
89}
90
91jQuery.postJSON = function(url, args, callback) {
92 args._xsrf = getCookie("_xsrf");
93 $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST",
94 success: function(response) {
95 callback(eval("(" + response + ")"));
96 }
97 });
98};