Updated extended-listbox to 3.0.0 (#16801)

This commit is contained in:
Christian Kotzbauer
2017-06-02 17:52:25 +02:00
committed by Andy
parent 16b9c15dea
commit 35a42944dc
2 changed files with 22 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ options.multiple = true;
options.searchBar = false;
options.searchBarWatermark = "Search";
options.searchBarButton = { icon: "fa fa-search", visible: true, onClick: function () { alert(); } };
options.getItems = function (): any[] {
options.getItems = (): (string|ListboxItem)[] => {
return ["Test1"];
};
options.onItemsChanged = (event: ListboxEvent): void => {
@@ -23,13 +23,13 @@ options.onItemsChanged = (event: ListboxEvent): void => {
options.onFilterChanged = (event: ListboxEvent): void => {
console.log(event.args);
};
options.onValueChanged = function (event: ListboxEvent): void {
options.onValueChanged = (event: ListboxEvent): void => {
console.log(event.args);
};
options.onItemDoubleClicked = function (event: ListboxEvent): void {
options.onItemDoubleClicked = (event: ListboxEvent): void => {
console.log(event.args);
};
options.onItemEnterPressed = function (event: ListboxEvent): void {
options.onItemEnterPressed = (event: ListboxEvent): void => {
console.log(event.args);
};
@@ -39,7 +39,7 @@ instance = <ExtendedListboxInstance>$test.listbox(options);
/////// NEW API ///////
// Add string item
var id = instance.addItem("Test2");
var id: string = instance.addItem("Test2");
// Add item
@@ -54,10 +54,18 @@ item.text = "Test3";
id = instance.addItem(item);
// Add string items
var ids: string[] = instance.addItems(["Test2", "Test1"]);
// Remove item
instance.removeItem(id);
// Remove items
instance.removeItems([id, ids[0]]);
// Get item
var i: ListboxItem = instance.getItem(id);

View File

@@ -1,4 +1,4 @@
// Type definitions for extended-listbox 2.0.x
// Type definitions for extended-listbox 3.0.x
// Project: https://github.com/code-chris/extended-listbox
// Definitions by: Christian Kotzbauer <https://github.com/code-chris>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -26,7 +26,7 @@ interface ListboxItem {
parentGroupId?: string;
/** list of childItems */
childItems?: any[];
childItems?: ListboxItem[];
}
interface ListboxSearchBarButtonOptions {
@@ -54,7 +54,7 @@ interface ListBoxOptions {
multiple?: boolean;
/** function which returns a array of items */
getItems?: () => any;
getItems?: () => (string|ListboxItem)[];
/** callback for selection changes */
onValueChanged?: (event: ListboxEvent) => void;
@@ -90,9 +90,15 @@ interface ExtendedListboxInstance {
/** Adds a new item to the list */
addItem(item: string|ListboxItem): string;
/** Adds new items to the list */
addItems(item: (string|ListboxItem)[]): string[];
/** Removes a item from the list */
removeItem(identifier: string): void;
/** Removes items from the list */
removeItems(identifiers: string[]): void;
/** Reverts all changes from the DOM */
destroy(): void;