├── .jscs.json
├── .jshintrc
├── Gruntfile.js
├── LICENSE
├── README.md
├── README.ru.md
├── bower.json
├── dist
├── jquery.lookingfor.js
├── jquery.lookingfor.min.js
└── jquery.lookingfor.min.map
├── html
├── data
│ └── countries.csv
├── highlight.html
└── simple.html
├── package.json
├── screenshots
└── highlight.png
└── src
└── jquery.lookingfor.js
/.jscs.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "requireCurlyBraces": ["for", "while", "do", "if", "else"],
4 | "requireSpaceAfterKeywords": ["if", "for", "while", "do", "switch", "return"],
5 | "disallowSpacesInsideArrayBrackets": true,
6 | "requireSpacesInsideObjectBrackets": "all",
7 | "disallowQuotedKeysInObjects": true,
8 | "disallowSpaceAfterObjectKeys": true,
9 | "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
10 | "requireRightStickedOperators": ["!"],
11 | "disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
12 | "requireLeftStickedOperators": [","],
13 | "disallowKeywords": ["with", "eval"],
14 | "validateJSDoc": {
15 | "checkParamNames": true,
16 | "checkRedundantParams": true,
17 | "requireParamTypes": true
18 | }
19 | }
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "bitwise": true,
4 | "browser": true,
5 | "eqeqeq": true,
6 | "camelcase": true,
7 | "curly": true,
8 | "debug": true,
9 | "forin": true,
10 | "freeze": true,
11 | "immed": true,
12 | "latedef": true,
13 | "maxdepth": 3,
14 | "maxparams": 3,
15 | "newcap": true,
16 | "noarg": true,
17 | "noempty": true,
18 | "nonbsp": true,
19 | "quotmark": "single",
20 | "undef": true,
21 | "unused": true,
22 | "predef": [
23 | "define",
24 | "jQuery"
25 | ]
26 | }
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | 'use strict';
3 |
4 | require('matchdep')
5 | .filterDev('grunt-*')
6 | .forEach(grunt.loadNpmTasks);
7 |
8 | grunt.initConfig({
9 | jsSource: 'src/*.js',
10 | jsDist: 'dist/',
11 | banner:
12 | '/**\n' +
13 | ' * jquery.lookingfor — fast search as you type\n' +
14 | ' * @author Alexander Burtsev, http://burtsev.me, 2014—<%= grunt.template.today("yyyy") %>\n' +
15 | ' * @license MIT\n' +
16 | ' */\n',
17 |
18 | jshint: {
19 | options: {
20 | jshintrc: '.jshintrc'
21 | },
22 | app: ['<%= jsSource %>']
23 | },
24 |
25 | jscs: {
26 | options: {
27 | config: '.jscs.json'
28 | },
29 | app: ['<%= jsSource %>']
30 | },
31 |
32 | copy: {
33 | options: {
34 | process: function (content, srcpath) {
35 | return grunt.config.get('banner') + content;
36 | }
37 | },
38 | source: {
39 | files: [{
40 | expand: true,
41 | cwd: 'src/',
42 | src: ['**'],
43 | dest: 'dist/'
44 | }]
45 | }
46 | },
47 |
48 | uglify: {
49 | options: {
50 | banner: '<%= banner %>',
51 | sourceMap: true
52 | },
53 | lookingfor: {
54 | files: {
55 | '<%= jsDist %>jquery.lookingfor.min.js': ['<%= jsSource %>']
56 | }
57 | }
58 | },
59 |
60 | watch: {
61 | lookingfor: {
62 | files: ['<%= jsSource %>'],
63 | tasks: ['jshint', 'jscs', 'uglify']
64 | }
65 | }
66 | });
67 |
68 | grunt.registerTask('default', ['jshint', 'jscs', 'copy', 'uglify', 'watch']);
69 | };
70 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Alexander Burtsev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jquery.lookingfor
2 | =================
3 |
4 | 
5 |
6 | Fast search as you type jQuery plugin.
7 |
8 | It's very small (minified — 2.5kb, gzipped — 1.2kb), very fast and supports old browsers (IE6+).
9 |
10 | __jquery.lookingfor__ plugin searches text in list items (```
```) and hides unmatched items.
11 | It works not only for `
`s, but for any HTML element on a page.
12 | Any input field (```input, textarea```) can be transformed to search filter with __jquery.lookingfor__.
13 |
14 | [Live demo](http://albburtsev.github.io/jquery.lookingfor/)
15 |
16 | ## Install
17 |
18 | Download latest [release](https://github.com/albburtsev/jquery.lookingfor/releases).
19 | Use [minified](https://github.com/albburtsev/jquery.lookingfor/blob/master/jquery.lookingfor.min.js)
20 | or [development](https://github.com/albburtsev/jquery.lookingfor/blob/master/jquery.lookingfor.js) version.
21 |
22 | Or use [bower](http://bower.io/) for install:
23 |
24 | ```
25 | bower install jquery.lookingfor --save
26 | ```
27 |
28 | ## Usage
29 |
30 | Include [jQuery](http://jquery.com) and __jquery.lookingfor__ on your page:
31 |
32 | ```html
33 |
34 |
35 | ```
36 |
37 | Prepare list of items for following search and an input field (optional):
38 |
39 | ```html
40 |
41 |
42 |
First
43 |
Second
44 |
Third
45 | ...
46 |
47 | ```
48 |
49 | Call ```lookingfor()``` method with necessary options:
50 |
51 | ```js
52 | jQuery(function($) {
53 | $('#numerals').lookingfor({
54 | input: $('input[name="query"]'),
55 | items: 'li'
56 | });
57 | });
58 | ```
59 |
60 | ### Options
61 |
62 | All options are optional.
63 |
64 | * __input__ — input field's selector;
65 | * __items__ — item's selector, default – ```'li'```;
66 | * __highlight__ — set ```true``` to highlight matched text, default — ```false```;
67 | * __highlightColor__ — ```#RRGGBB``` background color for matched text, default – ```#FFDE00```;
68 | * __onFound {Function(HTMLElement item, String query)}__ — callback, will be called when text is found.
69 |
--------------------------------------------------------------------------------
/README.ru.md:
--------------------------------------------------------------------------------
1 | jquery.lookingfor
2 | =================
3 |
4 | 
5 |
6 | Быстрый поиск набираемого текста.
7 |
8 | Плагин очень маленький (минифицированный — 2.5kb, сжатый — 1.2kb), очень быстрый и даже поддерживает старые браузеры (IE6+).
9 |
10 | Плагин __jquery.lookingfor__ ищет текст в элементах списков (```
```) и скрывает те элементы, для которых не найдено совпадений.
11 | Он работает не только со списками, но и с любыми другими элементами на странице, содержащими текст.
12 | Любое текстовое поле (```input, textarea```) можно сделать поисковым фильтром с помощью __jquery.lookingfor__.
13 |
14 | [Демо](http://albburtsev.github.io/jquery.lookingfor/)
15 |
16 | ## Установка
17 |
18 | Скачайте последний [релиз](https://github.com/albburtsev/jquery.lookingfor/releases)
19 | и подключите на страницу [минифицированную](https://github.com/albburtsev/jquery.lookingfor/blob/master/jquery.lookingfor.min.js)
20 | или [полную](https://github.com/albburtsev/jquery.lookingfor/blob/master/jquery.lookingfor.js) версию плагина.
21 |
22 | Или установите с помощью [bower](http://bower.io/)
23 |
24 | ```
25 | bower install jquery.lookingfor --save
26 | ```
27 |
28 | ## Быстрый старт
29 |
30 | Подключите [jQuery](http://jquery.com) и __jquery.lookingfor__ на свою страницу:
31 |
32 | ```html
33 |
34 |
35 | ```
36 |
37 | Приготовьте список элементов, содержащих текст, и поле ввода (при необходимости):
38 |
39 | ```html
40 |
41 |