Delegate a listener for the blur() event, on document.
This component is predominantly used to record 'blur' events on form elements. However is flexible enough to be customised.
$ component install nib-components/track-event
<!-- multiple skaters --> | |
<html> | |
<head> | |
</head> | |
<body> | |
<div class="js-pro-skater"> | |
<span>Favourite Pro Skater: {fullName} of {company}</span><br/> | |
<span>{firstName} was the best!</span> |
module.exports = function(name){ | |
document.addEventListener('blur', function(el){ | |
if (!el.target.value){ | |
_gaq.push(['_trackEvent', name, 'skipped', el.target.name]); | |
} | |
else { | |
_gaq.push(['_trackEvent', name, 'completed', el.target.name]); | |
} | |
}, true); | |
}; |
var data = [ | |
{price: "$99.99", stocked: true, name: "iPod Touch", category: "Electronics"}, | |
{price: "$399.99", stocked: false, name: "iPhone 5", category: "Electronics"}, | |
{price: "$199.99", stocked: true, name: "Nexus 7", category: "Electronics"}, | |
{price: "$49.99", stocked: true, name: "Football", category: "Sporting Goods"}, | |
{price: "$9.99", stocked: true, name: "Baseball", category: "Sporting Goods"}, | |
{price: "$29.99", stocked: false, name: "Basketball", category: "Sporting Goods"} | |
]; |
var BahaMenLyrics = require('bahaMenLyrics'); | |
var dogs = new BahaMenLyrics(); | |
dogs.sing(); // "Who let the Dogs out?! Woof... Woof... Woof... Woof" | |
var goats = new BahaMenLyrics('Goats', 'Baaaa'); | |
goats.sing(); // "Who let the Goats out?! Baaa... Baaa... Baaa... Baaa" |
/* | |
* Require our plugins. | |
*/ | |
var gulp = require('gulp'), | |
debug = require('gulp-debug'), | |
sass = require('gulp-ruby-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
minifycss = require('gulp-minify-css'), | |
jshint = require('gulp-jshint'), | |
uglify = require('gulp-uglify'), |
/* | |
* Require our plugins. | |
*/ | |
var gulp = require('gulp'), | |
debug = require('gulp-debug'), | |
sass = require('gulp-ruby-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
minifycss = require('gulp-minify-css'), | |
jshint = require('gulp-jshint'), | |
uglify = require('gulp-uglify'), |
This example uses Browserify and expects a stucture like | |
|- gulpfile.js | |
| | |
|- package.json | |
| | |
|- [javascript] | |
| | | |
| | - app.js | |
| | |
var promise = getPromise('http://api.icndb.com/jokes/random') | |
promise.then(function(data) { | |
console.log('Got data! Promise fulfilled.'); // 1st request finished | |
// 2nd request | |
return getPromise('http://api.icndb.com/jokes/random'); | |
}).then(function(result) { | |
console.log('the final result'); | |
}); |
{ | |
// -------------------------------------------------------------------- | |
// JSHint Configuration, Strict Edition | |
// -------------------------------------------------------------------- | |
// | |
// This is a options template for [JSHint][1], using [JSHint example][2] | |
// and [Ory Band's example][3] as basis and setting config values to | |
// be most strict: | |
// | |
// * set all enforcing options to true |