]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - static/js/site.js
1 //jQuery to collapse the navbar on scroll
2 $(window
).scroll(function() {
3 if ($(".navbar").offset().top
> 50) {
4 $(".navbar-fixed-top").addClass("top-nav-collapse");
6 $(".navbar-fixed-top").removeClass("top-nav-collapse");
10 //jQuery for page scrolling feature - requires jQuery Easing plugin
12 $('.page-scroll a, a.page-scroll').bind('click', function(event
) {
13 var $anchor
= $(this);
14 $('html, body').stop().animate({
15 scrollTop
: $($anchor
.attr('href')).offset().top
16 }, 1500, 'easeInOutExpo');
17 event
.preventDefault();
21 $.query = function(name
){
22 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
23 return results
[1] || 0;
26 $("a.download-splash").click(function(event
) {
27 event
.preventDefault();
28 linkLocation
= this.href
;
30 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
33 var $window
= $(window
);
37 top: function () { return $window
.width() <= 980 ? 290 : 240 }
42 if (/.*download-splash.*/i.test(window
.location
.href
)) {
43 $("p.download-path").ready(function(){
45 var allowed_prefixes
= [
46 "http://downloads.ipfire.org/",
49 var file_url
= $.query("file");
51 // Only accept URLs beginning with our known prefix.
52 for (i
in allowed_prefixes
) {
53 prefix
= allowed_prefixes
[i
];
54 if (file_url
.substring(0, prefix
.length
) == prefix
) {
60 $("p.download-path").prepend($("<a>", {
61 href
: encodeURI(file_url
),
64 setTimeout(function() { window
.location
= file_url
}, "2000");
69 /* $(".planet-search-autocomplete").typeahead({
70 source: function(query, process) {
71 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
72 if (data.query == query) {
73 process(data.results);
79 function getCookie(name
) {
80 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
81 return r
? r
[1] : undefined;
84 jQuery
.postJSON = function(url
, args
, callback
) {
85 args
._xsrf
= getCookie("_xsrf");
86 $.ajax({url
: url
, data
: $.param(args
), dataType
: "text", type
: "POST",
87 success: function(response
) {
88 callback(eval("(" + response
+ ")"));