]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - static/js/site.js
add spacing and menu on mobile
[people/shoehn/ipfire.org.git] / static / js / site.js
1 $(document).ready(function () {
2 $(window).scroll(function () {
3 if ($(document).scrollTop() > 100) {
4 $(".fixed-top").addClass("scrolled");
5 $(".menu-text").addClass("hidden");
6 } else {
7 $(".fixed-top").removeClass("scrolled");
8 $(".menu-text").removeClass("hidden");
9 }
10 });
11 });
12
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
22 $("#scrollto").click(function() {
23 $('html, body').animate({
24 scrollTop: $("#features").offset().top - $('.fixed-top').height()
25 }, 1500, 'easeInOutExpo');
26 });
27
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
40 var $window = $(window);
41
42 $(".sidenav").affix({
43 offset: {
44 top: function () { return $window.width() <= 980 ? 290 : 240 }
45 , bottom: 270
46 }
47 });
48
49 if (/.*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 }
75
76 /* $(".planet-search-autocomplete").typeahead({
77 source: function(query, process) {
78 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
79 if (data.query == query) {
80 process(data.results);
81 }
82 });
83 },
84 }); */
85
86 function getCookie(name) {
87 var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
88 return r ? r[1] : undefined;
89 }
90
91 jQuery.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 };