Commit a29eaffa by Bence Dányi

webui: toggle toplist

fixes #37
parent 717a6607
...@@ -113,7 +113,27 @@ var cloud = (function(cloud) { ...@@ -113,7 +113,27 @@ var cloud = (function(cloud) {
}) })
}); });
self.loadTopList = cloud.throttle(function() { var showToplist = ko.observable(false);
self.toggleToplist = cloud.throttle(function() {
if (!showToplist()) {
showToplist(true);
loadToplist();
} else {
showToplist(false);
self.currentPath('/');
loadFolder('/');
}
});
self.getToplistText = ko.computed(function() {
if (!showToplist()) {
return gettext('Toplist');
} else {
return gettext('Back to the root folder')
}
})
function loadToplist() {
self.currentPath('/'); self.currentPath('/');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
...@@ -136,7 +156,7 @@ var cloud = (function(cloud) { ...@@ -136,7 +156,7 @@ var cloud = (function(cloud) {
}); });
} }
}) })
}); }
/** /**
* After loadFolder completes, this function updates the UI * After loadFolder completes, this function updates the UI
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
</li> </li>
<li class="entry small-row"> <li class="entry small-row">
<div class="summary" id="new-folder"> <div class="summary" id="new-folder">
<div class="name toplist" data-bind="click: loadTopList">{% trans "Toplist" %}</div> <div class="name toplist" data-bind="click: toggleToplist, text: getToplistText"></div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</li> </li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment