diff --git a/Definitions/angular-1.0.2.d.ts b/Definitions/angular-1.0.d.ts similarity index 100% rename from Definitions/angular-1.0.2.d.ts rename to Definitions/angular-1.0.d.ts diff --git a/Definitions/angular-cookies-1.0.2.d.ts b/Definitions/angular-cookies-1.0.d.ts similarity index 100% rename from Definitions/angular-cookies-1.0.2.d.ts rename to Definitions/angular-cookies-1.0.d.ts diff --git a/Definitions/angular-mocks-1.0.2.d.ts b/Definitions/angular-mocks-1.0.d.ts similarity index 100% rename from Definitions/angular-mocks-1.0.2.d.ts rename to Definitions/angular-mocks-1.0.d.ts diff --git a/Definitions/angular-resource-1.0.2.d.ts b/Definitions/angular-resource-1.0.d.ts similarity index 100% rename from Definitions/angular-resource-1.0.2.d.ts rename to Definitions/angular-resource-1.0.d.ts diff --git a/Definitions/angular-sanitize-1.0.2.d.ts b/Definitions/angular-sanitize-1.0.d.ts similarity index 100% rename from Definitions/angular-sanitize-1.0.2.d.ts rename to Definitions/angular-sanitize-1.0.d.ts diff --git a/Definitions/backbone-0.9.d.ts b/Definitions/backbone-0.9.d.ts index 58370d36c..2838f4605 100644 --- a/Definitions/backbone-0.9.d.ts +++ b/Definitions/backbone-0.9.d.ts @@ -27,8 +27,7 @@ declare module Backbone { wait: bool; } - export class ModelBase { - bind(eventName: string, handler: Function, ctx?: any); + export class ModelBase extends Events { fetch(options? : ICallbackOptions); url: string; // or url(): string; parse(response); @@ -189,6 +188,7 @@ declare module Backbone { export var history: History; export class History { start(options? : IHistoryOptions ); + navigate(fragment: string, options: any); pushSate(); } diff --git a/Definitions/google.maps.d.ts b/Definitions/google.maps.d.ts index 8fdbf19d1..dffb71eeb 100644 --- a/Definitions/google.maps.d.ts +++ b/Definitions/google.maps.d.ts @@ -1,1512 +1,1531 @@ -/* -The MIT License - -Copyright (c) 2012 Folia A/S. http://www.folia.dk - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -declare module google.maps { - - /***** MVC *****/ - export class MVCObject { - constructor (); - bindTo(key: string, target: MVCObject, targetKey?: string, noNotify?: bool): void; - changed(key: string): void; - get(key: string): any; - notify(key: string): void; - set(key: string, value: any): void; - setValues(values: any): void; - setValues(values: undefined); - unbind(key: string): void; - unbindAll(): void; - } - - export class MVCArray extends MVCObject { - constructor (array?: any[]); - clear(): void; - forEach(callback: (elem: any, index: number) => void ): void; - getArray(): any[]; - getAt(i: number): any; - getLength(): number; - insertAt(i: number, elem: any): void; - pop(): void; - push(elem: any): number; - removeAt(i: number): any; - setAt(i: number, elem: any): void; - } - - /***** Map *****/ - export class Map extends MVCObject { - constructor (mapDiv: Element, opts?: MapOptions); - fitBounds(bounds: LatLngBounds); - getBounds(): LatLngBounds; - getCenter(): LatLng; - getDiv(): Element; - getHeading(): number; - getMapTypeId(): MapTypeId; - getProjection(): Projection; - getStreetView(): StreetViewPanorama; - getTilt(): number; - getZoom(): number; - panBy(x: number, y: number): void; - panTo(latLng: LatLng): void; - panToBounds(latLngBounds: LatLngBounds): void; - setCenter(latlng: LatLng): void; - setHeading(heading: number): void; - setMapTypeId(mapTypeId: MapTypeId): void; - setOptions(options: MapOptions): void; - setStreetView(panorama: StreetViewPanorama): void; - setTilt(tilt: number): void; - setZoom(zoom: number): void; - } - - export interface MapOptions { - backgroundColor?: string; - center?: LatLng; - disableDefaultUI?: bool; - disableDoubleClickZoom?: bool; - draggable?: bool; - draggableCursor?: string; - draggingCursor?: string; - heading?: number; - keyboardShortcuts?: bool; - mapMaker?: bool; - mapTypeControl?: bool; - mapTypeControlOptions?: MapTypeControlOptions; - mapTypeId?: MapTypeId; - maxZoom?: number; - minZoom?: number; - noClear?: bool; - overviewMapControl?: bool; - overviewMapControlOptions?: OverviewMapControlOptions; - panControl?: bool; - panControlOptions?: PanControlOptions; - rotateControl?: bool; - rotateControlOptions?: RotateControlOptions; - scaleControl?: bool; - scaleControlOptions?: ScaleControlOptions; - scrollwheel?: bool; - streetView?: bool; - streetViewControlOptions?: StreetViewControlOptions; - styles?: MapTypeStyle[]; - tilt?: number; - zoom?: number; - zoomControl?: bool; - zoomControlOptions?: ZoomControlOptions; - } - - export enum MapTypeId { - HYBRID, - ROADMAP, - SATELLITE, - TERRAIN - } - - /***** Controls *****/ - export interface MapTypeControlOptions { - mapTypeIds?: MapTypeId[]; - position?: ControlPosition; - style?: MapTypeControlStyle; - } - - export enum MapTypeControlStyle { - DEFAULT, - DROPDOWN_MENU, - HORIZONTAL_BAR - } - - export interface OverviewMapControlOptions { - opened?: bool; - } - - export interface PanControlOptions { - position: ControlPosition; - } - - export interface RotateControlOptions { - position: ControlPosition; - } - - export interface ScaleControlOptions { - position?: ControlPosition; - style?: ScaleControlStyle; - } - - export enum ScaleControlStyle { - DEFAULT - } - - export interface StreetViewControlOptions { - position: ControlPosition; - } - - export interface ZoomControlOptions { - position?: ControlPosition; - style?: ZoomControlStyle; - } - - export enum ZoomControlStyle { - DEFAULT, - LARGE, - SMALL - } - - export enum ControlPosition { - BOTTOM_CENTER, - BOTTOM_LEFT, - BOTTOM_RIGHT, - LEFT_BOTTOM, - LEFT_CENTER, - LEFT_TOP, - RIGHT_BOTTOM, - RIGHT_CENTER, - RIGHT_TOP, - TOP_CENTER, - TOP_LEFT, - TOP_RIGHT - } - - /***** Overlays *****/ - export class Marker extends MVCObject { - constructor (opts?: MarkerOptions); - getAnimation(): Animation; - getClickable(): bool; - getCursor(): string; - getDraggable(): bool; - getFlat(): bool; - getIcon(): MarkerImage; - getMap(): Map; - getMap(): StreetViewPanorama; - getPosition(): LatLng; - getShadow(): MarkerImage; - getShape(): MarkerShape; - getTitle(): string; - getVisible(): bool; - getZIndex(): number; - setAnimation(animation: Animation): void; - setClickable(flag: bool): void; - setCursor(cursor: string): void; - setDraggable(flag: bool): void; - setFlat(flag: bool): void; - setIcon(icon: MarkerImage): void; - setIcon(icon: string): void; - setMap(map: Map): void; - setMap(map: StreetViewPanorama): void; - setOptions(options: MarkerOptions): void; - setPosition(latlng: LatLng): void; - setShadow(shadow: MarkerImage): void; - setShadow(shadow: string): void; - setShape(shape: MarkerShape): void; - setTitle(title: string): void; - setVisible(visible: bool): void; - setZIndex(zIndex: number): void; - } - - export interface MarkerOptions { - animation?: Animation; - clickable?: bool; - cursor?: string; - draggable?: bool; - flat?: bool; - icon?: any; - map?: any; - optimized?: bool; - position?: LatLng; - raiseOnDrag?: bool; - shadow?: any; - shape?: MarkerShape; - title?: string; - visible?: bool; - zIndex?: number; - } - - export class MarkerImage { - constructor (url: string, size?: Size, origin?: Point, anchor?: Point, scaledSize?: Size); - anchor: Point; - origin: Point; - scaledSize: Size; - size: Size; - url: string; - } - - export interface MarkerShape { - coords?: number[]; - type?: string; - } - - export interface Symbol { - anchor?: Point; - fillColor?: string; - fillOpacity?: number; - path?: any; - rotation?: number; - scale?: number; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - } - - export enum SymbolPath { - BACKWARD_CLOSED_ARROW, - BACKWARD_OPEN_ARROW, - CIRCLE, - FORWARD_CLOSED_ARROW, - FORWARD_OPEN_ARROW - } - - export enum Animation { - BOUNCE, - DROP - } - - export class InfoWindow extends MVCObject { - constructor (opts?: InfoWindowOptions); - close(): void; - getContent(): string; - getContent(): Element; - getPosition(): LatLng; - getZIndex(): number; - open(map?: Map, anchor?: MVCObject): void; - open(map?: StreetViewPanorama, anchor?: MVCObject): void; - setContent(content: Node): void; - setContent(content: string): void; - setOptions(options: InfoWindowOptions): void; - setPosition(position: LatLng): void; - setZIndex(zIndex: number): void; - } - - export interface InfoWindowOptions { - content?: any; - disableAutoPan?: bool; - maxWidth?: number; - pixelOffset?: Size; - position?: LatLng; - zIndex?: number; - } - - export class Polyline extends MVCObject { - constructor (opts?: PolylineOptions); - getEditable(): bool; - getMap(): Map; - getPath(): MVCArray[]; - getVisible(): bool; - setEditable(editable: bool): void; - setMap(map: Map): void; - setOptions(options: PolylineOptions): void; - setPath(path: MVCArray[]): void; - setPath(path: LatLng[]): void; - setVisible(visible: bool): void; - } - - export interface PolylineOptions { - clickable?: bool; - editable?: bool; - geodesic?: bool; - icons?: IconSequence[]; - map?: Map; - path?: any[]; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - visible?: bool; - zIndex?: number; - } - - export interface IconSequence { - icon?: Symbol; - offset?: string; - repeat?: string; - } - - export class Polygon extends MVCObject { - constructor (opts?: PolygonOptions); - getEditable(): bool; - getMap(): Map; - getPath(): MVCArray[]; - getPaths(): MVCArray[][]; - getVisible(): bool; - setEditable(editable: bool): void; - setMap(map: Map): void; - setOptions(options: PolygonOptions): void; - setPath(path: MVCArray[]): void; - setPath(path: LatLng[]): void; - setPaths(paths: MVCArray[]): void; - setPaths(paths: MVCArray[][]): void; - setPaths(path: LatLng[]): void; - setPaths(path: LatLng[][]): void; - setVisible(visible: bool): void; - } - - export interface PolygonOptions { - clickable?: bool; - editable?: bool; - fillColor?: string; - fillOpacity?: number; - geodesic?: bool; - map?: Map; - paths?: any[]; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - visible?: bool; - zIndex?: number; - } - - export interface PolyMouseEvent { - edge?: number; - path?: number; - vertex?: number; - } - - export class Rectangle extends MVCObject { - constructor (opts?: RectangleOptions); - getBounds(): LatLngBounds; - getEditable(): bool; - getMap(): Map; - getVisible(): bool; - setBounds(bounds: LatLngBounds): void; - setEditable(editable: bool): void; - setMap(map: Map): void; - setOptions(options: RectangleOptions): void; - setVisible(visible: bool): void; - } - - export interface RectangleOptions { - bounds?: LatLngBounds; - clickable?: bool; - editable?: bool; - fillColor?: string; - fillOpacity?: number; - map?: Map; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - visible?: bool; - zIndex?: number; - } - - export class Circle extends MVCObject { - constructor (opts?: CircleOptions); - getBounds(): LatLngBounds; - getCenter(): LatLng; - getEditable(): bool; - getMap(): Map; - getRadius(): number; - getVisible(): bool; - setCenter(center: LatLng): void; - setEditable(editable: bool): void; - setMap(map: Map): void; - setOptions(options: CircleOptions): void; - setRadius(radius: number): void; - setVisible(visible: bool): void; - } - - export interface CircleOptions { - center?: LatLng; - clickable?: bool; - editable?: bool; - fillColor?: string; - fillOpacity?: number; - map?: Map; - radius?: number; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - visible?: bool; - zIndex?: number; - } - - export class GroundOverlay extends MVCObject { - constructor (url: string, bounds: LatLngBounds, opts?: GroundOverlayOptions); - getBounds(): LatLngBounds; - getMap(): Map; - getOpacity(): number; - getUrl(): string; - setMap(map: Map): void; - setOpacity(opacity: number): void; - } - - export interface GroundOverlayOptions { - clickable?: bool; - map?: Map; - opacity?: number; - } - - export class OverlayView extends MVCObject { - draw(): void; - getMap(): Map; - getPanes(): MapPanes; - getProjection(): MapCanvasProjection; - onAdd(): void; - onRemove(): void; - setMap(map: Map): void; - setMap(map: StreetViewPanorama): void; - } - - export interface MapPanes { - floatPane: Element; - floatShadow: Element; - mapPane: Element; - overlayImage: Element; - overlayLayer: Element; - overlayMouseTarget: Element; - overlayShadow: Element; - } - - export class MapCanvasProjection extends MVCObject { - fromContainerPixelToLatLng(pixel: Point, nowrap?: bool): LatLng; - fromDivPixelToLatLng(pixel: Point, nowrap?: bool): LatLng; - fromLatLngToContainerPixel(latLng: LatLng): Point; - fromLatLngToDivPixel(latLng: LatLng): Point; - getWorldWidth(): number; - } - - /***** Services *****/ - export class Geocoder { - constructor (); - geocode(request: GeocoderRequest, callback: (results: GeocoderResult[], status: GeocoderStatus) => void ): void; - } - - export interface GeocoderRequest { - address: string; - bounds?: LatLngBounds; - location?: LatLng; - region?: string; - } - - export enum GeocoderStatus { - ERROR, - INVALID_REQUEST, - OK, - OVER_QUERY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR, - ZERO_RESULTS - } - - export interface GeocoderResult { - address_components: GeocoderAddressComponent[]; - formatted_address: string; - geometry: GeocoderGeometry; - types: string[]; - } - - export interface GeocoderAddressComponent { - long_name: string; - short_name: string; - types: string[]; - } - - export interface GeocoderGeometry { - bounds: LatLngBounds; - location: LatLng; - location_type: GeocoderLocationType; - viewport: LatLngBounds; - } - - export enum GeocoderLocationType { - APPROXIMATE, - GEOMETRIC_CENTER, - RANGE_INTERPOLATED, - ROOFTOP - } - - export class DirectionsRenderer extends MVCObject { - constructor (opts?: DirectionsRendererOptions); - getDirections(): DirectionsResult; - getMap(): Map; - getPanel(): Element; - getRouteIndex(): number; - setDirections(directions: DirectionsResult): void; - setMap(map: Map): void; - setOptions(options: DirectionsRendererOptions): void; - setPanel(panel: Element): void; - setRouteIndex(routeIndex: number): void; - } - - export interface DirectionsRendererOptions { - directions?: DirectionsResult; - draggable?: bool; - hideRouteList?: bool; - infoWindow?: InfoWindow; - map?: Map; - markerOptions?: MarkerOptions; - panel?: Element; - polylineOptions?: PolylineOptions; - preserveViewport?: bool; - routeIndex?: number; - suppressBicyclingLayer?: bool; - suppressInfoWindows?: bool; - suppressMarkers?: bool; - suppressPolylines?: bool; - } - - export class DirectionsService { - constructor (); - route(request: DirectionsRequest, callback: (result: DirectionsResult, status: DirectionsStatus) => void ): void; - } - - export interface DirectionsRequest { - avoidHighways?: bool; - avoidTolls?: bool; - destination?: any; - optimizeWaypoints?: bool; - origin?: any; - provideRouteAlternatives?: bool; - region?: string; - transitOptions?: TransitOptions; - travelMode?: TravelMode; - unitSystem?: UnitSystem; - waypoints?: DirectionsWaypoint[]; - } - - export enum TravelMode { - BICYCLING, - DRIVING, - TRANSIT, - WALKING - } - - export enum UnitSystem { - IMPERIAL, - METRIC - } - - export interface TransitOptions { - arrivalTime?: Date; - departureTime?: Date; - } - - export interface DirectionsWaypoint { - location: any; - stopover: bool; - } - - export enum DirectionsStatus { - INVALID_REQUEST, - MAX_WAYPOINTS_EXCEEDED, - NOT_FOUND, - OK, - OVER_QUERY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR, - ZERO_RESULTS - } - - export interface DirectionsResult { - routes: DirectionsRoute[]; - } - - export interface DirectionsRoute { - bounds: LatLngBounds; - copyrights: string; - legs: DirectionsLeg[]; - overview_path: LatLng[]; - warnings: string[]; - waypoint_order: number[]; - } - - export interface DirectionsLeg { - arrival_time: Distance; - departure_time: Duration; - distance: Distance; - duration: Duration; - end_address: string; - end_location: LatLng; - start_address: string; - start_location: LatLng; - steps: DirectionsStep[]; - via_waypoints: LatLng[]; - } - - export interface DirectionsStep { - distance: Distance; - duration: Duration; - end_location: LatLng; - instructions: string; - path: LatLng[]; - start_location: LatLng; - steps: DirectionsStep; - transit: TransitDetails; - travel_mode: TravelMode; - } - - export interface Distance { - text: string; - value: number; - } - - export interface Duration { - text: string; - value: number; - } - - export interface Time { - text: string; - time_zone: string; - value: Date; - } - - export interface TransitDetails { - arrival_stop: TransitStop; - arrival_time: Time; - departure_stop: TransitStop; - departure_time: Time; - headsign: string; - headway: number; - line: TransitLine; - num_stops: number; - } - - export interface TransitStop { - location: LatLng; - name: string; - } - - export interface TransitLine { - agencies: TransitAgency[]; - color: string; - icon: string; - name: string; - short_name: string; - text_color: string; - url: string; - vehicle: TransitVehicle; - } - - export interface TransitAgency { - name: string; - phone: string; - url: string; - } - - export interface TransitVehicle { - icon: string; - local_icon: string; - name: string; - type: string; - } - - export class ElevationService { - constructor (); - getElevationAlongPath(request: PathElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; - getElevationForLocations(request: LocationElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; - } - - export interface LocationElevationRequest { - locations: LatLng[]; - } - - export interface PathElevationRequest { - path?: LatLng[]; - samples?: number; - } - - export interface ElevationResult { - elevation: number; - location: LatLng; - resolution: number; - } - - export enum ElevationStatus { - INVALID_REQUEST, - OK, - OVER_QUERY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR - } - - export class MaxZoomService { - constructor (); - getMaxZoomAtLatLng(latlng: LatLng, callback: (result: MaxZoomResult) => void ): void; - } - - export interface MaxZoomResult { - status: MaxZoomStatus; - zoom: number; - } - - export enum MaxZoomStatus { - ERROR, - OK - } - - export class DistanceMatrixService { - constructor (); - getDistanceMatrix(request: DistanceMatrixRequest, callback: (response: DistanceMatrixResponse, status: DistanceMatrixStatus) => void ): void; - } - - export interface DistanceMatrixRequest { - avoidHighways?: bool; - avoidTolls?: bool; - destinations?: any[]; - origins?: any[]; - region?: string; - travelMode?: TravelMode; - unitSystem?: UnitSystem; - } - - export interface DistanceMatrixResponse { - destinationAddresses: string[]; - originAddresses: string[]; - rows: DistanceMatrixResponseRow[]; - } - - export interface DistanceMatrixResponseRow { - elements: DistanceMatrixResponseElement[]; - } - - export interface DistanceMatrixResponseElement { - distance: Distance; - duration: Duration; - status: DistanceMatrixElementStatus; - } - - export enum DistanceMatrixStatus { - INVALID_REQUEST, - MAX_DIMENSIONS_EXCEEDED, - MAX_ELEMENTS_EXCEEDED, - OK, - OVER_QUERY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR - } - - export enum DistanceMatrixElementStatus { - NOT_FOUND, - OK, - ZERO_RESULTS - } - - /***** Map Types *****/ - export interface MapType { - getTile(tileCoord: Point, zoom: number, ownerDocument: Document): Element; - releaseTile(tile: Element): void; - alt?: string; - maxZoom?: number; - minZoom?: number; - name?: string; - projection?: Projection; - radius?: number; - tileSize?: Size; - } - - export class MapTypeRegistry extends MVCObject { - constructor (); - set(id: string, mapType: MapType): void; - } - - export interface Projection { - fromLatLngToPoint(latLng: LatLng, point?: Point): Point; - fromPointToLatLng(pixel: Point, noWrap?: bool): LatLng; - } - - export class ImageMapType { - constructor (opts: ImageMapTypeOptions); - getOpacity(): number; - setOpacity(opacity: number): void; - } - - export interface ImageMapTypeOptions { - alt?: string; - getTileUrl: (Point, number) => string; - maxZoom?: number; - minZoom?: number; - name?: string; - opacity?: number; - tileSize?: Size; - } - - export class StyledMapType { - constructor (styles: MapTypeStyle[], options?: StyledMapTypeOptions); - } - - export interface StyledMapTypeOptions { - alt?: string; - maxZoom?: number; - minZoom?: number; - name?: string; - } - - export interface MapTypeStyle { - elementType?: MapTypeStyleElementType; - featureType?: MapTypeStyleFeatureType; - stylers?: MapTypeStyler[]; - } - - export interface MapTypeStyleFeatureType { - administrative?: { - country?: string; - land_parcel?: string; - locality?: string; - neighborhood?: string; - province?: string; - }; - all?: string; - landscape?: { - man_made?: string; - natural?: string; - }; - poi?: { - attraction?: string; - business?: string; - government?: string; - medical?: string; - park?: string; - place_of_worship?: string; - school?: string; - sports_complex?: string; - }; - road?: { - arterial?: string; - highway?: { - controlled_access?: string; - }; - local?: string; - }; - transit?: { - line?: string; - station?: { - airport?: string; - bus?: string; - rail?: string; - }; - }; - water?: string; - } - - export enum MapTypeStyleElementType { - all, - geometry, - labels - } - - export interface MapTypeStyler { - gamma?: number; - hue?: string; - invert_lightness?: bool; - lightness?: number; - saturation?: number; - visibility?: string; - } - - /***** Layers *****/ - export class BicyclingLayer extends MVCObject { - constructor (); - getMap(): Map; - setMap(map: Map): void; - } - - export class FusionTablesLayer extends MVCObject { - constructor (options: FusionTablesLayerOptions); - getMap(): Map; - setMap(map: Map): void; - setOptions(options: FusionTablesLayerOptions): void; - } - - export interface FusionTablesLayerOptions { - clickable?: bool; - heatmap?: FusionTablesHeatmap; - map?: Map; - query?: FusionTablesQuery; - styles?: FusionTablesStyle[]; - suppressInfoWindows?: bool; - } - - export interface FusionTablesQuery { - from?: string; - limit?: number; - offset?: number; - orderBy?: string; - select?: string; - where?: string; - } - - export interface FusionTablesStyle { - markerOptions?: FusionTablesMarkerOptions; - polygonOptions?: FusionTablesPolygonOptions; - polylineOptions?: FusionTablesPolylineOptions; - where?: string; - } - - export interface FusionTablesHeatmap { - enabled: bool; - } - - export interface FusionTablesMarkerOptions { - iconName: string; - } - - export interface FusionTablesPolygonOptions { - fillColor?: string; - fillOpacity?: number; - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - } - - export interface FusionTablesPolylineOptions { - strokeColor?: string; - strokeOpacity?: number; - strokeWeight?: number; - } - - export interface FusionTablesMouseEvent { - infoWindowHtml: string; - latLng: LatLng; - pixelOffset: Size; - row: Object; - } - - export interface FusionTablesCell { - columnName: string; - value: string; - } - - export class KmlLayer extends MVCObject { - constructor (url: string, opts?: KmlLayerOptions); - getDefaultViewport(): LatLngBounds; - getMap(): Map; - getMetadata(): KmlLayerMetadata; - getStatus(): KmlLayerStatus; - getUrl(): string; - setMap(map: Map): void; - } - - export interface KmlLayerOptions { - clickable?: bool; - map?: Map; - preserveViewport?: bool; - suppressInfoWindows?: bool; - } - - export interface KmlLayerMetadata { - author: KmlAuthor; - description: string; - name: string; - snippet: string; - } - - export enum KmlLayerStatus { - DOCUMENT_NOT_FOUND, - DOCUMENT_TOO_LARGE, - FETCH_ERROR, - INVALID_DOCUMENT, - INVALID_REQUEST, - LIMITS_EXCEEDED, - OK, - TIMED_OUT, - UNKNOWN - } - - export interface KmlMouseEvent { - featureData: KmlFeatureData; - latLng: LatLng; - pixelOffset: Size; - } - - export interface KmlFeatureData { - author: KmlAuthor; - description: string; - id: string; - infoWindowHtml: string; - name: string; - snippet: string; - } - - export interface KmlAuthor { - email: string; - name: string; - uri: string; - } - - export class TrafficLayer extends MVCObject { - constructor (); - getMap(): void; - setMap(map: Map): void; - } - - export class TransitLayer extends MVCObject { - constructor (); - getMap(): void; - setMap(map: Map): void; - } - - /***** Street View *****/ - export class StreetViewPanorama { - constructor (container: Element, opts?: StreetViewPanoramaOptions); - controls: MVCArray[]; - getLinks(): StreetViewLink[]; - getPano(): string; - getPosition(): LatLng; - getPov(): StreetViewPov; - getVisible(): bool; - registerPanoProvider(provider: (input: string) => StreetViewPanoramaData); - setPano(pano: string): void; - setPosition(latLng: LatLng): void; - setPov(pov: StreetViewPov): void; - setVisible(flag: bool): void; - - } - - export interface StreetViewPanoramaOptions { - addressControl?: bool; - addressControlOptions?: StreetViewAddressControlOptions; - clickToGo?: bool; - disableDoubleClickZoom?: bool; - enableCloseButton?: bool; - imageDateControl?: bool; - linksControl?: bool; - panControl?: bool; - panControlOptions?: PanControlOptions; - pano?: string; - panoProvider?: (input: string) => StreetViewPanoramaData; - position?: LatLng; - pov?: StreetViewPov; - scrollwheel?: bool; - visible?: bool; - zoomControl?: bool; - zoomControlOptions?: ZoomControlOptions; - } - - export interface StreetViewAddressControlOptions { - position: ControlPosition; - } - - export interface StreetViewLink { - description?: string; - heading?: number; - pano?: string; - } - - export interface StreetViewPov { - heading?: number; - picth?: number; - zoom?: number; - } - - export interface StreetViewPanoramaData { - opyright?: string; - imageDate?: string; - links?: StreetViewLink[]; - location?: StreetViewLocation; - tiles?: StreetViewTileData; - } - - export interface StreetViewLocation { - description?: string; - latLng?: LatLng; - pano?: string; - } - - export interface StreetViewTileData { - centerHeading?: number; - tileSize?: Size; - worldSize?: Size; - } - - export interface StreetViewService { - getPanoramaById(pano: string, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void ); - getPanoramaByLocation(latlng: LatLng, radius: number, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void ); - } - - export enum StreetViewStatus { - OK, - UNKNOWN_ERROR, - ZERO_RESULTS - } - - /***** Base *****/ - export class LatLng { - constructor (lat: number, lng: number, noWrap?: bool); - equals(other: LatLng): bool; - lat(): number; - lng(): number; - toString(): string; - toUrlValue(precision?: number): string; - - } - - export class LatLngBounds { - constructor (sw?: LatLng, ne?: LatLng); - contains(latLng: LatLng): bool; - equals(other: LatLngBounds): bool; - extend(point: LatLng): LatLngBounds; - getCenter(): LatLng; - getNorthEast(): LatLng; - getSouthWest(): LatLng; - intersects(other: LatLngBounds): bool; - isEmpty(): bool; - toSpan(): LatLng; - toString(): string; - toUrlValue(precision?: number): string; - union(other: LatLngBounds): LatLngBounds; - } - - export class Point { - constructor (x: number, y: number); - x: number; - y: number; - equals(other: Point): bool; - toString(): string; - } - - export class Size { - constructor (width: number, height: number, widthUnit?: string, heightUnit?: string); - height: number; - width: number; - equals(other: Size): bool; - toString(): string; - } - - /***** Geometry Library *****/ - export module geometry { - export class encoding { - static decodePath(encodedPath: string): LatLng; - static encodePath(path: any[]): string; - } - - export class spherical { - static computeArea(path: any[], radius?: number): number; - static computeDistanceBetween(from: LatLng, to: LatLng, radius?: number): number; - static computeHeading(from: LatLng, to: LatLng): number; - static computeLength(path: any[], radius?: number): number; - static computeOffset(from: LatLng, distance: number, heading: number, radius?: number): LatLng; - static computeSignedArea(loop: any[], radius?: number): number; - static interpolate(from: LatLng, to: LatLng, fraction: number): LatLng; - } - - export class poly { - containsLocation(point: LatLng, polygon: Polygon): bool; - isLocationOnEdge(point: LatLng, poly: any, tolerance?: number): bool; - } - } - - /***** AdSense Library *****/ - export module adsense { - export class AdUnit extends MVCObject { - constructor (container: Element, opts: AdUnitOptions); - getChannelNumber(): string; - getContainer(): Element; - getFormat(): AdFormat; - getMap(): Map; - getPosition(): ControlPosition; - getPublisherId(): string; - setChannelNumber(channelNumber: string): void; - setFormat(format: AdFormat): void; - setMap(map: Map): void; - setPosition(position: ControlPosition): void; - } - - export interface AdUnitOptions { - channelNumber?: string; - format?: AdFormat; - map?: Map; - position?: ControlPosition; - publisherId?: string; - } - - export enum AdFormat { - BANNER, - BUTTON, - HALF_BANNER, - LARGE_RECTANGLE, - LEADERBOARD, - MEDIUM_RECTANGLE, - SKYSCRAPER, - SMALL_RECTANGLE, - SMALL_SQUARE, - SQUARE, - VERTICAL_BANNER, - WIDE_SKYSCRAPER - } - } - - /***** Panoramio Library *****/ - export module panoramio { - export class PanoramioLayer extends MVCObject { - constructor (opts?: PanoramioLayerOptions); - getMap(): Map; - getTag(): string; - getUserId(): string; - setMap(map: Map): void; - setOptions(options: PanoramioLayerOptions): void; - setTag(tag: string): void; - setUserId(userId: string): void; - } - - export interface PanoramioLayerOptions { - map?: Map; - suppressInfoWindows?: bool; - tag?: string; - userId?: string; - } - - export interface PanoramioFeature { - author: string; - photoId: string; - title: string; - url: string; - userId: string; - } - - export interface PanoramioMouseEvent { - featureDetails: PanoramioFeature; - infoWindowHtml: string; - latLng: LatLng; - pixelOffset: Size; - } - } - - export module places { - - export class Autocomplete extends MVCObject { - constructor (inputField: HTMLInputElement, opts?: AutocompleteOptions); - getBounds(): LatLngBounds; - getPlace(): PlaceResult; - setBounds(bounds: LatLngBounds): void; - setComponentRestrictions(restrictions: ComponentRestrictions): void; - setTypes(types: string[]): void; - } - - export interface AutocompleteOptions { - bounds: LatLngBounds; - componentRestrictions: ComponentRestrictions; - types: string[]; - } - - export interface ComponentRestrictions { - country: string; - } - - export interface PlaceDetailsRequest { - reference: string; - } - - export interface PlaceGeometry { - location: LatLng; - viewport: LatLngBounds; - } - - export interface PlaceResult { - address_components: GeocoderAddressComponent[]; - formatted_address: string; - formatted_phone_number: string; - geometry: PlaceGeometry; - html_attributions: string[]; - icon: string; - id: string; - international_phone_number: string; - name: string; - rating: number; - reference: string; - types: string[]; - url: string; - vicinity: string; - website: string; - } - - export interface PlaceSearchRequest { - bounds: LatLngBounds; - keyword: string; - location: LatLng; - name: string; - radius: number; - rankBy: RankBy; - types: string[]; - } - - export interface PlaceSearchPagination { - nextPage(): void; - hasNextPage: bool; - } - - export class PlacesService { - constructor (attrContainer: HTMLDivElement); - constructor (attrContainer: Map); - getDetails(request: PlaceDetailsRequest, callback: (result: PlaceResult, status: PlacesServiceStatus) => void ): void; - nearbySearch(request: PlaceSearchRequest, callback: (results: PlaceResult[], status: PlacesServiceStatus, pagination: PlaceSearchPagination) => void ): void; - textSearch(request: TextSearchRequest, callback: (results: PlaceResult[], status: PlacesServiceStatus) => void ): void; - } - - export enum PlacesServiceStatus { - INVALID_REQUEST, - OK, - OVER_QUERY_LIMIT, - REQUEST_DENIED, - UNKNOWN_ERROR, - ZERO_RESULTS - } - - export enum RankBy { - DISTANCE, - PROMINENCE - } - - export interface TextSearchRequest { - bounds: LatLngBounds; - location: LatLng; - query: string; - radius: number; - } - } - - export module drawing { - export class DrawingManager extends MVCObject { - constructor (options?: DrawingManagerOptions); - getDrawingMode(): OverlayType; - getMap(): Map; - setDrawingMode(drawingMode: OverlayType): void; - setMap(map: Map): void; - setOptions(options: DrawingManagerOptions): void; - } - - export interface DrawingManagerOptions { - circleOptions: CircleOptions; - drawingControl: bool; - drawingControlOptions: DrawingControlOptions; - drawingMode: OverlayType; - map: Map; - markerOptions: MarkerOptions; - polygonOptions: PolygonOptions; - polylineOptions: PolylineOptions; - rectangleOptions: RectangleOptions; - } - - export interface DrawingControlOptions { - drawingModes: OverlayType[]; - position: ControlPosition; - } - - export interface OverlayCompleteEvent { - overlay: MVCObject; - type: OverlayType; - } - - export enum OverlayType { - CIRCLE, - MARKER, - POLYGON, - POLYLINE, - RECTANGLE - } - } - - export module weather { - export class CloudLayer extends MVCObject { - constructor (); - getMap(): Map; - setMap(map: Map): void; - } - export class WeatherLayer extends MVCObject { - constructor (opts?: WeatherLayerOptions); - getMap(): Map; - setMap(map: Map): void; - setOptions(options: WeatherLayerOptions): void; - } - - export interface WeatherLayerOptions { - clickable: bool; - labelColor: LabelColor; - map: Map; - suppressInfoWindows: bool; - temperatureUnits: TemperatureUnit; - windSpeedUnits: WindSpeedUnit; - } - - export enum TemperatureUnit { - CELSIUS, - FAHRENHEIT - } - - export enum WindSpeedUnit { - KILOMETERS_PER_HOUR, - METERS_PER_SECOND, - MILES_PER_HOUR - } - - export enum LabelColor { - BLACK, - WHITE - } - - export interface WeatherMouseEvent { - featureDetails: WeatherFeature; - infoWindowHtml: string; - latLng: LatLng; - pixelOffset: Size; - } - - export interface WeatherFeature { - current: WeatherConditions; - forecast: WeatherForecast[]; - location: string; - temperatureUnit: TemperatureUnit; - windSpeedUnit: WindSpeedUnit; - } - - export interface WeatherConditions { - day: string; - description: string; - high: number; - humidity: number; - low: number; - shortDay: string; - temperature: number; - windDirection: string; - windSpeed: number; - } - - export interface WeatherForecast { - day: string; - description: string; - high: number; - low: number; - shortDay: string; - } - } - export module visualization { - export class HeatmapLayer extends MVCObject { - constructor (opts?: HeatmapLayerOptions); - getData(): MVCArray; - getMap(): Map; - setData(data: MVCArray): void; - setData(data: LatLng[]): void; - setData(data: WeightedLocation[]): void; - setMap(map: Map): void; - } - - export interface HeatmapLayerOptions { - data: LatLng[]; - dissipating: bool; - gradient: string[]; - map: Map; - maxIntensity: number; - opacity: number; - radius: number; - } - - export interface WeightedLocation { - location: LatLng; - weight: number; - } - } -} - +/* +The MIT License + +Copyright (c) 2012 Folia A/S. http://www.folia.dk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +declare module google.maps { + + /***** MVC *****/ + export class MVCObject { + constructor (); + bindTo(key: string, target: MVCObject, targetKey?: string, noNotify?: bool): void; + changed(key: string): void; + get(key: string): any; + notify(key: string): void; + set(key: string, value: any): void; + setValues(values: any): void; + setValues(values: undefined); + unbind(key: string): void; + unbindAll(): void; + } + + export class MVCArray extends MVCObject { + constructor (array?: any[]); + clear(): void; + forEach(callback: (elem: any, index: number) => void ): void; + getArray(): any[]; + getAt(i: number): any; + getLength(): number; + insertAt(i: number, elem: any): void; + pop(): void; + push(elem: any): number; + removeAt(i: number): any; + setAt(i: number, elem: any): void; + } + + /***** Map *****/ + export class Map extends MVCObject { + constructor (mapDiv: Element, opts?: MapOptions); + fitBounds(bounds: LatLngBounds); + getBounds(): LatLngBounds; + getCenter(): LatLng; + getDiv(): Element; + getHeading(): number; + getMapTypeId(): MapTypeId; + getProjection(): Projection; + getStreetView(): StreetViewPanorama; + getTilt(): number; + getZoom(): number; + panBy(x: number, y: number): void; + panTo(latLng: LatLng): void; + panToBounds(latLngBounds: LatLngBounds): void; + setCenter(latlng: LatLng): void; + setHeading(heading: number): void; + setMapTypeId(mapTypeId: MapTypeId): void; + setOptions(options: MapOptions): void; + setStreetView(panorama: StreetViewPanorama): void; + setTilt(tilt: number): void; + setZoom(zoom: number): void; + } + + export interface MapOptions { + backgroundColor?: string; + center?: LatLng; + disableDefaultUI?: bool; + disableDoubleClickZoom?: bool; + draggable?: bool; + draggableCursor?: string; + draggingCursor?: string; + heading?: number; + keyboardShortcuts?: bool; + mapMaker?: bool; + mapTypeControl?: bool; + mapTypeControlOptions?: MapTypeControlOptions; + mapTypeId?: MapTypeId; + maxZoom?: number; + minZoom?: number; + noClear?: bool; + overviewMapControl?: bool; + overviewMapControlOptions?: OverviewMapControlOptions; + panControl?: bool; + panControlOptions?: PanControlOptions; + rotateControl?: bool; + rotateControlOptions?: RotateControlOptions; + scaleControl?: bool; + scaleControlOptions?: ScaleControlOptions; + scrollwheel?: bool; + streetView?: bool; + streetViewControlOptions?: StreetViewControlOptions; + styles?: MapTypeStyle[]; + tilt?: number; + zoom?: number; + zoomControl?: bool; + zoomControlOptions?: ZoomControlOptions; + } + + export enum MapTypeId { + HYBRID, + ROADMAP, + SATELLITE, + TERRAIN + } + + /***** Controls *****/ + export interface MapTypeControlOptions { + mapTypeIds?: MapTypeId[]; + position?: ControlPosition; + style?: MapTypeControlStyle; + } + + export enum MapTypeControlStyle { + DEFAULT, + DROPDOWN_MENU, + HORIZONTAL_BAR + } + + export interface OverviewMapControlOptions { + opened?: bool; + } + + export interface PanControlOptions { + position: ControlPosition; + } + + export interface RotateControlOptions { + position: ControlPosition; + } + + export interface ScaleControlOptions { + position?: ControlPosition; + style?: ScaleControlStyle; + } + + export enum ScaleControlStyle { + DEFAULT + } + + export interface StreetViewControlOptions { + position: ControlPosition; + } + + export interface ZoomControlOptions { + position?: ControlPosition; + style?: ZoomControlStyle; + } + + export enum ZoomControlStyle { + DEFAULT, + LARGE, + SMALL + } + + export enum ControlPosition { + BOTTOM_CENTER, + BOTTOM_LEFT, + BOTTOM_RIGHT, + LEFT_BOTTOM, + LEFT_CENTER, + LEFT_TOP, + RIGHT_BOTTOM, + RIGHT_CENTER, + RIGHT_TOP, + TOP_CENTER, + TOP_LEFT, + TOP_RIGHT + } + + /***** Overlays *****/ + export class Marker extends MVCObject { + constructor (opts?: MarkerOptions); + getAnimation(): Animation; + getClickable(): bool; + getCursor(): string; + getDraggable(): bool; + getFlat(): bool; + getIcon(): MarkerImage; + getMap(): Map; + getMap(): StreetViewPanorama; + getPosition(): LatLng; + getShadow(): MarkerImage; + getShape(): MarkerShape; + getTitle(): string; + getVisible(): bool; + getZIndex(): number; + setAnimation(animation: Animation): void; + setClickable(flag: bool): void; + setCursor(cursor: string): void; + setDraggable(flag: bool): void; + setFlat(flag: bool): void; + setIcon(icon: MarkerImage): void; + setIcon(icon: string): void; + setMap(map: Map): void; + setMap(map: StreetViewPanorama): void; + setOptions(options: MarkerOptions): void; + setPosition(latlng: LatLng): void; + setShadow(shadow: MarkerImage): void; + setShadow(shadow: string): void; + setShape(shape: MarkerShape): void; + setTitle(title: string): void; + setVisible(visible: bool): void; + setZIndex(zIndex: number): void; + } + + export interface MarkerOptions { + animation?: Animation; + clickable?: bool; + cursor?: string; + draggable?: bool; + flat?: bool; + icon?: any; + map?: any; + optimized?: bool; + position?: LatLng; + raiseOnDrag?: bool; + shadow?: any; + shape?: MarkerShape; + title?: string; + visible?: bool; + zIndex?: number; + } + + export class MarkerImage { + constructor (url: string, size?: Size, origin?: Point, anchor?: Point, scaledSize?: Size); + anchor: Point; + origin: Point; + scaledSize: Size; + size: Size; + url: string; + } + + export interface MarkerShape { + coords?: number[]; + type?: string; + } + + export interface Symbol { + anchor?: Point; + fillColor?: string; + fillOpacity?: number; + path?: any; + rotation?: number; + scale?: number; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + } + + export enum SymbolPath { + BACKWARD_CLOSED_ARROW, + BACKWARD_OPEN_ARROW, + CIRCLE, + FORWARD_CLOSED_ARROW, + FORWARD_OPEN_ARROW + } + + export enum Animation { + BOUNCE, + DROP + } + + export class InfoWindow extends MVCObject { + constructor (opts?: InfoWindowOptions); + close(): void; + getContent(): string; + getContent(): Element; + getPosition(): LatLng; + getZIndex(): number; + open(map?: Map, anchor?: MVCObject): void; + open(map?: StreetViewPanorama, anchor?: MVCObject): void; + setContent(content: Node): void; + setContent(content: string): void; + setOptions(options: InfoWindowOptions): void; + setPosition(position: LatLng): void; + setZIndex(zIndex: number): void; + } + + export interface InfoWindowOptions { + content?: any; + disableAutoPan?: bool; + maxWidth?: number; + pixelOffset?: Size; + position?: LatLng; + zIndex?: number; + } + + export class Polyline extends MVCObject { + constructor (opts?: PolylineOptions); + getEditable(): bool; + getMap(): Map; + getPath(): MVCArray[]; + getVisible(): bool; + setEditable(editable: bool): void; + setMap(map: Map): void; + setOptions(options: PolylineOptions): void; + setPath(path: MVCArray[]): void; + setPath(path: LatLng[]): void; + setVisible(visible: bool): void; + } + + export interface PolylineOptions { + clickable?: bool; + editable?: bool; + geodesic?: bool; + icons?: IconSequence[]; + map?: Map; + path?: any[]; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + visible?: bool; + zIndex?: number; + } + + export interface IconSequence { + icon?: Symbol; + offset?: string; + repeat?: string; + } + + export class Polygon extends MVCObject { + constructor (opts?: PolygonOptions); + getEditable(): bool; + getMap(): Map; + getPath(): MVCArray[]; + getPaths(): MVCArray[][]; + getVisible(): bool; + setEditable(editable: bool): void; + setMap(map: Map): void; + setOptions(options: PolygonOptions): void; + setPath(path: MVCArray[]): void; + setPath(path: LatLng[]): void; + setPaths(paths: MVCArray[]): void; + setPaths(paths: MVCArray[][]): void; + setPaths(path: LatLng[]): void; + setPaths(path: LatLng[][]): void; + setVisible(visible: bool): void; + } + + export interface PolygonOptions { + clickable?: bool; + editable?: bool; + fillColor?: string; + fillOpacity?: number; + geodesic?: bool; + map?: Map; + paths?: any[]; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + visible?: bool; + zIndex?: number; + } + + export interface PolyMouseEvent { + edge?: number; + path?: number; + vertex?: number; + } + + export class Rectangle extends MVCObject { + constructor (opts?: RectangleOptions); + getBounds(): LatLngBounds; + getEditable(): bool; + getMap(): Map; + getVisible(): bool; + setBounds(bounds: LatLngBounds): void; + setEditable(editable: bool): void; + setMap(map: Map): void; + setOptions(options: RectangleOptions): void; + setVisible(visible: bool): void; + } + + export interface RectangleOptions { + bounds?: LatLngBounds; + clickable?: bool; + editable?: bool; + fillColor?: string; + fillOpacity?: number; + map?: Map; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + visible?: bool; + zIndex?: number; + } + + export class Circle extends MVCObject { + constructor (opts?: CircleOptions); + getBounds(): LatLngBounds; + getCenter(): LatLng; + getEditable(): bool; + getMap(): Map; + getRadius(): number; + getVisible(): bool; + setCenter(center: LatLng): void; + setEditable(editable: bool): void; + setMap(map: Map): void; + setOptions(options: CircleOptions): void; + setRadius(radius: number): void; + setVisible(visible: bool): void; + } + + export interface CircleOptions { + center?: LatLng; + clickable?: bool; + editable?: bool; + fillColor?: string; + fillOpacity?: number; + map?: Map; + radius?: number; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + visible?: bool; + zIndex?: number; + } + + export class GroundOverlay extends MVCObject { + constructor (url: string, bounds: LatLngBounds, opts?: GroundOverlayOptions); + getBounds(): LatLngBounds; + getMap(): Map; + getOpacity(): number; + getUrl(): string; + setMap(map: Map): void; + setOpacity(opacity: number): void; + } + + export interface GroundOverlayOptions { + clickable?: bool; + map?: Map; + opacity?: number; + } + + export class OverlayView extends MVCObject { + draw(): void; + getMap(): Map; + getPanes(): MapPanes; + getProjection(): MapCanvasProjection; + onAdd(): void; + onRemove(): void; + setMap(map: Map): void; + setMap(map: StreetViewPanorama): void; + } + + export interface MapPanes { + floatPane: Element; + floatShadow: Element; + mapPane: Element; + overlayImage: Element; + overlayLayer: Element; + overlayMouseTarget: Element; + overlayShadow: Element; + } + + export class MapCanvasProjection extends MVCObject { + fromContainerPixelToLatLng(pixel: Point, nowrap?: bool): LatLng; + fromDivPixelToLatLng(pixel: Point, nowrap?: bool): LatLng; + fromLatLngToContainerPixel(latLng: LatLng): Point; + fromLatLngToDivPixel(latLng: LatLng): Point; + getWorldWidth(): number; + } + + /***** Services *****/ + export class Geocoder { + constructor (); + geocode(request: GeocoderRequest, callback: (results: GeocoderResult[], status: GeocoderStatus) => void ): void; + } + + export interface GeocoderRequest { + address: string; + bounds?: LatLngBounds; + location?: LatLng; + region?: string; + } + + export enum GeocoderStatus { + ERROR, + INVALID_REQUEST, + OK, + OVER_QUERY_LIMIT, + REQUEST_DENIED, + UNKNOWN_ERROR, + ZERO_RESULTS + } + + export interface GeocoderResult { + address_components: GeocoderAddressComponent[]; + formatted_address: string; + geometry: GeocoderGeometry; + types: string[]; + } + + export interface GeocoderAddressComponent { + long_name: string; + short_name: string; + types: string[]; + } + + export interface GeocoderGeometry { + bounds: LatLngBounds; + location: LatLng; + location_type: GeocoderLocationType; + viewport: LatLngBounds; + } + + export enum GeocoderLocationType { + APPROXIMATE, + GEOMETRIC_CENTER, + RANGE_INTERPOLATED, + ROOFTOP + } + + export class DirectionsRenderer extends MVCObject { + constructor (opts?: DirectionsRendererOptions); + getDirections(): DirectionsResult; + getMap(): Map; + getPanel(): Element; + getRouteIndex(): number; + setDirections(directions: DirectionsResult): void; + setMap(map: Map): void; + setOptions(options: DirectionsRendererOptions): void; + setPanel(panel: Element): void; + setRouteIndex(routeIndex: number): void; + } + + export interface DirectionsRendererOptions { + directions?: DirectionsResult; + draggable?: bool; + hideRouteList?: bool; + infoWindow?: InfoWindow; + map?: Map; + markerOptions?: MarkerOptions; + panel?: Element; + polylineOptions?: PolylineOptions; + preserveViewport?: bool; + routeIndex?: number; + suppressBicyclingLayer?: bool; + suppressInfoWindows?: bool; + suppressMarkers?: bool; + suppressPolylines?: bool; + } + + export class DirectionsService { + constructor (); + route(request: DirectionsRequest, callback: (result: DirectionsResult, status: DirectionsStatus) => void ): void; + } + + export interface DirectionsRequest { + avoidHighways?: bool; + avoidTolls?: bool; + destination?: any; + optimizeWaypoints?: bool; + origin?: any; + provideRouteAlternatives?: bool; + region?: string; + transitOptions?: TransitOptions; + travelMode?: TravelMode; + unitSystem?: UnitSystem; + waypoints?: DirectionsWaypoint[]; + } + + export enum TravelMode { + BICYCLING, + DRIVING, + TRANSIT, + WALKING + } + + export enum UnitSystem { + IMPERIAL, + METRIC + } + + export interface TransitOptions { + arrivalTime?: Date; + departureTime?: Date; + } + + export interface DirectionsWaypoint { + location: any; + stopover: bool; + } + + export enum DirectionsStatus { + INVALID_REQUEST, + MAX_WAYPOINTS_EXCEEDED, + NOT_FOUND, + OK, + OVER_QUERY_LIMIT, + REQUEST_DENIED, + UNKNOWN_ERROR, + ZERO_RESULTS + } + + export interface DirectionsResult { + routes: DirectionsRoute[]; + } + + export interface DirectionsRoute { + bounds: LatLngBounds; + copyrights: string; + legs: DirectionsLeg[]; + overview_path: LatLng[]; + warnings: string[]; + waypoint_order: number[]; + } + + export interface DirectionsLeg { + arrival_time: Distance; + departure_time: Duration; + distance: Distance; + duration: Duration; + end_address: string; + end_location: LatLng; + start_address: string; + start_location: LatLng; + steps: DirectionsStep[]; + via_waypoints: LatLng[]; + } + + export interface DirectionsStep { + distance: Distance; + duration: Duration; + end_location: LatLng; + instructions: string; + path: LatLng[]; + start_location: LatLng; + steps: DirectionsStep; + transit: TransitDetails; + travel_mode: TravelMode; + } + + export interface Distance { + text: string; + value: number; + } + + export interface Duration { + text: string; + value: number; + } + + export interface Time { + text: string; + time_zone: string; + value: Date; + } + + export interface TransitDetails { + arrival_stop: TransitStop; + arrival_time: Time; + departure_stop: TransitStop; + departure_time: Time; + headsign: string; + headway: number; + line: TransitLine; + num_stops: number; + } + + export interface TransitStop { + location: LatLng; + name: string; + } + + export interface TransitLine { + agencies: TransitAgency[]; + color: string; + icon: string; + name: string; + short_name: string; + text_color: string; + url: string; + vehicle: TransitVehicle; + } + + export interface TransitAgency { + name: string; + phone: string; + url: string; + } + + export interface TransitVehicle { + icon: string; + local_icon: string; + name: string; + type: string; + } + + export class ElevationService { + constructor (); + getElevationAlongPath(request: PathElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; + getElevationForLocations(request: LocationElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; + } + + export interface LocationElevationRequest { + locations: LatLng[]; + } + + export interface PathElevationRequest { + path?: LatLng[]; + samples?: number; + } + + export interface ElevationResult { + elevation: number; + location: LatLng; + resolution: number; + } + + export enum ElevationStatus { + INVALID_REQUEST, + OK, + OVER_QUERY_LIMIT, + REQUEST_DENIED, + UNKNOWN_ERROR + } + + export class MaxZoomService { + constructor (); + getMaxZoomAtLatLng(latlng: LatLng, callback: (result: MaxZoomResult) => void ): void; + } + + export interface MaxZoomResult { + status: MaxZoomStatus; + zoom: number; + } + + export enum MaxZoomStatus { + ERROR, + OK + } + + export class DistanceMatrixService { + constructor (); + getDistanceMatrix(request: DistanceMatrixRequest, callback: (response: DistanceMatrixResponse, status: DistanceMatrixStatus) => void ): void; + } + + export interface DistanceMatrixRequest { + avoidHighways?: bool; + avoidTolls?: bool; + destinations?: any[]; + origins?: any[]; + region?: string; + travelMode?: TravelMode; + unitSystem?: UnitSystem; + } + + export interface DistanceMatrixResponse { + destinationAddresses: string[]; + originAddresses: string[]; + rows: DistanceMatrixResponseRow[]; + } + + export interface DistanceMatrixResponseRow { + elements: DistanceMatrixResponseElement[]; + } + + export interface DistanceMatrixResponseElement { + distance: Distance; + duration: Duration; + status: DistanceMatrixElementStatus; + } + + export enum DistanceMatrixStatus { + INVALID_REQUEST, + MAX_DIMENSIONS_EXCEEDED, + MAX_ELEMENTS_EXCEEDED, + OK, + OVER_QUERY_LIMIT, + REQUEST_DENIED, + UNKNOWN_ERROR + } + + export enum DistanceMatrixElementStatus { + NOT_FOUND, + OK, + ZERO_RESULTS + } + + /***** Map Types *****/ + export interface MapType { + getTile(tileCoord: Point, zoom: number, ownerDocument: Document): Element; + releaseTile(tile: Element): void; + alt?: string; + maxZoom?: number; + minZoom?: number; + name?: string; + projection?: Projection; + radius?: number; + tileSize?: Size; + } + + export class MapTypeRegistry extends MVCObject { + constructor (); + set(id: string, mapType: MapType): void; + } + + export interface Projection { + fromLatLngToPoint(latLng: LatLng, point?: Point): Point; + fromPointToLatLng(pixel: Point, noWrap?: bool): LatLng; + } + + export class ImageMapType { + constructor (opts: ImageMapTypeOptions); + getOpacity(): number; + setOpacity(opacity: number): void; + } + + export interface ImageMapTypeOptions { + alt?: string; + getTileUrl: (Point, number) => string; + maxZoom?: number; + minZoom?: number; + name?: string; + opacity?: number; + tileSize?: Size; + } + + export class StyledMapType { + constructor (styles: MapTypeStyle[], options?: StyledMapTypeOptions); + } + + export interface StyledMapTypeOptions { + alt?: string; + maxZoom?: number; + minZoom?: number; + name?: string; + } + + export interface MapTypeStyle { + elementType?: MapTypeStyleElementType; + featureType?: MapTypeStyleFeatureType; + stylers?: MapTypeStyler[]; + } + + export interface MapTypeStyleFeatureType { + administrative?: { + country?: string; + land_parcel?: string; + locality?: string; + neighborhood?: string; + province?: string; + }; + all?: string; + landscape?: { + man_made?: string; + natural?: string; + }; + poi?: { + attraction?: string; + business?: string; + government?: string; + medical?: string; + park?: string; + place_of_worship?: string; + school?: string; + sports_complex?: string; + }; + road?: { + arterial?: string; + highway?: { + controlled_access?: string; + }; + local?: string; + }; + transit?: { + line?: string; + station?: { + airport?: string; + bus?: string; + rail?: string; + }; + }; + water?: string; + } + + export enum MapTypeStyleElementType { + all, + geometry, + labels + } + + export interface MapTypeStyler { + gamma?: number; + hue?: string; + invert_lightness?: bool; + lightness?: number; + saturation?: number; + visibility?: string; + } + + /***** Layers *****/ + export class BicyclingLayer extends MVCObject { + constructor (); + getMap(): Map; + setMap(map: Map): void; + } + + export class FusionTablesLayer extends MVCObject { + constructor (options: FusionTablesLayerOptions); + getMap(): Map; + setMap(map: Map): void; + setOptions(options: FusionTablesLayerOptions): void; + } + + export interface FusionTablesLayerOptions { + clickable?: bool; + heatmap?: FusionTablesHeatmap; + map?: Map; + query?: FusionTablesQuery; + styles?: FusionTablesStyle[]; + suppressInfoWindows?: bool; + } + + export interface FusionTablesQuery { + from?: string; + limit?: number; + offset?: number; + orderBy?: string; + select?: string; + where?: string; + } + + export interface FusionTablesStyle { + markerOptions?: FusionTablesMarkerOptions; + polygonOptions?: FusionTablesPolygonOptions; + polylineOptions?: FusionTablesPolylineOptions; + where?: string; + } + + export interface FusionTablesHeatmap { + enabled: bool; + } + + export interface FusionTablesMarkerOptions { + iconName: string; + } + + export interface FusionTablesPolygonOptions { + fillColor?: string; + fillOpacity?: number; + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + } + + export interface FusionTablesPolylineOptions { + strokeColor?: string; + strokeOpacity?: number; + strokeWeight?: number; + } + + export interface FusionTablesMouseEvent { + infoWindowHtml: string; + latLng: LatLng; + pixelOffset: Size; + row: Object; + } + + export interface FusionTablesCell { + columnName: string; + value: string; + } + + export class KmlLayer extends MVCObject { + constructor (url: string, opts?: KmlLayerOptions); + getDefaultViewport(): LatLngBounds; + getMap(): Map; + getMetadata(): KmlLayerMetadata; + getStatus(): KmlLayerStatus; + getUrl(): string; + setMap(map: Map): void; + } + + export interface KmlLayerOptions { + clickable?: bool; + map?: Map; + preserveViewport?: bool; + suppressInfoWindows?: bool; + } + + export interface KmlLayerMetadata { + author: KmlAuthor; + description: string; + name: string; + snippet: string; + } + + export enum KmlLayerStatus { + DOCUMENT_NOT_FOUND, + DOCUMENT_TOO_LARGE, + FETCH_ERROR, + INVALID_DOCUMENT, + INVALID_REQUEST, + LIMITS_EXCEEDED, + OK, + TIMED_OUT, + UNKNOWN + } + + export interface KmlMouseEvent { + featureData: KmlFeatureData; + latLng: LatLng; + pixelOffset: Size; + } + + export interface KmlFeatureData { + author: KmlAuthor; + description: string; + id: string; + infoWindowHtml: string; + name: string; + snippet: string; + } + + export interface KmlAuthor { + email: string; + name: string; + uri: string; + } + + export class TrafficLayer extends MVCObject { + constructor (); + getMap(): void; + setMap(map: Map): void; + } + + export class TransitLayer extends MVCObject { + constructor (); + getMap(): void; + setMap(map: Map): void; + } + + /***** Street View *****/ + export class StreetViewPanorama { + constructor (container: Element, opts?: StreetViewPanoramaOptions); + controls: MVCArray[]; + getLinks(): StreetViewLink[]; + getPano(): string; + getPosition(): LatLng; + getPov(): StreetViewPov; + getVisible(): bool; + registerPanoProvider(provider: (input: string) => StreetViewPanoramaData); + setPano(pano: string): void; + setPosition(latLng: LatLng): void; + setPov(pov: StreetViewPov): void; + setVisible(flag: bool): void; + + } + + export interface StreetViewPanoramaOptions { + addressControl?: bool; + addressControlOptions?: StreetViewAddressControlOptions; + clickToGo?: bool; + disableDoubleClickZoom?: bool; + enableCloseButton?: bool; + imageDateControl?: bool; + linksControl?: bool; + panControl?: bool; + panControlOptions?: PanControlOptions; + pano?: string; + panoProvider?: (input: string) => StreetViewPanoramaData; + position?: LatLng; + pov?: StreetViewPov; + scrollwheel?: bool; + visible?: bool; + zoomControl?: bool; + zoomControlOptions?: ZoomControlOptions; + } + + export interface StreetViewAddressControlOptions { + position: ControlPosition; + } + + export interface StreetViewLink { + description?: string; + heading?: number; + pano?: string; + } + + export interface StreetViewPov { + heading?: number; + picth?: number; + zoom?: number; + } + + export interface StreetViewPanoramaData { + opyright?: string; + imageDate?: string; + links?: StreetViewLink[]; + location?: StreetViewLocation; + tiles?: StreetViewTileData; + } + + export interface StreetViewLocation { + description?: string; + latLng?: LatLng; + pano?: string; + } + + export interface StreetViewTileData { + centerHeading?: number; + tileSize?: Size; + worldSize?: Size; + } + + export interface StreetViewService { + getPanoramaById(pano: string, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void ); + getPanoramaByLocation(latlng: LatLng, radius: number, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void ); + } + + export enum StreetViewStatus { + OK, + UNKNOWN_ERROR, + ZERO_RESULTS + } + + /***** Base *****/ + export class LatLng { + constructor (lat: number, lng: number, noWrap?: bool); + equals(other: LatLng): bool; + lat(): number; + lng(): number; + toString(): string; + toUrlValue(precision?: number): string; + + } + + export class LatLngBounds { + constructor (sw?: LatLng, ne?: LatLng); + contains(latLng: LatLng): bool; + equals(other: LatLngBounds): bool; + extend(point: LatLng): LatLngBounds; + getCenter(): LatLng; + getNorthEast(): LatLng; + getSouthWest(): LatLng; + intersects(other: LatLngBounds): bool; + isEmpty(): bool; + toSpan(): LatLng; + toString(): string; + toUrlValue(precision?: number): string; + union(other: LatLngBounds): LatLngBounds; + } + + export class Point { + constructor (x: number, y: number); + x: number; + y: number; + equals(other: Point): bool; + toString(): string; + } + + export class Size { + constructor (width: number, height: number, widthUnit?: string, heightUnit?: string); + height: number; + width: number; + equals(other: Size): bool; + toString(): string; + } + + /***** Geometry Library *****/ + export module geometry { + export class encoding { + static decodePath(encodedPath: string): LatLng; + static encodePath(path: any[]): string; + } + + export class spherical { + static computeArea(path: any[], radius?: number): number; + static computeDistanceBetween(from: LatLng, to: LatLng, radius?: number): number; + static computeHeading(from: LatLng, to: LatLng): number; + static computeLength(path: any[], radius?: number): number; + static computeOffset(from: LatLng, distance: number, heading: number, radius?: number): LatLng; + static computeSignedArea(loop: any[], radius?: number): number; + static interpolate(from: LatLng, to: LatLng, fraction: number): LatLng; + } + + export class poly { + containsLocation(point: LatLng, polygon: Polygon): bool; + isLocationOnEdge(point: LatLng, poly: any, tolerance?: number): bool; + } + } + + /***** AdSense Library *****/ + export module adsense { + export class AdUnit extends MVCObject { + constructor (container: Element, opts: AdUnitOptions); + getChannelNumber(): string; + getContainer(): Element; + getFormat(): AdFormat; + getMap(): Map; + getPosition(): ControlPosition; + getPublisherId(): string; + setChannelNumber(channelNumber: string): void; + setFormat(format: AdFormat): void; + setMap(map: Map): void; + setPosition(position: ControlPosition): void; + } + + export interface AdUnitOptions { + channelNumber?: string; + format?: AdFormat; + map?: Map; + position?: ControlPosition; + publisherId?: string; + } + + export enum AdFormat { + BANNER, + BUTTON, + HALF_BANNER, + LARGE_RECTANGLE, + LEADERBOARD, + MEDIUM_RECTANGLE, + SKYSCRAPER, + SMALL_RECTANGLE, + SMALL_SQUARE, + SQUARE, + VERTICAL_BANNER, + WIDE_SKYSCRAPER + } + } + + /***** Panoramio Library *****/ + export module panoramio { + export class PanoramioLayer extends MVCObject { + constructor (opts?: PanoramioLayerOptions); + getMap(): Map; + getTag(): string; + getUserId(): string; + setMap(map: Map): void; + setOptions(options: PanoramioLayerOptions): void; + setTag(tag: string): void; + setUserId(userId: string): void; + } + + export interface PanoramioLayerOptions { + map?: Map; + suppressInfoWindows?: bool; + tag?: string; + userId?: string; + } + + export interface PanoramioFeature { + author: string; + photoId: string; + title: string; + url: string; + userId: string; + } + + export interface PanoramioMouseEvent { + featureDetails: PanoramioFeature; + infoWindowHtml: string; + latLng: LatLng; + pixelOffset: Size; + } + } + + export module places { + + export class Autocomplete extends MVCObject { + constructor (inputField: HTMLInputElement, opts?: AutocompleteOptions); + getBounds(): LatLngBounds; + getPlace(): PlaceResult; + setBounds(bounds: LatLngBounds): void; + setComponentRestrictions(restrictions: ComponentRestrictions): void; + setTypes(types: string[]): void; + } + + export interface AutocompleteOptions { + bounds: LatLngBounds; + componentRestrictions: ComponentRestrictions; + types: string[]; + } + + export interface ComponentRestrictions { + country: string; + } + + export interface PlaceDetailsRequest { + reference: string; + } + + export interface PlaceGeometry { + location: LatLng; + viewport: LatLngBounds; + } + + export interface PlaceResult { + address_components: GeocoderAddressComponent[]; + formatted_address: string; + formatted_phone_number: string; + geometry: PlaceGeometry; + html_attributions: string[]; + icon: string; + id: string; + international_phone_number: string; + name: string; + rating: number; + reference: string; + types: string[]; + url: string; + vicinity: string; + website: string; + } + + export interface PlaceSearchRequest { + bounds: LatLngBounds; + keyword: string; + location: LatLng; + name: string; + radius: number; + rankBy: RankBy; + types: string[]; + } + + export interface PlaceSearchPagination { + nextPage(): void; + hasNextPage: bool; + } + + export class PlacesService { + constructor (attrContainer: HTMLDivElement); + constructor (attrContainer: Map); + getDetails(request: PlaceDetailsRequest, callback: (result: PlaceResult, status: PlacesServiceStatus) => void ): void; + nearbySearch(request: PlaceSearchRequest, callback: (results: PlaceResult[], status: PlacesServiceStatus, pagination: PlaceSearchPagination) => void ): void; + textSearch(request: TextSearchRequest, callback: (results: PlaceResult[], status: PlacesServiceStatus) => void ): void; + } + + export enum PlacesServiceStatus { + INVALID_REQUEST, + OK, + OVER_QUERY_LIMIT, + REQUEST_DENIED, + UNKNOWN_ERROR, + ZERO_RESULTS + } + + export enum RankBy { + DISTANCE, + PROMINENCE + } + + export interface TextSearchRequest { + bounds: LatLngBounds; + location: LatLng; + query: string; + radius: number; + } + } + + export module drawing { + export class DrawingManager extends MVCObject { + constructor (options?: DrawingManagerOptions); + getDrawingMode(): OverlayType; + getMap(): Map; + setDrawingMode(drawingMode: OverlayType): void; + setMap(map: Map): void; + setOptions(options: DrawingManagerOptions): void; + } + + export interface DrawingManagerOptions { + circleOptions: CircleOptions; + drawingControl: bool; + drawingControlOptions: DrawingControlOptions; + drawingMode: OverlayType; + map: Map; + markerOptions: MarkerOptions; + polygonOptions: PolygonOptions; + polylineOptions: PolylineOptions; + rectangleOptions: RectangleOptions; + } + + export interface DrawingControlOptions { + drawingModes: OverlayType[]; + position: ControlPosition; + } + + export interface OverlayCompleteEvent { + overlay: MVCObject; + type: OverlayType; + } + + export enum OverlayType { + CIRCLE, + MARKER, + POLYGON, + POLYLINE, + RECTANGLE + } + } + + export module weather { + export class CloudLayer extends MVCObject { + constructor (); + getMap(): Map; + setMap(map: Map): void; + } + export class WeatherLayer extends MVCObject { + constructor (opts?: WeatherLayerOptions); + getMap(): Map; + setMap(map: Map): void; + setOptions(options: WeatherLayerOptions): void; + } + + export interface WeatherLayerOptions { + clickable: bool; + labelColor: LabelColor; + map: Map; + suppressInfoWindows: bool; + temperatureUnits: TemperatureUnit; + windSpeedUnits: WindSpeedUnit; + } + + export enum TemperatureUnit { + CELSIUS, + FAHRENHEIT + } + + export enum WindSpeedUnit { + KILOMETERS_PER_HOUR, + METERS_PER_SECOND, + MILES_PER_HOUR + } + + export enum LabelColor { + BLACK, + WHITE + } + + export interface WeatherMouseEvent { + featureDetails: WeatherFeature; + infoWindowHtml: string; + latLng: LatLng; + pixelOffset: Size; + } + + export interface WeatherFeature { + current: WeatherConditions; + forecast: WeatherForecast[]; + location: string; + temperatureUnit: TemperatureUnit; + windSpeedUnit: WindSpeedUnit; + } + + export interface WeatherConditions { + day: string; + description: string; + high: number; + humidity: number; + low: number; + shortDay: string; + temperature: number; + windDirection: string; + windSpeed: number; + } + + export interface WeatherForecast { + day: string; + description: string; + high: number; + low: number; + shortDay: string; + } + } + export module visualization { + export class HeatmapLayer extends MVCObject { + constructor (opts?: HeatmapLayerOptions); + getData(): MVCArray; + getMap(): Map; + setData(data: MVCArray): void; + setData(data: LatLng[]): void; + setData(data: WeightedLocation[]): void; + setMap(map: Map): void; + } + + export interface HeatmapLayerOptions { + data: LatLng[]; + dissipating: bool; + gradient: string[]; + map: Map; + maxIntensity: number; + opacity: number; + radius: number; + } + + export interface WeightedLocation { + location: LatLng; + weight: number; + } + } + + export class MouseEvent { + stop(): void; + } + + export class MapsEventListener { + + } + + export module event { + export function addDomListener(instance: Object, eventName: string, handler: Function, capture?: bool): MapsEventListener; + export function addDomListenerOnce(instance: Object, eventName:string, handler:Function, capture?: bool): MapsEventListener; + export function addListener(instance: Object, eventName: string, handler: Function): MapsEventListener; + export function addListenerOnce(instance:Object, eventName: string, handler: Function): MapsEventListener; + export function clearInstanceListeners(instance: Object): void; + export function clearListeners(instance: Object, eventName: string): void ; + export function removeListener(listener: MapsEventListener): void; + export function trigger(instance:Object, eventName:string, var_args?:any): void; + } +} + diff --git a/Definitions/linq-2.2.d.ts b/Definitions/linq-2.2.d.ts new file mode 100644 index 000000000..ead5a5ea8 --- /dev/null +++ b/Definitions/linq-2.2.d.ts @@ -0,0 +1,222 @@ +// Type definitions for linq.js 2.2 +// Project: http://linqjs.codeplex.com/ +// Definitions by: Marcin Najder +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// todo: jQuery plugin, RxJS Binding + +module linq { + + interface EnumerableStatic { + Choice(...contents: any[]): Enumerable; + Choice(contents: any[]): Enumerable; + Cycle(...contents: any[]): Enumerable; + Cycle(contents: any[]): Enumerable; + Empty(): Enumerable; + From(obj: any[]): Enumerable; + From(obj: any): Enumerable; + Return(element: any): Enumerable; + Matches(input: string, pattern: RegExp): Enumerable; + Matches(input: string, pattern: string, flags?: string): Enumerable; + Range(start: number, count: number, step?: number): Enumerable; + RangeDown(start: number, count: number, step?: number): Enumerable; + RangeTo(start: number, to: number, step?: number): Enumerable; + Repeat(obj: any, count?: number): Enumerable; + RepeatWithFinalize(initializer: () => any, finalizer: (resource: any) =>void ): Enumerable; + Generate(func: () => any, count?: number): Enumerable; + Generate(func: string, count?: number): Enumerable; + ToInfinity(start?: number, step?: number): Enumerable; + ToNegativeInfinity(start?: number, step?: number): Enumerable; + Unfold(seed, func: ($) => any): Enumerable; + Unfold(seed, func: string): Enumerable; + } + + interface Enumerable { + //Projection and Filtering Methods + CascadeBreadthFirst(func: ($) => any[], resultSelector: (v, i: number) => any): Enumerable; + CascadeBreadthFirst(func: string, resultSelector: string): Enumerable; + CascadeDepthFirst(func: ($) => any[], resultSelector: (v, i: number) => any): Enumerable; + CascadeDepthFirst(func: string, resultSelector: string): Enumerable; + Flatten(...items: any[]): Enumerable; + Pairwise(selector: (prev, next) => any): Enumerable; + Pairwise(selector: string): Enumerable; + Scan(func: (a, b) => any): Enumerable; + Scan(func: string): Enumerable; + Scan(seed, func: (a, b) => any, resultSelector?: ($) => any): Enumerable; + Scan(seed, func: string, resultSelector?: string): Enumerable; + Select(selector: ($, i: number) => any): Enumerable; + Select(selector: string): Enumerable; + SelectMany(collectionSelector: ($, i: number) => any[], resultSelector?: ($, item) => any): Enumerable; + SelectMany(collectionSelector: ($, i: number) => Enumerable, resultSelector?: ($, item) => any): Enumerable; + SelectMany(collectionSelector: string, resultSelector?: string): Enumerable; + Where(predicate: ($, i: number) => bool): Enumerable; + Where(predicate: string): Enumerable; + OfType(type: Function): Enumerable; + Zip(second: any[], selector: (v1, v2, i: number) => any): Enumerable; + Zip(second: any[], selector: string): Enumerable; + Zip(second: Enumerable, selector: (v1, v2, i: number) => any): Enumerable; + Zip(second: Enumerable, selector: string): Enumerable; + //Join Methods + Join(inner: any[], outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2) => any, compareSelector?: (v) => any): Enumerable; + Join(inner: any[], outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable; + Join(inner: Enumerable, outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2) => any, compareSelector?: (v) => any): Enumerable; + Join(inner: Enumerable, outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable; + GroupJoin(inner: any[], outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2: Enumerable) => any, compareSelector?: (v) => any): Enumerable; + GroupJoin(inner: any[], outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable; + GroupJoin(inner: Enumerable, outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2: Enumerable) => any, compareSelector?: (v) => any): Enumerable; + GroupJoin(inner: Enumerable, outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable; + //Set Methods + All(predicate: ($) => bool): bool; + All(predicate: string): bool; + Any(predicate?: ($) => bool): bool; + Any(predicate?: string): bool; + Concat(second: any[]): Enumerable; + Concat(second: Enumerable): Enumerable; + Insert(index: number, second: any[]): Enumerable; + Insert(index: number, second: Enumerable): Enumerable; + Alternate(value): Enumerable; + Contains(value, compareSelector?: ($) => any): bool; + Contains(value, compareSelector?: string): bool; + DefaultIfEmpty(defaultValue): Enumerable; + Distinct(compareSelector?: ($) => any): Enumerable; + Distinct(compareSelector?: string): Enumerable; + Except(second: any[], compareSelector?: ($) => any): Enumerable; + Except(second: any[], compareSelector?: string): Enumerable; + Except(second: Enumerable, compareSelector?: ($) => any): Enumerable; + Except(second: Enumerable, compareSelector?: string): Enumerable; + Intersect(second: any[], compareSelector?: ($) => any): Enumerable; + Intersect(second: any[], compareSelector?: string): Enumerable; + Intersect(second: Enumerable, compareSelector?: ($) => any): Enumerable; + Intersect(second: Enumerable, compareSelector?: string): Enumerable; + SequenceEqual(second: any[], compareSelector?: ($) => any): bool; + SequenceEqual(second: any[], compareSelector?: string): bool; + SequenceEqual(second: Enumerable, compareSelector?: ($) => any): bool; + SequenceEqual(second: Enumerable, compareSelector?: string): bool; + Union(second: any[], compareSelector?: ($) => any): Enumerable; + Union(second: any[], compareSelector?: string): Enumerable; + Union(second: Enumerable, compareSelector?: ($) => any): Enumerable; + Union(second: Enumerable, compareSelector?: string): Enumerable; + //Ordering Methods + OrderBy(keySelector?: ($) => any): OrderedEnumerable; + OrderBy(keySelector?: string): OrderedEnumerable; + OrderByDescending(keySelector?: ($) => any): OrderedEnumerable; + OrderByDescending(keySelector?: string): OrderedEnumerable; + Reverse(): Enumerable; + Shuffle(): Enumerable; + //Grouping Methods + GroupBy(keySelector: ($) => any, elementSelector?: ($) => any, resultSelector?: (key, e) => any, compareSelector?: ($) =>any): Enumerable; + GroupBy(keySelector: string, elementSelector?: string, resultSelector?: string, compareSelector?: string): Enumerable; + PartitionBy(keySelector: ($) => any, elementSelector?: ($) => any, resultSelector?: (key, e) => any, compareSelector?: ($) =>any): Enumerable; + PartitionBy(keySelector: string, elementSelector?: string, resultSelector?: string, compareSelector?: string): Enumerable; + BufferWithCount(count: number): Enumerable; + // Aggregate Methods + Aggregate(func: (a, b) => any); + Aggregate(seed, func: (a, b) => any, resultSelector?: ($) => any); + Aggregate(func: string); + Aggregate(seed, func: string, resultSelector?: string); + Average(selector?: ($) => number): number; + Average(selector?: string): number; + Count(predicate?: ($) => bool): number; + Count(predicate?: string): number; + Max(selector?: ($) => number): number; + Max(selector?: string): number; + Min(selector?: ($) => number): number; + Min(selector?: string): number; + MaxBy(selector: ($) => number): any; + MaxBy(selector: string): any; + MinBy(selector: ($) => number): any; + MinBy(selector: string): any; + Sum(selector?: ($) => number): number; + Sum(selector?: string): number; + //Paging Methods + ElementAt(index: number): any; + ElementAtOrDefault(index: number, defaultValue): any; + First(predicate?: ($) => bool): any; + First(predicate?: string): any; + FirstOrDefault(defaultValue, predicate?: ($) => bool): any; + FirstOrDefault(defaultValue, predicate?: string): any; + Last(predicate?: ($) => bool): any; + Last(predicate?: string): any; + LastOrDefault(defaultValue, predicate?: ($) => bool): any; + LastOrDefault(defaultValue, predicate?: string): any; + Single(predicate?: ($) => bool): any; + Single(predicate?: string): any; + SingleOrDefault(defaultValue, predicate?: ($) => bool): any; + SingleOrDefault(defaultValue, predicate?: string): any; + Skip(count: number): Enumerable; + SkipWhile(predicate: ($, i: number) => bool): Enumerable; + SkipWhile(predicate: string): Enumerable; + Take(count: number): Enumerable; + TakeWhile(predicate: ($, i: number) => bool): Enumerable; + TakeWhile(predicate: string): Enumerable; + TakeExceptLast(count?: number): Enumerable; + TakeFromLast(count: number): Enumerable; + IndexOf(item): number; + LastIndexOf(item): number; + // Convert Methods + ToArray(): any[]; + ToLookup(keySelector: ($) => any, elementSelector?: ($) => any, compareSelector?: (key) => any): Lookup; + ToLookup(keySelector: string, elementSelector?: string, compareSelector?: string): Lookup; + ToObject(keySelector: ($) => string, elementSelector: ($) => any): any; + ToObject(keySelector: string, elementSelector: string): any; + ToDictionary(keySelector: ($) => any, elementSelector: ($) => any, compareSelector?: (key) => any): Dictionary; + ToDictionary(keySelector: string, elementSelector: string, compareSelector?: string): Dictionary; + ToJSON(replacer?: (key, value) => any, space?: number): string; + ToJSON(replacer?: string, space?: number): string; + ToString(separator?: string, selector?: ($) =>any): string; + ToString(separator?: string, selector?: string): string; + //Action Methods + Do(action: ($, i: number) => void ): Enumerable; + Do(action: string): Enumerable; + ForEach(action: ($, i: number) => void ): void; + ForEach(func: ($, i: number) => bool): void; + ForEach(action_func: string): void; + Write(separator?: string, selector?: ($) =>any): void; + Write(separator?: string, selector?: string): void; + WriteLine(selector?: ($) =>any): void; + Force(): void; + //Functional Methods + Let(func: (e: Enumerable) => Enumerable): Enumerable; + Share(): Enumerable; + MemoizeAll(): Enumerable; + //Error Handling Methods + Catch(handler: (error: Error) => void ): Enumerable; + Catch(handler: string): Enumerable; + Finally(finallyAction: () => void ): Enumerable; + Finally(finallyAction: string): Enumerable; + //For Debug Methods + Trace(message?: string, selector?: ($) =>any): Enumerable; + Trace(message?: string, selector?: string): Enumerable; + } + + interface OrderedEnumerable extends Enumerable { + ThenBy(keySelector: ($) => any): OrderedEnumerable; + ThenBy(keySelector: string): OrderedEnumerable; + ThenByDescending(keySelector: ($) => any): OrderedEnumerable; + ThenByDescending(keySelector: string): OrderedEnumerable; + } + + interface Grouping extends Enumerable { + Key(); + } + + interface Lookup { + Count(): number; + Get(key): Enumerable; + Contains(key): bool; + ToEnumerable(): Enumerable; + } + + interface Dictionary { + Add(key, value): void; + Get(key): any; + Set(key, value): bool; + Contains(key): bool; + Clear(): void; + Remove(key): void; + Count(): number; + ToEnumerable(): Enumerable; + } +} + +declare var Enumerable: linq.EnumerableStatic; \ No newline at end of file diff --git a/Definitions/sammyjs-0.7.d.ts b/Definitions/sammyjs-0.7.d.ts new file mode 100644 index 000000000..8582eb3cc --- /dev/null +++ b/Definitions/sammyjs-0.7.d.ts @@ -0,0 +1,235 @@ +// Type definitions for Sammy.js +// Project: http://sammyjs.org/ +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +module Sammy { + export function (): Sammy.Application; + export function (selector: string): Sammy.Application; + export function (handler: Function): Sammy.Application; + export function (selector: string, handler: Function): Sammy.Application; + + export function Cache(app, options); + export function DataCacheProxy(initial, $element); + export function DataLocationProxy(app, data_name, href_attribute); + export function DefaultLocationProxy(app, run_interval_every); + export function EJS(app, method_alias); + + export function Exceptional(app, errorReporter); + export function Flash(app); + export function Form(app); // formFor ( name, object, content_callback ) + + export function Haml(app, method_alias); + export function Handlebars(app, method_alias); + export function Hogan(app, method_alias); + export function Hoptoad(app, errorReporter); + export function JSON(app); + export function Meld(app, method_alias); + export function MemoryCacheProxy(initial); + export function Mustache(app, method_alias); + export function NestedParams(app); + export function OAuth2(app); + export function PathLocationProxy(app); + export function Pure(app, method_alias); + export function PushLocationProxy(app); + export function Session(app, options); + export function Storage(app); + + export function Title(); + export function Tmpl(app, method_alias); + export function addLogger(logger); + export function log(); + + export interface Object { + + constructor (obj: any); + + escapeHTML(s: string): string; + h(s: string): string; + + has(key: string): bool; + join(...args: any[]): string; + keys(attributes_only?: bool): string[]; + log(...args: any[]): void; + toHTML(): string; + toHash(): any; + toString(include_functions?: bool): string; + } + + export interface Application extends Object { + + ROUTE_VERBS: string[]; + APP_EVENTS: string[]; + + (appFn: Function); + + $element(selector?: string): JQuery; + after(callback: Function): Application; + any(verb: string, path: string, callback: Function): void; + route(verb: string, path: string, callback: Function): void; + around(callback: Function): Application; + before(options: any, callback: Function): Application; + bind(name: string, callback: Function): Application; + bind(name: string, data: any, callback: Function): Application; + bindToAllEvents(callback: Function): Application; + clearTemplateCache(): any; + contextMatchesOptions(context: any, match_options: any, positive?: bool): bool; + del(path: string, callback: Function): Application; + del(path: RegExp, callback: Function): Application; + destroy(): Application; + error(message: string, original_error: Error): void; + eventNamespace(): string; + get(path: string, callback: Function): Application; + get(path: RegExp, callback: Function): Application; + getLocation(): string; + helper(name: string, method: Function): Application; + helpers(extensions: any): Application; + isRunning(): bool; + log(...params: any[]): void; + lookupRoute(verb: string, path: string): any; + mapRoutes(route_array: any[]): Application; + notFound(verb: string, path: string): any; + post(path: string, callback: Function): Application; + post(path: RegExp, callback: Function): Application; + put(path: string, callback: Function): Application; + put(path: RegExp, callback: Function): Application; + refresh(): Application; + routablePath(path: string): string; + route(verb: string, path: string, callback: Function): Application; + route(verb: string, path: RegExp, callback: Function): Application; + run(start_url?: string): Application; + runRoute(verb: string, path: string, params: any, target: any): any; + setLocation(new_location: string): string; + setLocationProxy(new_proxy: DataLocationProxy): void; + swap(content: any, callback: Function): string; + templateCache(key: string, value: any): any; + toString(): string; + trigger(name: string, data?: any): Application; + unload(): Application; + use(...params: any[]): void; + } + + export interface DataLocationProxy { + constructor (app, run_interval_every): DataLocationProxy; + fullPath(location_obj): string; + bind(): void; + unbind(): void; + setLocation(new_location: string): string; + _startPolling(every: number): void; + } + + export interface EventContext extends Object { + constructor (app, verb, path, params, target); + $element(): JQuery; + engineFor(engine: any): any; + eventNamespace(): string; + interpolate(content: any, data: any, engine: any, partials): EventContext; + json(str: string): any; + load(location: any, options?: any, callback?: Function): any; + loadPartials(partials); + notFound(): any; + partial(location: string, data: any, callback: Function, partials): RenderContext; + redirect(...params: any[]): void; + render(location: string, data: any, callback: Function, partials): RenderContext; + renderEach(location: any, name?: string, data?: any, callback?: Function): RenderContext; + send(...params: any[]): RenderContext; + swap(contents: any, callback: Function): string; + toString(): string; + trigger(name: string, data?: any): EventContext; + } + + export interface FormBuilder { + constructor (name, object); + checkbox(keypath: string, value: any, ...attributes: any[]): string; + close(): string; + hidden(keypath: string, ...attributes: any[]): string; + label(keypath: string, content: any, ...attributes: any[]): string; + open(...attributes: any[]); + password(keypath: string, ...attributes: any[]): string; + radio(keypath: string, value: any, ...attributes: any[]): string; + select(keypath: string, options: any, ...attributes: any[]): string; + submit(...attributes: any[]): string; + text(keypath: string, ...attributes: any[]): string; + textarea(keypath: string, ...attributes: any[]): string; + } + + export interface Form { + formFor(name: string, object: any, content_callback: Function): FormBuilder; + } + + export interface GoogleAnalytics { + constructor (app, tracker); + noTrack(); + track(path); + } + + export interface RenderContext extends Object { + constructor (event_context); + appendTo(selector: string): RenderContext; + collect(array: any[], callback: Function, now?: bool): RenderContext; + interpolate(data: any, engine?: any, retain?: bool): RenderContext; + load(location: string, options?: any, callback?: Function): RenderContext; + loadPartials(partials?: any): RenderContext; + next(content: any): void; + partial(location: string, callback: Function, partials): RenderContext; + partial(location: string, data: any, callback: Function, partials): RenderContext; + prependTo(selector: string): RenderContext; + render(callback: Function): RenderContext; + render(location: string, data: any): RenderContext; + render(location: string, callback: Function, partials?: any): RenderContext; + render(location: string, data: any, callback: Function): RenderContext; + render(location: string, data: any, callback: Function, partials: any): RenderContext; + renderEach(location: string, name: string, data: any, callback: Function): RenderContext; + replace(selector: string): RenderContext; + send(...params: any[]): RenderContext; + swap(callback: Function): RenderContext; + then(callback: Function): RenderContext; + trigger(name, data); + wait(): void; + } + + + export interface StoreOptions { + name?: string; + element?: string; + type?: string; + memory?: any; + data?: any; + cookie?: any; + local?: any; + session?: any; + } + + export interface Store { + + stores: any; + + constructor (options); + + clear(key: string): any; + clearAll(): void; + each(callback: Function): bool; + exists(key: string): bool; + fetch(key: string, callback: Function): any; + filter(callback: Function): bool; + first(callback: Function): bool; + get(key: string): any; + isAvailable(): bool; + keys(): string[]; + load(key: string, path: string, callback: Function): void; + set(key: string, value: any): any; + + Cookie(name, element, options); + Data(name, element); + LocalStorage(name, element); + Memory(name, element); + SessionStorage(name, element); + isAvailable(type); + Template(app, method_alias); + } +} +interface JQueryStatic { + sammy: Sammy; +} \ No newline at end of file diff --git a/README.md b/README.md index a92d08c42..a7318226b 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Complete * [jQuery UI](http://jqueryui.com/) * [Knockout.js](http://knockoutjs.com/) * [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) +* [linq.js](http://linqjs.codeplex.com/) (by Marcin Najder (https://github.com/marcinnajder)) * [Modernizr](http://modernizr.com/) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [Mustache.js](https://github.com/janl/mustache.js) @@ -35,6 +36,7 @@ Complete * [node_redis](https://github.com/mranney/node_redis) * [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) * [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) +* [Sammy.js](http://sammyjs.org/) * [Spin](http://fgnass.github.com/spin.js/) * [Underscore.js](http://underscorejs.org/) @@ -47,4 +49,6 @@ Next * Meteor * PhoneGap * Isotope -* Zepto \ No newline at end of file +* Zepto +* Socket.IO +* MongoDB \ No newline at end of file diff --git a/Tests/linq-tests.ts b/Tests/linq-tests.ts new file mode 100644 index 000000000..56e36fdab --- /dev/null +++ b/Tests/linq-tests.ts @@ -0,0 +1,39 @@ +/// +/// +// tests were run from VisualStudio + Resharper7 + +describe("Linq.js tests", function () { + it("Projection and Filtering Methods", function () { + expect(Enumerable.From([1,2,3,4]).ToString(",")).toBe("1,2,3,4"); + expect(Enumerable.Range(1, 4).Where((item: number) => item > 2).ToString(",")).toBe("3,4"); + expect(Enumerable.Range(1, 4).Where("(item) => item > 2").ToString(",")).toBe("3,4"); + expect(Enumerable.Range(1, 4).Where("$>2").ToString(",")).toBe("3,4"); + expect(Enumerable.Range(1, 4).Select((item: number,index:number) => item+index).ToString(",")).toBe("1,3,5,7"); + expect(Enumerable.Range(1, 4).Zip(Enumerable.Range(1, 10), (a: number,b:number) => a-b).ToString(",")).toBe("0,0,0,0"); + + }); + it("Join Methods", function () { + expect(Enumerable.Range(1, 4).Join(Enumerable.From(["a", "aaa"]), (l) => l, (r: string) => r.length, (l, r) =>l + ":" + r).ToString(",")).toBe("1:a,3:aaa"); + }); + it("Set Methods", function () { + expect(Enumerable.Range(2, 4, 2).All((item: number) => item % 2 == 0)).toBe(true); + expect(Enumerable.Range(1, 4).Intersect(Enumerable.Range(3, 4)).ToString(",")).toBe("3,4"); + }); + it("Ordering Methods", function () { + expect(Enumerable.From( + [ + { name: "marcin", age:15}, + { name: "albert", age:51}, + { name: "marcin", age:30}, + ]).OrderBy((p) => p.name).ThenByDescending((p) => p.age).Select((p) => p.name+p.age).ToString(",")).toBe("albert51,marcin30,marcin15"); + }); + it("Grouping Methods", function () { + expect(Enumerable.From(["a","aa","aaa","a","a","aaa"]) + .GroupBy((item:string) => item.length) + .Select((g: linq.Grouping) => { return { key: g.Key(), count: g.Count() }; }) + .OrderBy(g => g.key) + .Select(g => g.key+":"+g.count) + .ToString(",")).toBe("1:3,2:1,3:2"); + }); +}); + diff --git a/Tests/sammyjs-tests.ts b/Tests/sammyjs-tests.ts new file mode 100644 index 000000000..588d08f2c --- /dev/null +++ b/Tests/sammyjs-tests.ts @@ -0,0 +1,540 @@ +/// + +function test_general() { + var app = Sammy('#main', function () { + var _this: Sammy.Application; + _this.use('Mustache'); + _this.get('#/', function () { + var _this: Sammy.RenderContext; + _this.load('posts.json') + .renderEach('post.mustache') + .swap(); + }); + }); + + app.run('#/'); + + var _this: Sammy.Application; + _this.get('#/', function (context) { + var _this: Sammy.RenderContext; + _this.load('data/items.json') + .then(function (items) { + $.each(items, function (i, item) { + context.log(item.title, '-', item.artist); + }); + }); + }); +} + +function test_app() { + var s = new Sammy.Object({ first_name: 'Sammy', last_name: 'Davis Jr.' }); + s.toHTML(); + + var app = $.sammy(function () { + + var current_user = false; + function checkLoggedIn(callback) { + var _this: Sammy.EventContext; + if (!current_user) { + $.getJSON('/session', function (json) { + if (json.login) { + current_user = json; + callback(); + } else { + current_user = false; + _this.redirect('#/login'); + } + }); + } else { + callback(); + } + }; + var _this: Sammy.Application; + _this.around(checkLoggedIn); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.before('#/route', function () { }); + _this.before({ except: { path: '#/route' } }, function () { + _this.log('not before #/route'); + }); + _this.get('#/', function () { }); + _this.get('#/route', function () { }); + }); + + var app = $.sammy(), + context = { verb: 'get', path: '#/mypath' }; + + app.contextMatchesOptions(context, '#/mypath'); + app.contextMatchesOptions(context, '#/otherpath'); + app.contextMatchesOptions(context, { only: { path: '#/mypath' } }); + app.contextMatchesOptions(context, { only: { path: '#/otherpath' } }); + app.contextMatchesOptions(context, /path/); + app.contextMatchesOptions(context, /^path/); + app.contextMatchesOptions(context, { only: { verb: 'get' } }); + app.contextMatchesOptions(context, { only: { verb: 'post' } }); + app.contextMatchesOptions(context, { except: { verb: 'post' } }); + app.contextMatchesOptions(context, { except: { verb: 'get' } }); + app.contextMatchesOptions(context, { except: { path: '#/otherpath' } }); + app.contextMatchesOptions(context, { except: { path: '#/mypath' } }); + app.contextMatchesOptions(context, { path: ['#/mypath', '#/otherpath'] }); + app.contextMatchesOptions(context, { path: ['#/otherpath', '#/thirdpath'] }); + app.contextMatchesOptions(context, { only: { path: ['#/mypath', '#/otherpath'] } }); + app.contextMatchesOptions(context, { only: { path: ['#/otherpath', '#/thirdpath'] } }); + app.contextMatchesOptions(context, { except: { path: ['#/mypath', '#/otherpath'] } }); + app.contextMatchesOptions(context, { except: { path: ['#/otherpath', '#/thirdpath'] } }); + + var app = $.sammy(function (app) { + var _this: Sammy.Application; + $.each([1, 2, 3], function (i, num) { + app.helper('helper' + num, function () { + _this.log("I'm helper number " + num); + }); + }); + _this.get('#/', function () { + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.helpers({ + upcase: function (text) { + return text.toString().toUpperCase(); + } + }); + _this.get('#/', function () { + with (_this) { + $('#main').html(upcase($('#main').text())); + } + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.mapRoutes([ + ['get', '#/', function () { }], + ['post', '#/create', 'addUser'], + [/dowhatever/, function () { }] + ]); + }); + + var app = $.sammy(function () { }); + $(function () { + app.run(); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.setLocationProxy(new Sammy.DataLocationProxy(_this)); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.swap = function (content, callback) { + var context = _this; + context.$element().fadeOut('slow', function () { + context.$element().html(content); + context.$element().fadeIn('slow', function () { + if (callback) { + callback.apply(); + } + }); + }); + }; + }); + + var MyPlugin = function (app, prepend) { + var _this: Sammy.Application; + _this.helpers({ + myhelper: function (text) { + alert(prepend + " " + text); + } + }); + }; + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use(MyPlugin, '_this is my plugin'); + _this.get('#/', function () { + }); + }); + + $.sammy(function () { + var _this: Sammy.Application; + _this.use('Mustache'); + _this.use('Storage'); + }); +} + +function test_misc() { + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.setLocationProxy(new Sammy.DataLocationProxy(_this, 'location', 'rel')); + _this.get('about', function () { + var _this: Sammy.EventContext; + _this.partial('about.html'); + }); + }); + + $.sammy(function () { + var _this: Sammy.Application; + _this.get('#/:name', function () { + if (_this.params['name'] == 'sammy') { + _this.partial('name.html.erb', { name: 'Sammy' }); + } else { + _this.redirect('#/somewhere-else') + } + }); + }); + + var _this: Sammy.Application; + _this.redirect('#/other/route'); + _this.redirect('#', 'other', 'route'); + _this.render('mytemplate.mustache', { name: 'quirkey' }) + .appendTo('ul'); + _this.renderEach('mytemplate.mustache', [{ name: 'quirkey' }, { name: 'endor' }]); + + var item = { + name: 'My Item', + price: '$25.50', + meta: { + id: '123' + } + }; + var form = new Sammy.FormBuilder('item', item); + form.text('name'); + + var options = [ + ['Small', 's'], + ['Medium', 'm'], + ['Large', 'l'] + ]; + form.select('size', options); + + $.sammy(function () { + var _this: Sammy.Application; + _this.use('GoogleAnalytics') + _this.get('#/dont/track/me', function () { + _this.noTrack(); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use(Sammy.Haml); + _this.get('#/hello/:name', function () { + _this.title = 'Hello!' + _this.name = _this.params.name; + _this.partial('mytemplate.haml'); + }); + }); + app.run() + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Handlebars', 'hb'); + _this.get('#/hello/:name', function () { + _this.title = 'Hello!' + _this.name = _this.params.name; + _this.partial('mytemplate.hb'); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Handlebars', 'hb'); + _this.get('#/hello/:name/to/:friend', function (context) { + _this.load('mypartial.hb') + .then(function (partial) { + context.partials = { hello_friend: partial }; + context.name = context.params.name; + context.friend = context.params.friend; + context.partial('mytemplate.hb'); + }); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Hogan', 'hg'); + _this.get('#/hello/:name', function () { + _this.title = 'Hello!' + _this.name = _this.params.name; + _this.partial('mytemplate.hg'); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Hogan', 'hg'); + _this.get('#/hello/:name/to/:friend', function (context) { + _this.load('mypartial.hg') + .then(function (partial) { + context.partials = { hello_friend: partial }; + context.name = context.params.name; + context.friend = context.params.friend; + context.partial('mytemplate.hg'); + }); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use(Sammy.JSON); + _this.get('#/', function () { + _this.json({ user_id: 123 }); + _this.json("{\"user_id\":\"123\"}"); + _this.json("{\"user_id\":\"123\"}").user_id; + }); + }) + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Mustache', 'ms'); + _this.get('#/hello/:name', function () { + _this.title = 'Hello!' + _this.name = _this.params.name; + _this.partial('mytemplate.ms'); + }); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use('Mustache', 'ms'); + _this.get('#/hello/:name/to/:friend', function (context) { + _this.load('mypartial.ms') + .then(function (partial) { + context.partials = { hello_friend: partial }; + context.name = context.params.name; + context.friend = context.params.friend; + context.partial('mytemplate.ms'); + }); + }); + }); + + var app = $.sammy(function (app) { + var _this: Sammy.Application; + _this.use(Sammy.NestedParams); + _this.post('#/parse_me', function (context) { + $.log(_this.params); + }); + }); + + var _this: Sammy.Application; + _this.use('Storage'); + _this.use('OAuth2'); + _this.oauthorize = "/oauth/authorize"; + _this.requireOAuth(); + _this.requireOAuth("/private"); + _this.before(function (context) { return context.requireOAuth(); }) + _this.get("/private", function (context) { + _this.requireOAuth(function () { }); + }); + _this.bind("oauth.connected", function () { $("#signin").hide() }); + _this.bind("oauth.disconnected", function () { $("#signin").show() }); + _this.bind("oauth.denied", function (evt, error) { + _this.partial("admin/views/no_access.tmpl", { error: error.message }); + }); + _this.get("#/signout", function (context) { + context.loseAccessToken(); + context.redirect("#/"); + }); + + _this.get('#/', function () { + _this.render('mytemplate.template', { name: 'test' }); + }); + + _this.send($.getJSON, '/app.json') + .then(function (json) { + $('#message').text(json['message']); + } + ); + + _this.get('#/', function () { + _this.load('myfile.txt') + .then(function (content) { + $('#main').html(content); + }); + }); + + _this.get('#/', function () { + _this.load('mytext.json') + .then(function (content) { + var context = _this, + data = JSON.parse(content); + context.wait(); + $.post(data.url, {}, function (response) { + context.next(JSON.parse(response)); + }); + }) + .then(function (data) { + $('#message').text(data.status); + }); + }); + + var store = new Sammy.Store({ name: 'mystore', element: '#element', type: 'local' }); + store.set('foo', 'bar'); + store.get('foo'); + store.set('json', { obj: '_this is an obj' }); + store.get('json'); + store.keys(); + store.clear('foo'); + store.keys(); + store.clearAll(); + store.keys(); + + store.each(function (key, value) { + Sammy.log('key', key, 'value', value); + }); + var store = new Sammy.Store; + store.exists('foo'); + store.fetch('foo', function () { + return 'bar!'; + }); + store.get('foo'); + store.fetch('foo', function () { + return 'baz!'; + }); + + var store = new Sammy.Store; + store.set('one', 'two'); + store.set('two', 'three'); + store.set('1', 'two'); + var returned = store.filter(function (key, value) { + return value === 'two'; + }); + + var store = new Sammy.Store; + store.load('mytemplate', '/mytemplate.tpl', function () { + s.get('mytemplate') + }); + + var store = new Sammy.Store({ name: 'kvo' }); + $('body').bind('set-kvo-foo', function (e, data) { + Sammy.log(data.key + ' changed to ' + data.value); + }); + store.set('foo', 'bar'); + + $.sammy(function () { + _this.use('Template'); + _this.get('#/', function () { + _this.user = { name: 'Aaron Quint' }; + _this.partial('user.template'); + }) + }); + + _this.use(Sammy.Template, 'tpl'); + _this.get('#/', function () { + _this.partial('myfile.tpl'); + }); + _this.get('#/', function () { + _this.template('myform.tpl', { form: "
" }, { escape_html: false }); + }); +} + +function test_routes() { + var _this: Sammy.Application; + + _this.route('get', '#/', function () { + }); + _this.put('#/post/form', function () { + return false; + }); + _thisget('/test/123', function () { + }); + + _thisget('#/by_name/:name', function () { + alert(_this.params['name']); + }); + _thisget(/\#\/by_name\/(.*)/, function () { + alert(_this.params['splat']); + }); + _thisget('#/by_name/:name', function () { + _this.redirect('#', _this.params['name']); + }); + + _thisget('#/by_name/:name', function (context) { + context.redirect('#', _this.params['name']); + }); +} + +function test_events() { + var _this: Sammy.Application; + + _this.bind('db-loaded', function (e, data) { + var _this: Sammy.EventContext; + _this.redirect('#/'); + }); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.bind('test', function () { + var _this: Sammy.EventContext; + _this.trigger('other-event'); + }); + }); + app.trigger('other-event'); + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.bind('test', function (e, data) { + alert(data['my_data']); + }); + _this.get('#/', function () { + _this.trigger('test', { my_data: 'EVENTED!' }); + }); + }); +} + +function test_plugins() { + var MyPlugin = function (app) { + var _this: Sammy.Application; + _this.helpers({ + alert: function (message) { + _this.log("ALERT! " + message); + } + }); + }; + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use(MyPlugin); + _this.get('#/', function () { + var _this: Sammy.EventContext; + _this.alert("I'm home"); + }); + }); + var MyAdvancedPlugin = function (app, prefix, suffix) { + var _this: Sammy.Application; + _this.helpers({ + alert: function (message) { + _this.log(prefix, message, suffix); + } + }); + }; + + var app = $.sammy(function () { + var _this: Sammy.Application; + _this.use(MyAdvancedPlugin, 'BEFORE!', 'AFTER!'); + _this.get('#/', function () { + _this.alert("I'm home"); + }); + }); + + var dbLoadAndDisplay = function (app) { + var _this: Sammy.Application; + _this.get('#/', function () { + _this.record = _this.app.db[_this.app.element_selector]; + _this.app.swap(_this.record.toHTML()); + }); + _this.bind('run', function () { + }); + }; + + var app1 = Sammy('#div_1', function () { + _this.use(dbLoadAndDisplay); + }); + + var app2 = Sammy('#div_2', function () { + _this.use(dbLoadAndDisplay); + }); +} \ No newline at end of file