mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Update jQuery.Watermark, add tests
This commit is contained in:
+14
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Watermark plugin for jQuery 3.1.4
|
||||
// Type definitions for Watermark plugin for jQuery 3.1
|
||||
// Project: http://jquery-watermark.googlecode.com
|
||||
// Definitions by: https://github.com/anwarjaved
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -6,14 +6,25 @@
|
||||
|
||||
/// <reference path="../jquery/jquery-1.8.d.ts"/>
|
||||
|
||||
|
||||
interface WatermarkOptions {
|
||||
className?: string; // Default class name for all watermarks
|
||||
useNative?: bool; // If true, plugin will detect and use native browser support for watermarks, if available. (e.g., WebKit's placeholder attribute.)
|
||||
hideBeforeUnload?: bool; // If true, all watermarks will be hidden during the window beforeunload event.
|
||||
}
|
||||
|
||||
interface Watermark {
|
||||
options: WatermarkOptions;
|
||||
|
||||
show(element: string): void;
|
||||
hide(element: string): void;
|
||||
showAll(): void;
|
||||
hideAll(): void;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
watermark(text : string, options?: WatermarkOptions): JQuery;
|
||||
watermark(text: string, options?: WatermarkOptions): JQuery;
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
watermark: Watermark;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path="../jquery/jquery-1.8.d.ts"/>
|
||||
/// <reference path="jquery.watermark-3.1.d.ts"/>
|
||||
|
||||
|
||||
$('#inputId').watermark('Required information');
|
||||
$('#inputId').watermark('Required information', { className: 'myClassName' });
|
||||
$('#inputId').watermark('Search', { useNative: false });
|
||||
|
||||
$.watermark.options.className = 'myClass';
|
||||
|
||||
$.watermark.options.useNative = false;
|
||||
|
||||
var myFunction;
|
||||
$.watermark.options.useNative = myFunction;
|
||||
|
||||
$.watermark.options.hideBeforeUnload = false;
|
||||
|
||||
$.watermark.options = {
|
||||
className: 'myClass',
|
||||
useNative: false,
|
||||
hideBeforeUnload: false
|
||||
};
|
||||
|
||||
$.watermark.options.hideBeforeUnload = true;
|
||||
$.watermark.show('input.optional');
|
||||
$.watermark.hide('#myInput');
|
||||
$.watermark.showAll();
|
||||
$.watermark.hideAll();
|
||||
Reference in New Issue
Block a user