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
/* | |
* Utility to create index file with a list of all files - TOC | |
* */ | |
gulp.task('create-toc', function () { | |
var fs = require('fs'); | |
var fileList = ''; | |
fs.readdir('pages/cats', function(err, files) { | |
files.forEach(function (file) { | |
fileList += '<li><a href="'+ file +'">'+ file +'</a></li>'; |
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
gulp.task('webpack', function () { | |
console.log('TASK:WEBPACK'); | |
/* | |
* run in gulp: gulp webpack --target=prod | |
* to create prod JS | |
* */ | |
if (gutil.env.target == 'prod') { | |
webpackConfig.plugins = [ | |
new webpack.optimize.DedupePlugin(), |
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
gulp.task('rename', function () { | |
var fs = require('fs'); | |
var fileList = ''; | |
fs.readdir('sass/test', function(err, files) { | |
files.forEach(function (file) { | |
console.log('file: ', file); | |
fs.rename('sass/test/' + file, 'sass/test/_' + file, function (err) { | |
if (err) console.log('ERR: ' + err); | |
}) |
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 source: https://www.kirupa.com/html5/get_element_position_using_javascript.htm | |
// Helper function to get an element's exact position | |
function getPosition(el) { | |
var xPos = 0; | |
var yPos = 0; | |
while (el) { | |
if (el.tagName == "BODY") { | |
// deal with browser quirks with body/window/document and page scroll | |
var xScroll = el.scrollLeft || document.documentElement.scrollLeft; |
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
gulp.task('update-content-file', function () { | |
"use strict"; | |
var fs = fs || require('fs'); | |
var path = 'path/to/folder'; | |
// example of CSS path change and adding new css | |
var oldContent = /<link href="(.*)dev\/css\/main.css" rel="stylesheet">/; | |
var newContent = '<link href="/dev/css/main.css" rel="stylesheet"><link href="/dev/css/specific.css" rel="stylesheet">'; | |
fs.readdir(path, function(err, files) { |
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
(function() { | |
"use strict"; | |
var ticking = false; | |
window.addEventListener('scroll', function () { | |
if (!ticking) { | |
window.requestAnimationFrame(function () { | |
runYourMethod(); | |
ticking = false; | |
}); |
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
window.addEventListener("load", function () { | |
console.warn('------------------- EAGLE LANDED -------------------') | |
let arr = Array.from(document.getElementsByTagName('a')); | |
console.warn('A TAGS', arr.length); | |
arr.forEach(function (a) { | |
a.addEventListener('click', function (e) { | |
console.warn('CLICK ELEM', e.target); | |
e.preventDefault(); | |
}); | |
}); |
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
(function () { | |
const subClassExample = { | |
Person: function(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.gender = 'male'; | |
} | |
} | |
const clark = new subClassExample.Person('Clark', 'Kent'); |
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
/** | |
Task will run through /src/html/ folder and will loop through each html file | |
When it finds {{head}}, it will be replaced with a content from /src/inc/head.html | |
Example of src/inc/breadcrumb.html | |
<ul> | |
<li><a href="link/page">Home</a></li> | |
<li>{{content}}</li> | |
</ul> |
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
const asc = (left, right) => left < right ? -1 : left > right ? 1 : 0; | |
const desc = (left, right) => left > right ? -1 : left < right ? 1 : 0; | |
const sort = (array, column, order) => array.sort(({[column]: left}, {[column]: right}) => order(left, right)); | |
export const sortAsc = (array, column) => sort(array, column, asc); | |
export const sortDesc = (array, column) => sort(array, column, desc); |
OlderNewer