From 35243e64dff30581c3f577173fc92cd5ebaa7bc9 Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Sun, 19 Apr 2015 16:56:28 -0500 Subject: [PATCH] Add definitions and tests for muted callbacks --- jquery.pickadate/jquery.pickadate-tests.ts | 20 ++++++++++++++++++++ jquery.pickadate/jquery.pickadate.d.ts | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/jquery.pickadate/jquery.pickadate-tests.ts b/jquery.pickadate/jquery.pickadate-tests.ts index 15ebcbc3a..3bd3f0721 100644 --- a/jquery.pickadate/jquery.pickadate-tests.ts +++ b/jquery.pickadate/jquery.pickadate-tests.ts @@ -421,6 +421,26 @@ picker.get('id'); picker.get('enable'); picker.get('disable'); +// Set multiple at once +picker.set({ + select: new Date(2015, 3, 20), + highlight: [2015, 3, 20], + min: -4 +}); + +// Muted callbacks + +// One at a time +picker.set('disable', 'flip', { muted: true }) + +// Multiple at once +picker.set({ + select: [1988, 7, 14], + view: new Date(1988, 7, 14), + max: 4 +}, { muted: true }); + +// Clear the value in the picker’s input element. picker.set('clear'); // Set select for a date item object diff --git a/jquery.pickadate/jquery.pickadate.d.ts b/jquery.pickadate/jquery.pickadate.d.ts index 2c30eb046..4d5e52949 100644 --- a/jquery.pickadate/jquery.pickadate.d.ts +++ b/jquery.pickadate/jquery.pickadate.d.ts @@ -255,6 +255,14 @@ declare module Pickadate { interval?: number; } + interface SetOptions { + /** + * By default, any callbacks bound with the on method will be fired when its relevant thing is set. + * To silently set a thing, pass an options object with the muted parameter set to true. + */ + muted: boolean; + } + interface Picker { /** The picker's relative input element wrapped as a jQuery object. */ $node: JQuery; @@ -322,8 +330,8 @@ declare module Pickadate { get(thing: string, format: string): string; /** Set the properties, objects, and states to change the state of the picker. */ - set(thing: string, value?: any, options?: any): TPickerObject; - set(things: TOptions, options?: any): TPickerObject; + set(thing: string, value?: any, options?: SetOptions): TPickerObject; + set(things: TOptions, options?: SetOptions): TPickerObject; /** Bind callbacks to get fired off when the relative picker method is called. */ on(methodName: string, callback: (data?: any) => void): TPickerObject;