bulma/docs/lib/bulma.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-07-01 17:30:39 +00:00
'use strict';
jQuery(document).ready(function ($) {
var $toggle = $('#nav-toggle');
var $menu = $('#nav-menu');
2017-07-01 17:30:39 +00:00
$toggle.click(function () {
$(this).toggleClass('is-active');
$menu.toggleClass('is-active');
});
2017-07-01 17:30:39 +00:00
$('.modal-button').click(function () {
var target = $(this).data('target');
$('html').addClass('is-clipped');
$(target).addClass('is-active');
});
2017-07-01 17:30:39 +00:00
$('.modal-background, .modal-close').click(function () {
$('html').removeClass('is-clipped');
$(this).parent().removeClass('is-active');
});
2017-07-01 17:30:39 +00:00
$('.modal-card-head .delete, .modal-card-foot .button').click(function () {
$('html').removeClass('is-clipped');
$('#modal-ter').removeClass('is-active');
});
2017-07-01 17:30:39 +00:00
$(document).on('keyup', function (e) {
2017-03-14 22:43:36 +00:00
if (e.keyCode == 27) {
$('html').removeClass('is-clipped');
$('.modal').removeClass('is-active');
}
});
var $highlights = $('.highlight');
2017-07-01 17:30:39 +00:00
$highlights.each(function () {
var $el = $(this);
2017-08-14 11:58:21 +00:00
var copy = '<button class="bd-copy">Copy</button>';
var expand = '<button class="bd-expand">Expand</button>';
$el.append(copy);
if ($el.find('pre code').innerHeight() > 600) {
$el.append(expand);
}
});
2017-08-14 11:58:21 +00:00
var $highlightButtons = $('.highlight .bd-copy, .highlight .bd-expand');
2017-07-01 17:30:39 +00:00
$highlightButtons.hover(function () {
$(this).parent().css('box-shadow', '0 0 0 1px #ed6c63');
2017-07-01 17:30:39 +00:00
}, function () {
$(this).parent().css('box-shadow', 'none');
});
2017-08-14 11:58:21 +00:00
$('.highlight .bd-expand').click(function () {
$(this).parent().children('pre').css('max-height', 'none');
});
2017-08-14 11:58:21 +00:00
new Clipboard('.bd-copy', {
2017-07-01 17:30:39 +00:00
target: function target(trigger) {
return trigger.previousSibling;
}
});
2017-07-01 17:30:39 +00:00
});