diff --git a/_config.yml b/_config.yml index 620ebc3e35..c453883519 100644 --- a/_config.yml +++ b/_config.yml @@ -204,7 +204,7 @@ toc: #creative_commons: sidebar: - # Sidebar Position, available value: left | right (only for Pisces | Gemini). + # Sidebar Position, available value: left | right . position: left #position: right diff --git a/source/css/_schemes/Mist/index.styl b/source/css/_schemes/Mist/index.styl index bb2f4c50a4..62f2679f8a 100644 --- a/source/css/_schemes/Mist/index.styl +++ b/source/css/_schemes/Mist/index.styl @@ -9,6 +9,7 @@ @import "_menu"; @import "_search.styl"; @import "_posts-expanded"; +@import "sidebar/_sidebar"; @import "sidebar/sidebar-blogroll"; // Import _posts if want to justify text-align on mobile. // @import "../Pisces/_posts"; diff --git a/source/css/_schemes/Mist/sidebar/_sidebar.styl b/source/css/_schemes/Mist/sidebar/_sidebar.styl new file mode 100644 index 0000000000..279fb0ebef --- /dev/null +++ b/source/css/_schemes/Mist/sidebar/_sidebar.styl @@ -0,0 +1,10 @@ +if (hexo-config('sidebar.position') == 'left' ) { + .sidebar { + right: auto; + left: 0; + } + .sidebar-toggle { + right: auto; + left: 50px; + } +} diff --git a/source/css/_schemes/Muse/index.styl b/source/css/_schemes/Muse/index.styl index 2921064976..29612a6f04 100644 --- a/source/css/_schemes/Muse/index.styl +++ b/source/css/_schemes/Muse/index.styl @@ -2,6 +2,7 @@ @import "_logo.styl"; @import "_menu.styl"; @import "_search.styl"; +@import "sidebar/_sidebar"; @import "sidebar/sidebar-blogroll"; // Import _posts if want to justify text-align on mobile. // @import "../Pisces/_posts"; diff --git a/source/css/_schemes/Muse/sidebar/_sidebar.styl b/source/css/_schemes/Muse/sidebar/_sidebar.styl new file mode 100644 index 0000000000..279fb0ebef --- /dev/null +++ b/source/css/_schemes/Muse/sidebar/_sidebar.styl @@ -0,0 +1,10 @@ +if (hexo-config('sidebar.position') == 'left' ) { + .sidebar { + right: auto; + left: 0; + } + .sidebar-toggle { + right: auto; + left: 50px; + } +} diff --git a/source/js/src/motion.js b/source/js/src/motion.js index c6b72257f9..6e4e1bc459 100644 --- a/source/js/src/motion.js +++ b/source/js/src/motion.js @@ -51,27 +51,55 @@ $(document).ready(function () { this.el.velocity('stop').velocity(this.status[status]); }; - var sidebarToggleLine1st = new SidebarToggleLine({ - el: '.sidebar-toggle-line-first', - status: { - arrow: {width: '50%', rotateZ: '-45deg', top: '2px'}, - close: {width: '100%', rotateZ: '-45deg', top: '5px'} - } - }); - var sidebarToggleLine2nd = new SidebarToggleLine({ - el: '.sidebar-toggle-line-middle', - status: { - arrow: {width: '90%'}, - close: {opacity: 0} - } - }); - var sidebarToggleLine3rd = new SidebarToggleLine({ - el: '.sidebar-toggle-line-last', - status: { - arrow: {width: '50%', rotateZ: '45deg', top: '-2px'}, - close: {width: '100%', rotateZ: '45deg', top: '-5px'} - } - }); + var sidebarToggleLine1st; + var sidebarToggleLine2nd; + var sidebarToggleLine3rd; + var isRight = ((NexT.utils.isMist() || NexT.utils.isMuse()) && (CONFIG.sidebar.position != 'left')); + if (isRight){ + sidebarToggleLine1st = new SidebarToggleLine({ + el: '.sidebar-toggle-line-first', + status: { + arrow: {width: '50%', rotateZ: '-45deg', top: '2px'}, + close: {width: '100%', rotateZ: '-45deg', top: '5px'} + } + }); + sidebarToggleLine2nd = new SidebarToggleLine({ + el: '.sidebar-toggle-line-middle', + status: { + arrow: {width: '90%'}, + close: {opacity: 0} + } + }); + sidebarToggleLine3rd = new SidebarToggleLine({ + el: '.sidebar-toggle-line-last', + status: { + arrow: {width: '50%', rotateZ: '45deg', top: '-2px'}, + close: {width: '100%', rotateZ: '45deg', top: '-5px'} + } + }); + } else { + sidebarToggleLine1st = new SidebarToggleLine({ + el: '.sidebar-toggle-line-first', + status: { + arrow: {width: '50%', rotateZ: '45deg', top: '2px', left: '50%'}, + close: {width: '100%', rotateZ: '-45deg', top: '5px', left: '0px'} + } + }); + sidebarToggleLine2nd = new SidebarToggleLine({ + el: '.sidebar-toggle-line-middle', + status: { + arrow: {width: '90%', left: '2px'}, + close: {opacity: 0, left: '0px'} + } + }); + sidebarToggleLine3rd = new SidebarToggleLine({ + el: '.sidebar-toggle-line-last', + status: { + arrow: {width: '50%', rotateZ: '-45deg', top: '-2px', left: '50%'}, + close: {width: '100%', rotateZ: '45deg', top: '-5px', left: '0px'} + } + }); + } sidebarToggleLines.push(sidebarToggleLine1st); sidebarToggleLines.push(sidebarToggleLine2nd); @@ -98,7 +126,7 @@ $(document).ready(function () { $(document) .on('sidebar.isShowing', function () { NexT.utils.isDesktop() && $('body').velocity('stop').velocity( - {paddingRight: SIDEBAR_WIDTH}, + isRight ? {paddingRight: SIDEBAR_WIDTH} : {paddingLeft: SIDEBAR_WIDTH}, SIDEBAR_DISPLAY_DURATION ); }) @@ -164,7 +192,7 @@ $(document).ready(function () { this.sidebarEl.trigger('sidebar.isShowing'); }, hideSidebar: function () { - NexT.utils.isDesktop() && $('body').velocity('stop').velocity({paddingRight: 0}); + NexT.utils.isDesktop() && $('body').velocity('stop').velocity(isRight?{paddingRight: 0}:{paddingLeft: 0}); this.sidebarEl.find('.motion-element').velocity('stop').css('display', 'none'); this.sidebarEl.velocity('stop').velocity({width: 0}, {display: 'none'}); diff --git a/source/js/src/utils.js b/source/js/src/utils.js index 1188bf5392..0008990aaa 100644 --- a/source/js/src/utils.js +++ b/source/js/src/utils.js @@ -253,6 +253,10 @@ NexT.utils = NexT.$u = { $('.sidebar-toggle').trigger('click'); }, + isMuse: function () { + return CONFIG.scheme === 'Muse'; + }, + isMist: function () { return CONFIG.scheme === 'Mist'; },