mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Views -> Controllers, Moved previousLocationCfi logic to Reader, Bookmarks in Reader
This commit is contained in:
parent
3bfadb2abc
commit
e4be17a428
24 changed files with 1363 additions and 1003 deletions
50
reader/controllers/sidebar_controller.js
Normal file
50
reader/controllers/sidebar_controller.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
EPUBJS.reader.SidebarController = function(book) {
|
||||
var reader = this;
|
||||
|
||||
var $sidebar = $("#sidebar"),
|
||||
$panels = $("#panels");
|
||||
|
||||
var activePanel = "Toc";
|
||||
|
||||
var changePanelTo = function(viewName) {
|
||||
var controllerName = viewName + "Controller";
|
||||
|
||||
if(activePanel == viewName || typeof reader[controllerName] === 'undefined' ) return;
|
||||
reader[activePanel+ "Controller"].hide();
|
||||
reader[controllerName].show();
|
||||
activePanel = viewName;
|
||||
|
||||
$panels.find('.active').removeClass("active");
|
||||
$panels.find("#show-" + viewName ).addClass("active");
|
||||
};
|
||||
|
||||
var getActivePanel = function() {
|
||||
return activePanel;
|
||||
};
|
||||
|
||||
var show = function() {
|
||||
reader.sidebarOpen = true;
|
||||
reader.ReaderController.slideOut();
|
||||
$sidebar.addClass("open");
|
||||
}
|
||||
|
||||
var hide = function() {
|
||||
reader.sidebarOpen = false;
|
||||
reader.ReaderController.slideIn();
|
||||
$sidebar.removeClass("open");
|
||||
}
|
||||
|
||||
$panels.find(".show_view").on("click", function(event) {
|
||||
var view = $(this).data("view");
|
||||
|
||||
changePanelTo(view);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
return {
|
||||
'show' : show,
|
||||
'hide' : hide,
|
||||
'getActivePanel' : getActivePanel,
|
||||
'changePanelTo' : changePanelTo
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue