diff --git a/apps/mozorg/helpers.py b/apps/mozorg/helpers.py index 32e29eb027..441360294a 100644 --- a/apps/mozorg/helpers.py +++ b/apps/mozorg/helpers.py @@ -10,6 +10,7 @@ of terms and example values for them: """ from os import path +import re import jinja2 import jingo @@ -211,3 +212,23 @@ def field_with_attrs(bfield, **kwargs): fields from django forms""" bfield.field.widget.attrs.update(kwargs) return bfield + +@jingo.register.function +def platform_img(url, **kwargs): + attrs = ' '.join(('%s="%s"' % (attr, val) + for attr, val in kwargs.items())) + url = path.join(settings.MEDIA_URL, url.lstrip('/')) + (root, ext) = path.splitext(url) + + def url(plat): + return '%s%s%s' % (root, + {'win': '', + 'osx': '-mac', + 'linux': '-linux'}[plat], + ext) + + imgs = ('' + % (plat, url(plat), attrs) + for plat in ('win', 'osx', 'linux')) + + return jinja2.Markup(''.join(imgs)) diff --git a/apps/mozorg/templates/mozorg/firefox/customize.html b/apps/mozorg/templates/mozorg/firefox/customize.html index 30299590ce..72ff0ed79f 100644 --- a/apps/mozorg/templates/mozorg/firefox/customize.html +++ b/apps/mozorg/templates/mozorg/firefox/customize.html @@ -122,8 +122,7 @@

Plugins are small bits of third-party software built by companies like Adobe Systems or Apple to power videos, animation and games (examples include Flash Player or Quicktime). They can cause browser crashes or pose security risks when they get out of date, so we’ve built an easy tool to help you stay current. Check your plugins.

- - Make It Work: Plugins + {{ platform_img('img/firefox/customize/make-it-work.png', alt='Make It Work: Plugins') }}
diff --git a/media/css/sandstone/sandstone.less b/media/css/sandstone/sandstone.less index ca08572c47..7a625a6cf7 100644 --- a/media/css/sandstone/sandstone.less +++ b/media/css/sandstone/sandstone.less @@ -657,3 +657,21 @@ px 68 160 252 344 436 */ } /* }}} */ + + + +/* {{{ Firefox site functionality + This can be put into its own CSS file if needed. */ + +.platform-img { + display: none; +} + +.osx img.osx, +.mac img.osx, +.linux img.linux, +.win img.win { + display: inline; +} + +/* }}} */ diff --git a/media/js/site.js b/media/js/site.js new file mode 100644 index 0000000000..8918fe73c6 --- /dev/null +++ b/media/js/site.js @@ -0,0 +1,36 @@ + +(function() { + var site = { + platform: 'windows' + }; + + if(navigator.platform.indexOf("Win32") != -1 || + navigator.platform.indexOf("Win64") != -1) { + site.platform = 'windows'; + } + else if(navigator.platform.indexOf("Linux") != -1) { + site.platform = 'linux'; + } + else if (navigator.userAgent.indexOf("Mac OS X") != -1) { + site.platform = 'osx'; + } + else if (navigator.userAgent.indexOf("MSIE 5.2") != -1) { + site.platform = 'osx'; + } + else if (navigator.platform.indexOf("Mac") != -1) { + site.platform = 'mac'; + } + else { + site.platform = 'other'; + } + + function init() { + var b = $(document.body); + // Remove the default platform + b.removeClass('win'); + b.addClass(site.platform); + } + + $(document).ready(init); + window.site = site; +})(); diff --git a/settings/base.py b/settings/base.py index d6600f44ff..b4507bbd30 100644 --- a/settings/base.py +++ b/settings/base.py @@ -110,9 +110,11 @@ MINIFY_BUNDLES = { ), 'common': ( 'js/libs/jquery-1.7.1.min.js', + 'js/site.js', ), 'firefox': ( 'js/libs/jquery-1.7.1.min.js', + 'js/site.js', 'js/nav-main.js', ), 'firefox-customize': ( diff --git a/templates/base.html b/templates/base.html index 20da662e1e..1b65890e40 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,7 +23,9 @@ - + +