mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 18:24:30 -07:00
Add babel
This commit is contained in:
65
docs/_javascript/bulma.js
Normal file
65
docs/_javascript/bulma.js
Normal file
@@ -0,0 +1,65 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
|
||||
var $toggle = $('#nav-toggle');
|
||||
var $menu = $('#nav-menu');
|
||||
|
||||
$toggle.click(function() {
|
||||
$(this).toggleClass('is-active');
|
||||
$menu.toggleClass('is-active');
|
||||
});
|
||||
|
||||
$('.modal-button').click(function() {
|
||||
var target = $(this).data('target');
|
||||
$('html').addClass('is-clipped');
|
||||
$(target).addClass('is-active');
|
||||
});
|
||||
|
||||
$('.modal-background, .modal-close').click(function() {
|
||||
$('html').removeClass('is-clipped');
|
||||
$(this).parent().removeClass('is-active');
|
||||
});
|
||||
|
||||
$('.modal-card-head .delete, .modal-card-foot .button').click(function() {
|
||||
$('html').removeClass('is-clipped');
|
||||
$('#modal-ter').removeClass('is-active');
|
||||
});
|
||||
|
||||
$(document).on('keyup',function(e) {
|
||||
if (e.keyCode == 27) {
|
||||
$('html').removeClass('is-clipped');
|
||||
$('.modal').removeClass('is-active');
|
||||
}
|
||||
});
|
||||
|
||||
var $highlights = $('.highlight');
|
||||
|
||||
$highlights.each(function() {
|
||||
var $el = $(this);
|
||||
var copy = '<button class="copy">Copy</button>';
|
||||
var expand = '<button class="expand">Expand</button>';
|
||||
$el.append(copy);
|
||||
|
||||
if ($el.find('pre code').innerHeight() > 600) {
|
||||
$el.append(expand);
|
||||
}
|
||||
});
|
||||
|
||||
var $highlightButtons = $('.highlight .copy, .highlight .expand');
|
||||
|
||||
$highlightButtons.hover(function() {
|
||||
$(this).parent().css('box-shadow', '0 0 0 1px #ed6c63');
|
||||
}, function() {
|
||||
$(this).parent().css('box-shadow', 'none');
|
||||
});
|
||||
|
||||
$('.highlight .expand').click(function() {
|
||||
$(this).parent().children('pre').css('max-height', 'none');
|
||||
});
|
||||
|
||||
new Clipboard('.copy', {
|
||||
target: function(trigger) {
|
||||
return trigger.previousSibling;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
51
docs/_javascript/index.js
Normal file
51
docs/_javascript/index.js
Normal file
@@ -0,0 +1,51 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
const $grid = document.getElementById('grid');
|
||||
const $columns = Array.prototype.slice.call(document.querySelectorAll('#grid > .column'), 0);
|
||||
console.log('$columns', $columns);
|
||||
const $markup = document.querySelector('#markup code');
|
||||
const $message = document.getElementById('message');
|
||||
const $add = document.getElementById('add');
|
||||
const $remove = document.getElementById('remove');
|
||||
let showing = 5;
|
||||
|
||||
function showColumns() {
|
||||
if (showing === 13) {
|
||||
$message.style.display = 'block';
|
||||
} else {
|
||||
$message.style.display = 'none';
|
||||
}
|
||||
|
||||
showing = Math.min(Math.max(parseInt(showing), 2), 12);
|
||||
|
||||
$columns.forEach($el => {
|
||||
$el.style.display = 'none';
|
||||
});
|
||||
$columns.slice(0, showing).forEach($el => {
|
||||
$el.style.display = 'block';
|
||||
});
|
||||
|
||||
$markup.innerHTML = '<span class="nt"><div</span> <span class="na">class=</span><span class="s">"columns"</span><span class="nt">></span>';
|
||||
$markup.insertAdjacentHTML('beforeend', '\n');
|
||||
|
||||
for(let i = 0; i < showing; i++) {
|
||||
$markup.insertAdjacentHTML('beforeend', ' <span class="nt"><div</span> <span class="na">class=</span><span class="s">"column"</span><span class="nt">></span>');
|
||||
$markup.insertAdjacentHTML('beforeend', i + 1);
|
||||
$markup.insertAdjacentHTML('beforeend', '<span class="nt"></div></span>');
|
||||
$markup.insertAdjacentHTML('beforeend', '\n');
|
||||
}
|
||||
|
||||
$markup.insertAdjacentHTML('beforeend', '<span class="nt"></div></span>');
|
||||
}
|
||||
|
||||
$add.addEventListener('click', () => {
|
||||
showing++;
|
||||
showColumns();
|
||||
});
|
||||
|
||||
$remove.addEventListener('click', () => {
|
||||
showing--;
|
||||
showColumns();
|
||||
});
|
||||
|
||||
});
|
||||
56
docs/_javascript/main.js
Normal file
56
docs/_javascript/main.js
Normal file
@@ -0,0 +1,56 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Navbar burger menu
|
||||
|
||||
const $navBurger = document.getElementById('navBurger');
|
||||
const $navMenu = document.getElementById('navMenu');
|
||||
|
||||
if ($navBurger) {
|
||||
$navBurger.addEventListener('click', () => {
|
||||
$navBurger.classList.toggle('is-active');
|
||||
$navMenu.classList.toggle('is-active');
|
||||
});
|
||||
}
|
||||
|
||||
// Modals
|
||||
|
||||
const $html = document.documentElement;
|
||||
const $modals = Array.prototype.slice.call(document.querySelectorAll('.modal'), 0);
|
||||
const $modalButtons = Array.prototype.slice.call(document.querySelectorAll('.modal-button'), 0);
|
||||
const $modalCloses = Array.prototype.slice.call(document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button'), 0);
|
||||
|
||||
if ($modalButtons.length > 0) {
|
||||
$modalButtons.forEach($el => {
|
||||
$el.addEventListener('click', () => {
|
||||
const target = $el.dataset.target;
|
||||
console.log('target', target);
|
||||
const $target = document.getElementById(target);
|
||||
$html.classList.add('is-clipped');
|
||||
$target.classList.add('is-active');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($modalCloses.length > 0) {
|
||||
$modalCloses.forEach($el => {
|
||||
$el.addEventListener('click', () => {
|
||||
$html.classList.remove('is-clipped');
|
||||
closeModals();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.keyCode === 27) {
|
||||
$html.classList.remove('is-clipped');
|
||||
closeModals();
|
||||
}
|
||||
});
|
||||
|
||||
function closeModals() {
|
||||
$modals.forEach($el => {
|
||||
$el.classList.remove('is-active');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user