mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #6288 from TrabacchinLuigi/master
updated three libraries
This commit is contained in:
@@ -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").maxDate('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) {
|
||||
|
||||
+18
-14
@@ -10,15 +10,15 @@
|
||||
*/
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="../moment/moment.d.ts"/>
|
||||
|
||||
declare module BootstrapV3DatetimePicker {
|
||||
interface DatetimepickerChangeEventObject extends JQueryEventObject {
|
||||
date: any;
|
||||
oldDate: any;
|
||||
interface DatetimepickerChangeEventObject extends DatetimepickerEventObject {
|
||||
oldDate: moment.Moment;
|
||||
}
|
||||
|
||||
interface DatetimepickerEventObject extends JQueryEventObject {
|
||||
date: any;
|
||||
date: moment.Moment;
|
||||
}
|
||||
|
||||
interface DatetimepickerIcons {
|
||||
@@ -35,33 +35,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<any>;
|
||||
enabledDates?: Array<any>;
|
||||
defaultDate?: moment.Moment | Date | string;
|
||||
disabledDates?: Array<moment.Moment | Date | string>;
|
||||
enabledDates?: Array<moment.Moment | Date | string>;
|
||||
icons?: DatetimepickerIcons;
|
||||
useStrict?: boolean;
|
||||
direction?: string;
|
||||
sideBySide?: boolean;
|
||||
daysOfWeekDisabled?: Array<any>;
|
||||
daysOfWeekDisabled?: Array<number>;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
$('#calendar').fullCalendar('refetchEvents');
|
||||
|
||||
Vendored
+88
-58
@@ -4,6 +4,7 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="../moment/moment.d.ts"/>
|
||||
|
||||
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<number>;
|
||||
}
|
||||
|
||||
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<string>;
|
||||
monthNamesShort?: Array<string>;
|
||||
@@ -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, 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, delta: moment.Duration, 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<string>
|
||||
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.
|
||||
|
||||
@@ -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: Array<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,41 +97,41 @@ function test_datasets_array() {
|
||||
|
||||
function with_displayKey_option() {
|
||||
$('#the-basics .typeahead').typeahead(options, [{
|
||||
displayKey: 'value',
|
||||
source: substringMatcher(states)
|
||||
}]
|
||||
display: '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',
|
||||
display: 'value',
|
||||
templates: {},
|
||||
source: substringMatcher(states)
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
function with_multiple_datasets() {
|
||||
$('#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)
|
||||
}
|
||||
@@ -165,7 +161,7 @@ function test_datasets_objects() {
|
||||
function with_displayKey_option() {
|
||||
$('#the-basics .typeahead').typeahead(options,
|
||||
{
|
||||
displayKey: 'value',
|
||||
display: 'value',
|
||||
source: substringMatcher(states)
|
||||
}
|
||||
);
|
||||
@@ -184,7 +180,7 @@ function test_datasets_objects() {
|
||||
$('#the-basics .typeahead').typeahead(options,
|
||||
{
|
||||
name: 'states',
|
||||
displayKey: 'value',
|
||||
display: x => x.value,
|
||||
templates: {},
|
||||
source: substringMatcher(states)
|
||||
}
|
||||
@@ -192,16 +188,16 @@ function test_datasets_objects() {
|
||||
}
|
||||
|
||||
function with_multiple_objects() {
|
||||
$('#the-basics .typeahead').typeahead(options,
|
||||
$('#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)
|
||||
}
|
||||
@@ -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,13 +285,13 @@ 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;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+296
-242
@@ -87,7 +87,67 @@ 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;
|
||||
|
||||
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<any>, async: boolean, datasetName: string) => any): JQuery;
|
||||
on(events: "typeahead:render", selector: string, handler: (ev: JQueryEventObject, suggestions: Array<any>, async: boolean, datasetName: string) => any): JQuery;
|
||||
on(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array<any>, async: boolean, datasetName: string) => any): JQuery;
|
||||
off(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array<any>, 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;
|
||||
|
||||
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 {
|
||||
@@ -105,7 +165,7 @@ declare module Twitter.Typeahead {
|
||||
* cb can be invoked synchronously or asynchronously.
|
||||
*
|
||||
*/
|
||||
source: (query: string, cb: (result: any) => void) => void;
|
||||
source: ((query: string, syncResults: (result: Array<any>) => void, asyncResults?: (result: Array<any>) => void) => void);
|
||||
|
||||
/**
|
||||
* The name of the dataset.
|
||||
@@ -120,18 +180,18 @@ 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.
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
interface Templates {
|
||||
|
||||
/**
|
||||
* Rendered when 0 suggestions are available for the given query.
|
||||
* Can be either a HTML string or a precompiled template.
|
||||
@@ -178,267 +238,261 @@ declare module Twitter.Typeahead {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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<T>
|
||||
{
|
||||
/**
|
||||
* 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<T>;
|
||||
/**
|
||||
* 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<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T>
|
||||
{
|
||||
/**
|
||||
* 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<T>
|
||||
{
|
||||
/**
|
||||
* 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<T> {
|
||||
/**
|
||||
* 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<T>;
|
||||
/**
|
||||
* 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<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T> {
|
||||
/**
|
||||
* 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<T> {
|
||||
/**
|
||||
* 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<T> {
|
||||
constructor(options: Bloodhound.BloodhoundOptions<T>);
|
||||
/**
|
||||
* 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<any>;
|
||||
/**
|
||||
* 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<T>);
|
||||
/**
|
||||
* 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<any>;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user