1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-12-01 05:24:11 +01:00

Add possibility to remember the view and the sidebar status

This commit is contained in:
Brice Maron 2012-07-03 14:14:30 +02:00
parent abf07d70d1
commit 0474b10893
3 changed files with 50 additions and 5 deletions

29
ajax/changescreen.php Normal file
View File

@ -0,0 +1,29 @@
<?php
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks');
if(isset($_POST['view'])) {
$view = $_POST['view'];
switch($view){
case 'list':
case 'image';
break;
default:
OCP\JSON::error(array('message'=>'unexspected parameter: ' . $view));
exit;
}
OCP\Config::setUserValue(OCP\USER::getUser(), 'bookmarks', 'currentview', $view);
OCP\JSON::success();
}elseif(isset($_POST['sidebar'])) {
$view = $_POST['sidebar'];
switch($view){
case 'true':
case 'false';
break;
default:
OCP\JSON::error(array('message'=>'unexspected parameter: ' . $view));
exit;
}
OCP\Config::setUserValue(OCP\USER::getUser(), 'bookmarks', 'sidebar', $view);
OCP\JSON::success();
}

View File

@ -6,9 +6,8 @@ var bookmarks_sorting = 'bookmarks_sorting_recent';
var bookmark_view = 'image';
$(document).ready(function() {
switchView();
$('.centercontent').click(toggleSideBar);
$('#view_type input').click(switchView);
$('.centercontent').click(clickSideBar);
$('#view_type input').click(clickSwitchView);
$('#bookmark_add_submit').click(addBookmark);
$(window).resize(function () {
fillWindow($('.bookmarks_list'));
@ -20,9 +19,19 @@ $(document).ready(function() {
availableTags: fullTags,
onTagRemoved: filterTagsChanged
}).tagit('option', 'onTagAdded', filterTagsChanged);
getBookmarks();
if(init_sidebar == 'true')
toggleSideBar();
bookmark_view = init_view;
switchView();
});
function clickSideBar() {
$.post(OC.filePath('bookmarks', 'ajax', 'changescreen.php'), {sidebar: $('#leftcontent').is(':visible')});
toggleSideBar();
}
function toggleSideBar(){
if($('#leftcontent:visible')) {
$('#rightcontent').css('left','32.5em');
@ -38,8 +47,13 @@ function toggleSideBar(){
}
$(window).trigger('resize');
});
}
function clickSwitchView(){
$.post(OC.filePath('bookmarks', 'ajax', 'changescreen.php'), {view:bookmark_view});
switchView();
}
function switchView(){
if(bookmark_view == 'list') { //Then switch to img
$('.bookmarks_list').addClass('bm_view_img');

View File

@ -60,6 +60,8 @@
</div>
<script>
var fullTags = <?php echo $_['tags'];?>;
var init_view = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'bookmarks', 'currentview', 'list');?>';
var init_sidebar = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'bookmarks', 'sidebar', 'true');?>';
</script>
<div id="edit_dialog" style="display:none;">
<?php include 'addBm.php';?>