From 91cdc588cf5b3aa7d6d5f3e5ee3f18250a237167 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 1 Feb 2016 11:43:55 +0000 Subject: [PATCH] add CommonJS and package.json --- .gitignore | 33 +++++++++++++++++++++++++++++++++ js/dialogFx.js | 31 ++++++++++++++++++++++++------- package.json | 28 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e920c16 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history diff --git a/js/dialogFx.js b/js/dialogFx.js index c9e691a..467ad55 100644 --- a/js/dialogFx.js +++ b/js/dialogFx.js @@ -8,8 +8,28 @@ * Copyright 2014, Codrops * http://www.codrops.com */ -;( function( window ) { - + +(function (root, factory) { + var Modernizr = { + prefixed: function () { + return 'animation'; + }, + cssanimations: true, + }; + + if (typeof module === 'object' && module.exports) { + var classie = require('classie'); + try { + require('browsernizr/test/css/animations'); + Modernizr = require('browsernizr'); + } catch(e) {} + module.exports = factory(classie, Modernizr); + } else { + // Browser globals (root is window) + root.DialogFx = factory(root.classie, root.Modernizr || Modernizr); + } +}(this, function (classie, Modernizr) { + 'use strict'; var support = { animations : Modernizr.cssanimations }, @@ -151,8 +171,5 @@ this.isOpen = !this.isOpen; }; - - // add to global namespace - window.DialogFx = DialogFx; - -})( window ); + return DialogFx; +})); diff --git a/package.json b/package.json new file mode 100644 index 0000000..7ba444b --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "dialog-fx", + "version": "0.0.2", + "description": "A small collection of dialog effects using CSS animations for your inspiration.", + "main": "js/dialogFx.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/codrops/DialogEffects.git" + }, + "keywords": [ + "dialog", + "effect", + "animation", + "css" + ], + "author": "codrops", + "license": "MIT", + "bugs": { + "url": "https://github.com/codrops/DialogEffects/issues" + }, + "homepage": "https://github.com/codrops/DialogEffects#readme", + "dependencies": { + "classie": "^1.0.0" + } +}