Merge pull request #6356 from Pro/upstream

New definitions for jquery.highlight.js
This commit is contained in:
Masahiro Wakame
2015-10-27 08:14:11 +09:00
2 changed files with 46 additions and 0 deletions
@@ -0,0 +1,26 @@
/// <reference path="jquery.highlight-bartaz.d.ts" />
$('#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 <em class='important'>
$('#content').highlight('ipsum', { element: 'em', className: 'important' });
// remove default highlight
$('#content').unhighlight();
// remove custom highlight
$('#content').unhighlight({ element: 'em', className: 'important' });
+20
View File
@@ -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 <https://github.com/Pro/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
interface JQuery {
unhighlight(options?: {
element?: string,
className?: string
}): JQuery;
highlight(words: string | string[], options?: {
element?: string,
className?: string
caseSensitive?: boolean,
wordsOnly?: boolean
}): JQuery;
}