Rewrite contributions #848

Merged
merged 8 commits into from Sep 12, 2016

Conversation

Projects
None yet
2 participants
Owner

nottrobin commented Sep 12, 2016

Completely rewrite contributions HTML, CSS and JavaScript to:

  • Remove dependency on YUI
  • Use native HTML5 sliders (<input type=range>)
  • Use tidier BEM-based styling

Rather than implementing sliders entirely myself with JavaScript, I'm using the HTML5 "range" input type, a faster and more robust solution. For browsers that don't support the "range" type, I'm simply hiding sliders.

Note, sliders no longer have orange on one side and white on the other, as they used to. I'm not sure if this is possible with the styling options for the "range" type, but anyway it would introduce significant complexity which I'd rather not do.

QA

make run

Visit http://127.0.0.1:8001/download/desktop/contribute?version=16.04.1&architecture=amd64 and check:

  • The sliders look acceptable
  • As you slide the sliders, the numbers change, the total updates, and the "The same price as" changes
  • The same as you change the numbers, either by typing new numbers or using the arrows in the number field
  • The total is accurate
  • The boundaries for the items in "The same price as" section are the same as they were
  • If you reduce the contribution to zero, both "Pay with paypal" and "Not now, take me to the download ›" disappear, and instead you see "Download Ubuntu Desktop"
  • If you increase the contribution above zero, everything returns to normal
  • Clicking "Pay with Paypal" takes you to paypal for the correct amount
  • Clicking "Not now..." takes you to thank you page and starts download

Then turn off JavaScript, reload the page, and check:

  • Sliders are not visible - this will also be the experience of people with browsers that don't support <input type=range>.
  • "The same price as" row is not visible (as this requires JavaScript to work)
  • The form is still usable
  • You can still submit a contribution through paypal

Turn JavaScript back on, visit http://127.0.0.1:8001/download/desktop/contribute. Check:

  • "Not now..." link isn't there (as we aren't downloading anything specific)
  • When you reduce amount to zero, "Pay with Paypal" button is disabled

@pmahnke pmahnke self-assigned this Sep 12, 2016

@nottrobin nottrobin added this to the HTTPS milestone Sep 12, 2016

Contributor

pmahnke commented Sep 12, 2016

Errors

  • if you put in 0, you can't see the text of the button, on live, it just says 'Download'
    image
  • if you put in a really high number, you don't have an item
    image
  • firefox 47.01 and 48.02 doesn't have sliders?
    image
  • safari 9.1.3
    image
  • on ff and safari - '"The same price as" row is not visible (as this requires JavaScript to work)' I am seeing these areas
    image
  • 'You can still submit a contribution through paypal' however you can't use PayPal without JS
    image
  • when I turned js on ff again, and reloaded, the bottom sections don't update (total or comparator)
    image
Owner

nottrobin commented Sep 12, 2016

@pmahnke I can't check Safari from here, but hopefully those issues were for the same reasons as the firefox issues - JavaScript errors because NodeList.forEach didn't exist.

I've now fixed everything else. If you don't have JavaScript this is now what you see:

nojs

And if you go to http://127.0.0.1:8001/download/desktop without JavaScript and click "Download" you should go straight to the download and bypass the contribute page.

Could you please verify it all looks good?

nottrobin added some commits Sep 12, 2016

Rewrite contributions
Completely rewrite contributions HTML, CSS and JavaScript to:

- Remove dependency on YUI
- Use native HTML5 sliders (input type=range)
- Use tidier BEM-based styling
Remove NodeList.forEach calls
Apparently only Chrome supports NodeLide.forEach (although most browsers support Array.forEach). So lets use old fashioned for loops.
Skip contribute if no javascript
Since contribute page is useless without JavaScript, only link to it as part of the download journey if you have JavaScript enabled.
Add nojs message to contribute
contribute won't work without JavaScript, because of PayPal. So hide everything and display a message.
Always show an equivalent item
Even if you enter hundreds of thousands of points, incorrectly claim it's the same amount as a camel.
Fix scratch.js error
Add forEach polyfill and enable polyfills.js sitewide to fix scratch.js error.
Contributor

pmahnke commented Sep 12, 2016

Great work 👍

@nottrobin nottrobin merged commit e84fc95 into canonical-websites:master Sep 12, 2016

@nottrobin nottrobin deleted the nottrobin:contributions-updates branch Sep 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment