Giter VIP home page Giter VIP logo

mozilla-infobar's Introduction

mozilla-infobar

This is the home of the Mozilla, Firefox Update, and Translation Bars. These bars, in the first case, provide an easy way to let your users know that there is a newer version of Firefox available, and that they should upgrade.

In the second instance, it enables you to notify your users when the current page they are viewing, is available in their preferred language.

Getting the InfoBar

There are three ways to get the code.

Using Git

First step is to clone the project.

git clone [email protected]:mozilla/mozilla-infobar.git

Once the above operation has finished, you need to copy the following files to your project in the appropriate directories.

css/infobar.css
js/infobar.js

For additional information on using Bower packages see the Bower documentation.

Using Bower

You can also install it as a Bower package

bower install moziila-infobar

Using the InfoBar

Once you have the code, add the following two lines before the closing body tag of your main project page.

<!-- You can of course use any CDN of you choice or serve it from your own server -->
<script src="http://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="/js/infobar.js"></script>

Next include the HTML for the InfoBar anywhere inside the HTML of your document. As it is positioned absolutely, placing this at the end of your main content will work.

<div id="mozilla-infobar" class="mozilla-infobar infobar-hidden" role="dialog" aria-hidden="true">
  <p></p>
  <ul>
    <li><button class="btn-accept" type="button"></button></li>
    <li><button class="btn-cancel" type="button"></button></li>
  </ul>
</div>

There is an imporant attribute missing from the above, and without it, the InfoBar will not work. The attribute in question here is the data-infobar attribute. This attribute can have one, or both, of two possible values, update and translate. For example:

<div ... data-infobar="update">

The above will trigger the Update Bar to be shown if the current user is using a version of Firefox that is two major versions older than the latest release version.

If the value above is translate, it will show the Translation Bar based on the precense of some additional elements as described later. You can also specify both, as such:

<div ... data-infobar="update translate">

The order here is important, as both InfoBar elements will never be shown simultaneously. In the scenario above, the first time the page is loaded, the Update Bar will be run. Once the user has taken either of the available actions, the Translation Bar will be shown on subsequent page loads.

NOTE: Once a user has taken either of the available actions, that InfoBar will not be shown again for the duration of the user's session. Should they close the current tab/window and come back to said page, the bar will be shown again, if the user's browser is, either still out of date or, they are accessing the page in a locale other than their preferred, as applicable.

Translation Bar Usage Specifics

As mentioned above, the Translation Bar has some additional requirements in order to function. Over and above the already detailed requirements, the Translation Bar will look for either link elements with the hreflang attribute or a select element with an id attribute of page-language-select.

In the first instance, you would add link elements to the head of your document. For example:

<link rel="alternate" hreflang="es-ES" href="http://www.mozilla.org/es-ES/firefox/new/" title="English (US)" />
<link rel="alternate" hreflang="fr" href="http://www.mozilla.org/fr/firefox/new/" title="Français" />

These list the alternate languages the current page is available in, as well as the URL to redirect the user to. For smaller websites, or those only supporting a small selection of locales, hard coding these may be an option. Should your site support many locales, it would be wise to investigate generating these link elements using a server side language, coupled with template tags if required.

The alternative is to make use of a language selector, using a select element.

NOTE: This option will also require server side logic to redirect the user to the approrpiate page based on the value of the lang parameter passed.

<form id="lang_form" method="get" action="#">
  <label for="page-language-select">Other languages:</label>
  <select id="page-language-select" name="lang" dir="ltr">
    <option value="en-US" selected="" lang="en-US">English</option>
    <option value="eo" lang="eo">Esperanto</option>
    <option value="es-AR" lang="es-AR">Español (de Argentina)</option>
  </select>
  <noscript>
    <button type="submit">Go</button>
  </noscript>
</form>

mozilla-infobar's People

Contributors

alexgibson avatar jpetto avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mozilla-infobar's Issues

JSHint

Make JSHint part of the test task and also hook this task up to Travis so it is run when a pull request is opened.

Wiki changes

FYI: The following changes were made to this repository's wiki:

  • defacing spam has been removed

  • the wiki has been disabled, as it was not used

These were made as the result of a recent automated defacement of publically writeable wikis.

Improve README

Currently the README is a little unclear, especially about the translation bar. It needs additional information added to explain server interaction related to ways to generate the <link> elements or build the options for the '` element. It can also include some alternative options for small sites that does not have a lot of pages and/or supported locales.

contribute.json

This repo needs a contribute.json [https://github.com/mozilla/contribute.json] file.

Add updates based on changes from Bedrock

Learned some lessons when using this in practice on Bedrock. There are some JS and CSS changes that needs to be incorporated back into this repo from the work there.

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

Unit tests no functional

Currently due to some changes to the infobar.js file, the unit tests has stopped working. I is important to get these running as soon as possible.

Factor out Grunt

Currently tasks are run using Grunt. We can have a much lighter footprint and ease of use by factoring this dependency out in favor of npm scripts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.