]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - 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");
7 $(".fixed-top").removeClass("scrolled");
8 $(".menu-text").removeClass("hidden");
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");
18 $(".navbar-fixed-top").removeClass("top-nav-collapse");
22 $("#scrollto").click(function() {
23 $('html, body').animate({
24 scrollTop
: $("#features").offset().top
- $('.fixed-top').height()
25 }, 1500, 'easeInOutExpo');
28 $.query = function(name
){
29 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
30 return results
[1] || 0;
33 $("a.download-splash").click(function(event
) {
34 event
.preventDefault();
35 linkLocation
= this.href
;
37 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
40 var $window
= $(window
);
44 top: function () { return $window
.width() <= 980 ? 290 : 240 }
49 if (/.*download-splash.*/i.test(window
.location
.href
)) {
50 $("p.download-path").ready(function(){
52 var allowed_prefixes
= [
53 "http://downloads.ipfire.org/",
56 var file_url
= $.query("file");
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
) {
67 $("p.download-path").prepend($("<a>", {
68 href
: encodeURI(file_url
),
71 setTimeout(function() { window
.location
= file_url
}, "2000");
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);
86 function getCookie(name
) {
87 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
88 return r
? r
[1] : undefined;
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
+ ")"));