mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Move left bar collapsing to server-side preference.
This commit is contained in:
@@ -3495,3 +3495,13 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
giftmessage=None,
|
||||
comment=comment._fullname,
|
||||
))
|
||||
|
||||
@json_validate(
|
||||
VUser(),
|
||||
VModhash(),
|
||||
collapsed=VBoolean('collapsed'),
|
||||
)
|
||||
def POST_set_left_bar_collapsed(self, responder, collapsed):
|
||||
c.user.pref_collapse_left_bar = collapsed
|
||||
c.user._commit()
|
||||
|
||||
|
||||
@@ -616,6 +616,8 @@ class Reddit(Templated):
|
||||
|
||||
if self.show_chooser:
|
||||
classes.add('with-listing-chooser')
|
||||
if c.user.pref_collapse_left_bar:
|
||||
classes.add('listing-chooser-collapsed')
|
||||
|
||||
if self.extra_page_classes:
|
||||
classes.update(self.extra_page_classes)
|
||||
|
||||
@@ -91,6 +91,7 @@ class Account(Thing):
|
||||
pref_show_sponsorships = True,
|
||||
pref_highlight_new_comments = True,
|
||||
pref_monitor_mentions=True,
|
||||
pref_collapse_left_bar=False,
|
||||
mobile_compress = False,
|
||||
mobile_thumbnail = True,
|
||||
trusted_sponsor = False,
|
||||
|
||||
@@ -609,6 +609,12 @@ r.multi.ListingChooser = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.$el.addClass('initialized')
|
||||
|
||||
// transition collapsed state to server pref
|
||||
if (store.get('ui.collapse.listingchooser') == true) {
|
||||
this.toggleCollapsed(true)
|
||||
store.remove('ui.collapse.listingchooser')
|
||||
}
|
||||
|
||||
// HACK: fudge page heights for long lists of multis / short pages
|
||||
var thisHeight = this.$('.contents').height(),
|
||||
bodyHeight = $('body').height()
|
||||
@@ -629,8 +635,14 @@ r.multi.ListingChooser = Backbone.View.extend({
|
||||
}
|
||||
},
|
||||
|
||||
toggleCollapsed: function() {
|
||||
$('body').toggleClass('listing-chooser-collapsed')
|
||||
store.set('ui.collapse.listingchooser', $('body').is('.listing-chooser-collapsed'))
|
||||
toggleCollapsed: function(value) {
|
||||
$('body').toggleClass('listing-chooser-collapsed', value)
|
||||
Backbone.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/set_left_bar_collapsed.json',
|
||||
data: {
|
||||
'collapsed': $('body').is('.listing-chooser-collapsed')
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -91,10 +91,3 @@ r.ui.Summarize.prototype = {
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
r.ui.collapseListingChooser = function() {
|
||||
if (store.get('ui.collapse.listingchooser') == true) {
|
||||
$('body').addClass('listing-chooser-collapsed')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
%endfor
|
||||
</%def>
|
||||
|
||||
<script>r.ui.collapseListingChooser()</script>
|
||||
<div class="listing-chooser">
|
||||
<div class="grippy"></div>
|
||||
<div class="contents">
|
||||
|
||||
Reference in New Issue
Block a user