maps.nyc.gov

Class: Lang

nyc.Lang

new Lang(options)

Class for language translation using the Google Translate Gadget
Parameters:
Name Type Description
options nyc.Lang.Options Constructor options
Source:

Extends

Members

(static) EventType :string

Enumeration for nyc.Lang event types
Type:
  • string
Properties:
Name Type Description
READY string The ready event type
CHANGE string The change event type
Source:

Methods

init()

Initializes the class on callback from the Google Translate Gadget loader
Source:

lang() → {string}

Get the currently chosen language code
Source:
Returns:
The currently chosen language code
Type
string

off(eventName, evtHdlr, hdlrScopeopt)

Remove a previously connected event handler
Parameters:
Name Type Attributes Description
eventName string The name of the event to which the handler will be connected
evtHdlr function The event handler function
hdlrScope Object <optional>
The scope in which to invoke the event handler
Inherited From:
Source:

on(eventName, evtHdlr, hdlrScopeopt)

Connect a function to an event
Parameters:
Name Type Attributes Description
eventName string The name of the event to which the handler will be connected
evtHdlr function The event handler function
hdlrScope Object <optional>
The scope in which to invoke the event handler
Inherited From:
Source:

one(eventName, evtHdlr, hdlrScopeopt)

Connect a function to an event for a single invocation
Parameters:
Name Type Attributes Description
eventName string The name of the event to which the handler will be connected
evtHdlr function The event handler function
hdlrScope Object <optional>
The scope in which to invoke the event handler
Inherited From:
Source:

trigger(eventName, dataopt)

Trigger a named event with event data
Parameters:
Name Type Attributes Description
eventName string The name of the event to trigger
data Object <optional>
The event data
Inherited From:
Source:

Type Definitions

Choice

A language choice for nyc.Lang.Choices
Type:
  • Object
Properties:
Name Type Attributes Description
val string The language value used by Google
desc string The display value for the language
hint string <optional>
The translation of the word 'Translate' in the language
Source:

Choices

A mapping of nyc.Lang.Choice objects to language codes
Type:
Source:
Example
{
	en: {val: 'English', desc: 'English', hint: 'Translate'},
	es: {val: 'Spanish', desc: 'Espa&#241;ol', hint: 'Traducir'}
}

Options

Constructor for nyc.Lang
Type:
  • Object
Properties:
Name Type Attributes Default Description
target String | Element | JQuery The HTML DOM element that will provide language choices
languages nyc.Lang.Choices The languages to provide
isButton boolean <optional>
false Show as a button
showArrow boolean <optional>
false Show the hint arrow if displaying as a button
Source:

Events

change

The language value has changed
Type:
  • string
Source:

ready

The class has completed initialization
Type:
  • boolean
Source: