From da4f02bd35aaac24b62debfac86e054520191af4 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:42:17 +0200 Subject: [PATCH 01/10] Typeahead: added missing options, and missing parameters, normalized some comments and code style --- typeahead/typeahead-tests.ts | 64 +++-- typeahead/typeahead.d.ts | 507 +++++++++++++++++------------------ 2 files changed, 281 insertions(+), 290 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 2bcb016c0..3864865c9 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,14 +6,10 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: any, cb: any) { - var matches: any, substrRegex: any; - - // an array that will be populated with substring matches - matches = []; - + return function findMatches(q: string, syncResults: (x: any) => void) { + var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` - substrRegex = new RegExp(q, 'i'); + var substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array @@ -25,7 +21,7 @@ var substringMatcher = function (strs: any) { } }); - cb(matches); + syncResults(matches); } } @@ -46,14 +42,14 @@ function test_method_names() { $('#the-basics .typeahead').typeahead('open'); $('#the-basics .typeahead').typeahead('close'); $('#the-basics .typeahead').typeahead('val'); - $('#the-basics .typeahead').typeahead('val', 'test value'); + $('#the-basics .typeahead').typeahead('val', 'test value'); } function test_options() { var dataSets: Twitter.Typeahead.Dataset[] = []; - + function with_empty_options() { $('#the-basics .typeahead').typeahead({}, dataSets); } @@ -72,10 +68,10 @@ function test_options() { function with_all_options() { $('#the-basics .typeahead').typeahead({ - hint: true, - highlight: true, - minLength: 1 - }, + hint: true, + highlight: true, + minLength: 1 + }, dataSets ); } @@ -101,33 +97,33 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', - source: substringMatcher(states) - }] + displayKey: 'value', + source: substringMatcher(states) + }] ); } function with_templates_option() { $('#the-basics .typeahead').typeahead(options, [{ - templates: {}, - source: substringMatcher(states) - }] + templates: {}, + source: substringMatcher(states) + }] ); } function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ - name: 'states', - displayKey: 'value', - templates: {}, - source: substringMatcher(states) - }] + name: 'states', + displayKey: 'value', + templates: {}, + source: substringMatcher(states) + }] ); } function with_multiple_datasets() { $('#the-basics .typeahead').typeahead(options, [ - { + { name: 'states', displayKey: 'value', templates: {}, @@ -192,7 +188,7 @@ function test_datasets_objects() { } function with_multiple_objects() { - $('#the-basics .typeahead').typeahead(options, + $('#the-basics .typeahead').typeahead(options, { name: 'states', displayKey: 'value', @@ -231,7 +227,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: function(context: any) { + empty: function (context: any) { return context.name; } } @@ -249,7 +245,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - footer: function(context: any) { + footer: function (context: any) { return context.name; } } @@ -267,7 +263,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - header: function(context: any) { + header: function (context: any) { return context.name; } } @@ -277,8 +273,8 @@ function test_dataset_templates() { function with_suggestion_option() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), - templates: { - suggestion: function(context) { + templates: { + suggestion: function (context) { return context.name; } } @@ -289,10 +285,10 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: 'no results', + empty: 'no results', footer: 'custom footer', header: 'custom header', - suggestion: function(context) { + suggestion: function (context) { return context.name; } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index a8b139937..cde3a9277 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -10,19 +10,19 @@ interface JQuery { /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. * The menu is only visible when it is open and has content. - * - * @constructor + * + * @constructor * @param methodName Method 'open' - */ + */ typeahead(methodName: 'open'): JQuery; /** @@ -36,10 +36,10 @@ interface JQuery { /** * Returns the current value of the typeahead. * The value is the text the user has entered into the input element. - * - * @constructor + * + * @constructor * @param methodName Method 'val' - */ + */ typeahead(methodName: 'val'): string; /** @@ -87,7 +87,7 @@ interface JQuery { * @param options ('hint' or 'highlight' or 'minLength' all of which are optional) * @param datasets One or more datasets passed in as arguments. */ - typeahead(options: Twitter.Typeahead.Options, ... datasets: Twitter.Typeahead.Dataset[]): JQuery; + typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; } declare module Twitter.Typeahead { @@ -104,8 +104,8 @@ declare module Twitter.Typeahead { * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. * cb can be invoked synchronously or asynchronously. * - */ - source: (query: string, cb: (result: any) => void) => void; + */ + source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); /** * The name of the dataset. @@ -125,32 +125,33 @@ declare module Twitter.Typeahead { /** * A hash of templates to be used when rendering the dataset. * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. - */ + */ templates?: Templates; + async?: boolean; + display?: boolean | ((x: any) => boolean); } interface Templates { - /** * Rendered when 0 suggestions are available for the given query. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query - */ + */ empty?: any; /** * Rendered at the bottom of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ footer?: any; /** * Rendered at the top of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ header?: any; /** @@ -158,273 +159,267 @@ declare module Twitter.Typeahead { * If set, this has to be a precompiled template. * The associated suggestion object will serve as the context. * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. - */ + */ suggestion?: (datum: any) => string; } - /** - * When initializing a typeahead, there are a number of options you can configure. - */ + /** + * When initializing a typeahead, there are a number of options you can configure. + */ interface Options { - /** - * highlight: If true, when suggestions are rendered, - * pattern matches for the current query in text nodes will be wrapped in a strong element. - * Defaults to false. - */ - highlight?: boolean; + /** + * highlight: If true, when suggestions are rendered, + * pattern matches for the current query in text nodes will be wrapped in a strong element. + * Defaults to false. + */ + highlight?: boolean; - /** - * If false, the typeahead will not show a hint. Defaults to true. - */ - hint?: boolean; + /** + * If false, the typeahead will not show a hint. Defaults to true. + */ + hint?: boolean; - /** - * The minimum character length needed before suggestions start getting rendered. Defaults to 1. - */ - minLength?: number; + /** + * The minimum character length needed before suggestions start getting rendered. Defaults to 1. + */ + minLength?: number; } } -declare module Bloodhound -{ - interface BloodhoundOptions - { - /** - * Transforms a datum into an array of string tokens - * - * @constructor - * @param datum individual units that compose the dataset - */ - datumTokenizer?: any; - /** - * Transforms a query into an array of string tokens - * - * @constructor - * @param query tokenizer query - */ - queryTokenizer?: any; - /** - * The max number of suggestions to return from Bloodhound#get. - * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 - */ - limit?: number; - /** - * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. - * If not set, duplicate detection will not be performed. - */ - dupDetector?: (remoteMatch: T, localMatch: T) => boolean; - /** - * A compare function used to sort matched datums for a given query. - */ - sorter?: (a: T, b: T) => number; - /** - *An array of datums or a function that returns an array of datums. - */ - local?: () => T[]; - /** - * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. - */ - prefetch?: PrefetchOptions; - /** - * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. - */ - remote?: RemoteOptions; - } - - /** - * Prefetched data is fetched and processed on initialization. - * If the browser supports localStorage, the processed data will be cached - * there to prevent additional network requests on subsequent page loads. - */ - interface PrefetchOptions - { - /** - * A URL to a JSON file containing an array of datums. Required. - */ - url: string; - /** - * The time (in milliseconds) the prefetched data should be cached - * in localStorage. Defaults to 86400000 (1 day). - */ - ttl?: number; - /** - * A function that transforms the response body into an array of datums. - * - * @param parsedResponse Response body - */ - filter?: (parsedResponse: any) => T[]; - /** The key that data will be stored in local storage under. Defaults to value of url. - * - */ - cacheKey?: string; - /** - * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. - */ - thumbprint?: string; - /** - * The ajax settings object passed to jQuery.ajax. - */ - ajax?: JQueryAjaxSettings; - } - - /** - * Remote data is only used when the data provided by local and prefetch - * is insufficient. In order to prevent an obscene number of requests - * being made to remote endpoint, typeahead.js rate-limits remote requests. - */ - interface RemoteOptions - { - /** - * A URL to make requests to when the data provided by local and - * prefetch is insufficient. Required. - */ - url: string; - /** - * The pattern in url that will be replaced with the user's query - * when a request is made. Defaults to %QUERY. - */ - wildcard?: string; - /** - * Overrides the request URL. If set, no wildcard substitution will - * be performed on url. - * - * @param url Replacement URL - * @param uriEncodedQuery Encoded query - * @returns A valid URL - */ - replace?: (url: string, uriEncodedQuery: string) => string; - /** - * The function used for rate-limiting network requests. - * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. - */ - rateLimitby?: string; - /** - * The time interval in milliseconds that will be used by rateLimitFn. - * Defaults to 300. - */ - rateLimitWait?: number; +declare module Bloodhound { + interface BloodhoundOptions { + /** + * Transforms a datum into an array of string tokens + * + * @constructor + * @param datum individual units that compose the dataset + */ + datumTokenizer?: any; + /** + * Transforms a query into an array of string tokens + * + * @constructor + * @param query tokenizer query + */ + queryTokenizer?: any; + /** + * The max number of suggestions to return from Bloodhound#get. + * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 + */ + limit?: number; + /** + * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. + * If not set, duplicate detection will not be performed. + */ + dupDetector?: (remoteMatch: T, localMatch: T) => boolean; + /** + * A compare function used to sort matched datums for a given query. + */ + sorter?: (a: T, b: T) => number; + /** + * An array of datums or a function that returns an array of datums. + */ + local?: () => T[]; + /** + * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. + */ + prefetch?: PrefetchOptions; + /** + * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. + */ + remote?: RemoteOptions; + } /** - * Transforms the response body into an array of datums. - * - * @param parsedResponse Response body + * Prefetched data is fetched and processed on initialization. + * If the browser supports localStorage, the processed data will be cached + * there to prevent additional network requests on subsequent page loads. */ - filter?: (parsedResponse: any) => T[]; + interface PrefetchOptions { + /** + * A URL to a JSON file containing an array of datums. Required. + */ + url: string; + /** + * The time (in milliseconds) the prefetched data should be cached + * in localStorage. Defaults to 86400000 (1 day). + */ + ttl?: number; + /** + * A function that transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** The key that data will be stored in local storage under. Defaults to value of url. + * + */ + cacheKey?: string; + /** + * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. + */ + thumbprint?: string; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; + } + /** - * The ajax settings object passed to jQuery.ajax. + * Remote data is only used when the data provided by local and prefetch + * is insufficient. In order to prevent an obscene number of requests + * being made to remote endpoint, typeahead.js rate-limits remote requests. */ - ajax?: JQueryAjaxSettings; + interface RemoteOptions { + /** + * A URL to make requests to when the data provided by local and + * prefetch is insufficient. Required. + */ + url: string; + /** + * The pattern in url that will be replaced with the user's query + * when a request is made. Defaults to %QUERY. + */ + wildcard?: string; + /** + * Overrides the request URL. If set, no wildcard substitution will + * be performed on url. + * + * @param url Replacement URL + * @param uriEncodedQuery Encoded query + * @returns A valid URL + */ + replace?: (url: string, uriEncodedQuery: string) => string; + /** + * The function used for rate-limiting network requests. + * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. + */ + rateLimitby?: string; + /** + * The time interval in milliseconds that will be used by rateLimitFn. + * Defaults to 300. + */ + rateLimitWait?: number; + + /** + * Transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; - /** - * A function that provides a hook to allow you to prepare the settings object passed to transport - * when a request is about to be made. The function signature should be prepare(query, settings), - * where query is the query #search was called with and settings is the default settings object - * created internally by the Bloodhound instance. The prepare function should return a settings object. - * [Note: Added in 0.11.1] - * - * @param query The query #search was called with. - * @param settings The default settings object created internally by Bloodhound. - * @returns A JqueryAjaxSettings object. - */ - prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; - } + /** + * A function that provides a hook to allow you to prepare the settings object passed to transport + * when a request is about to be made. The function signature should be prepare(query, settings), + * where query is the query #search was called with and settings is the default settings object + * created internally by the Bloodhound instance. The prepare function should return a settings object. + * [Note: Added in 0.11.1] + * + * @param query The query #search was called with. + * @param settings The default settings object created internally by Bloodhound. + * @returns A JqueryAjaxSettings object. + */ + prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; + } - /** - * The most common tokenization methods. - */ - interface Tokenizers - { /** - * Split a given string on whitespace characters. + * The most common tokenization methods. */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; + interface Tokenizers { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; - /** - * Instances of the most common tokenization methods. - */ - obj: ObjTokenizer; - } + /** + * Instances of the most common tokenization methods. + */ + obj: ObjTokenizer; + } - interface ObjTokenizer - { - /** - * Split a given string on whitespace characters. - */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; - } + interface ObjTokenizer { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; + } } declare class Bloodhound { - constructor(options: Bloodhound.BloodhoundOptions); - /** - * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin - */ - public ttAdapter(): any; - /** - * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. - * Until initialized, all other methods will behave as no-ops. - * Returns a jQuery promise which is resolved when engine has been initialized. - * - * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. - * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. - * If reinitialize is truthy, the method will behave as if it were being called for the first time. - * - * var promise1 = engine.initialize(); - * var promise2 = engine.initialize(); - * var promise3 = engine.initialize(true); - * - * promise1 === promise2; - * promise3 !== promise1 && promise3 !== promise2; - */ - public initialize(reinitialize?: boolean): JQueryPromise; - /** - * Takes one argument, datums, which is expected to be an array of datums. - * The passed in datums will get added to the search index that powers the suggestion engine. - */ - public add(datums: T[]): void; - /** - * Removes all suggestions from the search index. - */ - public clear(): void; - /** - * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. - * clearPrefetchCache offers a way to programmatically clear said cache. - */ - public clearPrefetchCache(): void; - /** - * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. - * clearRemoteCache offers a way to programmatically clear said cache. - */ - public clearRemoteCache(): void; - /** - * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. - */ - public noConflict(): any; + constructor(options: Bloodhound.BloodhoundOptions); + /** + * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin + */ + public ttAdapter(): any; + /** + * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. + * Until initialized, all other methods will behave as no-ops. + * Returns a jQuery promise which is resolved when engine has been initialized. + * + * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. + * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. + * If reinitialize is truthy, the method will behave as if it were being called for the first time. + * + * var promise1 = engine.initialize(); + * var promise2 = engine.initialize(); + * var promise3 = engine.initialize(true); + * + * promise1 === promise2; + * promise3 !== promise1 && promise3 !== promise2; + */ + public initialize(reinitialize?: boolean): JQueryPromise; + /** + * Takes one argument, datums, which is expected to be an array of datums. + * The passed in datums will get added to the search index that powers the suggestion engine. + */ + public add(datums: T[]): void; + /** + * Removes all suggestions from the search index. + */ + public clear(): void; + /** + * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. + * clearPrefetchCache offers a way to programmatically clear said cache. + */ + public clearPrefetchCache(): void; + /** + * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. + * clearRemoteCache offers a way to programmatically clear said cache. + */ + public clearRemoteCache(): void; + /** + * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. + */ + public noConflict(): any; - /** - * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. - * cb will always be invoked once synchronously with suggestions that were available on the client. - * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. - */ - public get(query: string, cb: (datums: T[]) => void): void; + /** + * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. + * cb will always be invoked once synchronously with suggestions that were available on the client. + * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. + */ + public get(query: string, cb: (datums: T[]) => void): void; - /** - * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. - * Specify how you want datums and queries tokenized. - */ - public static tokenizers: Bloodhound.Tokenizers; + /** + * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. + * Specify how you want datums and queries tokenized. + */ + public static tokenizers: Bloodhound.Tokenizers; } declare module "bloodhound" { - export = Bloodhound; + export = Bloodhound; } From 7d715446377a65c491337c88efec1116507c2436 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:45:35 +0200 Subject: [PATCH 02/10] Bootstrap.v3.datetimepicker: referenced moment.js less generic type parameters, updated some functions, added some missing parameters --- .../bootstrap.v3.datetimepicker-tests.ts | 14 +++---- .../bootstrap.v3.datetimepicker.d.ts | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 6abf38f94..056c76dd6 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -6,17 +6,17 @@ function test_cases() { $('#datetimepicker').datetimepicker({ pickDate: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ pickTime: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ minDate: '2012-12-31' }); - - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); - - var startDate = new Date(2012, 1, 20); - var endDate = new Date(2012, 1, 25); + + $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + + var startDate = moment(new Date(2012, 1, 20)); + var endDate = moment(new Date(2012, 1, 25)); $('#datetimepicker2') .datetimepicker() .on("dp.change", function (ev) { diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts index 228b7537f..0db3f7b3f 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts @@ -10,15 +10,22 @@ */ /// +/// declare module BootstrapV3DatetimePicker { - interface DatetimepickerChangeEventObject extends JQueryEventObject { - date: any; - oldDate: any; + enum ViewMode { + 'days', + 'months', + 'years', + 'decades' + } + + interface DatetimepickerChangeEventObject extends DatetimepickerEventObject { + oldDate: moment.Moment; } interface DatetimepickerEventObject extends JQueryEventObject { - date: any; + date: moment.Moment; } interface DatetimepickerIcons { @@ -35,33 +42,37 @@ declare module BootstrapV3DatetimePicker { useSeconds?: boolean; useCurrent?: boolean; minuteStepping?: number; - minDate?: any; - maxDate?: any; + minDate?: moment.Moment | Date | string; + maxDate?: moment.Moment | Date | string; showToday?: boolean; collapse?: boolean; language?: string; - defaultDate?: string; - disabledDates?: Array; - enabledDates?: Array; + defaultDate?: moment.Moment | Date | string; + disabledDates?: Array; + enabledDates?: Array; icons?: DatetimepickerIcons; useStrict?: boolean; direction?: string; sideBySide?: boolean; - daysOfWeekDisabled?: Array; + daysOfWeekDisabled?: Array; calendarWeeks?: boolean; format?: string | boolean; locale?: string; showTodayButton?: boolean; + viewMode?: string; + inline?: boolean; } interface Datetimepicker { - setDate(date: any): void; - setMinDate(date: any): void; - setMaxDate(date: any): void; + date(date: moment.Moment | Date | string): void; + date(): moment.Moment; + minDate(date: moment.Moment | Date | string): void; + minDate(): moment.Moment | boolean; + maxDate(date: moment.Moment | Date | string): void; + maxDate(): moment.Moment | boolean; show(): void; disable(): void; enable(): void; - getDate(): void; } } From fd6b794520e5258ff59c7501d7d155fad3dad21a Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:49:50 +0200 Subject: [PATCH 03/10] FullCalendar: updated to last version, updated some interfaces names to fit documentation, less generic arguments and options, referenced moment.js --- fullCalendar/fullCalendar-tests.ts | 43 ++++----- fullCalendar/fullCalendar.d.ts | 146 +++++++++++++++++------------ 2 files changed, 107 insertions(+), 82 deletions(-) diff --git a/fullCalendar/fullCalendar-tests.ts b/fullCalendar/fullCalendar-tests.ts index 6890cbe42..b3ec7973c 100644 --- a/fullCalendar/fullCalendar-tests.ts +++ b/fullCalendar/fullCalendar-tests.ts @@ -4,11 +4,10 @@ // All examples from http://arshaw.com/fullcalendar/docs/ -$('#calendar').fullCalendar({ -}) +$('#calendar').fullCalendar({}); $('#calendar').fullCalendar({ - weekends: false + weekends: false }); $('#calendar').fullCalendar({ @@ -67,7 +66,7 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('option', 'aspectRatio', 1.8); $('#calendar').fullCalendar({ - viewRender: function(view) { + viewRender: function (view) { alert('The new title of the view is ' + view.title); } }); @@ -81,22 +80,19 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('render'); $('#calendar').fullCalendar({ - dragOpacity: { - month: .2, - '': .5 - } + dragOpacity: .5 }); var view = $('#calendar').fullCalendar('getView'); alert("The view's title is " + view.title); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -155,12 +151,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -220,12 +216,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -274,12 +270,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ editable: true, header: { @@ -339,12 +335,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -715,12 +711,12 @@ $('#draggable1').draggable(); $('#draggable2').draggable(); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ theme: true, header: { @@ -799,11 +795,11 @@ $(document).ready(function () { revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); - + }); /* initialize the calendar -----------------------------------------------------------------*/ - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -833,9 +829,8 @@ $(document).ready(function () { // if so, remove the element from the "Draggable Events" list $(this).remove(); } - } }); }); -$('#calendar').fullCalendar('refetchEvents') \ No newline at end of file +$('#calendar').fullCalendar('refetchEvents'); diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index f73dc2d8b..7552d5bfd 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module FullCalendar { export interface Calendar { @@ -34,7 +35,18 @@ declare module FullCalendar { version: string; } - export interface Options { + export interface BusinessHours { + start: moment.Duration; + end: moment.Duration; + dow: Array; + } + + export interface Timespan { + start: moment.Moment; + end: moment.Moment; + } + + export interface Options extends AgendaOptions, EventDraggingResizingOptions, DroppingExternalElementsOptions, SelectionOptions { // General display - http://arshaw.com/fullcalendar/docs/display/ @@ -55,14 +67,19 @@ declare module FullCalendar { weekMode?: string; weekNumbers?: boolean; weekNumberCalculation?: any; // String/Function + businessHours?: boolean | BusinessHours; height?: number; contentHeight?: number; aspectRatio?: number; handleWindowResize?: boolean; - viewRender?: (view: View, element: JQuery) => void; - viewDestroy?: (view: View, element: JQuery) => void; + viewRender?: (view: ViewObject, element: JQuery) => void; + viewDestroy?: (view: ViewObject, element: JQuery) => void; dayRender?: (date: Date, cell: HTMLTableDataCellElement) => void; - windowResize?: (view: View) => void; + windowResize?: (view: ViewObject) => void; + + // Timezone + timezone?: string | boolean; + now?: moment.Moment | Date | string | (() => moment.Moment) // Views - http://arshaw.com/fullcalendar/docs/views/ @@ -70,6 +87,7 @@ declare module FullCalendar { // Current Date - http://arshaw.com/fullcalendar/docs/current_date/ + defaultDate?: moment.Moment | Date | string; year?: number; month?: number; date?: number; @@ -79,6 +97,7 @@ declare module FullCalendar { timeFormat?: any; // String/ViewOptionHash columnFormat?: any; // String/ViewOptionHash titleFormat?: any; // String/ViewOptionHash + buttonText?: ButtonTextObject; monthNames?: Array; monthNamesShort?: Array; @@ -88,19 +107,10 @@ declare module FullCalendar { // Clicking & Hovering - http://arshaw.com/fullcalendar/docs/mouse/ - dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - eventClick?: (event: EventObject, jsEvent: MouseEvent, view: View) => any; // return type boolean or void - eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - - // Selection - http://arshaw.com/fullcalendar/docs/selection/ - - selectable?: any; // Boolean/ViewOptionHash - selectHelper?: any; // Boolean/Function - unselectAuto?: boolean; - unselectCancel?: string; - select?: (startDate: Date | string, endDate: Date | string, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - unselect?: (view: View, jsEvent: Event) => void; + dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: ViewObject) => void; + eventClick?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => any; // return type boolean or void + eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; + eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; // Event Data - http://arshaw.com/fullcalendar/docs/event_data/ @@ -129,7 +139,7 @@ declare module FullCalendar { endParam?: string lazyFetching?: boolean; eventDataTransform?: (eventData: any) => EventObject; - loading?: (isLoading: boolean, view: View) => void; + loading?: (isLoading: boolean, view: ViewObject) => void; // Event Rendering - http://arshaw.com/fullcalendar/docs/event_rendering/ @@ -137,37 +147,12 @@ declare module FullCalendar { eventBackgroundColor?: string; eventBorderColor?: string; eventTextColor?: string; - eventRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterAllRender?: (view: View) => void; - eventDestroy?: (event: EventObject, element: JQuery, view: View) => void; + eventRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterAllRender?: (view: ViewObject) => void; + eventDestroy?: (event: EventObject, element: JQuery, view: ViewObject) => void; - // Event Dragging & Resizing - editable?: boolean; - eventStartEditable?: boolean; - eventDurationEditable?: boolean; - dragRevertDuration?: number; - dragOpacity?: any; // Float/ViewOptionHash - eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - - droppable?: boolean; - dropAccept?: any; // String/Function - drop?: (date: Date, allDay: boolean, jsEvent: MouseEvent, ui: any) => void; - } - - export interface View { - name: string; - title: string; - start: Date | string; - end: Date | string; - visStart: Date; - visEnd: Date; } export interface ViewOptionHash { @@ -189,16 +174,56 @@ declare module FullCalendar { export interface AgendaOptions { allDaySlot?: boolean; allDayText?: string; - axisFormat?: string; - slotMinutes?: number; - snapMinutes?: number; - defaultEventMinutes?: number; - firstHour?: number; - minTime?: any; // Integer/String - maxTime?: any; // Integer/String + slotDuration?: moment.Duration; + slotLabelFormat?: string; + slotLabelInterval?: moment.Duration; + snapDuration?: moment.Duration; + scrollTime?: moment.Duration; + minTime?: moment.Duration; // Integer/String + maxTime?: moment.Duration; // Integer/String slotEventOverlap?: boolean; } + /* + * Event Dragging & Resizing + */ + export interface EventDraggingResizingOptions { + editable?: boolean; + eventStartEditable?: boolean; + eventDurationEditable?: boolean; + dragRevertDuration?: number; // integer, milliseconds + dragOpacity?: number; // float + dragScroll?: boolean; + eventOverlap?: boolean | ((stillEvent: EventObject, movingEvent: EventObject) => boolean); + eventConstraint?: BusinessHours | Timespan; + eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + } + /* + * Selection - http://arshaw.com/fullcalendar/docs/selection/ + */ + export interface SelectionOptions { + selectable?: boolean; + selectHelper?: boolean | ((start: moment.Moment, end: moment.Moment) => HTMLElement); + unselectAuto?: boolean; + unselectCancel?: string; + selectOverlap?: boolean | ((event: EventObject) => boolean); + selectConstraint?: Timespan | BusinessHours; + select?: (start: moment.Moment, end: moment.Moment, jsEvent: MouseEvent, view: ViewObject, resource?: any) => void; + unselect?: (view: ViewObject, jsEvent: Event) => void; + } + + export interface DroppingExternalElementsOptions { + droppable?: boolean; + dropAccept?: string | ((draggable: any) => boolean); + drop?: (date: moment.Moment, jsEvent: MouseEvent, ui: any) => void; + eventReceive?: (event: EventObject) => void + } + export interface ButtonTextObject { prev?: string; next?: string; @@ -210,12 +235,10 @@ declare module FullCalendar { day?: string; } - export interface EventObject { + export interface EventObject extends Timespan { id?: any // String/number title: string; allDay?: boolean; - start: Date | string; - end?: Date | string; url?: string; className?: any; // string/Array editable?: boolean; @@ -226,6 +249,13 @@ declare module FullCalendar { textColor?: string; } + export interface ViewObject extends Timespan { + name: string; + title: string; + intervalStart: moment.Moment; + intervalEnd: moment.Moment; + } + export interface EventSource extends JQueryAjaxSettings { /** @@ -272,7 +302,7 @@ interface JQuery { /** * Returns the View Object for the current view. */ - fullCalendar(method: 'getView'): FullCalendar.View; + fullCalendar(method: 'getView'): FullCalendar.ViewObject; /** * Immediately switches to a different view. From 3eed85776e25068f0234c0827230d05d1bd412bc Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:59:22 +0200 Subject: [PATCH 04/10] setMaxDate has been changed to getter and setters so it is now maxDate https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/docs/Functions.md#minmaxdate --- .../bootstrap.v3.datetimepicker-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 056c76dd6..e17b7b10c 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -13,7 +13,7 @@ function test_cases() { minDate: '2012-12-31' }); - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + $('#datetimepicker').data("DateTimePicker").maxDate('2012-12-31'); var startDate = moment(new Date(2012, 1, 20)); var endDate = moment(new Date(2012, 1, 25)); From d7b3d781a82a3a19fcc9eb7916e247156ab432ee Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 15:36:34 +0200 Subject: [PATCH 05/10] Typeahead : DisplayKey is now Display --- typeahead/typeahead-tests.ts | 20 ++++++++++---------- typeahead/typeahead.d.ts | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 3864865c9..ec2b2e2f3 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,7 +6,7 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: string, syncResults: (x: any) => void) { + return function findMatches(q: string, syncResults: (x: Array) => void) { var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` var substrRegex = new RegExp(q, 'i'); @@ -97,7 +97,7 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', + display: 'value', source: substringMatcher(states) }] ); @@ -114,7 +114,7 @@ function test_datasets_array() { function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }] @@ -125,13 +125,13 @@ function test_datasets_array() { $('#the-basics .typeahead').typeahead(options, [ { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -161,7 +161,7 @@ function test_datasets_objects() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, { - displayKey: 'value', + display: 'value', source: substringMatcher(states) } ); @@ -180,7 +180,7 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: x => x.value, templates: {}, source: substringMatcher(states) } @@ -191,13 +191,13 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -291,7 +291,7 @@ function test_dataset_templates() { suggestion: function (context) { return context.name; } - } + }, }); } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index cde3a9277..7ffbe5b50 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -105,7 +105,7 @@ declare module Twitter.Typeahead { * cb can be invoked synchronously or asynchronously. * */ - source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); + source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** * The name of the dataset. @@ -120,7 +120,7 @@ declare module Twitter.Typeahead { * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. * Defaults to value. */ - displayKey?: string | ((obj: any) => string); + display?: string | ((obj: any) => string); /** * A hash of templates to be used when rendering the dataset. @@ -128,7 +128,6 @@ declare module Twitter.Typeahead { */ templates?: Templates; async?: boolean; - display?: boolean | ((x: any) => boolean); } From bf24ad882812478d35937c70782624bfe2ac95eb Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:13:45 +0200 Subject: [PATCH 06/10] typeahead: Added support for some of the custom events --- typeahead/typeahead.d.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 7ffbe5b50..136f9650b 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -88,6 +88,41 @@ interface JQuery { * @param datasets One or more datasets passed in as arguments. */ typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; + + on(events: "typeahead:active", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:idle", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:open", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:close", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:change", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:render", selector: string, data: any, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", selector: string, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + off(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + + on(events: "typeahead:select", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; } declare module Twitter.Typeahead { From b7257e1d4c9eec50396df8d9759123060e5c8d7c Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:54:29 +0200 Subject: [PATCH 07/10] typeahead: added all the events, tests coming soon --- typeahead/typeahead.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 136f9650b..ce401c213 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -123,6 +123,31 @@ interface JQuery { on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:autocomplete", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:cursorchange", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:asyncrequest", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asynccancel", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asyncreceive", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; } declare module Twitter.Typeahead { From 99fe3fa43b31bea4a9a3137b748e6474cc936e63 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 15 Oct 2015 11:56:18 +0200 Subject: [PATCH 08/10] Fullcalendar: Fixed callback parameters on eventDrop and eventResize --- fullCalendar/fullCalendar.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index 7552d5bfd..6400dba7e 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -198,10 +198,10 @@ declare module FullCalendar { eventConstraint?: BusinessHours | Timespan; eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; } /* * Selection - http://arshaw.com/fullcalendar/docs/selection/ From d28dd90af5a7ba2b4f18b107ddba3321a5a1f629 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Sat, 17 Oct 2015 12:14:39 +0200 Subject: [PATCH 09/10] Typeahead: Received an update through nuget, incorporated the differences --- typeahead/typeahead.d.ts | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index ce401c213..e01e0d509 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -10,19 +10,19 @@ interface JQuery { /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. * The menu is only visible when it is open and has content. - * - * @constructor + * + * @constructor * @param methodName Method 'open' - */ + */ typeahead(methodName: 'open'): JQuery; /** @@ -36,10 +36,10 @@ interface JQuery { /** * Returns the current value of the typeahead. * The value is the text the user has entered into the input element. - * - * @constructor + * + * @constructor * @param methodName Method 'val' - */ + */ typeahead(methodName: 'val'): string; /** @@ -164,7 +164,7 @@ declare module Twitter.Typeahead { * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. * cb can be invoked synchronously or asynchronously. * - */ + */ source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** @@ -185,7 +185,7 @@ declare module Twitter.Typeahead { /** * A hash of templates to be used when rendering the dataset. * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. - */ + */ templates?: Templates; async?: boolean; } @@ -196,29 +196,43 @@ declare module Twitter.Typeahead { * Rendered when 0 suggestions are available for the given query. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query - */ + */ empty?: any; /** * Rendered at the bottom of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ footer?: any; /** * Rendered at the top of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ header?: any; + + /** + * Rendered when 0 suggestions are available for the given query. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + notFound?: (query: string) => string; + + /** + * Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + pending?: (query: string) => string; /** * Used to render a single suggestion. * If set, this has to be a precompiled template. * The associated suggestion object will serve as the context. * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. - */ + */ suggestion?: (datum: any) => string; } From b9a05cb4c96ae9961bbc41fbd7df9105c3b8fbd0 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Fri, 13 Nov 2015 10:40:30 +0100 Subject: [PATCH 10/10] removed unused enum --- .../bootstrap.v3.datetimepicker.d.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts index 0db3f7b3f..fb0b1b389 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts @@ -13,13 +13,6 @@ /// declare module BootstrapV3DatetimePicker { - enum ViewMode { - 'days', - 'months', - 'years', - 'decades' - } - interface DatetimepickerChangeEventObject extends DatetimepickerEventObject { oldDate: moment.Moment; }