Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
fix(browser support): add IE11 - 10 - 9 support
Browse files Browse the repository at this point in the history
+ document browser support
  • Loading branch information
vvo committed May 13, 2016
1 parent bcadf6b commit 0365683
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
3 changes: 1 addition & 2 deletions docs/source/layouts/bootstrap.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
<!-- Always force latest IE rendering engine or request Chrome Frame -->
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Algolia Places | No style test</title>
<%= javascript_include_tag config[:places_lib_url] %>
<style>
body {
font-family: Sans;
padding: 3em;
}
</style>
Expand Down
13 changes: 13 additions & 0 deletions docs/source/partials/documentation.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,19 @@ Once you do so, the default `algolia-places` class name will turn into `algolia-

See our [styling examples](./examples.html#input-styling).

## Browser support

Algolia Places comes with native support for all current
major browsers: Chrome, Firefox, Edge, Opera and Safari.

It also works natively on Internet Explorer 11 and 10.

To support Internet Explorer 9, you need to include a polyfill for
[Element.classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList).

To do so, you can use the [Polyfill.io service](https://cdn.polyfill.io/v2/docs/).


## Rate limits

Algolia Places enforces a default limit of **1,000 requests per hour and per IP** for free usage. You can contact us by <a href="mailto:[email protected]">e-mail</a> if you need more.
Expand Down
3 changes: 2 additions & 1 deletion src/findCountryCode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default function findCountryCode(tags) {
for (const tag of tags) {
for (let tagIndex = 0; tagIndex < tags.length; tagIndex++) {
const tag = tags[tagIndex];
const find = tag.match(/country\/(.*)?/);
if (find) {
return find[1];
Expand Down
3 changes: 2 additions & 1 deletion src/findType.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default function findType(tags) {
const types = ['country', 'city', 'address'];

for (const type of types) {
for (let typeIndex = 0; typeIndex < types.length; typeIndex++) {
const type = types[typeIndex];
if (tags.indexOf(type) !== -1) {
return type;
}
Expand Down
17 changes: 17 additions & 0 deletions src/navigatorLanguage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// polyfill for navigator.language (IE <= 10)
// not polyfilled by https://cdn.polyfill.io/v2/docs/

// Defined: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage
// with allowable values at http://www.ietf.org/rfc/bcp/bcp47.txt
// Note that the HTML spec suggests that anonymizing services return "en-US" by default for
// user privacy (so your app may wish to provide a means of changing the locale)
if (!('language' in navigator)) {
navigator.language =
// IE 10 in IE8 mode on Windows 7 uses upper-case in
// navigator.userLanguage country codes but per
// http://msdn.microsoft.com/en-us/library/ie/ms533052.aspx (via
// http://msdn.microsoft.com/en-us/library/ie/ms534713.aspx), they
// appear to be in lower case, so we bring them into harmony with navigator.language.
(navigator.userLanguage && navigator.userLanguage.replace(/-[a-z]{2}$/, String.prototype.toUpperCase)) ||
'en-US'; // Default for anonymizing services: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#navigatorlanguage
}
1 change: 1 addition & 0 deletions src/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import EventEmitter from 'events';
import algoliasearch from 'algoliasearch/lite';
import autocomplete from 'autocomplete.js';

import './navigatorLanguage.js';
import defaultTemplates from './defaultTemplates.js';
import formatHit from './formatHit.js';
import version from './version.js';
Expand Down

0 comments on commit 0365683

Please sign in to comment.