Skip to content

Commit

Permalink
Make sidebar sticky on account page
Browse files Browse the repository at this point in the history
Refs #47
  • Loading branch information
hnrch02 committed Jan 1, 2015
1 parent 1401e08 commit cf93205
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
4 changes: 4 additions & 0 deletions assets/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ body {
&.is-right {
right: 0;
}
}

.sticky-sidebar > .list-group {
margin-bottom: 0;
}
4 changes: 4 additions & 0 deletions assets/css/ui/panel-list.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.panel-list {
&:extend(.list-unstyled all);

&:last-child {
margin-bottom: 0;
}
}

.panel-list-item {
Expand Down
4 changes: 4 additions & 0 deletions assets/js/lib/markdownEditor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
!function($) {

var $win = $(window)

var MarkdownEditor = function(element) {
var $el = this.$element = $(element)
this.$textarea = $el.find('.markdown-editor-textarea')
Expand Down Expand Up @@ -30,6 +32,8 @@
}

MarkdownEditor.prototype.initPreview = function() {
$win.trigger('resize')

this.$preview.html('Vorschau wird geladen...')

this.jqXHR = $.ajax('/api/markdown', {
Expand Down
28 changes: 28 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,34 @@
.on('mousedown', '.js-copy-field', function(e) { e.preventDefault() })
}($);

!function($) {
var $win = $(window)
var $wrap = $('#content-wrapper')

$win.on('scroll resize', function() {
var scrollTop = $win.scrollTop()
var wrapHeight = $wrap.height()

$('.js-sticky-sidebar').each(function() {
var $this = $(this)
var height = $this.outerHeight()

if(height >= wrapHeight) return $this.css('position', 'static')

if(height + scrollTop > wrapHeight)
$this.css({
position: 'absolute',
top: wrapHeight - height
})
else
$this.css({
position: 'fixed',
top: ''
})
})
}).trigger('scroll')
}($);

!function($) {
$('.js-tooltip').tooltip()
$('.js-autosize').expanding()
Expand Down
6 changes: 4 additions & 2 deletions views/account/_nav.jade
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
+profileCard(user)
+nav(accountNav)
.col-md-3
.sticky-sidebar.js-sticky-sidebar
+profileCard(user)
+nav(accountNav)
3 changes: 1 addition & 2 deletions views/account/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ extends ../layout
block content

.row
.col-md-3
include _nav
include _nav

.col-md-9

Expand Down
3 changes: 2 additions & 1 deletion views/account/profile.jade
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ block content
else
.profile.row
.col-md-3
+profileCard(profile)
.sticky-sidebar.js-sticky-sidebar
+profileCard(profile)

.col-md-9
include ../partials/flash
Expand Down
3 changes: 1 addition & 2 deletions views/account/security.jade
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ extends ../layout
block content

.row
.col-md-3
include _nav
include _nav

.col-md-9

Expand Down

0 comments on commit cf93205

Please sign in to comment.