Add definitions and tests for muted callbacks

This commit is contained in:
Theodore Brown
2015-04-19 16:56:28 -05:00
parent d484d07be6
commit 35243e64df
2 changed files with 30 additions and 2 deletions
@@ -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 pickers input element.
picker.set('clear');
// Set select for a date item object
+10 -2
View File
@@ -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<TPickerObject, TItemObject extends Item, TOptions extends SetObject> {
/** 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;