bulma.js 1.6 KB

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