remember menu state
This commit is contained in:
parent
7a9341a9ec
commit
c3cfcab967
@ -5,16 +5,6 @@
|
||||
$this->create('radio_index', '/')
|
||||
->actionInclude('radio/index.php');
|
||||
|
||||
/** return [
|
||||
'resources' => [
|
||||
'station' => ['url' => '/stations'],
|
||||
],
|
||||
'routes' => [
|
||||
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
||||
]
|
||||
]; **/
|
||||
|
||||
|
||||
return [
|
||||
'resources' => [
|
||||
'station' => ['url' => '/stations'],
|
||||
@ -22,6 +12,8 @@ return [
|
||||
],
|
||||
'routes' => [
|
||||
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
||||
['name' => 'settings#getMenuState', 'url' => '/getMenuState', 'verb' => 'GET'],
|
||||
['name' => 'settings#saveMenuState', 'url' => '/saveMenuState', 'verb' => 'POST'],
|
||||
['name' => 'station_api#preflighted_cors', 'url' => '/api/0.1/{path}',
|
||||
'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']]
|
||||
]
|
||||
|
34
js/main.js
34
js/main.js
@ -305,8 +305,37 @@ $(function(){
|
||||
});
|
||||
};
|
||||
|
||||
function load_menu_state() {
|
||||
var menu_state = 0;
|
||||
var baseUrl = OC.generateUrl('/apps/radio/getMenuState');
|
||||
$.get(baseUrl, function ( data ) {
|
||||
if ("menu_state" in data) {
|
||||
menu_state = data["menu_state"];
|
||||
}
|
||||
switch_menu(menu_state);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function save_menu_state(menu_state) {
|
||||
var baseUrl = OC.generateUrl('/apps/radio/saveMenuState');
|
||||
var settings = {
|
||||
"menu_state": menu_state
|
||||
};
|
||||
$.ajax({
|
||||
url: baseUrl,
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(settings)
|
||||
}).done(function(data){
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function switch_menu(type) {
|
||||
|
||||
var state = Number(type);
|
||||
|
||||
$('#filestable').hide();
|
||||
$('#emptycontent').addClass('hidden');
|
||||
$('.nofilterresults').addClass('hidden');
|
||||
@ -316,7 +345,8 @@ $(function(){
|
||||
searchTimeout = setTimeout(function(){
|
||||
$('#app-navigation').find('li').removeClass("active");
|
||||
$("tbody > tr").remove();
|
||||
switch (type) {
|
||||
save_menu_state(state)
|
||||
switch (state) {
|
||||
case 0:
|
||||
$('li.nav-files').addClass('active');
|
||||
radio_query(1);
|
||||
@ -357,5 +387,5 @@ $(function(){
|
||||
});
|
||||
|
||||
// On app start, load top list
|
||||
switch_menu(0);
|
||||
load_menu_state();
|
||||
});
|
||||
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
style('radio', 'main');
|
||||
script('radio', 'main');
|
||||
OC_Util::addScript('search', 'search', true);
|
||||
OC_Util::addScript('search', 'searchprovider');
|
||||
?>
|
||||
|
||||
<div id="content" class="app-files" role="main">
|
||||
|
Loading…
Reference in New Issue
Block a user