mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-20 21:12:38 +08:00
jquery.colorpicker fixes (#23320)
* add 'disabled' option * allow multiple parameters in method calls
This commit is contained in:
7
types/jquery.colorpicker/index.d.ts
vendored
7
types/jquery.colorpicker/index.d.ts
vendored
@@ -31,6 +31,7 @@ interface JQueryColorpickerOptions {
|
||||
closeOnOutside?: boolean;
|
||||
color?: string;
|
||||
colorFormat?: string;
|
||||
disabled: boolean;
|
||||
draggable?: boolean;
|
||||
duration?: string;
|
||||
format?: string;
|
||||
@@ -38,7 +39,7 @@ interface JQueryColorpickerOptions {
|
||||
hsv?: boolean;
|
||||
inline?: boolean;
|
||||
inlineFrame?: boolean;
|
||||
layout?: {[part: string]: number[];};
|
||||
layout?: { [part: string]: number[]; };
|
||||
limit?: string;
|
||||
modal?: boolean;
|
||||
mode?: string;
|
||||
@@ -67,7 +68,7 @@ interface JQueryColorpickerStatic {
|
||||
regional: { [key: string]: string; };
|
||||
swatches: { [swatch: string]: { [name: string]: JQueryColorpickerStatic.RGB; }; };
|
||||
writers: { [name: string]: (color: any, that: any) => any; };
|
||||
Color: { new (r?: number, g?: number, b?: number, a?: number): JQueryColorpickerStatic.Color; };
|
||||
Color: { new(r?: number, g?: number, b?: number, a?: number): JQueryColorpickerStatic.Color; };
|
||||
}
|
||||
|
||||
declare namespace JQueryColorpickerStatic {
|
||||
@@ -162,6 +163,6 @@ interface JQuery {
|
||||
colorpicker(method: "open"): JQuery;
|
||||
colorpicker(method: string): JQuery;
|
||||
colorpicker(method: "setColor", color: any): JQuery;
|
||||
colorpicker(method: string, param: any): JQuery;
|
||||
colorpicker(method: string, ...params: any[]): JQuery;
|
||||
colorpicker(options?: JQueryColorpickerOptions): JQuery;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ var colorpicker = $("<input type=\"text\"/>").colorpicker({
|
||||
closeOnOutside: true, // Close the dialog when clicking outside the dialog (not for inline)
|
||||
color: '#00FF00', // Initial color (for inline only)
|
||||
colorFormat: 'HEX', // Format string for output color format
|
||||
disabled: false,
|
||||
draggable: true, // Make popup dialog draggable if header is visible.
|
||||
duration: 'fast',
|
||||
hsv: true, // Show HSV controls and modes
|
||||
@@ -67,6 +68,7 @@ colorpicker.colorpicker("open");
|
||||
colorpicker.colorpicker("close");
|
||||
colorpicker.colorpicker("destroy");
|
||||
colorpicker.colorpicker("setColor", "#deadbeef");
|
||||
colorpicker.colorpicker("option", "disabled", true);
|
||||
|
||||
// example plugins provided
|
||||
|
||||
@@ -94,23 +96,23 @@ $.colorpicker.parts["memory"] = function (inst) {
|
||||
break;
|
||||
}
|
||||
}).bind('contextmenu', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
container.append($node);
|
||||
},
|
||||
getMemory = function () {
|
||||
return (<string>(document.cookie.match(/\bcolorpicker-memory=([^;]*)/) || [0, ''])[1]).split(',');
|
||||
},
|
||||
setMemory = function () {
|
||||
var colors = [];
|
||||
$('> *', container).each(function () {
|
||||
colors.push(encodeURIComponent($(this).css('backgroundColor')));
|
||||
});
|
||||
var expdate = new Date();
|
||||
expdate.setDate(expdate.getDate() + (365 * 10));
|
||||
document.cookie = 'colorpicker-memory=' + colors.join() + ";expires=" + expdate.toUTCString();
|
||||
};
|
||||
setMemory = function () {
|
||||
var colors = [];
|
||||
$('> *', container).each(function () {
|
||||
colors.push(encodeURIComponent($(this).css('backgroundColor')));
|
||||
});
|
||||
var expdate = new Date();
|
||||
expdate.setDate(expdate.getDate() + (365 * 10));
|
||||
document.cookie = 'colorpicker-memory=' + colors.join() + ";expires=" + expdate.toUTCString();
|
||||
};
|
||||
|
||||
this.init = function () {
|
||||
container = $('<div/>')
|
||||
@@ -195,7 +197,7 @@ $.colorpicker.parsers['CMYK'] = function (color) {
|
||||
parseInt(m[2], 10) / 255,
|
||||
parseInt(m[3], 10) / 255,
|
||||
parseInt(m[4], 10) / 255
|
||||
);
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -206,7 +208,7 @@ $.colorpicker.parsers["#HEX8"] = function (color) {
|
||||
parseInt(m[2], 16) / 255,
|
||||
parseInt(m[3], 16) / 255,
|
||||
parseInt(m[4], 16) / 255
|
||||
).setAlpha(parseInt(m[1], 16) / 255);
|
||||
).setAlpha(parseInt(m[1], 16) / 255);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user