|
22 | 22 | $(window).scroll(function() { |
23 | 23 | var scrollerToTop = $('.backTop'); |
24 | 24 | var scrollerTOC = $('.widget-toc'); |
25 | | - document.documentElement.scrollTop + document.body.scrollTop > 200 ? scrollerToTop.fadeIn() : scrollerToTop.fadeOut(); |
26 | | - document.documentElement.scrollTop + document.body.scrollTop > 250 ? scrollerTOC.addClass("widget-toc-fixed") : scrollerTOC.removeClass("widget-toc-fixed"); |
| 25 | + document.documentElement.scrollTop + document.body.scrollTop > 200 ? |
| 26 | + scrollerToTop.fadeIn() : |
| 27 | + scrollerToTop.fadeOut(); |
| 28 | + document.documentElement.scrollTop + document.body.scrollTop > 250 ? |
| 29 | + scrollerTOC.addClass("widget-toc-fixed") : |
| 30 | + scrollerTOC.removeClass("widget-toc-fixed"); |
27 | 31 | }); |
28 | 32 |
|
29 | 33 | // #backTop Button Event |
|
46 | 50 | }); |
47 | 51 | }); |
48 | 52 |
|
| 53 | + var toc = $('.toc'); |
49 | 54 | // toc config |
50 | | - $("#toc").toc({ |
| 55 | + toc.toc({ |
51 | 56 | content: ".post-content", |
52 | 57 | headings: "h2,h3,h4,h5" |
53 | 58 | }); |
54 | 59 |
|
55 | | - if ($("#toc").children().length == 0) $(".widget-toc").hide(); |
| 60 | + if (toc.children().length == 0) $(".widget-toc").hide(); |
| 61 | + |
| 62 | + var tocHieght = toc.height(); |
| 63 | + var tocFixedHeight = $(window).height() - 192; |
| 64 | + tocHieght > tocFixedHeight ? |
| 65 | + toc.css('height', tocFixedHeight) : |
| 66 | + toc.css('height', tocHieght) |
| 67 | + |
| 68 | + $(window).resize(function() { |
| 69 | + var tocFixedHeight = $(this).height() - 192; |
| 70 | + tocHieght > tocFixedHeight ? |
| 71 | + toc.css('height', tocFixedHeight) : |
| 72 | + toc.css('height', tocHieght) |
| 73 | + }) |
56 | 74 |
|
57 | 75 | // toc animate effect |
58 | 76 | // bind click event to all internal page anchors |
|
66 | 84 | $(target).velocity('scroll', { |
67 | 85 | duration: 500, |
68 | 86 | easing: 'ease-in-out' |
69 | | - //easing: 'spring' |
| 87 | + //easing: 'spring' |
70 | 88 | }); |
71 | 89 | }); |
72 | 90 |
|
|
84 | 102 | locked: false |
85 | 103 | } |
86 | 104 | }, |
87 | | - beforeShow : function() { |
| 105 | + beforeShow: function() { |
88 | 106 | var alt = this.element.find('img').attr('alt'); |
89 | 107 |
|
90 | 108 | this.inner.find('img').attr('alt', alt); |
|
99 | 117 | $.fn.arctic_scroll = function(options) { |
100 | 118 |
|
101 | 119 | var defaults = { |
102 | | - elem: $(this), |
103 | | - speed: 500 |
104 | | - }, |
| 120 | + elem: $(this), |
| 121 | + speed: 500 |
| 122 | + }, |
105 | 123 |
|
106 | | - allOptions = $.extend(defaults, options); |
| 124 | + allOptions = $.extend(defaults, options); |
107 | 125 |
|
108 | 126 | allOptions.elem.click(function(event) { |
109 | 127 | event.preventDefault(); |
|
0 commit comments