Merge pull request #927 from nestalk/master

Add method function overloads
This commit is contained in:
Boris Yankov
2013-08-24 12:51:07 -07:00
5 changed files with 164 additions and 8 deletions
@@ -0,0 +1,52 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="jquery.simplePagination.d.ts"/>
var selector = '#elementId';
$(function () {
$(selector).pagination({
items: 100,
itemsOnPage: 10,
cssStyle: 'light-theme'
});
});
$(function () {
$(selector).pagination('selectPage', 1);
});
$(function () {
$(selector).pagination('prevPage');
});
$(function () {
$(selector).pagination('nextPage');
});
$(function () {
$(selector).pagination('getPagesCount');
});
$(function () {
$(selector).pagination('getCurrentPage');
});
$(function () {
$(selector).pagination('disable');
});
$(function () {
$(selector).pagination('enable');
});
$(function () {
$(selector).pagination('destroy');
});
$(function () {
$(selector).pagination('redraw');
});
$(function () {
$(selector).pagination('updateItems', 100);
});
+13 -1
View File
@@ -18,10 +18,22 @@ interface SimplePaginationOptions {
nextText?: string;
cssStyle?: string;
selectOnClick?: boolean;
onPageClick?: (interger) => void;
onPageClick?: (page?: number, event?: any) => void;
onInit?: () => void;
}
interface JQuery {
pagination(options?: SimplePaginationOptions): JQuery;
pagination(method: string): any;
pagination(method: string, value: any): any;
pagination(method: 'selectPage', pageNumber: number): void;
pagination(method: 'prevPage'): void;
pagination(method: 'nextPage'): void;
pagination(method: 'getPagesCount'): number;
pagination(method: 'getCurrentPage'): number;
pagination(method: 'disable'): void;
pagination(method: 'enable'): void;
pagination(method: 'destroy'): void;
pagination(method: 'redraw'): void;
pagination(method: 'updateItems', items: number): void;
}
+5 -1
View File
@@ -64,7 +64,11 @@ interface TimePickerOptions {
interface JQuery {
timepicker(): JQuery;
timepicker(options: TimePickerOptions): JQuery;
timepicker(methodName: string): JQuery;
timepicker(methodName: string): any;
timepicker(methodName: 'getTime'): string;
timepicker(methodName: 'getTimeAsDate'): Date;
timepicker(methodName: 'getHour'): number;
timepicker(methodName: 'getMinute'): number;
timepicker(methodName: string, methodParameter: any): any;
timepicker(optionLiteral: string, optionName: string): any;
}
+34 -1
View File
@@ -71,6 +71,27 @@ $("#e6").select2({
formatSelection: movieFormatSelection,
dropdownCssClass: "bigdrop"
});
$("#e6").select2({
placeholder: "Search for a movie",
minimumInputLength: 1,
ajax: {
url: () => { return "http://api.rottentomatoes.com/api/public/v1.0/movies.json"; },
dataType: 'jsonp',
data: function (term, page) {
return {
q: term,
page_limit: 10,
apikey: "ju6z9mjyajq2djue3gbvv26t"
};
},
results: function (data, page) {
return { results: data.movies };
}
},
formatResult: movieFormatResult,
formatSelection: movieFormatSelection,
dropdownCssClass: "bigdrop"
});
$("#e7").select2({
placeholder: "Search for a movie",
minimumInputLength: 3,
@@ -161,4 +182,16 @@ $("#e17_2").select2({
}
});
$("#e18,#e18_2").select2();
alert("Selected value is: " + $("#e8").select2("val")); $("#e8").select2("val", { id: "CA", text: "Califoria" });
alert("Selected value is: " + $("#e8").select2("val")); $("#e8").select2("val", { id: "CA", text: "Califoria" });
$("#e8").select2("val");
$("#e8").select2("val", "CA");
$("#e8").select2("data");
$("#e8").select2("data", { id: "CA", text: "Califoria" });
$("#e8").select2("destroy");
$("#e8").select2("open");
$("#e8").select2("enable", false);
$("#e8").select2("readonly", false);
$("#e8").select2('container');
$("#e8").select2('onSortStart');
$("#e8").select2('onSortEnd');
+60 -5
View File
@@ -20,7 +20,10 @@ interface AjaxFunction {
interface Select2AjaxOptions {
transport?: AjaxFunction;
url?: string;
/**
* Url to make request to, Can be string or a function returning a string.
*/
url?: any;
dataType?: string;
quietMillis?: number;
data?: (term: string, page: number, context: any) => any;
@@ -72,8 +75,60 @@ interface JQuery {
select2(): JQuery;
select2(it: IdTextPair): JQuery;
select2(options: Select2Options): JQuery;
select2(method: string, something: string): JQuery;
select2(method: string, something: string[]): JQuery;
select2(method: string, something: IdTextPair[]): JQuery;
select2(method: string, options: IdTextPair): JQuery;
select2(method: string): any;
select2(method: string, value: any, trigger?: boolean): any;
/**
* Get the id value of the current selection
*/
select2(method: 'val'): any;
/**
* Set the id value of the current selection
* @params value Value to set the id to
* @params triggerChange Should a change event be triggered
*/
select2(method: 'val', value: any, triggerChange?: boolean): any;
/**
* Get the data object of the current selection
*/
select2(method: 'data'): any;
/**
* Set the data of the current selection
* @params value Object to set the data to
* @params triggerChange Should a change event be triggered
*/
select2(method: 'data', value: any, triggerChange?: boolean): any;
/**
* Reverts changes to DOM done by Select2. Any selection done via Select2 will be preserved.
*/
select2(method: 'destroy'): void;
/**
* Opens the dropdown
*/
select2(method: 'open'): void;
/**
* Closes the dropdown
*/
select2(method: 'close'): void;
/**
* Enables or disables Select2 and its underlying form component
* @param value True if it should be enabled false if it should be disabled
*/
select2(method: 'enable', value: boolean): void;
/**
* Toggles readonly mode on Select2 and its underlying form component
* @param value True if it should be readonly false if it should be read write
*/
select2(method: 'readonly', value: boolean): void;
/**
* Retrieves the main container element that wraps all of DOM added by Select2
*/
select2(method: 'container'): HTMLElement;
/**
* Notifies Select2 that a drag and drop sorting operation has started
*/
select2(method: 'onSortStart'): void;
/**
* Notifies Select2 that a drag and drop sorting operation has finished
*/
select2(method: 'onSortEnd'): void;
}