[gimp-web/testing] Start to implement a downloads platform switcher



commit c3664b19fe2f18b94f4736edc702860f39ee3ca1
Author: Michael Schumacher <schumaml gmx de>
Date:   Wed Jul 29 00:10:28 2015 +0200

    Start to implement a downloads platform switcher

 downloads/index.htrw |    1 +
 includes/wgo.js      |   42 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/downloads/index.htrw b/downloads/index.htrw
index 07c58a0..e1b1392 100644
--- a/downloads/index.htrw
+++ b/downloads/index.htrw
@@ -15,6 +15,7 @@ $(document).ready(function() {
 
 <div id="downloads">
        <noscript>
+               Go to the downloads for <a href=#linux">GNU/Linux</a> <a href="#mac">OS X</a> <a 
href="#windows">Microsoft Windows</a></br>
                <!--#include virtual="/downloads/Linux.html"   -->
                <!--#include virtual="/downloads/Mac.html"     -->
                <!--#include virtual="/downloads/Windows.html" -->
diff --git a/includes/wgo.js b/includes/wgo.js
index b979e4c..d7089db 100644
--- a/includes/wgo.js
+++ b/includes/wgo.js
@@ -26,22 +26,50 @@ function mangleforOpera() {
 //provide download page depending on OS
 function renderDownload(platform) {
 
-    $("#downloads").html("<div id=\"os\">&nbsp;</div>\n<div id=\"moreos\"></div>\n<hr />\n<div 
id=\"source\">&nbsp;</div>\n");
+    $("#downloads").html("<div id=\"moreos\"></div>\n<div id=\"os\">&nbsp;</div>\n<hr />\n<div 
id=\"source\">&nbsp;</div>\n");
+    $("#moreos").html("Show downloads for   <a href=\"javascript:renderDownload('oslinux');\">GNU/Linux</a>
+                                          | <a href=\"javascript:renderDownload('osmac');\">OS X</a>
+                                          | <a href=\"javascript:renderDownload('oswindows');\">Microsoft 
Windows</a>
+                                          | <a href=\"javascript:renderDownload('all');\">All</a>");
 
+    // always have all the divs
+    $("#os").html("<div id=\"oslinux\"></div>\n<div id=\"osmac\"></div>\n<div id=\"oswindows\"></div>\n");
+
+    // decide which one to show
     if (platform == undefined) {
-       $("#os").load($.browser.OS + ".html"); // OS specific (autodetected)
-       $("#moreos").html("<a href=\"javascript:renderDownload('all');\">Show other downloads</a>");
+       platform    = "os" + $.browser.OS.toLowerCase();
+       platformdiv = "#" + platform;
     }
-    else if (platform == "all") {
-       $("#os").html("<div id=\"oslinux\"></div>\n<div id=\"osmac\"></div>\n<div id=\"oswindows\"></div>\n");
+
+    // load contents if necessary
+    if ( $("#oslinux").is(':empty') ) {
        $("#oslinux").load("Linux.html");
+    }
+
+    if ( $("#osmac").is(':empty') ) {
        $("#osmac").load("Mac.html");
+    }
+
+    if ( $("#oswindows").is(':empty') ) {
        $("#oswindows").load("Windows.html");
     }
+
+    if (platform == "all") {
+       $("#oslinux").show();
+       $("#osmac").show();
+       $("#oswindows").show();
+    }
     else
     {
-       $("#os").load(platform + ".html"); // OS specific (manual)
-       $("#moreos").html("<a href=\"javascript:renderDownload('all');\">Show other downloads</a>");
+       $('#os').each(function() {
+           if ($(this).attr('id') != 'os' && $(this).attr('id') != platform) {
+               $(this.hide();
+           } else {
+               $(this).show();
+           };
+       });
+
+
     }
 
     $("#source").load("source.html"); //sources for all


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]