Skip to content

Commit

Permalink
Reformat JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
sylhare committed Jun 15, 2019
1 parent b38e98e commit c21eea9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions assets/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ gulp.task("img", function imging() {
gulp.task('webp', () =>
gulp.src('img/**/*.{png,svg,jpg,jpeg,gif}')
.pipe(webp({
quality: 60,
preset: 'photo',
method: 6
quality: 60,
preset: 'photo',
method: 6
}))
.pipe(gulp.dest('img/'))
);
Expand Down
40 changes: 20 additions & 20 deletions assets/js/partials/katex_init.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
var elements = document.getElementsByTagName('script');

Array.prototype.forEach.call(elements, function (element) {
if (element.type.indexOf('math/tex') !== -1) {
// Extract math markdown
var textToRender = element.innerText || element.textContent;
if (element.type.indexOf('math/tex') !== -1) {
// Extract math markdown
var textToRender = element.innerText || element.textContent;

// Kramdown and KaTeX workaround
// https://github.com/rohanchandra/type-theme/issues/47
textToRender = textToRender.replace(/%.*/g, '');
// Kramdown and KaTeX workaround
// https://github.com/rohanchandra/type-theme/issues/47
textToRender = textToRender.replace(/%.*/g, '');

// Create span for KaTeX
var katexElement = document.createElement('span');
// Create span for KaTeX
var katexElement = document.createElement('span');

// Support inline and display math
if (element.type.indexOf('mode=display') !== -1) {
katexElement.className += "math-display";
textToRender = '\\displaystyle {' + textToRender + '}';
} else {
katexElement.className += "math-inline";
}

// Set displayMode to true to center equation
// https://github.com/Khan/KaTeX/issues/626
katex.render(textToRender, katexElement, {displayMode: false});
element.parentNode.insertBefore(katexElement, element);
// Support inline and display math
if (element.type.indexOf('mode=display') !== -1) {
katexElement.className += "math-display";
textToRender = '\\displaystyle {' + textToRender + '}';
} else {
katexElement.className += "math-inline";
}

// Set displayMode to true to center equation
// https://github.com/Khan/KaTeX/issues/626
katex.render(textToRender, katexElement, {displayMode: false});
element.parentNode.insertBefore(katexElement, element);
}
});
34 changes: 17 additions & 17 deletions assets/js/partials/masonry_init.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// init Masonry
try {
var elem = document.querySelector('.grid');
var msnry = new Masonry(elem, {
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter-sizer',
percentPosition: true
});
var elem = document.querySelector('.grid');
var msnry = new Masonry(elem, {
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter-sizer',
percentPosition: true
});

// layout Masonry after each image loads
var imgLoad = imagesLoaded(elem);
imgLoad.on('progress', function (instance, image) {
msnry.layout();
});
// layout Masonry after each image loads
var imgLoad = imagesLoaded(elem);
imgLoad.on('progress', function (instance, image) {
msnry.layout();
});
} catch (err) {
if (err instanceof ReferenceError) {
// Do nothing, Masonry is defined only in the gallery page
} else {
throw err;
}
if (err instanceof ReferenceError) {
// Do nothing, Masonry is defined only in the gallery page
} else {
throw err;
}
}
36 changes: 18 additions & 18 deletions assets/js/partials/navbar.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
document.addEventListener("DOMContentLoaded", function (event) {

/*
* Display the menu items on smaller screens
*/
var pull = document.getElementById('pull');
var menu = document.querySelector('nav ul');
/*
* Display the menu items on smaller screens
*/
var pull = document.getElementById('pull');
var menu = document.querySelector('nav ul');

pull.addEventListener('click', function (e) {
menu.classList.toggle('hide');
});
pull.addEventListener('click', function (e) {
menu.classList.toggle('hide');
});

/*
* Make the header images move on scroll
*/
window.addEventListener('scroll', function () {
var x = window.pageYOffset || document.body.scrollTop;
var main = document.getElementById("main");
var mainStyle = main.style;
mainStyle.backgroundPosition = '100% ' + parseInt(-x/3) + 'px' + ', 0%, center top';
});
/*
* Make the header images move on scroll
*/
window.addEventListener('scroll', function () {
var x = window.pageYOffset || document.body.scrollTop;
var main = document.getElementById("main");
var mainStyle = main.style;

mainStyle.backgroundPosition = '100% ' + parseInt(-x / 3) + 'px' + ', 0%, center top';
});
});

0 comments on commit c21eea9

Please sign in to comment.