Move the download button into the download file.

This commit is contained in:
Eli Barzilay 2010-06-06 19:09:33 -04:00
parent c9146b38e5
commit 7e088a324e
2 changed files with 35 additions and 32 deletions

View File

@ -1,9 +1,41 @@
#lang at-exp s-exp "shared.rkt"
(provide download)
(require "../download/data.rkt")
(provide download-button)
(define download
(page #:link-title "Download" #:window-title "Download Racket"
#:file "download/"
"Download page comes here."))
(require "../download/data.rkt")
(define download-button
(let ([img1 (copyfile (in-here "download.png"))]
[img2 (copyfile (in-here "download-dark.png"))])
@list{
@script/inline[type: "text/javascript"]{
@; Don't load all images here -- it causes a delay when loading the
@; page instead, do it only when needed, and also set a timer to do it
@; after loading the page. This makes it so that there's almost never
@; a delay when loading the page, and also no delay when switching the
@; image.
var rollovers = false, the_download_button = false;
function init_rollovers() {
if (!rollovers) {
rollovers = [ new Image(), new Image() ];
rollovers[0].src = "@img1";
rollovers[1].src = "@img2";
the_download_button = document.getElementById("download_button");
}
}
function set_download_image(n) {
if (!rollovers) init_rollovers();
the_download_button.src = rollovers[n].src;
}
setTimeout(init_rollovers, 400);
}
@a[href: "download/"
onmouseover: "set_download_image(1);"
onmouseout: "set_download_image(0);"]{
@img[id: "download_button" border: "0" src: img1
alt: "Download PLT Scheme" title: "Download PLT Scheme"]}}))

View File

@ -21,7 +21,7 @@
@span{@span[class: 'whatb]{Racket} is a programming language.})
(div class: 'aboutpane
(div class: 'panetitle "Start Quickly")
(div class: 'downloadbutton download-plt)
(div class: 'downloadbutton download-button)
(alts-panel
@; --- Each example here should be exactly 7 lines long ---
@; Candidates for initial example: ------------------------
@ -438,35 +438,6 @@
;; width: (round (* 3/2 425)) height: (round (* 3/2 344))]{
;; @param[name: "movie" value: url]}}))
(define download-plt
(let ([img1 (copyfile (in-here "download.png"))]
[img2 (copyfile (in-here "download-dark.png"))])
(list
@script/inline[type: "text/javascript"]{
@; Don't load all images here -- it causes a delay when loading the page
@; instead, do it only when needed, and also set a timer to do it after
@; loading the page. This makes it so that there's almost never a delay
@; when loading the page, and also no delay when switching the image.
var rollovers = false, the_download_button = false;
function init_rollovers() {
if (!rollovers) {
rollovers = [ new Image(), new Image() ];
rollovers[0].src = "@img1";
rollovers[1].src = "@img2";
the_download_button = document.getElementById("download_button");
}
}
function set_download_image(n) {
if (!rollovers) init_rollovers();
the_download_button.src = rollovers[n].src;
}
setTimeout(init_rollovers, 400);
}
@a[href: "download/"
onmouseover: "set_download_image(1);"
onmouseout: "set_download_image(0);"]{
@img[id: "download_button" border: "0" src: img1
alt: "Download PLT Scheme" title: "Download PLT Scheme"]})))
;; resources that are specific to the front page