1- /**
2- * 页面ready方法
3- */
41$ ( document ) . ready ( function ( ) {
5-
62 categoryAndTagDisplay ( ) ;
73 generateContent ( ) ;
84 backToTop ( ) ;
95} ) ;
106
11- /**
12- * load方法,页面的加载完成后触发
13- * {fixFooterInit();} 固定Footer栏
14- */
15- /*$(window).load(function() {
16- fixFooterInit();
17- });*/
18-
19-
20- /**
21- * 固定底栏的初始化方法
22- * 在一开始载入页面时,使用fixFooter()方法固定底栏。
23- * 在浏览器窗口改变大小是,依然固定底栏
24- * @return {[type] } [description]
25- */
267function fixFooterInit ( ) {
278 var footerHeight = $ ( 'footer' ) . outerHeight ( ) ;
28- var footerMarginTop = getFooterMarginTop ( ) - 0 ; //类型转换
29- // var footerMarginTop = 80;
9+ var footerMarginTop = getFooterMarginTop ( ) - 0 ;
3010
3111 fixFooter ( footerHeight , footerMarginTop ) ; //fix footer at the beginning
3212
3313 $ ( window ) . resize ( function ( ) { //when resize window, footer can auto get the postion
3414 fixFooter ( footerHeight , footerMarginTop ) ;
3515 } ) ;
36-
37- /* $('body').click(function() {
38- fixFooter(footerHeight, footerMarginTop);
39- });*/
40-
41-
4216}
4317
44- /**
45- * 固定底栏
46- * @param {number } footerHeight 底栏高度
47- * @param {number } footerMarginTop 底栏MarginTop
48- * @return {[type] } [description]
49- */
5018function fixFooter ( footerHeight , footerMarginTop ) {
5119 var windowHeight = $ ( window ) . height ( ) ;
5220 var contentHeight = $ ( 'body>.container' ) . outerHeight ( ) + $ ( 'body>.container' ) . offset ( ) . top + footerHeight + footerMarginTop ;
53- // console.log("window---"+windowHeight);
54- // console.log("$('body>.container').outerHeight()---"+$('body>.container').outerHeight() );
55- // console.log("$('body>.container').height()---"+$('body>.container').height() );
56- // console.log("$('#main').height()--------"+$('#main').height());
57- // console.log("$('body').height()--------"+$('body').height());
58- //console.log("$('#main').html()--------"+$('#main').html());
59- // console.log("$('body>.container').offset().top----"+$('body>.container').offset().top);
60- // console.log("footerHeight---"+footerHeight);
61- // console.log("footerMarginTop---"+footerMarginTop);
6221 console . log ( contentHeight ) ;
6322 if ( contentHeight < windowHeight ) {
6423 $ ( 'footer' ) . addClass ( 'navbar-fixed-bottom' ) ;
@@ -69,10 +28,6 @@ function fixFooter(footerHeight, footerMarginTop) {
6928 $ ( 'footer' ) . show ( 400 ) ;
7029}
7130
72- /**
73- * 使用正则表达式得到底栏的MarginTop
74- * @return {string } 底栏的MarginTop
75- */
7631function getFooterMarginTop ( ) {
7732 var margintop = $ ( 'footer' ) . css ( 'marginTop' ) ;
7833 var patt = new RegExp ( "[0-9]*" ) ;
@@ -82,24 +37,22 @@ function getFooterMarginTop() {
8237}
8338
8439function categoryAndTagDisplay ( ) {
85- /*only show All*/
40+ /*
8641 $('.post-list-body>div[post-category!=All]').hide();
87- /*only show All*/
8842 $('.post-list-body>div[post-tag!=All]').hide();
89-
43+ */
9044 /*show category when click categories list*/
9145 $ ( '.sidebar-list-item.category' ) . click ( function ( ) {
9246 var category = $ ( this ) . attr ( 'category' ) ; //get category's name
93-
94- $ ( '.post-list-body>div[post-category!=\'' + category + '\']' ) . hide ( 250 ) ;
95- $ ( '.post-list-body>div[post-category=\'' + category + '\']' ) . show ( 400 ) ;
47+ $ ( '.post-list-item' ) . not ( '[cats*=\'' + category + '\']' ) . slideUp ( 200 )
48+ $ ( '.post-list-item[cats*=\'' + category + '\']' ) . slideDown ( )
9649 } ) ;
9750 /*show category when click tags list*/
9851 $ ( '.sidebar-list-item.tag' ) . click ( function ( ) {
9952 var tag = $ ( this ) . attr ( 'tag' ) ; //get tag's name
10053
101- $ ( '.post-list-body>div[post-tag! =\'' + tag + '\']' ) . hide ( 250 ) ;
102- $ ( '.post-list-body>div[post-tag =\'' + tag + '\']' ) . show ( 400 ) ;
54+ $ ( '.post-list-item' ) . not ( '[tags* =\'' + tag + '\']' ) . slideUp ( 200 )
55+ $ ( '.post-list-item[tags* =\'' + tag + '\']' ) . slideDown ( )
10356 } ) ;
10457}
10558
@@ -116,9 +69,7 @@ function backToTop() {
11669 } ) ;
11770}
11871
119- /**
120- * 侧边目录
121- */
72+
12273function generateContent ( ) {
12374
12475 // console.log($('#markdown-toc').html());
0 commit comments