// Random code for illustration purposes
const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
// PostCSS parsing of scss partials for vendor prefixes, style and flexbox fixes
gulp.task('postcss', function () {
var postcss = require('gulp-postcss');
var scss = require('postcss-scss');
var flexbugs = require('postcss-flexbugs-fixes');
var autoprefixer = require('autoprefixer');
var stylelint = require('stylelint');
var stylefmt = require('stylefmt');
var plugins = [flexbugs(), autoprefixer(), stylelint(), stylefmt()];
return gulp.src('_sass/**/*.scss')
.pipe(postcss(plugins, {syntax: scss}))
.pipe(gulp.dest('_sass'));
});
function setMenuItemActive() {
menuItem = document.getElementById('header-main-menu').getElementsByTagName('a');
for(i = 0; i < menuItem.length; i++) {
if(document.location.href.indexOf(menuItem[i].href)>=0) {
menuItem[i].className='active';
}
}
}
window.onload = setMenuItemActive;
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function schemesFunction() {
document.getElementById("schemesDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.schemes-button')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
};
JavaScript samples
Next:SCSS samples
Previous:Code samples