Skip to content

Commit 1c825c8

Browse files
fixed up the auto-open epubs to open in the library view
1 parent 8d8d445 commit 1c825c8

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

background/hijack-ebooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
chrome.extension.sendRequest({storage: "hijack_epub_urls"}, function(response) {
22
if (response && response.hijack_epub_urls) {
33
$("a[href$='.epub']").each(function() {
4-
this.href = chrome.extension.getURL("/views/extractbook.html") + "#" + this.href;
4+
this.href = chrome.extension.getURL("/views/library.html") + "#/unpack/" + this.href;
55
this.target = "_blank";
66
});
77
}

scripts/library.js

+24-10
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,28 @@ $(function() {
265265

266266

267267

268+
});
269+
270+
window.LibraryRouter = Backbone.Router.extend({
271+
272+
initialize: function(options) {
273+
this.picker = options.picker;
274+
},
275+
276+
routes: {
277+
"options": "showOptions",
278+
"/unpack/*url": "beginExtraction"
279+
},
280+
281+
showOptions: function() {
282+
$('#readium-options-modal').modal('show');
283+
},
284+
285+
beginExtraction: function(url) {
286+
var extractor = new Readium.Models.ZipBookExtractor({url: url, src_filename: url});
287+
this.picker.beginExtraction(extractor);
288+
}
289+
268290
});
269291

270292
window.options = Readium.Models.ReadiumOptions.getInstance();
@@ -273,6 +295,8 @@ $(function() {
273295
window.Library = new LibraryItems();
274296
window.lib_view = new LibraryItemsView({collection: window.Library});
275297
window.fp_view = new FilePickerView();
298+
window.router = new LibraryRouter({picker: window.fp_view});
299+
Backbone.history.start({pushState: false, root: "views/library.html"})
276300

277301
})(jQuery);
278302

@@ -288,15 +312,5 @@ $(function() {
288312
$("#row-view-btn").click(function(e) {
289313
$('#library-items-container').addClass("row-view").removeClass("block-view")
290314
});
291-
292-
// TODO: use a Backbone router for this
293-
if(window.location.hash === "#options") {
294-
$('#readium-options-modal').modal('show')
295-
}
296-
/*
297-
$("#options-btn").click(function(e) {
298-
window.location = "/views/options.html";
299-
});
300-
*/
301315

302316
});

0 commit comments

Comments
 (0)