1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Remember view mode in cookie

This commit is contained in:
Daniel Pan
2016-02-22 17:16:40 +08:00
parent 978eb3973e
commit 5873f1af95
3 changed files with 156 additions and 2 deletions

View File

@@ -7,13 +7,14 @@ define([
'backbone',
'common',
'file-tree',
'js.cookie',
'app/collections/dirents',
'app/views/dirent',
'app/views/dirent-grid',
'app/views/fileupload',
'app/views/share'
], function($, progressbar, magnificPopup, simplemodal, _, Backbone, Common,
FileTree, DirentCollection, DirentView, DirentGridView, FileUploadView, ShareView) {
FileTree, Cookies, DirentCollection, DirentView, DirentGridView, FileUploadView, ShareView) {
'use strict';
var DirView = Backbone.View.extend({
@@ -37,7 +38,11 @@ define([
// For compatible with css, we use .repo-op instead of .dir-op
this.$dir_op_bar = this.$('.repo-op');
this.view_mode = 'list';
var view_mode = Cookies.get('view_mode');
if (view_mode == 'grid') {
this.view_mode = 'grid';
} else
this.view_mode = 'list';
this.contextOptions = {};
this.dir = new DirentCollection();
@@ -525,6 +530,7 @@ define([
return false;
} else {
this.view_mode = 'grid';
Cookies.set('view_mode', 'grid');
this.renderDir();
return false;
}
@@ -535,6 +541,7 @@ define([
return false;
} else {
this.view_mode = 'list';
Cookies.set('view_mode', 'list');
this.renderDir();
return false;
}