Comparing version 0.0.2 to 0.0.3
69
index.js
@@ -1,4 +0,4 @@ | ||
module.exports = function(element, options) { | ||
return new dropl(element, options); | ||
}; | ||
var classes = require('clas'); | ||
var events = require('evet'); | ||
var types = require('of'); | ||
@@ -9,47 +9,12 @@ // Dropdown | ||
var dropl = function(element, options) { | ||
if(!(this instanceof dropl)) return new dropl(element, options); | ||
this._setElement(element); | ||
this._setOptions(options); | ||
this._setElement(element); | ||
this._addOptions(); | ||
this.init(); | ||
}; | ||
var types = { | ||
isElement : function(node) { | ||
return node.nodeName && (node.nodeType === 1 || node.nodeType === 9); | ||
}, | ||
isString : function(value) { | ||
return Object.prototype.toString.call(value) === '[object String]'; | ||
}, | ||
isArray : function(obj) { | ||
return Object.prototype.toString.call(obj) === '[object Array]'; | ||
}, | ||
isObject : function(obj) { | ||
return obj !== null && Object.prototype.toString.call(obj) === '[object Object]'; | ||
} | ||
} | ||
var classes = { | ||
add: function(element, name) { | ||
element.classList.add(name); | ||
}, | ||
remove: function(element, name) { | ||
element.classList.remove(name); | ||
}, | ||
toggle: function(element, name) { | ||
element.classList.toggle(name); | ||
}, | ||
has: function(element, name) { | ||
return element.classList.contains(name); | ||
} | ||
function indexOf(arr, item) { | ||
return Array.prototype.indexOf.call(arr, item); | ||
}; | ||
var events = { | ||
on : function(element, type, fn, useCapture) { | ||
element.addEventListener(type, fn, !!useCapture); | ||
}, | ||
off : function(element, type, fn) { | ||
element.removeEventListener(type, fn); | ||
}, | ||
}; | ||
function hasProp(obj, prop) { | ||
@@ -73,4 +38,3 @@ return obj !== null && Object.prototype.hasOwnProperty.call(obj, prop); | ||
var defaults = { | ||
'align': 'left', | ||
'hover': false | ||
'align': 'left' | ||
}; | ||
@@ -81,5 +45,5 @@ this.options = extend(defaults, options); | ||
dropl.prototype._setElement = function(element) { | ||
if (types.isElement(element)) { | ||
if (types.element(element)) { | ||
this.element = element; | ||
} else if (types.isString(element)) { | ||
} else if (types.string(element)) { | ||
this.element = document.querySelector(element); | ||
@@ -110,13 +74,6 @@ } else { | ||
}); | ||
if (this.options.hover) { | ||
events.on(clicker, 'onmouseover', function(event) { | ||
self.toggle(); | ||
}); | ||
events.on(clicker, 'onmouseout', function(event) { | ||
self.toggle(); | ||
}); | ||
} | ||
}; | ||
dropl.prototype.init = function() { | ||
this._addOptions(); | ||
this._primeEvents(); | ||
@@ -137,2 +94,4 @@ }; | ||
if (!classes.has(dropdown, 'dropl-hidden')) classes.add(dropdown, 'dropl-hidden'); | ||
}; | ||
}; | ||
module.exports = dropl; |
{ | ||
"name": "dropl", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "dropdown", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "browserify index.js --standalone dropl > build/dropl.js", | ||
"minify": "yuicompressor build/dropl.js -o build/dropl.min.js" | ||
}, | ||
@@ -21,3 +22,8 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/ergusto/dropl" | ||
"homepage": "https://github.com/ergusto/dropl", | ||
"dependencies": { | ||
"clas": "0.0.5", | ||
"evet": "0.0.1", | ||
"of": "0.0.3" | ||
} | ||
} |
@@ -26,6 +26,5 @@ ##dropl | ||
var options = { | ||
'align': 'right', | ||
'hover': true | ||
'align': 'right' | ||
}; | ||
var dropdown = dropl(element, options); | ||
``` |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
14620
8
278
3
29
4
1
+ Addedclas@0.0.5
+ Addedevet@0.0.1
+ Addedof@0.0.3
+ Addedclas@0.0.5(transitive)
+ Addedevet@0.0.1(transitive)
+ Addedof@0.0.3(transitive)