angular-timezone-selector

WebJar for angular-timezone-selector

License

License

MIT
Categories

Categories

Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

angular-timezone-selector
Last Version

Last Version

1.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

angular-timezone-selector
WebJar for angular-timezone-selector
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mishguruorg/angular-timezone-selector

Download angular-timezone-selector

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/angular-timezone-selector/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>angular-timezone-selector</artifactId>
    <version>1.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/angular-timezone-selector/
implementation 'org.webjars.bower:angular-timezone-selector:1.6.0'
// https://jarcasting.com/artifacts/org.webjars.bower/angular-timezone-selector/
implementation ("org.webjars.bower:angular-timezone-selector:1.6.0")
'org.webjars.bower:angular-timezone-selector:jar:1.6.0'
<dependency org="org.webjars.bower" name="angular-timezone-selector" rev="1.6.0">
  <artifact name="angular-timezone-selector" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='angular-timezone-selector', version='1.6.0')
)
libraryDependencies += "org.webjars.bower" % "angular-timezone-selector" % "1.6.0"
[org.webjars.bower/angular-timezone-selector "1.6.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.webjars.bower : jstzdetect jar jsTimezoneDetect#~1.0.6
org.webjars.bower : angular jar [1.3.8,1.4)
org.webjars.bower : moment-timezone jar [0.4.0,0.5)
org.webjars.bower : chosen jar [1.4.2,1.5)
org.webjars.bower : moment jar [2.10.3,2.11)
org.webjars.bower : bootstrap jar [3.3.4,3.4)
org.webjars.bower : lodash jar 4.0.1

Project Modules

There are no modules declared in this project.

(Ready Only)

This repository is in a read only state - but creating a fork is always an option.

Timezone selector for Angular JS

A simple AngularJS directive to create timezone select. It uses chosen to create auto-complete timezone select. Timezone information comes from moment. Countries timezone data comes from TimezoneDB.

The user is able to choose their timezone by either typing the name of their country, or the name of the timezone directly.

The angular model that is bound to this directive will be set to the timezone name as used by moment-timezone i.e Pacific/Auckland.

View Demo

Plunker Example

Contributing

If you have a feature or fix please submit a pull request! This repo follows JavaScript standard style, please make sure all pull requests comply to this before submitting them.

js-standard-style

Usage

Install using bower

bower install angular-timezone-selector

Make your Angular module depend on module angular-timezone-selector.

angular.module('timezoneSelectExample', ['angular-timezone-selector']);

Then use directive timezone-selector.

<timezone-selector ng-model="timezone">

Options

Options can be included as attributes in the html element.

  • sort-by ["offset"] - This lets the list be sorted by UTC offset instead of alphabetical order.
  • display-utc ["true"] - This show UTC offsets in the timezone names
  • show-local ["true"] - This detects local timezone's and includes at the top. If jsTimezoneDetect is installed if will include the detected timezone otherwise it fallback on moment js and list all timezones with the same browsers UTC offset.
  • set-local ["true"] - This sets ngModel to detected timezone if it's not set yet. jsTimezoneDetect must be installed for this option to work.
  • primary-choices ["space seperated timezone names"] - This lets you put important timezone's at the top of the list or include extra aliases. Use names from momentjs-timezone, which you can list with the command: moment.tz.names;.
  • width - Sets the width of the element

An example of using the options is below:

<timezone-selector
    ng-model="timezone"
    display-utc="true"
    sort-by="offset"
    show-local="true"
    set-local="true"
    primary-choices="UTC GB WET GMT Asia/Macau"
    width="400px"
></timezone-selector>

Screenshot

The screenshot below show angular-selector in action with all options enabled:

Custom placeholder:

An example of using a custom placeholder message:

<div ng-init="translations.placeholder = 'SeLecT your timezone :)'">
    <timezone-selector
        ng-model="result"
        translations="translations"
        display-utc="true"
        sort-by="offset"
        show-local="true"
        primary-choices="UTC GB WET GMT Asia/Macau"
        name="timezone"
        required>
    </timezone-selector>
</div>

or with translate:

<div ng-init="translations.placeholder = ('TIMEZONE_PLACEHOLDER' | translate)">
    <timezone-selector
        ng-model="result"
        translations="translations"
        display-utc="true"
        sort-by="offset"
        show-local="true"
        primary-choices="UTC GB WET GMT Asia/Macau"
        name="timezone"
        required>
    </timezone-selector>
</div>

Author

Ashok Fernandez

With Thanks To

M Clark for adding options for primary & local timezones, and the ability to show and sort by offset.

a-k-g for fixing syntax error in data file and reminding me to update the bower tags!

Tom Grooffer for fixing a crash with JSTZ

karlhaas for fixing a crash when two instances were present on the same page and adding injectable strings and translations

G-Lex for adding the ability to set the width when creating the directive

Gu1 for making sure that moment was properly injected

tiagotex for adding the ability to set the local timezone as default, and fixing a bug where primary timezones with spaces wouldn't work

Rémy Dufour for adding Montreal as a timezone

Akiko Takano for adding more translation support

Attributions

Inspired by angular-timezone-select from alexcheng1982.

Styled using the examples from bootstrap-chosen by alxlit

org.webjars.bower

Mish Guru

Versions

Version
1.6.0
1.2.1
1.2.0
1.0.4