]>
git.ipfire.org Git - 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");
6 $(".fixed-top").removeClass("scrolled");
11 //jQuery to collapse the navbar on scroll
12 $(window
).scroll(function() {
13 if ($(".navbar").offset().top
> 50) {
14 $(".navbar-fixed-top").addClass("top-nav-collapse");
16 $(".navbar-fixed-top").removeClass("top-nav-collapse");
20 //jQuery for page scrolling feature - requires jQuery Easing plugin
22 $('.page-scroll a, a.page-scroll').bind('click', function(event
) {
23 var $anchor
= $(this);
24 $('html, body').stop().animate({
25 scrollTop
: $($anchor
.attr('href')).offset().top
26 }, 1500, 'easeInOutExpo');
27 event
.preventDefault();
31 $.query = function(name
){
32 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
33 return results
[1] || 0;
36 $("a.download-splash").click(function(event
) {
37 event
.preventDefault();
38 linkLocation
= this.href
;
40 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
43 var $window
= $(window
);
47 top: function () { return $window
.width() <= 980 ? 290 : 240 }
52 if (/.*download-splash.*/i.test(window
.location
.href
)) {
53 $("p.download-path").ready(function(){
55 var allowed_prefixes
= [
56 "http://downloads.ipfire.org/",
59 var file_url
= $.query("file");
61 // Only accept URLs beginning with our known prefix.
62 for (i
in allowed_prefixes
) {
63 prefix
= allowed_prefixes
[i
];
64 if (file_url
.substring(0, prefix
.length
) == prefix
) {
70 $("p.download-path").prepend($("<a>", {
71 href
: encodeURI(file_url
),
74 setTimeout(function() { window
.location
= file_url
}, "2000");
79 /* $(".planet-search-autocomplete").typeahead({
80 source: function(query, process) {
81 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
82 if (data.query == query) {
83 process(data.results);
89 function getCookie(name
) {
90 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
91 return r
? r
[1] : undefined;
94 jQuery
.postJSON = function(url
, args
, callback
) {
95 args
._xsrf
= getCookie("_xsrf");
96 $.ajax({url
: url
, data
: $.param(args
), dataType
: "text", type
: "POST",
97 success: function(response
) {
98 callback(eval("(" + response
+ ")"));