Update jQuery.Watermark, add tests

This commit is contained in:
Boris Yankov
2013-01-09 11:30:35 +02:00
parent ab9e6db3bd
commit 2bc074c287
2 changed files with 42 additions and 3 deletions
@@ -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();