Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "galiria", | ||
"description": "minimal image gallery", | ||
"main": "index.js", | ||
"main": "build/galiria.js", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Armando Magalhães <armando.mag95@gmail.com> (http://armand1m.herokuapp.com)" |
{ | ||
"name": "galiria", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "minimal image gallery", | ||
@@ -25,4 +25,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"gulp": "^3.9.0" | ||
"grunt": "^0.4.5" | ||
} | ||
} |
@@ -1,7 +0,18 @@ | ||
window.Galiria = (function(options) { | ||
module.exports = function Galiria() { | ||
'use strict'; | ||
var instance = _createContainerInstance(); | ||
/** @const instance Instance of Galiria, a Singleton. */ | ||
var instance; | ||
function _figureOnClick(e) { | ||
/** | ||
* must clone de <figure> element from the DOM | ||
* add de .galiria__container__figure element class on it | ||
* and append it on .galiria__container element class. | ||
* | ||
* also, set the modifier class .galiria__container--active on | ||
* .galiria__container element class. | ||
* | ||
* @param Event e Event when clickin on the image. | ||
*/ | ||
function _imageOnClick(e) { | ||
var figure = e.target.parentNode.cloneNode(true); | ||
@@ -20,2 +31,11 @@ figure.classList.add('galiria__container__figure'); | ||
/** | ||
* should remove the figure from the DOM | ||
* and from the {@var instance}. | ||
* | ||
* also removes the .galiria__container--active modifier class | ||
* from the container in {@var instance}. | ||
* | ||
* @param Event e Event when clickin on container. | ||
*/ | ||
function _containerOnClick(e) { | ||
@@ -30,3 +50,9 @@ if (instance.figure) { | ||
function _createContainerInstance() { | ||
/** | ||
* create a instance object with a container | ||
* and a list (the element with '.galiria' block class) | ||
* | ||
* @return instance An object with container DOM element, and a list | ||
*/ | ||
function _createInstance() { | ||
var docFrag = document.createDocumentFragment() | ||
@@ -46,2 +72,8 @@ , container = _createContainerElement() | ||
/** | ||
* creates a <div>, which will have a class .galiria__container | ||
* and a event listener on click. | ||
* | ||
* @return HTMLDivElement A div with .galiria__container element class | ||
*/ | ||
function _createContainerElement() { | ||
@@ -56,13 +88,20 @@ var container = document.createElement("div"); | ||
function _setFigureEvents() { | ||
for (var i = instance.list.children.length; i--;) { | ||
instance.list.children[i].addEventListener('click', _figureOnClick); | ||
} | ||
/** | ||
* set event listeners on all the childrens | ||
* of {@var instance.list}, the '<figure>' tags. | ||
*/ | ||
function _setImageEvents() { | ||
for (var i = instance.list.children.length; i--;) | ||
instance.list.children[i].children[0].addEventListener('click', _imageOnClick); | ||
} | ||
/** | ||
* actually initialize the Galiria | ||
*/ | ||
function init() { | ||
_setFigureEvents(); | ||
instance = _createInstance(); | ||
_setImageEvents(); | ||
} | ||
init(); | ||
})(); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
8801
9
217
1
34
3
2