Comparing version
177
Gruntfile.js
@@ -1,83 +0,110 @@ | ||
/* | ||
* classie | ||
* http://github.amexpub.com/modules/classie | ||
* | ||
* Copyright (c) 2013 Amex Pub. All rights reserved. | ||
*/ | ||
'use strict'; | ||
module.exports = function(grunt) { | ||
grunt.initConfig({ | ||
jsbeautifier: { | ||
files: ["<%= jshint.all %>"], | ||
options: { | ||
"indent_size": 2, | ||
"indent_char": " ", | ||
"indent_level": 0, | ||
"indent_with_tabs": false, | ||
"preserve_newlines": true, | ||
"max_preserve_newlines": 10, | ||
"brace_style": "collapse", | ||
"keep_array_indentation": false, | ||
"keep_function_indentation": false, | ||
"space_before_conditional": true, | ||
"eval_code": false, | ||
"indent_case": false, | ||
"unescape_strings": false, | ||
"space_after_anon_function": true | ||
} | ||
}, | ||
simplemocha: { | ||
options: { | ||
globals: ['should'], | ||
timeout: 3000, | ||
ignoreLeaks: false, | ||
ui: 'bdd', | ||
reporter: 'tap' | ||
}, | ||
all: { | ||
src: 'test/**/*.js' | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc' | ||
}, | ||
all: [ | ||
'Gruntfile.js', | ||
'config/**/*.js', | ||
'index.js', | ||
'lib/**/*.js', | ||
'routes/**/*.js', | ||
'test/**/*.js' | ||
] | ||
}, | ||
watch: { | ||
scripts: { | ||
// files: '**/*.js', | ||
files: [ | ||
'Gruntfile.js', | ||
'config/**/*.js', | ||
'index.js', | ||
'lib/**/*.js', | ||
'test/**/*.js', | ||
], | ||
tasks: ['lint', 'test'], | ||
options: { | ||
interrupt: true | ||
//Project configuration. | ||
grunt.initConfig({ | ||
jshint: { | ||
files: ['test/unit/**/*.js', 'test/intergration/**/*.js', 'lib/**/*.js', '!node_modules/*', '!test/helpers/**/*.js'], | ||
options: { | ||
jshintrc: '.jshintrc', | ||
reporter: require('jshint-stylish') | ||
} | ||
}, | ||
jsbeautifier: { | ||
files: ['lib/**/*.js', 'test/unit/**/*.js', 'Gruntfile.js'], | ||
options: { | ||
config: '.jsbeautify' | ||
} | ||
}, | ||
uglify: { | ||
options: { | ||
sourceMap: true, | ||
compress: { | ||
drop_console: true | ||
} | ||
}, | ||
prod: { | ||
files: { | ||
'classie.min.js': ['lib/**/*.js'] | ||
} | ||
} | ||
}, | ||
browserify: { | ||
options: { | ||
debug: true | ||
}, | ||
test: { | ||
files: { | ||
'test/browserified.js': ['test/unit/**/*.js'] | ||
} | ||
} | ||
}, | ||
coverage: { | ||
options: { | ||
thresholds: { | ||
'statements': 90, | ||
'branches': 90, | ||
'lines': 90, | ||
'functions': 90 | ||
}, | ||
dir: 'coverage', | ||
root: 'test' | ||
} | ||
}, | ||
plato: { | ||
lint: { | ||
options: { | ||
jshint: grunt.file.readJSON('.jshintrc'), | ||
dir: "test/coverage", | ||
title: grunt.file.readJSON('package.json').name, | ||
complexity: { | ||
minmi: true, | ||
forin: true, | ||
logicalot: false | ||
} | ||
}, | ||
files: { | ||
'test/coverage': ['lib/**/*.js'] | ||
} | ||
}, | ||
}, | ||
watch: { | ||
options: { | ||
livereload: true, | ||
}, | ||
jshint: { | ||
tasks: ['jshint'], | ||
files: ['test/unit/**/*.js', 'test/intergration/**/*.js', 'lib/**/*.js', '!node_modules/*', '!test/helpers/**/*.js'] | ||
}, | ||
uglify: { | ||
tasks: ['uglify'], | ||
files: ['lib/*.js'] | ||
}, | ||
jsbeautifier: { | ||
tasks: ['jsbeautifier'], | ||
files: ['test/unit/**/*.js', 'test/intergration/**/*.js', 'lib/**/*.js', '!node_modules/*', '!test/helpers/**/*.js'] | ||
} | ||
} | ||
} | ||
}); | ||
//automatically load deps from package.jso | ||
for (var key in grunt.file.readJSON("package.json").devDependencies) { | ||
if (key.indexOf("grunt") === 0 && key !== "grunt") { | ||
grunt.loadNpmTasks(key); | ||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('grunt-simple-mocha'); | ||
grunt.loadNpmTasks('grunt-jsbeautifier'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
require('time-grunt')(grunt); | ||
grunt.registerTask('default', ['jshint', 'simplemocha']); | ||
grunt.registerTask('lint', 'jshint'); | ||
grunt.registerTask('test', 'simplemocha'); | ||
grunt.registerTask('cover', ['plato']); | ||
grunt.registerTask('test', ['browserify:test']); | ||
grunt.registerTask('default', ['watch']); | ||
}; |
@@ -15,43 +15,71 @@ /*! | ||
// class helper functions from bonzo https://github.com/ded/bonzo | ||
// class helper functions from bonzo https://github.com/ded/bonzo | ||
var classList = require('./class_list_ployfill'), | ||
classie; | ||
function classReg( className ) { | ||
function classReg(className) { | ||
return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); | ||
} | ||
} | ||
// classList support for class management | ||
// altho to be fair, the api sucks because it won't accept multiple classes at once | ||
var hasClass, addClass, removeClass; | ||
function noop() {} | ||
if (typeof document === "object" && 'classList' in document.documentElement ) { | ||
hasClass = function( elem, c ) { | ||
return elem.classList.contains( c ); | ||
}; | ||
addClass = function( elem, c ) { | ||
elem.classList.add( c ); | ||
}; | ||
removeClass = function( elem, c ) { | ||
elem.classList.remove( c ); | ||
}; | ||
} | ||
else { | ||
hasClass = function( elem, c ) { | ||
return classReg( c ).test( elem.className ); | ||
}; | ||
addClass = function( elem, c ) { | ||
if ( !hasClass( elem, c ) ) { | ||
elem.className = elem.className + ' ' + c; | ||
} | ||
}; | ||
removeClass = function( elem, c ) { | ||
elem.className = elem.className.replace( classReg( c ), ' ' ); | ||
}; | ||
} | ||
function isArr(classes) { | ||
if (Array.isArray(classes)) { | ||
return true; | ||
} else if (Object.prototype.toString.call(classes) === '[object Array]') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
function toggleClass( elem, c ) { | ||
var fn = hasClass( elem, c ) ? removeClass : addClass; | ||
fn( elem, c ); | ||
} | ||
function removeMultiple() { | ||
var c = arguments[1], | ||
elem = arguments[0]; | ||
c.forEach(function(value) { | ||
if (classie.has(elem, value)) { | ||
noop(); | ||
} | ||
classie.removeClass(elem, value); | ||
}); | ||
} | ||
var classie = { | ||
function addMultiple() { | ||
var c = arguments[1], | ||
elem = arguments[0]; | ||
c.forEach(function(value) { | ||
if (classie.has(elem, value)) { | ||
noop(); | ||
} | ||
classie.addClass(elem, value); | ||
}); | ||
} | ||
function hasClass(elem, c) { | ||
return elem.classList.contains(c); | ||
} | ||
function addClass(elem, c) { | ||
if (isArr(c)) { | ||
addMultiple.apply(this, arguments); | ||
} else { | ||
elem.classList.add(c); | ||
} | ||
} | ||
function removeClass(elem, c) { | ||
if (isArr(c)) { | ||
removeMultiple.apply(this, arguments); | ||
} else { | ||
elem.classList.remove(c); | ||
} | ||
} | ||
function toggleClass(elem, c) { | ||
var fn = hasClass(elem, c) ? removeClass : addClass; | ||
fn(elem, c); | ||
} | ||
var classie = { | ||
// full names | ||
@@ -67,18 +95,12 @@ hasClass: hasClass, | ||
toggle: toggleClass | ||
}; | ||
}; | ||
// transport | ||
// transport | ||
if ( typeof module === "object" && module && typeof module.exports === "object" ) { | ||
if (typeof module === "object" && module && typeof module.exports === "object") { | ||
// commonjs / browserify | ||
module.exports = classie; | ||
} else { | ||
} else { | ||
// AMD | ||
define(classie); | ||
} | ||
// If there is a window object, that at least has a document property, | ||
// define classie | ||
if ( typeof window === "object" && typeof window.document === "object" ) { | ||
window.classie = classie; | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "dom class helper functions, browserified, classie -from bonzo", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
@@ -15,14 +15,25 @@ "engines": { | ||
}, | ||
"bugs": { | ||
"url": "git://github.com/yawetse/classie/issues" | ||
}, | ||
"scripts": { | ||
"test": "mocha -R spec --recursive" | ||
"test": "testem", | ||
"ci": "testem ci" | ||
}, | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"chai": "1.5.0", | ||
"contributor": "^0.1.22", | ||
"grunt": "0.4.1", | ||
"grunt-contrib-jshint": "0.4.3", | ||
"grunt-simple-mocha": "0.4.0", | ||
"grunt-browserify": "^2.1.4", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-contrib-uglify": "^0.5.1", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-jsbeautifier": "0.1.7", | ||
"mocha": "1.9.0", | ||
"grunt-contrib-watch": "^0.6.1" | ||
"grunt-plato": "^1.3.0", | ||
"jshint-stylish": "^0.4.0", | ||
"mocha": "^1.21.4", | ||
"testem": "^0.6.18", | ||
"time-grunt": "^0.4.0" | ||
}, | ||
@@ -34,3 +45,23 @@ "keywords": [ | ||
"dom manipulation" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Ernie Casilla", | ||
"email": "ecasilla@icloud.com", | ||
"url": "https://github.com/ecasilla", | ||
"contributions": 6, | ||
"additions": 17017, | ||
"deletions": 16719, | ||
"hireable": true | ||
}, | ||
{ | ||
"name": "Yaw Etse", | ||
"email": "yaw.etse@gmail.com", | ||
"url": "https://github.com/yawetse", | ||
"contributions": 4, | ||
"additions": 385, | ||
"deletions": 101, | ||
"hireable": false | ||
} | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28292
405.94%19
111.11%452
189.74%1
-50%13
85.71%1
Infinity%1
Infinity%