From d9d0667f9f6ff25867af69753d7d30d0cc6c9fb1 Mon Sep 17 00:00:00 2001 From: SammyG4Free Date: Mon, 23 Nov 2015 10:56:54 -0800 Subject: [PATCH 1/3] Type Definitions for DataTables Buttons extension. Added type definitions to support DataTables Buttons extension. --- .../jquery.dataTables.buttons-tests.ts | 33 +++++ .../jquery.dataTables.buttons.d.ts | 113 ++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 jquery.dataTables/jquery.dataTables.buttons-tests.ts create mode 100644 jquery.dataTables/jquery.dataTables.buttons.d.ts diff --git a/jquery.dataTables/jquery.dataTables.buttons-tests.ts b/jquery.dataTables/jquery.dataTables.buttons-tests.ts new file mode 100644 index 000000000..4a47b0f7e --- /dev/null +++ b/jquery.dataTables/jquery.dataTables.buttons-tests.ts @@ -0,0 +1,33 @@ +/// +/// +/// + +$(document).ready(function () { + + var config: DataTables.Settings = + { + // Buttons extension options + buttons: [ + { + extend: 'excel', + text: 'Excel', + className: 'class', + exportOptions: { + columns: ':visible' + } + }, + { + action: function (e, dt, node, config) { }, + available: function (dt, config) { return true; }, + destroy: function (dt, node, config) { }, + enabled: true, + init: function (dt, node, config) { }, + key: 'a', + name: 'name', + namespace: 'namespace', + titleAttr: 'title', + } + ], + } + +}); \ No newline at end of file diff --git a/jquery.dataTables/jquery.dataTables.buttons.d.ts b/jquery.dataTables/jquery.dataTables.buttons.d.ts new file mode 100644 index 000000000..fc018eba9 --- /dev/null +++ b/jquery.dataTables/jquery.dataTables.buttons.d.ts @@ -0,0 +1,113 @@ +// Type definitions for JQuery DataTables (v1.10.10) Buttons extension (v1.1.0) +// Project: http://datatables.net/extensions/buttons/ +// Definitions by: Sam Germano +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module DataTables { + export interface Settings { + /** + * Buttons extension options + */ + buttons?: boolean | string[] | ButtonSettings[]; + } + + //#region "button-settings" + + /** + * Buttons extension options + */ + export interface ButtonSettings { + /** + * Action to take when the button is activated + */ + action?: FunctionButtonAction; + + /** + * Ensure that any requirements have been satisfied before initialising a button + */ + available?: FunctionButtonAvailable; + + /** + * Set the class name for the button + */ + className?: string; + + /** + * Function that is called when the button is destroyed + */ + destroy?: FunctionButtonInit; + + /** + * Set a button's initial enabled state + */ + enabled?: boolean; + + /** + * Define which button type the button should be based on + */ + extend?: string; + + /** + * Initialisation function that can be used to add events specific to this button + */ + init?: FunctionButtonInit; + + /** + * Define an activation key for a button + */ + key?: string | ButtonKey; + + /** + * Set a name for each selection + */ + name?: string; + + /** + * Unique namespace for every button + */ + namespace?: string; + + /** + * The text to show in the button + */ + text?: string | ButtonText; + + /** + * Button 'title' attribute text + */ + titleAttr?: string; + + exportOptions?: ButtonExportOptions; + autoPrint?: boolean; + } + + export interface FunctionButtonAvailable { + (dt: DataTables.DataTable, config: any): boolean + } + export interface ButtonExportOptions { + columns?: string; + } + + export interface ButtonKey { + key?: string; + shiftKey?: boolean; + altKey?: boolean; + ctrlKey?: boolean; + metaKey?: boolean; + } + + export interface ButtonText { + (dt: DataTables.DataTable, node: JQuery, config: any): string + } + export interface FunctionButtonInit { + (dt: DataTables.DataTable, node: JQuery, config: any): void + } + // api object? + export interface FunctionButtonAction { + (e: any, dt: DataTables.DataTable, node: JQuery, config: any): void + } + //#endregion "button-settings +} \ No newline at end of file From 55ff277951c35e639fd3d983f90f1fc2514ff1a1 Mon Sep 17 00:00:00 2001 From: SammyG4Free Date: Mon, 23 Nov 2015 11:19:12 -0800 Subject: [PATCH 2/3] Header updated --- jquery.dataTables/jquery.dataTables.buttons.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.dataTables/jquery.dataTables.buttons.d.ts b/jquery.dataTables/jquery.dataTables.buttons.d.ts index fc018eba9..8ab0cff17 100644 --- a/jquery.dataTables/jquery.dataTables.buttons.d.ts +++ b/jquery.dataTables/jquery.dataTables.buttons.d.ts @@ -1,4 +1,4 @@ -// Type definitions for JQuery DataTables (v1.10.10) Buttons extension (v1.1.0) +// Type definitions for JQuery DataTables Buttons extension 1.1.0 // Project: http://datatables.net/extensions/buttons/ // Definitions by: Sam Germano // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 005e2c77a1c2f09445b36a3c043c8a4203eaad7e Mon Sep 17 00:00:00 2001 From: SammyG4Free Date: Tue, 15 Dec 2015 15:29:24 -0800 Subject: [PATCH 3/3] Updated to match naming standards --- .../datatables-buttons-tests.ts | 4 ++-- .../datatables-buttons.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename jquery.dataTables/jquery.dataTables.buttons-tests.ts => datatables-buttons/datatables-buttons-tests.ts (88%) rename jquery.dataTables/jquery.dataTables.buttons.d.ts => datatables-buttons/datatables-buttons.d.ts (97%) diff --git a/jquery.dataTables/jquery.dataTables.buttons-tests.ts b/datatables-buttons/datatables-buttons-tests.ts similarity index 88% rename from jquery.dataTables/jquery.dataTables.buttons-tests.ts rename to datatables-buttons/datatables-buttons-tests.ts index 4a47b0f7e..dbe176eea 100644 --- a/jquery.dataTables/jquery.dataTables.buttons-tests.ts +++ b/datatables-buttons/datatables-buttons-tests.ts @@ -1,6 +1,6 @@ /// -/// -/// +/// +/// $(document).ready(function () { diff --git a/jquery.dataTables/jquery.dataTables.buttons.d.ts b/datatables-buttons/datatables-buttons.d.ts similarity index 97% rename from jquery.dataTables/jquery.dataTables.buttons.d.ts rename to datatables-buttons/datatables-buttons.d.ts index 8ab0cff17..fd047f0a8 100644 --- a/jquery.dataTables/jquery.dataTables.buttons.d.ts +++ b/datatables-buttons/datatables-buttons.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// +/// declare module DataTables { export interface Settings {