-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
12,495 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: holmes.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: holmes.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>/** | ||
* search for dom elements on your page | ||
* @module holmes | ||
*/ | ||
(function(root, factory) { | ||
'use strict'; | ||
|
||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module. | ||
define([], function() { | ||
return (root.holmes = factory()); | ||
}); | ||
} else if (typeof exports === 'object') { | ||
// Node. Does not work with strict CommonJS, but | ||
// only CommonJS-like environments that support module.exports, | ||
// like Node. | ||
module.exports = factory(); | ||
} else { | ||
// Browser globals | ||
root.holmes = factory(); | ||
} | ||
})(this, function() { | ||
// UMD Definition above, do not remove this line | ||
|
||
// To get to know more about the Universal Module Definition | ||
// visit: https://github.com/umdjs/umd | ||
|
||
'use strict'; | ||
|
||
/** | ||
* search for dom elements on your page | ||
* @alias module:holmes | ||
* @param {Object} options | ||
* @param {string} [options.input='input[type=search]'] | ||
* A querySelector to find the input | ||
* @param {string} options.find | ||
* A querySelectorAll rule to find each of the find terms | ||
* @param {string=} options.placeholder | ||
* Text to show when there are no results (innerHTML) | ||
*/ | ||
function holmes(options) { | ||
window.addEventListener('DOMContentLoaded',function(){ | ||
options.parents = options.parents || 0; | ||
options.input = options.input || 'input[type=search]'; | ||
options.placeholder = options.placeholder || false; | ||
var search = document.querySelector(options.input); | ||
var elements = document.querySelectorAll(options.find); | ||
|
||
if (options.placeholder) { | ||
var placeholder = document.createElement('span'); | ||
placeholder.classList.add('hidden'); | ||
placeholder.innerHTML = options.placeholder; | ||
elements[0].parentNode.appendChild(placeholder); | ||
} | ||
|
||
search.addEventListener('input',function(){ | ||
var found = false; | ||
for (var i = 0; i < elements.length; i++) { | ||
var searchString = search.value.toLowerCase(); | ||
if (elements[i].textContent.toLowerCase().indexOf(searchString) === -1) { | ||
elements[i].classList.add('hidden'); | ||
} else { | ||
elements[i].classList.remove('hidden'); | ||
found = true; | ||
} | ||
}; | ||
if (!found && options.placeholder) { | ||
placeholder.classList.remove('hidden'); | ||
} else { | ||
placeholder.classList.add('hidden'); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
return holmes; | ||
|
||
}); | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-holmes.html">holmes</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Jun 05 2016 15:24:20 GMT+0200 (CEST) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Home</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Home</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3> </h3> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article><h1><a href="https://www.npmjs.com/package/holmes.js"><img alt="Holmes.js" src="https://haroen.me/holmes/images/logo.png" height="50px"></img></a></h1><blockquote> | ||
<p>Fast and easy searching inside a page.</p> | ||
</blockquote> | ||
<p><a href="https://travis-ci.org/Haroenv/holmes"><img src="https://travis-ci.org/Haroenv/holmes.svg?branch=gh-pages" alt="Build Status"></a><a href="https://www.npmjs.com/package/holmes.js"><img src="https://badge.fury.io/js/holmes.js.svg" alt="npm version"></a></p> | ||
<h2>Installation</h2><pre class="prettyprint source"><code>$ npm install --save holmes.js</code></pre><p>After which you can add it in your page with i.e. browserify or loading the module in a different script tag.</p> | ||
<p>You have to make sure that you have a <code>css</code> rule for the class <code>.hidden</code> that hides elements however you want. One option is to have this:</p> | ||
<pre class="prettyprint source lang-css"><code>.hidden { | ||
display: none; | ||
}</code></pre><p>but this could be any <code>css</code> you want.</p> | ||
<h2>Usage</h2><p><a href="https://haroen.me/holmes/">demo</a></p> | ||
<pre class="prettyprint source lang-js"><code>holmes({ | ||
input: '.search input', // queryselector for the input | ||
find: '.results article', // queryselector for element to search in | ||
placeholder: 'no results' // (optional) text to show when no results | ||
});</code></pre><p><a href="https://haroen.me/holmes/doc">full documentation</a></p> | ||
<h3>Questions?</h3><p>Compatible up to IE9.</p> | ||
<p>Let me know on twitter: <a href="https://twitter.com/haroenv">@haroenv</a>.</p> | ||
<h2>License</h2><p>Apache 2.0</p></article> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-holmes.html">holmes</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Jun 05 2016 15:24:20 GMT+0200 (CEST) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
Oops, something went wrong.