-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit da09ebd
Showing
7 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"rules": { | ||
"block-scoped-var": [1], | ||
"block-spacing": [2, "never"], | ||
"brace-style": [2], | ||
"camelcase": [2], | ||
"comma-spacing": [2], | ||
"curly": [2, "all"], | ||
"eqeqeq": [1], | ||
"no-else-return": [2], | ||
"no-empty-function": [2], | ||
"no-irregular-whitespace": [1], | ||
"no-multi-spaces": [2], | ||
"no-param-reassign": [2], | ||
"no-return-assign": [2], | ||
"no-trailing-spaces": [1], | ||
"no-unreachable": [2], | ||
"no-unused-vars": [2], | ||
"quotes": [2, "single"], | ||
"semi": [2, "always"], | ||
"valid-typeof": [2] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
(function (root, factory) { | ||
if ( typeof define === 'function' && define.amd ) { | ||
define([], factory(root)); | ||
} else if ( typeof exports === 'object' ) { | ||
module.exports = factory(root); | ||
} else { | ||
root.myPlugin = factory(root); | ||
} | ||
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) { | ||
|
||
'use strict'; | ||
|
||
|
||
var myPlugin = {}; | ||
var supports = !!document.querySelector && !!root.addEventListener; | ||
var settings, eventTimeout; | ||
|
||
var defaults = { | ||
someVar: 123, | ||
initClass: 'js-myplugin', | ||
callbackBefore: function () {}, | ||
callbackAfter: function () {} | ||
}; | ||
|
||
|
||
|
||
var forEach = function (collection, callback, scope) { | ||
if (Object.prototype.toString.call(collection) === '[object Object]') { | ||
for (var prop in collection) { | ||
if (Object.prototype.hasOwnProperty.call(collection, prop)) { | ||
callback.call(scope, collection[prop], prop, collection); | ||
} | ||
} | ||
} else { | ||
for (var i = 0, len = collection.length; i < len; i++) { | ||
callback.call(scope, collection[i], i, collection); | ||
} | ||
} | ||
}; | ||
|
||
var extend = function ( defaults, options ) { | ||
var extended = {}; | ||
forEach(defaults, function (value, prop) { | ||
extended[prop] = defaults[prop]; | ||
}); | ||
forEach(options, function (value, prop) { | ||
extended[prop] = options[prop]; | ||
}); | ||
return extended; | ||
}; | ||
|
||
var getDataOptions = function ( options ) { | ||
return !options || !(typeof JSON === 'object' && typeof JSON.parse === 'function') ? {} : JSON.parse( options ); | ||
}; | ||
|
||
var getClosest = function (elem, selector) { | ||
var firstChar = selector.charAt(0); | ||
for ( ; elem && elem !== document; elem = elem.parentNode ) { | ||
if ( firstChar === '.' ) { | ||
if ( elem.classList.contains( selector.substr(1) ) ) { | ||
return elem; | ||
} | ||
} else if ( firstChar === '#' ) { | ||
if ( elem.id === selector.substr(1) ) { | ||
return elem; | ||
} | ||
} else if ( firstChar === '[' ) { | ||
if ( elem.hasAttribute( selector.substr(1, selector.length - 2) ) ) { | ||
return elem; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
|
||
var eventHandler = function (event) { | ||
var toggle = event.target; | ||
var closest = getClosest(toggle, '[data-some-selector]'); | ||
if ( closest ) { | ||
} | ||
}; | ||
|
||
myPlugin.destroy = function () { | ||
|
||
if ( !settings ) return; | ||
|
||
document.documentElement.classList.remove( settings.initClass ); | ||
|
||
|
||
document.removeEventListener('click', eventHandler, false); | ||
|
||
settings = null; | ||
eventTimeout = null; | ||
|
||
}; | ||
|
||
var eventThrottler = function () { | ||
if ( !eventTimeout ) { | ||
eventTimeout = setTimeout(function() { | ||
eventTimeout = null; | ||
actualMethod( settings ); | ||
}, 66); | ||
} | ||
}; | ||
|
||
myPlugin.init = function ( options ) { | ||
|
||
if ( !supports ) return; | ||
|
||
myPlugin.destroy(); | ||
|
||
settings = extend( defaults, options || {} ); | ||
|
||
document.documentElement.classList.add( settings.initClass ); | ||
|
||
|
||
document.addEventListener('click', eventHandler, false); | ||
|
||
}; | ||
|
||
|
||
|
||
return myPlugin; | ||
|
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var eslint = require('gulp-eslint'); | ||
var rename = require('gulp-rename'); | ||
var strip = require('gulp-strip-comments'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
gulp.task('lint', function() { | ||
return gulp.src('./src/**/*.js') | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()); | ||
}); | ||
|
||
gulp.task('bundleScripts', function() { | ||
return gulp.src('./src/pleaseDontGo.js') | ||
.pipe(strip()) | ||
.pipe(gulp.dest('./dist')); | ||
}); | ||
|
||
gulp.task('minifyBundle', ['bundleScripts'], function() { | ||
return gulp.src('./dist/pleaseDontGo.js') | ||
.pipe(uglify()) | ||
.pipe(rename('pleaseDontGo.min.js')) | ||
.pipe(gulp.dest('./dist')); | ||
}); | ||
|
||
gulp.task('build', ['lint', 'minifyBundle']); | ||
|
||
gulp.task('watch', function() { | ||
gulp.watch('./src/**/*.js', ['lint', 'minifyBundle']); | ||
}); | ||
|
||
gulp.task('default', ['build', 'watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "please-dont-go", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./dist/pleaseDontGo.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/thomasvaeth/please-dont-go.git" | ||
}, | ||
"homepage": "https://github.com/thomasvaeth/please-dont-go", | ||
"bugs": "https://github.com/thomasvaeth/please-dont-go/issues", | ||
"scripts": { | ||
"start": "gulp" | ||
}, | ||
"keywords": [ | ||
"fetch", | ||
"instagram" | ||
], | ||
"author": "Thomas Vaeth <[email protected]> (http://thomasvaeth.com/)", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^3.0.1", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-strip-comments": "^2.4.3", | ||
"gulp-uglify": "^2.0.0" | ||
} | ||
} |
Oops, something went wrong.