bulma.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use strict';
  2. jQuery(document).ready(function ($) {
  3. var $toggle = $('#nav-toggle');
  4. var $menu = $('#nav-menu');
  5. $toggle.click(function () {
  6. $(this).toggleClass('is-active');
  7. $menu.toggleClass('is-active');
  8. });
  9. $('.modal-button').click(function () {
  10. var target = $(this).data('target');
  11. $('html').addClass('is-clipped');
  12. $(target).addClass('is-active');
  13. });
  14. $('.modal-background, .modal-close').click(function () {
  15. $('html').removeClass('is-clipped');
  16. $(this).parent().removeClass('is-active');
  17. });
  18. $('.modal-card-head .delete, .modal-card-foot .button').click(function () {
  19. $('html').removeClass('is-clipped');
  20. $('#modal-ter').removeClass('is-active');
  21. });
  22. $(document).on('keyup', function (e) {
  23. if (e.keyCode == 27) {
  24. $('html').removeClass('is-clipped');
  25. $('.modal').removeClass('is-active');
  26. }
  27. });
  28. var $highlights = $('.highlight');
  29. $highlights.each(function () {
  30. var $el = $(this);
  31. var copy = '<button class="bd-copy">Copy</button>';
  32. var expand = '<button class="bd-expand">Expand</button>';
  33. $el.append(copy);
  34. if ($el.find('pre code').innerHeight() > 600) {
  35. $el.append(expand);
  36. }
  37. });
  38. var $highlightButtons = $('.highlight .bd-copy, .highlight .bd-expand');
  39. $highlightButtons.hover(function () {
  40. $(this).parent().css('box-shadow', '0 0 0 1px #ed6c63');
  41. }, function () {
  42. $(this).parent().css('box-shadow', 'none');
  43. });
  44. $('.highlight .bd-expand').click(function () {
  45. $(this).parent().children('pre').css('max-height', 'none');
  46. });
  47. new Clipboard('.bd-copy', {
  48. target: function target(trigger) {
  49. return trigger.previousSibling;
  50. }
  51. });
  52. });