Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds Gruntfile.js, fixes #3
  • Loading branch information
albburtsev committed Apr 24, 2014
1 parent fe61d31 commit f5faf11
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 11 deletions.
19 changes: 19 additions & 0 deletions .jscs.json
@@ -0,0 +1,19 @@

{
"requireCurlyBraces": ["for", "while", "do", "if", "else"],
"requireSpaceAfterKeywords": ["if", "for", "while", "do", "switch", "return"],
"disallowSpacesInsideArrayBrackets": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireRightStickedOperators": ["!"],
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireLeftStickedOperators": [","],
"disallowKeywords": ["with", "eval"],
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}
53 changes: 53 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,53 @@
module.exports = function(grunt) {
'use strict';

require('matchdep')
.filterDev('grunt-*')
.forEach(grunt.loadNpmTasks);

grunt.initConfig({
jsSource: 'jquery.lookingfor.js',
banner:
'/**\n' +
' * jquery.lookingfor\n' +
' * @author Alexander Burtsev, http://burtsev.me, <%= grunt.template.today("yyyy") %>\n' +
' * @license MIT\n' +
' */\n',

jshint: {
options: {
globals: {
jQuery: true
}
},
app: ['<%= jsSource %>']
},

jscs: {
options: {
config: '.jscs.json'
},
app: ['<%= jsSource %>']
},

uglify: {
options: {
banner: '<%= banner %>'
},
lookingfor: {
files: {
'jquery.lookingfor.min.js': ['<%= jsSource %>']
}
}
},

watch: {
lookingfor: {
files: ['<%= jsSource %>'],
tasks: ['jshint', 'jscs', 'uglify']
}
}
});

grunt.registerTask('default', ['jshint', 'jscs', 'uglify', 'watch']);
};
21 changes: 11 additions & 10 deletions jquery.lookingfor.js
Expand Up @@ -2,10 +2,8 @@
* jQuery.lookingfor
* Searches text in list items on the page, hides unmatched items
*
* @version 0.0.0
* @requires jQuery
* @author Alexander Burtsev
* @copyright 2014 Alexander Burtsev
* @author Alexander Burtsev, http://burtsev.me
* @license MIT
*
* @todo: nested items
Expand All @@ -24,7 +22,7 @@
return this.each(function() {
new Lookingfor(this, opts);
});
}
};

function Lookingfor(container, opts) {
$.extend(this, {
Expand All @@ -46,15 +44,16 @@
hiddenItemAttr: 'data-lfhidden',
hiddenCount: 0
}, opts || {});

this._items = this.items ? $(this.items, container) : this._container.children();
this._input = $(this.input);

if ( !this._items.length )
if ( !this._items.length ) {
return;
}

if ( this._input.length ) {
this._input.on('keyup', this._debounce(function() {
this._input.on('keyup change', this._debounce(function() {
var value = (this._input.val() || '').toLowerCase();
value = $.trim(value);

Expand Down Expand Up @@ -151,8 +150,9 @@
},

showAll: function() {
if ( !this.hiddenCount )
if ( !this.hiddenCount ) {
return;
}

for (var i = 0, length = this.cache.length, item; i < length; i++) {
item = this.cache[i];
Expand All @@ -178,9 +178,10 @@
self = this;

return function() {
var args = arguments;
clearTimeout(timer);
timer = setTimeout(function() {
fn.call(context || self);
fn.apply(context || self, args);
}, delay);
};
},
Expand All @@ -191,7 +192,7 @@
return function() {
var start = new Date();
fn.call(context || self);
console.log(label || '', (new Date).getTime() - start.getTime());
console.log(label || '', (new Date()).getTime() - start.getTime());
};
}
};
Expand Down
6 changes: 6 additions & 0 deletions jquery.lookingfor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Expand Up @@ -20,5 +20,13 @@
"bugs": {
"url": "https://github.com/albburtsev/jquery.lookingfor/issues"
},
"homepage": "https://github.com/albburtsev/jquery.lookingfor"
"homepage": "https://github.com/albburtsev/jquery.lookingfor",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jscs-checker": "^0.4.1",
"matchdep": "^0.3.0"
}
}

0 comments on commit f5faf11

Please sign in to comment.