From 1f7bcc9133a3d82e3f980eabed5a7e640e010d11 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Mon, 19 Oct 2015 15:58:34 +0200 Subject: [PATCH] New definitions for jquery.highlight.js --- jquery.highlight/jquery.highlight-tests.ts | 26 ++++++++++++++++++++++ jquery.highlight/jquery.highlight.d.ts | 20 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 jquery.highlight/jquery.highlight-tests.ts create mode 100644 jquery.highlight/jquery.highlight.d.ts diff --git a/jquery.highlight/jquery.highlight-tests.ts b/jquery.highlight/jquery.highlight-tests.ts new file mode 100644 index 000000000..84ef701f1 --- /dev/null +++ b/jquery.highlight/jquery.highlight-tests.ts @@ -0,0 +1,26 @@ +/// + + + +$('#content').highlight('lorem'); + +// search for and highlight more terms at once +// so you can save some time on traversing DOM +$('#content').highlight(['lorem', 'ipsum']); +$('#content').highlight('lorem ipsum'); + +// search only for entire word 'lorem' +$('#content').highlight('lorem', { wordsOnly: true }); + +// don't ignore case during search of term 'lorem' +$('#content').highlight('lorem', { caseSensitive: true }); + +// wrap every occurrance of term 'ipsum' in content +// with +$('#content').highlight('ipsum', { element: 'em', className: 'important' }); + +// remove default highlight +$('#content').unhighlight(); + +// remove custom highlight +$('#content').unhighlight({ element: 'em', className: 'important' }); \ No newline at end of file diff --git a/jquery.highlight/jquery.highlight.d.ts b/jquery.highlight/jquery.highlight.d.ts new file mode 100644 index 000000000..d48d1f7d8 --- /dev/null +++ b/jquery.highlight/jquery.highlight.d.ts @@ -0,0 +1,20 @@ +// Type definitions for jquery.highlight.js +// Project: https://github.com/bartaz/sandbox.js/blob/master/jquery.highlight.js +// Definitions by: Stefan Profanter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface JQuery { + unhighlight(options?: { + element?: string, + className?: string + }): JQuery; + highlight(words: string | string[], options?: { + element?: string, + className?: string + caseSensitive?: boolean, + wordsOnly?: boolean + }): JQuery; +} \ No newline at end of file