mozilla/bedrock — Issue #4: Get basic download button working
Author: jlongster
Created: 2011-10-11 22:13:32+00:00
State: open

A little documentation after reviewing the mozilla.com source:

The download button is an absolute messy mix of PHP and javascript.

Every button calls `getNoScriptBlockForLocale` on the firefoxDetails object which dumps out markup for people with Javascript disabled.

For javascript users, there are two versions of the download button:

1. One that uses download.old.js, and simply dumps a block of javascript on the page to render the button (using a large template string and a bunch of document.write's). download.old.js depends on a big javascript object being dumped by the productDetails object containing details about the versions.

2. The other one uses download.js (which seems to be a newer version) and calls `getDownloadBlockForLocale` which dumps out javascript that calls into download.js functions. The difference seems to be that it dumps all the needed info into the js inline.

The productDetails class is 1000 lines long with a bunch of functions that mostly just dump HTML to render different ways of downloading Firefox.

This will be one of hardest things to migrate, I think. I don't think it will be possible to do this without cleaning up a lot of it. My hunch is to build a javascript library on top of the json files in product-details (that other projects use). The json can be dumped onto the page and the client-side javascript can take care of the rest. For the javascript disabled, we can build a light jinja helper which dumps out the markup that we do now.