From 76fe88ffcc86f673be031a6bb6578909f17d50d8 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Mar 2015 01:07:37 +0530 Subject: [PATCH] split ebook readers into extra repo --- oml/commands.py | 11 +- oml/server.py | 3 + static/epub.js/css/annotations.css | 8 - static/epub.js/css/main.css | 792 - static/epub.js/css/normalize.css | 505 - static/epub.js/css/popup.css | 96 - static/epub.js/epub.js | 7462 --- static/epub.js/epub.js.map | 1 - static/epub.js/epub.min.js | 7462 --- static/epub.js/epub.min.map | 1 - static/epub.js/epub_no_underscore.js | 7461 --- static/epub.js/epub_no_underscore.js.map | 23 - static/epub.js/font/fontello.eot | Bin 10204 -> 0 bytes static/epub.js/font/fontello.svg | 33 - static/epub.js/font/fontello.ttf | Bin 10036 -> 0 bytes static/epub.js/font/fontello.woff | Bin 6032 -> 0 bytes static/epub.js/hooks.js | 318 - static/epub.js/hooks.js.map | 17 - static/epub.js/hooks.min.js | 2 - static/epub.js/hooks.min.map | 1 - static/epub.js/hooks/extensions/highlight.js | 14 - static/epub.js/libs/inflate.js | 2 - static/epub.js/libs/inflate.map | 1 - static/epub.js/libs/jquery.highlight.js | 108 - static/epub.js/libs/screenfull.min.js | 7 - static/epub.js/libs/zip.min.js | 16 - static/epub.js/libs/zip.min.map | 1 - static/epub.js/plugins/hypothesis.js | 109 - static/epub.js/plugins/search.js | 125 - static/epub.js/reader.js | 1124 - static/epub.js/reader.js.map | 17 - static/epub.js/reader.min.js | 2 - static/epub.js/reader.min.map | 1 - static/pdf.js/compatibility.js | 483 - static/pdf.js/css/videopdf.css | 28 - static/pdf.js/debugger.js | 540 - static/pdf.js/embeds.js | 147 - static/pdf.js/images/annotation-check.svg | 11 - static/pdf.js/images/annotation-comment.svg | 16 - static/pdf.js/images/annotation-help.svg | 26 - static/pdf.js/images/annotation-insert.svg | 10 - static/pdf.js/images/annotation-key.svg | 11 - .../pdf.js/images/annotation-newparagraph.svg | 11 - static/pdf.js/images/annotation-note.svg | 42 - static/pdf.js/images/annotation-paragraph.svg | 16 - .../pdf.js/images/findbarButton-next-rtl.png | Bin 272 -> 0 bytes static/pdf.js/images/findbarButton-next.png | Bin 268 -> 0 bytes .../images/findbarButton-previous-rtl.png | Bin 268 -> 0 bytes .../pdf.js/images/findbarButton-previous.png | Bin 272 -> 0 bytes static/pdf.js/images/grab.cur | Bin 326 -> 0 bytes static/pdf.js/images/grabbing.cur | Bin 326 -> 0 bytes static/pdf.js/images/loading-icon.gif | Bin 2545 -> 0 bytes static/pdf.js/images/loading-small.png | Bin 3612 -> 0 bytes .../secondaryToolbarButton-firstPage.png | Bin 340 -> 0 bytes .../secondaryToolbarButton-handTool.png | Bin 250 -> 0 bytes .../secondaryToolbarButton-lastPage.png | Bin 315 -> 0 bytes .../secondaryToolbarButton-rotateCcw.png | Bin 414 -> 0 bytes .../secondaryToolbarButton-rotateCw.png | Bin 414 -> 0 bytes static/pdf.js/images/shadow.png | Bin 290 -> 0 bytes static/pdf.js/images/texture.png | Bin 2418 -> 0 bytes .../pdf.js/images/toolbarButton-bookmark.png | Bin 210 -> 0 bytes .../pdf.js/images/toolbarButton-download.png | Bin 343 -> 0 bytes .../images/toolbarButton-fullscreen.png | Bin 491 -> 0 bytes .../images/toolbarButton-menuArrows.png | Bin 200 -> 0 bytes .../pdf.js/images/toolbarButton-openFile.png | Bin 348 -> 0 bytes .../images/toolbarButton-pageDown-rtl.png | Bin 462 -> 0 bytes .../pdf.js/images/toolbarButton-pageDown.png | Bin 296 -> 0 bytes .../images/toolbarButton-pageUp-rtl.png | Bin 310 -> 0 bytes static/pdf.js/images/toolbarButton-pageUp.png | Bin 307 -> 0 bytes .../images/toolbarButton-presentationMode.png | Bin 450 -> 0 bytes static/pdf.js/images/toolbarButton-print.png | Bin 437 -> 0 bytes static/pdf.js/images/toolbarButton-search.png | Bin 411 -> 0 bytes ...olbarButton-secondaryToolbarToggle-rtl.png | Bin 583 -> 0 bytes .../toolbarButton-secondaryToolbarToggle.png | Bin 296 -> 0 bytes .../toolbarButton-sidebarToggle-rtl.png | Bin 548 -> 0 bytes .../images/toolbarButton-sidebarToggle.png | Bin 306 -> 0 bytes .../images/toolbarButton-viewOutline-rtl.png | Bin 405 -> 0 bytes .../images/toolbarButton-viewOutline.png | Bin 261 -> 0 bytes .../images/toolbarButton-viewThumbnail.png | Bin 182 -> 0 bytes static/pdf.js/images/toolbarButton-zoomIn.png | Bin 228 -> 0 bytes .../pdf.js/images/toolbarButton-zoomOut.png | Bin 141 -> 0 bytes static/pdf.js/l10n.js | 1004 - static/pdf.js/locale/ar/viewer.properties | 112 - static/pdf.js/locale/ca/viewer.properties | 131 - static/pdf.js/locale/cs/viewer.properties | 58 - static/pdf.js/locale/cy/viewer.properties | 134 - static/pdf.js/locale/da/viewer.properties | 132 - static/pdf.js/locale/de/viewer.properties | 141 - static/pdf.js/locale/el/viewer.properties | 124 - static/pdf.js/locale/en-US/viewer.properties | 141 - static/pdf.js/locale/es/viewer.properties | 141 - static/pdf.js/locale/fa/viewer.properties | 134 - static/pdf.js/locale/fi/viewer.properties | 129 - static/pdf.js/locale/fr/viewer.properties | 130 - static/pdf.js/locale/he/viewer.properties | 59 - static/pdf.js/locale/it/viewer.properties | 44 - static/pdf.js/locale/ja/viewer.properties | 141 - static/pdf.js/locale/ko/viewer.properties | 131 - static/pdf.js/locale/locale.properties | 87 - static/pdf.js/locale/lt/viewer.properties | 129 - static/pdf.js/locale/nl/viewer.properties | 141 - static/pdf.js/locale/no/viewer.properties | 134 - static/pdf.js/locale/pl/viewer.properties | 132 - static/pdf.js/locale/pt-BR/viewer.properties | 44 - static/pdf.js/locale/ro/viewer.properties | 55 - static/pdf.js/locale/ru/viewer.properties | 62 - static/pdf.js/locale/sr/viewer.properties | 55 - static/pdf.js/locale/sv/viewer.properties | 142 - static/pdf.js/locale/tr/viewer.properties | 129 - static/pdf.js/locale/vi/viewer.properties | 131 - static/pdf.js/locale/zh-CN/viewer.properties | 141 - static/pdf.js/locale/zh-TW/viewer.properties | 141 - static/pdf.js/minify.py | 3 - static/pdf.js/pdf.js | 7511 --- static/pdf.js/pdf.worker.js | 39957 ---------------- static/pdf.js/viewer.css | 1719 - static/pdf.js/viewer.js | 5397 --- static/txt.js/txt.js | 62 - static/txt.js/txt.py | 83 - static/txt.js/txt.ttf | Bin 379588 -> 0 bytes 120 files changed, 12 insertions(+), 86193 deletions(-) delete mode 100644 static/epub.js/css/annotations.css delete mode 100755 static/epub.js/css/main.css delete mode 100755 static/epub.js/css/normalize.css delete mode 100644 static/epub.js/css/popup.css delete mode 100644 static/epub.js/epub.js delete mode 100644 static/epub.js/epub.js.map delete mode 100644 static/epub.js/epub.min.js delete mode 100644 static/epub.js/epub.min.map delete mode 100644 static/epub.js/epub_no_underscore.js delete mode 100644 static/epub.js/epub_no_underscore.js.map delete mode 100644 static/epub.js/font/fontello.eot delete mode 100644 static/epub.js/font/fontello.svg delete mode 100644 static/epub.js/font/fontello.ttf delete mode 100644 static/epub.js/font/fontello.woff delete mode 100644 static/epub.js/hooks.js delete mode 100644 static/epub.js/hooks.js.map delete mode 100644 static/epub.js/hooks.min.js delete mode 100644 static/epub.js/hooks.min.map delete mode 100644 static/epub.js/hooks/extensions/highlight.js delete mode 100644 static/epub.js/libs/inflate.js delete mode 100644 static/epub.js/libs/inflate.map delete mode 100644 static/epub.js/libs/jquery.highlight.js delete mode 100644 static/epub.js/libs/screenfull.min.js delete mode 100644 static/epub.js/libs/zip.min.js delete mode 100644 static/epub.js/libs/zip.min.map delete mode 100644 static/epub.js/plugins/hypothesis.js delete mode 100644 static/epub.js/plugins/search.js delete mode 100644 static/epub.js/reader.js delete mode 100644 static/epub.js/reader.js.map delete mode 100644 static/epub.js/reader.min.js delete mode 100644 static/epub.js/reader.min.map delete mode 100644 static/pdf.js/compatibility.js delete mode 100644 static/pdf.js/css/videopdf.css delete mode 100644 static/pdf.js/debugger.js delete mode 100644 static/pdf.js/embeds.js delete mode 100644 static/pdf.js/images/annotation-check.svg delete mode 100644 static/pdf.js/images/annotation-comment.svg delete mode 100644 static/pdf.js/images/annotation-help.svg delete mode 100644 static/pdf.js/images/annotation-insert.svg delete mode 100644 static/pdf.js/images/annotation-key.svg delete mode 100644 static/pdf.js/images/annotation-newparagraph.svg delete mode 100644 static/pdf.js/images/annotation-note.svg delete mode 100644 static/pdf.js/images/annotation-paragraph.svg delete mode 100644 static/pdf.js/images/findbarButton-next-rtl.png delete mode 100644 static/pdf.js/images/findbarButton-next.png delete mode 100644 static/pdf.js/images/findbarButton-previous-rtl.png delete mode 100644 static/pdf.js/images/findbarButton-previous.png delete mode 100644 static/pdf.js/images/grab.cur delete mode 100644 static/pdf.js/images/grabbing.cur delete mode 100644 static/pdf.js/images/loading-icon.gif delete mode 100644 static/pdf.js/images/loading-small.png delete mode 100644 static/pdf.js/images/secondaryToolbarButton-firstPage.png delete mode 100644 static/pdf.js/images/secondaryToolbarButton-handTool.png delete mode 100644 static/pdf.js/images/secondaryToolbarButton-lastPage.png delete mode 100644 static/pdf.js/images/secondaryToolbarButton-rotateCcw.png delete mode 100644 static/pdf.js/images/secondaryToolbarButton-rotateCw.png delete mode 100644 static/pdf.js/images/shadow.png delete mode 100644 static/pdf.js/images/texture.png delete mode 100644 static/pdf.js/images/toolbarButton-bookmark.png delete mode 100644 static/pdf.js/images/toolbarButton-download.png delete mode 100644 static/pdf.js/images/toolbarButton-fullscreen.png delete mode 100644 static/pdf.js/images/toolbarButton-menuArrows.png delete mode 100644 static/pdf.js/images/toolbarButton-openFile.png delete mode 100644 static/pdf.js/images/toolbarButton-pageDown-rtl.png delete mode 100644 static/pdf.js/images/toolbarButton-pageDown.png delete mode 100644 static/pdf.js/images/toolbarButton-pageUp-rtl.png delete mode 100644 static/pdf.js/images/toolbarButton-pageUp.png delete mode 100644 static/pdf.js/images/toolbarButton-presentationMode.png delete mode 100644 static/pdf.js/images/toolbarButton-print.png delete mode 100644 static/pdf.js/images/toolbarButton-search.png delete mode 100644 static/pdf.js/images/toolbarButton-secondaryToolbarToggle-rtl.png delete mode 100644 static/pdf.js/images/toolbarButton-secondaryToolbarToggle.png delete mode 100644 static/pdf.js/images/toolbarButton-sidebarToggle-rtl.png delete mode 100644 static/pdf.js/images/toolbarButton-sidebarToggle.png delete mode 100644 static/pdf.js/images/toolbarButton-viewOutline-rtl.png delete mode 100644 static/pdf.js/images/toolbarButton-viewOutline.png delete mode 100644 static/pdf.js/images/toolbarButton-viewThumbnail.png delete mode 100644 static/pdf.js/images/toolbarButton-zoomIn.png delete mode 100644 static/pdf.js/images/toolbarButton-zoomOut.png delete mode 100644 static/pdf.js/l10n.js delete mode 100644 static/pdf.js/locale/ar/viewer.properties delete mode 100644 static/pdf.js/locale/ca/viewer.properties delete mode 100644 static/pdf.js/locale/cs/viewer.properties delete mode 100644 static/pdf.js/locale/cy/viewer.properties delete mode 100644 static/pdf.js/locale/da/viewer.properties delete mode 100644 static/pdf.js/locale/de/viewer.properties delete mode 100644 static/pdf.js/locale/el/viewer.properties delete mode 100644 static/pdf.js/locale/en-US/viewer.properties delete mode 100644 static/pdf.js/locale/es/viewer.properties delete mode 100644 static/pdf.js/locale/fa/viewer.properties delete mode 100644 static/pdf.js/locale/fi/viewer.properties delete mode 100644 static/pdf.js/locale/fr/viewer.properties delete mode 100644 static/pdf.js/locale/he/viewer.properties delete mode 100644 static/pdf.js/locale/it/viewer.properties delete mode 100644 static/pdf.js/locale/ja/viewer.properties delete mode 100644 static/pdf.js/locale/ko/viewer.properties delete mode 100644 static/pdf.js/locale/locale.properties delete mode 100644 static/pdf.js/locale/lt/viewer.properties delete mode 100644 static/pdf.js/locale/nl/viewer.properties delete mode 100644 static/pdf.js/locale/no/viewer.properties delete mode 100644 static/pdf.js/locale/pl/viewer.properties delete mode 100644 static/pdf.js/locale/pt-BR/viewer.properties delete mode 100644 static/pdf.js/locale/ro/viewer.properties delete mode 100644 static/pdf.js/locale/ru/viewer.properties delete mode 100644 static/pdf.js/locale/sr/viewer.properties delete mode 100644 static/pdf.js/locale/sv/viewer.properties delete mode 100644 static/pdf.js/locale/tr/viewer.properties delete mode 100644 static/pdf.js/locale/vi/viewer.properties delete mode 100644 static/pdf.js/locale/zh-CN/viewer.properties delete mode 100644 static/pdf.js/locale/zh-TW/viewer.properties delete mode 100644 static/pdf.js/minify.py delete mode 100644 static/pdf.js/pdf.js delete mode 100644 static/pdf.js/pdf.worker.js delete mode 100644 static/pdf.js/viewer.css delete mode 100644 static/pdf.js/viewer.js delete mode 100644 static/txt.js/txt.js delete mode 100755 static/txt.js/txt.py delete mode 100644 static/txt.js/txt.ttf diff --git a/oml/commands.py b/oml/commands.py index 3bf7c07..8940cf2 100644 --- a/oml/commands.py +++ b/oml/commands.py @@ -118,6 +118,11 @@ def command_update_static(*args): os.system('cd "%s" && git pull' % oxjs) r('python3', os.path.join(oxjs, 'tools', 'build', 'build.py')) r('python3', os.path.join(settings.static_path, 'py', 'build.py')) + reader = os.path.join(settings.base_dir, '..', 'reader') + if not os.path.exists(reader): + r('git', 'clone', 'https://git.0x2620.org/openmedialibrary_reader.git', reader) + elif os.path.exists(os.path.join(reader, '.git')): + os.system('cd "%s" && git pull' % reader) def command_release(*args): """ @@ -149,7 +154,7 @@ def command_release(*args): h.update(chunk) return h.hexdigest() - MODULES = ['platform', 'openmedialibrary', 'oxjs'] + MODULES = ['platform', 'openmedialibrary', 'oxjs', 'reader'] VERSIONS = {module:version(module) for module in MODULES} EXCLUDE=[ @@ -166,7 +171,9 @@ def command_release(*args): if module in ('openmedialibrary', ): cmd += ['--exclude', '*.pyc'] if module == 'openmedialibrary': - cmd += ['--exclude', 'oxjs/examples', '--exclude', 'gunicorn.pid'] + cmd += ['--exclude', 'gunicorn.pid'] + if module == 'js': + cmd += ['--exclude', 'oxjs/examples'] run(*cmd) release = {} release['modules'] = {module: { diff --git a/oml/server.py b/oml/server.py index 94c228d..17e0d0b 100644 --- a/oml/server.py +++ b/oml/server.py @@ -58,6 +58,9 @@ def run(): handlers = [ (r'/(favicon.ico)', StaticFileHandler, {'path': settings.static_path}), (r'/static/oxjs/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'oxjs')}), + (r'/static/epub.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'epub,js')}), + (r'/static/pdf.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'pdf,js')}), + (r'/static/txt.js/(.*)', StaticFileHandler, {'path': os.path.join(settings.base_dir, '..', 'reader', 'txt,js')}), (r'/static/(.*)', StaticFileHandler, {'path': settings.static_path}), (r'/(.*)/epub/(.*)', EpubHandler), (r'/(.*?)/reader/', ReaderHandler), diff --git a/static/epub.js/css/annotations.css b/static/epub.js/css/annotations.css deleted file mode 100644 index ae74f91..0000000 --- a/static/epub.js/css/annotations.css +++ /dev/null @@ -1,8 +0,0 @@ -.ui-loader { - display: none; -} - -.annotator-hl { - box-shadow: none !important; - cursor: pointer !important; -} \ No newline at end of file diff --git a/static/epub.js/css/main.css b/static/epub.js/css/main.css deleted file mode 100755 index fe0c65d..0000000 --- a/static/epub.js/css/main.css +++ /dev/null @@ -1,792 +0,0 @@ -@font-face { - font-family: 'fontello'; - src: url('../font/fontello.eot?60518104'); - src: url('../font/fontello.eot?60518104#iefix') format('embedded-opentype'), - url('../font/fontello.woff?60518104') format('woff'), - url('../font/fontello.ttf?60518104') format('truetype'), - url('../font/fontello.svg?60518104#fontello') format('svg'); - font-weight: normal; - font-style: normal; -} - -body { - background: #4e4e4e; - overflow: hidden; -} - -#main { - /* height: 500px; */ - position: absolute; - width: 100%; - height: 100%; - right: 0; - padding-top: 2%; - /* left: 40px; */ -/* -webkit-transform: translate(40px, 0); - -moz-transform: translate(40px, 0); */ - - /* border-radius: 5px 0px 0px 5px; */ - background: #fff; - overflow: hidden; -} - - -#titlebar { - height: 8%; - min-height: 20px; - padding: 10px; - /* margin: 0 50px 0 50px; */ - position: relative; - color: #4f4f4f; - font-weight: 100; - font-family: Georgia, "Times New Roman", Times, serif; - opacity: .5; - text-align: center; - -webkit-transition: opacity .5s; - -moz-transition: opacity .5s; - z-index: 10; -} - -#titlebar:hover { - opacity: 1; -} - -#titlebar a { - width: 18px; - height: 19px; - line-height: 20px; - overflow: hidden; - display: inline-block; - opacity: .5; - padding: 4px; - border-radius: 4px; -} - -#titlebar a::before { - visibility: visible; -} - -#titlebar a:hover { - opacity: .8; - border: 1px rgba(0,0,0,.2) solid; - padding: 3px; -} - -#titlebar a:active { - opacity: 1; - color: rgba(0,0,0,.6); - /* margin: 1px -1px -1px 1px; */ - -moz-box-shadow: inset 0 0 6px rgba(155,155,155,.8); - -webkit-box-shadow: inset 0 0 6px rgba(155,155,155,.8); - box-shadow: inset 0 0 6px rgba(155,155,155,.8); -} - -#book-title { - font-weight: 600; -} - -#title-seperator { - display: none; -} - -#viewer { - width: 88%; - height: 92%; - /* margin-left: 10%; */ - margin: 0 auto; - max-width: 1250px; - z-index: 2; - position: relative; - overflow: hidden; -} - -#viewer iframe { - border: none; -} - -#prev { - left: 40px; -} - -#next { - right: 40px; -} - -.arrow { - position: absolute; - top: 50%; - margin-top: -32px; - font-size: 64px; - color: #E2E2E2; - font-family: arial, sans-serif; - font-weight: bold; - cursor: pointer; -} - -.arrow:hover { - color: #777; -} - -.arrow:active, -.arrow.active { - color: #000; -} - -#sidebar { - background: #6b6b6b; - position: absolute; - /* left: -260px; */ - /* -webkit-transform: translate(-260px, 0); - -moz-transform: translate(-260px, 0); */ - top: 0; - min-width: 300px; - width: 25%; - height: 100%; - -webkit-transition: -webkit-transform .5s; - -moz-transition: -moz-transform .5s; - - overflow: hidden; -} - -#sidebar.open { - /* left: 0; */ - /* -webkit-transform: translate(0, 0); - -moz-transform: translate(0, 0); */ -} - -#main.closed { - /* left: 300px; */ - -webkit-transform: translate(300px, 0); - -moz-transform: translate(300px, 0); -} - -#main.single { - width: 75%; -} - -#main.single #viewer { - /* width: 60%; - margin-left: 20%; */ -} - -#panels { - background: #4e4e4e; - position: absolute; - left: 0; - top: 0; - width: 100%; - padding: 13px 0; - height: 14px; - -moz-box-shadow: 0px 1px 3px rgba(0,0,0,.6); - -webkit-box-shadow: 0px 1px 3px rgba(0,0,0,.6); - box-shadow: 0px 1px 3px rgba(0,0,0,.6); -} - -#opener { - /* padding: 10px 10px; */ - float: left; -} - -/* #opener #slider { - width: 25px; -} */ - -#metainfo { - display: inline-block; - text-align: center; - max-width: 80%; -} - -#title-controls { - float: right; -} - -#panels a { - visibility: hidden; - width: 18px; - height: 20px; - overflow: hidden; - display: inline-block; - color: #ccc; - margin-left: 6px; -} - -#panels a::before { - visibility: visible; -} - -#panels a:hover { - color: #AAA; -} - -#panels a:active { - color: #AAA; - margin: 1px 0 -1px 6px; -} - -#panels a.active, -#panels a.active:hover { - color: #AAA; -} - -#searchBox { - width: 165px; - float: left; - margin-left: 10px; - margin-top: -1px; - /* - border-radius: 5px; - background: #9b9b9b; - float: left; - margin-left: 5px; - margin-top: -5px; - padding: 3px 10px; - color: #000; - border: none; - outline: none; */ - -} - -input::-webkit-input-placeholder { - color: #454545; -} -input:-moz-placeholder { - color: #454545; -} - -#divider { - position: absolute; - width: 1px; - border-right: 1px #000 solid; - height: 80%; - z-index: 1; - left: 50%; - margin-left: -1px; - top: 10%; - opacity: .15; - display: none; -} - -#divider.show { - display: block; -} - -#loader { - position: absolute; - z-index: 10; - left: 50%; - top: 50%; - margin: -33px 0 0 -33px; -} - -#tocView, -#bookmarksView { - overflow-x: hidden; - overflow-y: hidden; - min-width: 300px; - width: 25%; - height: 100%; - visibility: hidden; - -webkit-transition: visibility 0 ease .5s; - -moz-transition: visibility 0 ease .5s; -} - - - -#sidebar.open #tocView, -#sidebar.open #bookmarksView { - overflow-y: auto; - visibility: visible; - -webkit-transition: visibility 0 ease 0; - -moz-transition: visibility 0 ease 0; -} - -#sidebar.open #tocView { - display: block; -} - -#tocView > ul, -#bookmarksView > ul { - margin-top: 15px; - margin-bottom: 50px; - padding-left: 20px; - display: block; -} - -#tocView li, -#bookmarksView li { - margin-bottom:10px; - width: 225px; - font-family: Georgia, "Times New Roman", Times, serif; - list-style: none; - text-transform: capitalize; -} - -#tocView li:active, -#tocView li.currentChapter -{ - list-style: none; -} - -.list_item a { - color: #AAA; - text-decoration: none; -} - -.list_item a.chapter { - font-size: 1em; -} - -.list_item a.section { - font-size: .8em; -} - -.list_item.currentChapter > a, -.list_item a:hover { - color: #f1f1f1 -} - -/* #tocView li.openChapter > a, */ -.list_item a:hover { - color: #E2E2E2; -} - -.list_item ul { - padding-left:10px; - margin-top: 8px; - display: none; -} - -.list_item.currentChapter > ul, -.list_item.openChapter > ul { - display: block; -} - -#tocView.hidden { - display: none; -} - -.toc_toggle { - display: inline-block; - width: 14px; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; -} - -.toc_toggle:before { - content: '▸'; - color: #fff; - margin-right: -4px; -} - -.currentChapter > .toc_toggle:before, -.openChapter > .toc_toggle:before { - content: '▾'; -} - -.view { - width: 300px; - height: 100%; - display: none; - padding-top: 50px; - overflow-y: auto; -} - -#searchResults { - margin-bottom: 50px; - padding-left: 20px; - display: block; -} - -#searchResults li { - margin-bottom:10px; - width: 225px; - font-family: Georgia, "Times New Roman", Times, serif; - list-style: none; -} - -#searchResults a { - color: #AAA; - text-decoration: none; -} - -#searchResults p { - text-decoration: none; - font-size: 12px; - line-height: 16px; -} - -#searchResults p .match { - background: #ccc; - color: #000; -} - -#searchResults li > p { - color: #AAA; -} - -#searchResults li a:hover { - color: #E2E2E2; -} - -#searchView.shown { - display: block; - overflow-y: scroll; -} - -#notes { - padding: 0 0 0 34px; -} - -#notes li { - color: #eee; - font-size: 12px; - width: 240px; - border-top: 1px #fff solid; - padding-top: 6px; - margin-bottom: 6px; -} - -#notes li a { - color: #fff; - display: inline-block; - margin-left: 6px; -} - -#notes li a:hover { - text-decoration: underline; -} - -#notes li img { - max-width: 240px; -} - -#note-text { - display: block; - width: 260px; - height: 80px; - margin: 0 auto; - padding: 5px; - border-radius: 5px; -} - -#note-text[disabled], #note-text[disabled="disabled"]{ - opacity: .5; -} - -#note-anchor { - margin-left: 218px; - margin-top: 5px; -} - -#settingsPanel { - display:none; -} - -#settingsPanel h3 { - color:#f1f1f1; - font-family:Georgia, "Times New Roman", Times, serif; - margin-bottom:10px; -} - -#settingsPanel ul { - margin-top:60px; - list-style-type:none; -} - -#settingsPanel li { - font-size:1em; - color:#f1f1f1; -} - -#settingsPanel .xsmall { font-size:x-small; } -#settingsPanel .small { font-size:small; } -#settingsPanel .medium { font-size:medium; } -#settingsPanel .large { font-size:large; } -#settingsPanel .xlarge { font-size:x-large; } - -.highlight { background-color: yellow } - -.modal { - position: fixed; - top: 50%; - left: 50%; - width: 50%; - width: 630px; - - height: auto; - z-index: 2000; - visibility: hidden; - margin-left: -320px; - margin-top: -160px; - -} - -.overlay { - position: fixed; - width: 100%; - height: 100%; - visibility: hidden; - top: 0; - left: 0; - z-index: 1000; - opacity: 0; - background: rgba(255,255,255,0.8); - -webkit-transition: all 0.3s; - -moz-transition: all 0.3s; - transition: all 0.3s; -} - -.md-show { - visibility: visible; -} - -.md-show ~ .overlay { - opacity: 1; - visibility: visible; -} - -/* Content styles */ -.md-content { - color: #fff; - background: #6b6b6b; - position: relative; - border-radius: 3px; - margin: 0 auto; - height: 320px; -} - -.md-content h3 { - margin: 0; - padding: 6px; - text-align: center; - font-size: 22px; - font-weight: 300; - opacity: 0.8; - background: rgba(0,0,0,0.1); - border-radius: 3px 3px 0 0; -} - -.md-content > div { - padding: 15px 40px 30px; - margin: 0; - font-weight: 300; - font-size: 14px; -} - -.md-content > div p { - margin: 0; - padding: 10px 0; -} - -.md-content > div ul { - margin: 0; - padding: 0 0 30px 20px; -} - -.md-content > div ul li { - padding: 5px 0; -} - -.md-content button { - display: block; - margin: 0 auto; - font-size: 0.8em; -} - -/* Effect 1: Fade in and scale up */ -.md-effect-1 .md-content { - -webkit-transform: scale(0.7); - -moz-transform: scale(0.7); - -ms-transform: scale(0.7); - transform: scale(0.7); - opacity: 0; - -webkit-transition: all 0.3s; - -moz-transition: all 0.3s; - transition: all 0.3s; -} - -.md-show.md-effect-1 .md-content { - -webkit-transform: scale(1); - -moz-transform: scale(1); - -ms-transform: scale(1); - transform: scale(1); - opacity: 1; -} - -.md-content > .closer { - font-size: 18px; - position: absolute; - right: 0; - top: 0; - font-size: 24px; - padding: 4px; -} - -@media only screen and (max-width: 1040px) { - #viewer{ - width: 50%; - margin-left: 25%; - } - - #divider, - #divider.show { - display: none; - } -} - -@media only screen and (max-width: 900px) { - #viewer{ - width: 60%; - margin-left: 20%; - } - - #prev { - left: 20px; - } - - #next { - right: 20px; - } -} - -@media only screen and (max-width: 550px) { - #viewer{ - width: 80%; - margin-left: 10%; - } - - #prev { - left: 0; - } - - #next { - right: 0; - } - - .arrow { - height: 100%; - top: 45px; - width: 10%; - text-indent: -10000px; - } - - #main { - -webkit-transform: translate(0, 0); - -moz-transform: translate(0, 0); - -webkit-transition: -webkit-transform .3s; - -moz-transition: -moz-transform .3s; - } - - #main.closed { - -webkit-transform: translate(260px, 0); - -moz-transform: translate(260px, 0); - } - - #titlebar { - /* font-size: 16px; */ - /* margin: 0 50px 0 50px; */ - } - - #metainfo { - font-size: 10px; - } - - #tocView { - width: 260px; - } - - #tocView li { - font-size: 12px; - } - - #tocView > ul{ - padding-left: 10px; - webkit-padding-start:; - } -} - - -/* For iPad portrait layouts only */ -@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: portrait) { - #viewer iframe { - width: 460px; - height: 740px; - } -} - /*For iPad landscape layouts only */ -@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: landscape) { - #viewer iframe { - width: 460px; - height: 415px; - } -} -/* For iPhone portrait layouts only */ -@media only screen and (max-device-width: 480px) and (orientation: portrait) { - #viewer { - width: 256px; - height: 432px; - } - #viewer iframe { - width: 256px; - height: 432px; - } -} -/* For iPhone landscape layouts only */ -@media only screen and (max-device-width: 480px) and (orientation: landscape) { - #viewer iframe { - width: 256px; - height: 124px; - } -} - -[class^="icon-"]:before, [class*=" icon-"]:before { - font-family: "fontello"; - font-style: normal; - font-weight: normal; - speak: none; - - display: inline-block; - text-decoration: inherit; - width: 1em; - margin-right: .2em; - text-align: center; - /* opacity: .8; */ - - /* For safety - reset parent styles, that can break glyph codes*/ - font-variant: normal; - text-transform: none; - - /* you can be more comfortable with increased icons size */ - font-size: 112%; -} - - -.icon-search:before { content: '\e807'; } /* '' */ -.icon-resize-full-1:before { content: '\e804'; } /* '' */ -.icon-cancel-circled2:before { content: '\e80f'; } /* '' */ -.icon-link:before { content: '\e80d'; } /* '' */ -.icon-bookmark:before { content: '\e805'; } /* '' */ -.icon-bookmark-empty:before { content: '\e806'; } /* '' */ -.icon-download-cloud:before { content: '\e811'; } /* '' */ -.icon-edit:before { content: '\e814'; } /* '' */ -.icon-menu:before { content: '\e802'; } /* '' */ -.icon-cog:before { content: '\e813'; } /* '' */ -.icon-resize-full:before { content: '\e812'; } /* '' */ -.icon-cancel-circled:before { content: '\e80e'; } /* '' */ -.icon-up-dir:before { content: '\e80c'; } /* '' */ -.icon-right-dir:before { content: '\e80b'; } /* '' */ -.icon-angle-right:before { content: '\e809'; } /* '' */ -.icon-angle-down:before { content: '\e80a'; } /* '' */ -.icon-right:before { content: '\e815'; } /* '' */ -.icon-list-1:before { content: '\e803'; } /* '' */ -.icon-list-numbered:before { content: '\e801'; } /* '' */ -.icon-columns:before { content: '\e810'; } /* '' */ -.icon-list:before { content: '\e800'; } /* '' */ -.icon-resize-small:before { content: '\e808'; } /* '' */ - -#titlebar { - display: none !important; -} diff --git a/static/epub.js/css/normalize.css b/static/epub.js/css/normalize.css deleted file mode 100755 index c3e014d..0000000 --- a/static/epub.js/css/normalize.css +++ /dev/null @@ -1,505 +0,0 @@ -/*! normalize.css v1.0.1 | MIT License | git.io/normalize */ - -/* ========================================================================== - HTML5 display definitions - ========================================================================== */ - -/* - * Corrects `block` display not defined in IE 6/7/8/9 and Firefox 3. - */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block; -} - -/* - * Corrects `inline-block` display not defined in IE 6/7/8/9 and Firefox 3. - */ - -audio, -canvas, -video { - display: inline-block; - *display: inline; - *zoom: 1; -} - -/* - * Prevents modern browsers from displaying `audio` without controls. - * Remove excess height in iOS 5 devices. - */ - -audio:not([controls]) { - display: none; - height: 0; -} - -/* - * Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3, - * and Safari 4. - * Known issue: no IE 6 support. - */ - -[hidden] { - display: none; -} - -/* ========================================================================== - Base - ========================================================================== */ - -/* - * 1. Corrects text resizing oddly in IE 6/7 when body `font-size` is set using - * `em` units. - * 2. Prevents iOS text size adjust after orientation change, without disabling - * user zoom. - */ - -html { - font-size: 100%; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ - -ms-text-size-adjust: 100%; /* 2 */ -} - -/* - * Addresses `font-family` inconsistency between `textarea` and other form - * elements. - */ - -html, -button, -input, -select, -textarea { - font-family: sans-serif; -} - -/* - * Addresses margins handled incorrectly in IE 6/7. - */ - -body { - margin: 0; -} - -/* ========================================================================== - Links - ========================================================================== */ - -/* - * Addresses `outline` inconsistency between Chrome and other browsers. - */ - -a:focus { - outline: thin dotted; -} - -/* - * Improves readability when focused and also mouse hovered in all browsers. - */ - -a:active, -a:hover { - outline: 0; -} - -/* ========================================================================== - Typography - ========================================================================== */ - -/* - * Addresses font sizes and margins set differently in IE 6/7. - * Addresses font sizes within `section` and `article` in Firefox 4+, Safari 5, - * and Chrome. - */ - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -h2 { - font-size: 1.5em; - margin: 0.83em 0; -} - -h3 { - font-size: 1.17em; - margin: 1em 0; -} - -h4 { - font-size: 1em; - margin: 1.33em 0; -} - -h5 { - font-size: 0.83em; - margin: 1.67em 0; -} - -h6 { - font-size: 0.75em; - margin: 2.33em 0; -} - -/* - * Addresses styling not present in IE 7/8/9, Safari 5, and Chrome. - */ - -abbr[title] { - border-bottom: 1px dotted; -} - -/* - * Addresses style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome. - */ - -b, -strong { - font-weight: bold; -} - -blockquote { - margin: 1em 40px; -} - -/* - * Addresses styling not present in Safari 5 and Chrome. - */ - -dfn { - font-style: italic; -} - -/* - * Addresses styling not present in IE 6/7/8/9. - */ - -mark { - background: #ff0; - color: #000; -} - -/* - * Addresses margins set differently in IE 6/7. - */ - -p, -pre { - margin: 1em 0; -} - -/* - * Corrects font family set oddly in IE 6, Safari 4/5, and Chrome. - */ - -code, -kbd, -pre, -samp { - font-family: monospace, serif; - _font-family: 'courier new', monospace; - font-size: 1em; -} - -/* - * Improves readability of pre-formatted text in all browsers. - */ - -pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; -} - -/* - * Addresses CSS quotes not supported in IE 6/7. - */ - -q { - quotes: none; -} - -/* - * Addresses `quotes` property not supported in Safari 4. - */ - -q:before, -q:after { - content: ''; - content: none; -} - -/* - * Addresses inconsistent and variable font size in all browsers. - */ - -small { - font-size: 80%; -} - -/* - * Prevents `sub` and `sup` affecting `line-height` in all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -/* ========================================================================== - Lists - ========================================================================== */ - -/* - * Addresses margins set differently in IE 6/7. - */ - -dl, -menu, -ol, -ul { - margin: 1em 0; -} - -dd { - margin: 0 0 0 40px; -} - -/* - * Addresses paddings set differently in IE 6/7. - */ - -menu, -ol, -ul { - padding: 0 0 0 40px; -} - -/* - * Corrects list images handled incorrectly in IE 7. - */ - -nav ul, -nav ol { - list-style: none; - list-style-image: none; -} - -/* ========================================================================== - Embedded content - ========================================================================== */ - -/* - * 1. Removes border when inside `a` element in IE 6/7/8/9 and Firefox 3. - * 2. Improves image quality when scaled in IE 7. - */ - -img { - border: 0; /* 1 */ - -ms-interpolation-mode: bicubic; /* 2 */ -} - -/* - * Corrects overflow displayed oddly in IE 9. - */ - -svg:not(:root) { - overflow: hidden; -} - -/* ========================================================================== - Figures - ========================================================================== */ - -/* - * Addresses margin not present in IE 6/7/8/9, Safari 5, and Opera 11. - */ - -figure { - margin: 0; -} - -/* ========================================================================== - Forms - ========================================================================== */ - -/* - * Corrects margin displayed oddly in IE 6/7. - */ - -form { - margin: 0; -} - -/* - * Define consistent border, margin, and padding. - */ - -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} - -/* - * 1. Corrects color not being inherited in IE 6/7/8/9. - * 2. Corrects text not wrapping in Firefox 3. - * 3. Corrects alignment displayed oddly in IE 6/7. - */ - -legend { - border: 0; /* 1 */ - padding: 0; - white-space: normal; /* 2 */ - *margin-left: -7px; /* 3 */ -} - -/* - * 1. Corrects font size not being inherited in all browsers. - * 2. Addresses margins set differently in IE 6/7, Firefox 3+, Safari 5, - * and Chrome. - * 3. Improves appearance and consistency in all browsers. - */ - -button, -input, -select, -textarea { - font-size: 100%; /* 1 */ - margin: 0; /* 2 */ - vertical-align: baseline; /* 3 */ - *vertical-align: middle; /* 3 */ -} - -/* - * Addresses Firefox 3+ setting `line-height` on `input` using `!important` in - * the UA stylesheet. - */ - -button, -input { - line-height: normal; -} - -/* - * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` - * and `video` controls. - * 2. Corrects inability to style clickable `input` types in iOS. - * 3. Improves usability and consistency of cursor style between image-type - * `input` and others. - * 4. Removes inner spacing in IE 7 without affecting normal text inputs. - * Known issue: inner spacing remains in IE 6. - */ - -button, -html input[type="button"], /* 1 */ -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; /* 2 */ - cursor: pointer; /* 3 */ - *overflow: visible; /* 4 */ -} - -/* - * Re-set default cursor for disabled elements. - */ - -button[disabled], -input[disabled] { - cursor: default; -} - -/* - * 1. Addresses box sizing set to content-box in IE 8/9. - * 2. Removes excess padding in IE 8/9. - * 3. Removes excess padding in IE 7. - * Known issue: excess padding remains in IE 6. - */ - -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ - *height: 13px; /* 3 */ - *width: 13px; /* 3 */ -} - -/* - * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. - * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome - * (include `-moz` to future-proof). - */ -/* -input[type="search"] { - -webkit-appearance: textfield; - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -*/ - -/* - * Removes inner padding and search cancel button in Safari 5 and Chrome - * on OS X. - */ - -/* input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} */ - -/* - * Removes inner padding and border in Firefox 3+. - */ - -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} - -/* - * 1. Removes default vertical scrollbar in IE 6/7/8/9. - * 2. Improves readability and alignment in all browsers. - */ - -textarea { - overflow: auto; /* 1 */ - vertical-align: top; /* 2 */ -} - -/* ========================================================================== - Tables - ========================================================================== */ - -/* - * Remove most spacing between table cells. - */ - -table { - border-collapse: collapse; - border-spacing: 0; -} diff --git a/static/epub.js/css/popup.css b/static/epub.js/css/popup.css deleted file mode 100644 index c41aac7..0000000 --- a/static/epub.js/css/popup.css +++ /dev/null @@ -1,96 +0,0 @@ -/* http://davidwalsh.name/css-tooltips */ -/* base CSS element */ -.popup { - background: #eee; - border: 1px solid #ccc; - padding: 10px; - border-radius: 8px; - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - position: fixed; - max-width: 300px; - font-size: 12px; - - display: none; - margin-left: 2px; - - margin-top: 30px; -} - -.popup.above { - margin-top: -10px; -} - -.popup.left { - margin-left: -20px; -} - -.popup.right { - margin-left: 40px; -} - -.pop_content { - max-height: 225px; - overflow-y: auto; -} - -.pop_content > p { - margin-top: 0; -} - -/* below */ -.popup:before { - position: absolute; - display: inline-block; - border-bottom: 10px solid #eee; - border-right: 10px solid transparent; - border-left: 10px solid transparent; - border-bottom-color: rgba(0, 0, 0, 0.2); - left: 50%; - top: -10px; - margin-left: -6px; - content: ''; -} - -.popup:after { - position: absolute; - display: inline-block; - border-bottom: 9px solid #eee; - border-right: 9px solid transparent; - border-left: 9px solid transparent; - left: 50%; - top: -9px; - margin-left: -5px; - content: ''; -} - -/* above */ -.popup.above:before { - border-bottom: none; - border-top: 10px solid #eee; - border-top-color: rgba(0, 0, 0, 0.2); - top: 100%; -} - -.popup.above:after { - border-bottom: none; - border-top: 9px solid #eee; - top: 100%; -} - -.popup.left:before, -.popup.left:after -{ - left: 20px; -} - -.popup.right:before, -.popup.right:after -{ - left: auto; - right: 20px; -} - - -.popup.show, .popup.on { - display: block; -} \ No newline at end of file diff --git a/static/epub.js/epub.js b/static/epub.js/epub.js deleted file mode 100644 index cb42010..0000000 --- a/static/epub.js/epub.js +++ /dev/null @@ -1,7462 +0,0 @@ -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); -(function(global) { -var define, requireModule, require, requirejs; - -(function() { - var registry = {}, seen = {}; - - define = function(name, deps, callback) { - registry[name] = { deps: deps, callback: callback }; - }; - - requirejs = require = requireModule = function(name) { - requirejs._eak_seen = registry; - - if (seen[name]) { return seen[name]; } - seen[name] = {}; - - if (!registry[name]) { - throw new Error("Could not find module " + name); - } - - var mod = registry[name], - deps = mod.deps, - callback = mod.callback, - reified = [], - exports; - - for (var i=0, l=deps.length; i 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - var alice = { name: 'alice' }; - var bob = { name: 'bob' }; - var users = [ alice, bob ]; - - var promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - var filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ - function filter(promises, filterFn, label) { - if (!isArray(promises)) { - throw new TypeError('You must pass an array to filter.'); - } - - if (!isFunction(filterFn)){ - throw new TypeError("You must pass a function to filter's second argument."); - } - - return all(promises, label).then(function(values){ - return map(promises, filterFn, label).then(function(filterResults){ - var i, - valuesLen = values.length, - filtered = []; - - for (i = 0; i < valuesLen; i++){ - if(filterResults[i]) filtered.push(values[i]); - } - return filtered; - }); - }); - } - - __exports__["default"] = filter; - }); -define("rsvp/hash", - ["./promise","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var isNonThenable = __dependency2__.isNonThenable; - var keysOf = __dependency2__.keysOf; - - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as as the first argument, or as the reason to - the rejection handler. For example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error("rejectedPromise")), - anotherRejectedPromise: RSVP.reject(new Error("anotherRejectedPromise")), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "rejectedPromise" - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve("Example"); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve("Proto Property") - }; - - var myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: "Example" - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @for RSVP - @param {Object} promises - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function hash(object, label) { - return new Promise(function(resolve, reject){ - var results = {}; - var keys = keysOf(object); - var remaining = keys.length; - var entry, property; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfilledTo(property) { - return function(value) { - results[property] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var i = 0; i < keys.length; i++) { - property = keys[i]; - entry = object[property]; - - if (isNonThenable(entry)) { - results[property] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Promise.cast(entry).then(fulfilledTo(property), onRejection); - } - } - }); - }; - }); -define("rsvp/instrument", - ["./config","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var now = __dependency2__.now; - - __exports__["default"] = function instrument(eventName, promise, child) { - // instrumentation should not disrupt normal usage. - try { - config.trigger(eventName, { - guid: promise._guidKey + promise._id, - eventName: eventName, - detail: promise._detail, - childGuid: child && promise._guidKey + child._id, - label: promise._label, - timeStamp: now(), - stack: new Error(promise._label).stack - }); - } catch(error) { - setTimeout(function(){ - throw error; - }, 0); - } - }; - }); -define("rsvp/map", - ["./promise","./all","./utils","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var all = __dependency2__["default"]; - var isArray = __dependency3__.isArray; - var isFunction = __dependency3__.isFunction; - - /** - - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first becuase they contain a url to those comments. - - ```javscript - - var mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - */ - __exports__["default"] = function map(promises, mapFn, label) { - - if (!isArray(promises)) { - throw new TypeError('You must pass an array to map.'); - } - - if (!isFunction(mapFn)){ - throw new TypeError("You must pass a function to map's second argument."); - } - - return all(promises, label).then(function(results){ - var resultLen = results.length, - mappedResults = [], - i; - - for (i = 0; i < resultLen; i++){ - mappedResults.push(mapFn(results[i])); - } - - return all(mappedResults, label); - }); - }; - }); -define("rsvp/node", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - var slice = Array.prototype.slice; - - function makeNodeCallbackFor(resolve, reject) { - return function (error, value) { - if (error) { - reject(error); - } else if (arguments.length > 2) { - resolve(slice.call(arguments, 1)); - } else { - resolve(value); - } - }; - } - - /** - `RSVP.denodeify` takes a "node-style" function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - var fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - var fs = require('fs'); - - var readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - var fs = require('fs'); - var log = require('some-async-logger'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - fs.writeFile('myfile2.txt', data, function(err){ - if (err) throw err; - log('success', function(err) { - if (err) throw err; - }); - }); - }); - ``` - - You can chain the operations together using `then` from the returned promise: - - ```javascript - var fs = require('fs'); - var denodeify = RSVP.denodeify; - var readFile = denodeify(fs.readFile); - var writeFile = denodeify(fs.writeFile); - var log = denodeify(require('some-async-logger')); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - return log('SUCCESS'); - }).then(function(){ - // success handler - }, function(reason){ - // rejection handler - }); - ``` - - @method denodeify - @for RSVP - @param {Function} nodeFunc a "node-style" function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ("function(err, value){ }"). - @param {Any} binding optional argument for binding the "this" value when - calling the `nodeFunc` function. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - */ - __exports__["default"] = function denodeify(nodeFunc, binding) { - return function() { - var nodeArgs = slice.call(arguments), resolve, reject; - var thisArg = this || binding; - - return new Promise(function(resolve, reject) { - Promise.all(nodeArgs).then(function(nodeArgs) { - try { - nodeArgs.push(makeNodeCallbackFor(resolve, reject)); - nodeFunc.apply(thisArg, nodeArgs); - } catch(e) { - reject(e); - } - }); - }); - }; - }; - }); -define("rsvp/promise", - ["./config","./events","./instrument","./utils","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var EventTarget = __dependency2__["default"]; - var instrument = __dependency3__["default"]; - var objectOrFunction = __dependency4__.objectOrFunction; - var isFunction = __dependency4__.isFunction; - var now = __dependency4__.now; - var cast = __dependency5__["default"]; - var all = __dependency6__["default"]; - var race = __dependency7__["default"]; - var Resolve = __dependency8__["default"]; - var Reject = __dependency9__["default"]; - - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; - - function noop() {} - - __exports__["default"] = Promise; - - - /** - - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - - Basic Usage: - ------------ - - ```js - var promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - var xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error("getJSON: `" + url + "` failed with status: [" + this.status + "]"); - } - } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - if (!isFunction(resolver)) { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); - } - - if (!(this instanceof Promise)) { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); - } - - this._id = counter++; - this._label = label; - this._subscribers = []; - - if (config.instrument) { - instrument('created', this); - } - - if (noop !== resolver) { - invokeResolver(resolver, this); - } - } - - function invokeResolver(resolver, promise) { - function resolvePromise(value) { - resolve(promise, value); - } - - function rejectPromise(reason) { - reject(promise, reason); - } - - try { - resolver(resolvePromise, rejectPromise); - } catch(e) { - rejectPromise(e); - } - } - - Promise.cast = cast; - Promise.all = all; - Promise.race = race; - Promise.resolve = Resolve; - Promise.reject = Reject; - - var PENDING = void 0; - var SEALED = 0; - var FULFILLED = 1; - var REJECTED = 2; - - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; - - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; - } - - function publish(promise, settled) { - var child, callback, subscribers = promise._subscribers, detail = promise._detail; - - if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); - } - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - invokeCallback(settled, child, callback, detail); - } - - promise._subscribers = null; - } - - Promise.prototype = { - /** - @property constructor - */ - constructor: Promise, - - _id: undefined, - _guidKey: guidKey, - _label: undefined, - - _state: undefined, - _detail: undefined, - _subscribers: undefined, - - _onerror: function (reason) { - config.trigger('error', reason); - }, - - /** - - A promise represents the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, "downstream" - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return "default name"; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `"default name"` - }); - - findUser().then(function (user) { - throw "Found user, but still unhappy"; - }, function (reason) { - throw "`findUser` rejected and we're unhappy"; - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be "Found user, but still unhappy". - // If `findUser` rejected, `reason` will be "`findUser` rejected and we're unhappy". - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException("Upstream error"); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - var result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findResult().then(function(result){ - - }, function(reason){ - - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - var author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong; - }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: function(onFulfillment, onRejection, label) { - var promise = this; - this._onerror = null; - - var thenPromise = new this.constructor(noop, label); - - if (this._state) { - var callbacks = arguments; - config.async(function invokePromiseCallback() { - invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail); - }); - } else { - subscribe(this, thenPromise, onFulfillment, onRejection); - } - - if (config.instrument) { - instrument('chained', promise, thenPromise); - } - - return thenPromise; - }, - - /** - `catch` is simply sugar for `then(null, onRejection)` which makes it the same - as the catch block, of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error("couldn't find that author"); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong; - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'catch': function(onRejection, label) { - return this.then(null, onRejection, label); - }, - - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't effect the return value - } - - findAuthor().finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'finally': function(callback, label) { - var constructor = this.constructor; - - return this.then(function(value) { - return constructor.cast(callback()).then(function(){ - return value; - }); - }, function(reason) { - return constructor.cast(callback()).then(function(){ - throw reason; - }); - }, label); - } - }; - - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value, error, succeeded, failed; - - if (hasCallback) { - try { - value = callback(detail); - succeeded = true; - } catch(e) { - failed = true; - error = e; - } - } else { - value = detail; - succeeded = true; - } - - if (handleThenable(promise, value)) { - return; - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - resolve(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function handleThenable(promise, value) { - var then = null, - resolved; - - try { - if (promise === value) { - throw new TypeError("A promises callback cannot return that same promise."); - } - - if (objectOrFunction(value)) { - then = value.then; - - if (isFunction(then)) { - then.call(value, function(val) { - if (resolved) { return true; } - resolved = true; - - if (value !== val) { - resolve(promise, val); - } else { - fulfill(promise, val); - } - }, function(val) { - if (resolved) { return true; } - resolved = true; - - reject(promise, val); - }, 'derived from: ' + (promise._label || ' unknown promise')); - - return true; - } - } - } catch (error) { - if (resolved) { return true; } - reject(promise, error); - return true; - } - - return false; - } - - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (!handleThenable(promise, value)) { - fulfill(promise, value); - } - } - - function fulfill(promise, value) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = value; - - config.async(publishFulfillment, promise); - } - - function reject(promise, reason) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = reason; - - config.async(publishRejection, promise); - } - - function publishFulfillment(promise) { - publish(promise, promise._state = FULFILLED); - } - - function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._detail); - } - - publish(promise, promise._state = REJECTED); - } - }); -define("rsvp/promise/all", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var isArray = __dependency1__.isArray; - var isNonThenable = __dependency1__.isNonThenable; - - /** - - `RSVP.Promise.all` returns a new promise which is fulfilled with an array of - fulfillment values for the passed promises, or rejects with the reason of the - first passed promise that rejects. It casts all elements of the passed iterable - to promises as it runs this algorithm. - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @for RSVP.Promise - @param {Array} promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function all(entries, label) { - - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to all.'); - } - - var remaining = entries.length; - var results = new Array(remaining); - var entry, pending = true; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfillmentAt(index) { - return function(value) { - results[index] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var index = 0; index < entries.length; index++) { - entry = entries[index]; - if (isNonThenable(entry)) { - results[index] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Constructor.cast(entry).then(fulfillmentAt(index), onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/cast", - ["exports"], - function(__exports__) { - "use strict"; - /** - - `RSVP.Promise.cast` cast coerces its argument to a promise, or returns the - argument if it is already a promise which shares a constructor with the caster; - - Example: - - ```javascript - var promise = RSVP.Promise.resolve(1); - var casted = RSVP.Promise.cast(promise); - - console.log(promise === casted); // true - ``` - - In the case of a promise whose constructor does not match, it is assimilated. - The resulting promise will fulfill or reject based on the outcome of the - promise being casted. - - In the case of a non-promise, a promise which will fulfill with that value is - returned. - - Example: - - ```javascript - var value = 1; // could be a number, boolean, string, undefined... - var casted = RSVP.Promise.cast(value); - - console.log(value === casted); // false - console.log(casted instanceof RSVP.Promise) // true - - casted.then(function(val) { - val === value // => true - }); - ``` - - `RSVP.Promise.cast` is similar to `RSVP.Promise.resolve`, but `RSVP.Promise.cast` differs in the - following ways: - - * `RSVP.Promise.cast` serves as a memory-efficient way of getting a promise, when you - have something that could either be a promise or a value. RSVP.resolve - will have the same effect but will create a new promise wrapper if the - argument is a promise. - * `RSVP.Promise.cast` is a way of casting incoming thenables or promise subclasses to - promises of the exact class specified, so that the resulting object's `then` is - ensured to have the behavior of the constructor you are calling cast on (i.e., RSVP.Promise). - - @method cast - @for RSVP.Promise - @param {Object} object to be casted - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise - */ - - __exports__["default"] = function cast(object, label) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - return new Constructor(function(resolve) { - resolve(object); - }, label); - }; - }); -define("rsvp/promise/race", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - /* global toString */ - - var isArray = __dependency1__.isArray; - var isFunction = __dependency1__.isFunction; - var isNonThenable = __dependency1__.isNonThenable; - - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 2"); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === "promise 2" because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - completed promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first completed promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error("promise 2")); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs because there are rejected promises! - }, function(reason){ - // reason.message === "promise2" because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - @method race - @for RSVP.Promise - @param {Array} promises array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - __exports__["default"] = function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this, entry; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to race.'); - } - - var pending = true; - - function onFulfillment(value) { if (pending) { pending = false; resolve(value); } } - function onRejection(reason) { if (pending) { pending = false; reject(reason); } } - - for (var i = 0; i < entries.length; i++) { - entry = entries[i]; - if (isNonThenable(entry)) { - pending = false; - resolve(entry); - return; - } else { - Constructor.cast(entry).then(onFulfillment, onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/reject", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @for RSVP.Promise - @param {Any} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - __exports__["default"] = function reject(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function (resolve, reject) { - reject(reason); - }, label); - }; - }); -define("rsvp/promise/resolve", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.resolve` returns a promise that will become fulfilled with the passed - `value`. It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @for RSVP.Promise - @param {Any} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - __exports__["default"] = function resolve(value, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - resolve(value); - }, label); - }; - }); -define("rsvp/race", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function race(array, label) { - return Promise.race(array, label); - }; - }); -define("rsvp/reject", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function reject(reason, label) { - return Promise.reject(reason, label); - }; - }); -define("rsvp/resolve", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function resolve(value, label) { - return Promise.resolve(value, label); - }; - }); -define("rsvp/rethrow", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will throw the error - again so the error can be handled by the promise. - - ```javascript - function throws(){ - throw new Error('Whoops!'); - } - - var promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - */ - __exports__["default"] = function rethrow(reason) { - setTimeout(function() { - throw reason; - }); - throw reason; - }; - }); -define("rsvp/utils", - ["exports"], - function(__exports__) { - "use strict"; - function objectOrFunction(x) { - return typeof x === "function" || (typeof x === "object" && x !== null); - } - - __exports__.objectOrFunction = objectOrFunction;function isFunction(x) { - return typeof x === "function"; - } - - __exports__.isFunction = isFunction;function isNonThenable(x) { - return !objectOrFunction(x); - } - - __exports__.isNonThenable = isNonThenable;function isArray(x) { - return Object.prototype.toString.call(x) === "[object Array]"; - } - - __exports__.isArray = isArray;// Date.now is not available in browsers < IE9 - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility - var now = Date.now || function() { return new Date().getTime(); }; - __exports__.now = now; - var keysOf = Object.keys || function(object) { - var result = []; - - for (var prop in object) { - result.push(prop); - } - - return result; - }; - __exports__.keysOf = keysOf; - }); -define("rsvp", - ["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all_settled","./rsvp/race","./rsvp/hash","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/asap","./rsvp/filter","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var EventTarget = __dependency2__["default"]; - var denodeify = __dependency3__["default"]; - var all = __dependency4__["default"]; - var allSettled = __dependency5__["default"]; - var race = __dependency6__["default"]; - var hash = __dependency7__["default"]; - var rethrow = __dependency8__["default"]; - var defer = __dependency9__["default"]; - var config = __dependency10__.config; - var configure = __dependency10__.configure; - var map = __dependency11__["default"]; - var resolve = __dependency12__["default"]; - var reject = __dependency13__["default"]; - var asap = __dependency14__["default"]; - var filter = __dependency15__["default"]; - - config.async = asap; // default async is asap; - - function async(callback, arg) { - config.async(callback, arg); - } - - function on() { - config.on.apply(config, arguments); - } - - function off() { - config.off.apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window.__PROMISE_INSTRUMENTATION__ === 'object') { - var callbacks = window.__PROMISE_INSTRUMENTATION__; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - __exports__.Promise = Promise; - __exports__.EventTarget = EventTarget; - __exports__.all = all; - __exports__.allSettled = allSettled; - __exports__.race = race; - __exports__.hash = hash; - __exports__.rethrow = rethrow; - __exports__.defer = defer; - __exports__.denodeify = denodeify; - __exports__.configure = configure; - __exports__.on = on; - __exports__.off = off; - __exports__.resolve = resolve; - __exports__.reject = reject; - __exports__.async = async; - __exports__.map = map; - __exports__.filter = filter; - }); -global.RSVP = requireModule('rsvp'); -}(window)); -'use strict'; - -var EPUBJS = EPUBJS || {}; -EPUBJS.VERSION = "0.2.3"; - -EPUBJS.plugins = EPUBJS.plugins || {}; - -EPUBJS.filePath = EPUBJS.filePath || "/epubjs/"; - -EPUBJS.Render = {}; - -(function(root) { - - var previousEpub = root.ePub || {}; - - var ePub = root.ePub = function() { - var bookPath, options; - - //-- var book = ePub("path/to/book.epub", { restore: true }) - if(typeof(arguments[0]) != 'undefined' && - typeof arguments[0] === 'string') { - - bookPath = arguments[0]; - - if( arguments[1] && typeof arguments[1] === 'object' ) { - options = arguments[1]; - options.bookPath = bookPath; - } else { - options = { 'bookPath' : bookPath }; - } - - } - - /* - * var book = ePub({ bookPath: "path/to/book.epub", restore: true }); - * - * - OR - - * - * var book = ePub({ restore: true }); - * book.open("path/to/book.epub"); - */ - - if( arguments[0] && typeof arguments[0] === 'object' ) { - options = arguments[0]; - } - - - return new EPUBJS.Book(options); - }; - - _.extend(ePub, { - noConflict : function() { - root.ePub = previousEpub; - return this; - } - }); - - //exports to multiple environments - if (typeof define === 'function' && define.amd) - //AMD - define(function(){ return ePub; }); - else if (typeof module != "undefined" && module.exports) - //Node - module.exports = ePub; - -})(window); - -EPUBJS.Book = function(options){ - - var book = this; - - this.settings = _.defaults(options || {}, { - bookPath : null, - bookKey : null, - packageUrl : null, - storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem' - fromStorage : false, - saved : false, - online : true, - contained : false, - width : null, - height: null, - layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'} - orientation : null, - minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always) - gap: "auto", //-- "auto" or int - version: 1, - restore: false, - reload : false, - goto : false, - styles : {}, - headTags : {}, - withCredentials: false, - render_method: "Iframe" - }); - - this.settings.EPUBJSVERSION = EPUBJS.VERSION; - - this.spinePos = 0; - this.stored = false; - - //-- All Book events for listening - /* - book:ready - book:stored - book:online - book:offline - book:pageChanged - book:loadFailed - book:loadChapterFailed - */ - - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - // EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - // this.getHooks("beforeChapterDisplay"); - - this.online = this.settings.online || navigator.onLine; - this.networkListeners(); - - this.store = false; //-- False if not using storage; - - //-- Determine storage method - //-- Override options: none | ram | websqldatabase | indexeddb | filesystem - - if(this.settings.storage !== false){ - this.storage = new fileStorage.storage(this.settings.storage); - } - - this.ready = { - manifest: new RSVP.defer(), - spine: new RSVP.defer(), - metadata: new RSVP.defer(), - cover: new RSVP.defer(), - toc: new RSVP.defer(), - pageList: new RSVP.defer() - }; - - this.readyPromises = [ - this.ready.manifest.promise, - this.ready.spine.promise, - this.ready.metadata.promise, - this.ready.cover.promise, - this.ready.toc.promise - ]; - - this.pageList = []; - this.pagination = new EPUBJS.Pagination(); - this.pageListReady = this.ready.pageList.promise; - - this.ready.all = RSVP.all(this.readyPromises); - - this.ready.all.then(this._ready.bind(this)); - - // Queue for methods used before rendering - this.isRendered = false; - this._q = EPUBJS.core.queue(this); - // Queue for rendering - this._rendering = false; - this._displayQ = EPUBJS.core.queue(this); - // Queue for going to another location - this._moving = false; - this._gotoQ = EPUBJS.core.queue(this); - - /** - * Creates a new renderer. - * The renderer will handle displaying the content using the method provided in the settings - */ - this.renderer = new EPUBJS.Renderer(this.settings.render_method); - //-- Set the width at which to switch from spreads to single pages - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.setGap(this.settings.gap); - //-- Pass through the renderer events - this.listenToRenderer(this.renderer); - - this.defer_opened = new RSVP.defer(); - this.opened = this.defer_opened.promise; - // BookUrl is optional, but if present start loading process - if(typeof this.settings.bookPath === 'string') { - this.open(this.settings.bookPath, this.settings.reload); - } - - window.addEventListener("beforeunload", this.unload.bind(this), false); - - //-- Listen for these promises: - //-- book.opened.then() - //-- book.rendered.then() -}; - -//-- Check bookUrl and start parsing book Assets or load them from storage -EPUBJS.Book.prototype.open = function(bookPath, forceReload){ - var book = this, - epubpackage, - opened = new RSVP.defer(); - - this.settings.bookPath = bookPath; - - //-- Get a absolute URL from the book path - this.bookUrl = this.urlFrom(bookPath); - - if(this.settings.contained || this.isContained(bookPath)){ - - this.settings.contained = this.contained = true; - - this.bookUrl = ''; - - epubpackage = this.unarchive(bookPath). - then(function(){ - return book.loadPackage(); - }); - - } else { - epubpackage = this.loadPackage(); - } - - if(this.settings.restore && !forceReload && localStorage){ - //-- Will load previous package json, or re-unpack if error - epubpackage.then(function(packageXml) { - var identifier = book.packageIdentifier(packageXml); - var restored = book.restore(identifier); - - if(!restored) { - book.unpack(packageXml); - } - opened.resolve(); - book.defer_opened.resolve(); - }); - - }else{ - - //-- Get package information from epub opf - epubpackage.then(function(packageXml) { - book.unpack(packageXml); - opened.resolve(); - book.defer_opened.resolve(); - }); - } - - //-- If there is network connection, store the books contents - if(this.online && this.settings.storage && !this.settings.contained){ - if(!this.settings.stored) opened.then(book.storeOffline()); - } - - this._registerReplacements(this.renderer); - - return opened.promise; - -}; - -EPUBJS.Book.prototype.loadPackage = function(_containerPath){ - var book = this, - parse = new EPUBJS.Parser(), - containerPath = _containerPath || "META-INF/container.xml", - containerXml, - packageXml; - - if(!this.settings.packageUrl) { //-- provide the packageUrl to skip this step - packageXml = book.loadXml(book.bookUrl + containerPath). - then(function(containerXml){ - return parse.container(containerXml); // Container has path to content - }). - then(function(paths){ - book.settings.contentsPath = book.bookUrl + paths.basePath; - book.settings.packageUrl = book.bookUrl + paths.packagePath; - book.settings.encoding = paths.encoding; - return book.loadXml(book.settings.packageUrl); // Containes manifest, spine and metadata - }); - } else { - packageXml = book.loadXml(book.settings.packageUrl); - } - - packageXml.catch(function(error) { - // handle errors in either of the two requests - console.error("Could not load book at: "+ containerPath); - book.trigger("book:loadFailed", containerPath); - }); - return packageXml; -}; - -EPUBJS.Book.prototype.packageIdentifier = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - return parse.identifier(packageXml); -}; - -EPUBJS.Book.prototype.unpack = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - book.contents = parse.packageContents(packageXml, book.settings.contentsPath); // Extract info from contents - - book.manifest = book.contents.manifest; - book.spine = book.contents.spine; - book.spineIndexByURL = book.contents.spineIndexByURL; - book.metadata = book.contents.metadata; - if(!book.settings.bookKey) { - book.settings.bookKey = book.generateBookKey(book.metadata.identifier); - } - - //-- Set Globbal Layout setting based on metadata - book.globalLayoutProperties = book.parseLayoutProperties(book.metadata); - - if(book.contents.coverPath) { - book.cover = book.contents.cover = book.settings.contentsPath + book.contents.coverPath; - } - - book.spineNodeIndex = book.contents.spineNodeIndex; - - book.ready.manifest.resolve(book.contents.manifest); - book.ready.spine.resolve(book.contents.spine); - book.ready.metadata.resolve(book.contents.metadata); - book.ready.cover.resolve(book.contents.cover); - - - //-- Load the TOC, optional; either the EPUB3 XHTML Navigation file or the EPUB2 NCX file - if(book.contents.navPath) { - book.settings.navUrl = book.settings.contentsPath + book.contents.navPath; - - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.nav(navHtml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - // Load the optional pageList - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.pageList(navHtml, book.spineIndexByURL, book.spine); - }).then(function(pageList){ - var epubcfi = new EPUBJS.EpubCFI(); - var wait = 0; // need to generate a cfi - - // No pageList found - if(pageList.length === 0) { - return; - } - - book.pageList = book.contents.pageList = pageList; - - // Replace HREFs with CFI - book.pageList.forEach(function(pg){ - if(!pg.cfi) { - wait += 1; - epubcfi.generateCfiFromHref(pg.href, book).then(function(cfi){ - pg.cfi = cfi; - pg.packageUrl = book.settings.packageUrl; - - wait -= 1; - if(wait === 0) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - }); - } - }); - - if(!wait) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - - }, function(error) { - book.ready.pageList.resolve([]); - }); - } else if(book.contents.tocPath) { - book.settings.tocUrl = book.settings.contentsPath + book.contents.tocPath; - - book.loadXml(book.settings.tocUrl). - then(function(tocXml){ - return parse.toc(tocXml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - } else { - book.ready.toc.resolve(false); - } - -}; - -EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) { - var box = this.element.getBoundingClientRect(); - var width = _width || this.settings.width || box.width; - var height = _height || this.settings.height || box.height; - var hiddenContainer; - var hiddenEl; - renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - renderer.setGap(this.settings.gap); - - this._registerReplacements(renderer); - if(this.settings.forceSingle) { - renderer.forceSingle(true); - } - - hiddenContainer = document.createElement("div"); - hiddenContainer.style.visibility = "hidden"; - hiddenContainer.style.overflow = "hidden"; - hiddenContainer.style.width = "0"; - hiddenContainer.style.height = "0"; - this.element.appendChild(hiddenContainer); - - hiddenEl = document.createElement("div"); - hiddenEl.style.visibility = "hidden"; - hiddenEl.style.overflow = "hidden"; - hiddenEl.style.width = width + "px";//"0"; - hiddenEl.style.height = height +"px"; //"0"; - hiddenContainer.appendChild(hiddenEl); - - renderer.initialize(hiddenEl); - return hiddenContainer; -}; - -// Generates the pageList array by loading every chapter and paging through them -EPUBJS.Book.prototype.generatePageList = function(width, height){ - var pageList = []; - var pager = new EPUBJS.Renderer(this.settings.render_method, false); //hidden - var hiddenContainer = this.createHiddenRender(pager, width, height); - var deferred = new RSVP.defer(); - var spinePos = -1; - var spineLength = this.spine.length; - var totalPages = 0; - var currentPage = 0; - var nextChapter = function(deferred){ - var chapter; - var next = spinePos + 1; - var done = deferred || new RSVP.defer(); - var loaded; - if(next >= spineLength) { - done.resolve(); - } else { - spinePos = next; - chapter = new EPUBJS.Chapter(this.spine[spinePos], this.store); - pager.displayChapter(chapter, this.globalLayoutProperties).then(function(chap){ - pager.pageMap.forEach(function(item){ - currentPage += 1; - pageList.push({ - "cfi" : item.start, - "page" : currentPage - }); - - }); - - if(pager.pageMap.length % 2 > 0 && - pager.spreads) { - currentPage += 1; // Handle Spreads - pageList.push({ - "cfi" : pager.pageMap[pager.pageMap.length - 1].end, - "page" : currentPage - }); - } - - // Load up the next chapter - setTimeout(function(){ - nextChapter(done); - }, 1); - }); - } - return done.promise; - }.bind(this); - - var finished = nextChapter().then(function(){ - pager.remove(); - this.element.removeChild(hiddenContainer); - deferred.resolve(pageList); - }.bind(this)); - - return deferred.promise; -}; - -// Render out entire book and generate the pagination -// Width and Height are optional and will default to the current dimensions -EPUBJS.Book.prototype.generatePagination = function(width, height) { - var book = this; - var defered = new RSVP.defer(); - - this.ready.spine.promise.then(function(){ - book.generatePageList(width, height).then(function(pageList){ - book.pageList = book.contents.pageList = pageList; - book.pagination.process(pageList); - book.ready.pageList.resolve(book.pageList); - defered.resolve(book.pageList); - }); - }); - - return defered.promise; -}; - -// Process the pagination from a JSON array containing the pagelist -EPUBJS.Book.prototype.loadPagination = function(pagelistJSON) { - var pageList = JSON.parse(pagelistJSON); - - if(pageList && pageList.length) { - this.pageList = pageList; - this.pagination.process(this.pageList); - this.ready.pageList.resolve(this.pageList); - } - return this.pageList; -}; - -EPUBJS.Book.prototype.getPageList = function() { - return this.ready.pageList.promise; -}; - -EPUBJS.Book.prototype.getMetadata = function() { - return this.ready.metadata.promise; -}; - -EPUBJS.Book.prototype.getToc = function() { - return this.ready.toc.promise; -}; - -/* Private Helpers */ - -//-- Listeners for browser events -EPUBJS.Book.prototype.networkListeners = function(){ - var book = this; - - window.addEventListener("offline", function(e) { - book.online = false; - book.trigger("book:offline"); - }, false); - - window.addEventListener("online", function(e) { - book.online = true; - book.trigger("book:online"); - }, false); - -}; - -// Listen to all events the renderer triggers and pass them as book events -EPUBJS.Book.prototype.listenToRenderer = function(renderer){ - var book = this; - renderer.Events.forEach(function(eventName){ - renderer.on(eventName, function(e){ - book.trigger(eventName, e); - }); - }); - - renderer.on("renderer:visibleRangeChanged", function(range) { - var startPage, endPage, percent; - var pageRange = []; - - if(this.pageList.length > 0) { - startPage = this.pagination.pageFromCfi(range.start); - percent = this.pagination.percentageFromPage(startPage); - pageRange.push(startPage); - - if(range.end) { - endPage = this.pagination.pageFromCfi(range.end); - //if(startPage != endPage) { - pageRange.push(endPage); - //} - } - this.trigger("book:pageChanged", { - "anchorPage": startPage, - "percentage": percent, - "pageRange" : pageRange - }); - - // TODO: Add event for first and last page. - // (though last is going to be hard, since it could be several reflowed pages long) - } - }.bind(this)); - - renderer.on("render:loaded", this.loadChange.bind(this)); -}; - -// Listens for load events from the Renderer and checks against the current chapter -// Prevents the Render from loading a different chapter when back button is pressed -EPUBJS.Book.prototype.loadChange = function(url){ - var uri = EPUBJS.core.uri(url); - var chapter; - - if(this.currentChapter) { - chapter = EPUBJS.core.uri(this.currentChapter.absolute); - } - - if(!this._rendering && this.currentChapter && uri.path != chapter.path){ - console.warn("Miss Match", uri.path, this.currentChapter.absolute); - this.goto(uri.filename); - } -}; - -EPUBJS.Book.prototype.unlistenToRenderer = function(renderer){ - renderer.Events.forEach(function(eventName){ - renderer.off(eventName); - } ); -}; - -//-- Choose between a request from store or a request from network -EPUBJS.Book.prototype.loadXml = function(url){ - if(this.settings.fromStorage) { - return this.storage.getXml(url, this.settings.encoding); - } else if(this.settings.contained) { - return this.zip.getXml(url, this.settings.encoding); - }else{ - return EPUBJS.core.request(url, 'xml', this.settings.withCredentials); - } -}; - -//-- Turns a url into a absolute url -EPUBJS.Book.prototype.urlFrom = function(bookPath){ - var uri = EPUBJS.core.uri(bookPath), - absolute = uri.protocol, - fromRoot = uri.path[0] == "/", - location = window.location, - //-- Get URL orgin, try for native or combine - origin = location.origin || location.protocol + "//" + location.host, - baseTag = document.getElementsByTagName('base'), - base; - - - //-- Check is Base tag is set - - if(baseTag.length) { - base = baseTag[0].href; - } - - //-- 1. Check if url is absolute - if(uri.protocol){ - return uri.origin + uri.path; - } - - //-- 2. Check if url starts with /, add base url - if(!absolute && fromRoot){ - return (base || origin) + uri.path; - } - - //-- 3. Or find full path to url and add that - if(!absolute && !fromRoot){ - return EPUBJS.core.resolveUrl(base || location.pathname, uri.path); - } - -}; - - -EPUBJS.Book.prototype.unarchive = function(bookPath){ - var book = this, - unarchived; - - //-- Must use storage - // if(this.settings.storage == false ){ - // this.settings.storage = true; - // this.storage = new fileStorage.storage(); - // } - - this.zip = new EPUBJS.Unarchiver(); - this.store = this.zip; // Use zip storaged in ram - return this.zip.openZip(bookPath); -}; - -//-- Checks if url has a .epub or .zip extension -EPUBJS.Book.prototype.isContained = function(bookUrl){ - var uri = EPUBJS.core.uri(bookUrl); - - if(uri.extension && (uri.extension == "epub" || uri.extension == "zip")){ - return true; - } - - return false; -}; - -//-- Checks if the book can be retrieved from localStorage -EPUBJS.Book.prototype.isSaved = function(bookKey) { - var storedSettings; - - if(!localStorage) { - return false; - } - - storedSettings = localStorage.getItem(bookKey); - - if( !localStorage || - storedSettings === null) { - return false; - } else { - return true; - } -}; - -// Generates the Book Key using the identifer in the manifest or other string provided -EPUBJS.Book.prototype.generateBookKey = function(identifier){ - return "epubjs:" + EPUBJS.VERSION + ":" + window.location.host + ":" + identifier; -}; - -EPUBJS.Book.prototype.saveContents = function(){ - if(!localStorage) { - return false; - } - localStorage.setItem(this.settings.bookKey, JSON.stringify(this.contents)); -}; - -EPUBJS.Book.prototype.removeSavedContents = function() { - if(!localStorage) { - return false; - } - localStorage.removeItem(this.settings.bookKey); -}; - - - -//-- Takes a string or a element -EPUBJS.Book.prototype.renderTo = function(elem){ - var book = this, - rendered; - - if(_.isElement(elem)) { - this.element = elem; - } else if (typeof elem == "string") { - this.element = EPUBJS.core.getEl(elem); - } else { - console.error("Not an Element"); - return; - } - - rendered = this.opened. - then(function(){ - // book.render = new EPUBJS.Renderer[this.settings.renderer](book); - book.renderer.initialize(book.element, book.settings.width, book.settings.height); - book._rendered(); - return book.startDisplay(); - }); - - // rendered.then(null, function(error) { console.error(error); }); - - return rendered; -}; - -EPUBJS.Book.prototype.startDisplay = function(){ - var display; - - if(this.settings.goto) { - display = this.goto(this.settings.goto); - }else if(this.settings.previousLocationCfi) { - display = this.gotoCfi(this.settings.previousLocationCfi); - }else{ - display = this.displayChapter(this.spinePos); - } - - return display; -}; - -EPUBJS.Book.prototype.restore = function(identifier){ - - var book = this, - fetch = ['manifest', 'spine', 'metadata', 'cover', 'toc', 'spineNodeIndex', 'spineIndexByURL', 'globalLayoutProperties'], - reject = false, - bookKey = this.generateBookKey(identifier), - fromStore = localStorage.getItem(bookKey), - len = fetch.length, - i; - - if(this.settings.clearSaved) reject = true; - - if(!reject && fromStore != 'undefined' && fromStore !== null){ - book.contents = JSON.parse(fromStore); - - for(i = 0; i < len; i++) { - var item = fetch[i]; - - if(!book.contents[item]) { - reject = true; - break; - } - book[item] = book.contents[item]; - } - } - - if(reject || !fromStore || !this.contents || !this.settings.contentsPath){ - return false; - }else{ - this.settings.bookKey = bookKey; - this.ready.manifest.resolve(this.manifest); - this.ready.spine.resolve(this.spine); - this.ready.metadata.resolve(this.metadata); - this.ready.cover.resolve(this.cover); - this.ready.toc.resolve(this.toc); - return true; - } - -}; - -EPUBJS.Book.prototype.displayChapter = function(chap, end, deferred){ - var book = this, - render, - cfi, - pos, - store, - defer = deferred || new RSVP.defer(); - - var chapter; - - if(!this.isRendered) { - this._q.enqueue("displayChapter", arguments); - // Reject for now. TODO: pass promise to queue - defer.reject({ - message : "Rendering", - stack : new Error().stack - }); - return defer.promise; - } - - - if(this._rendering || this._rendering) { - // Pass along the current defer - this._displayQ.enqueue("displayChapter", [chap, end, defer]); - return defer.promise; - } - - if(_.isNumber(chap)){ - pos = chap; - }else{ - cfi = new EPUBJS.EpubCFI(chap); - pos = cfi.spinePos; - } - - if(pos < 0 || pos >= this.spine.length){ - console.warn("Not A Valid Location"); - pos = 0; - end = false; - cfi = false; - } - - //-- Create a new chapter - chapter = new EPUBJS.Chapter(this.spine[pos], this.store); - - this._rendering = true; - - render = book.renderer.displayChapter(chapter, this.globalLayoutProperties); - if(cfi) { - book.renderer.gotoCfi(cfi); - } else if(end) { - book.renderer.lastPage(); - } - //-- Success, Clear render queue - render.then(function(rendered){ - // var inwait; - //-- Set the book's spine position - book.spinePos = pos; - - defer.resolve(book.renderer); - - if(!book.settings.fromStorage && - !book.settings.contained) { - book.preloadNextChapter(); - } - - book.currentChapter = chapter; - book._rendering = false; - book._displayQ.dequeue(); - if(book._displayQ.length() === 0) { - book._gotoQ.dequeue(); - } - - }, function(error) { - // handle errors in either of the two requests - console.error("Could not load Chapter: "+ chapter.absolute); - book.trigger("book:chapterLoadFailed", chapter.absolute); - book._rendering = false; - defer.reject(error); - }); - - return defer.promise; -}; - -EPUBJS.Book.prototype.nextPage = function(){ - var next; - - if(!this.isRendered) return this._q.enqueue("nextPage", arguments); - - next = this.renderer.nextPage(); - - if(!next){ - return this.nextChapter(); - } -}; - -EPUBJS.Book.prototype.prevPage = function() { - var prev; - - if(!this.isRendered) return this._q.enqueue("prevPage", arguments); - - prev = this.renderer.prevPage(); - - if(!prev){ - return this.prevChapter(); - } -}; - -EPUBJS.Book.prototype.nextChapter = function() { - var next; - if (this.spinePos < this.spine.length - 1) { - next = this.spinePos + 1; - // Skip non linear chapters - while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') { - next++; - } - if (next < this.spine.length) { - return this.displayChapter(next); - } else { - this.trigger("book:atEnd"); - } - - } else { - this.trigger("book:atEnd"); - } -}; - -EPUBJS.Book.prototype.prevChapter = function() { - var prev; - if (this.spinePos > 0) { - prev = this.spinePos - 1; - while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') { - prev--; - } - if (prev >= 0) { - return this.displayChapter(prev, true); - } else { - this.trigger("book:atStart"); - } - - } else { - this.trigger("book:atStart"); - } -}; - -EPUBJS.Book.prototype.getCurrentLocationCfi = function() { - if(!this.isRendered) return false; - return this.renderer.currentLocationCfi; -}; - -EPUBJS.Book.prototype.goto = function(target){ - - if(target.indexOf("epubcfi(") === 0) { - return this.gotoCfi(target); - } else if(target.indexOf("%") === target.length-1) { - return this.gotoPercentage(parseInt(target.substring(0, target.length-1))/100); - } else if(typeof target === "number" || isNaN(target) === false){ - return this.gotoPage(target); - } else { - return this.gotoHref(target); - } - -}; - -EPUBJS.Book.prototype.gotoCfi = function(cfiString, defer){ - var cfi, - spinePos, - spineItem, - rendered, - deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - console.warn("Not yet Rendered"); - this.settings.previousLocationCfi = cfiString; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - console.warn("Renderer is moving"); - this._gotoQ.enqueue("gotoCfi", [cfiString, deferred]); - return false; - } - - cfi = new EPUBJS.EpubCFI(cfiString); - spinePos = cfi.spinePos; - - if(spinePos == -1) { - return false; - } - - spineItem = this.spine[spinePos]; - promise = deferred.promise; - this._moving = true; - //-- If same chapter only stay on current chapter - if(this.currentChapter && this.spinePos === spinePos){ - this.renderer.gotoCfi(cfi); - this._moving = false; - deferred.resolve(this.renderer.currentLocationCfi); - } else { - - if(!spineItem || spinePos == -1) { - spinePos = 0; - spineItem = this.spine[spinePos]; - } - - this.currentChapter = new EPUBJS.Chapter(spineItem, this.store); - - if(this.currentChapter) { - this.spinePos = spinePos; - render = this.renderer.displayChapter(this.currentChapter, this.globalLayoutProperties); - - this.renderer.gotoCfi(cfi); - render.then(function(rendered){ - this._moving = false; - deferred.resolve(rendered.currentLocationCfi); - }.bind(this)); - } - } - - promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return promise; -}; - -EPUBJS.Book.prototype.gotoHref = function(url, defer){ - var split, chapter, section, relativeURL, spinePos; - var deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - this.settings.goto = url; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - this._gotoQ.enqueue("gotoHref", [url, deferred]); - return false; - } - - split = url.split("#"); - chapter = split[0]; - section = split[1] || false; - // absoluteURL = (chapter.search("://") === -1) ? (this.settings.contentsPath + chapter) : chapter; - relativeURL = chapter.replace(this.settings.contentsPath, ''); - spinePos = this.spineIndexByURL[relativeURL]; - - //-- If link fragment only stay on current chapter - if(!chapter){ - spinePos = this.currentChapter ? this.currentChapter.spinePos : 0; - } - - //-- Check that URL is present in the index, or stop - if(typeof(spinePos) != "number") return false; - - if(!this.currentChapter || spinePos != this.currentChapter.spinePos){ - //-- Load new chapter if different than current - return this.displayChapter(spinePos).then(function(){ - if(section){ - this.renderer.section(section); - } - deferred.resolve(this.renderer.currentLocationCfi); - }.bind(this)); - }else{ - //-- Goto section - if(section) { - this.renderer.section(section); - } else { - // Or jump to the start - this.renderer.firstPage(); - } - deferred.resolve(this.renderer.currentLocationCfi); - } - - deferred.promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Book.prototype.gotoPage = function(pg){ - var cfi = this.pagination.cfiFromPage(pg); - return this.gotoCfi(cfi); -}; - -EPUBJS.Book.prototype.gotoPercentage = function(percent){ - var pg = this.pagination.pageFromPercentage(percent); - return this.gotoPage(pg); -}; - -EPUBJS.Book.prototype.preloadNextChapter = function() { - var next; - var chap = this.spinePos + 1; - - if(chap >= this.spine.length){ - return false; - } - - next = new EPUBJS.Chapter(this.spine[chap]); - if(next) { - EPUBJS.core.request(next.absolute); - } -}; - - -EPUBJS.Book.prototype.storeOffline = function() { - var book = this, - assets = _.values(this.manifest); - - //-- Creates a queue of all items to load - return EPUBJS.storage.batch(assets). - then(function(){ - book.settings.stored = true; - book.trigger("book:stored"); - }); -}; - -EPUBJS.Book.prototype.availableOffline = function() { - return this.settings.stored > 0 ? true : false; -}; - -/* -EPUBJS.Book.prototype.fromStorage = function(stored) { - - if(this.contained) return; - - if(!stored){ - this.online = true; - this.tell("book:online"); - }else{ - if(!this.availableOffline){ - //-- If book hasn't been cached yet, store offline - this.storeOffline(function(){ - this.online = false; - this.tell("book:offline"); - }.bind(this)); - - }else{ - this.online = false; - this.tell("book:offline"); - } - } - -} -*/ - -EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) { - var noreflow = ["color", "background", "background-color"]; - - if(!this.isRendered) return this._q.enqueue("setStyle", arguments); - - this.settings.styles[style] = val; - - this.renderer.setStyle(style, val, prefixed); - - if(noreflow.indexOf(style) === -1) { - // clearTimeout(this.reformatTimeout); - // this.reformatTimeout = setTimeout(function(){ - this.renderer.reformat(); - // }.bind(this), 10); - } -}; - -EPUBJS.Book.prototype.removeStyle = function(style) { - if(!this.isRendered) return this._q.enqueue("removeStyle", arguments); - this.renderer.removeStyle(style); - this.renderer.reformat(); - delete this.settings.styles[style]; -}; - -EPUBJS.Book.prototype.addHeadTag = function(tag, attrs) { - if(!this.isRendered) return this._q.enqueue("addHeadTag", arguments); - this.settings.headTags[tag] = attrs; -}; - -EPUBJS.Book.prototype.useSpreads = function(use) { - console.warn("useSpreads is deprecated, use forceSingle or set a layoutOveride instead"); - if(use === false) { - this.forceSingle(true); - } else { - this.forceSingle(false); - } -}; - -EPUBJS.Book.prototype.forceSingle = function(_use) { - var force = typeof _use === "undefined" ? true : _use; - - this.renderer.forceSingle(force); - this.settings.forceSingle = force; - if(this.isRendered) { - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setMinSpreadWidth = function(width) { - this.settings.minSpreadWidth = width; - if(this.isRendered) { - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setGap = function(gap) { - this.settings.gap = gap; - if(this.isRendered) { - this.renderer.setGap(this.settings.gap); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.chapter = function(path) { - var spinePos = this.spineIndexByURL[path]; - var spineItem; - var chapter; - - if(spinePos){ - spineItem = this.spine[spinePos]; - chapter = new EPUBJS.Chapter(spineItem, this.store); - chapter.load(); - } - return chapter; -}; - -EPUBJS.Book.prototype.unload = function(){ - - if(this.settings.restore && localStorage) { - this.saveContents(); - } - - this.unlistenToRenderer(this.renderer); - - this.trigger("book:unload"); -}; - -EPUBJS.Book.prototype.destroy = function() { - - window.removeEventListener("beforeunload", this.unload); - - if(this.currentChapter) this.currentChapter.unload(); - - this.unload(); - - if(this.render) this.render.remove(); - -}; - -EPUBJS.Book.prototype._ready = function() { - - this.trigger("book:ready"); - -}; - -EPUBJS.Book.prototype._rendered = function(err) { - var book = this; - - this.isRendered = true; - this.trigger("book:rendered"); - - this._q.flush(); -}; - - -EPUBJS.Book.prototype.applyStyles = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyStyles", arguments); - renderer.applyStyles(this.settings.styles); - callback(); -}; - -EPUBJS.Book.prototype.applyHeadTags = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyHeadTags", arguments); - renderer.applyHeadTags(this.settings.headTags); - callback(); -}; - -EPUBJS.Book.prototype._registerReplacements = function(renderer){ - renderer.registerHook("beforeChapterDisplay", this.applyStyles.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", this.applyHeadTags.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", EPUBJS.replace.hrefs.bind(this), true); - - if(this._needsAssetReplacement()) { - - renderer.registerHook("beforeChapterDisplay", [ - EPUBJS.replace.head, - EPUBJS.replace.resources, - EPUBJS.replace.svg - ], true); - - } - -}; - -EPUBJS.Book.prototype._needsAssetReplacement = function(){ - if(this.settings.fromStorage) { - - //-- Filesystem api links are relative, so no need to replace them - if(this.storage.getStorageType() == "filesystem") { - return false; - } - - return true; - - } else if(this.settings.contained) { - - return true; - - } else { - - return false; - - } -}; - - -//-- http://www.idpf.org/epub/fxl/ -EPUBJS.Book.prototype.parseLayoutProperties = function(metadata){ - var layout = (this.layoutOveride && this.layoutOveride.layout) || metadata.layout || "reflowable"; - var spread = (this.layoutOveride && this.layoutOveride.spread) || metadata.spread || "auto"; - var orientation = (this.layoutOveride && this.layoutOveride.orientation) || metadata.orientation || "auto"; - return { - layout : layout, - spread : spread, - orientation : orientation - }; -}; - -//-- Enable binding events to book -RSVP.EventTarget.mixin(EPUBJS.Book.prototype); - -//-- Handle RSVP Errors -RSVP.on('error', function(event) { - //console.error(event, event.detail); -}); - -RSVP.configure('instrument', true); //-- true | will logging out all RSVP rejections -// RSVP.on('created', listener); -// RSVP.on('chained', listener); -// RSVP.on('fulfilled', listener); -RSVP.on('rejected', function(event){ - console.error(event.detail.message, event.detail.stack); -}); - -EPUBJS.Chapter = function(spineObject, store){ - this.href = spineObject.href; - this.absolute = spineObject.url; - this.id = spineObject.id; - this.spinePos = spineObject.index; - this.cfiBase = spineObject.cfiBase; - this.properties = spineObject.properties; - this.manifestProperties = spineObject.manifestProperties; - this.linear = spineObject.linear; - this.pages = 1; - this.store = store; - this.epubcfi = new EPUBJS.EpubCFI(); - this.deferred = new RSVP.defer(); - this.loaded = this.deferred.promise; -}; - - -EPUBJS.Chapter.prototype.load = function(_store){ - var store = _store || this.store; - var promise; - // if(this.store && (!this.book.online || this.book.contained)) - if(store){ - promise = store.get(this.href); - }else{ - promise = EPUBJS.core.request(this.absolute, 'xml'); - } - - promise.then(function(xml){ - this.setDocument(xml); - this.deferred.resolve(this); - }.bind(this)); - - return promise; -}; - -EPUBJS.Chapter.prototype.render = function(_store){ - - return this.load().then(function(doc){ - - var serializer = new XMLSerializer(); - var contents; - var head = doc.head; - var base = doc.createElement("base"); - - base.setAttribute("href", window.location.origin + this.absolute); - head.insertBefore(base, head.firstChild); - contents = serializer.serializeToString(doc); - - return contents; - - }.bind(this)); -}; - -EPUBJS.Chapter.prototype.url = function(_store){ - var deferred = new RSVP.defer(); - var store = _store || this.store; - var loaded; - var chapter = this; - var url; - - if(store){ - if(!this.tempUrl) { - store.getUrl(this.absolute).then(function(url){ - chapter.tempUrl = url; - deferred.resolve(url); - }); - } else { - url = this.tempUrl; - deferred.resolve(url); - } - }else{ - url = this.absolute; - deferred.resolve(url); - } - /* - loaded = EPUBJS.core.request(url, 'xml', false); - loaded.then(function(contents){ - chapter.contents = contents; - deferred.resolve(chapter.absolute); - }, function(error){ - deferred.reject(error); - }); - */ - - return deferred.promise; -}; - -EPUBJS.Chapter.prototype.setPages = function(num){ - this.pages = num; -}; - -EPUBJS.Chapter.prototype.getPages = function(num){ - return this.pages; -}; - -EPUBJS.Chapter.prototype.getID = function(){ - return this.ID; -}; - -EPUBJS.Chapter.prototype.unload = function(store){ - this.document = null; - if(this.tempUrl && store) { - store.revokeUrl(this.tempUrl); - this.tempUrl = false; - } -}; - -EPUBJS.Chapter.prototype.setDocument = function(_document){ - var uri = _document.namespaceURI; - var doctype = _document.doctype; - - // Creates an empty document - this.document = _document.implementation.createDocument( - uri, - null, - null - ); - this.contents = this.document.importNode( - _document.documentElement, //node to import - true //clone its descendants - ); - - this.document.appendChild(this.contents); - - // Fix to apply wgxpath to new document in IE - if(!this.document.evaluate && document.evaluate) { - this.document.evaluate = document.evaluate; - } - - // this.deferred.resolve(this.contents); -}; - -EPUBJS.Chapter.prototype.cfiFromRange = function(_range) { - var range; - var startXpath, endXpath; - var startContainer, endContainer; - var cleanTextContent, cleanEndTextContent; - - // Check for Contents - if(!this.document) return; - startXpath = EPUBJS.core.getElementXPath(_range.startContainer); - // console.log(startContainer) - endXpath = EPUBJS.core.getElementXPath(_range.endContainer); - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!_range.collapsed) { - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } - - range = this.document.createRange(); - // Find Exact Range in original document - if(startContainer) { - try { - range.setStart(startContainer, _range.startOffset); - if(!_range.collapsed && endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } catch (e) { - console.log("missed"); - startContainer = false; - } - - } - - // Fuzzy Match - if(!startContainer) { - console.log("not found, try fuzzy match"); - cleanStartTextContent = EPUBJS.core.cleanStringForXpath(_range.startContainer.textContent); - startXpath = "//text()[contains(.," + cleanStartTextContent + ")]"; - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(startContainer){ - // console.log("Found with Fuzzy"); - range.setStart(startContainer, _range.startOffset); - - if(!_range.collapsed) { - cleanEndTextContent = EPUBJS.core.cleanStringForXpath(_range.endContainer.textContent); - endXpath = "//text()[contains(.," + cleanEndTextContent + ")]"; - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - if(endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } - - } - } - - // Generate the Cfi - return this.epubcfi.generateCfiFromRange(range, this.cfiBase); -}; - -EPUBJS.Chapter.prototype.find = function(_query){ - var chapter = this; - var matches = []; - var query = _query.toLowerCase(); - //var xpath = this.document.evaluate(".//text()[contains(translate(., '"+query.toUpperCase()+"', '"+query+"'),'"+query+"')]", this.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - var find = function(node){ - // Search String - var text = node.textContent.toLowerCase(); - var range = chapter.document.createRange(); - var cfi; - var pos; - var last = -1; - var excerpt; - var limit = 150; - - while (pos != -1) { - pos = text.indexOf(query, last + 1); - - if(pos != -1) { - // If Found, Create Range - range = chapter.document.createRange(); - range.setStart(node, pos); - range.setEnd(node, pos + query.length); - - //Generate CFI - cfi = chapter.cfiFromRange(range); - - // Generate Excerpt - if(node.textContent.length < limit) { - excerpt = node.textContent; - } else { - excerpt = node.textContent.substring(pos-limit/2,pos+limit/2); - excerpt = "..." + excerpt + "..."; - } - - //Add CFI to list - matches.push({ - cfi: cfi, - excerpt: excerpt - }); - } - - last = pos; - } - - }; - - // Grab text nodes - - /* - for ( var i=0 ; i < xpath.snapshotLength; i++ ) { - find(xpath.snapshotItem(i)); - } - */ - - this.textSprint(this.document, function(node){ - find(node); - }); - - - // Return List of CFIs - return matches; -}; - - -EPUBJS.Chapter.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if (node.data && ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; -var EPUBJS = EPUBJS || {}; -EPUBJS.core = {}; - -//-- Get a element for an id -EPUBJS.core.getEl = function(elem) { - return document.getElementById(elem); -}; - -//-- Get all elements for a class -EPUBJS.core.getEls = function(classes) { - return document.getElementsByClassName(classes); -}; - -EPUBJS.core.request = function(url, type, withCredentials) { - var supportsURL = window.URL; - var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer"; - - var deferred = new RSVP.defer(); - - var xhr = new XMLHttpRequest(); - - //-- Check from PDF.js: - // https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js - var xhrPrototype = XMLHttpRequest.prototype; - - if (!('overrideMimeType' in xhrPrototype)) { - // IE10 might have response, but not overrideMimeType - Object.defineProperty(xhrPrototype, 'overrideMimeType', { - value: function xmlHttpRequestOverrideMimeType(mimeType) {} - }); - } - if(withCredentials) { - xhr.withCredentials = true; - } - xhr.open("GET", url, true); - xhr.onreadystatechange = handler; - - if(type == 'blob'){ - xhr.responseType = BLOB_RESPONSE; - } - - if(type == "json") { - xhr.setRequestHeader("Accept", "application/json"); - } - - if(type == 'xml') { - xhr.overrideMimeType('text/xml'); - } - - if(type == "binary") { - xhr.responseType = "arraybuffer"; - } - - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200 || this.responseXML ) { //-- Firefox is reporting 0 for blob urls - var r; - - if(type == 'xml'){ - r = this.responseXML; - }else - if(type == 'json'){ - r = JSON.parse(this.response); - }else - if(type == 'blob'){ - - if(supportsURL) { - r = this.response; - } else { - //-- Safari doesn't support responseType blob, so create a blob from arraybuffer - r = new Blob([this.response]); - } - - }else{ - r = this.response; - } - - deferred.resolve(r); - } else { - deferred.reject({ - message : this.response, - stack : new Error().stack - }); - } - } - } - - return deferred.promise; -}; - -EPUBJS.core.toArray = function(obj) { - var arr = []; - - for (var member in obj) { - var newitm; - if ( obj.hasOwnProperty(member) ) { - newitm = obj[member]; - newitm.ident = member; - arr.push(newitm); - } - } - - return arr; -}; - -//-- Parse the different parts of a url, returning a object -EPUBJS.core.uri = function(url){ - var uri = { - protocol : '', - host : '', - path : '', - origin : '', - directory : '', - base : '', - filename : '', - extension : '', - fragment : '', - href : url - }, - blob = url.indexOf('blob:'), - doubleSlash = url.indexOf('://'), - search = url.indexOf('?'), - fragment = url.indexOf("#"), - withoutProtocol, - dot, - firstSlash; - - if(blob === 0) { - uri.protocol = "blob"; - uri.base = url.indexOf(0, fragment); - return uri; - } - - if(fragment != -1) { - uri.fragment = url.slice(fragment + 1); - url = url.slice(0, fragment); - } - - if(search != -1) { - uri.search = url.slice(search + 1); - url = url.slice(0, search); - href = url; - } - - if(doubleSlash != -1) { - uri.protocol = url.slice(0, doubleSlash); - withoutProtocol = url.slice(doubleSlash+3); - firstSlash = withoutProtocol.indexOf('/'); - - if(firstSlash === -1) { - uri.host = uri.path; - uri.path = ""; - } else { - uri.host = withoutProtocol.slice(0, firstSlash); - uri.path = withoutProtocol.slice(firstSlash); - } - - - uri.origin = uri.protocol + "://" + uri.host; - - uri.directory = EPUBJS.core.folder(uri.path); - - uri.base = uri.origin + uri.directory; - // return origin; - } else { - uri.path = url; - uri.directory = EPUBJS.core.folder(url); - uri.base = uri.directory; - } - - //-- Filename - uri.filename = url.replace(uri.base, ''); - dot = uri.filename.lastIndexOf('.'); - if(dot != -1) { - uri.extension = uri.filename.slice(dot+1); - } - return uri; -}; - -//-- Parse out the folder, will return everything before the last slash - -EPUBJS.core.folder = function(url){ - - var lastSlash = url.lastIndexOf('/'); - - if(lastSlash == -1) var folder = ''; - - folder = url.slice(0, lastSlash + 1); - - return folder; - -}; - -//-- https://github.com/ebidel/filer.js/blob/master/src/filer.js#L128 -EPUBJS.core.dataURLToBlob = function(dataURL) { - var BASE64_MARKER = ';base64,', - parts, contentType, raw, rawLength, uInt8Array; - - if (dataURL.indexOf(BASE64_MARKER) == -1) { - parts = dataURL.split(','); - contentType = parts[0].split(':')[1]; - raw = parts[1]; - - return new Blob([raw], {type: contentType}); - } - - parts = dataURL.split(BASE64_MARKER); - contentType = parts[0].split(':')[1]; - raw = window.atob(parts[1]); - rawLength = raw.length; - - uInt8Array = new Uint8Array(rawLength); - - for (var i = 0; i < rawLength; ++i) { - uInt8Array[i] = raw.charCodeAt(i); - } - - return new Blob([uInt8Array], {type: contentType}); -}; - -//-- Load scripts async: http://stackoverflow.com/questions/7718935/load-scripts-asynchronously -EPUBJS.core.addScript = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('script'); - s.type = 'text/javascript'; - s.async = false; - s.src = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.addScripts = function(srcArr, callback, target) { - var total = srcArr.length, - curr = 0, - cb = function(){ - curr++; - if(total == curr){ - if(callback) callback(); - }else{ - EPUBJS.core.addScript(srcArr[curr], cb, target); - } - }; - - EPUBJS.core.addScript(srcArr[curr], cb, target); -}; - -EPUBJS.core.addCss = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('link'); - s.type = 'text/css'; - s.rel = "stylesheet"; - s.href = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.prefixed = function(unprefixed) { - var vendors = ["Webkit", "Moz", "O", "ms" ], - prefixes = ['-Webkit-', '-moz-', '-o-', '-ms-'], - upper = unprefixed[0].toUpperCase() + unprefixed.slice(1), - length = vendors.length; - - if (typeof(document.body.style[unprefixed]) != 'undefined') { - return unprefixed; - } - - for ( var i=0; i < length; i++ ) { - if (typeof(document.body.style[vendors[i] + upper]) != 'undefined') { - return vendors[i] + upper; - } - } - - return unprefixed; -}; - -EPUBJS.core.resolveUrl = function(base, path) { - var url, - segments = [], - uri = EPUBJS.core.uri(path), - folders = base.split("/"), - paths; - - if(uri.host) { - return path; - } - - folders.pop(); - - paths = path.split("/"); - paths.forEach(function(p){ - if(p === ".."){ - folders.pop(); - }else{ - segments.push(p); - } - }); - - url = folders.concat(segments); - - return url.join("/"); -}; - -// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -EPUBJS.core.uuid = function() { - var d = new Date().getTime(); - var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = (d + Math.random()*16)%16 | 0; - d = Math.floor(d/16); - return (c=='x' ? r : (r&0x7|0x8)).toString(16); - }); - return uuid; -}; - -// Fast quicksort insert for sorted array -- based on: -// http://stackoverflow.com/questions/1344500/efficient-way-to-insert-a-number-into-a-sorted-array-of-numbers -EPUBJS.core.insert = function(item, array, compareFunction) { - var location = EPUBJS.core.locationOf(item, array, compareFunction); - array.splice(location, 0, item); - - return location; -}; - -EPUBJS.core.locationOf = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return pivot; - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared > 0 ? pivot : pivot + 1; - } - - if(compared === 0) { - return pivot; - } - if(compared === -1) { - return EPUBJS.core.locationOf(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.locationOf(item, array, compareFunction, start, pivot); - } -}; - -EPUBJS.core.indexOfSorted = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return -1; // Not found - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared === 0 ? pivot : -1; - } - if(compared === 0) { - return pivot; // Found - } - if(compared === -1) { - return EPUBJS.core.indexOfSorted(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.indexOfSorted(item, array, compareFunction, start, pivot); - } -}; - - -EPUBJS.core.queue = function(_scope){ - var _q = []; - var scope = _scope; - // Add an item to the queue - var enqueue = function(funcName, args, context) { - _q.push({ - "funcName" : funcName, - "args" : args, - "context" : context - }); - return _q; - }; - // Run one item - var dequeue = function(){ - var inwait; - if(_q.length) { - inwait = _q.shift(); - // Defer to any current tasks - // setTimeout(function(){ - scope[inwait.funcName].apply(inwait.context || scope, inwait.args); - // }, 0); - } - }; - - // Run All - var flush = function(){ - while(_q.length) { - dequeue(); - } - }; - // Clear all items in wait - var clear = function(){ - _q = []; - }; - - var length = function(){ - return _q.length; - }; - - return { - "enqueue" : enqueue, - "dequeue" : dequeue, - "flush" : flush, - "clear" : clear, - "length" : length - }; -}; - -// From: https://code.google.com/p/fbug/source/browse/branches/firebug1.10/content/firebug/lib/xpath.js -/** - * Gets an XPath for an element which describes its hierarchical location. - */ -EPUBJS.core.getElementXPath = function(element) { - if (element && element.id) { - return '//*[@id="' + element.id + '"]'; - } else { - return EPUBJS.core.getElementTreeXPath(element); - } -}; - -EPUBJS.core.getElementTreeXPath = function(element) { - var paths = []; - var isXhtml = (element.ownerDocument.documentElement.getAttribute('xmlns') === "http://www.w3.org/1999/xhtml"); - var index, nodeName, tagName, pathIndex; - - if(element.nodeType === Node.TEXT_NODE){ - // index = Array.prototype.indexOf.call(element.parentNode.childNodes, element) + 1; - index = EPUBJS.core.indexOfTextNode(element) + 1; - - paths.push("text()["+index+"]"); - element = element.parentNode; - } - - // Use nodeName (instead of localName) so namespace prefix is included (if any). - for (; element && element.nodeType == 1; element = element.parentNode) - { - index = 0; - for (var sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) - { - // Ignore document type declaration. - if (sibling.nodeType == Node.DOCUMENT_TYPE_NODE) { - continue; - } - if (sibling.nodeName == element.nodeName) { - ++index; - } - } - nodeName = element.nodeName.toLowerCase(); - tagName = (isXhtml ? "xhtml:" + nodeName : nodeName); - pathIndex = (index ? "[" + (index+1) + "]" : ""); - paths.splice(0, 0, tagName + pathIndex); - } - - return paths.length ? "./" + paths.join("/") : null; -}; - -EPUBJS.core.nsResolver = function(prefix) { - var ns = { - 'xhtml' : 'http://www.w3.org/1999/xhtml', - 'epub': 'http://www.idpf.org/2007/ops' - }; - return ns[prefix] || null; -}; - -//https://stackoverflow.com/questions/13482352/xquery-looking-for-text-with-single-quote/13483496#13483496 -EPUBJS.core.cleanStringForXpath = function(str) { - var parts = str.match(/[^'"]+|['"]/g); - parts = parts.map(function(part){ - if (part === "'") { - return '\"\'\"'; // output "'" - } - - if (part === '"') { - return "\'\"\'"; // output '"' - } - return "\'" + part + "\'"; - }); - return "concat(\'\'," + parts.join(",") + ")"; -}; - -EPUBJS.core.indexOfTextNode = function(textNode){ - var parent = textNode.parentNode; - var children = parent.childNodes; - var sib; - var index = -1; - for (var i = 0; i < children.length; i++) { - sib = children[i]; - if(sib.nodeType === Node.TEXT_NODE){ - index++; - } - if(sib == textNode) break; - } - - return index; -}; -EPUBJS.EpubCFI = function(cfiStr){ - if(cfiStr) return this.parse(cfiStr); -}; - -EPUBJS.EpubCFI.prototype.generateChapterComponent = function(_spineNodeIndex, _pos, id) { - var pos = parseInt(_pos), - spineNodeIndex = _spineNodeIndex + 1, - cfi = '/'+spineNodeIndex+'/'; - - cfi += (pos + 1) * 2; - - if(id) cfi += "[" + id + "]"; - - //cfi += "!"; - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.generatePathComponent = function(steps) { - var parts = []; - - steps.forEach(function(part){ - var segment = ''; - segment += (part.index + 1) * 2; - - if(part.id) { - segment += "[" + part.id + "]"; - } - - parts.push(segment); - }); - - return parts.join('/'); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromElement = function(element, chapter) { - var steps = this.pathTo(element); - var path = this.generatePathComponent(steps); - if(!path.length) { - // Start of Chapter - return "epubcfi(" + chapter + "!/4/)"; - } else { - // First Text Node - return "epubcfi(" + chapter + "!" + path + "/1:0)"; - } -}; - -EPUBJS.EpubCFI.prototype.pathTo = function(node) { - var stack = [], - children; - - while(node && node.parentNode !== null && node.parentNode.nodeType != 9) { - children = node.parentNode.children; - - stack.unshift({ - 'id' : node.id, - // 'classList' : node.classList, - 'tagName' : node.tagName, - 'index' : children ? Array.prototype.indexOf.call(children, node) : 0 - }); - - node = node.parentNode; - } - - return stack; -}; - -EPUBJS.EpubCFI.prototype.getChapterComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - - return splitStr[0]; -}; - -EPUBJS.EpubCFI.prototype.getPathComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - var pathComponent = splitStr[1] ? splitStr[1].split(":") : ''; - - return pathComponent[0]; -}; - -EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent = function(cfiStr) { - var splitStr = cfiStr.split(":"); - return splitStr[1] || ''; -}; - - -EPUBJS.EpubCFI.prototype.parse = function(cfiStr) { - var cfi = {}, - chapSegment, - chapterComponent, - pathComponent, - charecterOffsetComponent, - assertion, - chapId, - path, - end, - endInt, - text, - parseStep = function(part){ - var type, index, has_brackets, id; - - type = "element"; - index = parseInt(part) / 2 - 1; - has_brackets = part.match(/\[(.*)\]/); - if(has_brackets && has_brackets[1]){ - id = has_brackets[1]; - } - - return { - "type" : type, - 'index' : index, - 'id' : id || false - }; - }; - - if(typeof cfiStr !== "string") { - return {spinePos: -1}; - } - - cfi.str = cfiStr; - - if(cfiStr.indexOf("epubcfi(") === 0 && cfiStr[cfiStr.length-1] === ")") { - // Remove intial epubcfi( and ending ) - cfiStr = cfiStr.slice(8, cfiStr.length-1); - } - - chapterComponent = this.getChapterComponent(cfiStr); - pathComponent = this.getPathComponent(cfiStr) || ''; - charecterOffsetComponent = this.getCharecterOffsetComponent(cfiStr); - // Make sure this is a valid cfi or return - if(!chapterComponent) { - return {spinePos: -1}; - } - - // Chapter segment is always the second one - chapSegment = chapterComponent.split("/")[2] || ''; - if(!chapSegment) return {spinePos:-1}; - - cfi.spinePos = (parseInt(chapSegment) / 2 - 1 ) || 0; - - chapId = chapSegment.match(/\[(.*)\]/); - - cfi.spineId = chapId ? chapId[1] : false; - - if(pathComponent.indexOf(',') != -1) { - // Handle ranges -- not supported yet - console.warn("CFI Ranges are not supported"); - } - - path = pathComponent.split('/'); - end = path.pop(); - - cfi.steps = []; - - path.forEach(function(part){ - var step; - - if(part) { - step = parseStep(part); - cfi.steps.push(step); - } - }); - - //-- Check if END is a text node or element - endInt = parseInt(end); - if(!isNaN(endInt)) { - - if(endInt % 2 === 0) { // Even = is an element - cfi.steps.push(parseStep(end)); - } else { - cfi.steps.push({ - "type" : "text", - 'index' : (endInt - 1 ) / 2 - }); - } - - } - - assertion = charecterOffsetComponent.match(/\[(.*)\]/); - if(assertion && assertion[1]){ - cfi.characterOffset = parseInt(charecterOffsetComponent.split('[')[0]); - // We arent handling these assertions yet - cfi.textLocationAssertion = assertion[1]; - } else { - cfi.characterOffset = parseInt(charecterOffsetComponent); - } - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.addMarker = function(cfi, _doc, _marker) { - var doc = _doc || document; - var marker = _marker || this.createMarker(doc); - var parent; - var lastStep; - var text; - var split; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - // Find the CFI elements parent - parent = this.findParent(cfi, doc); - - if(!parent) { - // CFI didn't return an element - // Maybe it isnt in the current chapter? - return false; - } - - if(lastStep && lastStep.type === "text") { - text = parent.childNodes[lastStep.index]; - if(cfi.characterOffset){ - split = text.splitText(cfi.characterOffset); - marker.classList.add("EPUBJS-CFI-SPLIT"); - parent.insertBefore(marker, split); - } else { - parent.insertBefore(marker, text); - } - } else { - parent.insertBefore(marker, parent.firstChild); - } - - return marker; -}; - -EPUBJS.EpubCFI.prototype.createMarker = function(_doc) { - var doc = _doc || document; - var element = doc.createElement('span'); - element.id = "EPUBJS-CFI-MARKER:"+ EPUBJS.core.uuid(); - element.classList.add("EPUBJS-CFI-MARKER"); - - return element; -}; - -EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) { - var doc = _doc || document; - // var id = marker.id; - - // Cleanup textnodes if they were split - if(marker.classList.contains("EPUBJS-CFI-SPLIT")){ - nextSib = marker.nextSibling; - prevSib = marker.previousSibling; - if(nextSib && - prevSib && - nextSib.nodeType === 3 && - prevSib.nodeType === 3){ - - prevSib.textContent += nextSib.textContent; - marker.parentNode.removeChild(nextSib); - } - marker.parentNode.removeChild(marker); - } else if(marker.classList.contains("EPUBJS-CFI-MARKER")) { - // Remove only elements added as markers - marker.parentNode.removeChild(marker); - } - -}; - -EPUBJS.EpubCFI.prototype.findParent = function(cfi, _doc) { - var doc = _doc || document, - element = doc.getElementsByTagName('html')[0], - children = Array.prototype.slice.call(element.children), - num, index, part, sections, - text, textBegin, textEnd; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - sections = cfi.steps.slice(0); // Clone steps array - if(!sections.length) { - return doc.getElementsByTagName('body')[0]; - } - - while(sections && sections.length > 0) { - part = sections.shift(); - // Find textNodes Parent - if(part.type === "text") { - text = element.childNodes[part.index]; - element = text.parentNode || element; - // Find element by id if present - } else if(part.id){ - element = doc.getElementById(part.id); - // Find element in parent - }else{ - element = children[part.index]; - } - // Element can't be found - if(typeof element === "undefined") { - console.error("No Element For", part, cfi.str); - return false; - } - // Get current element children and continue through steps - children = Array.prototype.slice.call(element.children); - } - - return element; -}; - -EPUBJS.EpubCFI.prototype.compare = function(cfiOne, cfiTwo) { - if(typeof cfiOne === 'string') { - cfiOne = new EPUBJS.EpubCFI(cfiOne); - } - if(typeof cfiTwo === 'string') { - cfiTwo = new EPUBJS.EpubCFI(cfiTwo); - } - // Compare Spine Positions - if(cfiOne.spinePos > cfiTwo.spinePos) { - return 1; - } - if(cfiOne.spinePos < cfiTwo.spinePos) { - return -1; - } - - - // Compare Each Step in the First item - for (var i = 0; i < cfiOne.steps.length; i++) { - if(!cfiTwo.steps[i]) { - return 1; - } - if(cfiOne.steps[i].index > cfiTwo.steps[i].index) { - return 1; - } - if(cfiOne.steps[i].index < cfiTwo.steps[i].index) { - return -1; - } - // Otherwise continue checking - } - - // All steps in First present in Second - if(cfiOne.steps.length < cfiTwo.steps.length) { - return -1; - } - - // Compare the charecter offset of the text node - if(cfiOne.characterOffset > cfiTwo.characterOffset) { - return 1; - } - if(cfiOne.characterOffset < cfiTwo.characterOffset) { - return -1; - } - - // CFI's are equal - return 0; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromHref = function(href, book) { - var uri = EPUBJS.core.uri(href); - var path = uri.path; - var fragment = uri.fragment; - var spinePos = book.spineIndexByURL[path]; - var loaded; - var deferred = new RSVP.defer(); - var epubcfi = new EPUBJS.EpubCFI(); - var spineItem; - - if(typeof spinePos !== "undefined"){ - spineItem = book.spine[spinePos]; - loaded = book.loadXml(spineItem.url); - loaded.then(function(doc){ - var element = doc.getElementById(fragment); - var cfi; - cfi = epubcfi.generateCfiFromElement(element, spineItem.cfiBase); - deferred.resolve(cfi); - }); - } - - return deferred.promise; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromTextNode = function(anchor, offset, base) { - var parent = anchor.parentNode; - var steps = this.pathTo(parent); - var path = this.generatePathComponent(steps); - var index = 1 + (2 * Array.prototype.indexOf.call(parent.childNodes, anchor)); - return "epubcfi(" + base + "!" + path + "/"+index+":"+(offset || 0)+")"; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRangeAnchor = function(range, base) { - var anchor = range.anchorNode; - var offset = range.anchorOffset; - return this.generateCfiFromTextNode(anchor, offset, base); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRange = function(range, base) { - var start, startElement, startSteps, startPath, startOffset, startIndex; - var end, endElement, endSteps, endPath, endOffset, endIndex; - - start = range.startContainer; - - if(start.nodeType === 3) { // text node - startElement = start.parentNode; - //startIndex = 1 + (2 * Array.prototype.indexOf.call(startElement.childNodes, start)); - startIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(start)); - startSteps = this.pathTo(startElement); - } else if(range.collapsed) { - return this.generateCfiFromElement(start, base); // single element - } else { - startSteps = this.pathTo(start); - } - - startPath = this.generatePathComponent(startSteps); - startOffset = range.startOffset; - - if(!range.collapsed) { - end = range.endContainer; - - if(end.nodeType === 3) { // text node - endElement = end.parentNode; - // endIndex = 1 + (2 * Array.prototype.indexOf.call(endElement.childNodes, end)); - endIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(end)); - - endSteps = this.pathTo(endElement); - } else { - endSteps = this.pathTo(end); - } - - endPath = this.generatePathComponent(endSteps); - endOffset = range.endOffset; - - return "epubcfi(" + base + "!" + startPath + "/" + startIndex + ":" + startOffset + "," + endPath + "/" + endIndex + ":" + endOffset + ")"; - - } else { - return "epubcfi(" + base + "!" + startPath + "/"+ startIndex +":"+ startOffset +")"; - } -}; - -EPUBJS.EpubCFI.prototype.generateXpathFromSteps = function(steps) { - var xpath = [".", "*"]; - - steps.forEach(function(step){ - var position = step.index + 1; - - if(step.id){ - xpath.push("*[position()=" + position + " and @id='" + step.id + "']"); - } else if(step.type === "text") { - xpath.push("text()[" + position + "]"); - } else { - xpath.push("*[" + position + "]"); - } - }); - - return xpath.join("/"); -}; - - -EPUBJS.EpubCFI.prototype.generateRangeFromCfi = function(cfi, _doc) { - var doc = _doc || document; - var range = doc.createRange(); - var lastStep; - var xpath; - var startContainer; - var textLength; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - xpath = this.generateXpathFromSteps(cfi.steps); - - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - startContainer = doc.evaluate(xpath, doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!startContainer) { - return null; - } - - if(startContainer && cfi.characterOffset >= 0) { - textLength = startContainer.length; - - if(cfi.characterOffset < textLength) { - range.setStart(startContainer, cfi.characterOffset); - range.setEnd(startContainer, textLength ); - } else { - console.debug("offset greater than length:", cfi.characterOffset, textLength); - range.setStart(startContainer, textLength - 1 ); - range.setEnd(startContainer, textLength ); - } - } else if(startContainer) { - range.selectNode(startContainer); - } - // doc.defaultView.getSelection().addRange(range); - return range; -}; - -EPUBJS.Events = function(obj, el){ - - this.events = {}; - - if(!el){ - this.el = document.createElement('div'); - }else{ - this.el = el; - } - - obj.createEvent = this.createEvent; - obj.tell = this.tell; - obj.listen = this.listen; - obj.deafen = this.deafen; - obj.listenUntil = this.listenUntil; - - return this; -}; - -EPUBJS.Events.prototype.createEvent = function(evt){ - var e = new CustomEvent(evt); - this.events[evt] = e; - return e; -}; - -EPUBJS.Events.prototype.tell = function(evt, msg){ - var e; - - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - e = this.createEvent(evt); - }else{ - e = this.events[evt]; - } - - if(msg) e.msg = msg; - this.el.dispatchEvent(e); - -}; - -EPUBJS.Events.prototype.listen = function(evt, func, bindto){ - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - this.createEvent(evt); - return; - } - - if(bindto){ - this.el.addEventListener(evt, func.bind(bindto), false); - }else{ - this.el.addEventListener(evt, func, false); - } - -}; - -EPUBJS.Events.prototype.deafen = function(evt, func){ - this.el.removeEventListener(evt, func, false); -}; - -EPUBJS.Events.prototype.listenUntil = function(OnEvt, OffEvt, func, bindto){ - this.listen(OnEvt, func, bindto); - - function unlisten(){ - this.deafen(OnEvt, func); - this.deafen(OffEvt, unlisten); - } - - this.listen(OffEvt, unlisten, this); -}; -EPUBJS.hooks = {}; -EPUBJS.Hooks = (function(){ - function hooks(){} - - //-- Get pre-registered hooks - hooks.prototype.getHooks = function(){ - var plugs; - this.hooks = {}; - Array.prototype.slice.call(arguments).forEach(function(arg){ - this.hooks[arg] = []; - }, this); - - for (var plugType in this.hooks) { - plugs = _.values(EPUBJS.hooks[plugType]); - - plugs.forEach(function(hook){ - this.registerHook(plugType, hook); - }, this); - } - }; - - //-- Hooks allow for injecting async functions that must all complete before continuing - // Functions must have a callback as their first argument. - hooks.prototype.registerHook = function(type, toAdd, toFront){ - - if(typeof(this.hooks[type]) != "undefined"){ - - if(typeof(toAdd) === "function"){ - if(toFront) { - this.hooks[type].unshift(toAdd); - }else{ - this.hooks[type].push(toAdd); - } - }else if(Array.isArray(toAdd)){ - toAdd.forEach(function(hook){ - if(toFront) { - this.hooks[type].unshift(hook); - }else{ - this.hooks[type].push(hook); - } - }, this); - } - }else{ - //-- Allows for undefined hooks, but maybe this should error? - this.hooks[type] = [func]; - } - }; - - hooks.prototype.triggerHooks = function(type, callback, passed){ - var hooks, count; - - if(typeof(this.hooks[type]) == "undefined") return false; - - hooks = this.hooks[type]; - - count = hooks.length; - if(count === 0 && callback) { - callback(); - } - - function countdown(){ - count--; - if(count <= 0 && callback) callback(); - } - - hooks.forEach(function(hook){ - hook(countdown, passed); - }); - }; - - return { - register: function(name) { - if(EPUBJS.hooks[name] === undefined) { EPUBJS.hooks[name] = {}; } - if(typeof EPUBJS.hooks[name] !== 'object') { throw "Already registered: "+name; } - return EPUBJS.hooks[name]; - }, - mixin: function(object) { - for (var prop in hooks.prototype) { - object[prop] = hooks.prototype[prop]; - } - } - }; -})(); - - -EPUBJS.Layout = EPUBJS.Layout || {}; - -EPUBJS.Layout.Reflowable = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){ - // Get the prefixed CSS commands - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - //-- Check the width and create even width columns - var width = Math.floor(_width); - // var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - this.documentElement = documentElement; - //-- Single Page - this.spreadWidth = (width + gap); - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnWidth] = width+"px"; - documentElement.style[columnGap] = gap+"px"; - this.colWidth = width; - this.gap = gap; - - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.Reflowable.prototype.calculatePages = function() { - var totalWidth, displayedPages; - this.documentElement.style.width = "auto"; //-- reset width for calculations - totalWidth = this.documentElement.scrollWidth; - displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - return { - displayedPages : displayedPages, - pageCount : displayedPages - }; -}; - -EPUBJS.Layout.ReflowableSpreads = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){ - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - var divisor = 2, - cutoff = 800; - - //-- Check the width and create even width columns - var fullWidth = Math.floor(_width); - var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1; - - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - - //-- Double Page - var colWidth = Math.floor((width - gap) / divisor); - - this.documentElement = documentElement; - this.spreadWidth = (colWidth + gap) * divisor; - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnGap] = gap+"px"; - documentElement.style[columnWidth] = colWidth+"px"; - - this.colWidth = colWidth; - this.gap = gap; - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function() { - var totalWidth = this.documentElement.scrollWidth; - var displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - //-- Add a page to the width of the document to account an for odd number of pages - this.documentElement.style.width = ((displayedPages * this.spreadWidth) - this.gap) + "px"; - - return { - displayedPages : displayedPages, - pageCount : displayedPages * 2 - }; -}; - -EPUBJS.Layout.Fixed = function(){ - this.documentElement = null; -}; - -EPUBJS.Layout.Fixed.prototype.format = function(documentElement, _width, _height, _gap){ - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var viewport = documentElement.querySelector("[name=viewport"); - var content; - var contents; - var width, height; - this.documentElement = documentElement; - /** - * check for the viewport size - * - */ - if(viewport && viewport.hasAttribute("content")) { - content = viewport.getAttribute("content"); - contents = content.split(','); - if(contents[0]){ - width = contents[0].replace("width=", ''); - } - if(contents[1]){ - height = contents[1].replace("height=", ''); - } - } - - //-- Adjust width and height - documentElement.style.width = width + "px" || "auto"; - documentElement.style.height = height + "px" || "auto"; - - //-- Remove columns - documentElement.style[columnWidth] = "auto"; - - //-- Scroll - documentElement.style.overflow = "auto"; - - this.colWidth = width; - this.gap = 0; - - return { - pageWidth : width, - pageHeight : height - }; - -}; - -EPUBJS.Layout.Fixed.prototype.calculatePages = function(){ - return { - displayedPages : 1, - pageCount : 1 - }; -}; - -EPUBJS.Pagination = function(pageList) { - this.pages = []; - this.locations = []; - this.epubcfi = new EPUBJS.EpubCFI(); - if(pageList && pageList.length) { - this.process(pageList); - } -}; - -EPUBJS.Pagination.prototype.process = function(pageList){ - pageList.forEach(function(item){ - this.pages.push(item.page); - this.locations.push(item.cfi); - }, this); - - this.pageList = pageList; - this.firstPage = parseInt(this.pages[0]); - this.lastPage = parseInt(this.pages[this.pages.length-1]); - this.totalPages = this.lastPage - this.firstPage; -}; - -EPUBJS.Pagination.prototype.pageFromCfi = function(cfi){ - var pg = -1; - - // Check if the pageList has not been set yet - if(this.locations.length === 0) { - return -1; - } - - // TODO: check if CFI is valid? - - // check if the cfi is in the location list - // var index = this.locations.indexOf(cfi); - var index = EPUBJS.core.indexOfSorted(cfi, this.locations, this.epubcfi.compare); - if(index != -1 && index < (this.pages.length-1) ) { - pg = this.pages[index]; - } else { - // Otherwise add it to the list of locations - // Insert it in the correct position in the locations page - //index = EPUBJS.core.insert(cfi, this.locations, this.epubcfi.compare); - index = EPUBJS.core.locationOf(cfi, this.locations, this.epubcfi.compare); - // Get the page at the location just before the new one, or return the first - pg = index-1 >= 0 ? this.pages[index-1] : this.pages[0]; - if(pg !== undefined) { - // Add the new page in so that the locations and page array match up - //this.pages.splice(index, 0, pg); - } else { - pg = -1; - } - - } - return pg; -}; - -EPUBJS.Pagination.prototype.cfiFromPage = function(pg){ - var cfi = -1; - // check that pg is an int - if(typeof pg != "number"){ - pg = parseInt(pg); - } - - // check if the cfi is in the page list - // Pages could be unsorted. - var index = this.pages.indexOf(pg); - if(index != -1) { - cfi = this.locations[index]; - } - // TODO: handle pages not in the list - return cfi; -}; - -EPUBJS.Pagination.prototype.pageFromPercentage = function(percent){ - var pg = Math.round(this.totalPages * percent); - return pg; -}; - -// Returns a value between 0 - 1 corresponding to the location of a page -EPUBJS.Pagination.prototype.percentageFromPage = function(pg){ - var percentage = (pg - this.firstPage) / this.totalPages; - return Math.round(percentage * 1000) / 1000; -}; - -// Returns a value between 0 - 1 corresponding to the location of a cfi -EPUBJS.Pagination.prototype.percentageFromCfi = function(cfi){ - var pg = this.pageFromCfi(cfi); - var percentage = this.percentageFromPage(pg); - return percentage; -}; -EPUBJS.Parser = function(baseUrl){ - this.baseUrl = baseUrl || ''; -}; - -EPUBJS.Parser.prototype.container = function(containerXml){ - //-- - var rootfile, fullpath, folder, encoding; - - if(!containerXml) { - console.error("Container File Not Found"); - return; - } - - rootfile = containerXml.querySelector("rootfile"); - - if(!rootfile) { - console.error("No RootFile Found"); - return; - } - - fullpath = rootfile.getAttribute('full-path'); - folder = EPUBJS.core.uri(fullpath).directory; - encoding = containerXml.xmlEncoding; - - //-- Now that we have the path we can parse the contents - return { - 'packagePath' : fullpath, - 'basePath' : folder, - 'encoding' : encoding - }; -}; - -EPUBJS.Parser.prototype.identifier = function(packageXml){ - var metadataNode; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - return this.getElementText(metadataNode, "identifier"); -}; - -EPUBJS.Parser.prototype.packageContents = function(packageXml, baseUrl){ - var parse = this; - var metadataNode, manifestNode, spineNode; - var manifest, navPath, tocPath, coverPath; - var spineNodeIndex; - var spine; - var spineIndexByURL; - - if(baseUrl) this.baseUrl = baseUrl; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - manifestNode = packageXml.querySelector("manifest"); - if(!manifestNode) { - console.error("No Manifest Found"); - return; - } - - spineNode = packageXml.querySelector("spine"); - if(!spineNode) { - console.error("No Spine Found"); - return; - } - - manifest = parse.manifest(manifestNode); - navPath = parse.findNavPath(manifestNode); - tocPath = parse.findTocPath(manifestNode, spineNode); - coverPath = parse.findCoverPath(manifestNode); - - spineNodeIndex = Array.prototype.indexOf.call(spineNode.parentNode.childNodes, spineNode); - - spine = parse.spine(spineNode, manifest); - - spineIndexByURL = {}; - spine.forEach(function(item){ - spineIndexByURL[item.href] = item.index; - }); - - return { - 'metadata' : parse.metadata(metadataNode), - 'spine' : spine, - 'manifest' : manifest, - 'navPath' : navPath, - 'tocPath' : tocPath, - 'coverPath': coverPath, - 'spineNodeIndex' : spineNodeIndex, - 'spineIndexByURL' : spineIndexByURL - }; -}; - -//-- Find TOC NAV -EPUBJS.Parser.prototype.findNavPath = function(manifestNode){ - // Find item with property 'nav' - // Should catch nav irregardless of order - var node = manifestNode.querySelector("item[properties$='nav'], item[properties^='nav '], item[properties*=' nav ']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Find TOC NCX: media-type="application/x-dtbncx+xml" href="toc.ncx" -EPUBJS.Parser.prototype.findTocPath = function(manifestNode, spineNode){ - var node = manifestNode.querySelector("item[media-type='application/x-dtbncx+xml']"); - var tocId; - - // If we can't find the toc by media-type then try to look for id of the item in the spine attributes as - // according to http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.4.1.2, - // "The item that describes the NCX must be referenced by the spine toc attribute." - if (!node) { - tocId = spineNode.getAttribute("toc"); - if(tocId) { - node = manifestNode.querySelector("item[id='" + tocId + "']"); - } - } - - return node ? node.getAttribute('href') : false; -}; - -//-- Find Cover: -EPUBJS.Parser.prototype.findCoverPath = function(manifestNode){ - var node = manifestNode.querySelector("item[properties='cover-image']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Expanded to match Readium web components -EPUBJS.Parser.prototype.metadata = function(xml){ - var metadata = {}, - p = this; - - metadata.bookTitle = p.getElementText(xml, 'title'); - metadata.creator = p.getElementText(xml, 'creator'); - metadata.description = p.getElementText(xml, 'description'); - - metadata.pubdate = p.getElementText(xml, 'date'); - - metadata.publisher = p.getElementText(xml, 'publisher'); - - metadata.identifier = p.getElementText(xml, "identifier"); - metadata.language = p.getElementText(xml, "language"); - metadata.rights = p.getElementText(xml, "rights"); - - metadata.modified_date = p.querySelectorText(xml, "meta[property='dcterms:modified']"); - metadata.layout = p.querySelectorText(xml, "meta[property='rendition:layout']"); - metadata.orientation = p.querySelectorText(xml, "meta[property='rendition:orientation']"); - metadata.spread = p.querySelectorText(xml, "meta[property='rendition:spread']"); - // metadata.page_prog_dir = packageXml.querySelector("spine").getAttribute("page-progression-direction"); - - return metadata; -}; - -EPUBJS.Parser.prototype.getElementText = function(xml, tag){ - var found = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag), - el; - - if(!found || found.length === 0) return ''; - - el = found[0]; - - if(el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; - -}; - -EPUBJS.Parser.prototype.querySelectorText = function(xml, q){ - var el = xml.querySelector(q); - - if(el && el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; -}; - -EPUBJS.Parser.prototype.manifest = function(manifestXml){ - var baseUrl = this.baseUrl, - manifest = {}; - - //-- Turn items into an array - var selected = manifestXml.querySelectorAll("item"), - items = Array.prototype.slice.call(selected); - - //-- Create an object with the id as key - items.forEach(function(item){ - var id = item.getAttribute('id'), - href = item.getAttribute('href') || '', - type = item.getAttribute('media-type') || '', - properties = item.getAttribute('properties') || ''; - - manifest[id] = { - 'href' : href, - 'url' : baseUrl + href, //-- Absolute URL for loading with a web worker - 'type' : type, - 'properties' : properties - }; - - }); - - return manifest; - -}; - -EPUBJS.Parser.prototype.spine = function(spineXml, manifest){ - var spine = []; - - var selected = spineXml.getElementsByTagName("itemref"), - items = Array.prototype.slice.call(selected); - - var spineNodeIndex = Array.prototype.indexOf.call(spineXml.parentNode.childNodes, spineXml); - - var epubcfi = new EPUBJS.EpubCFI(); - - //-- Add to array to mantain ordering and cross reference with manifest - items.forEach(function(item, index){ - var Id = item.getAttribute('idref'); - var cfiBase = epubcfi.generateChapterComponent(spineNodeIndex, index, Id); - var props = item.getAttribute('properties') || ''; - var propArray = props.length ? props.split(' ') : []; - var manifestProps = manifest[Id].properties; - var manifestPropArray = manifestProps.length ? manifestProps.split(' ') : []; - var vert = { - 'id' : Id, - 'linear' : item.getAttribute('linear') || '', - 'properties' : propArray, - 'manifestProperties' : manifestPropArray, - 'href' : manifest[Id].href, - 'url' : manifest[Id].url, - 'index' : index, - 'cfiBase' : cfiBase, - 'cfi' : "epub(" + cfiBase + ")" - }; - spine.push(vert); - }); - - return spine; -}; - -EPUBJS.Parser.prototype.nav = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="toc"]'), //-- [*|type="toc"] * Doesn't seem to work - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getTOC(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - split = href.split("#"), - baseUrl = split[0], - subitems = getTOC(item), - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - item.setAttribute('id', id); // Ensure all elements have an id - list.push({ - "id": id, - "href": href, - "label": text, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - }); - - return list; - } - - return getTOC(navEl); -}; - -EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){ - var navMap = tocXml.querySelector("navMap"); - if(!navMap) return []; - - function getTOC(parent){ - var list = [], - snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), - length = snapshot.snapshotLength; - - if(length === 0) return []; - - for ( var i=length-1 ; i >= 0; i-- ) { - var item = snapshot.snapshotItem(i); - - var id = item.getAttribute('id') || false, - content = item.querySelector("content"), - src = content.getAttribute('src'), - navLabel = item.querySelector("navLabel"), - text = navLabel.textContent ? navLabel.textContent : "", - split = src.split("#"), - baseUrl = split[0], - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - subitems = getTOC(item), - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - list.unshift({ - "id": id, - "href": src, - "label": text, - "spinePos": spinePos, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - } - - return list; - } - - return getTOC(navMap); -}; - -EPUBJS.Parser.prototype.pageList = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="page-list"]'), - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getPages(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - page = parseInt(text), - isCfi = href.indexOf("epubcfi"), - split, - packageUrl, - cfi; - - if(isCfi != -1) { - split = href.split("#"); - packageUrl = split[0]; - cfi = split.length > 1 ? split[1] : false; - list.push({ - "cfi" : cfi, - "href" : href, - "packageUrl" : packageUrl, - "page" : page - }); - } else { - list.push({ - "href" : href, - "page" : page - }); - } - - }); - - return list; - } - - return getPages(navEl); -}; - -EPUBJS.Render.Iframe = function() { - this.iframe = null; - this.document = null; - this.window = null; - this.docEl = null; - this.bodyEl = null; - - this.leftPos = 0; - this.pageWidth = 0; -}; - -//-- Build up any html needed -EPUBJS.Render.Iframe.prototype.create = function(){ - this.iframe = document.createElement('iframe'); - this.iframe.id = "epubjs-iframe:" + EPUBJS.core.uuid(); - this.iframe.scrolling = "no"; - this.iframe.seamless = "seamless"; - // Back up if seamless isn't supported - this.iframe.style.border = "none"; - - this.iframe.addEventListener("load", this.loaded.bind(this), false); - return this.iframe; -}; - -/** -* Sets the source of the iframe with the given URL string -* Takes: URL string -* Returns: promise with document element -*/ -EPUBJS.Render.Iframe.prototype.load = function(chapter){ - var render = this, - deferred = new RSVP.defer(); - - chapter.url().then(function(url){ - // Reset the scroll position - render.leftPos = 0; - - if(this.window) { - this.unload(); - } - - this.iframe.onload = function(e) { - render.document = render.iframe.contentDocument; - render.docEl = render.document.documentElement; - render.headEl = render.document.head; - render.bodyEl = render.document.body || render.document.querySelector("body"); - render.window = render.iframe.contentWindow; - - render.window.addEventListener("resize", render.resized.bind(render), false); - - //-- Clear Margins - if(render.bodyEl) { - render.bodyEl.style.margin = "0"; - } - - deferred.resolve(render.docEl); - }; - - this.iframe.onerror = function(e) { - //console.error("Error Loading Contents", e); - deferred.reject({ - message : "Error Loading Contents: " + e, - stack : new Error().stack - }); - }; - - this.iframe.contentWindow.location.replace(url); - - }.bind(this)); - - return deferred.promise; -}; - - -EPUBJS.Render.Iframe.prototype.loaded = function(v){ - var url = this.iframe.contentWindow.location.href; - if(url != "about:blank"){ - this.trigger("render:loaded", url); - } -}; - -// Resize the iframe to the given width and height -EPUBJS.Render.Iframe.prototype.resize = function(width, height){ - var iframeBox; - - if(!this.iframe) return; - - this.iframe.height = height; - - if(!isNaN(width) && width % 2 !== 0){ - width += 1; //-- Prevent cutting off edges of text in columns - } - - this.iframe.width = width; - // Get the fractional height and width of the iframe - // Default to orginal if bounding rect is 0 - this.width = this.iframe.getBoundingClientRect().width || width; - this.height = this.iframe.getBoundingClientRect().height || height; -}; - - -EPUBJS.Render.Iframe.prototype.resized = function(e){ - // Get the fractional height and width of the iframe - this.width = this.iframe.getBoundingClientRect().width; - this.height = this.iframe.getBoundingClientRect().height; -}; - -EPUBJS.Render.Iframe.prototype.totalWidth = function(){ - return this.docEl.scrollWidth; -}; - -EPUBJS.Render.Iframe.prototype.totalHeight = function(){ - return this.docEl.scrollHeight; -}; - -EPUBJS.Render.Iframe.prototype.setPageDimensions = function(pageWidth, pageHeight){ - this.pageWidth = pageWidth; - this.pageHeight = pageHeight; - //-- Add a page to the width of the document to account an for odd number of pages - // this.docEl.style.width = this.docEl.scrollWidth + pageWidth + "px"; -}; - -EPUBJS.Render.Iframe.prototype.setLeft = function(leftPos){ - // this.bodyEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style[EPUBJS.Render.Iframe.transform] = 'translate('+ (-leftPos) + 'px, 0)'; - this.document.defaultView.scrollTo(leftPos, 0); -}; - -EPUBJS.Render.Iframe.prototype.setStyle = function(style, val, prefixed){ - if(prefixed) { - style = EPUBJS.core.prefixed(style); - } - - if(this.bodyEl) this.bodyEl.style[style] = val; -}; - -EPUBJS.Render.Iframe.prototype.removeStyle = function(style){ - - if(this.bodyEl) this.bodyEl.style[style] = ''; - -}; - -EPUBJS.Render.Iframe.prototype.addHeadTag = function(tag, attrs, _doc) { - var doc = _doc || this.document; - var tagEl = doc.createElement(tag); - var headEl = doc.head; - - for(var attr in attrs) { - tagEl.setAttribute(attr, attrs[attr]); - } - - if(headEl) headEl.insertBefore(tagEl, headEl.firstChild); -}; - -EPUBJS.Render.Iframe.prototype.page = function(pg){ - this.leftPos = this.pageWidth * (pg-1); //-- pages start at 1 - this.setLeft(this.leftPos); -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByElement = function(el){ - var left, pg; - if(!el) return; - - left = this.leftPos + el.getBoundingClientRect().left; //-- Calculate left offset compaired to scrolled position - - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByRect = function(boundingClientRect){ - var left, pg; - - left = this.leftPos + boundingClientRect.left; //-- Calculate left offset compaired to scrolled position - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -// Return the root element of the content -EPUBJS.Render.Iframe.prototype.getBaseElement = function(){ - return this.bodyEl; -}; - -// Checks if an element is on the screen -EPUBJS.Render.Iframe.prototype.isElementVisible = function(el){ - var rect; - var left; - - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - left = rect.left; //+ rect.width; - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - left >= 0 && - left < this.pageWidth ) { - return true; - } - } - - return false; -}; - - -EPUBJS.Render.Iframe.prototype.scroll = function(bool){ - if(bool) { - this.iframe.scrolling = "yes"; - } else { - this.iframe.scrolling = "no"; - } -}; - -// Cleanup event listeners -EPUBJS.Render.Iframe.prototype.unload = function(){ - this.window.removeEventListener("resize", this.resized); -}; - -//-- Enable binding events to Render -RSVP.EventTarget.mixin(EPUBJS.Render.Iframe.prototype); -EPUBJS.Renderer = function(renderMethod, hidden) { - // Dom events to listen for - this.listenedEvents = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click"]; - this.upEvent = "mouseup"; - this.downEvent = "mousedown"; - if('ontouchstart' in document.documentElement) { - this.listenedEvents.push("touchstart", "touchend"); - this.upEvent = "touchend"; - this.downEvent = "touchstart"; - } - /** - * Setup a render method. - * Options are: Iframe - */ - if(renderMethod && typeof(EPUBJS.Render[renderMethod]) != "undefined"){ - this.render = new EPUBJS.Render[renderMethod](); - } else { - console.error("Not a Valid Rendering Method"); - } - - // Listen for load events - this.render.on("render:loaded", this.loaded.bind(this)); - - // Cached for replacement urls from storage - this.caches = {}; - - // Blank Cfi for Parsing - this.epubcfi = new EPUBJS.EpubCFI(); - - this.spreads = true; - this.isForcedSingle = false; - this.resized = _.debounce(this.onResized.bind(this), 100); - - this.layoutSettings = {}; - - this.hidden = hidden || false; - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - this.getHooks("beforeChapterDisplay"); - - //-- Queue up page changes if page map isn't ready - this._q = EPUBJS.core.queue(this); - - this._moving = false; - -}; - -//-- Renderer events for listening -EPUBJS.Renderer.prototype.Events = [ - "renderer:keydown", - "renderer:keyup", - "renderer:keypressed", - "renderer:mouseup", - "renderer:mousedown", - "renderer:click", - "renderer:touchstart", - "renderer:touchend", - "renderer:selected", - "renderer:chapterUnloaded", - "renderer:chapterDisplayed", - "renderer:locationChanged", - "renderer:visibleLocationChanged", - "renderer:resized", - "renderer:spreads" -]; - -/** -* Creates an element to render to. -* Resizes to passed width and height or to the elements size -*/ -EPUBJS.Renderer.prototype.initialize = function(element, width, height){ - this.container = element; - this.element = this.render.create(); - - this.initWidth = width; - this.initHeight = height; - - this.width = width || this.container.clientWidth; - this.height = height || this.container.clientHeight; - - this.container.appendChild(this.element); - - if(width && height){ - this.render.resize(this.width, this.height); - } else { - this.render.resize('100%', '100%'); - } - - document.addEventListener("orientationchange", this.onResized); -}; - -/** -* Display a chapter -* Takes: chapter object, global layout settings -* Returns: Promise with passed Renderer after pages has loaded -*/ -EPUBJS.Renderer.prototype.displayChapter = function(chapter, globalLayout){ - var store = false; - if(this._moving) { - console.error("Rendering In Progress"); - return; - } - this._moving = true; - // Get the url string from the chapter (may be from storage) - return chapter.url(). - then(function(url) { - - // Unload the previous chapter listener - if(this.currentChapter) { - this.currentChapter.unload(); // Remove stored blobs - - if(this.render.window){ - this.render.window.removeEventListener("resize", this.resized); - } - - this.removeEventListeners(); - this.removeSelectionListeners(); - this.trigger("renderer:chapterUnloaded"); - this.contents = null; - this.doc = null; - this.pageMap = null; - } - - this.currentChapter = chapter; - this.chapterPos = 1; - this.currentChapterCfiBase = chapter.cfiBase; - - this.layoutSettings = this.reconcileLayoutSettings(globalLayout, chapter.properties); - return this.load(chapter); - - }.bind(this)); - -}; - -/** -* Loads a url (string) and renders it, -* attaching event listeners and triggering hooks. -* Returns: Promise with the rendered contents. -*/ - -EPUBJS.Renderer.prototype.load = function(url){ - var deferred = new RSVP.defer(); - var loaded; - - // Switch to the required layout method for the settings - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - - this.visible(false); - - render = this.render.load(url); - - render.then(function(contents) { - var formated; - this.currentChapter.setDocument(this.render.document); - this.contents = contents; - this.doc = this.render.document; - - // Format the contents using the current layout method - this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap); - this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight); - - // window.addEventListener("orientationchange", this.onResized.bind(this), false); - if(!this.initWidth && !this.initHeight){ - this.render.window.addEventListener("resize", this.resized, false); - } - - this.addEventListeners(); - this.addSelectionListeners(); - - //-- Trigger registered hooks before displaying - this.beforeDisplay(function(){ - var pages = this.layout.calculatePages(); - var msg = this.currentChapter; - var queued = this._q.length(); - this._moving = false; - - this.updatePages(pages); - - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - - if(queued === 0) { - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - } - - msg.cfi = this.currentLocationCfi; //TODO: why is this cfi passed to chapterDisplayed - this.trigger("renderer:chapterDisplayed", msg); - - this.visible(true); - - deferred.resolve(this); //-- why does this return the renderer? - }.bind(this)); - - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Renderer.prototype.loaded = function(url){ - this.trigger("render:loaded", url); - // var uri = EPUBJS.core.uri(url); - // var relative = uri.path.replace(book.bookUrl, ''); - // console.log(url, uri, relative); -}; - -/** -* Reconciles the current chapters layout properies with -* the global layout properities. -* Takes: global layout settings object, chapter properties string -* Returns: Object with layout properties -*/ -EPUBJS.Renderer.prototype.reconcileLayoutSettings = function(global, chapter){ - var settings = {}; - - //-- Get the global defaults - for (var attr in global) { - if (global.hasOwnProperty(attr)){ - settings[attr] = global[attr]; - } - } - //-- Get the chapter's display type - chapter.forEach(function(prop){ - var rendition = prop.replace("rendition:", ''); - var split = rendition.indexOf("-"); - var property, value; - - if(split != -1){ - property = rendition.slice(0, split); - value = rendition.slice(split+1); - - settings[property] = value; - } - }); - return settings; -}; - -/** -* Uses the settings to determine which Layout Method is needed -* Triggers events based on the method choosen -* Takes: Layout settings object -* Returns: String of appropriate for EPUBJS.Layout function -*/ -EPUBJS.Renderer.prototype.determineLayout = function(settings){ - // Default is layout: reflowable & spread: auto - var spreads = this.determineSpreads(this.minSpreadWidth); - var layoutMethod = spreads ? "ReflowableSpreads" : "Reflowable"; - var scroll = false; - - if(settings.layout === "pre-paginated") { - layoutMethod = "Fixed"; - scroll = true; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "none") { - layoutMethod = "Reflowable"; - scroll = false; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "both") { - layoutMethod = "ReflowableSpreads"; - scroll = false; - spreads = true; - } - - this.spreads = spreads; - this.render.scroll(scroll); - this.trigger("renderer:spreads", spreads); - return layoutMethod; -}; - -// Shortcut to trigger the hook before displaying the chapter -EPUBJS.Renderer.prototype.beforeDisplay = function(callback, renderer){ - this.triggerHooks("beforeChapterDisplay", callback, this); -}; - -// Update the renderer with the information passed by the layout -EPUBJS.Renderer.prototype.updatePages = function(layout){ - this.pageMap = this.mapPage(); - // this.displayedPages = layout.displayedPages; - - if (this.spreads) { - this.displayedPages = Math.ceil(this.pageMap.length / 2); - } else { - this.displayedPages = this.pageMap.length; - } - - // this.currentChapter.pages = layout.pageCount; - this.currentChapter.pages = this.pageMap.length; - - this._q.flush(); -}; - -// Apply the layout again and jump back to the previous cfi position -EPUBJS.Renderer.prototype.reformat = function(){ - var renderer = this; - var formated, pages; - if(!this.contents) return; - - spreads = this.determineSpreads(this.minSpreadWidth); - - // Only re-layout if the spreads have switched - if(spreads != this.spreads){ - this.spreads = spreads; - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - } - - // Reset pages - this.chapterPos = 1; - this.render.page(1); - - // Give the css styles time to update - // clearTimeout(this.timeoutTillCfi); - // this.timeoutTillCfi = setTimeout(function(){ - - renderer.formated = renderer.layout.format(renderer.contents, renderer.render.width, renderer.render.height, renderer.gap); - renderer.render.setPageDimensions(renderer.formated.pageWidth, renderer.formated.pageHeight); - - pages = renderer.layout.calculatePages(); - renderer.updatePages(pages); - - //-- Go to current page after formating - if(renderer.currentLocationCfi){ - renderer.gotoCfi(renderer.currentLocationCfi); - } - // renderer.timeoutTillCfi = null; - -}; - -// Hide and show the render's container . -EPUBJS.Renderer.prototype.visible = function(bool){ - if(typeof(bool) === "undefined") { - return this.element.style.visibility; - } - - if(bool === true && !this.hidden){ - this.element.style.visibility = "visible"; - }else if(bool === false){ - this.element.style.visibility = "hidden"; - } -}; - -// Remove the render element and clean up listeners -EPUBJS.Renderer.prototype.remove = function() { - if(this.render.window) { - this.render.unload(); - this.render.window.removeEventListener("resize", this.resized); - this.removeEventListeners(); - this.removeSelectionListeners(); - } - - this.container.removeChild(this.element); -}; - -//-- STYLES - -EPUBJS.Renderer.prototype.applyStyles = function(styles) { - for (var style in styles) { - this.render.setStyle(style, styles[style]); - } -}; - -EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){ - this.render.setStyle(style, val, prefixed); -}; - -EPUBJS.Renderer.prototype.removeStyle = function(style){ - this.render.removeStyle(style); -}; - -//-- HEAD TAGS -EPUBJS.Renderer.prototype.applyHeadTags = function(headTags) { - for ( var headTag in headTags ) { - this.render.addHeadTag(headTag, headTags[headTag]); - } -}; - -//-- NAVIGATION - -EPUBJS.Renderer.prototype.page = function(pg){ - if(!this.pageMap) { - console.warn("pageMap not set, queuing"); - this._q.enqueue("page", arguments); - return true; - } - - if(pg >= 1 && pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; - -// Short cut to find next page's cfi starting at the last visible element -/* -EPUBJS.Renderer.prototype.nextPage = function(){ - var pg = this.chapterPos + 1; - if(pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - - this.currentLocationCfi = this.getPageCfi(this.visibileEl); - this.trigger("renderer:locationChanged", this.currentLocationCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; -*/ -EPUBJS.Renderer.prototype.nextPage = function(){ - return this.page(this.chapterPos + 1); -}; - -EPUBJS.Renderer.prototype.prevPage = function(){ - return this.page(this.chapterPos - 1); -}; - -//-- Show the page containing an Element -EPUBJS.Renderer.prototype.pageByElement = function(el){ - var pg; - if(!el) return; - - pg = this.render.getPageNumberByElement(el); - this.page(pg); -}; - -// Jump to the last page of the chapter -EPUBJS.Renderer.prototype.lastPage = function(){ - if(this._moving) { - return this._q.enqueue("lastPage", arguments); - } - - this.page(this.displayedPages); -}; - -// Jump to the first page of the chapter -EPUBJS.Renderer.prototype.firstPage = function(){ - this.page(1); -}; - -//-- Find a section by fragement id -EPUBJS.Renderer.prototype.section = function(fragment){ - var el = this.doc.getElementById(fragment), - left, pg; - - if(el){ - this.pageByElement(el); - } - -}; - -EPUBJS.Renderer.prototype.firstElementisTextNode = function(node) { - var children = node.childNodes; - var leng = children.length; - - if(leng && - children[0] && // First Child - children[0].nodeType === 3 && // This is a textNodes - children[0].textContent.trim().length) { // With non whitespace or return charecters - return true; - } - return false; -}; - -// Walk the node tree from a start element to next visible element -EPUBJS.Renderer.prototype.walk = function(node, x, y) { - var r, children, leng, - startNode = node, - prevNode, - stack = [startNode]; - - var STOP = 10000, ITER=0; - - while(!r && stack.length) { - node = stack.shift(); - if( this.containsPoint(node, x, y) && this.firstElementisTextNode(node)) { - r = node; - } - - if(!r && node && node.childElementCount > 0){ - children = node.children; - if (children && children.length) { - leng = children.length ? children.length : 0; - } else { - return r; - } - for (var i = leng-1; i >= 0; i--) { - if(children[i] != prevNode) stack.unshift(children[i]); - } - } - - if(!r && stack.length === 0 && startNode && startNode.parentNode !== null){ - stack.push(startNode.parentNode); - prevNode = startNode; - startNode = startNode.parentNode; - } - - - ITER++; - if(ITER > STOP) { - console.error("ENDLESS LOOP"); - break; - } - - } - - return r; -}; - -// Checks if an element is on the screen -EPUBJS.Renderer.prototype.containsPoint = function(el, x, y){ - var rect; - var left; - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - // console.log(el, rect, x, y); - - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - rect.left >= x && - x <= rect.left + rect.width) { - return true; - } - } - - return false; -}; - -EPUBJS.Renderer.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if ( ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.sprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.mapPage = function(){ - var renderer = this; - var map = []; - var root = this.render.getBaseElement(); - var page = 1; - var width = this.layout.colWidth + this.layout.gap; - var offset = this.formated.pageWidth * (this.chapterPos-1); - var limit = (width * page) - offset;// (width * page) - offset; - var elLimit = 0; - var prevRange; - var cfi; - var check = function(node) { - var elPos; - var elRange; - var children = Array.prototype.slice.call(node.childNodes); - if (node.nodeType == Node.ELEMENT_NODE) { - // elPos = node.getBoundingClientRect(); - elRange = document.createRange(); - elRange.selectNodeContents(node); - elPos = elRange.getBoundingClientRect(); - - if(!elPos || (elPos.width === 0 && elPos.height === 0)) { - return; - } - - //-- Element starts new Col - if(elPos.left > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - - //-- Element Spans new Col - if(elPos.right > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - } - - }; - var checkText = function(node){ - var ranges = renderer.splitTextNodeIntoWordsRanges(node); - ranges.forEach(function(range){ - var pos = range.getBoundingClientRect(); - - if(!pos || (pos.width === 0 && pos.height === 0)) { - return; - } - if(pos.left + pos.width < limit) { - if(!map[page-1]){ - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - // map[page-1].start = cfi; - map.push({ start: cfi, end: null }); - } - } else { - if(prevRange){ - prevRange.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - map.push({ - start: cfi, - end: null - }); - - page += 1; - limit = (width * page) - offset; - elLimit = limit; - } - - prevRange = range; - }); - - - }; - - this.sprint(root, check); - // this.textSprint(root, checkText); - - if(prevRange){ - prevRange.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - // Handle empty map - if(!map.length) { - range = this.doc.createRange(); - range.selectNodeContents(root); - range.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(range); - - map.push({ start: cfi, end: cfi }); - - } - - // clean up - prevRange = null; - ranges = null; - range = null; - root = null; - - return map; -}; - - -EPUBJS.Renderer.prototype.indexOfBreakableChar = function (text, startPosition) { - var whiteCharacters = "\x2D\x20\t\r\n\b\f"; - // '-' \x2D - // ' ' \x20 - - if (! startPosition) { - startPosition = 0; - } - - for (var i = startPosition; i < text.length; i++) { - if (whiteCharacters.indexOf(text.charAt(i)) != -1) { - return i; - } - } - - return -1; -}; - - -EPUBJS.Renderer.prototype.splitTextNodeIntoWordsRanges = function(node){ - var ranges = []; - var text = node.textContent.trim(); - var range; - var rect; - var list; - // jaroslaw.bielski@7bulls.com - // Usage of indexOf() function for space character as word delimiter - // is not sufficient in case of other breakable characters like \r\n- etc - pos = this.indexOfBreakableChar(text); - - if(pos === -1) { - range = this.doc.createRange(); - range.selectNodeContents(node); - return [range]; - } - - range = this.doc.createRange(); - range.setStart(node, 0); - range.setEnd(node, pos); - ranges.push(range); - - // jaroslaw.bielski@7bulls.com - // there was a word miss in case of one letter words - range = this.doc.createRange(); - range.setStart(node, pos+1); - - while ( pos != -1 ) { - - pos = this.indexOfBreakableChar(text, pos + 1); - if(pos > 0) { - - if(range) { - range.setEnd(node, pos); - ranges.push(range); - } - - range = this.doc.createRange(); - range.setStart(node, pos+1); - } - } - - if(range) { - range.setEnd(node, text.length); - ranges.push(range); - } - - return ranges; -}; - -EPUBJS.Renderer.prototype.rangePosition = function(range){ - var rect; - var list; - - list = range.getClientRects(); - - if(list.length) { - rect = list[0]; - return rect; - } - - return null; -}; - -/* -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(prevEl){ - var range = this.doc.createRange(); - var position; - // TODO : this might need to take margin / padding into account? - var x = 1;//this.formated.pageWidth/2; - var y = 1;//;this.formated.pageHeight/2; - - range = this.getRange(x, y); - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - - return this.currentChapter.cfiFromRange(range); -}; -*/ - -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(){ - var pg; - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - } - return this.pageMap[(this.chapterPos * 2) -1].start; -}; - -EPUBJS.Renderer.prototype.getRange = function(x, y, forceElement){ - var range = this.doc.createRange(); - var position; - forceElement = true; // temp override - if(typeof document.caretPositionFromPoint !== "undefined" && !forceElement){ - position = this.doc.caretPositionFromPoint(x, y); - range.setStart(position.offsetNode, position.offset); - } else if(typeof document.caretRangeFromPoint !== "undefined" && !forceElement){ - range = this.doc.caretRangeFromPoint(x, y); - } else { - this.visibileEl = this.findElementAfter(x, y); - range.setStart(this.visibileEl, 1); - } - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - return range; -}; - -/* -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(prevEl){ - var startX = 0; - var startY = 0; - var endX = this.width-1; - var endY = this.height-1; - var startRange = this.getRange(startX, startY); - var endRange = this.getRange(endX, endY); //fix if carret not avail - var startCfi = this.currentChapter.cfiFromRange(startRange); - var endCfi; - if(endRange) { - endCfi = this.currentChapter.cfiFromRange(endRange); - } - - return { - start: startCfi, - end: endCfi || false - }; -}; -*/ - -EPUBJS.Renderer.prototype.pagesInCurrentChapter = function() { - var pgs; - var length; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - length = this.pageMap.length; - - if(this.spreads){ - pgs = Math.ceil(length / 2); - } else { - pgs = length; - } - - return pgs; -}; - -EPUBJS.Renderer.prototype.currentRenderedPage = function(){ - var pg; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads && this.layout.pageCount > 1) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - return pg; -}; - -EPUBJS.Renderer.prototype.getRenderedPagesLeft = function(){ - var pg; - var lastPage; - var pagesLeft; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - lastPage = this.pageMap.length; - - if (this.spreads) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - pagesLeft = lastPage - pg; - return pagesLeft; - -}; - -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(){ - var pg; - var startRange, endRange; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - endRange = startRange; - - if(this.layout.pageCount > 1) { - endRange = this.pageMap[pg-1]; - } - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - endRange = startRange; - } - - if(!startRange) { - console.warn("page range miss:", pg, this.pageMap); - startRange = this.pageMap[this.pageMap.length-1]; - endRange = startRange; - } - - return { - start: startRange.start, - end: endRange.end - }; -}; - -// Goto a cfi position in the current chapter -EPUBJS.Renderer.prototype.gotoCfi = function(cfi){ - var pg; - var marker; - var range; - - if(this._moving){ - return this._q.enqueue("gotoCfi", arguments); - } - - if(_.isString(cfi)){ - cfi = this.epubcfi.parse(cfi); - } - - if(typeof document.evaluate === 'undefined') { - marker = this.epubcfi.addMarker(cfi, this.doc); - if(marker) { - pg = this.render.getPageNumberByElement(marker); - // Must Clean up Marker before going to page - this.epubcfi.removeMarker(marker, this.doc); - this.page(pg); - } - } else { - range = this.epubcfi.generateRangeFromCfi(cfi, this.doc); - if(range) { - // jaroslaw.bielski@7bulls.com - // It seems that sometimes getBoundingClientRect() returns null for first page CFI in chapter. - // It is always reproductible if few consecutive chapters have only one page. - // NOTE: This is only workaround and the issue needs an deeper investigation. - // NOTE: Observed on Android 4.2.1 using WebView widget as HTML renderer (Asus TF300T). - var rect = range.getBoundingClientRect(); - if (rect) { - pg = this.render.getPageNumberByRect(rect); - - } else { - // Goto first page in chapter - pg = 1; - } - - this.page(pg); - - // Reset the current location cfi to requested cfi - this.currentLocationCfi = cfi.str; - } - } -}; - -// Walk nodes until a visible element is found -EPUBJS.Renderer.prototype.findFirstVisible = function(startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - // kgolunski@7bulls.com - // Looks like an old API usage - // Set x and y as 0 to fullfill walk method API. - found = this.walk(el, 0, 0); - - if(found) { - return found; - }else{ - return startEl; - } - -}; -// TODO: remove me - unsused -EPUBJS.Renderer.prototype.findElementAfter = function(x, y, startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - found = this.walk(el, x, y); - if(found) { - return found; - }else{ - return el; - } - -}; - -/* -EPUBJS.Renderer.prototype.route = function(hash, callback){ - var location = window.location.hash.replace('#/', ''); - if(this.useHash && location.length && location != this.prevLocation){ - this.show(location, callback); - this.prevLocation = location; - return true; - } - return false; -} - -EPUBJS.Renderer.prototype.hideHashChanges = function(){ - this.useHash = false; -} - -*/ - -EPUBJS.Renderer.prototype.resize = function(width, height, setSize){ - var spreads; - - this.width = width; - this.height = height; - - if(setSize !== false) { - this.render.resize(this.width, this.height); - } - - - - if(this.contents){ - this.reformat(); - } - - this.trigger("renderer:resized", { - width: this.width, - height: this.height - }); -}; - -//-- Listeners for events in the frame - -EPUBJS.Renderer.prototype.onResized = function(e) { - var width = this.container.clientWidth; - var height = this.container.clientHeight; - - this.resize(width, height, false); -}; - -EPUBJS.Renderer.prototype.addEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.addEventListener(eventName, this.triggerEvent.bind(this), false); - }, this); - -}; - -EPUBJS.Renderer.prototype.removeEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.removeEventListener(eventName, this.triggerEvent, false); - }, this); - -}; - -// Pass browser events -EPUBJS.Renderer.prototype.triggerEvent = function(e){ - this.trigger("renderer:"+e.type, e); -}; - -EPUBJS.Renderer.prototype.addSelectionListeners = function(){ - this.render.document.addEventListener("selectionchange", this.onSelectionChange.bind(this), false); -}; - -EPUBJS.Renderer.prototype.removeSelectionListeners = function(){ - if(!this.render.document) { - return; - } - this.doc.removeEventListener("selectionchange", this.onSelectionChange, false); -}; - -EPUBJS.Renderer.prototype.onSelectionChange = function(e){ - if (this.selectionEndTimeout) { - clearTimeout(this.selectionEndTimeout); - } - this.selectionEndTimeout = setTimeout(function() { - this.selectedRange = this.render.window.getSelection(); - this.trigger("renderer:selected", this.selectedRange); - }.bind(this), 500); -}; - - -//-- Spreads - -EPUBJS.Renderer.prototype.setMinSpreadWidth = function(width){ - this.minSpreadWidth = width; - this.spreads = this.determineSpreads(width); -}; - -EPUBJS.Renderer.prototype.determineSpreads = function(cutoff){ - if(this.isForcedSingle || !cutoff || this.width < cutoff) { - return false; //-- Single Page - }else{ - return true; //-- Double Page - } -}; - -EPUBJS.Renderer.prototype.forceSingle = function(bool){ - if(bool) { - this.isForcedSingle = true; - // this.spreads = false; - } else { - this.isForcedSingle = false; - // this.spreads = this.determineSpreads(this.minSpreadWidth); - } -}; - -EPUBJS.Renderer.prototype.setGap = function(gap){ - this.gap = gap; //-- False == auto gap -}; - -//-- Content Replacements - -EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){ - var items = this.contents.querySelectorAll(query), - resources = Array.prototype.slice.call(items), - count = resources.length; - - - if(count === 0) { - finished(false); - return; - } - resources.forEach(function(item){ - var called = false; - var after = function(result, full){ - if(called === false) { - count--; - if(progress) progress(result, full, count); - if(count <= 0 && finished) finished(true); - called = true; - } - }; - - func(item, after); - - }.bind(this)); - -}; - -EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callback) { - var _oldUrls, - _newUrls = {}, - _store = this.currentChapter.store, - _cache = this.caches[query], - _uri = EPUBJS.core.uri(this.currentChapter.absolute), - _chapterBase = _uri.base, - _attr = attr, - _wait = 2000, - progress = function(url, full, count) { - _newUrls[full] = url; - }, - finished = function(notempty) { - if(callback) callback(); - - _.each(_oldUrls, function(url){ - _store.revokeUrl(url); - }); - - _cache = _newUrls; - }; - - if(!_store) return; - - if(!_cache) _cache = {}; - _oldUrls = _.clone(_cache); - - this.replace(query, function(link, done){ - var src = link.getAttribute(_attr), - full = EPUBJS.core.resolveUrl(_chapterBase, src); - - var replaceUrl = function(url) { - var timeout; - link.onload = function(){ - clearTimeout(timeout); - done(url, full); - }; - - link.onerror = function(e){ - clearTimeout(timeout); - done(url, full); - console.error(e); - }; - - if(query == "image") { - //-- SVG needs this to trigger a load event - link.setAttribute("externalResourcesRequired", "true"); - } - - if(query == "link[href]" && link.getAttribute("rel") !== "stylesheet") { - //-- Only Stylesheet links seem to have a load events, just continue others - done(url, full); - } - - link.setAttribute(_attr, url); - - //-- If elements never fire Load Event, should continue anyways - timeout = setTimeout(function(){ - done(url, full); - }, _wait); - - }; - - if(full in _oldUrls){ - replaceUrl(_oldUrls[full]); - _newUrls[full] = _oldUrls[full]; - delete _oldUrls[full]; - }else{ - func(_store, full, replaceUrl, link); - } - - }, finished, progress); -}; - -//-- Enable binding events to Renderer -RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype); - -var EPUBJS = EPUBJS || {}; -EPUBJS.replace = {}; - -//-- Replaces the relative links within the book to use our internal page changer -EPUBJS.replace.hrefs = function(callback, renderer){ - var book = this; - var replacments = function(link, done){ - var href = link.getAttribute("href"), - isRelative = href.search("://"), - directory, - relative, - location; - - if(isRelative != -1){ - - link.setAttribute("target", "_blank"); - - }else{ - // Links may need to be resolved, such as ../chp1.xhtml - directory = EPUBJS.core.uri(renderer.render.window.location.href).directory; - if(directory) { - relative = EPUBJS.core.resolveUrl(directory, href); - } else { - relative = href; - } - - link.onclick = function(){ - book.goto(relative); - return false; - }; - - } - done(); - - }; - - renderer.replace("a[href]", replacments, callback); - -}; - -EPUBJS.replace.head = function(callback, renderer) { - - renderer.replaceWithStored("link[href]", "href", EPUBJS.replace.links, callback); - -}; - - -//-- Replaces assets src's to point to stored version if browser is offline -EPUBJS.replace.resources = function(callback, renderer){ - //srcs = this.doc.querySelectorAll('[src]'); - renderer.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, callback); - -}; - -EPUBJS.replace.svg = function(callback, renderer) { - - renderer.replaceWithStored("image", "xlink:href", function(_store, full, done){ - _store.getUrl(full).then(done); - }, callback); - -}; - -EPUBJS.replace.srcs = function(_store, full, done){ - - _store.getUrl(full).then(done); - -}; - -//-- Replaces links in head, such as stylesheets - link[href] -EPUBJS.replace.links = function(_store, full, done, link){ - //-- Handle replacing urls in CSS - if(link.getAttribute("rel") === "stylesheet") { - EPUBJS.replace.stylesheets(_store, full).then(function(url, full){ - // done - setTimeout(function(){ - done(url, full); - }, 5); //-- Allow for css to apply before displaying chapter - }); - }else{ - _store.getUrl(full).then(done); - } -}; - -EPUBJS.replace.stylesheets = function(_store, full) { - var deferred = new RSVP.defer(); - - if(!_store) return; - - _store.getText(full).then(function(text){ - var url; - - EPUBJS.replace.cssUrls(_store, full, text).then(function(newText){ - var _URL = window.URL || window.webkitURL || window.mozURL; - - var blob = new Blob([newText], { "type" : "text\/css" }), - url = _URL.createObjectURL(blob); - - deferred.resolve(url); - - }, function(e) { - console.error(e); - }); - - }); - - return deferred.promise; -}; - -EPUBJS.replace.cssUrls = function(_store, base, text){ - var deferred = new RSVP.defer(), - promises = [], - matches = text.match(/url\(\'?\"?([^\'|^\"^\)]*)\'?\"?\)/g); - - if(!_store) return; - - if(!matches){ - deferred.resolve(text); - return deferred.promise; - } - - matches.forEach(function(str){ - var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, '')); - var replaced = _store.getUrl(full).then(function(url){ - text = text.replace(str, 'url("'+url+'")'); - }); - - promises.push(replaced); - }); - - RSVP.all(promises).then(function(){ - deferred.resolve(text); - }); - - return deferred.promise; -}; - - - -EPUBJS.Unarchiver = function(url){ - - this.loadLib(); - this.urlCache = {}; - -}; - -//-- Load the zip lib and set the workerScriptsPath -EPUBJS.Unarchiver.prototype.loadLib = function(callback){ - if(typeof(JSZip) == "undefined") console.error("JSZip lib not loaded"); -}; - -EPUBJS.Unarchiver.prototype.openZip = function(zipUrl, callback){ - var deferred = new RSVP.defer(); - - return EPUBJS.core.request(zipUrl, "binary").then(function(data){ - this.zip = new JSZip(data); - }.bind(this)); -}; - -EPUBJS.Unarchiver.prototype.getXml = function(url, encoding){ - - return this.getText(url, encoding). - then(function(text){ - var parser = new DOMParser(); - return parser.parseFromString(text, "text/xml"); - }); - -}; - -EPUBJS.Unarchiver.prototype.getUrl = function(url, mime){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - var tempUrl; - - if(!entry) { - deferred.reject({ - message : "File not found in the epub: " + url, - stack : new Error().stack - }); - return deferred.promise; - } - - if(url in this.urlCache) { - deferred.resolve(this.urlCache[url]); - return deferred.promise; - } - - blob = new Blob([entry.asUint8Array()], {type : mime || this.zip.getMimeType(entry.name)}); - - tempUrl = _URL.createObjectURL(blob); - deferred.resolve(tempUrl); - unarchiver.urlCache[url] = tempUrl; - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.getText = function(url, encoding){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - - if(!entry) { - console.warn("File not found in the contained epub:", url); - return deferred.promise; - } - - text = entry.asText(); - deferred.resolve(text); - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.revokeUrl = function(url){ - var _URL = window.URL || window.webkitURL || window.mozURL; - var fromCache = unarchiver.urlCache[url]; - if(fromCache) _URL.revokeObjectURL(fromCache); -}; - -EPUBJS.Unarchiver.prototype.failed = function(error){ - console.error(error); -}; - -EPUBJS.Unarchiver.prototype.afterSaved = function(error){ - this.callback(); -}; - -EPUBJS.Unarchiver.prototype.toStorage = function(entries){ - var timeout = 0, - delay = 20, - that = this, - count = entries.length; - - function callback(){ - count--; - if(count === 0) that.afterSaved(); - } - - entries.forEach(function(entry){ - - setTimeout(function(entry){ - that.saveEntryFileToStorage(entry, callback); - }, timeout, entry); - - timeout += delay; - }); - - console.log("time", timeout); - - //entries.forEach(this.saveEntryFileToStorage.bind(this)); -}; - -// EPUBJS.Unarchiver.prototype.saveEntryFileToStorage = function(entry, callback){ -// var that = this; -// entry.getData(new zip.BlobWriter(), function(blob) { -// EPUBJS.storage.save(entry.filename, blob, callback); -// }); -// }; - -//# sourceMappingURL=epub.js.map \ No newline at end of file diff --git a/static/epub.js/epub.js.map b/static/epub.js/epub.js.map deleted file mode 100644 index dd40312..0000000 --- a/static/epub.js/epub.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"epub.min.js","sources":["epub.js"],"names":["n","this","t","_","r","e","Array","prototype","u","Object","i","Function","a","push","o","slice","c","concat","l","toString","f","hasOwnProperty","s","forEach","p","map","h","reduce","v","reduceRight","d","filter","g","every","m","some","y","indexOf","b","lastIndexOf","x","isArray","keys","j","bind","w","_wrapped","exports","module","VERSION","A","each","length","call","has","collect","O","foldl","inject","arguments","TypeError","foldr","find","detect","E","select","reject","all","identity","any","contains","include","invoke","isFunction","apply","pluck","where","isEmpty","findWhere","max","Math","computed","value","min","shuffle","random","k","sortBy","index","criteria","sort","F","groupBy","countBy","sortedIndex","toArray","values","size","first","head","take","initial","last","rest","tail","drop","compact","R","flatten","without","difference","uniq","unique","union","intersection","zip","object","range","ceil","partial","bindAll","functions","memoize","delay","setTimeout","defer","throttle","Date","clearTimeout","debounce","once","wrap","compose","after","pairs","invert","methods","extend","pick","omit","defaults","clone","isObject","tap","I","source","global","multiline","ignoreCase","constructor","pop","isEqual","isString","isElement","nodeType","isArguments","isFinite","isNaN","parseFloat","isNumber","isBoolean","isNull","isUndefined","noConflict","times","floor","M","escape","&","<",">","\"","'","/","unescape","S","RegExp","join","replace","result","mixin","D","N","uniqueId","templateSettings","evaluate","interpolate","T","q","\\","\r","\n","\t","
","
","B","template","variable","chain","_chain","define","requireModule","require","requirejs","registry","seen","name","deps","callback","resolve","child","charAt","parts","split","parentBase","part","_eak_seen","Error","mod","reified","__dependency1__","__exports__","Promise","array","label","__dependency2__","fulfilled","state","rejected","reason","isNonThenable","entries","fulfilledResolver","resolveAll","rejectedResolver","results","remaining","entry","cast","then","useNextTick","process","nextTick","flush","useMutationObserver","iterations","observer","BrowserMutationObserver","node","document","createTextNode","observe","characterData","data","useSetTimeout","queue","tuple","arg","scheduleFlush","browserGlobal","window","MutationObserver","WebKitMutationObserver","configure","config","on","EventTarget","instrument","deferred","promise","callbacks","callbacksFor","_promiseCallbacks","off","trigger","undefined","eventName","allCallbacks","splice","options","__dependency3__","promises","filterFn","filterResults","valuesLen","filtered","keysOf","fulfilledTo","property","onRejection","now","guid","_guidKey","_id","detail","_detail","childGuid","_label","timeStamp","stack","error","mapFn","resultLen","mappedResults","makeNodeCallbackFor","nodeFunc","binding","nodeArgs","thisArg","__dependency4__","__dependency5__","__dependency6__","__dependency7__","__dependency8__","__dependency9__","noop","resolver","counter","_subscribers","invokeResolver","resolvePromise","rejectPromise","subscribe","parent","onFulfillment","subscribers","FULFILLED","REJECTED","publish","settled","invokeCallback","succeeded","failed","hasCallback","handleThenable","resolved","objectOrFunction","val","fulfill","_state","PENDING","SEALED","async","publishFulfillment","publishRejection","_onerror","race","Resolve","Reject","guidKey","thenPromise","catch","finally","Constructor","fulfillmentAt","pending","getTime","prop","__dependency10__","__dependency11__","__dependency12__","__dependency13__","__dependency14__","__dependency15__","denodeify","allSettled","hash","rethrow","asap","__PROMISE_INSTRUMENTATION__","RSVP","EPUBJS","plugins","filePath","Render","root","previousEpub","ePub","bookPath","Book","amd","settings","bookKey","packageUrl","storage","fromStorage","saved","online","contained","width","height","layoutOveride","orientation","minSpreadWidth","gap","version","restore","reload","goto","styles","headTags","withCredentials","render_method","EPUBJSVERSION","spinePos","stored","navigator","onLine","networkListeners","store","fileStorage","ready","manifest","spine","metadata","cover","toc","pageList","readyPromises","pagination","Pagination","pageListReady","_ready","isRendered","_q","core","_rendering","_displayQ","_moving","_gotoQ","renderer","Renderer","setMinSpreadWidth","setGap","listenToRenderer","defer_opened","opened","open","addEventListener","unload","forceReload","epubpackage","book","bookUrl","urlFrom","isContained","unarchive","loadPackage","localStorage","packageXml","identifier","packageIdentifier","restored","unpack","storeOffline","_registerReplacements","_containerPath","parse","Parser","containerPath","loadXml","containerXml","container","paths","contentsPath","basePath","packagePath","encoding","console","contents","packageContents","spineIndexByURL","generateBookKey","globalLayoutProperties","parseLayoutProperties","coverPath","spineNodeIndex","navPath","navUrl","navHtml","nav","epubcfi","EpubCFI","wait","pg","cfi","generateCfiFromHref","href","tocPath","tocUrl","tocXml","createHiddenRender","_width","_height","hiddenContainer","hiddenEl","box","element","getBoundingClientRect","forceSingle","createElement","style","visibility","overflow","appendChild","initialize","generatePageList","pager","spineLength","currentPage","nextChapter","chapter","next","done","Chapter","displayChapter","pageMap","item","start","page","spreads","end","remove","removeChild","generatePagination","defered","loadPagination","pagelistJSON","JSON","getPageList","getMetadata","getToc","Events","startPage","endPage","percent","pageRange","pageFromCfi","percentageFromPage","anchorPage","percentage","loadChange","url","uri","currentChapter","absolute","path","warn","filename","unlistenToRenderer","getXml","request","base","protocol","fromRoot","location","origin","host","baseTag","getElementsByTagName","resolveUrl","pathname","Unarchiver","openZip","extension","isSaved","storedSettings","getItem","saveContents","setItem","stringify","removeSavedContents","removeItem","renderTo","elem","rendered","getEl","_rendered","startDisplay","display","previousLocationCfi","gotoCfi","fetch","fromStore","len","clearSaved","chap","render","pos","enqueue","lastPage","preloadNextChapter","dequeue","message","nextPage","prevPage","prev","prevChapter","linear","getCurrentLocationCfi","currentLocationCfi","target","gotoPercentage","parseInt","substring","gotoPage","gotoHref","cfiString","spineItem","section","relativeURL","firstPage","cfiFromPage","pageFromPercentage","assets","batch","availableOffline","setStyle","prefixed","noreflow","reformat","removeStyle","addHeadTag","tag","attrs","useSpreads","use","_use","force","load","destroy","removeEventListener","applyStyles","applyHeadTags","registerHook","hrefs","_needsAssetReplacement","resources","svg","getStorageType","layout","spread","event","spineObject","id","cfiBase","properties","manifestProperties","pages","loaded","_store","get","xml","setDocument","doc","serializer","XMLSerializer","setAttribute","insertBefore","firstChild","serializeToString","tempUrl","getUrl","setPages","num","getPages","getID","ID","revokeUrl","_document","namespaceURI","doctype","implementation","createDocument","importNode","documentElement","cfiFromRange","_range","startXpath","endXpath","startContainer","endContainer","cleanEndTextContent","getElementXPath","nsResolver","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","collapsed","createRange","setStart","startOffset","setEnd","endOffset","log","cleanStartTextContent","cleanStringForXpath","textContent","generateCfiFromRange","_query","matches","query","toLowerCase","excerpt","text","limit","textSprint","func","treeWalker","createTreeWalker","NodeFilter","SHOW_TEXT","acceptNode","test","FILTER_ACCEPT","FILTER_REJECT","nextNode","getElementById","getEls","classes","getElementsByClassName","type","handler","readyState","DONE","status","responseXML","response","supportsURL","Blob","URL","BLOB_RESPONSE","xhr","XMLHttpRequest","xhrPrototype","defineProperty","onreadystatechange","responseType","setRequestHeader","overrideMimeType","send","obj","arr","member","newitm","ident","withoutProtocol","dot","firstSlash","directory","fragment","blob","doubleSlash","search","folder","lastSlash","dataURLToBlob","dataURL","contentType","raw","rawLength","uInt8Array","BASE64_MARKER","atob","Uint8Array","charCodeAt","addScript","src","onload","body","addScripts","srcArr","total","curr","cb","addCss","rel","unprefixed","vendors","upper","toUpperCase","segments","folders","uuid","insert","compareFunction","locationOf","_start","_end","compared","pivot","indexOfSorted","_scope","scope","funcName","args","context","inwait","shift","clear","getElementTreeXPath","nodeName","tagName","pathIndex","isXhtml","ownerDocument","getAttribute","Node","TEXT_NODE","indexOfTextNode","parentNode","sibling","previousSibling","DOCUMENT_TYPE_NODE","prefix","ns","xhtml","epub","str","match","textNode","sib","children","childNodes","cfiStr","generateChapterComponent","_spineNodeIndex","_pos","generatePathComponent","steps","segment","generateCfiFromElement","pathTo","unshift","getChapterComponent","splitStr","getPathComponent","pathComponent","getCharecterOffsetComponent","chapSegment","chapterComponent","charecterOffsetComponent","assertion","chapId","endInt","parseStep","has_brackets","spineId","step","characterOffset","textLocationAssertion","addMarker","_doc","_marker","lastStep","marker","createMarker","findParent","splitText","classList","add","removeMarker","nextSib","nextSibling","prevSib","sections","compare","cfiOne","cfiTwo","generateCfiFromTextNode","anchor","offset","generateCfiFromRangeAnchor","anchorNode","anchorOffset","startElement","startSteps","startPath","startIndex","endElement","endSteps","endPath","endIndex","generateXpathFromSteps","xpath","position","generateRangeFromCfi","textLength","debug","selectNode","el","events","createEvent","tell","listen","deafen","listenUntil","evt","CustomEvent","msg","dispatchEvent","bindto","OnEvt","OffEvt","unlisten","hooks","Hooks","getHooks","plugs","plugType","hook","toAdd","toFront","triggerHooks","passed","countdown","count","register","Layout","Reflowable","spreadWidth","format","_gap","columnAxis","columnGap","columnWidth","columnFill","colWidth","pageWidth","pageHeight","calculatePages","totalWidth","displayedPages","scrollWidth","pageCount","ReflowableSpreads","divisor","fullWidth","Fixed","content","viewport","querySelector","hasAttribute","locations","totalPages","round","percentageFromCfi","baseUrl","rootfile","fullpath","xmlEncoding","metadataNode","getElementText","manifestNode","spineNode","findNavPath","findTocPath","findCoverPath","tocId","bookTitle","creator","description","pubdate","publisher","language","rights","modified_date","querySelectorText","found","getElementsByTagNameNS","nodeValue","manifestXml","selected","querySelectorAll","items","spineXml","Id","props","propArray","manifestProps","manifestPropArray","vert","bookSpine","findListItems","findAnchorOrSpan","getTOC","list","nodes","subitems","idCounter","navEl","snapshot","ORDERED_NODE_SNAPSHOT_TYPE","snapshotLength","snapshotItem","navLabel","navMap","isCfi","Iframe","iframe","docEl","bodyEl","leftPos","create","scrolling","seamless","border","contentDocument","headEl","contentWindow","resized","margin","onerror","resize","totalHeight","scrollHeight","setPageDimensions","setLeft","defaultView","scrollTo","tagEl","attr","getPageNumberByElement","left","getPageNumberByRect","boundingClientRect","getBaseElement","isElementVisible","rect","scroll","bool","renderMethod","hidden","listenedEvents","upEvent","downEvent","caches","isForcedSingle","onResized","layoutSettings","initWidth","initHeight","clientWidth","clientHeight","globalLayout","removeEventListeners","removeSelectionListeners","chapterPos","currentChapterCfiBase","reconcileLayoutSettings","layoutMethod","determineLayout","visible","formated","addEventListeners","addSelectionListeners","beforeDisplay","queued","updatePages","visibleRangeCfi","getVisibleRangeCfi","rendition","determineSpreads","mapPage","headTag","pageByElement","firstElementisTextNode","leng","trim","walk","prevNode","startNode","STOP","ITER","containsPoint","childElementCount","sprint","SHOW_ELEMENT","prevRange","elLimit","check","elPos","elRange","ELEMENT_NODE","selectNodeContents","checkText","right","ranges","splitTextNodeIntoWordsRanges","collapse","indexOfBreakableChar","startPosition","whiteCharacters","rangePosition","getClientRects","getPageCfi","startRange","getRange","forceElement","caretPositionFromPoint","caretRangeFromPoint","visibileEl","findElementAfter","offsetNode","pagesInCurrentChapter","pgs","currentRenderedPage","getRenderedPagesLeft","pagesLeft","endRange","findFirstVisible","startEl","setSize","triggerEvent","onSelectionChange","selectionEndTimeout","selectedRange","getSelection","cutoff","finished","progress","called","full","replaceWithStored","_oldUrls","_newUrls","_cache","_uri","_chapterBase","_attr","_wait","link","replaceUrl","timeout","replacments","relative","isRelative","onclick","links","srcs","stylesheets","getText","cssUrls","newText","_URL","webkitURL","mozURL","createObjectURL","replaced","loadLib","urlCache","zipUrl","JSZip","parser","DOMParser","parseFromString","mime","unarchiver","decodededUrl","decodeURIComponent","file","asUint8Array","getMimeType","asText","fromCache","revokeObjectURL","afterSaved","toStorage","that","saveEntryFileToStorage"],"mappings":"CAAA,WAAY,GAAIA,GAAEC,KAAKC,EAAEF,EAAEG,EAAEC,KAAKC,EAAEC,MAAMC,UAAUC,EAAEC,OAAOF,UAAUG,EAAEC,SAASJ,UAAUK,EAAEP,EAAEQ,KAAKC,EAAET,EAAEU,MAAMC,EAAEX,EAAEY,OAAOC,EAAEV,EAAEW,SAASC,EAAEZ,EAAEa,eAAeC,EAAEjB,EAAEkB,QAAQC,EAAEnB,EAAEoB,IAAIC,EAAErB,EAAEsB,OAAOC,EAAEvB,EAAEwB,YAAYC,EAAEzB,EAAE0B,OAAOC,EAAE3B,EAAE4B,MAAMC,EAAE7B,EAAE8B,KAAKC,EAAE/B,EAAEgC,QAAQC,EAAEjC,EAAEkC,YAAYC,EAAElC,MAAMmC,QAAQtC,EAAEM,OAAOiC,KAAKC,EAAEjC,EAAEkC,KAAKC,EAAE,SAAS7C,GAAG,MAAOA,aAAa6C,GAAE7C,EAAEC,eAAgB4C,QAAG5C,KAAK6C,SAAS9C,GAAU,GAAI6C,GAAE7C,GAAI,oBAAoB+C,UAAS,mBAAoBC,SAAQA,OAAOD,UAAUA,QAAQC,OAAOD,QAAQF,GAAGE,QAAQ5C,EAAE0C,GAAG7C,EAAEG,EAAE0C,EAAEA,EAAEI,QAAQ,OAAQ,IAAIC,GAAEL,EAAEM,KAAKN,EAAEtB,QAAQ,SAASvB,EAAEE,EAAEG,GAAG,GAAG,MAAML,EAAE,GAAGsB,GAAGtB,EAAEuB,UA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L,WAAW3iB,UAAUuoC,WAAa,WACxC7oC,KAAK+M,YAGNmK,OAAO+L,WAAW3iB,UAAUwoC,UAAY,SAASx6B,GAMhD,QAASvB,KACRosB,IACa,IAAVA,GAAa4P,EAAKF,aAPtB,GAAIjC,GAAU,EACbl/B,EAAQ,GACRqhC,EAAO/oC,KACPm5B,EAAQ7qB,EAAQnL,MAOjBmL,GAAQhN,QAAQ,SAASsN,GAExBjH,WAAW,SAASiH,GACnBm6B,EAAKC,uBAAuBp6B,EAAO7B,IACjC65B,EAASh4B,GAEZg4B,GAAWl/B,IAGZyV,QAAQkO,IAAI,OAAQub"} \ No newline at end of file diff --git a/static/epub.js/epub.min.js b/static/epub.js/epub.min.js deleted file mode 100644 index cb42010..0000000 --- a/static/epub.js/epub.min.js +++ /dev/null @@ -1,7462 +0,0 @@ -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i},w.bind=function(n,t){if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));var r=o.call(arguments,2);return function(){return n.apply(t,r.concat(o.call(arguments)))}},w.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var I=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=I(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&I(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return I(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),"function"!=typeof/./&&(w.isFunction=function(n){return"function"==typeof n}),w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return n===void 0},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};M.unescape=w.invert(M.escape);var S={escape:RegExp("["+w.keys(M.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(M.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(S[n],function(t){return M[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=++N+"";return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,q={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||T).source,(r.interpolate||T).source,(r.evaluate||T).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(B,function(n){return"\\"+q[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var D=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); -(function(global) { -var define, requireModule, require, requirejs; - -(function() { - var registry = {}, seen = {}; - - define = function(name, deps, callback) { - registry[name] = { deps: deps, callback: callback }; - }; - - requirejs = require = requireModule = function(name) { - requirejs._eak_seen = registry; - - if (seen[name]) { return seen[name]; } - seen[name] = {}; - - if (!registry[name]) { - throw new Error("Could not find module " + name); - } - - var mod = registry[name], - deps = mod.deps, - callback = mod.callback, - reified = [], - exports; - - for (var i=0, l=deps.length; i 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - var alice = { name: 'alice' }; - var bob = { name: 'bob' }; - var users = [ alice, bob ]; - - var promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - var filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ - function filter(promises, filterFn, label) { - if (!isArray(promises)) { - throw new TypeError('You must pass an array to filter.'); - } - - if (!isFunction(filterFn)){ - throw new TypeError("You must pass a function to filter's second argument."); - } - - return all(promises, label).then(function(values){ - return map(promises, filterFn, label).then(function(filterResults){ - var i, - valuesLen = values.length, - filtered = []; - - for (i = 0; i < valuesLen; i++){ - if(filterResults[i]) filtered.push(values[i]); - } - return filtered; - }); - }); - } - - __exports__["default"] = filter; - }); -define("rsvp/hash", - ["./promise","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var isNonThenable = __dependency2__.isNonThenable; - var keysOf = __dependency2__.keysOf; - - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as as the first argument, or as the reason to - the rejection handler. For example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error("rejectedPromise")), - anotherRejectedPromise: RSVP.reject(new Error("anotherRejectedPromise")), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "rejectedPromise" - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve("Example"); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve("Proto Property") - }; - - var myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: "Example" - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @for RSVP - @param {Object} promises - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function hash(object, label) { - return new Promise(function(resolve, reject){ - var results = {}; - var keys = keysOf(object); - var remaining = keys.length; - var entry, property; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfilledTo(property) { - return function(value) { - results[property] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var i = 0; i < keys.length; i++) { - property = keys[i]; - entry = object[property]; - - if (isNonThenable(entry)) { - results[property] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Promise.cast(entry).then(fulfilledTo(property), onRejection); - } - } - }); - }; - }); -define("rsvp/instrument", - ["./config","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var now = __dependency2__.now; - - __exports__["default"] = function instrument(eventName, promise, child) { - // instrumentation should not disrupt normal usage. - try { - config.trigger(eventName, { - guid: promise._guidKey + promise._id, - eventName: eventName, - detail: promise._detail, - childGuid: child && promise._guidKey + child._id, - label: promise._label, - timeStamp: now(), - stack: new Error(promise._label).stack - }); - } catch(error) { - setTimeout(function(){ - throw error; - }, 0); - } - }; - }); -define("rsvp/map", - ["./promise","./all","./utils","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var all = __dependency2__["default"]; - var isArray = __dependency3__.isArray; - var isFunction = __dependency3__.isFunction; - - /** - - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first becuase they contain a url to those comments. - - ```javscript - - var mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - */ - __exports__["default"] = function map(promises, mapFn, label) { - - if (!isArray(promises)) { - throw new TypeError('You must pass an array to map.'); - } - - if (!isFunction(mapFn)){ - throw new TypeError("You must pass a function to map's second argument."); - } - - return all(promises, label).then(function(results){ - var resultLen = results.length, - mappedResults = [], - i; - - for (i = 0; i < resultLen; i++){ - mappedResults.push(mapFn(results[i])); - } - - return all(mappedResults, label); - }); - }; - }); -define("rsvp/node", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - var slice = Array.prototype.slice; - - function makeNodeCallbackFor(resolve, reject) { - return function (error, value) { - if (error) { - reject(error); - } else if (arguments.length > 2) { - resolve(slice.call(arguments, 1)); - } else { - resolve(value); - } - }; - } - - /** - `RSVP.denodeify` takes a "node-style" function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - var fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - var fs = require('fs'); - - var readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - var fs = require('fs'); - var log = require('some-async-logger'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - fs.writeFile('myfile2.txt', data, function(err){ - if (err) throw err; - log('success', function(err) { - if (err) throw err; - }); - }); - }); - ``` - - You can chain the operations together using `then` from the returned promise: - - ```javascript - var fs = require('fs'); - var denodeify = RSVP.denodeify; - var readFile = denodeify(fs.readFile); - var writeFile = denodeify(fs.writeFile); - var log = denodeify(require('some-async-logger')); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - return log('SUCCESS'); - }).then(function(){ - // success handler - }, function(reason){ - // rejection handler - }); - ``` - - @method denodeify - @for RSVP - @param {Function} nodeFunc a "node-style" function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ("function(err, value){ }"). - @param {Any} binding optional argument for binding the "this" value when - calling the `nodeFunc` function. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - */ - __exports__["default"] = function denodeify(nodeFunc, binding) { - return function() { - var nodeArgs = slice.call(arguments), resolve, reject; - var thisArg = this || binding; - - return new Promise(function(resolve, reject) { - Promise.all(nodeArgs).then(function(nodeArgs) { - try { - nodeArgs.push(makeNodeCallbackFor(resolve, reject)); - nodeFunc.apply(thisArg, nodeArgs); - } catch(e) { - reject(e); - } - }); - }); - }; - }; - }); -define("rsvp/promise", - ["./config","./events","./instrument","./utils","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var EventTarget = __dependency2__["default"]; - var instrument = __dependency3__["default"]; - var objectOrFunction = __dependency4__.objectOrFunction; - var isFunction = __dependency4__.isFunction; - var now = __dependency4__.now; - var cast = __dependency5__["default"]; - var all = __dependency6__["default"]; - var race = __dependency7__["default"]; - var Resolve = __dependency8__["default"]; - var Reject = __dependency9__["default"]; - - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; - - function noop() {} - - __exports__["default"] = Promise; - - - /** - - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - - Basic Usage: - ------------ - - ```js - var promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - var xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error("getJSON: `" + url + "` failed with status: [" + this.status + "]"); - } - } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - if (!isFunction(resolver)) { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); - } - - if (!(this instanceof Promise)) { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); - } - - this._id = counter++; - this._label = label; - this._subscribers = []; - - if (config.instrument) { - instrument('created', this); - } - - if (noop !== resolver) { - invokeResolver(resolver, this); - } - } - - function invokeResolver(resolver, promise) { - function resolvePromise(value) { - resolve(promise, value); - } - - function rejectPromise(reason) { - reject(promise, reason); - } - - try { - resolver(resolvePromise, rejectPromise); - } catch(e) { - rejectPromise(e); - } - } - - Promise.cast = cast; - Promise.all = all; - Promise.race = race; - Promise.resolve = Resolve; - Promise.reject = Reject; - - var PENDING = void 0; - var SEALED = 0; - var FULFILLED = 1; - var REJECTED = 2; - - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; - - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; - } - - function publish(promise, settled) { - var child, callback, subscribers = promise._subscribers, detail = promise._detail; - - if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); - } - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - invokeCallback(settled, child, callback, detail); - } - - promise._subscribers = null; - } - - Promise.prototype = { - /** - @property constructor - */ - constructor: Promise, - - _id: undefined, - _guidKey: guidKey, - _label: undefined, - - _state: undefined, - _detail: undefined, - _subscribers: undefined, - - _onerror: function (reason) { - config.trigger('error', reason); - }, - - /** - - A promise represents the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, "downstream" - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return "default name"; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `"default name"` - }); - - findUser().then(function (user) { - throw "Found user, but still unhappy"; - }, function (reason) { - throw "`findUser` rejected and we're unhappy"; - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be "Found user, but still unhappy". - // If `findUser` rejected, `reason` will be "`findUser` rejected and we're unhappy". - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException("Upstream error"); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - var result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findResult().then(function(result){ - - }, function(reason){ - - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - var author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong; - }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: function(onFulfillment, onRejection, label) { - var promise = this; - this._onerror = null; - - var thenPromise = new this.constructor(noop, label); - - if (this._state) { - var callbacks = arguments; - config.async(function invokePromiseCallback() { - invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail); - }); - } else { - subscribe(this, thenPromise, onFulfillment, onRejection); - } - - if (config.instrument) { - instrument('chained', promise, thenPromise); - } - - return thenPromise; - }, - - /** - `catch` is simply sugar for `then(null, onRejection)` which makes it the same - as the catch block, of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error("couldn't find that author"); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong; - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'catch': function(onRejection, label) { - return this.then(null, onRejection, label); - }, - - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't effect the return value - } - - findAuthor().finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'finally': function(callback, label) { - var constructor = this.constructor; - - return this.then(function(value) { - return constructor.cast(callback()).then(function(){ - return value; - }); - }, function(reason) { - return constructor.cast(callback()).then(function(){ - throw reason; - }); - }, label); - } - }; - - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value, error, succeeded, failed; - - if (hasCallback) { - try { - value = callback(detail); - succeeded = true; - } catch(e) { - failed = true; - error = e; - } - } else { - value = detail; - succeeded = true; - } - - if (handleThenable(promise, value)) { - return; - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - resolve(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function handleThenable(promise, value) { - var then = null, - resolved; - - try { - if (promise === value) { - throw new TypeError("A promises callback cannot return that same promise."); - } - - if (objectOrFunction(value)) { - then = value.then; - - if (isFunction(then)) { - then.call(value, function(val) { - if (resolved) { return true; } - resolved = true; - - if (value !== val) { - resolve(promise, val); - } else { - fulfill(promise, val); - } - }, function(val) { - if (resolved) { return true; } - resolved = true; - - reject(promise, val); - }, 'derived from: ' + (promise._label || ' unknown promise')); - - return true; - } - } - } catch (error) { - if (resolved) { return true; } - reject(promise, error); - return true; - } - - return false; - } - - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (!handleThenable(promise, value)) { - fulfill(promise, value); - } - } - - function fulfill(promise, value) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = value; - - config.async(publishFulfillment, promise); - } - - function reject(promise, reason) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = reason; - - config.async(publishRejection, promise); - } - - function publishFulfillment(promise) { - publish(promise, promise._state = FULFILLED); - } - - function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._detail); - } - - publish(promise, promise._state = REJECTED); - } - }); -define("rsvp/promise/all", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var isArray = __dependency1__.isArray; - var isNonThenable = __dependency1__.isNonThenable; - - /** - - `RSVP.Promise.all` returns a new promise which is fulfilled with an array of - fulfillment values for the passed promises, or rejects with the reason of the - first passed promise that rejects. It casts all elements of the passed iterable - to promises as it runs this algorithm. - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @for RSVP.Promise - @param {Array} promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function all(entries, label) { - - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to all.'); - } - - var remaining = entries.length; - var results = new Array(remaining); - var entry, pending = true; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfillmentAt(index) { - return function(value) { - results[index] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var index = 0; index < entries.length; index++) { - entry = entries[index]; - if (isNonThenable(entry)) { - results[index] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Constructor.cast(entry).then(fulfillmentAt(index), onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/cast", - ["exports"], - function(__exports__) { - "use strict"; - /** - - `RSVP.Promise.cast` cast coerces its argument to a promise, or returns the - argument if it is already a promise which shares a constructor with the caster; - - Example: - - ```javascript - var promise = RSVP.Promise.resolve(1); - var casted = RSVP.Promise.cast(promise); - - console.log(promise === casted); // true - ``` - - In the case of a promise whose constructor does not match, it is assimilated. - The resulting promise will fulfill or reject based on the outcome of the - promise being casted. - - In the case of a non-promise, a promise which will fulfill with that value is - returned. - - Example: - - ```javascript - var value = 1; // could be a number, boolean, string, undefined... - var casted = RSVP.Promise.cast(value); - - console.log(value === casted); // false - console.log(casted instanceof RSVP.Promise) // true - - casted.then(function(val) { - val === value // => true - }); - ``` - - `RSVP.Promise.cast` is similar to `RSVP.Promise.resolve`, but `RSVP.Promise.cast` differs in the - following ways: - - * `RSVP.Promise.cast` serves as a memory-efficient way of getting a promise, when you - have something that could either be a promise or a value. RSVP.resolve - will have the same effect but will create a new promise wrapper if the - argument is a promise. - * `RSVP.Promise.cast` is a way of casting incoming thenables or promise subclasses to - promises of the exact class specified, so that the resulting object's `then` is - ensured to have the behavior of the constructor you are calling cast on (i.e., RSVP.Promise). - - @method cast - @for RSVP.Promise - @param {Object} object to be casted - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise - */ - - __exports__["default"] = function cast(object, label) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - return new Constructor(function(resolve) { - resolve(object); - }, label); - }; - }); -define("rsvp/promise/race", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - /* global toString */ - - var isArray = __dependency1__.isArray; - var isFunction = __dependency1__.isFunction; - var isNonThenable = __dependency1__.isNonThenable; - - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 2"); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === "promise 2" because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - completed promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first completed promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error("promise 2")); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs because there are rejected promises! - }, function(reason){ - // reason.message === "promise2" because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - @method race - @for RSVP.Promise - @param {Array} promises array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - __exports__["default"] = function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this, entry; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to race.'); - } - - var pending = true; - - function onFulfillment(value) { if (pending) { pending = false; resolve(value); } } - function onRejection(reason) { if (pending) { pending = false; reject(reason); } } - - for (var i = 0; i < entries.length; i++) { - entry = entries[i]; - if (isNonThenable(entry)) { - pending = false; - resolve(entry); - return; - } else { - Constructor.cast(entry).then(onFulfillment, onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/reject", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @for RSVP.Promise - @param {Any} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - __exports__["default"] = function reject(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function (resolve, reject) { - reject(reason); - }, label); - }; - }); -define("rsvp/promise/resolve", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.resolve` returns a promise that will become fulfilled with the passed - `value`. It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @for RSVP.Promise - @param {Any} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - __exports__["default"] = function resolve(value, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - resolve(value); - }, label); - }; - }); -define("rsvp/race", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function race(array, label) { - return Promise.race(array, label); - }; - }); -define("rsvp/reject", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function reject(reason, label) { - return Promise.reject(reason, label); - }; - }); -define("rsvp/resolve", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function resolve(value, label) { - return Promise.resolve(value, label); - }; - }); -define("rsvp/rethrow", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will throw the error - again so the error can be handled by the promise. - - ```javascript - function throws(){ - throw new Error('Whoops!'); - } - - var promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - */ - __exports__["default"] = function rethrow(reason) { - setTimeout(function() { - throw reason; - }); - throw reason; - }; - }); -define("rsvp/utils", - ["exports"], - function(__exports__) { - "use strict"; - function objectOrFunction(x) { - return typeof x === "function" || (typeof x === "object" && x !== null); - } - - __exports__.objectOrFunction = objectOrFunction;function isFunction(x) { - return typeof x === "function"; - } - - __exports__.isFunction = isFunction;function isNonThenable(x) { - return !objectOrFunction(x); - } - - __exports__.isNonThenable = isNonThenable;function isArray(x) { - return Object.prototype.toString.call(x) === "[object Array]"; - } - - __exports__.isArray = isArray;// Date.now is not available in browsers < IE9 - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility - var now = Date.now || function() { return new Date().getTime(); }; - __exports__.now = now; - var keysOf = Object.keys || function(object) { - var result = []; - - for (var prop in object) { - result.push(prop); - } - - return result; - }; - __exports__.keysOf = keysOf; - }); -define("rsvp", - ["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all_settled","./rsvp/race","./rsvp/hash","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/asap","./rsvp/filter","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var EventTarget = __dependency2__["default"]; - var denodeify = __dependency3__["default"]; - var all = __dependency4__["default"]; - var allSettled = __dependency5__["default"]; - var race = __dependency6__["default"]; - var hash = __dependency7__["default"]; - var rethrow = __dependency8__["default"]; - var defer = __dependency9__["default"]; - var config = __dependency10__.config; - var configure = __dependency10__.configure; - var map = __dependency11__["default"]; - var resolve = __dependency12__["default"]; - var reject = __dependency13__["default"]; - var asap = __dependency14__["default"]; - var filter = __dependency15__["default"]; - - config.async = asap; // default async is asap; - - function async(callback, arg) { - config.async(callback, arg); - } - - function on() { - config.on.apply(config, arguments); - } - - function off() { - config.off.apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window.__PROMISE_INSTRUMENTATION__ === 'object') { - var callbacks = window.__PROMISE_INSTRUMENTATION__; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - __exports__.Promise = Promise; - __exports__.EventTarget = EventTarget; - __exports__.all = all; - __exports__.allSettled = allSettled; - __exports__.race = race; - __exports__.hash = hash; - __exports__.rethrow = rethrow; - __exports__.defer = defer; - __exports__.denodeify = denodeify; - __exports__.configure = configure; - __exports__.on = on; - __exports__.off = off; - __exports__.resolve = resolve; - __exports__.reject = reject; - __exports__.async = async; - __exports__.map = map; - __exports__.filter = filter; - }); -global.RSVP = requireModule('rsvp'); -}(window)); -'use strict'; - -var EPUBJS = EPUBJS || {}; -EPUBJS.VERSION = "0.2.3"; - -EPUBJS.plugins = EPUBJS.plugins || {}; - -EPUBJS.filePath = EPUBJS.filePath || "/epubjs/"; - -EPUBJS.Render = {}; - -(function(root) { - - var previousEpub = root.ePub || {}; - - var ePub = root.ePub = function() { - var bookPath, options; - - //-- var book = ePub("path/to/book.epub", { restore: true }) - if(typeof(arguments[0]) != 'undefined' && - typeof arguments[0] === 'string') { - - bookPath = arguments[0]; - - if( arguments[1] && typeof arguments[1] === 'object' ) { - options = arguments[1]; - options.bookPath = bookPath; - } else { - options = { 'bookPath' : bookPath }; - } - - } - - /* - * var book = ePub({ bookPath: "path/to/book.epub", restore: true }); - * - * - OR - - * - * var book = ePub({ restore: true }); - * book.open("path/to/book.epub"); - */ - - if( arguments[0] && typeof arguments[0] === 'object' ) { - options = arguments[0]; - } - - - return new EPUBJS.Book(options); - }; - - _.extend(ePub, { - noConflict : function() { - root.ePub = previousEpub; - return this; - } - }); - - //exports to multiple environments - if (typeof define === 'function' && define.amd) - //AMD - define(function(){ return ePub; }); - else if (typeof module != "undefined" && module.exports) - //Node - module.exports = ePub; - -})(window); - -EPUBJS.Book = function(options){ - - var book = this; - - this.settings = _.defaults(options || {}, { - bookPath : null, - bookKey : null, - packageUrl : null, - storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem' - fromStorage : false, - saved : false, - online : true, - contained : false, - width : null, - height: null, - layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'} - orientation : null, - minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always) - gap: "auto", //-- "auto" or int - version: 1, - restore: false, - reload : false, - goto : false, - styles : {}, - headTags : {}, - withCredentials: false, - render_method: "Iframe" - }); - - this.settings.EPUBJSVERSION = EPUBJS.VERSION; - - this.spinePos = 0; - this.stored = false; - - //-- All Book events for listening - /* - book:ready - book:stored - book:online - book:offline - book:pageChanged - book:loadFailed - book:loadChapterFailed - */ - - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - // EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - // this.getHooks("beforeChapterDisplay"); - - this.online = this.settings.online || navigator.onLine; - this.networkListeners(); - - this.store = false; //-- False if not using storage; - - //-- Determine storage method - //-- Override options: none | ram | websqldatabase | indexeddb | filesystem - - if(this.settings.storage !== false){ - this.storage = new fileStorage.storage(this.settings.storage); - } - - this.ready = { - manifest: new RSVP.defer(), - spine: new RSVP.defer(), - metadata: new RSVP.defer(), - cover: new RSVP.defer(), - toc: new RSVP.defer(), - pageList: new RSVP.defer() - }; - - this.readyPromises = [ - this.ready.manifest.promise, - this.ready.spine.promise, - this.ready.metadata.promise, - this.ready.cover.promise, - this.ready.toc.promise - ]; - - this.pageList = []; - this.pagination = new EPUBJS.Pagination(); - this.pageListReady = this.ready.pageList.promise; - - this.ready.all = RSVP.all(this.readyPromises); - - this.ready.all.then(this._ready.bind(this)); - - // Queue for methods used before rendering - this.isRendered = false; - this._q = EPUBJS.core.queue(this); - // Queue for rendering - this._rendering = false; - this._displayQ = EPUBJS.core.queue(this); - // Queue for going to another location - this._moving = false; - this._gotoQ = EPUBJS.core.queue(this); - - /** - * Creates a new renderer. - * The renderer will handle displaying the content using the method provided in the settings - */ - this.renderer = new EPUBJS.Renderer(this.settings.render_method); - //-- Set the width at which to switch from spreads to single pages - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.setGap(this.settings.gap); - //-- Pass through the renderer events - this.listenToRenderer(this.renderer); - - this.defer_opened = new RSVP.defer(); - this.opened = this.defer_opened.promise; - // BookUrl is optional, but if present start loading process - if(typeof this.settings.bookPath === 'string') { - this.open(this.settings.bookPath, this.settings.reload); - } - - window.addEventListener("beforeunload", this.unload.bind(this), false); - - //-- Listen for these promises: - //-- book.opened.then() - //-- book.rendered.then() -}; - -//-- Check bookUrl and start parsing book Assets or load them from storage -EPUBJS.Book.prototype.open = function(bookPath, forceReload){ - var book = this, - epubpackage, - opened = new RSVP.defer(); - - this.settings.bookPath = bookPath; - - //-- Get a absolute URL from the book path - this.bookUrl = this.urlFrom(bookPath); - - if(this.settings.contained || this.isContained(bookPath)){ - - this.settings.contained = this.contained = true; - - this.bookUrl = ''; - - epubpackage = this.unarchive(bookPath). - then(function(){ - return book.loadPackage(); - }); - - } else { - epubpackage = this.loadPackage(); - } - - if(this.settings.restore && !forceReload && localStorage){ - //-- Will load previous package json, or re-unpack if error - epubpackage.then(function(packageXml) { - var identifier = book.packageIdentifier(packageXml); - var restored = book.restore(identifier); - - if(!restored) { - book.unpack(packageXml); - } - opened.resolve(); - book.defer_opened.resolve(); - }); - - }else{ - - //-- Get package information from epub opf - epubpackage.then(function(packageXml) { - book.unpack(packageXml); - opened.resolve(); - book.defer_opened.resolve(); - }); - } - - //-- If there is network connection, store the books contents - if(this.online && this.settings.storage && !this.settings.contained){ - if(!this.settings.stored) opened.then(book.storeOffline()); - } - - this._registerReplacements(this.renderer); - - return opened.promise; - -}; - -EPUBJS.Book.prototype.loadPackage = function(_containerPath){ - var book = this, - parse = new EPUBJS.Parser(), - containerPath = _containerPath || "META-INF/container.xml", - containerXml, - packageXml; - - if(!this.settings.packageUrl) { //-- provide the packageUrl to skip this step - packageXml = book.loadXml(book.bookUrl + containerPath). - then(function(containerXml){ - return parse.container(containerXml); // Container has path to content - }). - then(function(paths){ - book.settings.contentsPath = book.bookUrl + paths.basePath; - book.settings.packageUrl = book.bookUrl + paths.packagePath; - book.settings.encoding = paths.encoding; - return book.loadXml(book.settings.packageUrl); // Containes manifest, spine and metadata - }); - } else { - packageXml = book.loadXml(book.settings.packageUrl); - } - - packageXml.catch(function(error) { - // handle errors in either of the two requests - console.error("Could not load book at: "+ containerPath); - book.trigger("book:loadFailed", containerPath); - }); - return packageXml; -}; - -EPUBJS.Book.prototype.packageIdentifier = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - return parse.identifier(packageXml); -}; - -EPUBJS.Book.prototype.unpack = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - book.contents = parse.packageContents(packageXml, book.settings.contentsPath); // Extract info from contents - - book.manifest = book.contents.manifest; - book.spine = book.contents.spine; - book.spineIndexByURL = book.contents.spineIndexByURL; - book.metadata = book.contents.metadata; - if(!book.settings.bookKey) { - book.settings.bookKey = book.generateBookKey(book.metadata.identifier); - } - - //-- Set Globbal Layout setting based on metadata - book.globalLayoutProperties = book.parseLayoutProperties(book.metadata); - - if(book.contents.coverPath) { - book.cover = book.contents.cover = book.settings.contentsPath + book.contents.coverPath; - } - - book.spineNodeIndex = book.contents.spineNodeIndex; - - book.ready.manifest.resolve(book.contents.manifest); - book.ready.spine.resolve(book.contents.spine); - book.ready.metadata.resolve(book.contents.metadata); - book.ready.cover.resolve(book.contents.cover); - - - //-- Load the TOC, optional; either the EPUB3 XHTML Navigation file or the EPUB2 NCX file - if(book.contents.navPath) { - book.settings.navUrl = book.settings.contentsPath + book.contents.navPath; - - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.nav(navHtml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - // Load the optional pageList - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.pageList(navHtml, book.spineIndexByURL, book.spine); - }).then(function(pageList){ - var epubcfi = new EPUBJS.EpubCFI(); - var wait = 0; // need to generate a cfi - - // No pageList found - if(pageList.length === 0) { - return; - } - - book.pageList = book.contents.pageList = pageList; - - // Replace HREFs with CFI - book.pageList.forEach(function(pg){ - if(!pg.cfi) { - wait += 1; - epubcfi.generateCfiFromHref(pg.href, book).then(function(cfi){ - pg.cfi = cfi; - pg.packageUrl = book.settings.packageUrl; - - wait -= 1; - if(wait === 0) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - }); - } - }); - - if(!wait) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - - }, function(error) { - book.ready.pageList.resolve([]); - }); - } else if(book.contents.tocPath) { - book.settings.tocUrl = book.settings.contentsPath + book.contents.tocPath; - - book.loadXml(book.settings.tocUrl). - then(function(tocXml){ - return parse.toc(tocXml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - } else { - book.ready.toc.resolve(false); - } - -}; - -EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) { - var box = this.element.getBoundingClientRect(); - var width = _width || this.settings.width || box.width; - var height = _height || this.settings.height || box.height; - var hiddenContainer; - var hiddenEl; - renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - renderer.setGap(this.settings.gap); - - this._registerReplacements(renderer); - if(this.settings.forceSingle) { - renderer.forceSingle(true); - } - - hiddenContainer = document.createElement("div"); - hiddenContainer.style.visibility = "hidden"; - hiddenContainer.style.overflow = "hidden"; - hiddenContainer.style.width = "0"; - hiddenContainer.style.height = "0"; - this.element.appendChild(hiddenContainer); - - hiddenEl = document.createElement("div"); - hiddenEl.style.visibility = "hidden"; - hiddenEl.style.overflow = "hidden"; - hiddenEl.style.width = width + "px";//"0"; - hiddenEl.style.height = height +"px"; //"0"; - hiddenContainer.appendChild(hiddenEl); - - renderer.initialize(hiddenEl); - return hiddenContainer; -}; - -// Generates the pageList array by loading every chapter and paging through them -EPUBJS.Book.prototype.generatePageList = function(width, height){ - var pageList = []; - var pager = new EPUBJS.Renderer(this.settings.render_method, false); //hidden - var hiddenContainer = this.createHiddenRender(pager, width, height); - var deferred = new RSVP.defer(); - var spinePos = -1; - var spineLength = this.spine.length; - var totalPages = 0; - var currentPage = 0; - var nextChapter = function(deferred){ - var chapter; - var next = spinePos + 1; - var done = deferred || new RSVP.defer(); - var loaded; - if(next >= spineLength) { - done.resolve(); - } else { - spinePos = next; - chapter = new EPUBJS.Chapter(this.spine[spinePos], this.store); - pager.displayChapter(chapter, this.globalLayoutProperties).then(function(chap){ - pager.pageMap.forEach(function(item){ - currentPage += 1; - pageList.push({ - "cfi" : item.start, - "page" : currentPage - }); - - }); - - if(pager.pageMap.length % 2 > 0 && - pager.spreads) { - currentPage += 1; // Handle Spreads - pageList.push({ - "cfi" : pager.pageMap[pager.pageMap.length - 1].end, - "page" : currentPage - }); - } - - // Load up the next chapter - setTimeout(function(){ - nextChapter(done); - }, 1); - }); - } - return done.promise; - }.bind(this); - - var finished = nextChapter().then(function(){ - pager.remove(); - this.element.removeChild(hiddenContainer); - deferred.resolve(pageList); - }.bind(this)); - - return deferred.promise; -}; - -// Render out entire book and generate the pagination -// Width and Height are optional and will default to the current dimensions -EPUBJS.Book.prototype.generatePagination = function(width, height) { - var book = this; - var defered = new RSVP.defer(); - - this.ready.spine.promise.then(function(){ - book.generatePageList(width, height).then(function(pageList){ - book.pageList = book.contents.pageList = pageList; - book.pagination.process(pageList); - book.ready.pageList.resolve(book.pageList); - defered.resolve(book.pageList); - }); - }); - - return defered.promise; -}; - -// Process the pagination from a JSON array containing the pagelist -EPUBJS.Book.prototype.loadPagination = function(pagelistJSON) { - var pageList = JSON.parse(pagelistJSON); - - if(pageList && pageList.length) { - this.pageList = pageList; - this.pagination.process(this.pageList); - this.ready.pageList.resolve(this.pageList); - } - return this.pageList; -}; - -EPUBJS.Book.prototype.getPageList = function() { - return this.ready.pageList.promise; -}; - -EPUBJS.Book.prototype.getMetadata = function() { - return this.ready.metadata.promise; -}; - -EPUBJS.Book.prototype.getToc = function() { - return this.ready.toc.promise; -}; - -/* Private Helpers */ - -//-- Listeners for browser events -EPUBJS.Book.prototype.networkListeners = function(){ - var book = this; - - window.addEventListener("offline", function(e) { - book.online = false; - book.trigger("book:offline"); - }, false); - - window.addEventListener("online", function(e) { - book.online = true; - book.trigger("book:online"); - }, false); - -}; - -// Listen to all events the renderer triggers and pass them as book events -EPUBJS.Book.prototype.listenToRenderer = function(renderer){ - var book = this; - renderer.Events.forEach(function(eventName){ - renderer.on(eventName, function(e){ - book.trigger(eventName, e); - }); - }); - - renderer.on("renderer:visibleRangeChanged", function(range) { - var startPage, endPage, percent; - var pageRange = []; - - if(this.pageList.length > 0) { - startPage = this.pagination.pageFromCfi(range.start); - percent = this.pagination.percentageFromPage(startPage); - pageRange.push(startPage); - - if(range.end) { - endPage = this.pagination.pageFromCfi(range.end); - //if(startPage != endPage) { - pageRange.push(endPage); - //} - } - this.trigger("book:pageChanged", { - "anchorPage": startPage, - "percentage": percent, - "pageRange" : pageRange - }); - - // TODO: Add event for first and last page. - // (though last is going to be hard, since it could be several reflowed pages long) - } - }.bind(this)); - - renderer.on("render:loaded", this.loadChange.bind(this)); -}; - -// Listens for load events from the Renderer and checks against the current chapter -// Prevents the Render from loading a different chapter when back button is pressed -EPUBJS.Book.prototype.loadChange = function(url){ - var uri = EPUBJS.core.uri(url); - var chapter; - - if(this.currentChapter) { - chapter = EPUBJS.core.uri(this.currentChapter.absolute); - } - - if(!this._rendering && this.currentChapter && uri.path != chapter.path){ - console.warn("Miss Match", uri.path, this.currentChapter.absolute); - this.goto(uri.filename); - } -}; - -EPUBJS.Book.prototype.unlistenToRenderer = function(renderer){ - renderer.Events.forEach(function(eventName){ - renderer.off(eventName); - } ); -}; - -//-- Choose between a request from store or a request from network -EPUBJS.Book.prototype.loadXml = function(url){ - if(this.settings.fromStorage) { - return this.storage.getXml(url, this.settings.encoding); - } else if(this.settings.contained) { - return this.zip.getXml(url, this.settings.encoding); - }else{ - return EPUBJS.core.request(url, 'xml', this.settings.withCredentials); - } -}; - -//-- Turns a url into a absolute url -EPUBJS.Book.prototype.urlFrom = function(bookPath){ - var uri = EPUBJS.core.uri(bookPath), - absolute = uri.protocol, - fromRoot = uri.path[0] == "/", - location = window.location, - //-- Get URL orgin, try for native or combine - origin = location.origin || location.protocol + "//" + location.host, - baseTag = document.getElementsByTagName('base'), - base; - - - //-- Check is Base tag is set - - if(baseTag.length) { - base = baseTag[0].href; - } - - //-- 1. Check if url is absolute - if(uri.protocol){ - return uri.origin + uri.path; - } - - //-- 2. Check if url starts with /, add base url - if(!absolute && fromRoot){ - return (base || origin) + uri.path; - } - - //-- 3. Or find full path to url and add that - if(!absolute && !fromRoot){ - return EPUBJS.core.resolveUrl(base || location.pathname, uri.path); - } - -}; - - -EPUBJS.Book.prototype.unarchive = function(bookPath){ - var book = this, - unarchived; - - //-- Must use storage - // if(this.settings.storage == false ){ - // this.settings.storage = true; - // this.storage = new fileStorage.storage(); - // } - - this.zip = new EPUBJS.Unarchiver(); - this.store = this.zip; // Use zip storaged in ram - return this.zip.openZip(bookPath); -}; - -//-- Checks if url has a .epub or .zip extension -EPUBJS.Book.prototype.isContained = function(bookUrl){ - var uri = EPUBJS.core.uri(bookUrl); - - if(uri.extension && (uri.extension == "epub" || uri.extension == "zip")){ - return true; - } - - return false; -}; - -//-- Checks if the book can be retrieved from localStorage -EPUBJS.Book.prototype.isSaved = function(bookKey) { - var storedSettings; - - if(!localStorage) { - return false; - } - - storedSettings = localStorage.getItem(bookKey); - - if( !localStorage || - storedSettings === null) { - return false; - } else { - return true; - } -}; - -// Generates the Book Key using the identifer in the manifest or other string provided -EPUBJS.Book.prototype.generateBookKey = function(identifier){ - return "epubjs:" + EPUBJS.VERSION + ":" + window.location.host + ":" + identifier; -}; - -EPUBJS.Book.prototype.saveContents = function(){ - if(!localStorage) { - return false; - } - localStorage.setItem(this.settings.bookKey, JSON.stringify(this.contents)); -}; - -EPUBJS.Book.prototype.removeSavedContents = function() { - if(!localStorage) { - return false; - } - localStorage.removeItem(this.settings.bookKey); -}; - - - -//-- Takes a string or a element -EPUBJS.Book.prototype.renderTo = function(elem){ - var book = this, - rendered; - - if(_.isElement(elem)) { - this.element = elem; - } else if (typeof elem == "string") { - this.element = EPUBJS.core.getEl(elem); - } else { - console.error("Not an Element"); - return; - } - - rendered = this.opened. - then(function(){ - // book.render = new EPUBJS.Renderer[this.settings.renderer](book); - book.renderer.initialize(book.element, book.settings.width, book.settings.height); - book._rendered(); - return book.startDisplay(); - }); - - // rendered.then(null, function(error) { console.error(error); }); - - return rendered; -}; - -EPUBJS.Book.prototype.startDisplay = function(){ - var display; - - if(this.settings.goto) { - display = this.goto(this.settings.goto); - }else if(this.settings.previousLocationCfi) { - display = this.gotoCfi(this.settings.previousLocationCfi); - }else{ - display = this.displayChapter(this.spinePos); - } - - return display; -}; - -EPUBJS.Book.prototype.restore = function(identifier){ - - var book = this, - fetch = ['manifest', 'spine', 'metadata', 'cover', 'toc', 'spineNodeIndex', 'spineIndexByURL', 'globalLayoutProperties'], - reject = false, - bookKey = this.generateBookKey(identifier), - fromStore = localStorage.getItem(bookKey), - len = fetch.length, - i; - - if(this.settings.clearSaved) reject = true; - - if(!reject && fromStore != 'undefined' && fromStore !== null){ - book.contents = JSON.parse(fromStore); - - for(i = 0; i < len; i++) { - var item = fetch[i]; - - if(!book.contents[item]) { - reject = true; - break; - } - book[item] = book.contents[item]; - } - } - - if(reject || !fromStore || !this.contents || !this.settings.contentsPath){ - return false; - }else{ - this.settings.bookKey = bookKey; - this.ready.manifest.resolve(this.manifest); - this.ready.spine.resolve(this.spine); - this.ready.metadata.resolve(this.metadata); - this.ready.cover.resolve(this.cover); - this.ready.toc.resolve(this.toc); - return true; - } - -}; - -EPUBJS.Book.prototype.displayChapter = function(chap, end, deferred){ - var book = this, - render, - cfi, - pos, - store, - defer = deferred || new RSVP.defer(); - - var chapter; - - if(!this.isRendered) { - this._q.enqueue("displayChapter", arguments); - // Reject for now. TODO: pass promise to queue - defer.reject({ - message : "Rendering", - stack : new Error().stack - }); - return defer.promise; - } - - - if(this._rendering || this._rendering) { - // Pass along the current defer - this._displayQ.enqueue("displayChapter", [chap, end, defer]); - return defer.promise; - } - - if(_.isNumber(chap)){ - pos = chap; - }else{ - cfi = new EPUBJS.EpubCFI(chap); - pos = cfi.spinePos; - } - - if(pos < 0 || pos >= this.spine.length){ - console.warn("Not A Valid Location"); - pos = 0; - end = false; - cfi = false; - } - - //-- Create a new chapter - chapter = new EPUBJS.Chapter(this.spine[pos], this.store); - - this._rendering = true; - - render = book.renderer.displayChapter(chapter, this.globalLayoutProperties); - if(cfi) { - book.renderer.gotoCfi(cfi); - } else if(end) { - book.renderer.lastPage(); - } - //-- Success, Clear render queue - render.then(function(rendered){ - // var inwait; - //-- Set the book's spine position - book.spinePos = pos; - - defer.resolve(book.renderer); - - if(!book.settings.fromStorage && - !book.settings.contained) { - book.preloadNextChapter(); - } - - book.currentChapter = chapter; - book._rendering = false; - book._displayQ.dequeue(); - if(book._displayQ.length() === 0) { - book._gotoQ.dequeue(); - } - - }, function(error) { - // handle errors in either of the two requests - console.error("Could not load Chapter: "+ chapter.absolute); - book.trigger("book:chapterLoadFailed", chapter.absolute); - book._rendering = false; - defer.reject(error); - }); - - return defer.promise; -}; - -EPUBJS.Book.prototype.nextPage = function(){ - var next; - - if(!this.isRendered) return this._q.enqueue("nextPage", arguments); - - next = this.renderer.nextPage(); - - if(!next){ - return this.nextChapter(); - } -}; - -EPUBJS.Book.prototype.prevPage = function() { - var prev; - - if(!this.isRendered) return this._q.enqueue("prevPage", arguments); - - prev = this.renderer.prevPage(); - - if(!prev){ - return this.prevChapter(); - } -}; - -EPUBJS.Book.prototype.nextChapter = function() { - var next; - if (this.spinePos < this.spine.length - 1) { - next = this.spinePos + 1; - // Skip non linear chapters - while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') { - next++; - } - if (next < this.spine.length) { - return this.displayChapter(next); - } else { - this.trigger("book:atEnd"); - } - - } else { - this.trigger("book:atEnd"); - } -}; - -EPUBJS.Book.prototype.prevChapter = function() { - var prev; - if (this.spinePos > 0) { - prev = this.spinePos - 1; - while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') { - prev--; - } - if (prev >= 0) { - return this.displayChapter(prev, true); - } else { - this.trigger("book:atStart"); - } - - } else { - this.trigger("book:atStart"); - } -}; - -EPUBJS.Book.prototype.getCurrentLocationCfi = function() { - if(!this.isRendered) return false; - return this.renderer.currentLocationCfi; -}; - -EPUBJS.Book.prototype.goto = function(target){ - - if(target.indexOf("epubcfi(") === 0) { - return this.gotoCfi(target); - } else if(target.indexOf("%") === target.length-1) { - return this.gotoPercentage(parseInt(target.substring(0, target.length-1))/100); - } else if(typeof target === "number" || isNaN(target) === false){ - return this.gotoPage(target); - } else { - return this.gotoHref(target); - } - -}; - -EPUBJS.Book.prototype.gotoCfi = function(cfiString, defer){ - var cfi, - spinePos, - spineItem, - rendered, - deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - console.warn("Not yet Rendered"); - this.settings.previousLocationCfi = cfiString; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - console.warn("Renderer is moving"); - this._gotoQ.enqueue("gotoCfi", [cfiString, deferred]); - return false; - } - - cfi = new EPUBJS.EpubCFI(cfiString); - spinePos = cfi.spinePos; - - if(spinePos == -1) { - return false; - } - - spineItem = this.spine[spinePos]; - promise = deferred.promise; - this._moving = true; - //-- If same chapter only stay on current chapter - if(this.currentChapter && this.spinePos === spinePos){ - this.renderer.gotoCfi(cfi); - this._moving = false; - deferred.resolve(this.renderer.currentLocationCfi); - } else { - - if(!spineItem || spinePos == -1) { - spinePos = 0; - spineItem = this.spine[spinePos]; - } - - this.currentChapter = new EPUBJS.Chapter(spineItem, this.store); - - if(this.currentChapter) { - this.spinePos = spinePos; - render = this.renderer.displayChapter(this.currentChapter, this.globalLayoutProperties); - - this.renderer.gotoCfi(cfi); - render.then(function(rendered){ - this._moving = false; - deferred.resolve(rendered.currentLocationCfi); - }.bind(this)); - } - } - - promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return promise; -}; - -EPUBJS.Book.prototype.gotoHref = function(url, defer){ - var split, chapter, section, relativeURL, spinePos; - var deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - this.settings.goto = url; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - this._gotoQ.enqueue("gotoHref", [url, deferred]); - return false; - } - - split = url.split("#"); - chapter = split[0]; - section = split[1] || false; - // absoluteURL = (chapter.search("://") === -1) ? (this.settings.contentsPath + chapter) : chapter; - relativeURL = chapter.replace(this.settings.contentsPath, ''); - spinePos = this.spineIndexByURL[relativeURL]; - - //-- If link fragment only stay on current chapter - if(!chapter){ - spinePos = this.currentChapter ? this.currentChapter.spinePos : 0; - } - - //-- Check that URL is present in the index, or stop - if(typeof(spinePos) != "number") return false; - - if(!this.currentChapter || spinePos != this.currentChapter.spinePos){ - //-- Load new chapter if different than current - return this.displayChapter(spinePos).then(function(){ - if(section){ - this.renderer.section(section); - } - deferred.resolve(this.renderer.currentLocationCfi); - }.bind(this)); - }else{ - //-- Goto section - if(section) { - this.renderer.section(section); - } else { - // Or jump to the start - this.renderer.firstPage(); - } - deferred.resolve(this.renderer.currentLocationCfi); - } - - deferred.promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Book.prototype.gotoPage = function(pg){ - var cfi = this.pagination.cfiFromPage(pg); - return this.gotoCfi(cfi); -}; - -EPUBJS.Book.prototype.gotoPercentage = function(percent){ - var pg = this.pagination.pageFromPercentage(percent); - return this.gotoPage(pg); -}; - -EPUBJS.Book.prototype.preloadNextChapter = function() { - var next; - var chap = this.spinePos + 1; - - if(chap >= this.spine.length){ - return false; - } - - next = new EPUBJS.Chapter(this.spine[chap]); - if(next) { - EPUBJS.core.request(next.absolute); - } -}; - - -EPUBJS.Book.prototype.storeOffline = function() { - var book = this, - assets = _.values(this.manifest); - - //-- Creates a queue of all items to load - return EPUBJS.storage.batch(assets). - then(function(){ - book.settings.stored = true; - book.trigger("book:stored"); - }); -}; - -EPUBJS.Book.prototype.availableOffline = function() { - return this.settings.stored > 0 ? true : false; -}; - -/* -EPUBJS.Book.prototype.fromStorage = function(stored) { - - if(this.contained) return; - - if(!stored){ - this.online = true; - this.tell("book:online"); - }else{ - if(!this.availableOffline){ - //-- If book hasn't been cached yet, store offline - this.storeOffline(function(){ - this.online = false; - this.tell("book:offline"); - }.bind(this)); - - }else{ - this.online = false; - this.tell("book:offline"); - } - } - -} -*/ - -EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) { - var noreflow = ["color", "background", "background-color"]; - - if(!this.isRendered) return this._q.enqueue("setStyle", arguments); - - this.settings.styles[style] = val; - - this.renderer.setStyle(style, val, prefixed); - - if(noreflow.indexOf(style) === -1) { - // clearTimeout(this.reformatTimeout); - // this.reformatTimeout = setTimeout(function(){ - this.renderer.reformat(); - // }.bind(this), 10); - } -}; - -EPUBJS.Book.prototype.removeStyle = function(style) { - if(!this.isRendered) return this._q.enqueue("removeStyle", arguments); - this.renderer.removeStyle(style); - this.renderer.reformat(); - delete this.settings.styles[style]; -}; - -EPUBJS.Book.prototype.addHeadTag = function(tag, attrs) { - if(!this.isRendered) return this._q.enqueue("addHeadTag", arguments); - this.settings.headTags[tag] = attrs; -}; - -EPUBJS.Book.prototype.useSpreads = function(use) { - console.warn("useSpreads is deprecated, use forceSingle or set a layoutOveride instead"); - if(use === false) { - this.forceSingle(true); - } else { - this.forceSingle(false); - } -}; - -EPUBJS.Book.prototype.forceSingle = function(_use) { - var force = typeof _use === "undefined" ? true : _use; - - this.renderer.forceSingle(force); - this.settings.forceSingle = force; - if(this.isRendered) { - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setMinSpreadWidth = function(width) { - this.settings.minSpreadWidth = width; - if(this.isRendered) { - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setGap = function(gap) { - this.settings.gap = gap; - if(this.isRendered) { - this.renderer.setGap(this.settings.gap); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.chapter = function(path) { - var spinePos = this.spineIndexByURL[path]; - var spineItem; - var chapter; - - if(spinePos){ - spineItem = this.spine[spinePos]; - chapter = new EPUBJS.Chapter(spineItem, this.store); - chapter.load(); - } - return chapter; -}; - -EPUBJS.Book.prototype.unload = function(){ - - if(this.settings.restore && localStorage) { - this.saveContents(); - } - - this.unlistenToRenderer(this.renderer); - - this.trigger("book:unload"); -}; - -EPUBJS.Book.prototype.destroy = function() { - - window.removeEventListener("beforeunload", this.unload); - - if(this.currentChapter) this.currentChapter.unload(); - - this.unload(); - - if(this.render) this.render.remove(); - -}; - -EPUBJS.Book.prototype._ready = function() { - - this.trigger("book:ready"); - -}; - -EPUBJS.Book.prototype._rendered = function(err) { - var book = this; - - this.isRendered = true; - this.trigger("book:rendered"); - - this._q.flush(); -}; - - -EPUBJS.Book.prototype.applyStyles = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyStyles", arguments); - renderer.applyStyles(this.settings.styles); - callback(); -}; - -EPUBJS.Book.prototype.applyHeadTags = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyHeadTags", arguments); - renderer.applyHeadTags(this.settings.headTags); - callback(); -}; - -EPUBJS.Book.prototype._registerReplacements = function(renderer){ - renderer.registerHook("beforeChapterDisplay", this.applyStyles.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", this.applyHeadTags.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", EPUBJS.replace.hrefs.bind(this), true); - - if(this._needsAssetReplacement()) { - - renderer.registerHook("beforeChapterDisplay", [ - EPUBJS.replace.head, - EPUBJS.replace.resources, - EPUBJS.replace.svg - ], true); - - } - -}; - -EPUBJS.Book.prototype._needsAssetReplacement = function(){ - if(this.settings.fromStorage) { - - //-- Filesystem api links are relative, so no need to replace them - if(this.storage.getStorageType() == "filesystem") { - return false; - } - - return true; - - } else if(this.settings.contained) { - - return true; - - } else { - - return false; - - } -}; - - -//-- http://www.idpf.org/epub/fxl/ -EPUBJS.Book.prototype.parseLayoutProperties = function(metadata){ - var layout = (this.layoutOveride && this.layoutOveride.layout) || metadata.layout || "reflowable"; - var spread = (this.layoutOveride && this.layoutOveride.spread) || metadata.spread || "auto"; - var orientation = (this.layoutOveride && this.layoutOveride.orientation) || metadata.orientation || "auto"; - return { - layout : layout, - spread : spread, - orientation : orientation - }; -}; - -//-- Enable binding events to book -RSVP.EventTarget.mixin(EPUBJS.Book.prototype); - -//-- Handle RSVP Errors -RSVP.on('error', function(event) { - //console.error(event, event.detail); -}); - -RSVP.configure('instrument', true); //-- true | will logging out all RSVP rejections -// RSVP.on('created', listener); -// RSVP.on('chained', listener); -// RSVP.on('fulfilled', listener); -RSVP.on('rejected', function(event){ - console.error(event.detail.message, event.detail.stack); -}); - -EPUBJS.Chapter = function(spineObject, store){ - this.href = spineObject.href; - this.absolute = spineObject.url; - this.id = spineObject.id; - this.spinePos = spineObject.index; - this.cfiBase = spineObject.cfiBase; - this.properties = spineObject.properties; - this.manifestProperties = spineObject.manifestProperties; - this.linear = spineObject.linear; - this.pages = 1; - this.store = store; - this.epubcfi = new EPUBJS.EpubCFI(); - this.deferred = new RSVP.defer(); - this.loaded = this.deferred.promise; -}; - - -EPUBJS.Chapter.prototype.load = function(_store){ - var store = _store || this.store; - var promise; - // if(this.store && (!this.book.online || this.book.contained)) - if(store){ - promise = store.get(this.href); - }else{ - promise = EPUBJS.core.request(this.absolute, 'xml'); - } - - promise.then(function(xml){ - this.setDocument(xml); - this.deferred.resolve(this); - }.bind(this)); - - return promise; -}; - -EPUBJS.Chapter.prototype.render = function(_store){ - - return this.load().then(function(doc){ - - var serializer = new XMLSerializer(); - var contents; - var head = doc.head; - var base = doc.createElement("base"); - - base.setAttribute("href", window.location.origin + this.absolute); - head.insertBefore(base, head.firstChild); - contents = serializer.serializeToString(doc); - - return contents; - - }.bind(this)); -}; - -EPUBJS.Chapter.prototype.url = function(_store){ - var deferred = new RSVP.defer(); - var store = _store || this.store; - var loaded; - var chapter = this; - var url; - - if(store){ - if(!this.tempUrl) { - store.getUrl(this.absolute).then(function(url){ - chapter.tempUrl = url; - deferred.resolve(url); - }); - } else { - url = this.tempUrl; - deferred.resolve(url); - } - }else{ - url = this.absolute; - deferred.resolve(url); - } - /* - loaded = EPUBJS.core.request(url, 'xml', false); - loaded.then(function(contents){ - chapter.contents = contents; - deferred.resolve(chapter.absolute); - }, function(error){ - deferred.reject(error); - }); - */ - - return deferred.promise; -}; - -EPUBJS.Chapter.prototype.setPages = function(num){ - this.pages = num; -}; - -EPUBJS.Chapter.prototype.getPages = function(num){ - return this.pages; -}; - -EPUBJS.Chapter.prototype.getID = function(){ - return this.ID; -}; - -EPUBJS.Chapter.prototype.unload = function(store){ - this.document = null; - if(this.tempUrl && store) { - store.revokeUrl(this.tempUrl); - this.tempUrl = false; - } -}; - -EPUBJS.Chapter.prototype.setDocument = function(_document){ - var uri = _document.namespaceURI; - var doctype = _document.doctype; - - // Creates an empty document - this.document = _document.implementation.createDocument( - uri, - null, - null - ); - this.contents = this.document.importNode( - _document.documentElement, //node to import - true //clone its descendants - ); - - this.document.appendChild(this.contents); - - // Fix to apply wgxpath to new document in IE - if(!this.document.evaluate && document.evaluate) { - this.document.evaluate = document.evaluate; - } - - // this.deferred.resolve(this.contents); -}; - -EPUBJS.Chapter.prototype.cfiFromRange = function(_range) { - var range; - var startXpath, endXpath; - var startContainer, endContainer; - var cleanTextContent, cleanEndTextContent; - - // Check for Contents - if(!this.document) return; - startXpath = EPUBJS.core.getElementXPath(_range.startContainer); - // console.log(startContainer) - endXpath = EPUBJS.core.getElementXPath(_range.endContainer); - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!_range.collapsed) { - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } - - range = this.document.createRange(); - // Find Exact Range in original document - if(startContainer) { - try { - range.setStart(startContainer, _range.startOffset); - if(!_range.collapsed && endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } catch (e) { - console.log("missed"); - startContainer = false; - } - - } - - // Fuzzy Match - if(!startContainer) { - console.log("not found, try fuzzy match"); - cleanStartTextContent = EPUBJS.core.cleanStringForXpath(_range.startContainer.textContent); - startXpath = "//text()[contains(.," + cleanStartTextContent + ")]"; - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(startContainer){ - // console.log("Found with Fuzzy"); - range.setStart(startContainer, _range.startOffset); - - if(!_range.collapsed) { - cleanEndTextContent = EPUBJS.core.cleanStringForXpath(_range.endContainer.textContent); - endXpath = "//text()[contains(.," + cleanEndTextContent + ")]"; - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - if(endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } - - } - } - - // Generate the Cfi - return this.epubcfi.generateCfiFromRange(range, this.cfiBase); -}; - -EPUBJS.Chapter.prototype.find = function(_query){ - var chapter = this; - var matches = []; - var query = _query.toLowerCase(); - //var xpath = this.document.evaluate(".//text()[contains(translate(., '"+query.toUpperCase()+"', '"+query+"'),'"+query+"')]", this.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - var find = function(node){ - // Search String - var text = node.textContent.toLowerCase(); - var range = chapter.document.createRange(); - var cfi; - var pos; - var last = -1; - var excerpt; - var limit = 150; - - while (pos != -1) { - pos = text.indexOf(query, last + 1); - - if(pos != -1) { - // If Found, Create Range - range = chapter.document.createRange(); - range.setStart(node, pos); - range.setEnd(node, pos + query.length); - - //Generate CFI - cfi = chapter.cfiFromRange(range); - - // Generate Excerpt - if(node.textContent.length < limit) { - excerpt = node.textContent; - } else { - excerpt = node.textContent.substring(pos-limit/2,pos+limit/2); - excerpt = "..." + excerpt + "..."; - } - - //Add CFI to list - matches.push({ - cfi: cfi, - excerpt: excerpt - }); - } - - last = pos; - } - - }; - - // Grab text nodes - - /* - for ( var i=0 ; i < xpath.snapshotLength; i++ ) { - find(xpath.snapshotItem(i)); - } - */ - - this.textSprint(this.document, function(node){ - find(node); - }); - - - // Return List of CFIs - return matches; -}; - - -EPUBJS.Chapter.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if (node.data && ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; -var EPUBJS = EPUBJS || {}; -EPUBJS.core = {}; - -//-- Get a element for an id -EPUBJS.core.getEl = function(elem) { - return document.getElementById(elem); -}; - -//-- Get all elements for a class -EPUBJS.core.getEls = function(classes) { - return document.getElementsByClassName(classes); -}; - -EPUBJS.core.request = function(url, type, withCredentials) { - var supportsURL = window.URL; - var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer"; - - var deferred = new RSVP.defer(); - - var xhr = new XMLHttpRequest(); - - //-- Check from PDF.js: - // https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js - var xhrPrototype = XMLHttpRequest.prototype; - - if (!('overrideMimeType' in xhrPrototype)) { - // IE10 might have response, but not overrideMimeType - Object.defineProperty(xhrPrototype, 'overrideMimeType', { - value: function xmlHttpRequestOverrideMimeType(mimeType) {} - }); - } - if(withCredentials) { - xhr.withCredentials = true; - } - xhr.open("GET", url, true); - xhr.onreadystatechange = handler; - - if(type == 'blob'){ - xhr.responseType = BLOB_RESPONSE; - } - - if(type == "json") { - xhr.setRequestHeader("Accept", "application/json"); - } - - if(type == 'xml') { - xhr.overrideMimeType('text/xml'); - } - - if(type == "binary") { - xhr.responseType = "arraybuffer"; - } - - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200 || this.responseXML ) { //-- Firefox is reporting 0 for blob urls - var r; - - if(type == 'xml'){ - r = this.responseXML; - }else - if(type == 'json'){ - r = JSON.parse(this.response); - }else - if(type == 'blob'){ - - if(supportsURL) { - r = this.response; - } else { - //-- Safari doesn't support responseType blob, so create a blob from arraybuffer - r = new Blob([this.response]); - } - - }else{ - r = this.response; - } - - deferred.resolve(r); - } else { - deferred.reject({ - message : this.response, - stack : new Error().stack - }); - } - } - } - - return deferred.promise; -}; - -EPUBJS.core.toArray = function(obj) { - var arr = []; - - for (var member in obj) { - var newitm; - if ( obj.hasOwnProperty(member) ) { - newitm = obj[member]; - newitm.ident = member; - arr.push(newitm); - } - } - - return arr; -}; - -//-- Parse the different parts of a url, returning a object -EPUBJS.core.uri = function(url){ - var uri = { - protocol : '', - host : '', - path : '', - origin : '', - directory : '', - base : '', - filename : '', - extension : '', - fragment : '', - href : url - }, - blob = url.indexOf('blob:'), - doubleSlash = url.indexOf('://'), - search = url.indexOf('?'), - fragment = url.indexOf("#"), - withoutProtocol, - dot, - firstSlash; - - if(blob === 0) { - uri.protocol = "blob"; - uri.base = url.indexOf(0, fragment); - return uri; - } - - if(fragment != -1) { - uri.fragment = url.slice(fragment + 1); - url = url.slice(0, fragment); - } - - if(search != -1) { - uri.search = url.slice(search + 1); - url = url.slice(0, search); - href = url; - } - - if(doubleSlash != -1) { - uri.protocol = url.slice(0, doubleSlash); - withoutProtocol = url.slice(doubleSlash+3); - firstSlash = withoutProtocol.indexOf('/'); - - if(firstSlash === -1) { - uri.host = uri.path; - uri.path = ""; - } else { - uri.host = withoutProtocol.slice(0, firstSlash); - uri.path = withoutProtocol.slice(firstSlash); - } - - - uri.origin = uri.protocol + "://" + uri.host; - - uri.directory = EPUBJS.core.folder(uri.path); - - uri.base = uri.origin + uri.directory; - // return origin; - } else { - uri.path = url; - uri.directory = EPUBJS.core.folder(url); - uri.base = uri.directory; - } - - //-- Filename - uri.filename = url.replace(uri.base, ''); - dot = uri.filename.lastIndexOf('.'); - if(dot != -1) { - uri.extension = uri.filename.slice(dot+1); - } - return uri; -}; - -//-- Parse out the folder, will return everything before the last slash - -EPUBJS.core.folder = function(url){ - - var lastSlash = url.lastIndexOf('/'); - - if(lastSlash == -1) var folder = ''; - - folder = url.slice(0, lastSlash + 1); - - return folder; - -}; - -//-- https://github.com/ebidel/filer.js/blob/master/src/filer.js#L128 -EPUBJS.core.dataURLToBlob = function(dataURL) { - var BASE64_MARKER = ';base64,', - parts, contentType, raw, rawLength, uInt8Array; - - if (dataURL.indexOf(BASE64_MARKER) == -1) { - parts = dataURL.split(','); - contentType = parts[0].split(':')[1]; - raw = parts[1]; - - return new Blob([raw], {type: contentType}); - } - - parts = dataURL.split(BASE64_MARKER); - contentType = parts[0].split(':')[1]; - raw = window.atob(parts[1]); - rawLength = raw.length; - - uInt8Array = new Uint8Array(rawLength); - - for (var i = 0; i < rawLength; ++i) { - uInt8Array[i] = raw.charCodeAt(i); - } - - return new Blob([uInt8Array], {type: contentType}); -}; - -//-- Load scripts async: http://stackoverflow.com/questions/7718935/load-scripts-asynchronously -EPUBJS.core.addScript = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('script'); - s.type = 'text/javascript'; - s.async = false; - s.src = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.addScripts = function(srcArr, callback, target) { - var total = srcArr.length, - curr = 0, - cb = function(){ - curr++; - if(total == curr){ - if(callback) callback(); - }else{ - EPUBJS.core.addScript(srcArr[curr], cb, target); - } - }; - - EPUBJS.core.addScript(srcArr[curr], cb, target); -}; - -EPUBJS.core.addCss = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('link'); - s.type = 'text/css'; - s.rel = "stylesheet"; - s.href = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.prefixed = function(unprefixed) { - var vendors = ["Webkit", "Moz", "O", "ms" ], - prefixes = ['-Webkit-', '-moz-', '-o-', '-ms-'], - upper = unprefixed[0].toUpperCase() + unprefixed.slice(1), - length = vendors.length; - - if (typeof(document.body.style[unprefixed]) != 'undefined') { - return unprefixed; - } - - for ( var i=0; i < length; i++ ) { - if (typeof(document.body.style[vendors[i] + upper]) != 'undefined') { - return vendors[i] + upper; - } - } - - return unprefixed; -}; - -EPUBJS.core.resolveUrl = function(base, path) { - var url, - segments = [], - uri = EPUBJS.core.uri(path), - folders = base.split("/"), - paths; - - if(uri.host) { - return path; - } - - folders.pop(); - - paths = path.split("/"); - paths.forEach(function(p){ - if(p === ".."){ - folders.pop(); - }else{ - segments.push(p); - } - }); - - url = folders.concat(segments); - - return url.join("/"); -}; - -// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -EPUBJS.core.uuid = function() { - var d = new Date().getTime(); - var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = (d + Math.random()*16)%16 | 0; - d = Math.floor(d/16); - return (c=='x' ? r : (r&0x7|0x8)).toString(16); - }); - return uuid; -}; - -// Fast quicksort insert for sorted array -- based on: -// http://stackoverflow.com/questions/1344500/efficient-way-to-insert-a-number-into-a-sorted-array-of-numbers -EPUBJS.core.insert = function(item, array, compareFunction) { - var location = EPUBJS.core.locationOf(item, array, compareFunction); - array.splice(location, 0, item); - - return location; -}; - -EPUBJS.core.locationOf = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return pivot; - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared > 0 ? pivot : pivot + 1; - } - - if(compared === 0) { - return pivot; - } - if(compared === -1) { - return EPUBJS.core.locationOf(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.locationOf(item, array, compareFunction, start, pivot); - } -}; - -EPUBJS.core.indexOfSorted = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return -1; // Not found - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared === 0 ? pivot : -1; - } - if(compared === 0) { - return pivot; // Found - } - if(compared === -1) { - return EPUBJS.core.indexOfSorted(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.indexOfSorted(item, array, compareFunction, start, pivot); - } -}; - - -EPUBJS.core.queue = function(_scope){ - var _q = []; - var scope = _scope; - // Add an item to the queue - var enqueue = function(funcName, args, context) { - _q.push({ - "funcName" : funcName, - "args" : args, - "context" : context - }); - return _q; - }; - // Run one item - var dequeue = function(){ - var inwait; - if(_q.length) { - inwait = _q.shift(); - // Defer to any current tasks - // setTimeout(function(){ - scope[inwait.funcName].apply(inwait.context || scope, inwait.args); - // }, 0); - } - }; - - // Run All - var flush = function(){ - while(_q.length) { - dequeue(); - } - }; - // Clear all items in wait - var clear = function(){ - _q = []; - }; - - var length = function(){ - return _q.length; - }; - - return { - "enqueue" : enqueue, - "dequeue" : dequeue, - "flush" : flush, - "clear" : clear, - "length" : length - }; -}; - -// From: https://code.google.com/p/fbug/source/browse/branches/firebug1.10/content/firebug/lib/xpath.js -/** - * Gets an XPath for an element which describes its hierarchical location. - */ -EPUBJS.core.getElementXPath = function(element) { - if (element && element.id) { - return '//*[@id="' + element.id + '"]'; - } else { - return EPUBJS.core.getElementTreeXPath(element); - } -}; - -EPUBJS.core.getElementTreeXPath = function(element) { - var paths = []; - var isXhtml = (element.ownerDocument.documentElement.getAttribute('xmlns') === "http://www.w3.org/1999/xhtml"); - var index, nodeName, tagName, pathIndex; - - if(element.nodeType === Node.TEXT_NODE){ - // index = Array.prototype.indexOf.call(element.parentNode.childNodes, element) + 1; - index = EPUBJS.core.indexOfTextNode(element) + 1; - - paths.push("text()["+index+"]"); - element = element.parentNode; - } - - // Use nodeName (instead of localName) so namespace prefix is included (if any). - for (; element && element.nodeType == 1; element = element.parentNode) - { - index = 0; - for (var sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) - { - // Ignore document type declaration. - if (sibling.nodeType == Node.DOCUMENT_TYPE_NODE) { - continue; - } - if (sibling.nodeName == element.nodeName) { - ++index; - } - } - nodeName = element.nodeName.toLowerCase(); - tagName = (isXhtml ? "xhtml:" + nodeName : nodeName); - pathIndex = (index ? "[" + (index+1) + "]" : ""); - paths.splice(0, 0, tagName + pathIndex); - } - - return paths.length ? "./" + paths.join("/") : null; -}; - -EPUBJS.core.nsResolver = function(prefix) { - var ns = { - 'xhtml' : 'http://www.w3.org/1999/xhtml', - 'epub': 'http://www.idpf.org/2007/ops' - }; - return ns[prefix] || null; -}; - -//https://stackoverflow.com/questions/13482352/xquery-looking-for-text-with-single-quote/13483496#13483496 -EPUBJS.core.cleanStringForXpath = function(str) { - var parts = str.match(/[^'"]+|['"]/g); - parts = parts.map(function(part){ - if (part === "'") { - return '\"\'\"'; // output "'" - } - - if (part === '"') { - return "\'\"\'"; // output '"' - } - return "\'" + part + "\'"; - }); - return "concat(\'\'," + parts.join(",") + ")"; -}; - -EPUBJS.core.indexOfTextNode = function(textNode){ - var parent = textNode.parentNode; - var children = parent.childNodes; - var sib; - var index = -1; - for (var i = 0; i < children.length; i++) { - sib = children[i]; - if(sib.nodeType === Node.TEXT_NODE){ - index++; - } - if(sib == textNode) break; - } - - return index; -}; -EPUBJS.EpubCFI = function(cfiStr){ - if(cfiStr) return this.parse(cfiStr); -}; - -EPUBJS.EpubCFI.prototype.generateChapterComponent = function(_spineNodeIndex, _pos, id) { - var pos = parseInt(_pos), - spineNodeIndex = _spineNodeIndex + 1, - cfi = '/'+spineNodeIndex+'/'; - - cfi += (pos + 1) * 2; - - if(id) cfi += "[" + id + "]"; - - //cfi += "!"; - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.generatePathComponent = function(steps) { - var parts = []; - - steps.forEach(function(part){ - var segment = ''; - segment += (part.index + 1) * 2; - - if(part.id) { - segment += "[" + part.id + "]"; - } - - parts.push(segment); - }); - - return parts.join('/'); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromElement = function(element, chapter) { - var steps = this.pathTo(element); - var path = this.generatePathComponent(steps); - if(!path.length) { - // Start of Chapter - return "epubcfi(" + chapter + "!/4/)"; - } else { - // First Text Node - return "epubcfi(" + chapter + "!" + path + "/1:0)"; - } -}; - -EPUBJS.EpubCFI.prototype.pathTo = function(node) { - var stack = [], - children; - - while(node && node.parentNode !== null && node.parentNode.nodeType != 9) { - children = node.parentNode.children; - - stack.unshift({ - 'id' : node.id, - // 'classList' : node.classList, - 'tagName' : node.tagName, - 'index' : children ? Array.prototype.indexOf.call(children, node) : 0 - }); - - node = node.parentNode; - } - - return stack; -}; - -EPUBJS.EpubCFI.prototype.getChapterComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - - return splitStr[0]; -}; - -EPUBJS.EpubCFI.prototype.getPathComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - var pathComponent = splitStr[1] ? splitStr[1].split(":") : ''; - - return pathComponent[0]; -}; - -EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent = function(cfiStr) { - var splitStr = cfiStr.split(":"); - return splitStr[1] || ''; -}; - - -EPUBJS.EpubCFI.prototype.parse = function(cfiStr) { - var cfi = {}, - chapSegment, - chapterComponent, - pathComponent, - charecterOffsetComponent, - assertion, - chapId, - path, - end, - endInt, - text, - parseStep = function(part){ - var type, index, has_brackets, id; - - type = "element"; - index = parseInt(part) / 2 - 1; - has_brackets = part.match(/\[(.*)\]/); - if(has_brackets && has_brackets[1]){ - id = has_brackets[1]; - } - - return { - "type" : type, - 'index' : index, - 'id' : id || false - }; - }; - - if(typeof cfiStr !== "string") { - return {spinePos: -1}; - } - - cfi.str = cfiStr; - - if(cfiStr.indexOf("epubcfi(") === 0 && cfiStr[cfiStr.length-1] === ")") { - // Remove intial epubcfi( and ending ) - cfiStr = cfiStr.slice(8, cfiStr.length-1); - } - - chapterComponent = this.getChapterComponent(cfiStr); - pathComponent = this.getPathComponent(cfiStr) || ''; - charecterOffsetComponent = this.getCharecterOffsetComponent(cfiStr); - // Make sure this is a valid cfi or return - if(!chapterComponent) { - return {spinePos: -1}; - } - - // Chapter segment is always the second one - chapSegment = chapterComponent.split("/")[2] || ''; - if(!chapSegment) return {spinePos:-1}; - - cfi.spinePos = (parseInt(chapSegment) / 2 - 1 ) || 0; - - chapId = chapSegment.match(/\[(.*)\]/); - - cfi.spineId = chapId ? chapId[1] : false; - - if(pathComponent.indexOf(',') != -1) { - // Handle ranges -- not supported yet - console.warn("CFI Ranges are not supported"); - } - - path = pathComponent.split('/'); - end = path.pop(); - - cfi.steps = []; - - path.forEach(function(part){ - var step; - - if(part) { - step = parseStep(part); - cfi.steps.push(step); - } - }); - - //-- Check if END is a text node or element - endInt = parseInt(end); - if(!isNaN(endInt)) { - - if(endInt % 2 === 0) { // Even = is an element - cfi.steps.push(parseStep(end)); - } else { - cfi.steps.push({ - "type" : "text", - 'index' : (endInt - 1 ) / 2 - }); - } - - } - - assertion = charecterOffsetComponent.match(/\[(.*)\]/); - if(assertion && assertion[1]){ - cfi.characterOffset = parseInt(charecterOffsetComponent.split('[')[0]); - // We arent handling these assertions yet - cfi.textLocationAssertion = assertion[1]; - } else { - cfi.characterOffset = parseInt(charecterOffsetComponent); - } - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.addMarker = function(cfi, _doc, _marker) { - var doc = _doc || document; - var marker = _marker || this.createMarker(doc); - var parent; - var lastStep; - var text; - var split; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - // Find the CFI elements parent - parent = this.findParent(cfi, doc); - - if(!parent) { - // CFI didn't return an element - // Maybe it isnt in the current chapter? - return false; - } - - if(lastStep && lastStep.type === "text") { - text = parent.childNodes[lastStep.index]; - if(cfi.characterOffset){ - split = text.splitText(cfi.characterOffset); - marker.classList.add("EPUBJS-CFI-SPLIT"); - parent.insertBefore(marker, split); - } else { - parent.insertBefore(marker, text); - } - } else { - parent.insertBefore(marker, parent.firstChild); - } - - return marker; -}; - -EPUBJS.EpubCFI.prototype.createMarker = function(_doc) { - var doc = _doc || document; - var element = doc.createElement('span'); - element.id = "EPUBJS-CFI-MARKER:"+ EPUBJS.core.uuid(); - element.classList.add("EPUBJS-CFI-MARKER"); - - return element; -}; - -EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) { - var doc = _doc || document; - // var id = marker.id; - - // Cleanup textnodes if they were split - if(marker.classList.contains("EPUBJS-CFI-SPLIT")){ - nextSib = marker.nextSibling; - prevSib = marker.previousSibling; - if(nextSib && - prevSib && - nextSib.nodeType === 3 && - prevSib.nodeType === 3){ - - prevSib.textContent += nextSib.textContent; - marker.parentNode.removeChild(nextSib); - } - marker.parentNode.removeChild(marker); - } else if(marker.classList.contains("EPUBJS-CFI-MARKER")) { - // Remove only elements added as markers - marker.parentNode.removeChild(marker); - } - -}; - -EPUBJS.EpubCFI.prototype.findParent = function(cfi, _doc) { - var doc = _doc || document, - element = doc.getElementsByTagName('html')[0], - children = Array.prototype.slice.call(element.children), - num, index, part, sections, - text, textBegin, textEnd; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - sections = cfi.steps.slice(0); // Clone steps array - if(!sections.length) { - return doc.getElementsByTagName('body')[0]; - } - - while(sections && sections.length > 0) { - part = sections.shift(); - // Find textNodes Parent - if(part.type === "text") { - text = element.childNodes[part.index]; - element = text.parentNode || element; - // Find element by id if present - } else if(part.id){ - element = doc.getElementById(part.id); - // Find element in parent - }else{ - element = children[part.index]; - } - // Element can't be found - if(typeof element === "undefined") { - console.error("No Element For", part, cfi.str); - return false; - } - // Get current element children and continue through steps - children = Array.prototype.slice.call(element.children); - } - - return element; -}; - -EPUBJS.EpubCFI.prototype.compare = function(cfiOne, cfiTwo) { - if(typeof cfiOne === 'string') { - cfiOne = new EPUBJS.EpubCFI(cfiOne); - } - if(typeof cfiTwo === 'string') { - cfiTwo = new EPUBJS.EpubCFI(cfiTwo); - } - // Compare Spine Positions - if(cfiOne.spinePos > cfiTwo.spinePos) { - return 1; - } - if(cfiOne.spinePos < cfiTwo.spinePos) { - return -1; - } - - - // Compare Each Step in the First item - for (var i = 0; i < cfiOne.steps.length; i++) { - if(!cfiTwo.steps[i]) { - return 1; - } - if(cfiOne.steps[i].index > cfiTwo.steps[i].index) { - return 1; - } - if(cfiOne.steps[i].index < cfiTwo.steps[i].index) { - return -1; - } - // Otherwise continue checking - } - - // All steps in First present in Second - if(cfiOne.steps.length < cfiTwo.steps.length) { - return -1; - } - - // Compare the charecter offset of the text node - if(cfiOne.characterOffset > cfiTwo.characterOffset) { - return 1; - } - if(cfiOne.characterOffset < cfiTwo.characterOffset) { - return -1; - } - - // CFI's are equal - return 0; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromHref = function(href, book) { - var uri = EPUBJS.core.uri(href); - var path = uri.path; - var fragment = uri.fragment; - var spinePos = book.spineIndexByURL[path]; - var loaded; - var deferred = new RSVP.defer(); - var epubcfi = new EPUBJS.EpubCFI(); - var spineItem; - - if(typeof spinePos !== "undefined"){ - spineItem = book.spine[spinePos]; - loaded = book.loadXml(spineItem.url); - loaded.then(function(doc){ - var element = doc.getElementById(fragment); - var cfi; - cfi = epubcfi.generateCfiFromElement(element, spineItem.cfiBase); - deferred.resolve(cfi); - }); - } - - return deferred.promise; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromTextNode = function(anchor, offset, base) { - var parent = anchor.parentNode; - var steps = this.pathTo(parent); - var path = this.generatePathComponent(steps); - var index = 1 + (2 * Array.prototype.indexOf.call(parent.childNodes, anchor)); - return "epubcfi(" + base + "!" + path + "/"+index+":"+(offset || 0)+")"; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRangeAnchor = function(range, base) { - var anchor = range.anchorNode; - var offset = range.anchorOffset; - return this.generateCfiFromTextNode(anchor, offset, base); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRange = function(range, base) { - var start, startElement, startSteps, startPath, startOffset, startIndex; - var end, endElement, endSteps, endPath, endOffset, endIndex; - - start = range.startContainer; - - if(start.nodeType === 3) { // text node - startElement = start.parentNode; - //startIndex = 1 + (2 * Array.prototype.indexOf.call(startElement.childNodes, start)); - startIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(start)); - startSteps = this.pathTo(startElement); - } else if(range.collapsed) { - return this.generateCfiFromElement(start, base); // single element - } else { - startSteps = this.pathTo(start); - } - - startPath = this.generatePathComponent(startSteps); - startOffset = range.startOffset; - - if(!range.collapsed) { - end = range.endContainer; - - if(end.nodeType === 3) { // text node - endElement = end.parentNode; - // endIndex = 1 + (2 * Array.prototype.indexOf.call(endElement.childNodes, end)); - endIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(end)); - - endSteps = this.pathTo(endElement); - } else { - endSteps = this.pathTo(end); - } - - endPath = this.generatePathComponent(endSteps); - endOffset = range.endOffset; - - return "epubcfi(" + base + "!" + startPath + "/" + startIndex + ":" + startOffset + "," + endPath + "/" + endIndex + ":" + endOffset + ")"; - - } else { - return "epubcfi(" + base + "!" + startPath + "/"+ startIndex +":"+ startOffset +")"; - } -}; - -EPUBJS.EpubCFI.prototype.generateXpathFromSteps = function(steps) { - var xpath = [".", "*"]; - - steps.forEach(function(step){ - var position = step.index + 1; - - if(step.id){ - xpath.push("*[position()=" + position + " and @id='" + step.id + "']"); - } else if(step.type === "text") { - xpath.push("text()[" + position + "]"); - } else { - xpath.push("*[" + position + "]"); - } - }); - - return xpath.join("/"); -}; - - -EPUBJS.EpubCFI.prototype.generateRangeFromCfi = function(cfi, _doc) { - var doc = _doc || document; - var range = doc.createRange(); - var lastStep; - var xpath; - var startContainer; - var textLength; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - xpath = this.generateXpathFromSteps(cfi.steps); - - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - startContainer = doc.evaluate(xpath, doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!startContainer) { - return null; - } - - if(startContainer && cfi.characterOffset >= 0) { - textLength = startContainer.length; - - if(cfi.characterOffset < textLength) { - range.setStart(startContainer, cfi.characterOffset); - range.setEnd(startContainer, textLength ); - } else { - console.debug("offset greater than length:", cfi.characterOffset, textLength); - range.setStart(startContainer, textLength - 1 ); - range.setEnd(startContainer, textLength ); - } - } else if(startContainer) { - range.selectNode(startContainer); - } - // doc.defaultView.getSelection().addRange(range); - return range; -}; - -EPUBJS.Events = function(obj, el){ - - this.events = {}; - - if(!el){ - this.el = document.createElement('div'); - }else{ - this.el = el; - } - - obj.createEvent = this.createEvent; - obj.tell = this.tell; - obj.listen = this.listen; - obj.deafen = this.deafen; - obj.listenUntil = this.listenUntil; - - return this; -}; - -EPUBJS.Events.prototype.createEvent = function(evt){ - var e = new CustomEvent(evt); - this.events[evt] = e; - return e; -}; - -EPUBJS.Events.prototype.tell = function(evt, msg){ - var e; - - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - e = this.createEvent(evt); - }else{ - e = this.events[evt]; - } - - if(msg) e.msg = msg; - this.el.dispatchEvent(e); - -}; - -EPUBJS.Events.prototype.listen = function(evt, func, bindto){ - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - this.createEvent(evt); - return; - } - - if(bindto){ - this.el.addEventListener(evt, func.bind(bindto), false); - }else{ - this.el.addEventListener(evt, func, false); - } - -}; - -EPUBJS.Events.prototype.deafen = function(evt, func){ - this.el.removeEventListener(evt, func, false); -}; - -EPUBJS.Events.prototype.listenUntil = function(OnEvt, OffEvt, func, bindto){ - this.listen(OnEvt, func, bindto); - - function unlisten(){ - this.deafen(OnEvt, func); - this.deafen(OffEvt, unlisten); - } - - this.listen(OffEvt, unlisten, this); -}; -EPUBJS.hooks = {}; -EPUBJS.Hooks = (function(){ - function hooks(){} - - //-- Get pre-registered hooks - hooks.prototype.getHooks = function(){ - var plugs; - this.hooks = {}; - Array.prototype.slice.call(arguments).forEach(function(arg){ - this.hooks[arg] = []; - }, this); - - for (var plugType in this.hooks) { - plugs = _.values(EPUBJS.hooks[plugType]); - - plugs.forEach(function(hook){ - this.registerHook(plugType, hook); - }, this); - } - }; - - //-- Hooks allow for injecting async functions that must all complete before continuing - // Functions must have a callback as their first argument. - hooks.prototype.registerHook = function(type, toAdd, toFront){ - - if(typeof(this.hooks[type]) != "undefined"){ - - if(typeof(toAdd) === "function"){ - if(toFront) { - this.hooks[type].unshift(toAdd); - }else{ - this.hooks[type].push(toAdd); - } - }else if(Array.isArray(toAdd)){ - toAdd.forEach(function(hook){ - if(toFront) { - this.hooks[type].unshift(hook); - }else{ - this.hooks[type].push(hook); - } - }, this); - } - }else{ - //-- Allows for undefined hooks, but maybe this should error? - this.hooks[type] = [func]; - } - }; - - hooks.prototype.triggerHooks = function(type, callback, passed){ - var hooks, count; - - if(typeof(this.hooks[type]) == "undefined") return false; - - hooks = this.hooks[type]; - - count = hooks.length; - if(count === 0 && callback) { - callback(); - } - - function countdown(){ - count--; - if(count <= 0 && callback) callback(); - } - - hooks.forEach(function(hook){ - hook(countdown, passed); - }); - }; - - return { - register: function(name) { - if(EPUBJS.hooks[name] === undefined) { EPUBJS.hooks[name] = {}; } - if(typeof EPUBJS.hooks[name] !== 'object') { throw "Already registered: "+name; } - return EPUBJS.hooks[name]; - }, - mixin: function(object) { - for (var prop in hooks.prototype) { - object[prop] = hooks.prototype[prop]; - } - } - }; -})(); - - -EPUBJS.Layout = EPUBJS.Layout || {}; - -EPUBJS.Layout.Reflowable = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){ - // Get the prefixed CSS commands - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - //-- Check the width and create even width columns - var width = Math.floor(_width); - // var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - this.documentElement = documentElement; - //-- Single Page - this.spreadWidth = (width + gap); - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnWidth] = width+"px"; - documentElement.style[columnGap] = gap+"px"; - this.colWidth = width; - this.gap = gap; - - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.Reflowable.prototype.calculatePages = function() { - var totalWidth, displayedPages; - this.documentElement.style.width = "auto"; //-- reset width for calculations - totalWidth = this.documentElement.scrollWidth; - displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - return { - displayedPages : displayedPages, - pageCount : displayedPages - }; -}; - -EPUBJS.Layout.ReflowableSpreads = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){ - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - var divisor = 2, - cutoff = 800; - - //-- Check the width and create even width columns - var fullWidth = Math.floor(_width); - var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1; - - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - - //-- Double Page - var colWidth = Math.floor((width - gap) / divisor); - - this.documentElement = documentElement; - this.spreadWidth = (colWidth + gap) * divisor; - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnGap] = gap+"px"; - documentElement.style[columnWidth] = colWidth+"px"; - - this.colWidth = colWidth; - this.gap = gap; - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function() { - var totalWidth = this.documentElement.scrollWidth; - var displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - //-- Add a page to the width of the document to account an for odd number of pages - this.documentElement.style.width = ((displayedPages * this.spreadWidth) - this.gap) + "px"; - - return { - displayedPages : displayedPages, - pageCount : displayedPages * 2 - }; -}; - -EPUBJS.Layout.Fixed = function(){ - this.documentElement = null; -}; - -EPUBJS.Layout.Fixed.prototype.format = function(documentElement, _width, _height, _gap){ - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var viewport = documentElement.querySelector("[name=viewport"); - var content; - var contents; - var width, height; - this.documentElement = documentElement; - /** - * check for the viewport size - * - */ - if(viewport && viewport.hasAttribute("content")) { - content = viewport.getAttribute("content"); - contents = content.split(','); - if(contents[0]){ - width = contents[0].replace("width=", ''); - } - if(contents[1]){ - height = contents[1].replace("height=", ''); - } - } - - //-- Adjust width and height - documentElement.style.width = width + "px" || "auto"; - documentElement.style.height = height + "px" || "auto"; - - //-- Remove columns - documentElement.style[columnWidth] = "auto"; - - //-- Scroll - documentElement.style.overflow = "auto"; - - this.colWidth = width; - this.gap = 0; - - return { - pageWidth : width, - pageHeight : height - }; - -}; - -EPUBJS.Layout.Fixed.prototype.calculatePages = function(){ - return { - displayedPages : 1, - pageCount : 1 - }; -}; - -EPUBJS.Pagination = function(pageList) { - this.pages = []; - this.locations = []; - this.epubcfi = new EPUBJS.EpubCFI(); - if(pageList && pageList.length) { - this.process(pageList); - } -}; - -EPUBJS.Pagination.prototype.process = function(pageList){ - pageList.forEach(function(item){ - this.pages.push(item.page); - this.locations.push(item.cfi); - }, this); - - this.pageList = pageList; - this.firstPage = parseInt(this.pages[0]); - this.lastPage = parseInt(this.pages[this.pages.length-1]); - this.totalPages = this.lastPage - this.firstPage; -}; - -EPUBJS.Pagination.prototype.pageFromCfi = function(cfi){ - var pg = -1; - - // Check if the pageList has not been set yet - if(this.locations.length === 0) { - return -1; - } - - // TODO: check if CFI is valid? - - // check if the cfi is in the location list - // var index = this.locations.indexOf(cfi); - var index = EPUBJS.core.indexOfSorted(cfi, this.locations, this.epubcfi.compare); - if(index != -1 && index < (this.pages.length-1) ) { - pg = this.pages[index]; - } else { - // Otherwise add it to the list of locations - // Insert it in the correct position in the locations page - //index = EPUBJS.core.insert(cfi, this.locations, this.epubcfi.compare); - index = EPUBJS.core.locationOf(cfi, this.locations, this.epubcfi.compare); - // Get the page at the location just before the new one, or return the first - pg = index-1 >= 0 ? this.pages[index-1] : this.pages[0]; - if(pg !== undefined) { - // Add the new page in so that the locations and page array match up - //this.pages.splice(index, 0, pg); - } else { - pg = -1; - } - - } - return pg; -}; - -EPUBJS.Pagination.prototype.cfiFromPage = function(pg){ - var cfi = -1; - // check that pg is an int - if(typeof pg != "number"){ - pg = parseInt(pg); - } - - // check if the cfi is in the page list - // Pages could be unsorted. - var index = this.pages.indexOf(pg); - if(index != -1) { - cfi = this.locations[index]; - } - // TODO: handle pages not in the list - return cfi; -}; - -EPUBJS.Pagination.prototype.pageFromPercentage = function(percent){ - var pg = Math.round(this.totalPages * percent); - return pg; -}; - -// Returns a value between 0 - 1 corresponding to the location of a page -EPUBJS.Pagination.prototype.percentageFromPage = function(pg){ - var percentage = (pg - this.firstPage) / this.totalPages; - return Math.round(percentage * 1000) / 1000; -}; - -// Returns a value between 0 - 1 corresponding to the location of a cfi -EPUBJS.Pagination.prototype.percentageFromCfi = function(cfi){ - var pg = this.pageFromCfi(cfi); - var percentage = this.percentageFromPage(pg); - return percentage; -}; -EPUBJS.Parser = function(baseUrl){ - this.baseUrl = baseUrl || ''; -}; - -EPUBJS.Parser.prototype.container = function(containerXml){ - //-- - var rootfile, fullpath, folder, encoding; - - if(!containerXml) { - console.error("Container File Not Found"); - return; - } - - rootfile = containerXml.querySelector("rootfile"); - - if(!rootfile) { - console.error("No RootFile Found"); - return; - } - - fullpath = rootfile.getAttribute('full-path'); - folder = EPUBJS.core.uri(fullpath).directory; - encoding = containerXml.xmlEncoding; - - //-- Now that we have the path we can parse the contents - return { - 'packagePath' : fullpath, - 'basePath' : folder, - 'encoding' : encoding - }; -}; - -EPUBJS.Parser.prototype.identifier = function(packageXml){ - var metadataNode; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - return this.getElementText(metadataNode, "identifier"); -}; - -EPUBJS.Parser.prototype.packageContents = function(packageXml, baseUrl){ - var parse = this; - var metadataNode, manifestNode, spineNode; - var manifest, navPath, tocPath, coverPath; - var spineNodeIndex; - var spine; - var spineIndexByURL; - - if(baseUrl) this.baseUrl = baseUrl; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - manifestNode = packageXml.querySelector("manifest"); - if(!manifestNode) { - console.error("No Manifest Found"); - return; - } - - spineNode = packageXml.querySelector("spine"); - if(!spineNode) { - console.error("No Spine Found"); - return; - } - - manifest = parse.manifest(manifestNode); - navPath = parse.findNavPath(manifestNode); - tocPath = parse.findTocPath(manifestNode, spineNode); - coverPath = parse.findCoverPath(manifestNode); - - spineNodeIndex = Array.prototype.indexOf.call(spineNode.parentNode.childNodes, spineNode); - - spine = parse.spine(spineNode, manifest); - - spineIndexByURL = {}; - spine.forEach(function(item){ - spineIndexByURL[item.href] = item.index; - }); - - return { - 'metadata' : parse.metadata(metadataNode), - 'spine' : spine, - 'manifest' : manifest, - 'navPath' : navPath, - 'tocPath' : tocPath, - 'coverPath': coverPath, - 'spineNodeIndex' : spineNodeIndex, - 'spineIndexByURL' : spineIndexByURL - }; -}; - -//-- Find TOC NAV -EPUBJS.Parser.prototype.findNavPath = function(manifestNode){ - // Find item with property 'nav' - // Should catch nav irregardless of order - var node = manifestNode.querySelector("item[properties$='nav'], item[properties^='nav '], item[properties*=' nav ']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Find TOC NCX: media-type="application/x-dtbncx+xml" href="toc.ncx" -EPUBJS.Parser.prototype.findTocPath = function(manifestNode, spineNode){ - var node = manifestNode.querySelector("item[media-type='application/x-dtbncx+xml']"); - var tocId; - - // If we can't find the toc by media-type then try to look for id of the item in the spine attributes as - // according to http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.4.1.2, - // "The item that describes the NCX must be referenced by the spine toc attribute." - if (!node) { - tocId = spineNode.getAttribute("toc"); - if(tocId) { - node = manifestNode.querySelector("item[id='" + tocId + "']"); - } - } - - return node ? node.getAttribute('href') : false; -}; - -//-- Find Cover: -EPUBJS.Parser.prototype.findCoverPath = function(manifestNode){ - var node = manifestNode.querySelector("item[properties='cover-image']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Expanded to match Readium web components -EPUBJS.Parser.prototype.metadata = function(xml){ - var metadata = {}, - p = this; - - metadata.bookTitle = p.getElementText(xml, 'title'); - metadata.creator = p.getElementText(xml, 'creator'); - metadata.description = p.getElementText(xml, 'description'); - - metadata.pubdate = p.getElementText(xml, 'date'); - - metadata.publisher = p.getElementText(xml, 'publisher'); - - metadata.identifier = p.getElementText(xml, "identifier"); - metadata.language = p.getElementText(xml, "language"); - metadata.rights = p.getElementText(xml, "rights"); - - metadata.modified_date = p.querySelectorText(xml, "meta[property='dcterms:modified']"); - metadata.layout = p.querySelectorText(xml, "meta[property='rendition:layout']"); - metadata.orientation = p.querySelectorText(xml, "meta[property='rendition:orientation']"); - metadata.spread = p.querySelectorText(xml, "meta[property='rendition:spread']"); - // metadata.page_prog_dir = packageXml.querySelector("spine").getAttribute("page-progression-direction"); - - return metadata; -}; - -EPUBJS.Parser.prototype.getElementText = function(xml, tag){ - var found = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag), - el; - - if(!found || found.length === 0) return ''; - - el = found[0]; - - if(el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; - -}; - -EPUBJS.Parser.prototype.querySelectorText = function(xml, q){ - var el = xml.querySelector(q); - - if(el && el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; -}; - -EPUBJS.Parser.prototype.manifest = function(manifestXml){ - var baseUrl = this.baseUrl, - manifest = {}; - - //-- Turn items into an array - var selected = manifestXml.querySelectorAll("item"), - items = Array.prototype.slice.call(selected); - - //-- Create an object with the id as key - items.forEach(function(item){ - var id = item.getAttribute('id'), - href = item.getAttribute('href') || '', - type = item.getAttribute('media-type') || '', - properties = item.getAttribute('properties') || ''; - - manifest[id] = { - 'href' : href, - 'url' : baseUrl + href, //-- Absolute URL for loading with a web worker - 'type' : type, - 'properties' : properties - }; - - }); - - return manifest; - -}; - -EPUBJS.Parser.prototype.spine = function(spineXml, manifest){ - var spine = []; - - var selected = spineXml.getElementsByTagName("itemref"), - items = Array.prototype.slice.call(selected); - - var spineNodeIndex = Array.prototype.indexOf.call(spineXml.parentNode.childNodes, spineXml); - - var epubcfi = new EPUBJS.EpubCFI(); - - //-- Add to array to mantain ordering and cross reference with manifest - items.forEach(function(item, index){ - var Id = item.getAttribute('idref'); - var cfiBase = epubcfi.generateChapterComponent(spineNodeIndex, index, Id); - var props = item.getAttribute('properties') || ''; - var propArray = props.length ? props.split(' ') : []; - var manifestProps = manifest[Id].properties; - var manifestPropArray = manifestProps.length ? manifestProps.split(' ') : []; - var vert = { - 'id' : Id, - 'linear' : item.getAttribute('linear') || '', - 'properties' : propArray, - 'manifestProperties' : manifestPropArray, - 'href' : manifest[Id].href, - 'url' : manifest[Id].url, - 'index' : index, - 'cfiBase' : cfiBase, - 'cfi' : "epub(" + cfiBase + ")" - }; - spine.push(vert); - }); - - return spine; -}; - -EPUBJS.Parser.prototype.nav = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="toc"]'), //-- [*|type="toc"] * Doesn't seem to work - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getTOC(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - split = href.split("#"), - baseUrl = split[0], - subitems = getTOC(item), - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - item.setAttribute('id', id); // Ensure all elements have an id - list.push({ - "id": id, - "href": href, - "label": text, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - }); - - return list; - } - - return getTOC(navEl); -}; - -EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){ - var navMap = tocXml.querySelector("navMap"); - if(!navMap) return []; - - function getTOC(parent){ - var list = [], - snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), - length = snapshot.snapshotLength; - - if(length === 0) return []; - - for ( var i=length-1 ; i >= 0; i-- ) { - var item = snapshot.snapshotItem(i); - - var id = item.getAttribute('id') || false, - content = item.querySelector("content"), - src = content.getAttribute('src'), - navLabel = item.querySelector("navLabel"), - text = navLabel.textContent ? navLabel.textContent : "", - split = src.split("#"), - baseUrl = split[0], - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - subitems = getTOC(item), - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - list.unshift({ - "id": id, - "href": src, - "label": text, - "spinePos": spinePos, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - } - - return list; - } - - return getTOC(navMap); -}; - -EPUBJS.Parser.prototype.pageList = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="page-list"]'), - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getPages(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - page = parseInt(text), - isCfi = href.indexOf("epubcfi"), - split, - packageUrl, - cfi; - - if(isCfi != -1) { - split = href.split("#"); - packageUrl = split[0]; - cfi = split.length > 1 ? split[1] : false; - list.push({ - "cfi" : cfi, - "href" : href, - "packageUrl" : packageUrl, - "page" : page - }); - } else { - list.push({ - "href" : href, - "page" : page - }); - } - - }); - - return list; - } - - return getPages(navEl); -}; - -EPUBJS.Render.Iframe = function() { - this.iframe = null; - this.document = null; - this.window = null; - this.docEl = null; - this.bodyEl = null; - - this.leftPos = 0; - this.pageWidth = 0; -}; - -//-- Build up any html needed -EPUBJS.Render.Iframe.prototype.create = function(){ - this.iframe = document.createElement('iframe'); - this.iframe.id = "epubjs-iframe:" + EPUBJS.core.uuid(); - this.iframe.scrolling = "no"; - this.iframe.seamless = "seamless"; - // Back up if seamless isn't supported - this.iframe.style.border = "none"; - - this.iframe.addEventListener("load", this.loaded.bind(this), false); - return this.iframe; -}; - -/** -* Sets the source of the iframe with the given URL string -* Takes: URL string -* Returns: promise with document element -*/ -EPUBJS.Render.Iframe.prototype.load = function(chapter){ - var render = this, - deferred = new RSVP.defer(); - - chapter.url().then(function(url){ - // Reset the scroll position - render.leftPos = 0; - - if(this.window) { - this.unload(); - } - - this.iframe.onload = function(e) { - render.document = render.iframe.contentDocument; - render.docEl = render.document.documentElement; - render.headEl = render.document.head; - render.bodyEl = render.document.body || render.document.querySelector("body"); - render.window = render.iframe.contentWindow; - - render.window.addEventListener("resize", render.resized.bind(render), false); - - //-- Clear Margins - if(render.bodyEl) { - render.bodyEl.style.margin = "0"; - } - - deferred.resolve(render.docEl); - }; - - this.iframe.onerror = function(e) { - //console.error("Error Loading Contents", e); - deferred.reject({ - message : "Error Loading Contents: " + e, - stack : new Error().stack - }); - }; - - this.iframe.contentWindow.location.replace(url); - - }.bind(this)); - - return deferred.promise; -}; - - -EPUBJS.Render.Iframe.prototype.loaded = function(v){ - var url = this.iframe.contentWindow.location.href; - if(url != "about:blank"){ - this.trigger("render:loaded", url); - } -}; - -// Resize the iframe to the given width and height -EPUBJS.Render.Iframe.prototype.resize = function(width, height){ - var iframeBox; - - if(!this.iframe) return; - - this.iframe.height = height; - - if(!isNaN(width) && width % 2 !== 0){ - width += 1; //-- Prevent cutting off edges of text in columns - } - - this.iframe.width = width; - // Get the fractional height and width of the iframe - // Default to orginal if bounding rect is 0 - this.width = this.iframe.getBoundingClientRect().width || width; - this.height = this.iframe.getBoundingClientRect().height || height; -}; - - -EPUBJS.Render.Iframe.prototype.resized = function(e){ - // Get the fractional height and width of the iframe - this.width = this.iframe.getBoundingClientRect().width; - this.height = this.iframe.getBoundingClientRect().height; -}; - -EPUBJS.Render.Iframe.prototype.totalWidth = function(){ - return this.docEl.scrollWidth; -}; - -EPUBJS.Render.Iframe.prototype.totalHeight = function(){ - return this.docEl.scrollHeight; -}; - -EPUBJS.Render.Iframe.prototype.setPageDimensions = function(pageWidth, pageHeight){ - this.pageWidth = pageWidth; - this.pageHeight = pageHeight; - //-- Add a page to the width of the document to account an for odd number of pages - // this.docEl.style.width = this.docEl.scrollWidth + pageWidth + "px"; -}; - -EPUBJS.Render.Iframe.prototype.setLeft = function(leftPos){ - // this.bodyEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style[EPUBJS.Render.Iframe.transform] = 'translate('+ (-leftPos) + 'px, 0)'; - this.document.defaultView.scrollTo(leftPos, 0); -}; - -EPUBJS.Render.Iframe.prototype.setStyle = function(style, val, prefixed){ - if(prefixed) { - style = EPUBJS.core.prefixed(style); - } - - if(this.bodyEl) this.bodyEl.style[style] = val; -}; - -EPUBJS.Render.Iframe.prototype.removeStyle = function(style){ - - if(this.bodyEl) this.bodyEl.style[style] = ''; - -}; - -EPUBJS.Render.Iframe.prototype.addHeadTag = function(tag, attrs, _doc) { - var doc = _doc || this.document; - var tagEl = doc.createElement(tag); - var headEl = doc.head; - - for(var attr in attrs) { - tagEl.setAttribute(attr, attrs[attr]); - } - - if(headEl) headEl.insertBefore(tagEl, headEl.firstChild); -}; - -EPUBJS.Render.Iframe.prototype.page = function(pg){ - this.leftPos = this.pageWidth * (pg-1); //-- pages start at 1 - this.setLeft(this.leftPos); -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByElement = function(el){ - var left, pg; - if(!el) return; - - left = this.leftPos + el.getBoundingClientRect().left; //-- Calculate left offset compaired to scrolled position - - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByRect = function(boundingClientRect){ - var left, pg; - - left = this.leftPos + boundingClientRect.left; //-- Calculate left offset compaired to scrolled position - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -// Return the root element of the content -EPUBJS.Render.Iframe.prototype.getBaseElement = function(){ - return this.bodyEl; -}; - -// Checks if an element is on the screen -EPUBJS.Render.Iframe.prototype.isElementVisible = function(el){ - var rect; - var left; - - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - left = rect.left; //+ rect.width; - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - left >= 0 && - left < this.pageWidth ) { - return true; - } - } - - return false; -}; - - -EPUBJS.Render.Iframe.prototype.scroll = function(bool){ - if(bool) { - this.iframe.scrolling = "yes"; - } else { - this.iframe.scrolling = "no"; - } -}; - -// Cleanup event listeners -EPUBJS.Render.Iframe.prototype.unload = function(){ - this.window.removeEventListener("resize", this.resized); -}; - -//-- Enable binding events to Render -RSVP.EventTarget.mixin(EPUBJS.Render.Iframe.prototype); -EPUBJS.Renderer = function(renderMethod, hidden) { - // Dom events to listen for - this.listenedEvents = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click"]; - this.upEvent = "mouseup"; - this.downEvent = "mousedown"; - if('ontouchstart' in document.documentElement) { - this.listenedEvents.push("touchstart", "touchend"); - this.upEvent = "touchend"; - this.downEvent = "touchstart"; - } - /** - * Setup a render method. - * Options are: Iframe - */ - if(renderMethod && typeof(EPUBJS.Render[renderMethod]) != "undefined"){ - this.render = new EPUBJS.Render[renderMethod](); - } else { - console.error("Not a Valid Rendering Method"); - } - - // Listen for load events - this.render.on("render:loaded", this.loaded.bind(this)); - - // Cached for replacement urls from storage - this.caches = {}; - - // Blank Cfi for Parsing - this.epubcfi = new EPUBJS.EpubCFI(); - - this.spreads = true; - this.isForcedSingle = false; - this.resized = _.debounce(this.onResized.bind(this), 100); - - this.layoutSettings = {}; - - this.hidden = hidden || false; - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - this.getHooks("beforeChapterDisplay"); - - //-- Queue up page changes if page map isn't ready - this._q = EPUBJS.core.queue(this); - - this._moving = false; - -}; - -//-- Renderer events for listening -EPUBJS.Renderer.prototype.Events = [ - "renderer:keydown", - "renderer:keyup", - "renderer:keypressed", - "renderer:mouseup", - "renderer:mousedown", - "renderer:click", - "renderer:touchstart", - "renderer:touchend", - "renderer:selected", - "renderer:chapterUnloaded", - "renderer:chapterDisplayed", - "renderer:locationChanged", - "renderer:visibleLocationChanged", - "renderer:resized", - "renderer:spreads" -]; - -/** -* Creates an element to render to. -* Resizes to passed width and height or to the elements size -*/ -EPUBJS.Renderer.prototype.initialize = function(element, width, height){ - this.container = element; - this.element = this.render.create(); - - this.initWidth = width; - this.initHeight = height; - - this.width = width || this.container.clientWidth; - this.height = height || this.container.clientHeight; - - this.container.appendChild(this.element); - - if(width && height){ - this.render.resize(this.width, this.height); - } else { - this.render.resize('100%', '100%'); - } - - document.addEventListener("orientationchange", this.onResized); -}; - -/** -* Display a chapter -* Takes: chapter object, global layout settings -* Returns: Promise with passed Renderer after pages has loaded -*/ -EPUBJS.Renderer.prototype.displayChapter = function(chapter, globalLayout){ - var store = false; - if(this._moving) { - console.error("Rendering In Progress"); - return; - } - this._moving = true; - // Get the url string from the chapter (may be from storage) - return chapter.url(). - then(function(url) { - - // Unload the previous chapter listener - if(this.currentChapter) { - this.currentChapter.unload(); // Remove stored blobs - - if(this.render.window){ - this.render.window.removeEventListener("resize", this.resized); - } - - this.removeEventListeners(); - this.removeSelectionListeners(); - this.trigger("renderer:chapterUnloaded"); - this.contents = null; - this.doc = null; - this.pageMap = null; - } - - this.currentChapter = chapter; - this.chapterPos = 1; - this.currentChapterCfiBase = chapter.cfiBase; - - this.layoutSettings = this.reconcileLayoutSettings(globalLayout, chapter.properties); - return this.load(chapter); - - }.bind(this)); - -}; - -/** -* Loads a url (string) and renders it, -* attaching event listeners and triggering hooks. -* Returns: Promise with the rendered contents. -*/ - -EPUBJS.Renderer.prototype.load = function(url){ - var deferred = new RSVP.defer(); - var loaded; - - // Switch to the required layout method for the settings - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - - this.visible(false); - - render = this.render.load(url); - - render.then(function(contents) { - var formated; - this.currentChapter.setDocument(this.render.document); - this.contents = contents; - this.doc = this.render.document; - - // Format the contents using the current layout method - this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap); - this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight); - - // window.addEventListener("orientationchange", this.onResized.bind(this), false); - if(!this.initWidth && !this.initHeight){ - this.render.window.addEventListener("resize", this.resized, false); - } - - this.addEventListeners(); - this.addSelectionListeners(); - - //-- Trigger registered hooks before displaying - this.beforeDisplay(function(){ - var pages = this.layout.calculatePages(); - var msg = this.currentChapter; - var queued = this._q.length(); - this._moving = false; - - this.updatePages(pages); - - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - - if(queued === 0) { - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - } - - msg.cfi = this.currentLocationCfi; //TODO: why is this cfi passed to chapterDisplayed - this.trigger("renderer:chapterDisplayed", msg); - - this.visible(true); - - deferred.resolve(this); //-- why does this return the renderer? - }.bind(this)); - - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Renderer.prototype.loaded = function(url){ - this.trigger("render:loaded", url); - // var uri = EPUBJS.core.uri(url); - // var relative = uri.path.replace(book.bookUrl, ''); - // console.log(url, uri, relative); -}; - -/** -* Reconciles the current chapters layout properies with -* the global layout properities. -* Takes: global layout settings object, chapter properties string -* Returns: Object with layout properties -*/ -EPUBJS.Renderer.prototype.reconcileLayoutSettings = function(global, chapter){ - var settings = {}; - - //-- Get the global defaults - for (var attr in global) { - if (global.hasOwnProperty(attr)){ - settings[attr] = global[attr]; - } - } - //-- Get the chapter's display type - chapter.forEach(function(prop){ - var rendition = prop.replace("rendition:", ''); - var split = rendition.indexOf("-"); - var property, value; - - if(split != -1){ - property = rendition.slice(0, split); - value = rendition.slice(split+1); - - settings[property] = value; - } - }); - return settings; -}; - -/** -* Uses the settings to determine which Layout Method is needed -* Triggers events based on the method choosen -* Takes: Layout settings object -* Returns: String of appropriate for EPUBJS.Layout function -*/ -EPUBJS.Renderer.prototype.determineLayout = function(settings){ - // Default is layout: reflowable & spread: auto - var spreads = this.determineSpreads(this.minSpreadWidth); - var layoutMethod = spreads ? "ReflowableSpreads" : "Reflowable"; - var scroll = false; - - if(settings.layout === "pre-paginated") { - layoutMethod = "Fixed"; - scroll = true; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "none") { - layoutMethod = "Reflowable"; - scroll = false; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "both") { - layoutMethod = "ReflowableSpreads"; - scroll = false; - spreads = true; - } - - this.spreads = spreads; - this.render.scroll(scroll); - this.trigger("renderer:spreads", spreads); - return layoutMethod; -}; - -// Shortcut to trigger the hook before displaying the chapter -EPUBJS.Renderer.prototype.beforeDisplay = function(callback, renderer){ - this.triggerHooks("beforeChapterDisplay", callback, this); -}; - -// Update the renderer with the information passed by the layout -EPUBJS.Renderer.prototype.updatePages = function(layout){ - this.pageMap = this.mapPage(); - // this.displayedPages = layout.displayedPages; - - if (this.spreads) { - this.displayedPages = Math.ceil(this.pageMap.length / 2); - } else { - this.displayedPages = this.pageMap.length; - } - - // this.currentChapter.pages = layout.pageCount; - this.currentChapter.pages = this.pageMap.length; - - this._q.flush(); -}; - -// Apply the layout again and jump back to the previous cfi position -EPUBJS.Renderer.prototype.reformat = function(){ - var renderer = this; - var formated, pages; - if(!this.contents) return; - - spreads = this.determineSpreads(this.minSpreadWidth); - - // Only re-layout if the spreads have switched - if(spreads != this.spreads){ - this.spreads = spreads; - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - } - - // Reset pages - this.chapterPos = 1; - this.render.page(1); - - // Give the css styles time to update - // clearTimeout(this.timeoutTillCfi); - // this.timeoutTillCfi = setTimeout(function(){ - - renderer.formated = renderer.layout.format(renderer.contents, renderer.render.width, renderer.render.height, renderer.gap); - renderer.render.setPageDimensions(renderer.formated.pageWidth, renderer.formated.pageHeight); - - pages = renderer.layout.calculatePages(); - renderer.updatePages(pages); - - //-- Go to current page after formating - if(renderer.currentLocationCfi){ - renderer.gotoCfi(renderer.currentLocationCfi); - } - // renderer.timeoutTillCfi = null; - -}; - -// Hide and show the render's container . -EPUBJS.Renderer.prototype.visible = function(bool){ - if(typeof(bool) === "undefined") { - return this.element.style.visibility; - } - - if(bool === true && !this.hidden){ - this.element.style.visibility = "visible"; - }else if(bool === false){ - this.element.style.visibility = "hidden"; - } -}; - -// Remove the render element and clean up listeners -EPUBJS.Renderer.prototype.remove = function() { - if(this.render.window) { - this.render.unload(); - this.render.window.removeEventListener("resize", this.resized); - this.removeEventListeners(); - this.removeSelectionListeners(); - } - - this.container.removeChild(this.element); -}; - -//-- STYLES - -EPUBJS.Renderer.prototype.applyStyles = function(styles) { - for (var style in styles) { - this.render.setStyle(style, styles[style]); - } -}; - -EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){ - this.render.setStyle(style, val, prefixed); -}; - -EPUBJS.Renderer.prototype.removeStyle = function(style){ - this.render.removeStyle(style); -}; - -//-- HEAD TAGS -EPUBJS.Renderer.prototype.applyHeadTags = function(headTags) { - for ( var headTag in headTags ) { - this.render.addHeadTag(headTag, headTags[headTag]); - } -}; - -//-- NAVIGATION - -EPUBJS.Renderer.prototype.page = function(pg){ - if(!this.pageMap) { - console.warn("pageMap not set, queuing"); - this._q.enqueue("page", arguments); - return true; - } - - if(pg >= 1 && pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; - -// Short cut to find next page's cfi starting at the last visible element -/* -EPUBJS.Renderer.prototype.nextPage = function(){ - var pg = this.chapterPos + 1; - if(pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - - this.currentLocationCfi = this.getPageCfi(this.visibileEl); - this.trigger("renderer:locationChanged", this.currentLocationCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; -*/ -EPUBJS.Renderer.prototype.nextPage = function(){ - return this.page(this.chapterPos + 1); -}; - -EPUBJS.Renderer.prototype.prevPage = function(){ - return this.page(this.chapterPos - 1); -}; - -//-- Show the page containing an Element -EPUBJS.Renderer.prototype.pageByElement = function(el){ - var pg; - if(!el) return; - - pg = this.render.getPageNumberByElement(el); - this.page(pg); -}; - -// Jump to the last page of the chapter -EPUBJS.Renderer.prototype.lastPage = function(){ - if(this._moving) { - return this._q.enqueue("lastPage", arguments); - } - - this.page(this.displayedPages); -}; - -// Jump to the first page of the chapter -EPUBJS.Renderer.prototype.firstPage = function(){ - this.page(1); -}; - -//-- Find a section by fragement id -EPUBJS.Renderer.prototype.section = function(fragment){ - var el = this.doc.getElementById(fragment), - left, pg; - - if(el){ - this.pageByElement(el); - } - -}; - -EPUBJS.Renderer.prototype.firstElementisTextNode = function(node) { - var children = node.childNodes; - var leng = children.length; - - if(leng && - children[0] && // First Child - children[0].nodeType === 3 && // This is a textNodes - children[0].textContent.trim().length) { // With non whitespace or return charecters - return true; - } - return false; -}; - -// Walk the node tree from a start element to next visible element -EPUBJS.Renderer.prototype.walk = function(node, x, y) { - var r, children, leng, - startNode = node, - prevNode, - stack = [startNode]; - - var STOP = 10000, ITER=0; - - while(!r && stack.length) { - node = stack.shift(); - if( this.containsPoint(node, x, y) && this.firstElementisTextNode(node)) { - r = node; - } - - if(!r && node && node.childElementCount > 0){ - children = node.children; - if (children && children.length) { - leng = children.length ? children.length : 0; - } else { - return r; - } - for (var i = leng-1; i >= 0; i--) { - if(children[i] != prevNode) stack.unshift(children[i]); - } - } - - if(!r && stack.length === 0 && startNode && startNode.parentNode !== null){ - stack.push(startNode.parentNode); - prevNode = startNode; - startNode = startNode.parentNode; - } - - - ITER++; - if(ITER > STOP) { - console.error("ENDLESS LOOP"); - break; - } - - } - - return r; -}; - -// Checks if an element is on the screen -EPUBJS.Renderer.prototype.containsPoint = function(el, x, y){ - var rect; - var left; - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - // console.log(el, rect, x, y); - - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - rect.left >= x && - x <= rect.left + rect.width) { - return true; - } - } - - return false; -}; - -EPUBJS.Renderer.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if ( ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.sprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.mapPage = function(){ - var renderer = this; - var map = []; - var root = this.render.getBaseElement(); - var page = 1; - var width = this.layout.colWidth + this.layout.gap; - var offset = this.formated.pageWidth * (this.chapterPos-1); - var limit = (width * page) - offset;// (width * page) - offset; - var elLimit = 0; - var prevRange; - var cfi; - var check = function(node) { - var elPos; - var elRange; - var children = Array.prototype.slice.call(node.childNodes); - if (node.nodeType == Node.ELEMENT_NODE) { - // elPos = node.getBoundingClientRect(); - elRange = document.createRange(); - elRange.selectNodeContents(node); - elPos = elRange.getBoundingClientRect(); - - if(!elPos || (elPos.width === 0 && elPos.height === 0)) { - return; - } - - //-- Element starts new Col - if(elPos.left > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - - //-- Element Spans new Col - if(elPos.right > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - } - - }; - var checkText = function(node){ - var ranges = renderer.splitTextNodeIntoWordsRanges(node); - ranges.forEach(function(range){ - var pos = range.getBoundingClientRect(); - - if(!pos || (pos.width === 0 && pos.height === 0)) { - return; - } - if(pos.left + pos.width < limit) { - if(!map[page-1]){ - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - // map[page-1].start = cfi; - map.push({ start: cfi, end: null }); - } - } else { - if(prevRange){ - prevRange.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - map.push({ - start: cfi, - end: null - }); - - page += 1; - limit = (width * page) - offset; - elLimit = limit; - } - - prevRange = range; - }); - - - }; - - this.sprint(root, check); - // this.textSprint(root, checkText); - - if(prevRange){ - prevRange.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - // Handle empty map - if(!map.length) { - range = this.doc.createRange(); - range.selectNodeContents(root); - range.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(range); - - map.push({ start: cfi, end: cfi }); - - } - - // clean up - prevRange = null; - ranges = null; - range = null; - root = null; - - return map; -}; - - -EPUBJS.Renderer.prototype.indexOfBreakableChar = function (text, startPosition) { - var whiteCharacters = "\x2D\x20\t\r\n\b\f"; - // '-' \x2D - // ' ' \x20 - - if (! startPosition) { - startPosition = 0; - } - - for (var i = startPosition; i < text.length; i++) { - if (whiteCharacters.indexOf(text.charAt(i)) != -1) { - return i; - } - } - - return -1; -}; - - -EPUBJS.Renderer.prototype.splitTextNodeIntoWordsRanges = function(node){ - var ranges = []; - var text = node.textContent.trim(); - var range; - var rect; - var list; - // jaroslaw.bielski@7bulls.com - // Usage of indexOf() function for space character as word delimiter - // is not sufficient in case of other breakable characters like \r\n- etc - pos = this.indexOfBreakableChar(text); - - if(pos === -1) { - range = this.doc.createRange(); - range.selectNodeContents(node); - return [range]; - } - - range = this.doc.createRange(); - range.setStart(node, 0); - range.setEnd(node, pos); - ranges.push(range); - - // jaroslaw.bielski@7bulls.com - // there was a word miss in case of one letter words - range = this.doc.createRange(); - range.setStart(node, pos+1); - - while ( pos != -1 ) { - - pos = this.indexOfBreakableChar(text, pos + 1); - if(pos > 0) { - - if(range) { - range.setEnd(node, pos); - ranges.push(range); - } - - range = this.doc.createRange(); - range.setStart(node, pos+1); - } - } - - if(range) { - range.setEnd(node, text.length); - ranges.push(range); - } - - return ranges; -}; - -EPUBJS.Renderer.prototype.rangePosition = function(range){ - var rect; - var list; - - list = range.getClientRects(); - - if(list.length) { - rect = list[0]; - return rect; - } - - return null; -}; - -/* -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(prevEl){ - var range = this.doc.createRange(); - var position; - // TODO : this might need to take margin / padding into account? - var x = 1;//this.formated.pageWidth/2; - var y = 1;//;this.formated.pageHeight/2; - - range = this.getRange(x, y); - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - - return this.currentChapter.cfiFromRange(range); -}; -*/ - -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(){ - var pg; - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - } - return this.pageMap[(this.chapterPos * 2) -1].start; -}; - -EPUBJS.Renderer.prototype.getRange = function(x, y, forceElement){ - var range = this.doc.createRange(); - var position; - forceElement = true; // temp override - if(typeof document.caretPositionFromPoint !== "undefined" && !forceElement){ - position = this.doc.caretPositionFromPoint(x, y); - range.setStart(position.offsetNode, position.offset); - } else if(typeof document.caretRangeFromPoint !== "undefined" && !forceElement){ - range = this.doc.caretRangeFromPoint(x, y); - } else { - this.visibileEl = this.findElementAfter(x, y); - range.setStart(this.visibileEl, 1); - } - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - return range; -}; - -/* -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(prevEl){ - var startX = 0; - var startY = 0; - var endX = this.width-1; - var endY = this.height-1; - var startRange = this.getRange(startX, startY); - var endRange = this.getRange(endX, endY); //fix if carret not avail - var startCfi = this.currentChapter.cfiFromRange(startRange); - var endCfi; - if(endRange) { - endCfi = this.currentChapter.cfiFromRange(endRange); - } - - return { - start: startCfi, - end: endCfi || false - }; -}; -*/ - -EPUBJS.Renderer.prototype.pagesInCurrentChapter = function() { - var pgs; - var length; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - length = this.pageMap.length; - - if(this.spreads){ - pgs = Math.ceil(length / 2); - } else { - pgs = length; - } - - return pgs; -}; - -EPUBJS.Renderer.prototype.currentRenderedPage = function(){ - var pg; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads && this.layout.pageCount > 1) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - return pg; -}; - -EPUBJS.Renderer.prototype.getRenderedPagesLeft = function(){ - var pg; - var lastPage; - var pagesLeft; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - lastPage = this.pageMap.length; - - if (this.spreads) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - pagesLeft = lastPage - pg; - return pagesLeft; - -}; - -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(){ - var pg; - var startRange, endRange; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - endRange = startRange; - - if(this.layout.pageCount > 1) { - endRange = this.pageMap[pg-1]; - } - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - endRange = startRange; - } - - if(!startRange) { - console.warn("page range miss:", pg, this.pageMap); - startRange = this.pageMap[this.pageMap.length-1]; - endRange = startRange; - } - - return { - start: startRange.start, - end: endRange.end - }; -}; - -// Goto a cfi position in the current chapter -EPUBJS.Renderer.prototype.gotoCfi = function(cfi){ - var pg; - var marker; - var range; - - if(this._moving){ - return this._q.enqueue("gotoCfi", arguments); - } - - if(_.isString(cfi)){ - cfi = this.epubcfi.parse(cfi); - } - - if(typeof document.evaluate === 'undefined') { - marker = this.epubcfi.addMarker(cfi, this.doc); - if(marker) { - pg = this.render.getPageNumberByElement(marker); - // Must Clean up Marker before going to page - this.epubcfi.removeMarker(marker, this.doc); - this.page(pg); - } - } else { - range = this.epubcfi.generateRangeFromCfi(cfi, this.doc); - if(range) { - // jaroslaw.bielski@7bulls.com - // It seems that sometimes getBoundingClientRect() returns null for first page CFI in chapter. - // It is always reproductible if few consecutive chapters have only one page. - // NOTE: This is only workaround and the issue needs an deeper investigation. - // NOTE: Observed on Android 4.2.1 using WebView widget as HTML renderer (Asus TF300T). - var rect = range.getBoundingClientRect(); - if (rect) { - pg = this.render.getPageNumberByRect(rect); - - } else { - // Goto first page in chapter - pg = 1; - } - - this.page(pg); - - // Reset the current location cfi to requested cfi - this.currentLocationCfi = cfi.str; - } - } -}; - -// Walk nodes until a visible element is found -EPUBJS.Renderer.prototype.findFirstVisible = function(startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - // kgolunski@7bulls.com - // Looks like an old API usage - // Set x and y as 0 to fullfill walk method API. - found = this.walk(el, 0, 0); - - if(found) { - return found; - }else{ - return startEl; - } - -}; -// TODO: remove me - unsused -EPUBJS.Renderer.prototype.findElementAfter = function(x, y, startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - found = this.walk(el, x, y); - if(found) { - return found; - }else{ - return el; - } - -}; - -/* -EPUBJS.Renderer.prototype.route = function(hash, callback){ - var location = window.location.hash.replace('#/', ''); - if(this.useHash && location.length && location != this.prevLocation){ - this.show(location, callback); - this.prevLocation = location; - return true; - } - return false; -} - -EPUBJS.Renderer.prototype.hideHashChanges = function(){ - this.useHash = false; -} - -*/ - -EPUBJS.Renderer.prototype.resize = function(width, height, setSize){ - var spreads; - - this.width = width; - this.height = height; - - if(setSize !== false) { - this.render.resize(this.width, this.height); - } - - - - if(this.contents){ - this.reformat(); - } - - this.trigger("renderer:resized", { - width: this.width, - height: this.height - }); -}; - -//-- Listeners for events in the frame - -EPUBJS.Renderer.prototype.onResized = function(e) { - var width = this.container.clientWidth; - var height = this.container.clientHeight; - - this.resize(width, height, false); -}; - -EPUBJS.Renderer.prototype.addEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.addEventListener(eventName, this.triggerEvent.bind(this), false); - }, this); - -}; - -EPUBJS.Renderer.prototype.removeEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.removeEventListener(eventName, this.triggerEvent, false); - }, this); - -}; - -// Pass browser events -EPUBJS.Renderer.prototype.triggerEvent = function(e){ - this.trigger("renderer:"+e.type, e); -}; - -EPUBJS.Renderer.prototype.addSelectionListeners = function(){ - this.render.document.addEventListener("selectionchange", this.onSelectionChange.bind(this), false); -}; - -EPUBJS.Renderer.prototype.removeSelectionListeners = function(){ - if(!this.render.document) { - return; - } - this.doc.removeEventListener("selectionchange", this.onSelectionChange, false); -}; - -EPUBJS.Renderer.prototype.onSelectionChange = function(e){ - if (this.selectionEndTimeout) { - clearTimeout(this.selectionEndTimeout); - } - this.selectionEndTimeout = setTimeout(function() { - this.selectedRange = this.render.window.getSelection(); - this.trigger("renderer:selected", this.selectedRange); - }.bind(this), 500); -}; - - -//-- Spreads - -EPUBJS.Renderer.prototype.setMinSpreadWidth = function(width){ - this.minSpreadWidth = width; - this.spreads = this.determineSpreads(width); -}; - -EPUBJS.Renderer.prototype.determineSpreads = function(cutoff){ - if(this.isForcedSingle || !cutoff || this.width < cutoff) { - return false; //-- Single Page - }else{ - return true; //-- Double Page - } -}; - -EPUBJS.Renderer.prototype.forceSingle = function(bool){ - if(bool) { - this.isForcedSingle = true; - // this.spreads = false; - } else { - this.isForcedSingle = false; - // this.spreads = this.determineSpreads(this.minSpreadWidth); - } -}; - -EPUBJS.Renderer.prototype.setGap = function(gap){ - this.gap = gap; //-- False == auto gap -}; - -//-- Content Replacements - -EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){ - var items = this.contents.querySelectorAll(query), - resources = Array.prototype.slice.call(items), - count = resources.length; - - - if(count === 0) { - finished(false); - return; - } - resources.forEach(function(item){ - var called = false; - var after = function(result, full){ - if(called === false) { - count--; - if(progress) progress(result, full, count); - if(count <= 0 && finished) finished(true); - called = true; - } - }; - - func(item, after); - - }.bind(this)); - -}; - -EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callback) { - var _oldUrls, - _newUrls = {}, - _store = this.currentChapter.store, - _cache = this.caches[query], - _uri = EPUBJS.core.uri(this.currentChapter.absolute), - _chapterBase = _uri.base, - _attr = attr, - _wait = 2000, - progress = function(url, full, count) { - _newUrls[full] = url; - }, - finished = function(notempty) { - if(callback) callback(); - - _.each(_oldUrls, function(url){ - _store.revokeUrl(url); - }); - - _cache = _newUrls; - }; - - if(!_store) return; - - if(!_cache) _cache = {}; - _oldUrls = _.clone(_cache); - - this.replace(query, function(link, done){ - var src = link.getAttribute(_attr), - full = EPUBJS.core.resolveUrl(_chapterBase, src); - - var replaceUrl = function(url) { - var timeout; - link.onload = function(){ - clearTimeout(timeout); - done(url, full); - }; - - link.onerror = function(e){ - clearTimeout(timeout); - done(url, full); - console.error(e); - }; - - if(query == "image") { - //-- SVG needs this to trigger a load event - link.setAttribute("externalResourcesRequired", "true"); - } - - if(query == "link[href]" && link.getAttribute("rel") !== "stylesheet") { - //-- Only Stylesheet links seem to have a load events, just continue others - done(url, full); - } - - link.setAttribute(_attr, url); - - //-- If elements never fire Load Event, should continue anyways - timeout = setTimeout(function(){ - done(url, full); - }, _wait); - - }; - - if(full in _oldUrls){ - replaceUrl(_oldUrls[full]); - _newUrls[full] = _oldUrls[full]; - delete _oldUrls[full]; - }else{ - func(_store, full, replaceUrl, link); - } - - }, finished, progress); -}; - -//-- Enable binding events to Renderer -RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype); - -var EPUBJS = EPUBJS || {}; -EPUBJS.replace = {}; - -//-- Replaces the relative links within the book to use our internal page changer -EPUBJS.replace.hrefs = function(callback, renderer){ - var book = this; - var replacments = function(link, done){ - var href = link.getAttribute("href"), - isRelative = href.search("://"), - directory, - relative, - location; - - if(isRelative != -1){ - - link.setAttribute("target", "_blank"); - - }else{ - // Links may need to be resolved, such as ../chp1.xhtml - directory = EPUBJS.core.uri(renderer.render.window.location.href).directory; - if(directory) { - relative = EPUBJS.core.resolveUrl(directory, href); - } else { - relative = href; - } - - link.onclick = function(){ - book.goto(relative); - return false; - }; - - } - done(); - - }; - - renderer.replace("a[href]", replacments, callback); - -}; - -EPUBJS.replace.head = function(callback, renderer) { - - renderer.replaceWithStored("link[href]", "href", EPUBJS.replace.links, callback); - -}; - - -//-- Replaces assets src's to point to stored version if browser is offline -EPUBJS.replace.resources = function(callback, renderer){ - //srcs = this.doc.querySelectorAll('[src]'); - renderer.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, callback); - -}; - -EPUBJS.replace.svg = function(callback, renderer) { - - renderer.replaceWithStored("image", "xlink:href", function(_store, full, done){ - _store.getUrl(full).then(done); - }, callback); - -}; - -EPUBJS.replace.srcs = function(_store, full, done){ - - _store.getUrl(full).then(done); - -}; - -//-- Replaces links in head, such as stylesheets - link[href] -EPUBJS.replace.links = function(_store, full, done, link){ - //-- Handle replacing urls in CSS - if(link.getAttribute("rel") === "stylesheet") { - EPUBJS.replace.stylesheets(_store, full).then(function(url, full){ - // done - setTimeout(function(){ - done(url, full); - }, 5); //-- Allow for css to apply before displaying chapter - }); - }else{ - _store.getUrl(full).then(done); - } -}; - -EPUBJS.replace.stylesheets = function(_store, full) { - var deferred = new RSVP.defer(); - - if(!_store) return; - - _store.getText(full).then(function(text){ - var url; - - EPUBJS.replace.cssUrls(_store, full, text).then(function(newText){ - var _URL = window.URL || window.webkitURL || window.mozURL; - - var blob = new Blob([newText], { "type" : "text\/css" }), - url = _URL.createObjectURL(blob); - - deferred.resolve(url); - - }, function(e) { - console.error(e); - }); - - }); - - return deferred.promise; -}; - -EPUBJS.replace.cssUrls = function(_store, base, text){ - var deferred = new RSVP.defer(), - promises = [], - matches = text.match(/url\(\'?\"?([^\'|^\"^\)]*)\'?\"?\)/g); - - if(!_store) return; - - if(!matches){ - deferred.resolve(text); - return deferred.promise; - } - - matches.forEach(function(str){ - var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, '')); - var replaced = _store.getUrl(full).then(function(url){ - text = text.replace(str, 'url("'+url+'")'); - }); - - promises.push(replaced); - }); - - RSVP.all(promises).then(function(){ - deferred.resolve(text); - }); - - return deferred.promise; -}; - - - -EPUBJS.Unarchiver = function(url){ - - this.loadLib(); - this.urlCache = {}; - -}; - -//-- Load the zip lib and set the workerScriptsPath -EPUBJS.Unarchiver.prototype.loadLib = function(callback){ - if(typeof(JSZip) == "undefined") console.error("JSZip lib not loaded"); -}; - -EPUBJS.Unarchiver.prototype.openZip = function(zipUrl, callback){ - var deferred = new RSVP.defer(); - - return EPUBJS.core.request(zipUrl, "binary").then(function(data){ - this.zip = new JSZip(data); - }.bind(this)); -}; - -EPUBJS.Unarchiver.prototype.getXml = function(url, encoding){ - - return this.getText(url, encoding). - then(function(text){ - var parser = new DOMParser(); - return parser.parseFromString(text, "text/xml"); - }); - -}; - -EPUBJS.Unarchiver.prototype.getUrl = function(url, mime){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - var tempUrl; - - if(!entry) { - deferred.reject({ - message : "File not found in the epub: " + url, - stack : new Error().stack - }); - return deferred.promise; - } - - if(url in this.urlCache) { - deferred.resolve(this.urlCache[url]); - return deferred.promise; - } - - blob = new Blob([entry.asUint8Array()], {type : mime || this.zip.getMimeType(entry.name)}); - - tempUrl = _URL.createObjectURL(blob); - deferred.resolve(tempUrl); - unarchiver.urlCache[url] = tempUrl; - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.getText = function(url, encoding){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - - if(!entry) { - console.warn("File not found in the contained epub:", url); - return deferred.promise; - } - - text = entry.asText(); - deferred.resolve(text); - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.revokeUrl = function(url){ - var _URL = window.URL || window.webkitURL || window.mozURL; - var fromCache = unarchiver.urlCache[url]; - if(fromCache) _URL.revokeObjectURL(fromCache); -}; - -EPUBJS.Unarchiver.prototype.failed = function(error){ - console.error(error); -}; - -EPUBJS.Unarchiver.prototype.afterSaved = function(error){ - this.callback(); -}; - -EPUBJS.Unarchiver.prototype.toStorage = function(entries){ - var timeout = 0, - delay = 20, - that = this, - count = entries.length; - - function callback(){ - count--; - if(count === 0) that.afterSaved(); - } - - entries.forEach(function(entry){ - - setTimeout(function(entry){ - that.saveEntryFileToStorage(entry, callback); - }, timeout, entry); - - timeout += delay; - }); - - console.log("time", timeout); - - //entries.forEach(this.saveEntryFileToStorage.bind(this)); -}; - -// EPUBJS.Unarchiver.prototype.saveEntryFileToStorage = function(entry, callback){ -// var that = this; -// entry.getData(new zip.BlobWriter(), function(blob) { -// EPUBJS.storage.save(entry.filename, blob, callback); -// }); -// }; - -//# sourceMappingURL=epub.js.map \ No newline at end of file diff --git a/static/epub.js/epub.min.map b/static/epub.js/epub.min.map deleted file mode 100644 index dd40312..0000000 --- a/static/epub.js/epub.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"epub.min.js","sources":["epub.js"],"names":["n","this","t","_","r","e","Array","prototype","u","Object","i","Function","a","push","o","slice","c","concat","l","toString","f","hasOwnProperty","s","forEach","p","map","h","reduce","v","reduceRight","d","filter","g","every","m","some","y","indexOf","b","lastIndexOf","x","isArray","keys","j","bind","w","_wrapped","exports","module","VERSION","A","each","length","call","has","collect","O","foldl","inject","arguments","TypeError","foldr","find","detect","E","select","reject","all","identity","any","contains","include","invoke","isFunction","apply","pluck","where","isEmpty","findWhere","max","Math","computed","value","min","shuffle","random","k","sortBy","index","criteria","sort","F","groupBy","countBy","sortedIndex","toArray","values","size","first","head","take","initial","last","rest","tail","drop","compact","R","flatten","without","difference","uniq","unique","union","intersection","zip","object","range","ceil","partial","bindAll","functions","memoize","delay","setTimeout","defer","throttle","Date","clearTimeout","debounce","once","wrap","compose","after","pairs","invert","methods","extend","pick","omit","defaults","clone","isObject","tap","I","source","global","multiline","ignoreCase","constructor","pop","isEqual","isString","isElement","nodeType","isArguments","isFinite","isNaN","parseFloat","isNumber","isBoolean","isNull","isUndefined","noConflict","times","floor","M","escape","&","<",">","\"","'","/","unescape","S","RegExp","join","replace","result","mixin","D","N","uniqueId","templateSettings","evaluate","interpolate","T","q","\\","\r","\n","\t","
","
","B","template","variable","chain","_chain","define","requireModule","require","requirejs","registry","seen","name","deps","callback","resolve","child","charAt","parts","split","parentBase","part","_eak_seen","Error","mod","reified","__dependency1__","__exports__","Promise","array","label","__dependency2__","fulfilled","state","rejected","reason","isNonThenable","entries","fulfilledResolver","resolveAll","rejectedResolver","results","remaining","entry","cast","then","useNextTick","process","nextTick","flush","useMutationObserver","iterations","observer","BrowserMutationObserver","node","document","createTextNode","observe","characterData","data","useSetTimeout","queue","tuple","arg","scheduleFlush","browserGlobal","window","MutationObserver","WebKitMutationObserver","configure","config","on","EventTarget","instrument","deferred","promise","callbacks","callbacksFor","_promiseCallbacks","off","trigger","undefined","eventName","allCallbacks","splice","options","__dependency3__","promises","filterFn","filterResults","valuesLen","filtered","keysOf","fulfilledTo","property","onRejection","now","guid","_guidKey","_id","detail","_detail","childGuid","_label","timeStamp","stack","error","mapFn","resultLen","mappedResults","makeNodeCallbackFor","nodeFunc","binding","nodeArgs","thisArg","__dependency4__","__dependency5__","__dependency6__","__dependency7__","__dependency8__","__dependency9__","noop","resolver","counter","_subscribers","invokeResolver","resolvePromise","rejectPromise","subscribe","parent","onFulfillment","subscribers","FULFILLED","REJECTED","publish","settled","invokeCallback","succeeded","failed","hasCallback","handleThenable","resolved","objectOrFunction","val","fulfill","_state","PENDING","SEALED","async","publishFulfillment","publishRejection","_onerror","race","Resolve","Reject","guidKey","thenPromise","catch","finally","Constructor","fulfillmentAt","pending","getTime","prop","__dependency10__","__dependency11__","__dependency12__","__dependency13__","__dependency14__","__dependency15__","denodeify","allSettled","hash","rethrow","asap","__PROMISE_INSTRUMENTATION__","RSVP","EPUBJS","plugins","filePath","Render","root","previousEpub","ePub","bookPath","Book","amd","settings","bookKey","packageUrl","storage","fromStorage","saved","online","contained","width","height","layoutOveride","orientation","minSpreadWidth","gap","version","restore","reload","goto","styles","headTags","withCredentials","render_method","EPUBJSVERSION","spinePos","stored","navigator","onLine","networkListeners","store","fileStorage","ready","manifest","spine","metadata","cover","toc","pageList","readyPromises","pagination","Pagination","pageListReady","_ready","isRendered","_q","core","_rendering","_displayQ","_moving","_gotoQ","renderer","Renderer","setMinSpreadWidth","setGap","listenToRenderer","defer_opened","opened","open","addEventListener","unload","forceReload","epubpackage","book","bookUrl","urlFrom","isContained","unarchive","loadPackage","localStorage","packageXml","identifier","packageIdentifier","restored","unpack","storeOffline","_registerReplacements","_containerPath","parse","Parser","containerPath","loadXml","containerXml","container","paths","contentsPath","basePath","packagePath","encoding","console","contents","packageContents","spineIndexByURL","generateBookKey","globalLayoutProperties","parseLayoutProperties","coverPath","spineNodeIndex","navPath","navUrl","navHtml","nav","epubcfi","EpubCFI","wait","pg","cfi","generateCfiFromHref","href","tocPath","tocUrl","tocXml","createHiddenRender","_width","_height","hiddenContainer","hiddenEl","box","element","getBoundingClientRect","forceSingle","createElement","style","visibility","overflow","appendChild","initialize","generatePageList","pager","spineLength","currentPage","nextChapter","chapter","next","done","Chapter","displayChapter","pageMap","item","start","page","spreads","end","remove","removeChild","generatePagination","defered","loadPagination","pagelistJSON","JSON","getPageList","getMetadata","getToc","Events","startPage","endPage","percent","pageRange","pageFromCfi","percentageFromPage","anchorPage","percentage","loadChange","url","uri","currentChapter","absolute","path","warn","filename","unlistenToRenderer","getXml","request","base","protocol","fromRoot","location","origin","host","baseTag","getElementsByTagName","resolveUrl","pathname","Unarchiver","openZip","extension","isSaved","storedSettings","getItem","saveContents","setItem","stringify","removeSavedContents","removeItem","renderTo","elem","rendered","getEl","_rendered","startDisplay","display","previousLocationCfi","gotoCfi","fetch","fromStore","len","clearSaved","chap","render","pos","enqueue","lastPage","preloadNextChapter","dequeue","message","nextPage","prevPage","prev","prevChapter","linear","getCurrentLocationCfi","currentLocationCfi","target","gotoPercentage","parseInt","substring","gotoPage","gotoHref","cfiString","spineItem","section","relativeURL","firstPage","cfiFromPage","pageFromPercentage","assets","batch","availableOffline","setStyle","prefixed","noreflow","reformat","removeStyle","addHeadTag","tag","attrs","useSpreads","use","_use","force","load","destroy","removeEventListener","applyStyles","applyHeadTags","registerHook","hrefs","_needsAssetReplacement","resources","svg","getStorageType","layout","spread","event","spineObject","id","cfiBase","properties","manifestProperties","pages","loaded","_store","get","xml","setDocument","doc","serializer","XMLSerializer","setAttribute","insertBefore","firstChild","serializeToString","tempUrl","getUrl","setPages","num","getPages","getID","ID","revokeUrl","_document","namespaceURI","doctype","implementation","createDocument","importNode","documentElement","cfiFromRange","_range","startXpath","endXpath","startContainer","endContainer","cleanEndTextContent","getElementXPath","nsResolver","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","collapsed","createRange","setStart","startOffset","setEnd","endOffset","log","cleanStartTextContent","cleanStringForXpath","textContent","generateCfiFromRange","_query","matches","query","toLowerCase","excerpt","text","limit","textSprint","func","treeWalker","createTreeWalker","NodeFilter","SHOW_TEXT","acceptNode","test","FILTER_ACCEPT","FILTER_REJECT","nextNode","getElementById","getEls","classes","getElementsByClassName","type","handler","readyState","DONE","status","responseXML","response","supportsURL","Blob","URL","BLOB_RESPONSE","xhr","XMLHttpRequest","xhrPrototype","defineProperty","onreadystatechange","responseType","setRequestHeader","overrideMimeType","send","obj","arr","member","newitm","ident","withoutProtocol","dot","firstSlash","directory","fragment","blob","doubleSlash","search","folder","lastSlash","dataURLToBlob","dataURL","contentType","raw","rawLength","uInt8Array","BASE64_MARKER","atob","Uint8Array","charCodeAt","addScript","src","onload","body","addScripts","srcArr","total","curr","cb","addCss","rel","unprefixed","vendors","upper","toUpperCase","segments","folders","uuid","insert","compareFunction","locationOf","_start","_end","compared","pivot","indexOfSorted","_scope","scope","funcName","args","context","inwait","shift","clear","getElementTreeXPath","nodeName","tagName","pathIndex","isXhtml","ownerDocument","getAttribute","Node","TEXT_NODE","indexOfTextNode","parentNode","sibling","previousSibling","DOCUMENT_TYPE_NODE","prefix","ns","xhtml","epub","str","match","textNode","sib","children","childNodes","cfiStr","generateChapterComponent","_spineNodeIndex","_pos","generatePathComponent","steps","segment","generateCfiFromElement","pathTo","unshift","getChapterComponent","splitStr","getPathComponent","pathComponent","getCharecterOffsetComponent","chapSegment","chapterComponent","charecterOffsetComponent","assertion","chapId","endInt","parseStep","has_brackets","spineId","step","characterOffset","textLocationAssertion","addMarker","_doc","_marker","lastStep","marker","createMarker","findParent","splitText","classList","add","removeMarker","nextSib","nextSibling","prevSib","sections","compare","cfiOne","cfiTwo","generateCfiFromTextNode","anchor","offset","generateCfiFromRangeAnchor","anchorNode","anchorOffset","startElement","startSteps","startPath","startIndex","endElement","endSteps","endPath","endIndex","generateXpathFromSteps","xpath","position","generateRangeFromCfi","textLength","debug","selectNode","el","events","createEvent","tell","listen","deafen","listenUntil","evt","CustomEvent","msg","dispatchEvent","bindto","OnEvt","OffEvt","unlisten","hooks","Hooks","getHooks","plugs","plugType","hook","toAdd","toFront","triggerHooks","passed","countdown","count","register","Layout","Reflowable","spreadWidth","format","_gap","columnAxis","columnGap","columnWidth","columnFill","colWidth","pageWidth","pageHeight","calculatePages","totalWidth","displayedPages","scrollWidth","pageCount","ReflowableSpreads","divisor","fullWidth","Fixed","content","viewport","querySelector","hasAttribute","locations","totalPages","round","percentageFromCfi","baseUrl","rootfile","fullpath","xmlEncoding","metadataNode","getElementText","manifestNode","spineNode","findNavPath","findTocPath","findCoverPath","tocId","bookTitle","creator","description","pubdate","publisher","language","rights","modified_date","querySelectorText","found","getElementsByTagNameNS","nodeValue","manifestXml","selected","querySelectorAll","items","spineXml","Id","props","propArray","manifestProps","manifestPropArray","vert","bookSpine","findListItems","findAnchorOrSpan","getTOC","list","nodes","subitems","idCounter","navEl","snapshot","ORDERED_NODE_SNAPSHOT_TYPE","snapshotLength","snapshotItem","navLabel","navMap","isCfi","Iframe","iframe","docEl","bodyEl","leftPos","create","scrolling","seamless","border","contentDocument","headEl","contentWindow","resized","margin","onerror","resize","totalHeight","scrollHeight","setPageDimensions","setLeft","defaultView","scrollTo","tagEl","attr","getPageNumberByElement","left","getPageNumberByRect","boundingClientRect","getBaseElement","isElementVisible","rect","scroll","bool","renderMethod","hidden","listenedEvents","upEvent","downEvent","caches","isForcedSingle","onResized","layoutSettings","initWidth","initHeight","clientWidth","clientHeight","globalLayout","removeEventListeners","removeSelectionListeners","chapterPos","currentChapterCfiBase","reconcileLayoutSettings","layoutMethod","determineLayout","visible","formated","addEventListeners","addSelectionListeners","beforeDisplay","queued","updatePages","visibleRangeCfi","getVisibleRangeCfi","rendition","determineSpreads","mapPage","headTag","pageByElement","firstElementisTextNode","leng","trim","walk","prevNode","startNode","STOP","ITER","containsPoint","childElementCount","sprint","SHOW_ELEMENT","prevRange","elLimit","check","elPos","elRange","ELEMENT_NODE","selectNodeContents","checkText","right","ranges","splitTextNodeIntoWordsRanges","collapse","indexOfBreakableChar","startPosition","whiteCharacters","rangePosition","getClientRects","getPageCfi","startRange","getRange","forceElement","caretPositionFromPoint","caretRangeFromPoint","visibileEl","findElementAfter","offsetNode","pagesInCurrentChapter","pgs","currentRenderedPage","getRenderedPagesLeft","pagesLeft","endRange","findFirstVisible","startEl","setSize","triggerEvent","onSelectionChange","selectionEndTimeout","selectedRange","getSelection","cutoff","finished","progress","called","full","replaceWithStored","_oldUrls","_newUrls","_cache","_uri","_chapterBase","_attr","_wait","link","replaceUrl","timeout","replacments","relative","isRelative","onclick","links","srcs","stylesheets","getText","cssUrls","newText","_URL","webkitURL","mozURL","createObjectURL","replaced","loadLib","urlCache","zipUrl","JSZip","parser","DOMParser","parseFromString","mime","unarchiver","decodededUrl","decodeURIComponent","file","asUint8Array","getMimeType","asText","fromCache","revokeObjectURL","afterSaved","toStorage","that","saveEntryFileToStorage"],"mappings":"CAAA,WAAY,GAAIA,GAAEC,KAAKC,EAAEF,EAAEG,EAAEC,KAAKC,EAAEC,MAAMC,UAAUC,EAAEC,OAAOF,UAAUG,EAAEC,SAASJ,UAAUK,EAAEP,EAAEQ,KAAKC,EAAET,EAAEU,MAAMC,EAAEX,EAAEY,OAAOC,EAAEV,EAAEW,SAASC,EAAEZ,EAAEa,eAAeC,EAAEjB,EAAEkB,QAAQC,EAAEnB,EAAEoB,IAAIC,EAAErB,EAAEsB,OAAOC,EAAEvB,EAAEwB,YAAYC,EAAEzB,EAAE0B,OAAOC,EAAE3B,EAAE4B,MAAMC,EAAE7B,EAAE8B,KAAKC,EAAE/B,EAAEgC,QAAQC,EAAEjC,EAAEkC,YAAYC,EAAElC,MAAMmC,QAAQtC,EAAEM,OAAOiC,KAAKC,EAAEjC,EAAEkC,KAAKC,EAAE,SAAS7C,GAAG,MAAOA,aAAa6C,GAAE7C,EAAEC,eAAgB4C,QAAG5C,KAAK6C,SAAS9C,GAAU,GAAI6C,GAAE7C,GAAI,oBAAoB+C,UAAS,mBAAoBC,SAAQA,OAAOD,UAAUA,QAAQC,OAAOD,QAAQF,GAAGE,QAAQ5C,EAAE0C,GAAG7C,EAAEG,EAAE0C,EAAEA,EAAEI,QAAQ,OAAQ,IAAIC,GAAEL,EAAEM,KAAKN,EAAEtB,QAAQ,SAASvB,EAAEE,EAAEG,GAAG,GAAG,MAAML,EAAE,GAAGsB,GAAGtB,EAAEuB,UAAUD,EAAEtB,EAAEuB,QAAQrB,EA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7oC,KAAK+M,YAGNmK,OAAO+L,WAAW3iB,UAAUwoC,UAAY,SAASx6B,GAMhD,QAASvB,KACRosB,IACa,IAAVA,GAAa4P,EAAKF,aAPtB,GAAIjC,GAAU,EACbl/B,EAAQ,GACRqhC,EAAO/oC,KACPm5B,EAAQ7qB,EAAQnL,MAOjBmL,GAAQhN,QAAQ,SAASsN,GAExBjH,WAAW,SAASiH,GACnBm6B,EAAKC,uBAAuBp6B,EAAO7B,IACjC65B,EAASh4B,GAEZg4B,GAAWl/B,IAGZyV,QAAQkO,IAAI,OAAQub"} \ No newline at end of file diff --git a/static/epub.js/epub_no_underscore.js b/static/epub.js/epub_no_underscore.js deleted file mode 100644 index 7835d6f..0000000 --- a/static/epub.js/epub_no_underscore.js +++ /dev/null @@ -1,7461 +0,0 @@ -(function(global) { -var define, requireModule, require, requirejs; - -(function() { - var registry = {}, seen = {}; - - define = function(name, deps, callback) { - registry[name] = { deps: deps, callback: callback }; - }; - - requirejs = require = requireModule = function(name) { - requirejs._eak_seen = registry; - - if (seen[name]) { return seen[name]; } - seen[name] = {}; - - if (!registry[name]) { - throw new Error("Could not find module " + name); - } - - var mod = registry[name], - deps = mod.deps, - callback = mod.callback, - reified = [], - exports; - - for (var i=0, l=deps.length; i 1; - }; - - RSVP.filter(promises, filterFn).then(function(result){ - // result is [ 2, 3 ] - }); - ``` - - If any of the `promises` given to `RSVP.filter` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var filterFn = function(item){ - return item > 1; - }; - - RSVP.filter(promises, filterFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.filter` will also wait for any promises returned from `filterFn`. - For instance, you may want to fetch a list of users then return a subset - of those users based on some asynchronous operation: - - ```javascript - - var alice = { name: 'alice' }; - var bob = { name: 'bob' }; - var users = [ alice, bob ]; - - var promises = users.map(function(user){ - return RSVP.resolve(user); - }); - - var filterFn = function(user){ - // Here, Alice has permissions to create a blog post, but Bob does not. - return getPrivilegesForUser(user).then(function(privs){ - return privs.can_create_blog_post === true; - }); - }; - RSVP.filter(promises, filterFn).then(function(users){ - // true, because the server told us only Alice can create a blog post. - users.length === 1; - // false, because Alice is the only user present in `users` - users[0] === bob; - }); - ``` - - @method filter - @for RSVP - @param {Array} promises - @param {Function} filterFn - function to be called on each resolved value to - filter the final results. - @param {String} label optional string describing the promise. Useful for - tooling. - @return {Promise} - */ - function filter(promises, filterFn, label) { - if (!isArray(promises)) { - throw new TypeError('You must pass an array to filter.'); - } - - if (!isFunction(filterFn)){ - throw new TypeError("You must pass a function to filter's second argument."); - } - - return all(promises, label).then(function(values){ - return map(promises, filterFn, label).then(function(filterResults){ - var i, - valuesLen = values.length, - filtered = []; - - for (i = 0; i < valuesLen; i++){ - if(filterResults[i]) filtered.push(values[i]); - } - return filtered; - }); - }); - } - - __exports__["default"] = filter; - }); -define("rsvp/hash", - ["./promise","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var isNonThenable = __dependency2__.isNonThenable; - var keysOf = __dependency2__.keysOf; - - /** - `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array - for its `promises` argument. - - Returns a promise that is fulfilled when all the given promises have been - fulfilled, or rejected if any of them become rejected. The returned promise - is fulfilled with a hash that has the same key names as the `promises` object - argument. If any of the values in the object are not promises, they will - simply be copied over to the fulfilled object. - - Example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - yourPromise: RSVP.resolve(2), - theirPromise: RSVP.resolve(3), - notAPromise: 4 - }; - - RSVP.hash(promises).then(function(hash){ - // hash here is an object that looks like: - // { - // myPromise: 1, - // yourPromise: 2, - // theirPromise: 3, - // notAPromise: 4 - // } - }); - ```` - - If any of the `promises` given to `RSVP.hash` are rejected, the first promise - that is rejected will be given as as the first argument, or as the reason to - the rejection handler. For example: - - ```javascript - var promises = { - myPromise: RSVP.resolve(1), - rejectedPromise: RSVP.reject(new Error("rejectedPromise")), - anotherRejectedPromise: RSVP.reject(new Error("anotherRejectedPromise")), - }; - - RSVP.hash(promises).then(function(hash){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "rejectedPromise" - }); - ``` - - An important note: `RSVP.hash` is intended for plain JavaScript objects that - are just a set of keys and values. `RSVP.hash` will NOT preserve prototype - chains. - - Example: - - ```javascript - function MyConstructor(){ - this.example = RSVP.resolve("Example"); - } - - MyConstructor.prototype = { - protoProperty: RSVP.resolve("Proto Property") - }; - - var myObject = new MyConstructor(); - - RSVP.hash(myObject).then(function(hash){ - // protoProperty will not be present, instead you will just have an - // object that looks like: - // { - // example: "Example" - // } - // - // hash.hasOwnProperty('protoProperty'); // false - // 'undefined' === typeof hash.protoProperty - }); - ``` - - @method hash - @for RSVP - @param {Object} promises - @param {String} label - optional string that describes the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all properties of `promises` - have been fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function hash(object, label) { - return new Promise(function(resolve, reject){ - var results = {}; - var keys = keysOf(object); - var remaining = keys.length; - var entry, property; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfilledTo(property) { - return function(value) { - results[property] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var i = 0; i < keys.length; i++) { - property = keys[i]; - entry = object[property]; - - if (isNonThenable(entry)) { - results[property] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Promise.cast(entry).then(fulfilledTo(property), onRejection); - } - } - }); - }; - }); -define("rsvp/instrument", - ["./config","./utils","exports"], - function(__dependency1__, __dependency2__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var now = __dependency2__.now; - - __exports__["default"] = function instrument(eventName, promise, child) { - // instrumentation should not disrupt normal usage. - try { - config.trigger(eventName, { - guid: promise._guidKey + promise._id, - eventName: eventName, - detail: promise._detail, - childGuid: child && promise._guidKey + child._id, - label: promise._label, - timeStamp: now(), - stack: new Error(promise._label).stack - }); - } catch(error) { - setTimeout(function(){ - throw error; - }, 0); - } - }; - }); -define("rsvp/map", - ["./promise","./all","./utils","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var all = __dependency2__["default"]; - var isArray = __dependency3__.isArray; - var isFunction = __dependency3__.isFunction; - - /** - - `RSVP.map` is similar to JavaScript's native `map` method, except that it - waits for all promises to become fulfilled before running the `mapFn` on - each item in given to `promises`. `RSVP.map` returns a promise that will - become fulfilled with the result of running `mapFn` on the values the promises - become fulfilled with. - - For example: - - ```javascript - - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(result){ - // result is [ 2, 3, 4 ] - }); - ``` - - If any of the `promises` given to `RSVP.map` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - var mapFn = function(item){ - return item + 1; - }; - - RSVP.map(promises, mapFn).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(reason) { - // reason.message === "2" - }); - ``` - - `RSVP.map` will also wait if a promise is returned from `mapFn`. For example, - say you want to get all comments from a set of blog posts, but you need - the blog posts first becuase they contain a url to those comments. - - ```javscript - - var mapFn = function(blogPost){ - // getComments does some ajax and returns an RSVP.Promise that is fulfilled - // with some comments data - return getComments(blogPost.comments_url); - }; - - // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled - // with some blog post data - RSVP.map(getBlogPosts(), mapFn).then(function(comments){ - // comments is the result of asking the server for the comments - // of all blog posts returned from getBlogPosts() - }); - ``` - - @method map - @for RSVP - @param {Array} promises - @param {Function} mapFn function to be called on each fulfilled promise. - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled with the result of calling - `mapFn` on each fulfilled promise or value when they become fulfilled. - The promise will be rejected if any of the given `promises` become rejected. - */ - __exports__["default"] = function map(promises, mapFn, label) { - - if (!isArray(promises)) { - throw new TypeError('You must pass an array to map.'); - } - - if (!isFunction(mapFn)){ - throw new TypeError("You must pass a function to map's second argument."); - } - - return all(promises, label).then(function(results){ - var resultLen = results.length, - mappedResults = [], - i; - - for (i = 0; i < resultLen; i++){ - mappedResults.push(mapFn(results[i])); - } - - return all(mappedResults, label); - }); - }; - }); -define("rsvp/node", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - var slice = Array.prototype.slice; - - function makeNodeCallbackFor(resolve, reject) { - return function (error, value) { - if (error) { - reject(error); - } else if (arguments.length > 2) { - resolve(slice.call(arguments, 1)); - } else { - resolve(value); - } - }; - } - - /** - `RSVP.denodeify` takes a "node-style" function and returns a function that - will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the - browser when you'd prefer to use promises over using callbacks. For example, - `denodeify` transforms the following: - - ```javascript - var fs = require('fs'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - handleData(data); - }); - ``` - - into: - - ```javascript - var fs = require('fs'); - - var readFile = RSVP.denodeify(fs.readFile); - - readFile('myfile.txt').then(handleData, handleError); - ``` - - Using `denodeify` makes it easier to compose asynchronous operations instead - of using callbacks. For example, instead of: - - ```javascript - var fs = require('fs'); - var log = require('some-async-logger'); - - fs.readFile('myfile.txt', function(err, data){ - if (err) return handleError(err); - fs.writeFile('myfile2.txt', data, function(err){ - if (err) throw err; - log('success', function(err) { - if (err) throw err; - }); - }); - }); - ``` - - You can chain the operations together using `then` from the returned promise: - - ```javascript - var fs = require('fs'); - var denodeify = RSVP.denodeify; - var readFile = denodeify(fs.readFile); - var writeFile = denodeify(fs.writeFile); - var log = denodeify(require('some-async-logger')); - - readFile('myfile.txt').then(function(data){ - return writeFile('myfile2.txt', data); - }).then(function(){ - return log('SUCCESS'); - }).then(function(){ - // success handler - }, function(reason){ - // rejection handler - }); - ``` - - @method denodeify - @for RSVP - @param {Function} nodeFunc a "node-style" function that takes a callback as - its last argument. The callback expects an error to be passed as its first - argument (if an error occurred, otherwise null), and the value from the - operation as its second argument ("function(err, value){ }"). - @param {Any} binding optional argument for binding the "this" value when - calling the `nodeFunc` function. - @return {Function} a function that wraps `nodeFunc` to return an - `RSVP.Promise` - */ - __exports__["default"] = function denodeify(nodeFunc, binding) { - return function() { - var nodeArgs = slice.call(arguments), resolve, reject; - var thisArg = this || binding; - - return new Promise(function(resolve, reject) { - Promise.all(nodeArgs).then(function(nodeArgs) { - try { - nodeArgs.push(makeNodeCallbackFor(resolve, reject)); - nodeFunc.apply(thisArg, nodeArgs); - } catch(e) { - reject(e); - } - }); - }); - }; - }; - }); -define("rsvp/promise", - ["./config","./events","./instrument","./utils","./promise/cast","./promise/all","./promise/race","./promise/resolve","./promise/reject","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __exports__) { - "use strict"; - var config = __dependency1__.config; - var EventTarget = __dependency2__["default"]; - var instrument = __dependency3__["default"]; - var objectOrFunction = __dependency4__.objectOrFunction; - var isFunction = __dependency4__.isFunction; - var now = __dependency4__.now; - var cast = __dependency5__["default"]; - var all = __dependency6__["default"]; - var race = __dependency7__["default"]; - var Resolve = __dependency8__["default"]; - var Reject = __dependency9__["default"]; - - var guidKey = 'rsvp_' + now() + '-'; - var counter = 0; - - function noop() {} - - __exports__["default"] = Promise; - - - /** - - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise’s eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - - Basic Usage: - ------------ - - ```js - var promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - var xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error("getJSON: `" + url + "` failed with status: [" + this.status + "]"); - } - } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} - @param {String} label optional string for labeling the promise. - Useful for tooling. - @constructor - */ - function Promise(resolver, label) { - if (!isFunction(resolver)) { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); - } - - if (!(this instanceof Promise)) { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); - } - - this._id = counter++; - this._label = label; - this._subscribers = []; - - if (config.instrument) { - instrument('created', this); - } - - if (noop !== resolver) { - invokeResolver(resolver, this); - } - } - - function invokeResolver(resolver, promise) { - function resolvePromise(value) { - resolve(promise, value); - } - - function rejectPromise(reason) { - reject(promise, reason); - } - - try { - resolver(resolvePromise, rejectPromise); - } catch(e) { - rejectPromise(e); - } - } - - Promise.cast = cast; - Promise.all = all; - Promise.race = race; - Promise.resolve = Resolve; - Promise.reject = Reject; - - var PENDING = void 0; - var SEALED = 0; - var FULFILLED = 1; - var REJECTED = 2; - - function subscribe(parent, child, onFulfillment, onRejection) { - var subscribers = parent._subscribers; - var length = subscribers.length; - - subscribers[length] = child; - subscribers[length + FULFILLED] = onFulfillment; - subscribers[length + REJECTED] = onRejection; - } - - function publish(promise, settled) { - var child, callback, subscribers = promise._subscribers, detail = promise._detail; - - if (config.instrument) { - instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise); - } - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - invokeCallback(settled, child, callback, detail); - } - - promise._subscribers = null; - } - - Promise.prototype = { - /** - @property constructor - */ - constructor: Promise, - - _id: undefined, - _guidKey: guidKey, - _label: undefined, - - _state: undefined, - _detail: undefined, - _subscribers: undefined, - - _onerror: function (reason) { - config.trigger('error', reason); - }, - - /** - - A promise represents the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, "downstream" - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return "default name"; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `"default name"` - }); - - findUser().then(function (user) { - throw "Found user, but still unhappy"; - }, function (reason) { - throw "`findUser` rejected and we're unhappy"; - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be "Found user, but still unhappy". - // If `findUser` rejected, `reason` will be "`findUser` rejected and we're unhappy". - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException("Upstream error"); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - var result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findResult().then(function(result){ - - }, function(reason){ - - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - var author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javacsript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong; - }); - ``` - - @method then - @param {Function} onFulfillment - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - then: function(onFulfillment, onRejection, label) { - var promise = this; - this._onerror = null; - - var thenPromise = new this.constructor(noop, label); - - if (this._state) { - var callbacks = arguments; - config.async(function invokePromiseCallback() { - invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail); - }); - } else { - subscribe(this, thenPromise, onFulfillment, onRejection); - } - - if (config.instrument) { - instrument('chained', promise, thenPromise); - } - - return thenPromise; - }, - - /** - `catch` is simply sugar for `then(null, onRejection)` which makes it the same - as the catch block, of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error("couldn't find that author"); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong; - }); - ``` - - @method catch - @param {Function} onRejection - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'catch': function(onRejection, label) { - return this.then(null, onRejection, label); - }, - - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't effect the return value - } - - findAuthor().finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} - */ - 'finally': function(callback, label) { - var constructor = this.constructor; - - return this.then(function(value) { - return constructor.cast(callback()).then(function(){ - return value; - }); - }, function(reason) { - return constructor.cast(callback()).then(function(){ - throw reason; - }); - }, label); - } - }; - - function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value, error, succeeded, failed; - - if (hasCallback) { - try { - value = callback(detail); - succeeded = true; - } catch(e) { - failed = true; - error = e; - } - } else { - value = detail; - succeeded = true; - } - - if (handleThenable(promise, value)) { - return; - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - resolve(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } - } - - function handleThenable(promise, value) { - var then = null, - resolved; - - try { - if (promise === value) { - throw new TypeError("A promises callback cannot return that same promise."); - } - - if (objectOrFunction(value)) { - then = value.then; - - if (isFunction(then)) { - then.call(value, function(val) { - if (resolved) { return true; } - resolved = true; - - if (value !== val) { - resolve(promise, val); - } else { - fulfill(promise, val); - } - }, function(val) { - if (resolved) { return true; } - resolved = true; - - reject(promise, val); - }, 'derived from: ' + (promise._label || ' unknown promise')); - - return true; - } - } - } catch (error) { - if (resolved) { return true; } - reject(promise, error); - return true; - } - - return false; - } - - function resolve(promise, value) { - if (promise === value) { - fulfill(promise, value); - } else if (!handleThenable(promise, value)) { - fulfill(promise, value); - } - } - - function fulfill(promise, value) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = value; - - config.async(publishFulfillment, promise); - } - - function reject(promise, reason) { - if (promise._state !== PENDING) { return; } - promise._state = SEALED; - promise._detail = reason; - - config.async(publishRejection, promise); - } - - function publishFulfillment(promise) { - publish(promise, promise._state = FULFILLED); - } - - function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._detail); - } - - publish(promise, promise._state = REJECTED); - } - }); -define("rsvp/promise/all", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var isArray = __dependency1__.isArray; - var isNonThenable = __dependency1__.isNonThenable; - - /** - - `RSVP.Promise.all` returns a new promise which is fulfilled with an array of - fulfillment values for the passed promises, or rejects with the reason of the - first passed promise that rejects. It casts all elements of the passed iterable - to promises as it runs this algorithm. - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.resolve(2); - var promise3 = RSVP.resolve(3); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `RSVP.all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - var promise1 = RSVP.resolve(1); - var promise2 = RSVP.reject(new Error("2")); - var promise3 = RSVP.reject(new Error("3")); - var promises = [ promise1, promise2, promise3 ]; - - RSVP.Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @for RSVP.Promise - @param {Array} promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - */ - __exports__["default"] = function all(entries, label) { - - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to all.'); - } - - var remaining = entries.length; - var results = new Array(remaining); - var entry, pending = true; - - if (remaining === 0) { - resolve(results); - return; - } - - function fulfillmentAt(index) { - return function(value) { - results[index] = value; - if (--remaining === 0) { - resolve(results); - } - }; - } - - function onRejection(reason) { - remaining = 0; - reject(reason); - } - - for (var index = 0; index < entries.length; index++) { - entry = entries[index]; - if (isNonThenable(entry)) { - results[index] = entry; - if (--remaining === 0) { - resolve(results); - } - } else { - Constructor.cast(entry).then(fulfillmentAt(index), onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/cast", - ["exports"], - function(__exports__) { - "use strict"; - /** - - `RSVP.Promise.cast` cast coerces its argument to a promise, or returns the - argument if it is already a promise which shares a constructor with the caster; - - Example: - - ```javascript - var promise = RSVP.Promise.resolve(1); - var casted = RSVP.Promise.cast(promise); - - console.log(promise === casted); // true - ``` - - In the case of a promise whose constructor does not match, it is assimilated. - The resulting promise will fulfill or reject based on the outcome of the - promise being casted. - - In the case of a non-promise, a promise which will fulfill with that value is - returned. - - Example: - - ```javascript - var value = 1; // could be a number, boolean, string, undefined... - var casted = RSVP.Promise.cast(value); - - console.log(value === casted); // false - console.log(casted instanceof RSVP.Promise) // true - - casted.then(function(val) { - val === value // => true - }); - ``` - - `RSVP.Promise.cast` is similar to `RSVP.Promise.resolve`, but `RSVP.Promise.cast` differs in the - following ways: - - * `RSVP.Promise.cast` serves as a memory-efficient way of getting a promise, when you - have something that could either be a promise or a value. RSVP.resolve - will have the same effect but will create a new promise wrapper if the - argument is a promise. - * `RSVP.Promise.cast` is a way of casting incoming thenables or promise subclasses to - promises of the exact class specified, so that the resulting object's `then` is - ensured to have the behavior of the constructor you are calling cast on (i.e., RSVP.Promise). - - @method cast - @for RSVP.Promise - @param {Object} object to be casted - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise - */ - - __exports__["default"] = function cast(object, label) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - return new Constructor(function(resolve) { - resolve(object); - }, label); - }; - }); -define("rsvp/promise/race", - ["../utils","exports"], - function(__dependency1__, __exports__) { - "use strict"; - /* global toString */ - - var isArray = __dependency1__.isArray; - var isFunction = __dependency1__.isFunction; - var isNonThenable = __dependency1__.isNonThenable; - - /** - `RSVP.Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 2"); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // result === "promise 2" because it was resolved before promise1 - // was resolved. - }); - ``` - - `RSVP.Promise.race` is deterministic in that only the state of the first - completed promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first completed promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - var promise1 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - resolve("promise 1"); - }, 200); - }); - - var promise2 = new RSVP.Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error("promise 2")); - }, 100); - }); - - RSVP.Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs because there are rejected promises! - }, function(reason){ - // reason.message === "promise2" because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - @method race - @for RSVP.Promise - @param {Array} promises array of promises to observe - @param {String} label optional string for describing the promise returned. - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. - */ - __exports__["default"] = function race(entries, label) { - /*jshint validthis:true */ - var Constructor = this, entry; - - return new Constructor(function(resolve, reject) { - if (!isArray(entries)) { - throw new TypeError('You must pass an array to race.'); - } - - var pending = true; - - function onFulfillment(value) { if (pending) { pending = false; resolve(value); } } - function onRejection(reason) { if (pending) { pending = false; reject(reason); } } - - for (var i = 0; i < entries.length; i++) { - entry = entries[i]; - if (isNonThenable(entry)) { - pending = false; - resolve(entry); - return; - } else { - Constructor.cast(entry).then(onFulfillment, onRejection); - } - } - }, label); - }; - }); -define("rsvp/promise/reject", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. - It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @for RSVP.Promise - @param {Any} reason value that the returned promise will be rejected with. - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. - */ - __exports__["default"] = function reject(reason, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function (resolve, reject) { - reject(reason); - }, label); - }; - }); -define("rsvp/promise/resolve", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.Promise.resolve` returns a promise that will become fulfilled with the passed - `value`. It is essentially shorthand for the following: - - ```javascript - var promise = new RSVP.Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - var promise = RSVP.Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @for RSVP.Promise - @param {Any} value value that the returned promise will be resolved with - @param {String} label optional string for identifying the returned promise. - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` - */ - __exports__["default"] = function resolve(value, label) { - /*jshint validthis:true */ - var Constructor = this; - - return new Constructor(function(resolve, reject) { - resolve(value); - }, label); - }; - }); -define("rsvp/race", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function race(array, label) { - return Promise.race(array, label); - }; - }); -define("rsvp/reject", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function reject(reason, label) { - return Promise.reject(reason, label); - }; - }); -define("rsvp/resolve", - ["./promise","exports"], - function(__dependency1__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - - __exports__["default"] = function resolve(value, label) { - return Promise.resolve(value, label); - }; - }); -define("rsvp/rethrow", - ["exports"], - function(__exports__) { - "use strict"; - /** - `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event - loop in order to aid debugging. - - Promises A+ specifies that any exceptions that occur with a promise must be - caught by the promises implementation and bubbled to the last handler. For - this reason, it is recommended that you always specify a second rejection - handler function to `then`. However, `RSVP.rethrow` will throw the exception - outside of the promise, so it bubbles up to your console if in the browser, - or domain/cause uncaught exception in Node. `rethrow` will throw the error - again so the error can be handled by the promise. - - ```javascript - function throws(){ - throw new Error('Whoops!'); - } - - var promise = new RSVP.Promise(function(resolve, reject){ - throws(); - }); - - promise.catch(RSVP.rethrow).then(function(){ - // Code here doesn't run because the promise became rejected due to an - // error! - }, function (err){ - // handle the error here - }); - ``` - - The 'Whoops' error will be thrown on the next turn of the event loop - and you can watch for it in your console. You can also handle it using a - rejection handler given to `.then` or `.catch` on the returned promise. - - @method rethrow - @for RSVP - @param {Error} reason reason the promise became rejected. - @throws Error - */ - __exports__["default"] = function rethrow(reason) { - setTimeout(function() { - throw reason; - }); - throw reason; - }; - }); -define("rsvp/utils", - ["exports"], - function(__exports__) { - "use strict"; - function objectOrFunction(x) { - return typeof x === "function" || (typeof x === "object" && x !== null); - } - - __exports__.objectOrFunction = objectOrFunction;function isFunction(x) { - return typeof x === "function"; - } - - __exports__.isFunction = isFunction;function isNonThenable(x) { - return !objectOrFunction(x); - } - - __exports__.isNonThenable = isNonThenable;function isArray(x) { - return Object.prototype.toString.call(x) === "[object Array]"; - } - - __exports__.isArray = isArray;// Date.now is not available in browsers < IE9 - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility - var now = Date.now || function() { return new Date().getTime(); }; - __exports__.now = now; - var keysOf = Object.keys || function(object) { - var result = []; - - for (var prop in object) { - result.push(prop); - } - - return result; - }; - __exports__.keysOf = keysOf; - }); -define("rsvp", - ["./rsvp/promise","./rsvp/events","./rsvp/node","./rsvp/all","./rsvp/all_settled","./rsvp/race","./rsvp/hash","./rsvp/rethrow","./rsvp/defer","./rsvp/config","./rsvp/map","./rsvp/resolve","./rsvp/reject","./rsvp/asap","./rsvp/filter","exports"], - function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __exports__) { - "use strict"; - var Promise = __dependency1__["default"]; - var EventTarget = __dependency2__["default"]; - var denodeify = __dependency3__["default"]; - var all = __dependency4__["default"]; - var allSettled = __dependency5__["default"]; - var race = __dependency6__["default"]; - var hash = __dependency7__["default"]; - var rethrow = __dependency8__["default"]; - var defer = __dependency9__["default"]; - var config = __dependency10__.config; - var configure = __dependency10__.configure; - var map = __dependency11__["default"]; - var resolve = __dependency12__["default"]; - var reject = __dependency13__["default"]; - var asap = __dependency14__["default"]; - var filter = __dependency15__["default"]; - - config.async = asap; // default async is asap; - - function async(callback, arg) { - config.async(callback, arg); - } - - function on() { - config.on.apply(config, arguments); - } - - function off() { - config.off.apply(config, arguments); - } - - // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__` - if (typeof window !== 'undefined' && typeof window.__PROMISE_INSTRUMENTATION__ === 'object') { - var callbacks = window.__PROMISE_INSTRUMENTATION__; - configure('instrument', true); - for (var eventName in callbacks) { - if (callbacks.hasOwnProperty(eventName)) { - on(eventName, callbacks[eventName]); - } - } - } - - __exports__.Promise = Promise; - __exports__.EventTarget = EventTarget; - __exports__.all = all; - __exports__.allSettled = allSettled; - __exports__.race = race; - __exports__.hash = hash; - __exports__.rethrow = rethrow; - __exports__.defer = defer; - __exports__.denodeify = denodeify; - __exports__.configure = configure; - __exports__.on = on; - __exports__.off = off; - __exports__.resolve = resolve; - __exports__.reject = reject; - __exports__.async = async; - __exports__.map = map; - __exports__.filter = filter; - }); -global.RSVP = requireModule('rsvp'); -}(window)); -'use strict'; - -var EPUBJS = EPUBJS || {}; -EPUBJS.VERSION = "0.2.3"; - -EPUBJS.plugins = EPUBJS.plugins || {}; - -EPUBJS.filePath = EPUBJS.filePath || "/epubjs/"; - -EPUBJS.Render = {}; - -(function(root) { - - var previousEpub = root.ePub || {}; - - var ePub = root.ePub = function() { - var bookPath, options; - - //-- var book = ePub("path/to/book.epub", { restore: true }) - if(typeof(arguments[0]) != 'undefined' && - typeof arguments[0] === 'string') { - - bookPath = arguments[0]; - - if( arguments[1] && typeof arguments[1] === 'object' ) { - options = arguments[1]; - options.bookPath = bookPath; - } else { - options = { 'bookPath' : bookPath }; - } - - } - - /* - * var book = ePub({ bookPath: "path/to/book.epub", restore: true }); - * - * - OR - - * - * var book = ePub({ restore: true }); - * book.open("path/to/book.epub"); - */ - - if( arguments[0] && typeof arguments[0] === 'object' ) { - options = arguments[0]; - } - - - return new EPUBJS.Book(options); - }; - - _.extend(ePub, { - noConflict : function() { - root.ePub = previousEpub; - return this; - } - }); - - //exports to multiple environments - if (typeof define === 'function' && define.amd) - //AMD - define(function(){ return ePub; }); - else if (typeof module != "undefined" && module.exports) - //Node - module.exports = ePub; - -})(window); - -EPUBJS.Book = function(options){ - - var book = this; - - this.settings = _.defaults(options || {}, { - bookPath : null, - bookKey : null, - packageUrl : null, - storage: false, //-- true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem' - fromStorage : false, - saved : false, - online : true, - contained : false, - width : null, - height: null, - layoutOveride : null, // Default: { spread: 'reflowable', layout: 'auto', orientation: 'auto'} - orientation : null, - minSpreadWidth: 800, //-- overridden by spread: none (never) / both (always) - gap: "auto", //-- "auto" or int - version: 1, - restore: false, - reload : false, - goto : false, - styles : {}, - headTags : {}, - withCredentials: false, - render_method: "Iframe" - }); - - this.settings.EPUBJSVERSION = EPUBJS.VERSION; - - this.spinePos = 0; - this.stored = false; - - //-- All Book events for listening - /* - book:ready - book:stored - book:online - book:offline - book:pageChanged - book:loadFailed - book:loadChapterFailed - */ - - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - // EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - // this.getHooks("beforeChapterDisplay"); - - this.online = this.settings.online || navigator.onLine; - this.networkListeners(); - - this.store = false; //-- False if not using storage; - - //-- Determine storage method - //-- Override options: none | ram | websqldatabase | indexeddb | filesystem - - if(this.settings.storage !== false){ - this.storage = new fileStorage.storage(this.settings.storage); - } - - this.ready = { - manifest: new RSVP.defer(), - spine: new RSVP.defer(), - metadata: new RSVP.defer(), - cover: new RSVP.defer(), - toc: new RSVP.defer(), - pageList: new RSVP.defer() - }; - - this.readyPromises = [ - this.ready.manifest.promise, - this.ready.spine.promise, - this.ready.metadata.promise, - this.ready.cover.promise, - this.ready.toc.promise - ]; - - this.pageList = []; - this.pagination = new EPUBJS.Pagination(); - this.pageListReady = this.ready.pageList.promise; - - this.ready.all = RSVP.all(this.readyPromises); - - this.ready.all.then(this._ready.bind(this)); - - // Queue for methods used before rendering - this.isRendered = false; - this._q = EPUBJS.core.queue(this); - // Queue for rendering - this._rendering = false; - this._displayQ = EPUBJS.core.queue(this); - // Queue for going to another location - this._moving = false; - this._gotoQ = EPUBJS.core.queue(this); - - /** - * Creates a new renderer. - * The renderer will handle displaying the content using the method provided in the settings - */ - this.renderer = new EPUBJS.Renderer(this.settings.render_method); - //-- Set the width at which to switch from spreads to single pages - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.setGap(this.settings.gap); - //-- Pass through the renderer events - this.listenToRenderer(this.renderer); - - this.defer_opened = new RSVP.defer(); - this.opened = this.defer_opened.promise; - // BookUrl is optional, but if present start loading process - if(typeof this.settings.bookPath === 'string') { - this.open(this.settings.bookPath, this.settings.reload); - } - - window.addEventListener("beforeunload", this.unload.bind(this), false); - - //-- Listen for these promises: - //-- book.opened.then() - //-- book.rendered.then() -}; - -//-- Check bookUrl and start parsing book Assets or load them from storage -EPUBJS.Book.prototype.open = function(bookPath, forceReload){ - var book = this, - epubpackage, - opened = new RSVP.defer(); - - this.settings.bookPath = bookPath; - - //-- Get a absolute URL from the book path - this.bookUrl = this.urlFrom(bookPath); - - if(this.settings.contained || this.isContained(bookPath)){ - - this.settings.contained = this.contained = true; - - this.bookUrl = ''; - - epubpackage = this.unarchive(bookPath). - then(function(){ - return book.loadPackage(); - }); - - } else { - epubpackage = this.loadPackage(); - } - - if(this.settings.restore && !forceReload && localStorage){ - //-- Will load previous package json, or re-unpack if error - epubpackage.then(function(packageXml) { - var identifier = book.packageIdentifier(packageXml); - var restored = book.restore(identifier); - - if(!restored) { - book.unpack(packageXml); - } - opened.resolve(); - book.defer_opened.resolve(); - }); - - }else{ - - //-- Get package information from epub opf - epubpackage.then(function(packageXml) { - book.unpack(packageXml); - opened.resolve(); - book.defer_opened.resolve(); - }); - } - - //-- If there is network connection, store the books contents - if(this.online && this.settings.storage && !this.settings.contained){ - if(!this.settings.stored) opened.then(book.storeOffline()); - } - - this._registerReplacements(this.renderer); - - return opened.promise; - -}; - -EPUBJS.Book.prototype.loadPackage = function(_containerPath){ - var book = this, - parse = new EPUBJS.Parser(), - containerPath = _containerPath || "META-INF/container.xml", - containerXml, - packageXml; - - if(!this.settings.packageUrl) { //-- provide the packageUrl to skip this step - packageXml = book.loadXml(book.bookUrl + containerPath). - then(function(containerXml){ - return parse.container(containerXml); // Container has path to content - }). - then(function(paths){ - book.settings.contentsPath = book.bookUrl + paths.basePath; - book.settings.packageUrl = book.bookUrl + paths.packagePath; - book.settings.encoding = paths.encoding; - return book.loadXml(book.settings.packageUrl); // Containes manifest, spine and metadata - }); - } else { - packageXml = book.loadXml(book.settings.packageUrl); - } - - packageXml.catch(function(error) { - // handle errors in either of the two requests - console.error("Could not load book at: "+ containerPath); - book.trigger("book:loadFailed", containerPath); - }); - return packageXml; -}; - -EPUBJS.Book.prototype.packageIdentifier = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - return parse.identifier(packageXml); -}; - -EPUBJS.Book.prototype.unpack = function(packageXml){ - var book = this, - parse = new EPUBJS.Parser(); - - book.contents = parse.packageContents(packageXml, book.settings.contentsPath); // Extract info from contents - - book.manifest = book.contents.manifest; - book.spine = book.contents.spine; - book.spineIndexByURL = book.contents.spineIndexByURL; - book.metadata = book.contents.metadata; - if(!book.settings.bookKey) { - book.settings.bookKey = book.generateBookKey(book.metadata.identifier); - } - - //-- Set Globbal Layout setting based on metadata - book.globalLayoutProperties = book.parseLayoutProperties(book.metadata); - - if(book.contents.coverPath) { - book.cover = book.contents.cover = book.settings.contentsPath + book.contents.coverPath; - } - - book.spineNodeIndex = book.contents.spineNodeIndex; - - book.ready.manifest.resolve(book.contents.manifest); - book.ready.spine.resolve(book.contents.spine); - book.ready.metadata.resolve(book.contents.metadata); - book.ready.cover.resolve(book.contents.cover); - - - //-- Load the TOC, optional; either the EPUB3 XHTML Navigation file or the EPUB2 NCX file - if(book.contents.navPath) { - book.settings.navUrl = book.settings.contentsPath + book.contents.navPath; - - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.nav(navHtml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - // Load the optional pageList - book.loadXml(book.settings.navUrl). - then(function(navHtml){ - return parse.pageList(navHtml, book.spineIndexByURL, book.spine); - }).then(function(pageList){ - var epubcfi = new EPUBJS.EpubCFI(); - var wait = 0; // need to generate a cfi - - // No pageList found - if(pageList.length === 0) { - return; - } - - book.pageList = book.contents.pageList = pageList; - - // Replace HREFs with CFI - book.pageList.forEach(function(pg){ - if(!pg.cfi) { - wait += 1; - epubcfi.generateCfiFromHref(pg.href, book).then(function(cfi){ - pg.cfi = cfi; - pg.packageUrl = book.settings.packageUrl; - - wait -= 1; - if(wait === 0) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - }); - } - }); - - if(!wait) { - book.pagination.process(book.pageList); - book.ready.pageList.resolve(book.pageList); - } - - }, function(error) { - book.ready.pageList.resolve([]); - }); - } else if(book.contents.tocPath) { - book.settings.tocUrl = book.settings.contentsPath + book.contents.tocPath; - - book.loadXml(book.settings.tocUrl). - then(function(tocXml){ - return parse.toc(tocXml, book.spineIndexByURL, book.spine); // Grab Table of Contents - }).then(function(toc){ - book.toc = book.contents.toc = toc; - book.ready.toc.resolve(book.contents.toc); - }, function(error) { - book.ready.toc.resolve(false); - }); - - } else { - book.ready.toc.resolve(false); - } - -}; - -EPUBJS.Book.prototype.createHiddenRender = function(renderer, _width, _height) { - var box = this.element.getBoundingClientRect(); - var width = _width || this.settings.width || box.width; - var height = _height || this.settings.height || box.height; - var hiddenContainer; - var hiddenEl; - renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - renderer.setGap(this.settings.gap); - - this._registerReplacements(renderer); - if(this.settings.forceSingle) { - renderer.forceSingle(true); - } - - hiddenContainer = document.createElement("div"); - hiddenContainer.style.visibility = "hidden"; - hiddenContainer.style.overflow = "hidden"; - hiddenContainer.style.width = "0"; - hiddenContainer.style.height = "0"; - this.element.appendChild(hiddenContainer); - - hiddenEl = document.createElement("div"); - hiddenEl.style.visibility = "hidden"; - hiddenEl.style.overflow = "hidden"; - hiddenEl.style.width = width + "px";//"0"; - hiddenEl.style.height = height +"px"; //"0"; - hiddenContainer.appendChild(hiddenEl); - - renderer.initialize(hiddenEl); - return hiddenContainer; -}; - -// Generates the pageList array by loading every chapter and paging through them -EPUBJS.Book.prototype.generatePageList = function(width, height){ - var pageList = []; - var pager = new EPUBJS.Renderer(this.settings.render_method, false); //hidden - var hiddenContainer = this.createHiddenRender(pager, width, height); - var deferred = new RSVP.defer(); - var spinePos = -1; - var spineLength = this.spine.length; - var totalPages = 0; - var currentPage = 0; - var nextChapter = function(deferred){ - var chapter; - var next = spinePos + 1; - var done = deferred || new RSVP.defer(); - var loaded; - if(next >= spineLength) { - done.resolve(); - } else { - spinePos = next; - chapter = new EPUBJS.Chapter(this.spine[spinePos], this.store); - pager.displayChapter(chapter, this.globalLayoutProperties).then(function(chap){ - pager.pageMap.forEach(function(item){ - currentPage += 1; - pageList.push({ - "cfi" : item.start, - "page" : currentPage - }); - - }); - - if(pager.pageMap.length % 2 > 0 && - pager.spreads) { - currentPage += 1; // Handle Spreads - pageList.push({ - "cfi" : pager.pageMap[pager.pageMap.length - 1].end, - "page" : currentPage - }); - } - - // Load up the next chapter - setTimeout(function(){ - nextChapter(done); - }, 1); - }); - } - return done.promise; - }.bind(this); - - var finished = nextChapter().then(function(){ - pager.remove(); - this.element.removeChild(hiddenContainer); - deferred.resolve(pageList); - }.bind(this)); - - return deferred.promise; -}; - -// Render out entire book and generate the pagination -// Width and Height are optional and will default to the current dimensions -EPUBJS.Book.prototype.generatePagination = function(width, height) { - var book = this; - var defered = new RSVP.defer(); - - this.ready.spine.promise.then(function(){ - book.generatePageList(width, height).then(function(pageList){ - book.pageList = book.contents.pageList = pageList; - book.pagination.process(pageList); - book.ready.pageList.resolve(book.pageList); - defered.resolve(book.pageList); - }); - }); - - return defered.promise; -}; - -// Process the pagination from a JSON array containing the pagelist -EPUBJS.Book.prototype.loadPagination = function(pagelistJSON) { - var pageList = JSON.parse(pagelistJSON); - - if(pageList && pageList.length) { - this.pageList = pageList; - this.pagination.process(this.pageList); - this.ready.pageList.resolve(this.pageList); - } - return this.pageList; -}; - -EPUBJS.Book.prototype.getPageList = function() { - return this.ready.pageList.promise; -}; - -EPUBJS.Book.prototype.getMetadata = function() { - return this.ready.metadata.promise; -}; - -EPUBJS.Book.prototype.getToc = function() { - return this.ready.toc.promise; -}; - -/* Private Helpers */ - -//-- Listeners for browser events -EPUBJS.Book.prototype.networkListeners = function(){ - var book = this; - - window.addEventListener("offline", function(e) { - book.online = false; - book.trigger("book:offline"); - }, false); - - window.addEventListener("online", function(e) { - book.online = true; - book.trigger("book:online"); - }, false); - -}; - -// Listen to all events the renderer triggers and pass them as book events -EPUBJS.Book.prototype.listenToRenderer = function(renderer){ - var book = this; - renderer.Events.forEach(function(eventName){ - renderer.on(eventName, function(e){ - book.trigger(eventName, e); - }); - }); - - renderer.on("renderer:visibleRangeChanged", function(range) { - var startPage, endPage, percent; - var pageRange = []; - - if(this.pageList.length > 0) { - startPage = this.pagination.pageFromCfi(range.start); - percent = this.pagination.percentageFromPage(startPage); - pageRange.push(startPage); - - if(range.end) { - endPage = this.pagination.pageFromCfi(range.end); - //if(startPage != endPage) { - pageRange.push(endPage); - //} - } - this.trigger("book:pageChanged", { - "anchorPage": startPage, - "percentage": percent, - "pageRange" : pageRange - }); - - // TODO: Add event for first and last page. - // (though last is going to be hard, since it could be several reflowed pages long) - } - }.bind(this)); - - renderer.on("render:loaded", this.loadChange.bind(this)); -}; - -// Listens for load events from the Renderer and checks against the current chapter -// Prevents the Render from loading a different chapter when back button is pressed -EPUBJS.Book.prototype.loadChange = function(url){ - var uri = EPUBJS.core.uri(url); - var chapter; - - if(this.currentChapter) { - chapter = EPUBJS.core.uri(this.currentChapter.absolute); - } - - if(!this._rendering && this.currentChapter && uri.path != chapter.path){ - console.warn("Miss Match", uri.path, this.currentChapter.absolute); - this.goto(uri.filename); - } -}; - -EPUBJS.Book.prototype.unlistenToRenderer = function(renderer){ - renderer.Events.forEach(function(eventName){ - renderer.off(eventName); - } ); -}; - -//-- Choose between a request from store or a request from network -EPUBJS.Book.prototype.loadXml = function(url){ - if(this.settings.fromStorage) { - return this.storage.getXml(url, this.settings.encoding); - } else if(this.settings.contained) { - return this.zip.getXml(url, this.settings.encoding); - }else{ - return EPUBJS.core.request(url, 'xml', this.settings.withCredentials); - } -}; - -//-- Turns a url into a absolute url -EPUBJS.Book.prototype.urlFrom = function(bookPath){ - var uri = EPUBJS.core.uri(bookPath), - absolute = uri.protocol, - fromRoot = uri.path[0] == "/", - location = window.location, - //-- Get URL orgin, try for native or combine - origin = location.origin || location.protocol + "//" + location.host, - baseTag = document.getElementsByTagName('base'), - base; - - - //-- Check is Base tag is set - - if(baseTag.length) { - base = baseTag[0].href; - } - - //-- 1. Check if url is absolute - if(uri.protocol){ - return uri.origin + uri.path; - } - - //-- 2. Check if url starts with /, add base url - if(!absolute && fromRoot){ - return (base || origin) + uri.path; - } - - //-- 3. Or find full path to url and add that - if(!absolute && !fromRoot){ - return EPUBJS.core.resolveUrl(base || location.pathname, uri.path); - } - -}; - - -EPUBJS.Book.prototype.unarchive = function(bookPath){ - var book = this, - unarchived; - - //-- Must use storage - // if(this.settings.storage == false ){ - // this.settings.storage = true; - // this.storage = new fileStorage.storage(); - // } - - this.zip = new EPUBJS.Unarchiver(); - this.store = this.zip; // Use zip storaged in ram - return this.zip.openZip(bookPath); -}; - -//-- Checks if url has a .epub or .zip extension -EPUBJS.Book.prototype.isContained = function(bookUrl){ - var uri = EPUBJS.core.uri(bookUrl); - - if(uri.extension && (uri.extension == "epub" || uri.extension == "zip")){ - return true; - } - - return false; -}; - -//-- Checks if the book can be retrieved from localStorage -EPUBJS.Book.prototype.isSaved = function(bookKey) { - var storedSettings; - - if(!localStorage) { - return false; - } - - storedSettings = localStorage.getItem(bookKey); - - if( !localStorage || - storedSettings === null) { - return false; - } else { - return true; - } -}; - -// Generates the Book Key using the identifer in the manifest or other string provided -EPUBJS.Book.prototype.generateBookKey = function(identifier){ - return "epubjs:" + EPUBJS.VERSION + ":" + window.location.host + ":" + identifier; -}; - -EPUBJS.Book.prototype.saveContents = function(){ - if(!localStorage) { - return false; - } - localStorage.setItem(this.settings.bookKey, JSON.stringify(this.contents)); -}; - -EPUBJS.Book.prototype.removeSavedContents = function() { - if(!localStorage) { - return false; - } - localStorage.removeItem(this.settings.bookKey); -}; - - - -//-- Takes a string or a element -EPUBJS.Book.prototype.renderTo = function(elem){ - var book = this, - rendered; - - if(_.isElement(elem)) { - this.element = elem; - } else if (typeof elem == "string") { - this.element = EPUBJS.core.getEl(elem); - } else { - console.error("Not an Element"); - return; - } - - rendered = this.opened. - then(function(){ - // book.render = new EPUBJS.Renderer[this.settings.renderer](book); - book.renderer.initialize(book.element, book.settings.width, book.settings.height); - book._rendered(); - return book.startDisplay(); - }); - - // rendered.then(null, function(error) { console.error(error); }); - - return rendered; -}; - -EPUBJS.Book.prototype.startDisplay = function(){ - var display; - - if(this.settings.goto) { - display = this.goto(this.settings.goto); - }else if(this.settings.previousLocationCfi) { - display = this.gotoCfi(this.settings.previousLocationCfi); - }else{ - display = this.displayChapter(this.spinePos); - } - - return display; -}; - -EPUBJS.Book.prototype.restore = function(identifier){ - - var book = this, - fetch = ['manifest', 'spine', 'metadata', 'cover', 'toc', 'spineNodeIndex', 'spineIndexByURL', 'globalLayoutProperties'], - reject = false, - bookKey = this.generateBookKey(identifier), - fromStore = localStorage.getItem(bookKey), - len = fetch.length, - i; - - if(this.settings.clearSaved) reject = true; - - if(!reject && fromStore != 'undefined' && fromStore !== null){ - book.contents = JSON.parse(fromStore); - - for(i = 0; i < len; i++) { - var item = fetch[i]; - - if(!book.contents[item]) { - reject = true; - break; - } - book[item] = book.contents[item]; - } - } - - if(reject || !fromStore || !this.contents || !this.settings.contentsPath){ - return false; - }else{ - this.settings.bookKey = bookKey; - this.ready.manifest.resolve(this.manifest); - this.ready.spine.resolve(this.spine); - this.ready.metadata.resolve(this.metadata); - this.ready.cover.resolve(this.cover); - this.ready.toc.resolve(this.toc); - return true; - } - -}; - -EPUBJS.Book.prototype.displayChapter = function(chap, end, deferred){ - var book = this, - render, - cfi, - pos, - store, - defer = deferred || new RSVP.defer(); - - var chapter; - - if(!this.isRendered) { - this._q.enqueue("displayChapter", arguments); - // Reject for now. TODO: pass promise to queue - defer.reject({ - message : "Rendering", - stack : new Error().stack - }); - return defer.promise; - } - - - if(this._rendering || this._rendering) { - // Pass along the current defer - this._displayQ.enqueue("displayChapter", [chap, end, defer]); - return defer.promise; - } - - if(_.isNumber(chap)){ - pos = chap; - }else{ - cfi = new EPUBJS.EpubCFI(chap); - pos = cfi.spinePos; - } - - if(pos < 0 || pos >= this.spine.length){ - console.warn("Not A Valid Location"); - pos = 0; - end = false; - cfi = false; - } - - //-- Create a new chapter - chapter = new EPUBJS.Chapter(this.spine[pos], this.store); - - this._rendering = true; - - render = book.renderer.displayChapter(chapter, this.globalLayoutProperties); - if(cfi) { - book.renderer.gotoCfi(cfi); - } else if(end) { - book.renderer.lastPage(); - } - //-- Success, Clear render queue - render.then(function(rendered){ - // var inwait; - //-- Set the book's spine position - book.spinePos = pos; - - defer.resolve(book.renderer); - - if(!book.settings.fromStorage && - !book.settings.contained) { - book.preloadNextChapter(); - } - - book.currentChapter = chapter; - book._rendering = false; - book._displayQ.dequeue(); - if(book._displayQ.length() === 0) { - book._gotoQ.dequeue(); - } - - }, function(error) { - // handle errors in either of the two requests - console.error("Could not load Chapter: "+ chapter.absolute); - book.trigger("book:chapterLoadFailed", chapter.absolute); - book._rendering = false; - defer.reject(error); - }); - - return defer.promise; -}; - -EPUBJS.Book.prototype.nextPage = function(){ - var next; - - if(!this.isRendered) return this._q.enqueue("nextPage", arguments); - - next = this.renderer.nextPage(); - - if(!next){ - return this.nextChapter(); - } -}; - -EPUBJS.Book.prototype.prevPage = function() { - var prev; - - if(!this.isRendered) return this._q.enqueue("prevPage", arguments); - - prev = this.renderer.prevPage(); - - if(!prev){ - return this.prevChapter(); - } -}; - -EPUBJS.Book.prototype.nextChapter = function() { - var next; - if (this.spinePos < this.spine.length - 1) { - next = this.spinePos + 1; - // Skip non linear chapters - while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') { - next++; - } - if (next < this.spine.length) { - return this.displayChapter(next); - } else { - this.trigger("book:atEnd"); - } - - } else { - this.trigger("book:atEnd"); - } -}; - -EPUBJS.Book.prototype.prevChapter = function() { - var prev; - if (this.spinePos > 0) { - prev = this.spinePos - 1; - while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') { - prev--; - } - if (prev >= 0) { - return this.displayChapter(prev, true); - } else { - this.trigger("book:atStart"); - } - - } else { - this.trigger("book:atStart"); - } -}; - -EPUBJS.Book.prototype.getCurrentLocationCfi = function() { - if(!this.isRendered) return false; - return this.renderer.currentLocationCfi; -}; - -EPUBJS.Book.prototype.goto = function(target){ - - if(target.indexOf("epubcfi(") === 0) { - return this.gotoCfi(target); - } else if(target.indexOf("%") === target.length-1) { - return this.gotoPercentage(parseInt(target.substring(0, target.length-1))/100); - } else if(typeof target === "number" || isNaN(target) === false){ - return this.gotoPage(target); - } else { - return this.gotoHref(target); - } - -}; - -EPUBJS.Book.prototype.gotoCfi = function(cfiString, defer){ - var cfi, - spinePos, - spineItem, - rendered, - deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - console.warn("Not yet Rendered"); - this.settings.previousLocationCfi = cfiString; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - console.warn("Renderer is moving"); - this._gotoQ.enqueue("gotoCfi", [cfiString, deferred]); - return false; - } - - cfi = new EPUBJS.EpubCFI(cfiString); - spinePos = cfi.spinePos; - - if(spinePos == -1) { - return false; - } - - spineItem = this.spine[spinePos]; - promise = deferred.promise; - this._moving = true; - //-- If same chapter only stay on current chapter - if(this.currentChapter && this.spinePos === spinePos){ - this.renderer.gotoCfi(cfi); - this._moving = false; - deferred.resolve(this.renderer.currentLocationCfi); - } else { - - if(!spineItem || spinePos == -1) { - spinePos = 0; - spineItem = this.spine[spinePos]; - } - - this.currentChapter = new EPUBJS.Chapter(spineItem, this.store); - - if(this.currentChapter) { - this.spinePos = spinePos; - render = this.renderer.displayChapter(this.currentChapter, this.globalLayoutProperties); - - this.renderer.gotoCfi(cfi); - render.then(function(rendered){ - this._moving = false; - deferred.resolve(rendered.currentLocationCfi); - }.bind(this)); - } - } - - promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return promise; -}; - -EPUBJS.Book.prototype.gotoHref = function(url, defer){ - var split, chapter, section, relativeURL, spinePos; - var deferred = defer || new RSVP.defer(); - - if(!this.isRendered) { - this.settings.goto = url; - return false; - } - - // Currently going to a chapter - if(this._moving || this._rendering) { - this._gotoQ.enqueue("gotoHref", [url, deferred]); - return false; - } - - split = url.split("#"); - chapter = split[0]; - section = split[1] || false; - // absoluteURL = (chapter.search("://") === -1) ? (this.settings.contentsPath + chapter) : chapter; - relativeURL = chapter.replace(this.settings.contentsPath, ''); - spinePos = this.spineIndexByURL[relativeURL]; - - //-- If link fragment only stay on current chapter - if(!chapter){ - spinePos = this.currentChapter ? this.currentChapter.spinePos : 0; - } - - //-- Check that URL is present in the index, or stop - if(typeof(spinePos) != "number") return false; - - if(!this.currentChapter || spinePos != this.currentChapter.spinePos){ - //-- Load new chapter if different than current - return this.displayChapter(spinePos).then(function(){ - if(section){ - this.renderer.section(section); - } - deferred.resolve(this.renderer.currentLocationCfi); - }.bind(this)); - }else{ - //-- Goto section - if(section) { - this.renderer.section(section); - } else { - // Or jump to the start - this.renderer.firstPage(); - } - deferred.resolve(this.renderer.currentLocationCfi); - } - - deferred.promise.then(function(){ - this._gotoQ.dequeue(); - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Book.prototype.gotoPage = function(pg){ - var cfi = this.pagination.cfiFromPage(pg); - return this.gotoCfi(cfi); -}; - -EPUBJS.Book.prototype.gotoPercentage = function(percent){ - var pg = this.pagination.pageFromPercentage(percent); - return this.gotoPage(pg); -}; - -EPUBJS.Book.prototype.preloadNextChapter = function() { - var next; - var chap = this.spinePos + 1; - - if(chap >= this.spine.length){ - return false; - } - - next = new EPUBJS.Chapter(this.spine[chap]); - if(next) { - EPUBJS.core.request(next.absolute); - } -}; - - -EPUBJS.Book.prototype.storeOffline = function() { - var book = this, - assets = _.values(this.manifest); - - //-- Creates a queue of all items to load - return EPUBJS.storage.batch(assets). - then(function(){ - book.settings.stored = true; - book.trigger("book:stored"); - }); -}; - -EPUBJS.Book.prototype.availableOffline = function() { - return this.settings.stored > 0 ? true : false; -}; - -/* -EPUBJS.Book.prototype.fromStorage = function(stored) { - - if(this.contained) return; - - if(!stored){ - this.online = true; - this.tell("book:online"); - }else{ - if(!this.availableOffline){ - //-- If book hasn't been cached yet, store offline - this.storeOffline(function(){ - this.online = false; - this.tell("book:offline"); - }.bind(this)); - - }else{ - this.online = false; - this.tell("book:offline"); - } - } - -} -*/ - -EPUBJS.Book.prototype.setStyle = function(style, val, prefixed) { - var noreflow = ["color", "background", "background-color"]; - - if(!this.isRendered) return this._q.enqueue("setStyle", arguments); - - this.settings.styles[style] = val; - - this.renderer.setStyle(style, val, prefixed); - - if(noreflow.indexOf(style) === -1) { - // clearTimeout(this.reformatTimeout); - // this.reformatTimeout = setTimeout(function(){ - this.renderer.reformat(); - // }.bind(this), 10); - } -}; - -EPUBJS.Book.prototype.removeStyle = function(style) { - if(!this.isRendered) return this._q.enqueue("removeStyle", arguments); - this.renderer.removeStyle(style); - this.renderer.reformat(); - delete this.settings.styles[style]; -}; - -EPUBJS.Book.prototype.addHeadTag = function(tag, attrs) { - if(!this.isRendered) return this._q.enqueue("addHeadTag", arguments); - this.settings.headTags[tag] = attrs; -}; - -EPUBJS.Book.prototype.useSpreads = function(use) { - console.warn("useSpreads is deprecated, use forceSingle or set a layoutOveride instead"); - if(use === false) { - this.forceSingle(true); - } else { - this.forceSingle(false); - } -}; - -EPUBJS.Book.prototype.forceSingle = function(_use) { - var force = typeof _use === "undefined" ? true : _use; - - this.renderer.forceSingle(force); - this.settings.forceSingle = force; - if(this.isRendered) { - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setMinSpreadWidth = function(width) { - this.settings.minSpreadWidth = width; - if(this.isRendered) { - this.renderer.setMinSpreadWidth(this.settings.minSpreadWidth); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.setGap = function(gap) { - this.settings.gap = gap; - if(this.isRendered) { - this.renderer.setGap(this.settings.gap); - this.renderer.reformat(); - } -}; - -EPUBJS.Book.prototype.chapter = function(path) { - var spinePos = this.spineIndexByURL[path]; - var spineItem; - var chapter; - - if(spinePos){ - spineItem = this.spine[spinePos]; - chapter = new EPUBJS.Chapter(spineItem, this.store); - chapter.load(); - } - return chapter; -}; - -EPUBJS.Book.prototype.unload = function(){ - - if(this.settings.restore && localStorage) { - this.saveContents(); - } - - this.unlistenToRenderer(this.renderer); - - this.trigger("book:unload"); -}; - -EPUBJS.Book.prototype.destroy = function() { - - window.removeEventListener("beforeunload", this.unload); - - if(this.currentChapter) this.currentChapter.unload(); - - this.unload(); - - if(this.render) this.render.remove(); - -}; - -EPUBJS.Book.prototype._ready = function() { - - this.trigger("book:ready"); - -}; - -EPUBJS.Book.prototype._rendered = function(err) { - var book = this; - - this.isRendered = true; - this.trigger("book:rendered"); - - this._q.flush(); -}; - - -EPUBJS.Book.prototype.applyStyles = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyStyles", arguments); - renderer.applyStyles(this.settings.styles); - callback(); -}; - -EPUBJS.Book.prototype.applyHeadTags = function(renderer, callback){ - // if(!this.isRendered) return this._q.enqueue("applyHeadTags", arguments); - renderer.applyHeadTags(this.settings.headTags); - callback(); -}; - -EPUBJS.Book.prototype._registerReplacements = function(renderer){ - renderer.registerHook("beforeChapterDisplay", this.applyStyles.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", this.applyHeadTags.bind(this, renderer), true); - renderer.registerHook("beforeChapterDisplay", EPUBJS.replace.hrefs.bind(this), true); - - if(this._needsAssetReplacement()) { - - renderer.registerHook("beforeChapterDisplay", [ - EPUBJS.replace.head, - EPUBJS.replace.resources, - EPUBJS.replace.svg - ], true); - - } - -}; - -EPUBJS.Book.prototype._needsAssetReplacement = function(){ - if(this.settings.fromStorage) { - - //-- Filesystem api links are relative, so no need to replace them - if(this.storage.getStorageType() == "filesystem") { - return false; - } - - return true; - - } else if(this.settings.contained) { - - return true; - - } else { - - return false; - - } -}; - - -//-- http://www.idpf.org/epub/fxl/ -EPUBJS.Book.prototype.parseLayoutProperties = function(metadata){ - var layout = (this.layoutOveride && this.layoutOveride.layout) || metadata.layout || "reflowable"; - var spread = (this.layoutOveride && this.layoutOveride.spread) || metadata.spread || "auto"; - var orientation = (this.layoutOveride && this.layoutOveride.orientation) || metadata.orientation || "auto"; - return { - layout : layout, - spread : spread, - orientation : orientation - }; -}; - -//-- Enable binding events to book -RSVP.EventTarget.mixin(EPUBJS.Book.prototype); - -//-- Handle RSVP Errors -RSVP.on('error', function(event) { - //console.error(event, event.detail); -}); - -RSVP.configure('instrument', true); //-- true | will logging out all RSVP rejections -// RSVP.on('created', listener); -// RSVP.on('chained', listener); -// RSVP.on('fulfilled', listener); -RSVP.on('rejected', function(event){ - console.error(event.detail.message, event.detail.stack); -}); - -EPUBJS.Chapter = function(spineObject, store){ - this.href = spineObject.href; - this.absolute = spineObject.url; - this.id = spineObject.id; - this.spinePos = spineObject.index; - this.cfiBase = spineObject.cfiBase; - this.properties = spineObject.properties; - this.manifestProperties = spineObject.manifestProperties; - this.linear = spineObject.linear; - this.pages = 1; - this.store = store; - this.epubcfi = new EPUBJS.EpubCFI(); - this.deferred = new RSVP.defer(); - this.loaded = this.deferred.promise; -}; - - -EPUBJS.Chapter.prototype.load = function(_store){ - var store = _store || this.store; - var promise; - // if(this.store && (!this.book.online || this.book.contained)) - if(store){ - promise = store.get(this.href); - }else{ - promise = EPUBJS.core.request(this.absolute, 'xml'); - } - - promise.then(function(xml){ - this.setDocument(xml); - this.deferred.resolve(this); - }.bind(this)); - - return promise; -}; - -EPUBJS.Chapter.prototype.render = function(_store){ - - return this.load().then(function(doc){ - - var serializer = new XMLSerializer(); - var contents; - var head = doc.head; - var base = doc.createElement("base"); - - base.setAttribute("href", window.location.origin + this.absolute); - head.insertBefore(base, head.firstChild); - contents = serializer.serializeToString(doc); - - return contents; - - }.bind(this)); -}; - -EPUBJS.Chapter.prototype.url = function(_store){ - var deferred = new RSVP.defer(); - var store = _store || this.store; - var loaded; - var chapter = this; - var url; - - if(store){ - if(!this.tempUrl) { - store.getUrl(this.absolute).then(function(url){ - chapter.tempUrl = url; - deferred.resolve(url); - }); - } else { - url = this.tempUrl; - deferred.resolve(url); - } - }else{ - url = this.absolute; - deferred.resolve(url); - } - /* - loaded = EPUBJS.core.request(url, 'xml', false); - loaded.then(function(contents){ - chapter.contents = contents; - deferred.resolve(chapter.absolute); - }, function(error){ - deferred.reject(error); - }); - */ - - return deferred.promise; -}; - -EPUBJS.Chapter.prototype.setPages = function(num){ - this.pages = num; -}; - -EPUBJS.Chapter.prototype.getPages = function(num){ - return this.pages; -}; - -EPUBJS.Chapter.prototype.getID = function(){ - return this.ID; -}; - -EPUBJS.Chapter.prototype.unload = function(store){ - this.document = null; - if(this.tempUrl && store) { - store.revokeUrl(this.tempUrl); - this.tempUrl = false; - } -}; - -EPUBJS.Chapter.prototype.setDocument = function(_document){ - var uri = _document.namespaceURI; - var doctype = _document.doctype; - - // Creates an empty document - this.document = _document.implementation.createDocument( - uri, - null, - null - ); - this.contents = this.document.importNode( - _document.documentElement, //node to import - true //clone its descendants - ); - - this.document.appendChild(this.contents); - - // Fix to apply wgxpath to new document in IE - if(!this.document.evaluate && document.evaluate) { - this.document.evaluate = document.evaluate; - } - - // this.deferred.resolve(this.contents); -}; - -EPUBJS.Chapter.prototype.cfiFromRange = function(_range) { - var range; - var startXpath, endXpath; - var startContainer, endContainer; - var cleanTextContent, cleanEndTextContent; - - // Check for Contents - if(!this.document) return; - startXpath = EPUBJS.core.getElementXPath(_range.startContainer); - // console.log(startContainer) - endXpath = EPUBJS.core.getElementXPath(_range.endContainer); - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!_range.collapsed) { - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - } - - range = this.document.createRange(); - // Find Exact Range in original document - if(startContainer) { - try { - range.setStart(startContainer, _range.startOffset); - if(!_range.collapsed && endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } catch (e) { - console.log("missed"); - startContainer = false; - } - - } - - // Fuzzy Match - if(!startContainer) { - console.log("not found, try fuzzy match"); - cleanStartTextContent = EPUBJS.core.cleanStringForXpath(_range.startContainer.textContent); - startXpath = "//text()[contains(.," + cleanStartTextContent + ")]"; - - startContainer = this.document.evaluate(startXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(startContainer){ - // console.log("Found with Fuzzy"); - range.setStart(startContainer, _range.startOffset); - - if(!_range.collapsed) { - cleanEndTextContent = EPUBJS.core.cleanStringForXpath(_range.endContainer.textContent); - endXpath = "//text()[contains(.," + cleanEndTextContent + ")]"; - endContainer = this.document.evaluate(endXpath, this.document, EPUBJS.core.nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - if(endContainer) { - range.setEnd(endContainer, _range.endOffset); - } - } - - } - } - - // Generate the Cfi - return this.epubcfi.generateCfiFromRange(range, this.cfiBase); -}; - -EPUBJS.Chapter.prototype.find = function(_query){ - var chapter = this; - var matches = []; - var query = _query.toLowerCase(); - //var xpath = this.document.evaluate(".//text()[contains(translate(., '"+query.toUpperCase()+"', '"+query+"'),'"+query+"')]", this.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - var find = function(node){ - // Search String - var text = node.textContent.toLowerCase(); - var range = chapter.document.createRange(); - var cfi; - var pos; - var last = -1; - var excerpt; - var limit = 150; - - while (pos != -1) { - pos = text.indexOf(query, last + 1); - - if(pos != -1) { - // If Found, Create Range - range = chapter.document.createRange(); - range.setStart(node, pos); - range.setEnd(node, pos + query.length); - - //Generate CFI - cfi = chapter.cfiFromRange(range); - - // Generate Excerpt - if(node.textContent.length < limit) { - excerpt = node.textContent; - } else { - excerpt = node.textContent.substring(pos-limit/2,pos+limit/2); - excerpt = "..." + excerpt + "..."; - } - - //Add CFI to list - matches.push({ - cfi: cfi, - excerpt: excerpt - }); - } - - last = pos; - } - - }; - - // Grab text nodes - - /* - for ( var i=0 ; i < xpath.snapshotLength; i++ ) { - find(xpath.snapshotItem(i)); - } - */ - - this.textSprint(this.document, function(node){ - find(node); - }); - - - // Return List of CFIs - return matches; -}; - - -EPUBJS.Chapter.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if (node.data && ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; -var EPUBJS = EPUBJS || {}; -EPUBJS.core = {}; - -//-- Get a element for an id -EPUBJS.core.getEl = function(elem) { - return document.getElementById(elem); -}; - -//-- Get all elements for a class -EPUBJS.core.getEls = function(classes) { - return document.getElementsByClassName(classes); -}; - -EPUBJS.core.request = function(url, type, withCredentials) { - var supportsURL = window.URL; - var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer"; - - var deferred = new RSVP.defer(); - - var xhr = new XMLHttpRequest(); - - //-- Check from PDF.js: - // https://github.com/mozilla/pdf.js/blob/master/web/compatibility.js - var xhrPrototype = XMLHttpRequest.prototype; - - if (!('overrideMimeType' in xhrPrototype)) { - // IE10 might have response, but not overrideMimeType - Object.defineProperty(xhrPrototype, 'overrideMimeType', { - value: function xmlHttpRequestOverrideMimeType(mimeType) {} - }); - } - if(withCredentials) { - xhr.withCredentials = true; - } - xhr.open("GET", url, true); - xhr.onreadystatechange = handler; - - if(type == 'blob'){ - xhr.responseType = BLOB_RESPONSE; - } - - if(type == "json") { - xhr.setRequestHeader("Accept", "application/json"); - } - - if(type == 'xml') { - xhr.overrideMimeType('text/xml'); - } - - if(type == "binary") { - xhr.responseType = "arraybuffer"; - } - - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200 || this.responseXML ) { //-- Firefox is reporting 0 for blob urls - var r; - - if(type == 'xml'){ - r = this.responseXML; - }else - if(type == 'json'){ - r = JSON.parse(this.response); - }else - if(type == 'blob'){ - - if(supportsURL) { - r = this.response; - } else { - //-- Safari doesn't support responseType blob, so create a blob from arraybuffer - r = new Blob([this.response]); - } - - }else{ - r = this.response; - } - - deferred.resolve(r); - } else { - deferred.reject({ - message : this.response, - stack : new Error().stack - }); - } - } - } - - return deferred.promise; -}; - -EPUBJS.core.toArray = function(obj) { - var arr = []; - - for (var member in obj) { - var newitm; - if ( obj.hasOwnProperty(member) ) { - newitm = obj[member]; - newitm.ident = member; - arr.push(newitm); - } - } - - return arr; -}; - -//-- Parse the different parts of a url, returning a object -EPUBJS.core.uri = function(url){ - var uri = { - protocol : '', - host : '', - path : '', - origin : '', - directory : '', - base : '', - filename : '', - extension : '', - fragment : '', - href : url - }, - blob = url.indexOf('blob:'), - doubleSlash = url.indexOf('://'), - search = url.indexOf('?'), - fragment = url.indexOf("#"), - withoutProtocol, - dot, - firstSlash; - - if(blob === 0) { - uri.protocol = "blob"; - uri.base = url.indexOf(0, fragment); - return uri; - } - - if(fragment != -1) { - uri.fragment = url.slice(fragment + 1); - url = url.slice(0, fragment); - } - - if(search != -1) { - uri.search = url.slice(search + 1); - url = url.slice(0, search); - href = url; - } - - if(doubleSlash != -1) { - uri.protocol = url.slice(0, doubleSlash); - withoutProtocol = url.slice(doubleSlash+3); - firstSlash = withoutProtocol.indexOf('/'); - - if(firstSlash === -1) { - uri.host = uri.path; - uri.path = ""; - } else { - uri.host = withoutProtocol.slice(0, firstSlash); - uri.path = withoutProtocol.slice(firstSlash); - } - - - uri.origin = uri.protocol + "://" + uri.host; - - uri.directory = EPUBJS.core.folder(uri.path); - - uri.base = uri.origin + uri.directory; - // return origin; - } else { - uri.path = url; - uri.directory = EPUBJS.core.folder(url); - uri.base = uri.directory; - } - - //-- Filename - uri.filename = url.replace(uri.base, ''); - dot = uri.filename.lastIndexOf('.'); - if(dot != -1) { - uri.extension = uri.filename.slice(dot+1); - } - return uri; -}; - -//-- Parse out the folder, will return everything before the last slash - -EPUBJS.core.folder = function(url){ - - var lastSlash = url.lastIndexOf('/'); - - if(lastSlash == -1) var folder = ''; - - folder = url.slice(0, lastSlash + 1); - - return folder; - -}; - -//-- https://github.com/ebidel/filer.js/blob/master/src/filer.js#L128 -EPUBJS.core.dataURLToBlob = function(dataURL) { - var BASE64_MARKER = ';base64,', - parts, contentType, raw, rawLength, uInt8Array; - - if (dataURL.indexOf(BASE64_MARKER) == -1) { - parts = dataURL.split(','); - contentType = parts[0].split(':')[1]; - raw = parts[1]; - - return new Blob([raw], {type: contentType}); - } - - parts = dataURL.split(BASE64_MARKER); - contentType = parts[0].split(':')[1]; - raw = window.atob(parts[1]); - rawLength = raw.length; - - uInt8Array = new Uint8Array(rawLength); - - for (var i = 0; i < rawLength; ++i) { - uInt8Array[i] = raw.charCodeAt(i); - } - - return new Blob([uInt8Array], {type: contentType}); -}; - -//-- Load scripts async: http://stackoverflow.com/questions/7718935/load-scripts-asynchronously -EPUBJS.core.addScript = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('script'); - s.type = 'text/javascript'; - s.async = false; - s.src = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.addScripts = function(srcArr, callback, target) { - var total = srcArr.length, - curr = 0, - cb = function(){ - curr++; - if(total == curr){ - if(callback) callback(); - }else{ - EPUBJS.core.addScript(srcArr[curr], cb, target); - } - }; - - EPUBJS.core.addScript(srcArr[curr], cb, target); -}; - -EPUBJS.core.addCss = function(src, callback, target) { - var s, r; - r = false; - s = document.createElement('link'); - s.type = 'text/css'; - s.rel = "stylesheet"; - s.href = src; - s.onload = s.onreadystatechange = function() { - if ( !r && (!this.readyState || this.readyState == 'complete') ) { - r = true; - if(callback) callback(); - } - }; - target = target || document.body; - target.appendChild(s); -}; - -EPUBJS.core.prefixed = function(unprefixed) { - var vendors = ["Webkit", "Moz", "O", "ms" ], - prefixes = ['-Webkit-', '-moz-', '-o-', '-ms-'], - upper = unprefixed[0].toUpperCase() + unprefixed.slice(1), - length = vendors.length; - - if (typeof(document.body.style[unprefixed]) != 'undefined') { - return unprefixed; - } - - for ( var i=0; i < length; i++ ) { - if (typeof(document.body.style[vendors[i] + upper]) != 'undefined') { - return vendors[i] + upper; - } - } - - return unprefixed; -}; - -EPUBJS.core.resolveUrl = function(base, path) { - var url, - segments = [], - uri = EPUBJS.core.uri(path), - folders = base.split("/"), - paths; - - if(uri.host) { - return path; - } - - folders.pop(); - - paths = path.split("/"); - paths.forEach(function(p){ - if(p === ".."){ - folders.pop(); - }else{ - segments.push(p); - } - }); - - url = folders.concat(segments); - - return url.join("/"); -}; - -// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -EPUBJS.core.uuid = function() { - var d = new Date().getTime(); - var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = (d + Math.random()*16)%16 | 0; - d = Math.floor(d/16); - return (c=='x' ? r : (r&0x7|0x8)).toString(16); - }); - return uuid; -}; - -// Fast quicksort insert for sorted array -- based on: -// http://stackoverflow.com/questions/1344500/efficient-way-to-insert-a-number-into-a-sorted-array-of-numbers -EPUBJS.core.insert = function(item, array, compareFunction) { - var location = EPUBJS.core.locationOf(item, array, compareFunction); - array.splice(location, 0, item); - - return location; -}; - -EPUBJS.core.locationOf = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return pivot; - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared > 0 ? pivot : pivot + 1; - } - - if(compared === 0) { - return pivot; - } - if(compared === -1) { - return EPUBJS.core.locationOf(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.locationOf(item, array, compareFunction, start, pivot); - } -}; - -EPUBJS.core.indexOfSorted = function(item, array, compareFunction, _start, _end) { - var start = _start || 0; - var end = _end || array.length; - var pivot = parseInt(start + (end - start) / 2); - var compared; - if(!compareFunction){ - compareFunction = function(a, b) { - if(a > b) return 1; - if(a < b) return -1; - if(a = b) return 0; - }; - } - if(end-start <= 0) { - return -1; // Not found - } - - compared = compareFunction(array[pivot], item); - if(end-start === 1) { - return compared === 0 ? pivot : -1; - } - if(compared === 0) { - return pivot; // Found - } - if(compared === -1) { - return EPUBJS.core.indexOfSorted(item, array, compareFunction, pivot, end); - } else{ - return EPUBJS.core.indexOfSorted(item, array, compareFunction, start, pivot); - } -}; - - -EPUBJS.core.queue = function(_scope){ - var _q = []; - var scope = _scope; - // Add an item to the queue - var enqueue = function(funcName, args, context) { - _q.push({ - "funcName" : funcName, - "args" : args, - "context" : context - }); - return _q; - }; - // Run one item - var dequeue = function(){ - var inwait; - if(_q.length) { - inwait = _q.shift(); - // Defer to any current tasks - // setTimeout(function(){ - scope[inwait.funcName].apply(inwait.context || scope, inwait.args); - // }, 0); - } - }; - - // Run All - var flush = function(){ - while(_q.length) { - dequeue(); - } - }; - // Clear all items in wait - var clear = function(){ - _q = []; - }; - - var length = function(){ - return _q.length; - }; - - return { - "enqueue" : enqueue, - "dequeue" : dequeue, - "flush" : flush, - "clear" : clear, - "length" : length - }; -}; - -// From: https://code.google.com/p/fbug/source/browse/branches/firebug1.10/content/firebug/lib/xpath.js -/** - * Gets an XPath for an element which describes its hierarchical location. - */ -EPUBJS.core.getElementXPath = function(element) { - if (element && element.id) { - return '//*[@id="' + element.id + '"]'; - } else { - return EPUBJS.core.getElementTreeXPath(element); - } -}; - -EPUBJS.core.getElementTreeXPath = function(element) { - var paths = []; - var isXhtml = (element.ownerDocument.documentElement.getAttribute('xmlns') === "http://www.w3.org/1999/xhtml"); - var index, nodeName, tagName, pathIndex; - - if(element.nodeType === Node.TEXT_NODE){ - // index = Array.prototype.indexOf.call(element.parentNode.childNodes, element) + 1; - index = EPUBJS.core.indexOfTextNode(element) + 1; - - paths.push("text()["+index+"]"); - element = element.parentNode; - } - - // Use nodeName (instead of localName) so namespace prefix is included (if any). - for (; element && element.nodeType == 1; element = element.parentNode) - { - index = 0; - for (var sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) - { - // Ignore document type declaration. - if (sibling.nodeType == Node.DOCUMENT_TYPE_NODE) { - continue; - } - if (sibling.nodeName == element.nodeName) { - ++index; - } - } - nodeName = element.nodeName.toLowerCase(); - tagName = (isXhtml ? "xhtml:" + nodeName : nodeName); - pathIndex = (index ? "[" + (index+1) + "]" : ""); - paths.splice(0, 0, tagName + pathIndex); - } - - return paths.length ? "./" + paths.join("/") : null; -}; - -EPUBJS.core.nsResolver = function(prefix) { - var ns = { - 'xhtml' : 'http://www.w3.org/1999/xhtml', - 'epub': 'http://www.idpf.org/2007/ops' - }; - return ns[prefix] || null; -}; - -//https://stackoverflow.com/questions/13482352/xquery-looking-for-text-with-single-quote/13483496#13483496 -EPUBJS.core.cleanStringForXpath = function(str) { - var parts = str.match(/[^'"]+|['"]/g); - parts = parts.map(function(part){ - if (part === "'") { - return '\"\'\"'; // output "'" - } - - if (part === '"') { - return "\'\"\'"; // output '"' - } - return "\'" + part + "\'"; - }); - return "concat(\'\'," + parts.join(",") + ")"; -}; - -EPUBJS.core.indexOfTextNode = function(textNode){ - var parent = textNode.parentNode; - var children = parent.childNodes; - var sib; - var index = -1; - for (var i = 0; i < children.length; i++) { - sib = children[i]; - if(sib.nodeType === Node.TEXT_NODE){ - index++; - } - if(sib == textNode) break; - } - - return index; -}; -EPUBJS.EpubCFI = function(cfiStr){ - if(cfiStr) return this.parse(cfiStr); -}; - -EPUBJS.EpubCFI.prototype.generateChapterComponent = function(_spineNodeIndex, _pos, id) { - var pos = parseInt(_pos), - spineNodeIndex = _spineNodeIndex + 1, - cfi = '/'+spineNodeIndex+'/'; - - cfi += (pos + 1) * 2; - - if(id) cfi += "[" + id + "]"; - - //cfi += "!"; - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.generatePathComponent = function(steps) { - var parts = []; - - steps.forEach(function(part){ - var segment = ''; - segment += (part.index + 1) * 2; - - if(part.id) { - segment += "[" + part.id + "]"; - } - - parts.push(segment); - }); - - return parts.join('/'); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromElement = function(element, chapter) { - var steps = this.pathTo(element); - var path = this.generatePathComponent(steps); - if(!path.length) { - // Start of Chapter - return "epubcfi(" + chapter + "!/4/)"; - } else { - // First Text Node - return "epubcfi(" + chapter + "!" + path + "/1:0)"; - } -}; - -EPUBJS.EpubCFI.prototype.pathTo = function(node) { - var stack = [], - children; - - while(node && node.parentNode !== null && node.parentNode.nodeType != 9) { - children = node.parentNode.children; - - stack.unshift({ - 'id' : node.id, - // 'classList' : node.classList, - 'tagName' : node.tagName, - 'index' : children ? Array.prototype.indexOf.call(children, node) : 0 - }); - - node = node.parentNode; - } - - return stack; -}; - -EPUBJS.EpubCFI.prototype.getChapterComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - - return splitStr[0]; -}; - -EPUBJS.EpubCFI.prototype.getPathComponent = function(cfiStr) { - - var splitStr = cfiStr.split("!"); - var pathComponent = splitStr[1] ? splitStr[1].split(":") : ''; - - return pathComponent[0]; -}; - -EPUBJS.EpubCFI.prototype.getCharecterOffsetComponent = function(cfiStr) { - var splitStr = cfiStr.split(":"); - return splitStr[1] || ''; -}; - - -EPUBJS.EpubCFI.prototype.parse = function(cfiStr) { - var cfi = {}, - chapSegment, - chapterComponent, - pathComponent, - charecterOffsetComponent, - assertion, - chapId, - path, - end, - endInt, - text, - parseStep = function(part){ - var type, index, has_brackets, id; - - type = "element"; - index = parseInt(part) / 2 - 1; - has_brackets = part.match(/\[(.*)\]/); - if(has_brackets && has_brackets[1]){ - id = has_brackets[1]; - } - - return { - "type" : type, - 'index' : index, - 'id' : id || false - }; - }; - - if(typeof cfiStr !== "string") { - return {spinePos: -1}; - } - - cfi.str = cfiStr; - - if(cfiStr.indexOf("epubcfi(") === 0 && cfiStr[cfiStr.length-1] === ")") { - // Remove intial epubcfi( and ending ) - cfiStr = cfiStr.slice(8, cfiStr.length-1); - } - - chapterComponent = this.getChapterComponent(cfiStr); - pathComponent = this.getPathComponent(cfiStr) || ''; - charecterOffsetComponent = this.getCharecterOffsetComponent(cfiStr); - // Make sure this is a valid cfi or return - if(!chapterComponent) { - return {spinePos: -1}; - } - - // Chapter segment is always the second one - chapSegment = chapterComponent.split("/")[2] || ''; - if(!chapSegment) return {spinePos:-1}; - - cfi.spinePos = (parseInt(chapSegment) / 2 - 1 ) || 0; - - chapId = chapSegment.match(/\[(.*)\]/); - - cfi.spineId = chapId ? chapId[1] : false; - - if(pathComponent.indexOf(',') != -1) { - // Handle ranges -- not supported yet - console.warn("CFI Ranges are not supported"); - } - - path = pathComponent.split('/'); - end = path.pop(); - - cfi.steps = []; - - path.forEach(function(part){ - var step; - - if(part) { - step = parseStep(part); - cfi.steps.push(step); - } - }); - - //-- Check if END is a text node or element - endInt = parseInt(end); - if(!isNaN(endInt)) { - - if(endInt % 2 === 0) { // Even = is an element - cfi.steps.push(parseStep(end)); - } else { - cfi.steps.push({ - "type" : "text", - 'index' : (endInt - 1 ) / 2 - }); - } - - } - - assertion = charecterOffsetComponent.match(/\[(.*)\]/); - if(assertion && assertion[1]){ - cfi.characterOffset = parseInt(charecterOffsetComponent.split('[')[0]); - // We arent handling these assertions yet - cfi.textLocationAssertion = assertion[1]; - } else { - cfi.characterOffset = parseInt(charecterOffsetComponent); - } - - return cfi; -}; - -EPUBJS.EpubCFI.prototype.addMarker = function(cfi, _doc, _marker) { - var doc = _doc || document; - var marker = _marker || this.createMarker(doc); - var parent; - var lastStep; - var text; - var split; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - // Find the CFI elements parent - parent = this.findParent(cfi, doc); - - if(!parent) { - // CFI didn't return an element - // Maybe it isnt in the current chapter? - return false; - } - - if(lastStep && lastStep.type === "text") { - text = parent.childNodes[lastStep.index]; - if(cfi.characterOffset){ - split = text.splitText(cfi.characterOffset); - marker.classList.add("EPUBJS-CFI-SPLIT"); - parent.insertBefore(marker, split); - } else { - parent.insertBefore(marker, text); - } - } else { - parent.insertBefore(marker, parent.firstChild); - } - - return marker; -}; - -EPUBJS.EpubCFI.prototype.createMarker = function(_doc) { - var doc = _doc || document; - var element = doc.createElement('span'); - element.id = "EPUBJS-CFI-MARKER:"+ EPUBJS.core.uuid(); - element.classList.add("EPUBJS-CFI-MARKER"); - - return element; -}; - -EPUBJS.EpubCFI.prototype.removeMarker = function(marker, _doc) { - var doc = _doc || document; - // var id = marker.id; - - // Cleanup textnodes if they were split - if(marker.classList.contains("EPUBJS-CFI-SPLIT")){ - nextSib = marker.nextSibling; - prevSib = marker.previousSibling; - if(nextSib && - prevSib && - nextSib.nodeType === 3 && - prevSib.nodeType === 3){ - - prevSib.textContent += nextSib.textContent; - marker.parentNode.removeChild(nextSib); - } - marker.parentNode.removeChild(marker); - } else if(marker.classList.contains("EPUBJS-CFI-MARKER")) { - // Remove only elements added as markers - marker.parentNode.removeChild(marker); - } - -}; - -EPUBJS.EpubCFI.prototype.findParent = function(cfi, _doc) { - var doc = _doc || document, - element = doc.getElementsByTagName('html')[0], - children = Array.prototype.slice.call(element.children), - num, index, part, sections, - text, textBegin, textEnd; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - sections = cfi.steps.slice(0); // Clone steps array - if(!sections.length) { - return doc.getElementsByTagName('body')[0]; - } - - while(sections && sections.length > 0) { - part = sections.shift(); - // Find textNodes Parent - if(part.type === "text") { - text = element.childNodes[part.index]; - element = text.parentNode || element; - // Find element by id if present - } else if(part.id){ - element = doc.getElementById(part.id); - // Find element in parent - }else{ - element = children[part.index]; - } - // Element can't be found - if(typeof element === "undefined") { - console.error("No Element For", part, cfi.str); - return false; - } - // Get current element children and continue through steps - children = Array.prototype.slice.call(element.children); - } - - return element; -}; - -EPUBJS.EpubCFI.prototype.compare = function(cfiOne, cfiTwo) { - if(typeof cfiOne === 'string') { - cfiOne = new EPUBJS.EpubCFI(cfiOne); - } - if(typeof cfiTwo === 'string') { - cfiTwo = new EPUBJS.EpubCFI(cfiTwo); - } - // Compare Spine Positions - if(cfiOne.spinePos > cfiTwo.spinePos) { - return 1; - } - if(cfiOne.spinePos < cfiTwo.spinePos) { - return -1; - } - - - // Compare Each Step in the First item - for (var i = 0; i < cfiOne.steps.length; i++) { - if(!cfiTwo.steps[i]) { - return 1; - } - if(cfiOne.steps[i].index > cfiTwo.steps[i].index) { - return 1; - } - if(cfiOne.steps[i].index < cfiTwo.steps[i].index) { - return -1; - } - // Otherwise continue checking - } - - // All steps in First present in Second - if(cfiOne.steps.length < cfiTwo.steps.length) { - return -1; - } - - // Compare the charecter offset of the text node - if(cfiOne.characterOffset > cfiTwo.characterOffset) { - return 1; - } - if(cfiOne.characterOffset < cfiTwo.characterOffset) { - return -1; - } - - // CFI's are equal - return 0; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromHref = function(href, book) { - var uri = EPUBJS.core.uri(href); - var path = uri.path; - var fragment = uri.fragment; - var spinePos = book.spineIndexByURL[path]; - var loaded; - var deferred = new RSVP.defer(); - var epubcfi = new EPUBJS.EpubCFI(); - var spineItem; - - if(typeof spinePos !== "undefined"){ - spineItem = book.spine[spinePos]; - loaded = book.loadXml(spineItem.url); - loaded.then(function(doc){ - var element = doc.getElementById(fragment); - var cfi; - cfi = epubcfi.generateCfiFromElement(element, spineItem.cfiBase); - deferred.resolve(cfi); - }); - } - - return deferred.promise; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromTextNode = function(anchor, offset, base) { - var parent = anchor.parentNode; - var steps = this.pathTo(parent); - var path = this.generatePathComponent(steps); - var index = 1 + (2 * Array.prototype.indexOf.call(parent.childNodes, anchor)); - return "epubcfi(" + base + "!" + path + "/"+index+":"+(offset || 0)+")"; -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRangeAnchor = function(range, base) { - var anchor = range.anchorNode; - var offset = range.anchorOffset; - return this.generateCfiFromTextNode(anchor, offset, base); -}; - -EPUBJS.EpubCFI.prototype.generateCfiFromRange = function(range, base) { - var start, startElement, startSteps, startPath, startOffset, startIndex; - var end, endElement, endSteps, endPath, endOffset, endIndex; - - start = range.startContainer; - - if(start.nodeType === 3) { // text node - startElement = start.parentNode; - //startIndex = 1 + (2 * Array.prototype.indexOf.call(startElement.childNodes, start)); - startIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(start)); - startSteps = this.pathTo(startElement); - } else if(range.collapsed) { - return this.generateCfiFromElement(start, base); // single element - } else { - startSteps = this.pathTo(start); - } - - startPath = this.generatePathComponent(startSteps); - startOffset = range.startOffset; - - if(!range.collapsed) { - end = range.endContainer; - - if(end.nodeType === 3) { // text node - endElement = end.parentNode; - // endIndex = 1 + (2 * Array.prototype.indexOf.call(endElement.childNodes, end)); - endIndex = 1 + (2 * EPUBJS.core.indexOfTextNode(end)); - - endSteps = this.pathTo(endElement); - } else { - endSteps = this.pathTo(end); - } - - endPath = this.generatePathComponent(endSteps); - endOffset = range.endOffset; - - return "epubcfi(" + base + "!" + startPath + "/" + startIndex + ":" + startOffset + "," + endPath + "/" + endIndex + ":" + endOffset + ")"; - - } else { - return "epubcfi(" + base + "!" + startPath + "/"+ startIndex +":"+ startOffset +")"; - } -}; - -EPUBJS.EpubCFI.prototype.generateXpathFromSteps = function(steps) { - var xpath = [".", "*"]; - - steps.forEach(function(step){ - var position = step.index + 1; - - if(step.id){ - xpath.push("*[position()=" + position + " and @id='" + step.id + "']"); - } else if(step.type === "text") { - xpath.push("text()[" + position + "]"); - } else { - xpath.push("*[" + position + "]"); - } - }); - - return xpath.join("/"); -}; - - -EPUBJS.EpubCFI.prototype.generateRangeFromCfi = function(cfi, _doc) { - var doc = _doc || document; - var range = doc.createRange(); - var lastStep; - var xpath; - var startContainer; - var textLength; - - if(typeof cfi === 'string') { - cfi = this.parse(cfi); - } - - // check spinePos - if(cfi.spinePos === -1) { - // Not a valid CFI - return false; - } - - xpath = this.generateXpathFromSteps(cfi.steps); - - // Get the terminal step - lastStep = cfi.steps[cfi.steps.length-1]; - startContainer = doc.evaluate(xpath, doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - - if(!startContainer) { - return null; - } - - if(startContainer && cfi.characterOffset >= 0) { - textLength = startContainer.length; - - if(cfi.characterOffset < textLength) { - range.setStart(startContainer, cfi.characterOffset); - range.setEnd(startContainer, textLength ); - } else { - console.debug("offset greater than length:", cfi.characterOffset, textLength); - range.setStart(startContainer, textLength - 1 ); - range.setEnd(startContainer, textLength ); - } - } else if(startContainer) { - range.selectNode(startContainer); - } - // doc.defaultView.getSelection().addRange(range); - return range; -}; - -EPUBJS.Events = function(obj, el){ - - this.events = {}; - - if(!el){ - this.el = document.createElement('div'); - }else{ - this.el = el; - } - - obj.createEvent = this.createEvent; - obj.tell = this.tell; - obj.listen = this.listen; - obj.deafen = this.deafen; - obj.listenUntil = this.listenUntil; - - return this; -}; - -EPUBJS.Events.prototype.createEvent = function(evt){ - var e = new CustomEvent(evt); - this.events[evt] = e; - return e; -}; - -EPUBJS.Events.prototype.tell = function(evt, msg){ - var e; - - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - e = this.createEvent(evt); - }else{ - e = this.events[evt]; - } - - if(msg) e.msg = msg; - this.el.dispatchEvent(e); - -}; - -EPUBJS.Events.prototype.listen = function(evt, func, bindto){ - if(!this.events[evt]){ - console.warn("No event:", evt, "defined yet, creating."); - this.createEvent(evt); - return; - } - - if(bindto){ - this.el.addEventListener(evt, func.bind(bindto), false); - }else{ - this.el.addEventListener(evt, func, false); - } - -}; - -EPUBJS.Events.prototype.deafen = function(evt, func){ - this.el.removeEventListener(evt, func, false); -}; - -EPUBJS.Events.prototype.listenUntil = function(OnEvt, OffEvt, func, bindto){ - this.listen(OnEvt, func, bindto); - - function unlisten(){ - this.deafen(OnEvt, func); - this.deafen(OffEvt, unlisten); - } - - this.listen(OffEvt, unlisten, this); -}; -EPUBJS.hooks = {}; -EPUBJS.Hooks = (function(){ - function hooks(){} - - //-- Get pre-registered hooks - hooks.prototype.getHooks = function(){ - var plugs; - this.hooks = {}; - Array.prototype.slice.call(arguments).forEach(function(arg){ - this.hooks[arg] = []; - }, this); - - for (var plugType in this.hooks) { - plugs = _.values(EPUBJS.hooks[plugType]); - - plugs.forEach(function(hook){ - this.registerHook(plugType, hook); - }, this); - } - }; - - //-- Hooks allow for injecting async functions that must all complete before continuing - // Functions must have a callback as their first argument. - hooks.prototype.registerHook = function(type, toAdd, toFront){ - - if(typeof(this.hooks[type]) != "undefined"){ - - if(typeof(toAdd) === "function"){ - if(toFront) { - this.hooks[type].unshift(toAdd); - }else{ - this.hooks[type].push(toAdd); - } - }else if(Array.isArray(toAdd)){ - toAdd.forEach(function(hook){ - if(toFront) { - this.hooks[type].unshift(hook); - }else{ - this.hooks[type].push(hook); - } - }, this); - } - }else{ - //-- Allows for undefined hooks, but maybe this should error? - this.hooks[type] = [func]; - } - }; - - hooks.prototype.triggerHooks = function(type, callback, passed){ - var hooks, count; - - if(typeof(this.hooks[type]) == "undefined") return false; - - hooks = this.hooks[type]; - - count = hooks.length; - if(count === 0 && callback) { - callback(); - } - - function countdown(){ - count--; - if(count <= 0 && callback) callback(); - } - - hooks.forEach(function(hook){ - hook(countdown, passed); - }); - }; - - return { - register: function(name) { - if(EPUBJS.hooks[name] === undefined) { EPUBJS.hooks[name] = {}; } - if(typeof EPUBJS.hooks[name] !== 'object') { throw "Already registered: "+name; } - return EPUBJS.hooks[name]; - }, - mixin: function(object) { - for (var prop in hooks.prototype) { - object[prop] = hooks.prototype[prop]; - } - } - }; -})(); - - -EPUBJS.Layout = EPUBJS.Layout || {}; - -EPUBJS.Layout.Reflowable = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.Reflowable.prototype.format = function(documentElement, _width, _height, _gap){ - // Get the prefixed CSS commands - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - //-- Check the width and create even width columns - var width = Math.floor(_width); - // var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 0; // Not needed for single - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - this.documentElement = documentElement; - //-- Single Page - this.spreadWidth = (width + gap); - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnWidth] = width+"px"; - documentElement.style[columnGap] = gap+"px"; - this.colWidth = width; - this.gap = gap; - - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.Reflowable.prototype.calculatePages = function() { - var totalWidth, displayedPages; - this.documentElement.style.width = "auto"; //-- reset width for calculations - totalWidth = this.documentElement.scrollWidth; - displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - return { - displayedPages : displayedPages, - pageCount : displayedPages - }; -}; - -EPUBJS.Layout.ReflowableSpreads = function(){ - this.documentElement = null; - this.spreadWidth = null; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.format = function(documentElement, _width, _height, _gap){ - var columnAxis = EPUBJS.core.prefixed('columnAxis'); - var columnGap = EPUBJS.core.prefixed('columnGap'); - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var columnFill = EPUBJS.core.prefixed('columnFill'); - - var divisor = 2, - cutoff = 800; - - //-- Check the width and create even width columns - var fullWidth = Math.floor(_width); - var width = (fullWidth % 2 === 0) ? fullWidth : fullWidth - 1; - - var section = Math.floor(width / 8); - var gap = (_gap >= 0) ? _gap : ((section % 2 === 0) ? section : section - 1); - - //-- Double Page - var colWidth = Math.floor((width - gap) / divisor); - - this.documentElement = documentElement; - this.spreadWidth = (colWidth + gap) * divisor; - - - documentElement.style.overflow = "hidden"; - - // Must be set to the new calculated width or the columns will be off - documentElement.style.width = width + "px"; - - //-- Adjust height - documentElement.style.height = _height + "px"; - - //-- Add columns - documentElement.style[columnAxis] = "horizontal"; - documentElement.style[columnFill] = "auto"; - documentElement.style[columnGap] = gap+"px"; - documentElement.style[columnWidth] = colWidth+"px"; - - this.colWidth = colWidth; - this.gap = gap; - return { - pageWidth : this.spreadWidth, - pageHeight : _height - }; -}; - -EPUBJS.Layout.ReflowableSpreads.prototype.calculatePages = function() { - var totalWidth = this.documentElement.scrollWidth; - var displayedPages = Math.ceil(totalWidth / this.spreadWidth); - - //-- Add a page to the width of the document to account an for odd number of pages - this.documentElement.style.width = ((displayedPages * this.spreadWidth) - this.gap) + "px"; - - return { - displayedPages : displayedPages, - pageCount : displayedPages * 2 - }; -}; - -EPUBJS.Layout.Fixed = function(){ - this.documentElement = null; -}; - -EPUBJS.Layout.Fixed.prototype.format = function(documentElement, _width, _height, _gap){ - var columnWidth = EPUBJS.core.prefixed('columnWidth'); - var viewport = documentElement.querySelector("[name=viewport"); - var content; - var contents; - var width, height; - this.documentElement = documentElement; - /** - * check for the viewport size - * - */ - if(viewport && viewport.hasAttribute("content")) { - content = viewport.getAttribute("content"); - contents = content.split(','); - if(contents[0]){ - width = contents[0].replace("width=", ''); - } - if(contents[1]){ - height = contents[1].replace("height=", ''); - } - } - - //-- Adjust width and height - documentElement.style.width = width + "px" || "auto"; - documentElement.style.height = height + "px" || "auto"; - - //-- Remove columns - documentElement.style[columnWidth] = "auto"; - - //-- Scroll - documentElement.style.overflow = "auto"; - - this.colWidth = width; - this.gap = 0; - - return { - pageWidth : width, - pageHeight : height - }; - -}; - -EPUBJS.Layout.Fixed.prototype.calculatePages = function(){ - return { - displayedPages : 1, - pageCount : 1 - }; -}; - -EPUBJS.Pagination = function(pageList) { - this.pages = []; - this.locations = []; - this.epubcfi = new EPUBJS.EpubCFI(); - if(pageList && pageList.length) { - this.process(pageList); - } -}; - -EPUBJS.Pagination.prototype.process = function(pageList){ - pageList.forEach(function(item){ - this.pages.push(item.page); - this.locations.push(item.cfi); - }, this); - - this.pageList = pageList; - this.firstPage = parseInt(this.pages[0]); - this.lastPage = parseInt(this.pages[this.pages.length-1]); - this.totalPages = this.lastPage - this.firstPage; -}; - -EPUBJS.Pagination.prototype.pageFromCfi = function(cfi){ - var pg = -1; - - // Check if the pageList has not been set yet - if(this.locations.length === 0) { - return -1; - } - - // TODO: check if CFI is valid? - - // check if the cfi is in the location list - // var index = this.locations.indexOf(cfi); - var index = EPUBJS.core.indexOfSorted(cfi, this.locations, this.epubcfi.compare); - if(index != -1 && index < (this.pages.length-1) ) { - pg = this.pages[index]; - } else { - // Otherwise add it to the list of locations - // Insert it in the correct position in the locations page - //index = EPUBJS.core.insert(cfi, this.locations, this.epubcfi.compare); - index = EPUBJS.core.locationOf(cfi, this.locations, this.epubcfi.compare); - // Get the page at the location just before the new one, or return the first - pg = index-1 >= 0 ? this.pages[index-1] : this.pages[0]; - if(pg !== undefined) { - // Add the new page in so that the locations and page array match up - //this.pages.splice(index, 0, pg); - } else { - pg = -1; - } - - } - return pg; -}; - -EPUBJS.Pagination.prototype.cfiFromPage = function(pg){ - var cfi = -1; - // check that pg is an int - if(typeof pg != "number"){ - pg = parseInt(pg); - } - - // check if the cfi is in the page list - // Pages could be unsorted. - var index = this.pages.indexOf(pg); - if(index != -1) { - cfi = this.locations[index]; - } - // TODO: handle pages not in the list - return cfi; -}; - -EPUBJS.Pagination.prototype.pageFromPercentage = function(percent){ - var pg = Math.round(this.totalPages * percent); - return pg; -}; - -// Returns a value between 0 - 1 corresponding to the location of a page -EPUBJS.Pagination.prototype.percentageFromPage = function(pg){ - var percentage = (pg - this.firstPage) / this.totalPages; - return Math.round(percentage * 1000) / 1000; -}; - -// Returns a value between 0 - 1 corresponding to the location of a cfi -EPUBJS.Pagination.prototype.percentageFromCfi = function(cfi){ - var pg = this.pageFromCfi(cfi); - var percentage = this.percentageFromPage(pg); - return percentage; -}; -EPUBJS.Parser = function(baseUrl){ - this.baseUrl = baseUrl || ''; -}; - -EPUBJS.Parser.prototype.container = function(containerXml){ - //-- - var rootfile, fullpath, folder, encoding; - - if(!containerXml) { - console.error("Container File Not Found"); - return; - } - - rootfile = containerXml.querySelector("rootfile"); - - if(!rootfile) { - console.error("No RootFile Found"); - return; - } - - fullpath = rootfile.getAttribute('full-path'); - folder = EPUBJS.core.uri(fullpath).directory; - encoding = containerXml.xmlEncoding; - - //-- Now that we have the path we can parse the contents - return { - 'packagePath' : fullpath, - 'basePath' : folder, - 'encoding' : encoding - }; -}; - -EPUBJS.Parser.prototype.identifier = function(packageXml){ - var metadataNode; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - return this.getElementText(metadataNode, "identifier"); -}; - -EPUBJS.Parser.prototype.packageContents = function(packageXml, baseUrl){ - var parse = this; - var metadataNode, manifestNode, spineNode; - var manifest, navPath, tocPath, coverPath; - var spineNodeIndex; - var spine; - var spineIndexByURL; - - if(baseUrl) this.baseUrl = baseUrl; - - if(!packageXml) { - console.error("Package File Not Found"); - return; - } - - metadataNode = packageXml.querySelector("metadata"); - if(!metadataNode) { - console.error("No Metadata Found"); - return; - } - - manifestNode = packageXml.querySelector("manifest"); - if(!manifestNode) { - console.error("No Manifest Found"); - return; - } - - spineNode = packageXml.querySelector("spine"); - if(!spineNode) { - console.error("No Spine Found"); - return; - } - - manifest = parse.manifest(manifestNode); - navPath = parse.findNavPath(manifestNode); - tocPath = parse.findTocPath(manifestNode, spineNode); - coverPath = parse.findCoverPath(manifestNode); - - spineNodeIndex = Array.prototype.indexOf.call(spineNode.parentNode.childNodes, spineNode); - - spine = parse.spine(spineNode, manifest); - - spineIndexByURL = {}; - spine.forEach(function(item){ - spineIndexByURL[item.href] = item.index; - }); - - return { - 'metadata' : parse.metadata(metadataNode), - 'spine' : spine, - 'manifest' : manifest, - 'navPath' : navPath, - 'tocPath' : tocPath, - 'coverPath': coverPath, - 'spineNodeIndex' : spineNodeIndex, - 'spineIndexByURL' : spineIndexByURL - }; -}; - -//-- Find TOC NAV -EPUBJS.Parser.prototype.findNavPath = function(manifestNode){ - // Find item with property 'nav' - // Should catch nav irregardless of order - var node = manifestNode.querySelector("item[properties$='nav'], item[properties^='nav '], item[properties*=' nav ']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Find TOC NCX: media-type="application/x-dtbncx+xml" href="toc.ncx" -EPUBJS.Parser.prototype.findTocPath = function(manifestNode, spineNode){ - var node = manifestNode.querySelector("item[media-type='application/x-dtbncx+xml']"); - var tocId; - - // If we can't find the toc by media-type then try to look for id of the item in the spine attributes as - // according to http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.4.1.2, - // "The item that describes the NCX must be referenced by the spine toc attribute." - if (!node) { - tocId = spineNode.getAttribute("toc"); - if(tocId) { - node = manifestNode.querySelector("item[id='" + tocId + "']"); - } - } - - return node ? node.getAttribute('href') : false; -}; - -//-- Find Cover: -EPUBJS.Parser.prototype.findCoverPath = function(manifestNode){ - var node = manifestNode.querySelector("item[properties='cover-image']"); - return node ? node.getAttribute('href') : false; -}; - -//-- Expanded to match Readium web components -EPUBJS.Parser.prototype.metadata = function(xml){ - var metadata = {}, - p = this; - - metadata.bookTitle = p.getElementText(xml, 'title'); - metadata.creator = p.getElementText(xml, 'creator'); - metadata.description = p.getElementText(xml, 'description'); - - metadata.pubdate = p.getElementText(xml, 'date'); - - metadata.publisher = p.getElementText(xml, 'publisher'); - - metadata.identifier = p.getElementText(xml, "identifier"); - metadata.language = p.getElementText(xml, "language"); - metadata.rights = p.getElementText(xml, "rights"); - - metadata.modified_date = p.querySelectorText(xml, "meta[property='dcterms:modified']"); - metadata.layout = p.querySelectorText(xml, "meta[property='rendition:layout']"); - metadata.orientation = p.querySelectorText(xml, "meta[property='rendition:orientation']"); - metadata.spread = p.querySelectorText(xml, "meta[property='rendition:spread']"); - // metadata.page_prog_dir = packageXml.querySelector("spine").getAttribute("page-progression-direction"); - - return metadata; -}; - -EPUBJS.Parser.prototype.getElementText = function(xml, tag){ - var found = xml.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/", tag), - el; - - if(!found || found.length === 0) return ''; - - el = found[0]; - - if(el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; - -}; - -EPUBJS.Parser.prototype.querySelectorText = function(xml, q){ - var el = xml.querySelector(q); - - if(el && el.childNodes.length){ - return el.childNodes[0].nodeValue; - } - - return ''; -}; - -EPUBJS.Parser.prototype.manifest = function(manifestXml){ - var baseUrl = this.baseUrl, - manifest = {}; - - //-- Turn items into an array - var selected = manifestXml.querySelectorAll("item"), - items = Array.prototype.slice.call(selected); - - //-- Create an object with the id as key - items.forEach(function(item){ - var id = item.getAttribute('id'), - href = item.getAttribute('href') || '', - type = item.getAttribute('media-type') || '', - properties = item.getAttribute('properties') || ''; - - manifest[id] = { - 'href' : href, - 'url' : baseUrl + href, //-- Absolute URL for loading with a web worker - 'type' : type, - 'properties' : properties - }; - - }); - - return manifest; - -}; - -EPUBJS.Parser.prototype.spine = function(spineXml, manifest){ - var spine = []; - - var selected = spineXml.getElementsByTagName("itemref"), - items = Array.prototype.slice.call(selected); - - var spineNodeIndex = Array.prototype.indexOf.call(spineXml.parentNode.childNodes, spineXml); - - var epubcfi = new EPUBJS.EpubCFI(); - - //-- Add to array to mantain ordering and cross reference with manifest - items.forEach(function(item, index){ - var Id = item.getAttribute('idref'); - var cfiBase = epubcfi.generateChapterComponent(spineNodeIndex, index, Id); - var props = item.getAttribute('properties') || ''; - var propArray = props.length ? props.split(' ') : []; - var manifestProps = manifest[Id].properties; - var manifestPropArray = manifestProps.length ? manifestProps.split(' ') : []; - var vert = { - 'id' : Id, - 'linear' : item.getAttribute('linear') || '', - 'properties' : propArray, - 'manifestProperties' : manifestPropArray, - 'href' : manifest[Id].href, - 'url' : manifest[Id].url, - 'index' : index, - 'cfiBase' : cfiBase, - 'cfi' : "epub(" + cfiBase + ")" - }; - spine.push(vert); - }); - - return spine; -}; - -EPUBJS.Parser.prototype.nav = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="toc"]'), //-- [*|type="toc"] * Doesn't seem to work - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getTOC(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - split = href.split("#"), - baseUrl = split[0], - subitems = getTOC(item), - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - item.setAttribute('id', id); // Ensure all elements have an id - list.push({ - "id": id, - "href": href, - "label": text, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - }); - - return list; - } - - return getTOC(navEl); -}; - -EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){ - var navMap = tocXml.querySelector("navMap"); - if(!navMap) return []; - - function getTOC(parent){ - var list = [], - snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), - length = snapshot.snapshotLength; - - if(length === 0) return []; - - for ( var i=length-1 ; i >= 0; i-- ) { - var item = snapshot.snapshotItem(i); - - var id = item.getAttribute('id') || false, - content = item.querySelector("content"), - src = content.getAttribute('src'), - navLabel = item.querySelector("navLabel"), - text = navLabel.textContent ? navLabel.textContent : "", - split = src.split("#"), - baseUrl = split[0], - spinePos = spineIndexByURL[baseUrl], - spineItem = bookSpine[spinePos], - subitems = getTOC(item), - cfi = spineItem ? spineItem.cfi : ''; - - if(!id) { - if(spinePos) { - spineItem = bookSpine[spinePos]; - id = spineItem.id; - cfi = spineItem.cfi; - } else { - id = 'epubjs-autogen-toc-id-' + (idCounter++); - } - } - - list.unshift({ - "id": id, - "href": src, - "label": text, - "spinePos": spinePos, - "subitems" : subitems, - "parent" : parent ? parent.getAttribute('id') : null, - "cfi" : cfi - }); - - } - - return list; - } - - return getTOC(navMap); -}; - -EPUBJS.Parser.prototype.pageList = function(navHtml, spineIndexByURL, bookSpine){ - var navEl = navHtml.querySelector('nav[*|type="page-list"]'), - idCounter = 0; - - if(!navEl) return []; - - // Implements `> ol > li` - function findListItems(parent){ - var items = []; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('ol' == node.tagName){ - Array.prototype.slice.call(node.childNodes).forEach(function(item){ - if('li' == item.tagName){ - items.push(item); - } - }); - } - }); - - return items; - - } - - // Implements `> a, > span` - function findAnchorOrSpan(parent){ - var item = null; - - Array.prototype.slice.call(parent.childNodes).forEach(function(node){ - if('a' == node.tagName || 'span' == node.tagName){ - item = node; - } - }); - - return item; - } - - function getPages(parent){ - var list = [], - nodes = findListItems(parent), - items = Array.prototype.slice.call(nodes), - length = items.length, - node; - - if(length === 0) return false; - - items.forEach(function(item){ - var id = item.getAttribute('id') || false, - content = findAnchorOrSpan(item), - href = content.getAttribute('href') || '', - text = content.textContent || "", - page = parseInt(text), - isCfi = href.indexOf("epubcfi"), - split, - packageUrl, - cfi; - - if(isCfi != -1) { - split = href.split("#"); - packageUrl = split[0]; - cfi = split.length > 1 ? split[1] : false; - list.push({ - "cfi" : cfi, - "href" : href, - "packageUrl" : packageUrl, - "page" : page - }); - } else { - list.push({ - "href" : href, - "page" : page - }); - } - - }); - - return list; - } - - return getPages(navEl); -}; - -EPUBJS.Render.Iframe = function() { - this.iframe = null; - this.document = null; - this.window = null; - this.docEl = null; - this.bodyEl = null; - - this.leftPos = 0; - this.pageWidth = 0; -}; - -//-- Build up any html needed -EPUBJS.Render.Iframe.prototype.create = function(){ - this.iframe = document.createElement('iframe'); - this.iframe.id = "epubjs-iframe:" + EPUBJS.core.uuid(); - this.iframe.scrolling = "no"; - this.iframe.seamless = "seamless"; - // Back up if seamless isn't supported - this.iframe.style.border = "none"; - - this.iframe.addEventListener("load", this.loaded.bind(this), false); - return this.iframe; -}; - -/** -* Sets the source of the iframe with the given URL string -* Takes: URL string -* Returns: promise with document element -*/ -EPUBJS.Render.Iframe.prototype.load = function(chapter){ - var render = this, - deferred = new RSVP.defer(); - - chapter.url().then(function(url){ - // Reset the scroll position - render.leftPos = 0; - - if(this.window) { - this.unload(); - } - - this.iframe.onload = function(e) { - render.document = render.iframe.contentDocument; - render.docEl = render.document.documentElement; - render.headEl = render.document.head; - render.bodyEl = render.document.body || render.document.querySelector("body"); - render.window = render.iframe.contentWindow; - - render.window.addEventListener("resize", render.resized.bind(render), false); - - //-- Clear Margins - if(render.bodyEl) { - render.bodyEl.style.margin = "0"; - } - - deferred.resolve(render.docEl); - }; - - this.iframe.onerror = function(e) { - //console.error("Error Loading Contents", e); - deferred.reject({ - message : "Error Loading Contents: " + e, - stack : new Error().stack - }); - }; - - this.iframe.contentWindow.location.replace(url); - - }.bind(this)); - - return deferred.promise; -}; - - -EPUBJS.Render.Iframe.prototype.loaded = function(v){ - var url = this.iframe.contentWindow.location.href; - if(url != "about:blank"){ - this.trigger("render:loaded", url); - } -}; - -// Resize the iframe to the given width and height -EPUBJS.Render.Iframe.prototype.resize = function(width, height){ - var iframeBox; - - if(!this.iframe) return; - - this.iframe.height = height; - - if(!isNaN(width) && width % 2 !== 0){ - width += 1; //-- Prevent cutting off edges of text in columns - } - - this.iframe.width = width; - // Get the fractional height and width of the iframe - // Default to orginal if bounding rect is 0 - this.width = this.iframe.getBoundingClientRect().width || width; - this.height = this.iframe.getBoundingClientRect().height || height; -}; - - -EPUBJS.Render.Iframe.prototype.resized = function(e){ - // Get the fractional height and width of the iframe - this.width = this.iframe.getBoundingClientRect().width; - this.height = this.iframe.getBoundingClientRect().height; -}; - -EPUBJS.Render.Iframe.prototype.totalWidth = function(){ - return this.docEl.scrollWidth; -}; - -EPUBJS.Render.Iframe.prototype.totalHeight = function(){ - return this.docEl.scrollHeight; -}; - -EPUBJS.Render.Iframe.prototype.setPageDimensions = function(pageWidth, pageHeight){ - this.pageWidth = pageWidth; - this.pageHeight = pageHeight; - //-- Add a page to the width of the document to account an for odd number of pages - // this.docEl.style.width = this.docEl.scrollWidth + pageWidth + "px"; -}; - -EPUBJS.Render.Iframe.prototype.setLeft = function(leftPos){ - // this.bodyEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style.marginLeft = -leftPos + "px"; - // this.docEl.style[EPUBJS.Render.Iframe.transform] = 'translate('+ (-leftPos) + 'px, 0)'; - this.document.defaultView.scrollTo(leftPos, 0); -}; - -EPUBJS.Render.Iframe.prototype.setStyle = function(style, val, prefixed){ - if(prefixed) { - style = EPUBJS.core.prefixed(style); - } - - if(this.bodyEl) this.bodyEl.style[style] = val; -}; - -EPUBJS.Render.Iframe.prototype.removeStyle = function(style){ - - if(this.bodyEl) this.bodyEl.style[style] = ''; - -}; - -EPUBJS.Render.Iframe.prototype.addHeadTag = function(tag, attrs, _doc) { - var doc = _doc || this.document; - var tagEl = doc.createElement(tag); - var headEl = doc.head; - - for(var attr in attrs) { - tagEl.setAttribute(attr, attrs[attr]); - } - - if(headEl) headEl.insertBefore(tagEl, headEl.firstChild); -}; - -EPUBJS.Render.Iframe.prototype.page = function(pg){ - this.leftPos = this.pageWidth * (pg-1); //-- pages start at 1 - this.setLeft(this.leftPos); -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByElement = function(el){ - var left, pg; - if(!el) return; - - left = this.leftPos + el.getBoundingClientRect().left; //-- Calculate left offset compaired to scrolled position - - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -//-- Show the page containing an Element -EPUBJS.Render.Iframe.prototype.getPageNumberByRect = function(boundingClientRect){ - var left, pg; - - left = this.leftPos + boundingClientRect.left; //-- Calculate left offset compaired to scrolled position - pg = Math.floor(left / this.pageWidth) + 1; //-- pages start at 1 - - return pg; -}; - -// Return the root element of the content -EPUBJS.Render.Iframe.prototype.getBaseElement = function(){ - return this.bodyEl; -}; - -// Checks if an element is on the screen -EPUBJS.Render.Iframe.prototype.isElementVisible = function(el){ - var rect; - var left; - - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - left = rect.left; //+ rect.width; - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - left >= 0 && - left < this.pageWidth ) { - return true; - } - } - - return false; -}; - - -EPUBJS.Render.Iframe.prototype.scroll = function(bool){ - if(bool) { - this.iframe.scrolling = "yes"; - } else { - this.iframe.scrolling = "no"; - } -}; - -// Cleanup event listeners -EPUBJS.Render.Iframe.prototype.unload = function(){ - this.window.removeEventListener("resize", this.resized); -}; - -//-- Enable binding events to Render -RSVP.EventTarget.mixin(EPUBJS.Render.Iframe.prototype); -EPUBJS.Renderer = function(renderMethod, hidden) { - // Dom events to listen for - this.listenedEvents = ["keydown", "keyup", "keypressed", "mouseup", "mousedown", "click"]; - this.upEvent = "mouseup"; - this.downEvent = "mousedown"; - if('ontouchstart' in document.documentElement) { - this.listenedEvents.push("touchstart", "touchend"); - this.upEvent = "touchend"; - this.downEvent = "touchstart"; - } - /** - * Setup a render method. - * Options are: Iframe - */ - if(renderMethod && typeof(EPUBJS.Render[renderMethod]) != "undefined"){ - this.render = new EPUBJS.Render[renderMethod](); - } else { - console.error("Not a Valid Rendering Method"); - } - - // Listen for load events - this.render.on("render:loaded", this.loaded.bind(this)); - - // Cached for replacement urls from storage - this.caches = {}; - - // Blank Cfi for Parsing - this.epubcfi = new EPUBJS.EpubCFI(); - - this.spreads = true; - this.isForcedSingle = false; - this.resized = _.debounce(this.onResized.bind(this), 100); - - this.layoutSettings = {}; - - this.hidden = hidden || false; - //-- Adds Hook methods to the Book prototype - // Hooks will all return before triggering the callback. - EPUBJS.Hooks.mixin(this); - //-- Get pre-registered hooks for events - this.getHooks("beforeChapterDisplay"); - - //-- Queue up page changes if page map isn't ready - this._q = EPUBJS.core.queue(this); - - this._moving = false; - -}; - -//-- Renderer events for listening -EPUBJS.Renderer.prototype.Events = [ - "renderer:keydown", - "renderer:keyup", - "renderer:keypressed", - "renderer:mouseup", - "renderer:mousedown", - "renderer:click", - "renderer:touchstart", - "renderer:touchend", - "renderer:selected", - "renderer:chapterUnloaded", - "renderer:chapterDisplayed", - "renderer:locationChanged", - "renderer:visibleLocationChanged", - "renderer:resized", - "renderer:spreads" -]; - -/** -* Creates an element to render to. -* Resizes to passed width and height or to the elements size -*/ -EPUBJS.Renderer.prototype.initialize = function(element, width, height){ - this.container = element; - this.element = this.render.create(); - - this.initWidth = width; - this.initHeight = height; - - this.width = width || this.container.clientWidth; - this.height = height || this.container.clientHeight; - - this.container.appendChild(this.element); - - if(width && height){ - this.render.resize(this.width, this.height); - } else { - this.render.resize('100%', '100%'); - } - - document.addEventListener("orientationchange", this.onResized); -}; - -/** -* Display a chapter -* Takes: chapter object, global layout settings -* Returns: Promise with passed Renderer after pages has loaded -*/ -EPUBJS.Renderer.prototype.displayChapter = function(chapter, globalLayout){ - var store = false; - if(this._moving) { - console.error("Rendering In Progress"); - return; - } - this._moving = true; - // Get the url string from the chapter (may be from storage) - return chapter.url(). - then(function(url) { - - // Unload the previous chapter listener - if(this.currentChapter) { - this.currentChapter.unload(); // Remove stored blobs - - if(this.render.window){ - this.render.window.removeEventListener("resize", this.resized); - } - - this.removeEventListeners(); - this.removeSelectionListeners(); - this.trigger("renderer:chapterUnloaded"); - this.contents = null; - this.doc = null; - this.pageMap = null; - } - - this.currentChapter = chapter; - this.chapterPos = 1; - this.currentChapterCfiBase = chapter.cfiBase; - - this.layoutSettings = this.reconcileLayoutSettings(globalLayout, chapter.properties); - return this.load(chapter); - - }.bind(this)); - -}; - -/** -* Loads a url (string) and renders it, -* attaching event listeners and triggering hooks. -* Returns: Promise with the rendered contents. -*/ - -EPUBJS.Renderer.prototype.load = function(url){ - var deferred = new RSVP.defer(); - var loaded; - - // Switch to the required layout method for the settings - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - - this.visible(false); - - render = this.render.load(url); - - render.then(function(contents) { - var formated; - this.currentChapter.setDocument(this.render.document); - this.contents = contents; - this.doc = this.render.document; - - // Format the contents using the current layout method - this.formated = this.layout.format(contents, this.render.width, this.render.height, this.gap); - this.render.setPageDimensions(this.formated.pageWidth, this.formated.pageHeight); - - // window.addEventListener("orientationchange", this.onResized.bind(this), false); - if(!this.initWidth && !this.initHeight){ - this.render.window.addEventListener("resize", this.resized, false); - } - - this.addEventListeners(); - this.addSelectionListeners(); - - //-- Trigger registered hooks before displaying - this.beforeDisplay(function(){ - var pages = this.layout.calculatePages(); - var msg = this.currentChapter; - var queued = this._q.length(); - this._moving = false; - - this.updatePages(pages); - - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - - if(queued === 0) { - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - } - - msg.cfi = this.currentLocationCfi; //TODO: why is this cfi passed to chapterDisplayed - this.trigger("renderer:chapterDisplayed", msg); - - this.visible(true); - - deferred.resolve(this); //-- why does this return the renderer? - }.bind(this)); - - }.bind(this)); - - return deferred.promise; -}; - -EPUBJS.Renderer.prototype.loaded = function(url){ - this.trigger("render:loaded", url); - // var uri = EPUBJS.core.uri(url); - // var relative = uri.path.replace(book.bookUrl, ''); - // console.log(url, uri, relative); -}; - -/** -* Reconciles the current chapters layout properies with -* the global layout properities. -* Takes: global layout settings object, chapter properties string -* Returns: Object with layout properties -*/ -EPUBJS.Renderer.prototype.reconcileLayoutSettings = function(global, chapter){ - var settings = {}; - - //-- Get the global defaults - for (var attr in global) { - if (global.hasOwnProperty(attr)){ - settings[attr] = global[attr]; - } - } - //-- Get the chapter's display type - chapter.forEach(function(prop){ - var rendition = prop.replace("rendition:", ''); - var split = rendition.indexOf("-"); - var property, value; - - if(split != -1){ - property = rendition.slice(0, split); - value = rendition.slice(split+1); - - settings[property] = value; - } - }); - return settings; -}; - -/** -* Uses the settings to determine which Layout Method is needed -* Triggers events based on the method choosen -* Takes: Layout settings object -* Returns: String of appropriate for EPUBJS.Layout function -*/ -EPUBJS.Renderer.prototype.determineLayout = function(settings){ - // Default is layout: reflowable & spread: auto - var spreads = this.determineSpreads(this.minSpreadWidth); - var layoutMethod = spreads ? "ReflowableSpreads" : "Reflowable"; - var scroll = false; - - if(settings.layout === "pre-paginated") { - layoutMethod = "Fixed"; - scroll = true; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "none") { - layoutMethod = "Reflowable"; - scroll = false; - spreads = false; - } - - if(settings.layout === "reflowable" && settings.spread === "both") { - layoutMethod = "ReflowableSpreads"; - scroll = false; - spreads = true; - } - - this.spreads = spreads; - this.render.scroll(scroll); - this.trigger("renderer:spreads", spreads); - return layoutMethod; -}; - -// Shortcut to trigger the hook before displaying the chapter -EPUBJS.Renderer.prototype.beforeDisplay = function(callback, renderer){ - this.triggerHooks("beforeChapterDisplay", callback, this); -}; - -// Update the renderer with the information passed by the layout -EPUBJS.Renderer.prototype.updatePages = function(layout){ - this.pageMap = this.mapPage(); - // this.displayedPages = layout.displayedPages; - - if (this.spreads) { - this.displayedPages = Math.ceil(this.pageMap.length / 2); - } else { - this.displayedPages = this.pageMap.length; - } - - // this.currentChapter.pages = layout.pageCount; - this.currentChapter.pages = this.pageMap.length; - - this._q.flush(); -}; - -// Apply the layout again and jump back to the previous cfi position -EPUBJS.Renderer.prototype.reformat = function(){ - var renderer = this; - var formated, pages; - if(!this.contents) return; - - spreads = this.determineSpreads(this.minSpreadWidth); - - // Only re-layout if the spreads have switched - if(spreads != this.spreads){ - this.spreads = spreads; - this.layoutMethod = this.determineLayout(this.layoutSettings); - this.layout = new EPUBJS.Layout[this.layoutMethod](); - } - - // Reset pages - this.chapterPos = 1; - this.render.page(1); - - // Give the css styles time to update - // clearTimeout(this.timeoutTillCfi); - // this.timeoutTillCfi = setTimeout(function(){ - - renderer.formated = renderer.layout.format(renderer.contents, renderer.render.width, renderer.render.height, renderer.gap); - renderer.render.setPageDimensions(renderer.formated.pageWidth, renderer.formated.pageHeight); - - pages = renderer.layout.calculatePages(); - renderer.updatePages(pages); - - //-- Go to current page after formating - if(renderer.currentLocationCfi){ - renderer.gotoCfi(renderer.currentLocationCfi); - } - // renderer.timeoutTillCfi = null; - -}; - -// Hide and show the render's container . -EPUBJS.Renderer.prototype.visible = function(bool){ - if(typeof(bool) === "undefined") { - return this.element.style.visibility; - } - - if(bool === true && !this.hidden){ - this.element.style.visibility = "visible"; - }else if(bool === false){ - this.element.style.visibility = "hidden"; - } -}; - -// Remove the render element and clean up listeners -EPUBJS.Renderer.prototype.remove = function() { - if(this.render.window) { - this.render.unload(); - this.render.window.removeEventListener("resize", this.resized); - this.removeEventListeners(); - this.removeSelectionListeners(); - } - - this.container.removeChild(this.element); -}; - -//-- STYLES - -EPUBJS.Renderer.prototype.applyStyles = function(styles) { - for (var style in styles) { - this.render.setStyle(style, styles[style]); - } -}; - -EPUBJS.Renderer.prototype.setStyle = function(style, val, prefixed){ - this.render.setStyle(style, val, prefixed); -}; - -EPUBJS.Renderer.prototype.removeStyle = function(style){ - this.render.removeStyle(style); -}; - -//-- HEAD TAGS -EPUBJS.Renderer.prototype.applyHeadTags = function(headTags) { - for ( var headTag in headTags ) { - this.render.addHeadTag(headTag, headTags[headTag]); - } -}; - -//-- NAVIGATION - -EPUBJS.Renderer.prototype.page = function(pg){ - if(!this.pageMap) { - console.warn("pageMap not set, queuing"); - this._q.enqueue("page", arguments); - return true; - } - - if(pg >= 1 && pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - this.visibleRangeCfi = this.getVisibleRangeCfi(); - this.currentLocationCfi = this.visibleRangeCfi.start; - this.trigger("renderer:locationChanged", this.currentLocationCfi); - this.trigger("renderer:visibleRangeChanged", this.visibleRangeCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; - -// Short cut to find next page's cfi starting at the last visible element -/* -EPUBJS.Renderer.prototype.nextPage = function(){ - var pg = this.chapterPos + 1; - if(pg <= this.displayedPages){ - this.chapterPos = pg; - - this.render.page(pg); - - this.currentLocationCfi = this.getPageCfi(this.visibileEl); - this.trigger("renderer:locationChanged", this.currentLocationCfi); - - return true; - } - //-- Return false if page is greater than the total - return false; -}; -*/ -EPUBJS.Renderer.prototype.nextPage = function(){ - return this.page(this.chapterPos + 1); -}; - -EPUBJS.Renderer.prototype.prevPage = function(){ - return this.page(this.chapterPos - 1); -}; - -//-- Show the page containing an Element -EPUBJS.Renderer.prototype.pageByElement = function(el){ - var pg; - if(!el) return; - - pg = this.render.getPageNumberByElement(el); - this.page(pg); -}; - -// Jump to the last page of the chapter -EPUBJS.Renderer.prototype.lastPage = function(){ - if(this._moving) { - return this._q.enqueue("lastPage", arguments); - } - - this.page(this.displayedPages); -}; - -// Jump to the first page of the chapter -EPUBJS.Renderer.prototype.firstPage = function(){ - this.page(1); -}; - -//-- Find a section by fragement id -EPUBJS.Renderer.prototype.section = function(fragment){ - var el = this.doc.getElementById(fragment), - left, pg; - - if(el){ - this.pageByElement(el); - } - -}; - -EPUBJS.Renderer.prototype.firstElementisTextNode = function(node) { - var children = node.childNodes; - var leng = children.length; - - if(leng && - children[0] && // First Child - children[0].nodeType === 3 && // This is a textNodes - children[0].textContent.trim().length) { // With non whitespace or return charecters - return true; - } - return false; -}; - -// Walk the node tree from a start element to next visible element -EPUBJS.Renderer.prototype.walk = function(node, x, y) { - var r, children, leng, - startNode = node, - prevNode, - stack = [startNode]; - - var STOP = 10000, ITER=0; - - while(!r && stack.length) { - node = stack.shift(); - if( this.containsPoint(node, x, y) && this.firstElementisTextNode(node)) { - r = node; - } - - if(!r && node && node.childElementCount > 0){ - children = node.children; - if (children && children.length) { - leng = children.length ? children.length : 0; - } else { - return r; - } - for (var i = leng-1; i >= 0; i--) { - if(children[i] != prevNode) stack.unshift(children[i]); - } - } - - if(!r && stack.length === 0 && startNode && startNode.parentNode !== null){ - stack.push(startNode.parentNode); - prevNode = startNode; - startNode = startNode.parentNode; - } - - - ITER++; - if(ITER > STOP) { - console.error("ENDLESS LOOP"); - break; - } - - } - - return r; -}; - -// Checks if an element is on the screen -EPUBJS.Renderer.prototype.containsPoint = function(el, x, y){ - var rect; - var left; - if(el && typeof el.getBoundingClientRect === 'function'){ - rect = el.getBoundingClientRect(); - // console.log(el, rect, x, y); - - if( rect.width !== 0 && - rect.height !== 0 && // Element not visible - rect.left >= x && - x <= rect.left + rect.width) { - return true; - } - } - - return false; -}; - -EPUBJS.Renderer.prototype.textSprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { - acceptNode: function (node) { - if ( ! /^\s*$/.test(node.data) ) { - return NodeFilter.FILTER_ACCEPT; - } else { - return NodeFilter.FILTER_REJECT; - } - } - }, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.sprint = function(root, func) { - var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, false); - var node; - while ((node = treeWalker.nextNode())) { - func(node); - } - -}; - -EPUBJS.Renderer.prototype.mapPage = function(){ - var renderer = this; - var map = []; - var root = this.render.getBaseElement(); - var page = 1; - var width = this.layout.colWidth + this.layout.gap; - var offset = this.formated.pageWidth * (this.chapterPos-1); - var limit = (width * page) - offset;// (width * page) - offset; - var elLimit = 0; - var prevRange; - var cfi; - var check = function(node) { - var elPos; - var elRange; - var children = Array.prototype.slice.call(node.childNodes); - if (node.nodeType == Node.ELEMENT_NODE) { - // elPos = node.getBoundingClientRect(); - elRange = document.createRange(); - elRange.selectNodeContents(node); - elPos = elRange.getBoundingClientRect(); - - if(!elPos || (elPos.width === 0 && elPos.height === 0)) { - return; - } - - //-- Element starts new Col - if(elPos.left > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - - //-- Element Spans new Col - if(elPos.right > elLimit) { - children.forEach(function(node){ - if(node.nodeType == Node.TEXT_NODE && - node.textContent.trim().length) { - checkText(node); - } - }); - } - } - - }; - var checkText = function(node){ - var ranges = renderer.splitTextNodeIntoWordsRanges(node); - ranges.forEach(function(range){ - var pos = range.getBoundingClientRect(); - - if(!pos || (pos.width === 0 && pos.height === 0)) { - return; - } - if(pos.left + pos.width < limit) { - if(!map[page-1]){ - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - // map[page-1].start = cfi; - map.push({ start: cfi, end: null }); - } - } else { - if(prevRange){ - prevRange.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - range.collapse(true); - cfi = renderer.currentChapter.cfiFromRange(range); - map.push({ - start: cfi, - end: null - }); - - page += 1; - limit = (width * page) - offset; - elLimit = limit; - } - - prevRange = range; - }); - - - }; - - this.sprint(root, check); - // this.textSprint(root, checkText); - - if(prevRange){ - prevRange.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(prevRange); - map[map.length-1].end = cfi; - } - - // Handle empty map - if(!map.length) { - range = this.doc.createRange(); - range.selectNodeContents(root); - range.collapse(true); - - cfi = renderer.currentChapter.cfiFromRange(range); - - map.push({ start: cfi, end: cfi }); - - } - - // clean up - prevRange = null; - ranges = null; - range = null; - root = null; - - return map; -}; - - -EPUBJS.Renderer.prototype.indexOfBreakableChar = function (text, startPosition) { - var whiteCharacters = "\x2D\x20\t\r\n\b\f"; - // '-' \x2D - // ' ' \x20 - - if (! startPosition) { - startPosition = 0; - } - - for (var i = startPosition; i < text.length; i++) { - if (whiteCharacters.indexOf(text.charAt(i)) != -1) { - return i; - } - } - - return -1; -}; - - -EPUBJS.Renderer.prototype.splitTextNodeIntoWordsRanges = function(node){ - var ranges = []; - var text = node.textContent.trim(); - var range; - var rect; - var list; - // jaroslaw.bielski@7bulls.com - // Usage of indexOf() function for space character as word delimiter - // is not sufficient in case of other breakable characters like \r\n- etc - pos = this.indexOfBreakableChar(text); - - if(pos === -1) { - range = this.doc.createRange(); - range.selectNodeContents(node); - return [range]; - } - - range = this.doc.createRange(); - range.setStart(node, 0); - range.setEnd(node, pos); - ranges.push(range); - - // jaroslaw.bielski@7bulls.com - // there was a word miss in case of one letter words - range = this.doc.createRange(); - range.setStart(node, pos+1); - - while ( pos != -1 ) { - - pos = this.indexOfBreakableChar(text, pos + 1); - if(pos > 0) { - - if(range) { - range.setEnd(node, pos); - ranges.push(range); - } - - range = this.doc.createRange(); - range.setStart(node, pos+1); - } - } - - if(range) { - range.setEnd(node, text.length); - ranges.push(range); - } - - return ranges; -}; - -EPUBJS.Renderer.prototype.rangePosition = function(range){ - var rect; - var list; - - list = range.getClientRects(); - - if(list.length) { - rect = list[0]; - return rect; - } - - return null; -}; - -/* -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(prevEl){ - var range = this.doc.createRange(); - var position; - // TODO : this might need to take margin / padding into account? - var x = 1;//this.formated.pageWidth/2; - var y = 1;//;this.formated.pageHeight/2; - - range = this.getRange(x, y); - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - - return this.currentChapter.cfiFromRange(range); -}; -*/ - -// Get the cfi of the current page -EPUBJS.Renderer.prototype.getPageCfi = function(){ - var pg; - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - } - return this.pageMap[(this.chapterPos * 2) -1].start; -}; - -EPUBJS.Renderer.prototype.getRange = function(x, y, forceElement){ - var range = this.doc.createRange(); - var position; - forceElement = true; // temp override - if(typeof document.caretPositionFromPoint !== "undefined" && !forceElement){ - position = this.doc.caretPositionFromPoint(x, y); - range.setStart(position.offsetNode, position.offset); - } else if(typeof document.caretRangeFromPoint !== "undefined" && !forceElement){ - range = this.doc.caretRangeFromPoint(x, y); - } else { - this.visibileEl = this.findElementAfter(x, y); - range.setStart(this.visibileEl, 1); - } - - // var test = this.doc.defaultView.getSelection(); - // var r = this.doc.createRange(); - // test.removeAllRanges(); - // r.setStart(range.startContainer, range.startOffset); - // r.setEnd(range.startContainer, range.startOffset + 1); - // test.addRange(r); - return range; -}; - -/* -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(prevEl){ - var startX = 0; - var startY = 0; - var endX = this.width-1; - var endY = this.height-1; - var startRange = this.getRange(startX, startY); - var endRange = this.getRange(endX, endY); //fix if carret not avail - var startCfi = this.currentChapter.cfiFromRange(startRange); - var endCfi; - if(endRange) { - endCfi = this.currentChapter.cfiFromRange(endRange); - } - - return { - start: startCfi, - end: endCfi || false - }; -}; -*/ - -EPUBJS.Renderer.prototype.pagesInCurrentChapter = function() { - var pgs; - var length; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - length = this.pageMap.length; - - if(this.spreads){ - pgs = Math.ceil(length / 2); - } else { - pgs = length; - } - - return pgs; -}; - -EPUBJS.Renderer.prototype.currentRenderedPage = function(){ - var pg; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads && this.layout.pageCount > 1) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - return pg; -}; - -EPUBJS.Renderer.prototype.getRenderedPagesLeft = function(){ - var pg; - var lastPage; - var pagesLeft; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - lastPage = this.pageMap.length; - - if (this.spreads) { - pg = this.chapterPos*2; - } else { - pg = this.chapterPos; - } - - pagesLeft = lastPage - pg; - return pagesLeft; - -}; - -EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(){ - var pg; - var startRange, endRange; - - if(!this.pageMap) { - console.warn("page map not loaded"); - return false; - } - - if (this.spreads) { - pg = this.chapterPos*2; - startRange = this.pageMap[pg-2]; - endRange = startRange; - - if(this.layout.pageCount > 1) { - endRange = this.pageMap[pg-1]; - } - } else { - pg = this.chapterPos; - startRange = this.pageMap[pg-1]; - endRange = startRange; - } - - if(!startRange) { - console.warn("page range miss:", pg, this.pageMap); - startRange = this.pageMap[this.pageMap.length-1]; - endRange = startRange; - } - - return { - start: startRange.start, - end: endRange.end - }; -}; - -// Goto a cfi position in the current chapter -EPUBJS.Renderer.prototype.gotoCfi = function(cfi){ - var pg; - var marker; - var range; - - if(this._moving){ - return this._q.enqueue("gotoCfi", arguments); - } - - if(_.isString(cfi)){ - cfi = this.epubcfi.parse(cfi); - } - - if(typeof document.evaluate === 'undefined') { - marker = this.epubcfi.addMarker(cfi, this.doc); - if(marker) { - pg = this.render.getPageNumberByElement(marker); - // Must Clean up Marker before going to page - this.epubcfi.removeMarker(marker, this.doc); - this.page(pg); - } - } else { - range = this.epubcfi.generateRangeFromCfi(cfi, this.doc); - if(range) { - // jaroslaw.bielski@7bulls.com - // It seems that sometimes getBoundingClientRect() returns null for first page CFI in chapter. - // It is always reproductible if few consecutive chapters have only one page. - // NOTE: This is only workaround and the issue needs an deeper investigation. - // NOTE: Observed on Android 4.2.1 using WebView widget as HTML renderer (Asus TF300T). - var rect = range.getBoundingClientRect(); - if (rect) { - pg = this.render.getPageNumberByRect(rect); - - } else { - // Goto first page in chapter - pg = 1; - } - - this.page(pg); - - // Reset the current location cfi to requested cfi - this.currentLocationCfi = cfi.str; - } - } -}; - -// Walk nodes until a visible element is found -EPUBJS.Renderer.prototype.findFirstVisible = function(startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - // kgolunski@7bulls.com - // Looks like an old API usage - // Set x and y as 0 to fullfill walk method API. - found = this.walk(el, 0, 0); - - if(found) { - return found; - }else{ - return startEl; - } - -}; -// TODO: remove me - unsused -EPUBJS.Renderer.prototype.findElementAfter = function(x, y, startEl){ - var el = startEl || this.render.getBaseElement(); - var found; - found = this.walk(el, x, y); - if(found) { - return found; - }else{ - return el; - } - -}; - -/* -EPUBJS.Renderer.prototype.route = function(hash, callback){ - var location = window.location.hash.replace('#/', ''); - if(this.useHash && location.length && location != this.prevLocation){ - this.show(location, callback); - this.prevLocation = location; - return true; - } - return false; -} - -EPUBJS.Renderer.prototype.hideHashChanges = function(){ - this.useHash = false; -} - -*/ - -EPUBJS.Renderer.prototype.resize = function(width, height, setSize){ - var spreads; - - this.width = width; - this.height = height; - - if(setSize !== false) { - this.render.resize(this.width, this.height); - } - - - - if(this.contents){ - this.reformat(); - } - - this.trigger("renderer:resized", { - width: this.width, - height: this.height - }); -}; - -//-- Listeners for events in the frame - -EPUBJS.Renderer.prototype.onResized = function(e) { - var width = this.container.clientWidth; - var height = this.container.clientHeight; - - this.resize(width, height, false); -}; - -EPUBJS.Renderer.prototype.addEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.addEventListener(eventName, this.triggerEvent.bind(this), false); - }, this); - -}; - -EPUBJS.Renderer.prototype.removeEventListeners = function(){ - if(!this.render.document) { - return; - } - this.listenedEvents.forEach(function(eventName){ - this.render.document.removeEventListener(eventName, this.triggerEvent, false); - }, this); - -}; - -// Pass browser events -EPUBJS.Renderer.prototype.triggerEvent = function(e){ - this.trigger("renderer:"+e.type, e); -}; - -EPUBJS.Renderer.prototype.addSelectionListeners = function(){ - this.render.document.addEventListener("selectionchange", this.onSelectionChange.bind(this), false); -}; - -EPUBJS.Renderer.prototype.removeSelectionListeners = function(){ - if(!this.render.document) { - return; - } - this.doc.removeEventListener("selectionchange", this.onSelectionChange, false); -}; - -EPUBJS.Renderer.prototype.onSelectionChange = function(e){ - if (this.selectionEndTimeout) { - clearTimeout(this.selectionEndTimeout); - } - this.selectionEndTimeout = setTimeout(function() { - this.selectedRange = this.render.window.getSelection(); - this.trigger("renderer:selected", this.selectedRange); - }.bind(this), 500); -}; - - -//-- Spreads - -EPUBJS.Renderer.prototype.setMinSpreadWidth = function(width){ - this.minSpreadWidth = width; - this.spreads = this.determineSpreads(width); -}; - -EPUBJS.Renderer.prototype.determineSpreads = function(cutoff){ - if(this.isForcedSingle || !cutoff || this.width < cutoff) { - return false; //-- Single Page - }else{ - return true; //-- Double Page - } -}; - -EPUBJS.Renderer.prototype.forceSingle = function(bool){ - if(bool) { - this.isForcedSingle = true; - // this.spreads = false; - } else { - this.isForcedSingle = false; - // this.spreads = this.determineSpreads(this.minSpreadWidth); - } -}; - -EPUBJS.Renderer.prototype.setGap = function(gap){ - this.gap = gap; //-- False == auto gap -}; - -//-- Content Replacements - -EPUBJS.Renderer.prototype.replace = function(query, func, finished, progress){ - var items = this.contents.querySelectorAll(query), - resources = Array.prototype.slice.call(items), - count = resources.length; - - - if(count === 0) { - finished(false); - return; - } - resources.forEach(function(item){ - var called = false; - var after = function(result, full){ - if(called === false) { - count--; - if(progress) progress(result, full, count); - if(count <= 0 && finished) finished(true); - called = true; - } - }; - - func(item, after); - - }.bind(this)); - -}; - -EPUBJS.Renderer.prototype.replaceWithStored = function(query, attr, func, callback) { - var _oldUrls, - _newUrls = {}, - _store = this.currentChapter.store, - _cache = this.caches[query], - _uri = EPUBJS.core.uri(this.currentChapter.absolute), - _chapterBase = _uri.base, - _attr = attr, - _wait = 2000, - progress = function(url, full, count) { - _newUrls[full] = url; - }, - finished = function(notempty) { - if(callback) callback(); - - _.each(_oldUrls, function(url){ - _store.revokeUrl(url); - }); - - _cache = _newUrls; - }; - - if(!_store) return; - - if(!_cache) _cache = {}; - _oldUrls = _.clone(_cache); - - this.replace(query, function(link, done){ - var src = link.getAttribute(_attr), - full = EPUBJS.core.resolveUrl(_chapterBase, src); - - var replaceUrl = function(url) { - var timeout; - link.onload = function(){ - clearTimeout(timeout); - done(url, full); - }; - - link.onerror = function(e){ - clearTimeout(timeout); - done(url, full); - console.error(e); - }; - - if(query == "image") { - //-- SVG needs this to trigger a load event - link.setAttribute("externalResourcesRequired", "true"); - } - - if(query == "link[href]" && link.getAttribute("rel") !== "stylesheet") { - //-- Only Stylesheet links seem to have a load events, just continue others - done(url, full); - } - - link.setAttribute(_attr, url); - - //-- If elements never fire Load Event, should continue anyways - timeout = setTimeout(function(){ - done(url, full); - }, _wait); - - }; - - if(full in _oldUrls){ - replaceUrl(_oldUrls[full]); - _newUrls[full] = _oldUrls[full]; - delete _oldUrls[full]; - }else{ - func(_store, full, replaceUrl, link); - } - - }, finished, progress); -}; - -//-- Enable binding events to Renderer -RSVP.EventTarget.mixin(EPUBJS.Renderer.prototype); - -var EPUBJS = EPUBJS || {}; -EPUBJS.replace = {}; - -//-- Replaces the relative links within the book to use our internal page changer -EPUBJS.replace.hrefs = function(callback, renderer){ - var book = this; - var replacments = function(link, done){ - var href = link.getAttribute("href"), - isRelative = href.search("://"), - directory, - relative, - location; - - if(isRelative != -1){ - - link.setAttribute("target", "_blank"); - - }else{ - // Links may need to be resolved, such as ../chp1.xhtml - directory = EPUBJS.core.uri(renderer.render.window.location.href).directory; - if(directory) { - relative = EPUBJS.core.resolveUrl(directory, href); - } else { - relative = href; - } - - link.onclick = function(){ - book.goto(relative); - return false; - }; - - } - done(); - - }; - - renderer.replace("a[href]", replacments, callback); - -}; - -EPUBJS.replace.head = function(callback, renderer) { - - renderer.replaceWithStored("link[href]", "href", EPUBJS.replace.links, callback); - -}; - - -//-- Replaces assets src's to point to stored version if browser is offline -EPUBJS.replace.resources = function(callback, renderer){ - //srcs = this.doc.querySelectorAll('[src]'); - renderer.replaceWithStored("[src]", "src", EPUBJS.replace.srcs, callback); - -}; - -EPUBJS.replace.svg = function(callback, renderer) { - - renderer.replaceWithStored("image", "xlink:href", function(_store, full, done){ - _store.getUrl(full).then(done); - }, callback); - -}; - -EPUBJS.replace.srcs = function(_store, full, done){ - - _store.getUrl(full).then(done); - -}; - -//-- Replaces links in head, such as stylesheets - link[href] -EPUBJS.replace.links = function(_store, full, done, link){ - //-- Handle replacing urls in CSS - if(link.getAttribute("rel") === "stylesheet") { - EPUBJS.replace.stylesheets(_store, full).then(function(url, full){ - // done - setTimeout(function(){ - done(url, full); - }, 5); //-- Allow for css to apply before displaying chapter - }); - }else{ - _store.getUrl(full).then(done); - } -}; - -EPUBJS.replace.stylesheets = function(_store, full) { - var deferred = new RSVP.defer(); - - if(!_store) return; - - _store.getText(full).then(function(text){ - var url; - - EPUBJS.replace.cssUrls(_store, full, text).then(function(newText){ - var _URL = window.URL || window.webkitURL || window.mozURL; - - var blob = new Blob([newText], { "type" : "text\/css" }), - url = _URL.createObjectURL(blob); - - deferred.resolve(url); - - }, function(e) { - console.error(e); - }); - - }); - - return deferred.promise; -}; - -EPUBJS.replace.cssUrls = function(_store, base, text){ - var deferred = new RSVP.defer(), - promises = [], - matches = text.match(/url\(\'?\"?([^\'|^\"^\)]*)\'?\"?\)/g); - - if(!_store) return; - - if(!matches){ - deferred.resolve(text); - return deferred.promise; - } - - matches.forEach(function(str){ - var full = EPUBJS.core.resolveUrl(base, str.replace(/url\(|[|\)|\'|\"]/g, '')); - var replaced = _store.getUrl(full).then(function(url){ - text = text.replace(str, 'url("'+url+'")'); - }); - - promises.push(replaced); - }); - - RSVP.all(promises).then(function(){ - deferred.resolve(text); - }); - - return deferred.promise; -}; - - - -EPUBJS.Unarchiver = function(url){ - - this.loadLib(); - this.urlCache = {}; - -}; - -//-- Load the zip lib and set the workerScriptsPath -EPUBJS.Unarchiver.prototype.loadLib = function(callback){ - if(typeof(JSZip) == "undefined") console.error("JSZip lib not loaded"); -}; - -EPUBJS.Unarchiver.prototype.openZip = function(zipUrl, callback){ - var deferred = new RSVP.defer(); - - return EPUBJS.core.request(zipUrl, "binary").then(function(data){ - this.zip = new JSZip(data); - }.bind(this)); -}; - -EPUBJS.Unarchiver.prototype.getXml = function(url, encoding){ - - return this.getText(url, encoding). - then(function(text){ - var parser = new DOMParser(); - return parser.parseFromString(text, "text/xml"); - }); - -}; - -EPUBJS.Unarchiver.prototype.getUrl = function(url, mime){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - var tempUrl; - - if(!entry) { - deferred.reject({ - message : "File not found in the epub: " + url, - stack : new Error().stack - }); - return deferred.promise; - } - - if(url in this.urlCache) { - deferred.resolve(this.urlCache[url]); - return deferred.promise; - } - - blob = new Blob([entry.asUint8Array()], {type : mime || this.zip.getMimeType(entry.name)}); - - tempUrl = _URL.createObjectURL(blob); - deferred.resolve(tempUrl); - unarchiver.urlCache[url] = tempUrl; - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.getText = function(url, encoding){ - var unarchiver = this; - var deferred = new RSVP.defer(); - var decodededUrl = window.decodeURIComponent(url); - var entry = this.zip.file(decodededUrl); - var _URL = window.URL || window.webkitURL || window.mozURL; - - if(!entry) { - console.warn("File not found in the contained epub:", url); - return deferred.promise; - } - - text = entry.asText(); - deferred.resolve(text); - - return deferred.promise; -}; - -EPUBJS.Unarchiver.prototype.revokeUrl = function(url){ - var _URL = window.URL || window.webkitURL || window.mozURL; - var fromCache = unarchiver.urlCache[url]; - if(fromCache) _URL.revokeObjectURL(fromCache); -}; - -EPUBJS.Unarchiver.prototype.failed = function(error){ - console.error(error); -}; - -EPUBJS.Unarchiver.prototype.afterSaved = function(error){ - this.callback(); -}; - -EPUBJS.Unarchiver.prototype.toStorage = function(entries){ - var timeout = 0, - delay = 20, - that = this, - count = entries.length; - - function callback(){ - count--; - if(count === 0) that.afterSaved(); - } - - entries.forEach(function(entry){ - - setTimeout(function(entry){ - that.saveEntryFileToStorage(entry, callback); - }, timeout, entry); - - timeout += delay; - }); - - console.log("time", timeout); - - //entries.forEach(this.saveEntryFileToStorage.bind(this)); -}; - -// EPUBJS.Unarchiver.prototype.saveEntryFileToStorage = function(entry, callback){ -// var that = this; -// entry.getData(new zip.BlobWriter(), function(blob) { -// EPUBJS.storage.save(entry.filename, blob, callback); -// }); -// }; - -//# sourceMappingURL=epub_no_underscore.js.map \ No newline at end of file diff --git a/static/epub.js/epub_no_underscore.js.map b/static/epub.js/epub_no_underscore.js.map deleted file mode 100644 index afad7ad..0000000 --- a/static/epub.js/epub_no_underscore.js.map +++ /dev/null @@ -1,23 +0,0 @@ -{ - "version": 3, - "file": "epub_no_underscore.js", - "sources": [ - "libs/rsvp/rsvp.js", - "src/base.js", - "src/book.js", - "src/chapter.js", - "src/core.js", - "src/epubcfi.js", - "src/events.js", - "src/hooks.js", - "src/layout.js", - "src/pagination.js", - "src/parser.js", - "src/render_iframe.js", - "src/renderer.js", - "src/replace.js", - "src/unarchiver.js" - ], - "names": [], - "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,Y;ACtoEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;ACjvCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACjRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACthBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;ACtfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;AC5KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACvFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;AC5dA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uD;AC7NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A;ACluCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;;ACtIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A" -} \ No newline at end of file diff --git a/static/epub.js/font/fontello.eot b/static/epub.js/font/fontello.eot deleted file mode 100644 index f63ffa043ea29008e7f5b161b87c44ce567d15fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10204 zcmeHNYiwM{b)LEJz5C=oN$qNR$>nls?t|p=X_BH=yQC;vr1+G~6>WJ}S4m2h z6DgAIHgO2Yc8tJqT@;Ce#0VO+xKz@{cHKBY)z&fcFp3s2Vxx7@pj8Vu&5txq1dHl7 zcXuUH@uLCqvy}JFIcLtydCZwJXYTbo5klJVql6>uk0T;)0H8cW88kFn#P2)}GSGeD zE8TafWynG1$O>5|8>B!M@oxnkHZl(E6gdk#Pu4*3l4GE(k#(|QaBHN6BuF!QK4?71 zOsI`qCOpZFOf)6?8V(DBv79W|@|8`4+_0JIEd1k(lpQVBL3xrf^=ZL4KG2 z8t^ILb@NLb=kI4DN#zAR9$Z|R$?v~9@C)Efr{<;n`BnP7I!Z{D0$f|pFBQJ`M^%2{ z4UqBu)s^*)EByPX3Gx3D`rfm;R#<)Z$_uv$secFj#|Y)`rOyzNDBLHwS3!BQ*wS}N z3&k?sStIoA`Wu}am?f#}=w?Z6&=k2Zdk%{|}zRANMLZMa;xULZpfGkU=t=%F8xRuuGiC3F5RvvGSaW z@`U53D^v@7P05G>5ISK7LI?Ntwls(9sw%A(N;0Y5!F>li+nRe?x}yzsP2og!pfXfd z>vC9pR;SB`c?6>{pJ9rU(J=hS$f4iI6BC*tz`k1TWuUn`2e@8@ClYL~EJVchrMQ(4Z z`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XDrVdXOiT)bUT?XA6+ai|C(WxzqB?IwkU5#dS zlF_+vddtKfDjquZ!U;USZEfMRBYY4}Z^Ew-Yig_sVOSaV7yH=|E^PE>Va6boAI!mj zcU-nbh${rsGdk(JiWiQCyKT@#9GILUx+Rp>a+vqetX7JXC7s^PZCS;rz7+M>!gxCv zZPB>yh;32UR>ZbA);eQbJZoLCErGRec$KxD*p|dvZ){6utuMBvu(mR`WnyhrOjn}+ zN7;KIy9#6ckj>fvWV3cJWV1F1*{rRGY}RU!&Dt8sW^FBGvo-|TtgVY_y+-_mV=&p8 z(=u>qjx9hQtzOqy6W8lwdN`_w5qS{=*&t%09D1RAS4i7DI(0V@D;(DwZu^sZ^+=;m zJLF;F)k05urWKHNPhlMP4>==SiK~(M}rKpzGP3R7iP8^ zWL?1y(X@jh_$`Vci0f^J`Ou6jd526+CA40oX{J|+h{<-iFAVHHbRp0NWHZ#J=2Pu+;@&f8=-{|>q9Hre1V58cIc zZ%l8FmV0(h+8xtdqMKN9wziuH{$CReXD9S}$nP;c!s4auKpn9VLZ~JXxkVj&u^W-i zZU223&@1{`HPeE^Oz9tJ$Xco;Cnco>jnJlz0}Gad#^Gad#!$aom=P)twW zcJm2_=p7(GY(SlWaz@mE+yx{b(_3$IpJa%^J!3$Od)9y$Yayn$-DaI*h{1ZwfEeq% z0WsEvnBIPy^)y2a)-wjgSQib5u`b1;x>C^jy3zA2eaDe`55GiSAICvVpUS?h;HovF zAxrk_d}#Hm&|n%E@4u>Ya^sdn`?u=o6Jt|)>WQf>iSI|80YkmOP*eu^dx_rqeO>q* K{$I9!LjD)8G->Dn diff --git a/static/epub.js/font/fontello.svg b/static/epub.js/font/fontello.svg deleted file mode 100644 index 2db1398..0000000 --- a/static/epub.js/font/fontello.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - -Copyright (C) 2013 by original authors @ fontello.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/static/epub.js/font/fontello.ttf b/static/epub.js/font/fontello.ttf deleted file mode 100644 index 95715f86629cdbe17012ceb0595caaf61c8c15cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10036 zcmeHNdu*H6b-(v}^W#%|N+wNx5=BW7ACjnNELo;W$#P=JdfE{!$003I4_mKEvgfpR z?Ic^83aOI@MUZ6}S{H3ltl03;?bgK0nga8-H0UE3HZ*98EyIe<8?vr{bX{x2@_zRt zY0F8ItU&)9Wq$XZbI-l!anC*X+>a)d5Mm>j2v4#j6U~Xf#)EHx@-DtdXO?qoZ`N0R zlMvdE?}IaEH#O;dw(DCmOOMX!e_Id< z;hrVL^Xx)CH%kMt7YV7<(BHWLg8UBuRp3*=>lT(b&ppUSlFIXV9A8?U$?dy3@C)Ef zr2=V_C`rfy;o?mL?Fw15e?@y~<4yGx3oS zX(l~nkjy4?vW*k$5+`zkIPFlZJZGXj;rQta)dF8rGGYLPPMCqv!M(k$E#bPVN~?vE zbh3AF?}4uNmY&u_9_0~5s}qoFBv8elVx&&+nsDVM(vIa_1IUa&C^0<x>KXA>a5gu! zDmLqJq7d1o$kW6{oFRi}i-EUQ1a`8h%nHQKRf19#0nM^Wv_^_s(e{^$wX>m4p z_~FA3AD@2c==j*^$j}4*`?bB=-rk-%zqi8K;0o1NRz`eoNv>_^^0p;9JKE)j&V97A ztD{zG@Ps;Tq zIzp1%(ADO7e?Jd?c?bVL^hJB?ssoy%vd1RaDpl1~XX?4u5vZka2!Yy0FYmNgxtpz> zT4Q&8yq*s7!>V%Yn4+o*_mXUR??3;dmr~K!IMl-*-q}HSBAu}W4YyV~93i1va#mXv z%F*DF*8NfwO=aBb?s%}W(rR;1ttOzw8w2rOL3{1h(@X{)7W%X9?*6z(R^3g5|NPdH ztg145Q15A3r51_tv3-YZfBRSbG449CW9K!K&SYC76+{I|o^mN1G6F9O(_rJUZ>CwA zrz52eK*?Zz2mab5Pb6IOPeVt0XBYg*{M7(|G2B=)E}UCCm=qM#Lbg#8 z1aWG#(jjnscZajigSV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-|ji=AN`+(;SWNANGr9|kKcMMB4+m`h&qzuC~@ppK}y%W5wbW) zjfQuM1X*L}+q#s9*&T+zB|G4KrYo6T?tHIhpztcx^(4{Tt?qj+wfpCzqozIr`RH8J z#fMvJwZoGZ=T7AX-gXzG3Cl#zQ%ny|SEi?8rh(2^12+03MoWgpH_v~s5r(vT)XeOp zG<1W@8;0OOI#Zi_Ul+RWJV$PKaDRnDyA#(IADctpU6{Kpgfz>Pb|o(Iaz(D7URH$P zUZ@Cd*@c4$|apUFr#SWee?mdhn13<6p|NJNm6O;ehT*Z?;=P$x>G;nJ02+?o= zS26fxm|qpt+tc&vlaa{t$VnX{NHl0*qnm{dkZ6QFF)}+QU?Z7R=gLyWynsT16>b=2 z|Emkg0%?Le;7Z~C!Arqs!tWv|BZMP#Agm(7BQ7IJAbmqdMfO78L@7nhLLGVS8$bm3 z_@A=~GxT8YpD4fyrY)nSyjJtc^GyC}*C&A=`EoH6C#A1<(9*=JX!~tCff|``t(lC) zNhzK?W*}Y}+`Difd}aE88<_cz(VRsQkMVE5^F*E?31HzaQsSS8>n^*?5c57rWxC0r zG`Pipwp*8@Bv#-j)776$HXjL-_E@rj`cUS49=*-k#-5C}W`mxHw%5>R1KL~mPp)i6 zZwjXTGug7D=iCTxx9tnH^(hdFQlOHCExEOcc}``;vA6=6XUpM=6^)$xtlUB5Y{MEq zMU$RQC_4S9&h}%z&dM`1?(yE*?J{+FC5W$RsR~H0WVPqnL(`>mX>|171Wdjw;;wco zxwsWUFRbq)B*pp48Xh8(&@$1Uz^HeSTt1dOHr7N-?}9Virt2=3Ra+YWNbU|sshy0^ zI_cT*_T3#W{rG6EJuO!qbrIeyOgH+?!Wgqtc#Je9m3?;nvMYYasOPp;+Xzp|vBc`_O81RE=_ A2mk;8 diff --git a/static/epub.js/hooks.js b/static/epub.js/hooks.js deleted file mode 100644 index fad6409..0000000 --- a/static/epub.js/hooks.js +++ /dev/null @@ -1,318 +0,0 @@ -EPUBJS.Hooks.register("beforeChapterDisplay").endnotes = function(callback, renderer){ - - var notes = renderer.contents.querySelectorAll('a[href]'), - items = Array.prototype.slice.call(notes), //[].slice.call() - attr = "epub:type", - type = "noteref", - folder = EPUBJS.core.folder(location.pathname), - cssPath = (folder + EPUBJS.cssPath) || folder, - popups = {}; - - EPUBJS.core.addCss(cssPath + "popup.css", false, renderer.render.document.head); - - - items.forEach(function(item){ - var epubType = item.getAttribute(attr), - href, - id, - el, - pop, - pos, - left, - top, - txt; - - if(epubType != type) return; - - href = item.getAttribute("href"); - id = href.replace("#", ''); - el = renderer.render.document.getElementById(id); - - - item.addEventListener("mouseover", showPop, false); - item.addEventListener("mouseout", hidePop, false); - - function showPop(){ - var poppos, - iheight = renderer.height, - iwidth = renderer.width, - tip, - pop, - maxHeight = 225, - itemRect; - - if(!txt) { - pop = el.cloneNode(true); - txt = pop.querySelector("p"); - } - - // chapter.replaceLinks.bind(this) //TODO:Fred - update? - //-- create a popup with endnote inside of it - if(!popups[id]) { - popups[id] = document.createElement("div"); - popups[id].setAttribute("class", "popup"); - - pop_content = document.createElement("div"); - - popups[id].appendChild(pop_content); - - pop_content.appendChild(txt); - pop_content.setAttribute("class", "pop_content"); - - renderer.render.document.body.appendChild(popups[id]); - - //-- TODO: will these leak memory? - Fred - popups[id].addEventListener("mouseover", onPop, false); - popups[id].addEventListener("mouseout", offPop, false); - - //-- Add hide on page change - // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", hidePop); - // chapter.book.listenUntil("book:pageChanged", "book:chapterDestroy", offPop); - renderer.on("renderer:pageChanged", hidePop, this); - renderer.on("renderer:pageChanged", offPop, this); - // chapter.book.on("renderer:chapterDestroy", hidePop, this); - } - - pop = popups[id]; - - - //-- get location of item - itemRect = item.getBoundingClientRect(); - left = itemRect.left; - top = itemRect.top; - - //-- show the popup - pop.classList.add("show"); - - //-- locations of popup - popRect = pop.getBoundingClientRect(); - - //-- position the popup - pop.style.left = left - popRect.width / 2 + "px"; - pop.style.top = top + "px"; - - - //-- Adjust max height - if(maxHeight > iheight / 2.5) { - maxHeight = iheight / 2.5; - pop_content.style.maxHeight = maxHeight + "px"; - } - - //-- switch above / below - if(popRect.height + top >= iheight - 25) { - pop.style.top = top - popRect.height + "px"; - pop.classList.add("above"); - }else{ - pop.classList.remove("above"); - } - - //-- switch left - if(left - popRect.width <= 0) { - pop.style.left = left + "px"; - pop.classList.add("left"); - }else{ - pop.classList.remove("left"); - } - - //-- switch right - if(left + popRect.width / 2 >= iwidth) { - //-- TEMP MOVE: 300 - pop.style.left = left - 300 + "px"; - - popRect = pop.getBoundingClientRect(); - pop.style.left = left - popRect.width + "px"; - //-- switch above / below again - if(popRect.height + top >= iheight - 25) { - pop.style.top = top - popRect.height + "px"; - pop.classList.add("above"); - }else{ - pop.classList.remove("above"); - } - - pop.classList.add("right"); - }else{ - pop.classList.remove("right"); - } - - - } - - function onPop(){ - popups[id].classList.add("on"); - } - - function offPop(){ - popups[id].classList.remove("on"); - } - - function hidePop(){ - setTimeout(function(){ - popups[id].classList.remove("show"); - }, 100); - } - - }); - - - if(callback) callback(); - -} - -EPUBJS.Hooks.register("beforeChapterDisplay").mathml = function(callback, renderer){ - - // check of currentChapter properties contains 'mathml' - if(renderer.currentChapter.manifestProperties.indexOf("mathml") !== -1 ){ - - // Assign callback to be inside iframe window - renderer.iframe.contentWindow.mathmlCallback = callback; - - // add MathJax config script tag to the renderer body - var s = document.createElement("script"); - s.type = 'text/x-mathjax-config'; - s.innerHTML = '\ - MathJax.Hub.Register.StartupHook("End",function () { \ - window.mathmlCallback(); \ - });\ - MathJax.Hub.Config({jax: ["input/TeX","input/MathML","output/SVG"],extensions: ["tex2jax.js","mml2jax.js","MathEvents.js"],TeX: {extensions: ["noErrors.js","noUndefined.js","autoload-all.js"]},MathMenu: {showRenderer: false},menuSettings: {zoom: "Click"},messageStyle: "none"}); \ - '; - renderer.doc.body.appendChild(s); - // add MathJax.js to renderer head - EPUBJS.core.addScript("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML", null, renderer.doc.head); - - } else { - if(callback) callback(); - } -} - -EPUBJS.Hooks.register("beforeChapterDisplay").smartimages = function(callback, renderer){ - var images = renderer.contents.querySelectorAll('img'), - items = Array.prototype.slice.call(images), - iheight = renderer.height,//chapter.bodyEl.clientHeight,//chapter.doc.body.getBoundingClientRect().height, - oheight; - - if(renderer.layoutSettings.layout != "reflowable") { - callback(); - return; //-- Only adjust images for reflowable text - } - - items.forEach(function(item){ - - function size() { - var itemRect = item.getBoundingClientRect(), - rectHeight = itemRect.height, - top = itemRect.top, - oHeight = item.getAttribute('data-height'), - height = oHeight || rectHeight, - newHeight, - fontSize = Number(getComputedStyle(item, "").fontSize.match(/(\d*(\.\d*)?)px/)[1]), - fontAdjust = fontSize ? fontSize / 2 : 0; - - iheight = renderer.contents.clientHeight; - if(top < 0) top = 0; - - if(height + top >= iheight) { - - if(top < iheight/2) { - // Remove top and half font-size from height to keep container from overflowing - newHeight = iheight - top - fontAdjust; - item.style.maxHeight = newHeight + "px"; - item.style.width= "auto"; - }else{ - if(height > iheight) { - item.style.maxHeight = iheight + "px"; - item.style.width= "auto"; - itemRect = item.getBoundingClientRect(); - height = itemRect.height; - } - item.style.display = "block"; - item.style["WebkitColumnBreakBefore"] = "always"; - item.style["breakBefore"] = "column"; - - } - - item.setAttribute('data-height', newHeight); - - }else{ - item.style.removeProperty('max-height'); - item.style.removeProperty('margin-top'); - } - } - - item.addEventListener('load', size, false); - - renderer.on("renderer:resized", size); - - renderer.on("renderer:chapterUnloaded", function(){ - item.removeEventListener('load', size); - renderer.off("renderer:resized", size); - }); - - size(); - - }); - - if(callback) callback(); - -} - -EPUBJS.Hooks.register("beforeChapterDisplay").transculsions = function(callback, renderer){ - /* - - */ - - var trans = renderer.contents.querySelectorAll('[transclusion]'), - items = Array.prototype.slice.call(trans); - - items.forEach(function(item){ - var src = item.getAttribute("ref"), - iframe = document.createElement('iframe'), - orginal_width = item.getAttribute("width"), - orginal_height = item.getAttribute("height"), - parent = item.parentNode, - width = orginal_width, - height = orginal_height, - ratio; - - - function size() { - width = orginal_width; - height = orginal_height; - - if(width > chapter.colWidth){ - ratio = chapter.colWidth / width; - - width = chapter.colWidth; - height = height * ratio; - } - - iframe.width = width; - iframe.height = height; - } - - - size(); - - //-- resize event - - - renderer.listenUntil("renderer:resized", "renderer:chapterUnloaded", size); - - iframe.src = src; - - // - parent.replaceChild(iframe, item); - - - }); - - - - - if(callback) callback(); - - -} - -//# sourceMappingURL=hooks.js.map \ No newline at end of file diff --git a/static/epub.js/hooks.js.map b/static/epub.js/hooks.js.map deleted file mode 100644 index 7ed25d6..0000000 --- a/static/epub.js/hooks.js.map +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 3, - "file": "reader.js", - "sources": [ - "reader_src/reader.js", - "reader_src/controllers/bookmarks_controller.js", - "reader_src/controllers/controls_controller.js", - "reader_src/controllers/meta_controller.js", - "reader_src/controllers/notes_controller.js", - "reader_src/controllers/reader_controller.js", - "reader_src/controllers/settings_controller.js", - "reader_src/controllers/sidebar_controller.js", - "reader_src/controllers/toc_controller.js" - ], - "names": [], - "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gD;ACjUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AClEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AC9RA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACxHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A" -} \ No newline at end of file diff --git a/static/epub.js/hooks.min.js b/static/epub.js/hooks.min.js deleted file mode 100644 index 33049a9..0000000 --- a/static/epub.js/hooks.min.js +++ /dev/null @@ -1,2 +0,0 @@ -EPUBJS.Hooks.register("beforeChapterDisplay").endnotes=function(a,b){var c=b.contents.querySelectorAll("a[href]"),d=Array.prototype.slice.call(c),e="epub:type",f="noteref",g=EPUBJS.core.folder(location.pathname),h=g+EPUBJS.cssPath||g,i={};EPUBJS.core.addCss(h+"popup.css",!1,b.render.document.head),d.forEach(function(a){function c(){var c,e,f=b.height,j=b.width,p=225;o||(c=l.cloneNode(!0),o=c.querySelector("p")),i[k]||(i[k]=document.createElement("div"),i[k].setAttribute("class","popup"),pop_content=document.createElement("div"),i[k].appendChild(pop_content),pop_content.appendChild(o),pop_content.setAttribute("class","pop_content"),b.render.document.body.appendChild(i[k]),i[k].addEventListener("mouseover",d,!1),i[k].addEventListener("mouseout",g,!1),b.on("renderer:pageChanged",h,this),b.on("renderer:pageChanged",g,this)),c=i[k],e=a.getBoundingClientRect(),m=e.left,n=e.top,c.classList.add("show"),popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width/2+"px",c.style.top=n+"px",p>f/2.5&&(p=f/2.5,pop_content.style.maxHeight=p+"px"),popRect.height+n>=f-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),m-popRect.width<=0?(c.style.left=m+"px",c.classList.add("left")):c.classList.remove("left"),m+popRect.width/2>=j?(c.style.left=m-300+"px",popRect=c.getBoundingClientRect(),c.style.left=m-popRect.width+"px",popRect.height+n>=f-25?(c.style.top=n-popRect.height+"px",c.classList.add("above")):c.classList.remove("above"),c.classList.add("right")):c.classList.remove("right")}function d(){i[k].classList.add("on")}function g(){i[k].classList.remove("on")}function h(){setTimeout(function(){i[k].classList.remove("show")},100)}var j,k,l,m,n,o,p=a.getAttribute(e);p==f&&(j=a.getAttribute("href"),k=j.replace("#",""),l=b.render.document.getElementById(k),a.addEventListener("mouseover",c,!1),a.addEventListener("mouseout",h,!1))}),a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").mathml=function(a,b){if(-1!==b.currentChapter.manifestProperties.indexOf("mathml")){b.iframe.contentWindow.mathmlCallback=a;var c=document.createElement("script");c.type="text/x-mathjax-config",c.innerHTML=' MathJax.Hub.Register.StartupHook("End",function () { window.mathmlCallback(); }); MathJax.Hub.Config({jax: ["input/TeX","input/MathML","output/SVG"],extensions: ["tex2jax.js","mml2jax.js","MathEvents.js"],TeX: {extensions: ["noErrors.js","noUndefined.js","autoload-all.js"]},MathMenu: {showRenderer: false},menuSettings: {zoom: "Click"},messageStyle: "none"}); ',b.doc.body.appendChild(c),EPUBJS.core.addScript("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",null,b.doc.head)}else a&&a()},EPUBJS.Hooks.register("beforeChapterDisplay").smartimages=function(a,b){var c=b.contents.querySelectorAll("img"),d=Array.prototype.slice.call(c),e=b.height;return"reflowable"!=b.layoutSettings.layout?void a():(d.forEach(function(a){function c(){var c,d=a.getBoundingClientRect(),f=d.height,g=d.top,h=a.getAttribute("data-height"),i=h||f,j=Number(getComputedStyle(a,"").fontSize.match(/(\d*(\.\d*)?)px/)[1]),k=j?j/2:0;e=b.contents.clientHeight,0>g&&(g=0),i+g>=e?(e/2>g?(c=e-g-k,a.style.maxHeight=c+"px",a.style.width="auto"):(i>e&&(a.style.maxHeight=e+"px",a.style.width="auto",d=a.getBoundingClientRect(),i=d.height),a.style.display="block",a.style.WebkitColumnBreakBefore="always",a.style.breakBefore="column"),a.setAttribute("data-height",c)):(a.style.removeProperty("max-height"),a.style.removeProperty("margin-top"))}a.addEventListener("load",c,!1),b.on("renderer:resized",c),b.on("renderer:chapterUnloaded",function(){a.removeEventListener("load",c),b.off("renderer:resized",c)}),c()}),void(a&&a()))},EPUBJS.Hooks.register("beforeChapterDisplay").transculsions=function(a,b){var c=b.contents.querySelectorAll("[transclusion]"),d=Array.prototype.slice.call(c);d.forEach(function(a){function c(){j=g,k=h,j>chapter.colWidth&&(d=chapter.colWidth/j,j=chapter.colWidth,k*=d),f.width=j,f.height=k}var d,e=a.getAttribute("ref"),f=document.createElement("iframe"),g=a.getAttribute("width"),h=a.getAttribute("height"),i=a.parentNode,j=g,k=h;c(),b.listenUntil("renderer:resized","renderer:chapterUnloaded",c),f.src=e,i.replaceChild(f,a)}),a&&a()}; -//# sourceMappingURL=hooks.min.map \ No newline at end of file diff --git a/static/epub.js/hooks.min.map b/static/epub.js/hooks.min.map deleted file mode 100644 index 783dac9..0000000 --- a/static/epub.js/hooks.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hooks.min.js","sources":["hooks.js"],"names":["EPUBJS","Hooks","register","endnotes","callback","renderer","notes","contents","querySelectorAll","items","Array","prototype","slice","call","attr","type","folder","core","location","pathname","cssPath","popups","addCss","render","document","head","forEach","item","showPop","pop","itemRect","iheight","height","iwidth","width","maxHeight","txt","el","cloneNode","querySelector","id","createElement","setAttribute","pop_content","appendChild","body","addEventListener","onPop","offPop","on","hidePop","this","getBoundingClientRect","left","top","classList","add","popRect","style","remove","setTimeout","href","epubType","getAttribute","replace","getElementById","mathml","currentChapter","manifestProperties","indexOf","iframe","contentWindow","mathmlCallback","s","innerHTML","doc","addScript","smartimages","images","layoutSettings","layout","size","newHeight","rectHeight","oHeight","fontSize","Number","getComputedStyle","match","fontAdjust","clientHeight","display","removeProperty","removeEventListener","off","transculsions","trans","orginal_width","orginal_height","chapter","colWidth","ratio","src","parent","parentNode","listenUntil","replaceChild"],"mappings":"AAAAA,OAAOC,MAAMC,SAAS,wBAAwBC,SAAW,SAASC,EAAUC,GAE1E,GAAIC,GAAQD,EAASE,SAASC,iBAAiB,WAC9CC,EAAQC,MAAMC,UAAUC,MAAMC,KAAKP,GACnCQ,EAAO,YACPC,EAAO,UACPC,EAAShB,OAAOiB,KAAKD,OAAOE,SAASC,UACrCC,EAAWJ,EAAShB,OAAOoB,SAAYJ,EACvCK,I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yF,IAAI,mBAAoBb,KAGlCA,WAIE7E,GAAUA,OAIfJ,OAAOC,MAAMC,SAAS,wBAAwB6F,cAAgB,SAAS3F,EAAUC,GAO/E,GAAI2F,GAAQ3F,EAASE,SAASC,iBAAiB,kBAC7CC,EAAQC,MAAMC,UAAUC,MAAMC,KAAKmF,EAErCvF,GAAMiB,QAAQ,SAASC,GAWtB,QAASsD,KACR/C,EAAQ+D,EACRjE,EAASkE,EAENhE,EAAQiE,QAAQC,WAClBC,EAAQF,QAAQC,SAAWlE,EAE3BA,EAAQiE,QAAQC,SAChBpE,GAAkBqE,GAGnB/B,EAAOpC,MAAQA,EACfoC,EAAOtC,OAASA,EAtBjB,GAOCqE,GAPGC,EAAM3E,EAAKoC,aAAa,OAC3BO,EAAS9C,SAASiB,cAAc,UAChCwD,EAAgBtE,EAAKoC,aAAa,SAClCmC,EAAiBvE,EAAKoC,aAAa,UACnCwC,EAAS5E,EAAK6E,WACdtE,EAAQ+D,EACRjE,EAASkE,CAoBVjB,KAKA5E,EAASoG,YAAY,mBAAoB,2BAA4BxB,GAErEX,EAAOgC,IAAMA,EAGbC,EAAOG,aAAapC,EAAQ3C,KAQ1BvB,GAAUA"} \ No newline at end of file diff --git a/static/epub.js/hooks/extensions/highlight.js b/static/epub.js/hooks/extensions/highlight.js deleted file mode 100644 index 1dd1c67..0000000 --- a/static/epub.js/hooks/extensions/highlight.js +++ /dev/null @@ -1,14 +0,0 @@ -EPUBJS.Hooks.register("beforeChapterDisplay").highlight = function(callback, renderer){ - - // EPUBJS.core.addScript("js/libs/jquery.highlight.js", null, renderer.doc.head); - - var s = document.createElement("style"); - s.innerHTML =".highlight { background: yellow; font-weight: normal; }"; - - renderer.render.document.head.appendChild(s); - - if(callback) callback(); - -} - - diff --git a/static/epub.js/libs/inflate.js b/static/epub.js/libs/inflate.js deleted file mode 100644 index 5bf3eed..0000000 --- a/static/epub.js/libs/inflate.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(a){function b(){function a(a,b,c,d,j,k,l,n,p,r,s){var t,u,v,w,x,y,z,A,C,D,E,F,G,H,I;D=0,x=c;do e[a[b+D]]++,D++,x--;while(0!==x);if(e[0]==c)return l[0]=-1,n[0]=0,i;for(A=n[0],y=1;B>=y&&0===e[y];y++);for(z=y,y>A&&(A=y),x=B;0!==x&&0===e[x];x--);for(v=x,A>x&&(A=x),n[0]=A,H=1<y;y++,H<<=1)if((H-=e[y])<0)return m;if((H-=e[x])<0)return m;for(e[x]+=H,h[1]=y=0,D=1,G=2;0!==--x;)h[G]=y+=e[D],G++,D++;x=0,D=0;do 0!==(y=a[b+D])&&(s[h[y]++]=x),D++;while(++x=z;z++)for(t=e[z];0!==t--;){for(;z>F+A;){if(w++,F+=A,I=v-F,I=I>A?A:I,(u=1<<(y=z-F))>t+1&&(u-=t+1,G=z,I>y))for(;++yq)return m;g[w]=E=r[0],r[0]+=I,0!==w?(h[w]=x,f[0]=y,f[1]=A,y=x>>>F-A,f[2]=E-g[w-1]-y,p.set(f,3*(g[w-1]+y))):l[0]=E}for(f[1]=z-F,D>=c?f[0]=192:s[D]>>F;I>y;y+=u)p.set(f,3*(E+y));for(y=1<>>=1)x^=y;for(x^=y,C=(1<b;b++)d[b]=0;for(b=0;B+1>b;b++)e[b]=0;for(b=0;3>b;b++)f[b]=0;g.set(e.subarray(0,B),0),h.set(e.subarray(0,B+1),0)}var c,d,e,f,g,h,j=this;j.inflate_trees_bits=function(e,f,g,h,i){var j;return b(19),c[0]=0,j=a(e,0,19,19,null,null,g,f,h,c,d),j==m?i.msg="oversubscribed dynamic bit lengths tree":(j==o||0===f[0])&&(i.msg="incomplete dynamic bit lengths tree",j=m),j},j.inflate_trees_dynamic=function(e,f,g,h,j,k,l,p,q){var r;return b(288),c[0]=0,r=a(g,0,e,257,x,y,k,h,p,c,d),r!=i||0===h[0]?(r==m?q.msg="oversubscribed literal/length tree":r!=n&&(q.msg="incomplete literal/length tree",r=m),r):(b(288),r=a(g,e,f,0,z,A,l,j,p,c,d),r!=i||0===j[0]&&e>257?(r==m?q.msg="oversubscribed distance tree":r==o?(q.msg="incomplete distance tree",r=m):r!=n&&(q.msg="empty distance tree with lengths",r=m),r):i)}}function c(){function a(a,b,c,d,e,f,g,h){var k,l,n,o,q,r,s,t,u,v,w,x,y,z,A,B;s=h.next_in_index,t=h.avail_in,q=g.bitb,r=g.bitk,u=g.write,v=ur;)t--,q|=(255&h.read_byte(s++))<>=l[B+1],r-=l[B+1],0!==(16&o)){for(o&=15,y=l[B+2]+(q&p[o]),q>>=o,r-=o;15>r;)t--,q|=(255&h.read_byte(s++))<>=l[B+1],r-=l[B+1],0!==(16&o)){for(o&=15;o>r;)t--,q|=(255&h.read_byte(s++))<>=o,r-=o,v-=y,u>=z)A=u-z,u-A>0&&2>u-A?(g.window[u++]=g.window[A++],g.window[u++]=g.window[A++],y-=2):(g.window.set(g.window.subarray(A,A+2),u),u+=2,A+=2,y-=2);else{A=u-z;do A+=g.end;while(0>A);if(o=g.end-A,y>o){if(y-=o,u-A>0&&o>u-A){do g.window[u++]=g.window[A++];while(0!==--o)}else g.window.set(g.window.subarray(A,A+o),u),u+=o,A+=o,o=0;A=0}}if(u-A>0&&y>u-A){do g.window[u++]=g.window[A++];while(0!==--y)}else g.window.set(g.window.subarray(A,A+y),u),u+=y,A+=y,y=0;break}if(0!==(64&o))return h.msg="invalid distance code",y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,m;k+=l[B+2],k+=q&p[o],B=3*(n+k),o=l[B]}break}if(0!==(64&o))return 0!==(32&o)?(y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,j):(h.msg="invalid literal/length code",y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,m);if(k+=l[B+2],k+=q&p[o],B=3*(n+k),0===(o=l[B])){q>>=l[B+1],r-=l[B+1],g.window[u++]=l[B+2],v--;break}}else q>>=l[B+1],r-=l[B+1],g.window[u++]=l[B+2],v--}while(v>=258&&t>=10);return y=h.avail_in-t,y=y>r>>3?r>>3:y,t+=y,s-=y,r-=y<<3,g.bitb=q,g.bitk=r,h.avail_in=t,h.total_in+=s-h.next_in_index,h.next_in_index=s,g.write=u,i}var b,c,d,e,f=this,g=0,h=0,k=0,n=0,o=0,q=0,r=0,s=0,t=0,u=0;f.init=function(a,f,g,h,i,j){b=C,r=a,s=f,d=g,t=h,e=i,u=j,c=null},f.proc=function(f,v,w){var x,y,z,A,B,M,N,O=0,P=0,Q=0;for(Q=v.next_in_index,A=v.avail_in,O=f.bitb,P=f.bitk,B=f.write,M=B=258&&A>=10&&(f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,w=a(r,s,d,t,e,u,f,v),Q=v.next_in_index,A=v.avail_in,O=f.bitb,P=f.bitk,B=f.write,M=BP;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>>=c[y+1],P-=c[y+1],z=c[y],0===z){n=c[y+2],b=I;break}if(0!==(16&z)){o=15&z,g=c[y+2],b=E;break}if(0===(64&z)){k=z,h=y/3+c[y+2];break}if(0!==(32&z)){b=J;break}return b=L,v.msg="invalid literal/length code",w=m,f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);case E:for(x=o;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=x,P-=x,k=s,c=e,h=u,b=F;case F:for(x=k;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=c[y+1],P-=c[y+1],z=c[y],0!==(16&z)){o=15&z,q=c[y+2],b=G;break}if(0===(64&z)){k=z,h=y/3+c[y+2];break}return b=L,v.msg="invalid distance code",w=m,f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);case G:for(x=o;x>P;){if(0===A)return f.bitb=O,f.bitk=P,v.avail_in=A,v.total_in+=Q-v.next_in_index,v.next_in_index=Q,f.write=B,f.inflate_flush(v,w);w=i,A--,O|=(255&v.read_byte(Q++))<>=x,P-=x,b=H;case H:for(N=B-q;0>N;)N+=f.end;for(;0!==g;){if(0===M&&(B==f.end&&0!==f.read&&(B=0,M=B7&&(P-=8,A++,Q--),f.write=B,w=f.inflate_flush(v,w),B=f.write,M=Ba.avail_out&&(c=a.avail_out),0!==c&&b==o&&(b=i),a.avail_out-=c,a.total_out+=c,a.next_out.set(f.window.subarray(e,e+c),d),d+=c,e+=c,e==f.end&&(e=0,f.write==f.end&&(f.write=0),c=f.write-e,c>a.avail_out&&(c=a.avail_out),0!==c&&b==o&&(b=i),a.avail_out-=c,a.total_out+=c,a.next_out.set(f.window.subarray(e,e+c),d),d+=c,e+=c),a.next_out_index=d,f.read=e,b},f.proc=function(a,c){var d,o,q,w,y,z,A,B;for(w=a.next_in_index,y=a.avail_in,o=f.bitb,q=f.bitk,z=f.write,A=zq;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>1){case 0:o>>>=3,q-=3,d=7&q,o>>>=d,q-=d,g=O;break;case 1:var C=[],D=[],E=[[]],F=[[]];b.inflate_trees_fixed(C,D,E,F),t.init(C[0],D[0],E[0],0,F[0],0),o>>>=3,q-=3,g=T;break;case 2:o>>>=3,q-=3,g=Q;break;case 3:return o>>>=3,q-=3,g=W,a.msg="invalid block type",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c)}break;case O:for(;32>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>16&65535)!=(65535&o))return g=W,a.msg="invalid stored block lengths",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);h=65535&o,o=q=0,g=0!==h?P:0!==u?U:N;break;case P:if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);if(0===A&&(z==f.end&&0!==f.read&&(z=0,A=zy&&(d=y),d>A&&(d=A),f.window.set(a.read_buf(w,d),z),w+=d,y-=d,z+=d,A-=d,0!==(h-=d))break;g=0!==u?U:N;break;case Q:for(;14>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<29||(d>>5&31)>29)return g=W,a.msg="too many length or distance symbols",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);if(d=258+(31&d)+(d>>5&31),!e||e.lengthB;B++)e[B]=0;o>>>=14,q-=14,n=0,g=R;case R:for(;4+(k>>>10)>n;){for(;3>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>=3,q-=3}for(;19>n;)e[M[n++]]=0;if(r[0]=7,d=x.inflate_trees_bits(e,r,s,v,a),d!=i)return c=d,c==m&&(e=null,g=W),f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);n=0,g=S;case S:for(;;){if(d=k,!(258+(31&d)+(d>>5&31)>n))break;var G,H;for(d=r[0];d>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<H)o>>>=d,q-=d,e[n++]=H;else{for(B=18==H?7:H-14,G=18==H?11:3;d+B>q;){if(0===y)return f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);c=i,y--,o|=(255&a.read_byte(w++))<>>=d,q-=d,G+=o&p[B],o>>>=B,q-=B,B=n,d=k,B+G>258+(31&d)+(d>>5&31)||16==H&&1>B)return e=null,g=W,a.msg="invalid bit length repeat",c=m,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);H=16==H?e[B-1]:0;do e[B++]=H;while(0!==--G);n=B}}s[0]=-1;var I=[],J=[],K=[],L=[];if(I[0]=9,J[0]=6,d=k,d=x.inflate_trees_dynamic(257+(31&d),1+(d>>5&31),e,I,J,K,L,v,a),d!=i)return d==m&&(e=null,g=W),c=d,f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,f.inflate_flush(a,c);t.init(I[0],J[0],v,K[0],v,L[0]),g=T;case T:if(f.bitb=o,f.bitk=q,a.avail_in=y,a.total_in+=w-a.next_in_index,a.next_in_index=w,f.write=z,(c=t.proc(f,a,c))!=j)return f.inflate_flush(a,c);if(c=i,t.free(a),w=a.next_in_index,y=a.avail_in,o=f.bitb,q=f.bitk,z=f.write,A=ze||e>15?(b.inflateEnd(c),l):(b.wbits=e,c.istate.blocks=new d(c,1<>4)+8>a.istate.wbits){a.istate.mode=gb,a.msg="invalid window size",a.istate.marker=5;break}a.istate.mode=$;case $:if(0===a.avail_in)return c;if(c=b,a.avail_in--,a.total_in++,d=255&a.read_byte(a.next_in_index++),((a.istate.method<<8)+d)%31!==0){a.istate.mode=gb,a.msg="incorrect header check",a.istate.marker=5;break}if(0===(d&X)){a.istate.mode=eb;break}a.istate.mode=_;case _:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need=(255&a.read_byte(a.next_in_index++))<<24&4278190080,a.istate.mode=ab;case ab:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need+=(255&a.read_byte(a.next_in_index++))<<16&16711680,a.istate.mode=bb;case bb:if(0===a.avail_in)return c;c=b,a.avail_in--,a.total_in++,a.istate.need+=(255&a.read_byte(a.next_in_index++))<<8&65280,a.istate.mode=cb;case cb:return 0===a.avail_in?c:(c=b,a.avail_in--,a.total_in++,a.istate.need+=255&a.read_byte(a.next_in_index++),a.istate.mode=db,k);case db:return a.istate.mode=gb,a.msg="need dictionary",a.istate.marker=0,l;case eb:if(c=a.istate.blocks.proc(a,c),c==m){a.istate.mode=gb,a.istate.marker=0;break}if(c==i&&(c=b),c!=j)return c;c=b,a.istate.blocks.reset(a,a.istate.was),a.istate.mode=fb;case fb:return j;case gb:return m;default:return l}},b.inflateSetDictionary=function(a,b,c){var d=0,e=c;return a&&a.istate&&a.istate.mode==db?(e>=1<e;)b.read_byte(d)==hb[e]?e++:e=0!==b.read_byte(d)?0:4-e,d++,c--;return b.total_in+=d-b.next_in_index,b.next_in_index=d,b.avail_in=c,b.istate.marker=e,4!=e?m:(f=b.total_in,g=b.total_out,a(b),b.total_in=f,b.total_out=g,b.istate.mode=eb,i)},b.inflateSyncPoint=function(a){return a&&a.istate&&a.istate.blocks?a.istate.blocks.sync_point():l}}function f(){}function g(){var a=this,b=new f,c=512,d=r,e=new Uint8Array(c),g=!1;b.inflateInit(),b.next_out=e,a.append=function(a,f){var h,k,l=[],m=0,n=0,p=0;if(0!==a.length){b.next_in_index=0,b.next_in=a,b.avail_in=a.length;do{if(b.next_out_index=0,b.avail_out=c,0!==b.avail_in||g||(b.next_in_index=0,g=!0),h=b.inflate(d),g&&h==o)return-1;if(h!=i&&h!=j)throw"inflating: "+b.msg;if((g||h==j)&&b.avail_in==a.length)return-1;b.next_out_index&&l.push(b.next_out_index==c?new Uint8Array(e):new Uint8Array(e.subarray(0,b.next_out_index))),p+=b.next_out_index,f&&b.next_in_index>0&&b.next_in_index!=m&&(f(b.next_in_index),m=b.next_in_index)}while(b.avail_in>0||0===b.avail_out);return k=new Uint8Array(p),l.forEach(function(a){k.set(a,n),n+=a.length}),k}},a.flush=function(){b.inflateEnd()}}var h=15,i=0,j=1,k=2,l=-2,m=-3,n=-4,o=-5,p=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],q=1440,r=0,s=4,t=9,u=5,v=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],w=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],x=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],y=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],z=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],A=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],B=15;b.inflate_trees_fixed=function(a,b,c,d){return a[0]=t,b[0]=u,c[0]=v,d[0]=w,i};var C=0,D=1,E=2,F=3,G=4,H=5,I=6,J=7,K=8,L=9,M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=0,O=1,P=2,Q=3,R=4,S=5,T=6,U=7,V=8,W=9,X=32,Y=8,Z=0,$=1,_=2,ab=3,bb=4,cb=5,db=6,eb=7,fb=12,gb=13,hb=[0,0,255,255];f.prototype={inflateInit:function(a){var b=this;return b.istate=new e,a||(a=h),b.istate.inflateInit(b,a)},inflate:function(a){var b=this;return b.istate?b.istate.inflate(b,a):l},inflateEnd:function(){var a=this;if(!a.istate)return l;var b=a.istate.inflateEnd(a);return a.istate=null,b},inflateSync:function(){var a=this;return a.istate?a.istate.inflateSync(a):l},inflateSetDictionary:function(a,b){var c=this;return c.istate?c.istate.inflateSetDictionary(c,a,b):l},read_byte:function(a){var b=this;return b.next_in.subarray(a,a+1)[0]},read_buf:function(a,b){var c=this;return c.next_in.subarray(a,a+b)}};var ib;a.zip?a.zip.Inflater=g:(ib=new g,a.addEventListener("message",function(b){var c=b.data;c.append&&a.postMessage({onappend:!0,data:ib.append(c.data,function(b){a.postMessage({progress:!0,current:b})})}),c.flush&&(ib.flush(),a.postMessage({onflush:!0}))},!1))}(this); -//# sourceMappingURL=inflate.map \ No newline at end of file diff --git a/static/epub.js/libs/inflate.map b/static/epub.js/libs/inflate.map deleted file mode 100644 index dc48317..0000000 --- a/static/epub.js/libs/inflate.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"inflate.js","sources":["../../libs/zip/inflate.js"],"names":["obj","InfTree","huft_build","b","bindex","n","s","d","e","t","m","hp","hn","v","a","f","g","h","i","j","k","l","mask","p","q","w","xp","y","z","c","Z_OK","BMAX","Z_DATA_ERROR","x","u","MANY","r","set","Z_BUF_ERROR","initWorkArea","vsize","Int32Array","length","subarray","that","this","inflate_trees_bits","bb","tb","result","msg","inflate_trees_dynamic","nl","nd","bl","bd","tl","td","cplens","cplext","Z_MEM_ERROR","cpdist","cpdext","InfCodes","inflate_fast","tl_index","td_index","tp","tp_index","ml","md","tp_index_t_3","next_in_index","avail_in","bitb","bitk","write","read","end","inflate_mask","read_byte","window","total_in","Z_STREAM_END","mode","tree","ltree","dtree","len","tree_index","need","lit","get","dist","lbits","dbits","ltree_index","dtree_index","init","START","proc","tindex","WASH","BADCODE","LEN","inflate_flush","LIT","LENEXT","DIST","DISTEXT","COPY","END","Z_STREAM_ERROR","free","InfBlocks","blens","TYPE","left","table","index","codes","last","hufts","check","inftree","Uint8Array","reset","CODES","next_out_index","avail_out","total_out","next_out","LENS","inflate_trees_fixed","TABLE","BADBLOCKS","STORED","DRY","read_buf","BTREE","border","DTREE","bl_","bd_","tl_","td_","DONELOCKS","set_dictionary","start","sync_point","Inflate","inflateReset","istate","BLOCKS","blocks","method","was","marker","wbits","inflateEnd","inflateInit","inflate","next_in","Z_FINISH","METHOD","Z_DEFLATED","BAD","FLAG","PRESET_DICT","DICT4","DICT3","DICT2","DICT1","DICT0","Z_NEED_DICT","DONE","inflateSetDictionary","dictionary","dictLength","inflateSync","mark","inflateSyncPoint","ZStream","Inflater","bufsize","flush","Z_NO_FLUSH","buf","nomoreinput","append","data","onprogress","err","array","buffers","lastIndex","bufferIndex","bufferSize","push","forEach","chunk","MAX_BITS","fixed_bl","fixed_bd","fixed_tl","fixed_td","prototype","bits","ret","size","inflater","zip","addEventListener","event","message","postMessage","onappend","current","progress","onflush"],"mappings":"CAmCA,SAAUA,GAqFT,QAASC,KAUR,QAASC,GAAWC,EAEpBC,EAAQC,EACRC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAWC,GAAIC,GACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,E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EAAK4G,OACT,MAAOxC,EACR,IAAIgG,GAAMpK,EAAK4G,OAAOO,WAAWnH,EAEjC,OADAA,GAAK4G,OAAS,KACPwD,GAGR7B,YAAc,WACb,GAAIvI,GAAOC,IACX,OAAKD,GAAK4G,OAEH5G,EAAK4G,OAAO2B,YAAYvI,GADvBoE,GAGTgE,qBAAuB,SAASC,EAAYC,GAC3C,GAAItI,GAAOC,IACX,OAAKD,GAAK4G,OAEH5G,EAAK4G,OAAOwB,qBAAqBpI,EAAMqI,EAAYC,GADlDlE,GAGThC,UAAY,SAASoE,GACpB,GAAIxG,GAAOC,IACX,OAAOD,GAAKsH,QAAQvH,SAASyG,EAAOA,EAAQ,GAAG,IAEhDV,SAAW,SAASU,EAAO6D,GAC1B,GAAIrK,GAAOC,IACX,OAAOD,GAAKsH,QAAQvH,SAASyG,EAAOA,EAAQ6D,IA6D9C,IAAIC,GAEAlN,GAAImN,IACPnN,EAAImN,IAAI5B,SAAWA,GAEnB2B,GAAW,GAAI3B,GACfvL,EAAIoN,iBAAiB,UAAW,SAASC,GACxC,GAAIC,GAAUD,EAAMvB,IAEhBwB,GAAQzB,QACX7L,EAAIuN,aACHC,UAAW,EACX1B,KAAOoB,GAASrB,OAAOyB,EAAQxB,KAAM,SAAS2B,GAC7CzN,EAAIuN,aACHG,UAAW,EACXD,QAAUA,QAIVH,EAAQ7B,QACXyB,GAASzB,QACTzL,EAAIuN,aACHI,SAAU,OAGV,KAGF9K"} \ No newline at end of file diff --git a/static/epub.js/libs/jquery.highlight.js b/static/epub.js/libs/jquery.highlight.js deleted file mode 100644 index 9dcf3c7..0000000 --- a/static/epub.js/libs/jquery.highlight.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * jQuery Highlight plugin - * - * Based on highlight v3 by Johann Burkard - * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html - * - * Code a little bit refactored and cleaned (in my humble opinion). - * Most important changes: - * - has an option to highlight only entire words (wordsOnly - false by default), - * - has an option to be case sensitive (caseSensitive - false by default) - * - highlight element tag and class names can be specified in options - * - * Usage: - * // wrap every occurrance of text 'lorem' in content - * // with (default options) - * $('#content').highlight('lorem'); - * - * // search for and highlight more terms at once - * // so you can save some time on traversing DOM - * $('#content').highlight(['lorem', 'ipsum']); - * $('#content').highlight('lorem ipsum'); - * - * // search only for entire word 'lorem' - * $('#content').highlight('lorem', { wordsOnly: true }); - * - * // don't ignore case during search of term 'lorem' - * $('#content').highlight('lorem', { caseSensitive: true }); - * - * // wrap every occurrance of term 'ipsum' in content - * // with - * $('#content').highlight('ipsum', { element: 'em', className: 'important' }); - * - * // remove default highlight - * $('#content').unhighlight(); - * - * // remove custom highlight - * $('#content').unhighlight({ element: 'em', className: 'important' }); - * - * - * Copyright (c) 2009 Bartek Szopka - * - * Licensed under MIT license. - * - */ - -jQuery.extend({ - highlight: function (node, re, nodeName, className) { - if (node.nodeType === 3) { - var match = node.data.match(re); - if (match) { - var highlight = document.createElement(nodeName || 'span'); - highlight.className = className || 'highlight'; - var wordNode = node.splitText(match.index); - wordNode.splitText(match[0].length); - var wordClone = wordNode.cloneNode(true); - highlight.appendChild(wordClone); - wordNode.parentNode.replaceChild(highlight, wordNode); - return 1; //skip added node in parent - } - } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children - !/(script|style)/i.test(node.tagName) && // ignore script and style nodes - !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted - for (var i = 0; i < node.childNodes.length; i++) { - i += jQuery.highlight(node.childNodes[i], re, nodeName, className); - } - } - return 0; - } -}); - -jQuery.fn.unhighlight = function (options) { - var settings = { className: 'highlight', element: 'span' }; - jQuery.extend(settings, options); - - return this.find(settings.element + "." + settings.className).each(function () { - var parent = this.parentNode; - parent.replaceChild(this.firstChild, this); - parent.normalize(); - }).end(); -}; - -jQuery.fn.highlight = function (words, options) { - var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false }; - jQuery.extend(settings, options); - - if (words.constructor === String) { - words = [words]; - } - words = jQuery.grep(words, function(word, i){ - return word != ''; - }); - words = jQuery.map(words, function(word, i) { - return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); - }); - if (words.length == 0) { return this; }; - - var flag = settings.caseSensitive ? "" : "i"; - var pattern = "(" + words.join("|") + ")"; - if (settings.wordsOnly) { - pattern = "\\b" + pattern + "\\b"; - } - var re = new RegExp(pattern, flag); - - return this.each(function () { - jQuery.highlight(this, re, settings.element, settings.className); - }); -}; - diff --git a/static/epub.js/libs/screenfull.min.js b/static/epub.js/libs/screenfull.min.js deleted file mode 100644 index 6f5eaf3..0000000 --- a/static/epub.js/libs/screenfull.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! -* screenfull -* v1.1.0 - 2013-09-06 -* https://github.com/sindresorhus/screenfull.js -* (c) Sindre Sorhus; MIT License -*/ -!function(a,b){"use strict";var c="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,d=function(){for(var a,c,d=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenchange","MSFullscreenerror"]],e=0,f=d.length,g={};f>e;e++)if(a=d[e],a&&a[1]in b){for(e=0,c=a.length;c>e;e++)g[d[0][e]]=a[e];return g}return!1}(),e={request:function(a){var e=d.requestFullscreen;a=a||b.documentElement,/5\.1[\.\d]* Safari/.test(navigator.userAgent)?a[e]():a[e](c&&Element.ALLOW_KEYBOARD_INPUT)},exit:function(){b[d.exitFullscreen]()},toggle:function(a){this.isFullscreen?this.exit():this.request(a)},onchange:function(){},onerror:function(){},raw:d};return d?(Object.defineProperties(e,{isFullscreen:{get:function(){return!!b[d.fullscreenElement]}},element:{enumerable:!0,get:function(){return b[d.fullscreenElement]}},enabled:{enumerable:!0,get:function(){return!!b[d.fullscreenEnabled]}}}),b.addEventListener(d.fullscreenchange,function(a){e.onchange.call(e,a)}),b.addEventListener(d.fullscreenerror,function(a){e.onerror.call(e,a)}),a.screenfull=e,void 0):(a.screenfull=!1,void 0)}(window,document); \ No newline at end of file diff --git a/static/epub.js/libs/zip.min.js b/static/epub.js/libs/zip.min.js deleted file mode 100644 index 8db9a7f..0000000 --- a/static/epub.js/libs/zip.min.js +++ /dev/null @@ -1,16 +0,0 @@ -/*! - -JSZip - A Javascript class for generating and reading zip files - - -(c) 2009-2014 Stuart Knightley -Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. - -JSZip uses the library pako released under the MIT license : -https://github.com/nodeca/pako/blob/master/LICENSE -*/ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":8}],4:[function(a,b){"use strict";var c=a("./utils"),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var e="string"!==c.getTypeOf(a);"undefined"==typeof b&&(b=0);var f=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=e?a[i]:a.charCodeAt(i),g=255&(b^h),f=d[g],b=b>>>8^f;return-1^b}},{"./utils":21}],5:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":21}],6:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!1,c.date=null,c.compression=null,c.comment=null},{}],7:[function(a,b,c){"use strict";var d=a("./utils");c.string2binary=function(a){return d.string2binary(a)},c.string2Uint8Array=function(a){return d.transformTo("uint8array",a)},c.uint8Array2String=function(a){return d.transformTo("string",a)},c.string2Blob=function(a){var b=d.transformTo("arraybuffer",a);return d.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){return d.arrayBuffer2Blob(a)},c.transformTo=function(a,b){return d.transformTo(a,b)},c.getTypeOf=function(a){return d.getTypeOf(a)},c.checkSupport=function(a){return d.checkSupport(a)},c.MAX_VALUE_16BITS=d.MAX_VALUE_16BITS,c.MAX_VALUE_32BITS=d.MAX_VALUE_32BITS,c.pretty=function(a){return d.pretty(a)},c.findCompression=function(a){return d.findCompression(a)},c.isRegExp=function(a){return d.isRegExp(a)}},{"./utils":21}],8:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("pako");c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a){return e.deflateRaw(a)},c.uncompress=function(a){return e.inflateRaw(a)}},{pako:24}],9:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.comment=null,this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}var d=a("./base64");c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./deprecatedPublicUtils"),c.base64={encode:function(a){return d.encode(a)},decode:function(a){return d.decode(a)}},c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},t=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},x=function(a,b){return"/"!=a.slice(-1)&&(a+="/"),b="undefined"!=typeof b?b:!1,this.files[a]||v.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},y=function(a,b){var c,f=new j;return a._data instanceof j?(f.uncompressedSize=a._data.uncompressedSize,f.crc32=a._data.crc32,0===f.uncompressedSize||a.dir?(b=i.STORE,f.compressedContent="",f.crc32=0):a._data.compressionMethod===b.magic?f.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c)))):(c=p(a),(!c||0===c.length||a.dir)&&(b=i.STORE,c=""),f.uncompressedSize=c.length,f.crc32=e(c),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c))),f.compressedSize=f.compressedContent.length,f.compressionMethod=b.magic,f},z=function(a,b,c,g){var h,i,j,k,m=(c.compressedContent,d.transformTo("string",l.utf8encode(b.name))),n=b.comment||"",o=d.transformTo("string",l.utf8encode(n)),p=m.length!==b.name.length,q=o.length!==n.length,r=b.options,t="",u="",v="";j=b._initialMetadata.dir!==b.dir?b.dir:r.dir,k=b._initialMetadata.date!==b.date?b.date:r.date,h=k.getHours(),h<<=6,h|=k.getMinutes(),h<<=5,h|=k.getSeconds()/2,i=k.getFullYear()-1980,i<<=4,i|=k.getMonth()+1,i<<=5,i|=k.getDate(),p&&(u=s(1,1)+s(e(m),4)+m,t+="up"+s(u.length,2)+u),q&&(v=s(1,1)+s(this.crc32(o),4)+o,t+="uc"+s(v.length,2)+v);var w="";w+="\n\x00",w+=p||q?"\x00\b":"\x00\x00",w+=c.compressionMethod,w+=s(h,2),w+=s(i,2),w+=s(c.crc32,4),w+=s(c.compressedSize,4),w+=s(c.uncompressedSize,4),w+=s(m.length,2),w+=s(t.length,2);var x=f.LOCAL_FILE_HEADER+w+m+t,y=f.CENTRAL_FILE_HEADER+"\x00"+w+s(o.length,2)+"\x00\x00\x00\x00"+(j===!0?"\x00\x00\x00":"\x00\x00\x00\x00")+s(g,4)+m+t+o;return{fileRecord:x,dirRecord:y,compressedObject:c}},A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new r(d.name,d._data,t(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(d.isRegExp(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}return this.filter(function(b,c){return!c.dir&&b===a})[0]||null}return a=this.root+a,v.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d.isRegExp(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=x.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5}],19:[function(a,b){"use strict";var c=a("./utils"),d=function(a){this.data=new Uint8Array(a),this.index=0};d.prototype={append:function(a){0!==a.length&&(a=c.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}},b.exports=d},{"./utils":21}],20:[function(a,b,c){"use strict";for(var d=a("./utils"),e=a("./support"),f=a("./nodeBuffer"),g=new Array(256),h=0;256>h;h++)g[h]=h>=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;g[254]=g[254]=1;var i=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=e.uint8array?new Uint8Array(i):new Array(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},j=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+g[a[c]]>b?c:b},k=function(a){var b,c,e,f,h=a.length,i=new Array(2*h);for(c=0,b=0;h>b;)if(e=a[b++],128>e)i[c++]=e;else if(f=g[e],f>4)i[c++]=65533,b+=f-1;else{for(e&=2===f?31:3===f?15:7;f>1&&h>b;)e=e<<6|63&a[b++],f--;f>1?i[c++]=65533:65536>e?i[c++]=e:(e-=65536,i[c++]=55296|e>>10&1023,i[c++]=56320|1023&e)}return i.length!==c&&(i.subarray?i=i.subarray(0,c):i.length=c),d.applyFromCharCode(i)};c.utf8encode=function(a){return e.nodebuffer?f(a,"utf-8"):i(a)},c.utf8decode=function(a){if(e.nodebuffer)return d.transformTo("nodebuffer",a).toString("utf-8");a=d.transformTo(e.uint8array?"uint8array":"array",a);for(var b=[],c=0,f=a.length,g=65536;f>c;){var h=j(a,Math.min(c+g,f));b.push(k(e.uint8array?a.subarray(c,h):a.slice(c,h))),c=h}return b.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support"),k=a("./object");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=k.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=g.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==n)throw new Error(j[c]);b.header&&g.deflateSetHeader(this.strm,b.header) -};s.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?m:l,e.input="string"==typeof a?i.string2buf(a):a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new h.Buf8(f),e.next_out=0,e.avail_out=f),c=g.deflate(e,d),c!==o&&c!==n)return this.onEnd(c),this.ended=!0,!1;(0===e.avail_out||0===e.avail_in&&d===m)&&this.onData("string"===this.options.to?i.buf2binstring(h.shrinkBuf(e.output,e.next_out)):h.shrinkBuf(e.output,e.next_out))}while((e.avail_in>0||0===e.avail_out)&&c!==o);return d===m?(c=g.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===n):!0},s.prototype.onData=function(a){this.chunks.push(a)},s.prototype.onEnd=function(a){a===n&&(this.result="string"===this.options.to?this.chunks.join(""):h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=e,c.gzip=f},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(a,b,c){"use strict";function d(a,b){var c=new m(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,m=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,l.input="string"==typeof a?h.binstring2buf(a):a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(m),l.next_out=0,l.avail_out=m),c=f.inflate(l,i.Z_NO_FLUSH),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&d===i.Z_FINISH)&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=m-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out)))}while(l.avail_in>0&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):!0},m.prototype.onData=function(a){this.chunks.push(a)},m.prototype.onEnd=function(a){a===i.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=m,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],28:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":27}],29:[function(a,b){"use strict";function c(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=c},{}],30:[function(a,b){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(a,b){"use strict";function c(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function d(a,b,c,d){var f=e,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^f[255&(a^b[h])];return-1^a}var e=c();b.exports=d},{}],32:[function(a,b,c){"use strict";function d(a,b){return a.msg=G[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(C.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){D._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,C.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=E(a.adler,b,e,c):2===a.state.wrap&&(a.adler=F(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-jb?a.strstart-(a.w_size-jb):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ib,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ib-(m-f),f=m-ib,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-jb)){C.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=hb)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===H)return sb;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return sb;if(a.strstart-a.block_start>=a.w_size-jb&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?sb:sb}function o(a,b){for(var c,d;;){if(a.lookahead=hb&&(a.ins_h=(a.ins_h<=hb)if(d=D._tr_tally(a,a.strstart-a.match_start,a.match_length-hb),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=hb){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<=hb&&(a.ins_h=(a.ins_h<4096)&&(a.match_length=hb-1)),a.prev_length>=hb&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-hb,d=D._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-hb),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<=hb&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ib;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ib-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=hb?(c=D._tr_tally(a,1,a.match_length-hb),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===H)return sb;break}if(a.match_length=0,c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function s(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=B[a.level].max_lazy,a.good_match=B[a.level].good_length,a.nice_match=B[a.level].nice_length,a.max_chain_length=B[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=hb-1,a.match_available=0,a.ins_h=0}function t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*fb),this.dyn_dtree=new C.Buf16(2*(2*db+1)),this.bl_tree=new C.Buf16(2*(2*eb+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(gb+1),this.heap=new C.Buf16(2*cb+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*cb+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function u(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=X,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?lb:qb,a.adler=2===b.wrap?0:1,b.last_flush=H,D._tr_init(b),M):d(a,O)}function v(a){var b=u(a);return b===M&&s(a.state),b}function w(a,b){return a&&a.state?2!==a.state.wrap?O:(a.state.gzhead=b,M):O}function x(a,b,c,e,f,g){if(!a)return O;var h=1;if(b===R&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>Z||c!==Y||8>e||e>15||0>b||b>9||0>g||g>V)return d(a,O);8===e&&(e=9);var i=new t;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,v(a)}function y(a,b){return x(a,b,Y,$,_,W)}function z(a,b){var c,h,k,l;if(!a||!a.state||b>L||0>b)return a?d(a,O):O;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===rb&&b!==K)return d(a,0===a.avail_out?Q:O);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===lb)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=F(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=mb):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,wb),h.status=qb);else{var m=Y+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=T||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=kb),m+=31-m%31,h.status=qb,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===mb)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=nb)}else h.status=nb;if(h.status===nb)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=ob)}else h.status=ob;if(h.status===ob)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=pb)}else h.status=pb;if(h.status===pb&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=qb)):h.status=qb),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,M}else if(0===a.avail_in&&e(b)<=e(c)&&b!==K)return d(a,Q);if(h.status===rb&&0!==a.avail_in)return d(a,Q);if(0!==a.avail_in||0!==h.lookahead||b!==H&&h.status!==rb){var o=h.strategy===T?r(h,b):h.strategy===U?q(h,b):B[h.level].func(h,b);if((o===ub||o===vb)&&(h.status=rb),o===sb||o===ub)return 0===a.avail_out&&(h.last_flush=-1),M;if(o===tb&&(b===I?D._tr_align(h):b!==L&&(D._tr_stored_block(h,0,0,!1),b===J&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,M}return b!==K?M:h.wrap<=0?N:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?M:N)}function A(a){var b;return a&&a.state?(b=a.state.status,b!==lb&&b!==mb&&b!==nb&&b!==ob&&b!==pb&&b!==qb&&b!==rb?d(a,O):(a.state=null,b===qb?d(a,P):M)):O}var B,C=a("../utils/common"),D=a("./trees"),E=a("./adler32"),F=a("./crc32"),G=a("./messages"),H=0,I=1,J=3,K=4,L=5,M=0,N=1,O=-2,P=-3,Q=-5,R=-1,S=1,T=2,U=3,V=4,W=0,X=2,Y=8,Z=9,$=15,_=8,ab=29,bb=256,cb=bb+1+ab,db=30,eb=19,fb=2*cb+1,gb=15,hb=3,ib=258,jb=ib+hb+1,kb=32,lb=42,mb=69,nb=73,ob=91,pb=103,qb=113,rb=666,sb=1,tb=2,ub=3,vb=4,wb=3,xb=function(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e};B=[new xb(0,0,0,0,n),new xb(4,4,8,4,o),new xb(4,5,16,8,o),new xb(4,6,32,32,o),new xb(4,4,16,16,p),new xb(8,16,32,32,p),new xb(8,16,128,128,p),new xb(8,32,128,256,p),new xb(32,128,258,1024,p),new xb(32,258,258,4096,p)],c.deflateInit=y,c.deflateInit2=x,c.deflateReset=v,c.deflateResetKeep=u,c.deflateSetHeader=w,c.deflate=z,c.deflateEnd=A,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(a,b){"use strict";function c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=c},{}],34:[function(a,b){"use strict";var c=30,d=12;b.exports=function(a,b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;e=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=e.dmax,l=e.wsize,m=e.whave,n=e.wnext,o=e.window,p=e.hold,q=e.bits,r=e.lencode,s=e.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);break}for(c.back=0;Ab=c.lencode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a; -if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b<>V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b<>>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1<>=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1<=b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++jj){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)}),function(){"use strict";var a={application:{"andrew-inset":"ez",annodex:"anx","atom+xml":"atom","atomcat+xml":"atomcat","atomserv+xml":"atomsrv",bbolin:"lin",cap:["cap","pcap"],"cu-seeme":"cu","davmount+xml":"davmount",dsptype:"tsp",ecmascript:["es","ecma"],futuresplash:"spl",hta:"hta","java-archive":"jar","java-serialized-object":"ser","java-vm":"class",javascript:"js",m3g:"m3g","mac-binhex40":"hqx",mathematica:["nb","ma","mb"],msaccess:"mdb",msword:["doc","dot"],mxf:"mxf",oda:"oda",ogg:"ogx",pdf:"pdf","pgp-keys":"key","pgp-signature":["asc","sig"],"pics-rules":"prf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],rar:"rar","rdf+xml":"rdf","rss+xml":"rss",rtf:"rtf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd"],"xspf+xml":"xspf",zip:"zip","vnd.android.package-archive":"apk","vnd.cinderella":"cdy","vnd.google-earth.kml+xml":"kml","vnd.google-earth.kmz":"kmz","vnd.mozilla.xul+xml":"xul","vnd.ms-excel":["xls","xlb","xlt","xlm","xla","xlc","xlw"],"vnd.ms-pki.seccat":"cat","vnd.ms-pki.stl":"stl","vnd.ms-powerpoint":["ppt","pps","pot"],"vnd.oasis.opendocument.chart":"odc","vnd.oasis.opendocument.database":"odb","vnd.oasis.opendocument.formula":"odf","vnd.oasis.opendocument.graphics":"odg","vnd.oasis.opendocument.graphics-template":"otg","vnd.oasis.opendocument.image":"odi","vnd.oasis.opendocument.presentation":"odp","vnd.oasis.opendocument.presentation-template":"otp","vnd.oasis.opendocument.spreadsheet":"ods","vnd.oasis.opendocument.spreadsheet-template":"ots","vnd.oasis.opendocument.text":"odt","vnd.oasis.opendocument.text-master":"odm","vnd.oasis.opendocument.text-template":"ott","vnd.oasis.opendocument.text-web":"oth","vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","vnd.openxmlformats-officedocument.spreadsheetml.template":"xltx","vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","vnd.openxmlformats-officedocument.presentationml.slideshow":"ppsx","vnd.openxmlformats-officedocument.presentationml.template":"potx","vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","vnd.openxmlformats-officedocument.wordprocessingml.template":"dotx","vnd.smaf":"mmf","vnd.stardivision.calc":"sdc","vnd.stardivision.chart":"sds","vnd.stardivision.draw":"sda","vnd.stardivision.impress":"sdd","vnd.stardivision.math":["sdf","smf"],"vnd.stardivision.writer":["sdw","vor"],"vnd.stardivision.writer-global":"sgl","vnd.sun.xml.calc":"sxc","vnd.sun.xml.calc.template":"stc","vnd.sun.xml.draw":"sxd","vnd.sun.xml.draw.template":"std","vnd.sun.xml.impress":"sxi","vnd.sun.xml.impress.template":"sti","vnd.sun.xml.math":"sxm","vnd.sun.xml.writer":"sxw","vnd.sun.xml.writer.global":"sxg","vnd.sun.xml.writer.template":"stw","vnd.symbian.install":["sis","sisx"],"vnd.visio":["vsd","vst","vss","vsw"],"vnd.wap.wbxml":"wbxml","vnd.wap.wmlc":"wmlc","vnd.wap.wmlscriptc":"wmlsc","vnd.wordperfect":"wpd","vnd.wordperfect5.1":"wp5","x-123":"wk","x-7z-compressed":"7z","x-abiword":"abw","x-apple-diskimage":"dmg","x-bcpio":"bcpio","x-bittorrent":"torrent","x-cbr":["cbr","cba","cbt","cb7"],"x-cbz":"cbz","x-cdf":["cdf","cda"],"x-cdlink":"vcd","x-chess-pgn":"pgn","x-cpio":"cpio","x-csh":"csh","x-debian-package":["deb","udeb"],"x-director":["dcr","dir","dxr","cst","cct","cxt","w3d","fgd","swa"],"x-dms":"dms","x-doom":"wad","x-dvi":"dvi","x-httpd-eruby":"rhtml","x-font":"pcf.Z","x-freemind":"mm","x-gnumeric":"gnumeric","x-go-sgf":"sgf","x-graphing-calculator":"gcf","x-gtar":["gtar","taz"],"x-hdf":"hdf","x-httpd-php":["phtml","pht","php"],"x-httpd-php-source":"phps","x-httpd-php3":"php3","x-httpd-php3-preprocessed":"php3p","x-httpd-php4":"php4","x-httpd-php5":"php5","x-ica":"ica","x-info":"info","x-internet-signup":["ins","isp"],"x-iphone":"iii","x-iso9660-image":"iso","x-java-jnlp-file":"jnlp","x-jmol":"jmz","x-killustrator":"kil","x-koan":["skp","skd","skt","skm"],"x-kpresenter":["kpr","kpt"],"x-kword":["kwd","kwt"],"x-latex":"latex","x-lha":"lha","x-lyx":"lyx","x-lzh":"lzh","x-lzx":"lzx","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-ms-wmd":"wmd","x-ms-wmz":"wmz","x-msdos-program":["com","exe","bat","dll"],"x-msi":"msi","x-netcdf":["nc","cdf"],"x-ns-proxy-autoconfig":["pac","dat"],"x-nwc":"nwc","x-object":"o","x-oz-application":"oza","x-pkcs7-certreqresp":"p7r","x-python-code":["pyc","pyo"],"x-qgis":["qgs","shp","shx"],"x-quicktimeplayer":"qtl","x-redhat-package-manager":"rpm","x-ruby":"rb","x-sh":"sh","x-shar":"shar","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","x-stuffit":"sit","x-sv4cpio":"sv4cpio","x-sv4crc":"sv4crc","x-tar":"tar","x-tcl":"tcl","x-tex-gf":"gf","x-tex-pk":"pk","x-texinfo":["texinfo","texi"],"x-trash":["~","%","bak","old","sik"],"x-troff":["t","tr","roff"],"x-troff-man":"man","x-troff-me":"me","x-troff-ms":"ms","x-ustar":"ustar","x-wais-source":"src","x-wingz":"wz","x-x509-ca-cert":["crt","der","cer"],"x-xcf":"xcf","x-xfig":"fig","x-xpinstall":"xpi",applixware:"aw","atomsvc+xml":"atomsvc","ccxml+xml":"ccxml","cdmi-capability":"cdmia","cdmi-container":"cdmic","cdmi-domain":"cdmid","cdmi-object":"cdmio","cdmi-queue":"cdmiq","docbook+xml":"dbk","dssc+der":"dssc","dssc+xml":"xdssc","emma+xml":"emma","epub+zip":"epub",exi:"exi","font-tdpfr":"pfr","gml+xml":"gml","gpx+xml":"gpx",gxf:"gxf",hyperstudio:"stk","inkml+xml":["ink","inkml"],ipfix:"ipfix",json:"json","jsonml+json":"jsonml","lost+xml":"lostxml","mads+xml":"mads",marc:"mrc","marcxml+xml":"mrcx","mathml+xml":"mathml",mbox:"mbox","mediaservercontrol+xml":"mscml","metalink+xml":"metalink","metalink4+xml":"meta4","mets+xml":"mets","mods+xml":"mods",mp21:["m21","mp21"],mp4:"mp4s","oebps-package+xml":"opf","omdoc+xml":"omdoc",onenote:["onetoc","onetoc2","onetmp","onepkg"],oxps:"oxps","patch-ops-error+xml":"xer","pgp-encrypted":"pgp",pkcs10:"p10","pkcs7-mime":["p7m","p7c"],"pkcs7-signature":"p7s",pkcs8:"p8","pkix-attr-cert":"ac","pkix-crl":"crl","pkix-pkipath":"pkipath",pkixcmp:"pki","pls+xml":"pls","prs.cww":"cww","pskc+xml":"pskcxml","reginfo+xml":"rif","relax-ng-compact-syntax":"rnc","resource-lists+xml":"rl","resource-lists-diff+xml":"rld","rls-services+xml":"rs","rpki-ghostbusters":"gbr","rpki-manifest":"mft","rpki-roa":"roa","rsd+xml":"rsd","sbml+xml":"sbml","scvp-cv-request":"scq","scvp-cv-response":"scs","scvp-vp-request":"spq","scvp-vp-response":"spp",sdp:"sdp","set-payment-initiation":"setpay","set-registration-initiation":"setreg","shf+xml":"shf","sparql-query":"rq","sparql-results+xml":"srx",srgs:"gram","srgs+xml":"grxml","sru+xml":"sru","ssdl+xml":"ssdl","ssml+xml":"ssml","tei+xml":["tei","teicorpus"],"thraud+xml":"tfi","timestamped-data":"tsd","vnd.3gpp.pic-bw-large":"plb","vnd.3gpp.pic-bw-small":"psb","vnd.3gpp.pic-bw-var":"pvb","vnd.3gpp2.tcap":"tcap","vnd.3m.post-it-notes":"pwn","vnd.accpac.simply.aso":"aso","vnd.accpac.simply.imp":"imp","vnd.acucobol":"acu","vnd.acucorp":["atc","acutc"],"vnd.adobe.air-application-installer-package+zip":"air","vnd.adobe.formscentral.fcdt":"fcdt","vnd.adobe.fxp":["fxp","fxpl"],"vnd.adobe.xdp+xml":"xdp","vnd.adobe.xfdf":"xfdf","vnd.ahead.space":"ahead","vnd.airzip.filesecure.azf":"azf","vnd.airzip.filesecure.azs":"azs","vnd.amazon.ebook":"azw","vnd.americandynamics.acc":"acc","vnd.amiga.ami":"ami","vnd.anser-web-certificate-issue-initiation":"cii","vnd.anser-web-funds-transfer-initiation":"fti","vnd.antix.game-component":"atx","vnd.apple.installer+xml":"mpkg","vnd.apple.mpegurl":"m3u8","vnd.aristanetworks.swi":"swi","vnd.astraea-software.iota":"iota","vnd.audiograph":"aep","vnd.blueice.multipass":"mpm","vnd.bmi":"bmi","vnd.businessobjects":"rep","vnd.chemdraw+xml":"cdxml","vnd.chipnuts.karaoke-mmd":"mmd","vnd.claymore":"cla","vnd.cloanto.rp9":"rp9","vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"vnd.cluetrust.cartomobile-config":"c11amc","vnd.cluetrust.cartomobile-config-pkg":"c11amz","vnd.commonspace":"csp","vnd.contact.cmsg":"cdbcmsg","vnd.cosmocaller":"cmc","vnd.crick.clicker":"clkx","vnd.crick.clicker.keyboard":"clkk","vnd.crick.clicker.palette":"clkp","vnd.crick.clicker.template":"clkt","vnd.crick.clicker.wordbank":"clkw","vnd.criticaltools.wbs+xml":"wbs","vnd.ctc-posml":"pml","vnd.cups-ppd":"ppd","vnd.curl.car":"car","vnd.curl.pcurl":"pcurl","vnd.dart":"dart","vnd.data-vision.rdz":"rdz","vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"vnd.dece.ttml+xml":["uvt","uvvt"],"vnd.dece.unspecified":["uvx","uvvx"],"vnd.dece.zip":["uvz","uvvz"],"vnd.denovo.fcselayout-link":"fe_launch","vnd.dna":"dna","vnd.dolby.mlp":"mlp","vnd.dpgraph":"dpg","vnd.dreamfactory":"dfac","vnd.ds-keypoint":"kpxx","vnd.dvb.ait":"ait","vnd.dvb.service":"svc","vnd.dynageo":"geo","vnd.ecowin.chart":"mag","vnd.enliven":"nml","vnd.epson.esf":"esf","vnd.epson.msf":"msf","vnd.epson.quickanime":"qam","vnd.epson.salt":"slt","vnd.epson.ssf":"ssf","vnd.eszigno3+xml":["es3","et3"],"vnd.ezpix-album":"ez2","vnd.ezpix-package":"ez3","vnd.fdf":"fdf","vnd.fdsn.mseed":"mseed","vnd.fdsn.seed":["seed","dataless"],"vnd.flographit":"gph","vnd.fluxtime.clip":"ftc","vnd.framemaker":["fm","frame","maker","book"],"vnd.frogans.fnc":"fnc","vnd.frogans.ltf":"ltf","vnd.fsc.weblaunch":"fsc","vnd.fujitsu.oasys":"oas","vnd.fujitsu.oasys2":"oa2","vnd.fujitsu.oasys3":"oa3","vnd.fujitsu.oasysgp":"fg5","vnd.fujitsu.oasysprs":"bh2","vnd.fujixerox.ddd":"ddd","vnd.fujixerox.docuworks":"xdw","vnd.fujixerox.docuworks.binder":"xbd","vnd.fuzzysheet":"fzs","vnd.genomatix.tuxedo":"txd","vnd.geogebra.file":"ggb","vnd.geogebra.tool":"ggt","vnd.geometry-explorer":["gex","gre"],"vnd.geonext":"gxt","vnd.geoplan":"g2w","vnd.geospace":"g3w","vnd.gmx":"gmx","vnd.grafeq":["gqf","gqs"],"vnd.groove-account":"gac","vnd.groove-help":"ghf","vnd.groove-identity-message":"gim","vnd.groove-injector":"grv","vnd.groove-tool-message":"gtm","vnd.groove-tool-template":"tpl","vnd.groove-vcard":"vcg","vnd.hal+xml":"hal","vnd.handheld-entertainment+xml":"zmm","vnd.hbci":"hbci","vnd.hhe.lesson-player":"les","vnd.hp-hpgl":"hpgl","vnd.hp-hpid":"hpid","vnd.hp-hps":"hps","vnd.hp-jlyt":"jlt","vnd.hp-pcl":"pcl","vnd.hp-pclxl":"pclxl","vnd.hydrostatix.sof-data":"sfd-hdstx","vnd.ibm.minipay":"mpy","vnd.ibm.modcap":["afp","listafp","list3820"],"vnd.ibm.rights-management":"irm","vnd.ibm.secure-container":"sc","vnd.iccprofile":["icc","icm"],"vnd.igloader":"igl","vnd.immervision-ivp":"ivp","vnd.immervision-ivu":"ivu","vnd.insors.igm":"igm","vnd.intercon.formnet":["xpw","xpx"],"vnd.intergeo":"i2g","vnd.intu.qbo":"qbo","vnd.intu.qfx":"qfx","vnd.ipunplugged.rcprofile":"rcprofile","vnd.irepository.package+xml":"irp","vnd.is-xpr":"xpr","vnd.isac.fcs":"fcs","vnd.jam":"jam","vnd.jcp.javame.midlet-rms":"rms","vnd.jisp":"jisp","vnd.joost.joda-archive":"joda","vnd.kahootz":["ktz","ktr"],"vnd.kde.karbon":"karbon","vnd.kde.kchart":"chrt","vnd.kde.kformula":"kfo","vnd.kde.kivio":"flw","vnd.kde.kontour":"kon","vnd.kde.kpresenter":["kpr","kpt"],"vnd.kde.kspread":"ksp","vnd.kde.kword":["kwd","kwt"],"vnd.kenameaapp":"htke","vnd.kidspiration":"kia","vnd.kinar":["kne","knp"],"vnd.koan":["skp","skd","skt","skm"],"vnd.kodak-descriptor":"sse","vnd.las.las+xml":"lasxml","vnd.llamagraphics.life-balance.desktop":"lbd","vnd.llamagraphics.life-balance.exchange+xml":"lbe","vnd.lotus-1-2-3":"123","vnd.lotus-approach":"apr","vnd.lotus-freelance":"pre","vnd.lotus-notes":"nsf","vnd.lotus-organizer":"org","vnd.lotus-screencam":"scm","vnd.lotus-wordpro":"lwp","vnd.macports.portpkg":"portpkg","vnd.mcd":"mcd","vnd.medcalcdata":"mc1","vnd.mediastation.cdkey":"cdkey","vnd.mfer":"mwf","vnd.mfmp":"mfm","vnd.micrografx.flo":"flo","vnd.micrografx.igx":"igx","vnd.mif":"mif","vnd.mobius.daf":"daf","vnd.mobius.dis":"dis","vnd.mobius.mbk":"mbk","vnd.mobius.mqy":"mqy","vnd.mobius.msl":"msl","vnd.mobius.plc":"plc","vnd.mobius.txf":"txf","vnd.mophun.application":"mpn","vnd.mophun.certificate":"mpc","vnd.ms-artgalry":"cil","vnd.ms-cab-compressed":"cab","vnd.ms-excel.addin.macroenabled.12":"xlam","vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","vnd.ms-excel.sheet.macroenabled.12":"xlsm","vnd.ms-excel.template.macroenabled.12":"xltm","vnd.ms-fontobject":"eot","vnd.ms-htmlhelp":"chm","vnd.ms-ims":"ims","vnd.ms-lrm":"lrm","vnd.ms-officetheme":"thmx","vnd.ms-powerpoint.addin.macroenabled.12":"ppam","vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","vnd.ms-powerpoint.slide.macroenabled.12":"sldm","vnd.ms-powerpoint.slideshow.macroenabled.12":"ppsm","vnd.ms-powerpoint.template.macroenabled.12":"potm","vnd.ms-project":["mpp","mpt"],"vnd.ms-word.document.macroenabled.12":"docm","vnd.ms-word.template.macroenabled.12":"dotm","vnd.ms-works":["wps","wks","wcm","wdb"],"vnd.ms-wpl":"wpl","vnd.ms-xpsdocument":"xps","vnd.mseq":"mseq","vnd.musician":"mus","vnd.muvee.style":"msty","vnd.mynfc":"taglet","vnd.neurolanguage.nlu":"nlu","vnd.nitf":["ntf","nitf"],"vnd.noblenet-directory":"nnd","vnd.noblenet-sealer":"nns","vnd.noblenet-web":"nnw","vnd.nokia.n-gage.data":"ngdat","vnd.nokia.n-gage.symbian.install":"n-gage","vnd.nokia.radio-preset":"rpst","vnd.nokia.radio-presets":"rpss","vnd.novadigm.edm":"edm","vnd.novadigm.edx":"edx","vnd.novadigm.ext":"ext","vnd.oasis.opendocument.chart-template":"otc","vnd.oasis.opendocument.formula-template":"odft","vnd.oasis.opendocument.image-template":"oti","vnd.olpc-sugar":"xo","vnd.oma.dd2+xml":"dd2","vnd.openofficeorg.extension":"oxt","vnd.openxmlformats-officedocument.presentationml.slide":"sldx","vnd.osgeo.mapguide.package":"mgp","vnd.osgi.dp":"dp","vnd.osgi.subsystem":"esa","vnd.palm":["pdb","pqa","oprc"],"vnd.pawaafile":"paw","vnd.pg.format":"str","vnd.pg.osasli":"ei6","vnd.picsel":"efif","vnd.pmi.widget":"wg","vnd.pocketlearn":"plf","vnd.powerbuilder6":"pbd","vnd.previewsystems.box":"box","vnd.proteus.magazine":"mgz","vnd.publishare-delta-tree":"qps","vnd.pvi.ptid1":"ptid","vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"vnd.realvnc.bed":"bed","vnd.recordare.musicxml":"mxl","vnd.recordare.musicxml+xml":"musicxml","vnd.rig.cryptonote":"cryptonote","vnd.rn-realmedia":"rm","vnd.rn-realmedia-vbr":"rmvb","vnd.route66.link66+xml":"link66","vnd.sailingtracker.track":"st","vnd.seemail":"see","vnd.sema":"sema","vnd.semd":"semd","vnd.semf":"semf","vnd.shana.informed.formdata":"ifm","vnd.shana.informed.formtemplate":"itp","vnd.shana.informed.interchange":"iif","vnd.shana.informed.package":"ipk","vnd.simtech-mindmapper":["twd","twds"],"vnd.smart.teacher":"teacher","vnd.solent.sdkm+xml":["sdkm","sdkd"],"vnd.spotfire.dxp":"dxp","vnd.spotfire.sfs":"sfs","vnd.stepmania.package":"smzip","vnd.stepmania.stepchart":"sm","vnd.sus-calendar":["sus","susp"],"vnd.svd":"svd","vnd.syncml+xml":"xsm","vnd.syncml.dm+wbxml":"bdm","vnd.syncml.dm+xml":"xdm","vnd.tao.intent-module-archive":"tao","vnd.tcpdump.pcap":["pcap","cap","dmp"],"vnd.tmobile-livetv":"tmo","vnd.trid.tpt":"tpt","vnd.triscape.mxs":"mxs","vnd.trueapp":"tra","vnd.ufdl":["ufd","ufdl"],"vnd.uiq.theme":"utz","vnd.umajin":"umj","vnd.unity":"unityweb","vnd.uoml+xml":"uoml","vnd.vcx":"vcx","vnd.visionary":"vis","vnd.vsf":"vsf","vnd.webturbo":"wtb","vnd.wolfram.player":"nbp","vnd.wqd":"wqd","vnd.wt.stf":"stf","vnd.xara":"xar","vnd.xfdl":"xfdl","vnd.yamaha.hv-dic":"hvd","vnd.yamaha.hv-script":"hvs","vnd.yamaha.hv-voice":"hvp","vnd.yamaha.openscoreformat":"osf","vnd.yamaha.openscoreformat.osfpvg+xml":"osfpvg","vnd.yamaha.smaf-audio":"saf","vnd.yamaha.smaf-phrase":"spf","vnd.yellowriver-custom-menu":"cmp","vnd.zul":["zir","zirz"],"vnd.zzazz.deck+xml":"zaz","voicexml+xml":"vxml",widget:"wgt",winhlp:"hlp","wsdl+xml":"wsdl","wspolicy+xml":"wspolicy","x-ace-compressed":"ace","x-authorware-bin":["aab","x32","u32","vox"],"x-authorware-map":"aam","x-authorware-seg":"aas","x-blorb":["blb","blorb"],"x-bzip":"bz","x-bzip2":["bz2","boz"],"x-cfs-compressed":"cfs","x-chat":"chat","x-conference":"nsc","x-dgc-compressed":"dgc","x-dtbncx+xml":"ncx","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-eva":"eva","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-freearc":"arc","x-gca-compressed":"gca","x-glulx":"ulx","x-gramps-xml":"gramps","x-install-instructions":"install","x-lzh-compressed":["lzh","lha"],"x-mie":"mie","x-mobipocket-ebook":["prc","mobi"],"x-ms-application":"application","x-ms-shortcut":"lnk","x-ms-xbap":"xbap","x-msbinder":"obd","x-mscardfile":"crd","x-msclip":"clp","x-msdownload":["exe","dll","com","bat","msi"],"x-msmediaview":["mvb","m13","m14"],"x-msmetafile":["wmf","wmz","emf","emz"],"x-msmoney":"mny","x-mspublisher":"pub","x-msschedule":"scd","x-msterminal":"trm","x-mswrite":"wri","x-nzb":"nzb","x-pkcs12":["p12","pfx"],"x-pkcs7-certificates":["p7b","spc"],"x-research-info-systems":"ris","x-silverlight-app":"xap","x-sql":"sql","x-stuffitx":"sitx","x-subrip":"srt","x-t3vm-image":"t3","x-tads":"gam","x-tex":"tex","x-tex-tfm":"tfm","x-tgif":"obj","x-xliff+xml":"xlf","x-xz":"xz","x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"xaml+xml":"xaml","xcap-diff+xml":"xdf","xenc+xml":"xenc","xml-dtd":"dtd","xop+xml":"xop","xproc+xml":"xpl","xslt+xml":"xslt","xv+xml":["mxml","xhvml","xvml","xvm"],yang:"yang","yin+xml":"yin",envoy:"evy",fractals:"fif","internet-property-stream":"acx",olescript:"axs","vnd.ms-outlook":"msg","vnd.ms-pkicertstore":"sst","x-compress":"z","x-compressed":"tgz","x-gzip":"gz","x-perfmon":["pma","pmc","pml","pmr","pmw"],"x-pkcs7-mime":["p7c","p7m"],"ynd.ms-pkipko":"pko"},audio:{amr:"amr","amr-wb":"awb",annodex:"axa",basic:["au","snd"],flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"prs.sid":"sid","x-aiff":["aif","aiff","aifc"],"x-gsm":"gsm","x-ms-wma":"wma","x-ms-wax":"wax","x-pn-realaudio":"ram","x-realaudio":"ra","x-sd2":"sd2","x-wav":"wav",adpcm:"adp",mp4:"mp4a",s3m:"s3m",silk:"sil","vnd.dece.audio":["uva","uvva"],"vnd.digital-winds":"eol","vnd.dra":"dra","vnd.dts":"dts","vnd.dts.hd":"dtshd","vnd.lucent.voice":"lvp","vnd.ms-playready.media.pya":"pya","vnd.nuera.ecelp4800":"ecelp4800","vnd.nuera.ecelp7470":"ecelp7470","vnd.nuera.ecelp9600":"ecelp9600","vnd.rip":"rip",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},chemical:{"x-alchemy":"alc","x-cache":["cac","cache"],"x-cache-csf":"csf","x-cactvs-binary":["cbin","cascii","ctab"],"x-cdx":"cdx","x-chem3d":"c3d","x-cif":"cif","x-cmdf":"cmdf","x-cml":"cml","x-compass":"cpa","x-crossfire":"bsd","x-csml":["csml","csm"],"x-ctx":"ctx","x-cxf":["cxf","cef"],"x-embl-dl-nucleotide":["emb","embl"],"x-gamess-input":["inp","gam","gamin"],"x-gaussian-checkpoint":["fch","fchk"],"x-gaussian-cube":"cub","x-gaussian-input":["gau","gjc","gjf"],"x-gaussian-log":"gal","x-gcg8-sequence":"gcg","x-genbank":"gen","x-hin":"hin","x-isostar":["istr","ist"],"x-jcamp-dx":["jdx","dx"],"x-kinemage":"kin","x-macmolecule":"mcm","x-macromodel-input":["mmd","mmod"],"x-mdl-molfile":"mol","x-mdl-rdfile":"rd","x-mdl-rxnfile":"rxn","x-mdl-sdfile":["sd","sdf"],"x-mdl-tgf":"tgf","x-mmcif":"mcif","x-mol2":"mol2","x-molconn-Z":"b","x-mopac-graph":"gpt","x-mopac-input":["mop","mopcrt","mpc","zmt"],"x-mopac-out":"moo","x-ncbi-asn1":"asn","x-ncbi-asn1-ascii":["prt","ent"],"x-ncbi-asn1-binary":["val","aso"],"x-pdb":["pdb","ent"],"x-rosdal":"ros","x-swissprot":"sw","x-vamas-iso14976":"vms","x-vmd":"vmd","x-xtel":"xtel","x-xyz":"xyz"},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"vnd.djvu":["djvu","djv"],"vnd.wap.wbmp":"wbmp","x-canon-cr2":"cr2","x-canon-crw":"crw","x-cmu-raster":"ras","x-coreldraw":"cdr","x-coreldrawpattern":"pat","x-coreldrawtemplate":"cdt","x-corelphotopaint":"cpt","x-epson-erf":"erf","x-icon":"ico","x-jg":"art","x-jng":"jng","x-nikon-nef":"nef","x-olympus-orf":"orf","x-photoshop":"psd","x-portable-anymap":"pnm","x-portable-bitmap":"pbm","x-portable-graymap":"pgm","x-portable-pixmap":"ppm","x-rgb":"rgb","x-xbitmap":"xbm","x-xpixmap":"xpm","x-xwindowdump":"xwd",bmp:"bmp",cgm:"cgm",g3fax:"g3",ktx:"ktx","prs.btif":"btif",sgi:"sgi","vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"vnd.dwg":"dwg","vnd.dxf":"dxf","vnd.fastbidsheet":"fbs","vnd.fpx":"fpx","vnd.fst":"fst","vnd.fujixerox.edmics-mmr":"mmr","vnd.fujixerox.edmics-rlc":"rlc","vnd.ms-modi":"mdi","vnd.ms-photo":"wdp","vnd.net-fpx":"npx","vnd.xiff":"xif",webp:"webp","x-3ds":"3ds","x-cmx":"cmx","x-freehand":["fh","fhc","fh4","fh5","fh7"],"x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod",pipeg:"jfif"},message:{rfc822:["eml","mime","mht","mhtml","nws"]},model:{iges:["igs","iges"],mesh:["msh","mesh","silo"],vrml:["wrl","vrml"],"x3d+vrml":["x3dv","x3dvz"],"x3d+xml":["x3d","x3dz"],"x3d+binary":["x3db","x3dbz"],"vnd.collada+xml":"dae","vnd.dwf":"dwf","vnd.gdl":"gdl","vnd.gtw":"gtw","vnd.mts":"mts","vnd.vtu":"vtu"},text:{"cache-manifest":["manifest","appcache"],calendar:["ics","icz","ifb"],css:"css",csv:"csv",h323:"323",html:["html","htm","shtml","stm"],iuls:"uls",mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx",scriptlet:["sct","wsc"],texmacs:["tm","ts"],"tab-separated-values":"tsv","vnd.sun.j2me.app-descriptor":"jad","vnd.wap.wml":"wml","vnd.wap.wmlscript":"wmls","x-bibtex":"bib","x-boo":"boo","x-c++hdr":["h++","hpp","hxx","hh"],"x-c++src":["c++","cpp","cxx","cc"],"x-component":"htc","x-dsrc":"d","x-diff":["diff","patch"],"x-haskell":"hs","x-java":"java","x-literate-haskell":"lhs","x-moc":"moc","x-pascal":["p","pas"],"x-pcs-gcd":"gcd","x-perl":["pl","pm"],"x-python":"py","x-scala":"scala","x-setext":"etx","x-tcl":["tcl","tk"],"x-tex":["tex","ltx","sty","cls"],"x-vcalendar":"vcs","x-vcard":"vcf",n3:"n3","prs.lines.tag":"dsc",sgml:["sgml","sgm"],troff:["t","tr","roff","man","me","ms"],turtle:"ttl","uri-list":["uri","uris","urls"],vcard:"vcard","vnd.curl":"curl","vnd.curl.dcurl":"dcurl","vnd.curl.scurl":"scurl","vnd.curl.mcurl":"mcurl","vnd.dvb.subtitle":"sub","vnd.fly":"fly","vnd.fmi.flexstor":"flx","vnd.graphviz":"gv","vnd.in3d.3dml":"3dml","vnd.in3d.spot":"spot","x-asm":["s","asm"],"x-c":["c","cc","cxx","cpp","h","hh","dic"],"x-fortran":["f","for","f77","f90"],"x-opml":"opml","x-nfo":"nfo","x-sfv":"sfv","x-uuencode":"uu",webviewhtml:"htt"},video:{"3gpp":"3gp",annodex:"axv",dl:"dl",dv:["dif","dv"],fli:"fli",gl:"gl",mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.dece.hd":["uvh","uvvh"],"vnd.dece.mobile":["uvm","uvvm"],"vnd.dece.pd":["uvp","uvvp"],"vnd.dece.sd":["uvs","uvvs"],"vnd.dece.video":["uvv","uvvv"],"vnd.dvb.file":"dvb","vnd.fvt":"fvt","vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"},"x-conference":{"x-cooltalk":"ice"},"x-world":{"x-vrml":["vrm","vrml","wrl","flr","wrz","xaf","xof"]}},b=function(){var b,c,d,e,f={}; -for(b in a)if(a.hasOwnProperty(b))for(c in a[b])if(a[b].hasOwnProperty(c))if(d=a[b][c],"string"==typeof d)f[d]=b+"/"+c;else for(e=0;e= 0 && left <= width) { - annotatations.push($this.data('annotation')); - } - }); - - //-- Update viewer - annotator.updateViewer(annotatations); - }; - - var attach = function(){ - annotator = window.annotator; - annotator.frame.appendTo(element); - - annotator.subscribe('annotationEditorShown', function () { - showAnnotations(true); - }); - annotator.subscribe('annotationViewerShown', function () { - showAnnotations(true); - }); - - annotator.subscribe("annotationsLoaded", function(e){ - var _$ = reader.book.renderer.render.window.annotator.constructor.$; - - - reader.annotator = annotator; - updateAnnotations(); - - _$(reader.book.renderer.contents).on("click", ".annotator-hl", function(event){ - var $this = _$(this); - - reader.annotator.updateViewer([$this.data('annotation')]); - - // $scope.$apply(function(){ - // $scope.single = true; - // $scope.noUpdate = true; - // }); - - }); - }); - - $(".h-icon-comment").on("click", function () { - if ($main.hasClass("single")) { - showAnnotations(false); - } else { - showAnnotations(true); - } - }); - - reader.book.on("renderer:locationChanged", function(){ - updateAnnotations(); - }); - - } - - var showAnnotations = function(single) { - var currentPosition = reader.currentLocationCfi; - reader.settings.sidebarReflow = false; - - if(single) { - $main.addClass("single"); - window.annotator.setVisibleHighlights(true); - } else { - $main.removeClass("single"); - window.annotator.setVisibleHighlights(false); - } - - $main.one("transitionend", function(){ - book.gotoCfi(currentPosition); - }); - - }; - - book.ready.all.then(function() { - reader.HypothesisController.attach(); - }); - - return { - 'attach': attach - }; -}; \ No newline at end of file diff --git a/static/epub.js/plugins/search.js b/static/epub.js/plugins/search.js deleted file mode 100644 index 607f5a9..0000000 --- a/static/epub.js/plugins/search.js +++ /dev/null @@ -1,125 +0,0 @@ -EPUBJS.reader.search = {}; - -// Search Server -- https://github.com/futurepress/epubjs-search -EPUBJS.reader.search.SERVER = "https://pacific-cliffs-3579.herokuapp.com"; - -EPUBJS.reader.search.request = function(q, callback) { - var fetch = $.ajax({ - dataType: "json", - url: EPUBJS.reader.search.SERVER + "/search?q=" + encodeURIComponent(q) - }); - - fetch.fail(function(err) { - console.error(err); - }); - - fetch.done(function(results) { - callback(results); - }); -}; - -EPUBJS.reader.plugins.SearchController = function(Book) { - var reader = this; - - var $searchBox = $("#searchBox"), - $searchResults = $("#searchResults"), - $searchView = $("#searchView"), - iframeDoc; - - var searchShown = false; - - var onShow = function() { - query(); - searchShown = true; - $searchView.addClass("shown"); - }; - - var onHide = function() { - searchShown = false; - $searchView.removeClass("shown"); - }; - - var query = function() { - var q = $searchBox.val(); - - if(q == '') { - return; - } - - $searchResults.empty(); - $searchResults.append("
  • Searching...

  • "); - - - - EPUBJS.reader.search.request(q, function(data) { - var results = data.results; - - $searchResults.empty(); - - if(iframeDoc) { - $(iframeDoc).find('body').unhighlight(); - } - - if(results.length == 0) { - $searchResults.append("
  • No Results Found

  • "); - return; - } - - iframeDoc = $("#viewer iframe")[0].contentDocument; - $(iframeDoc).find('body').highlight(q, { element: 'span' }); - - results.forEach(function(result) { - var $li = $("
  • "); - var $item = $(""+result.title+"

    "+result.highlight+"

    "); - - $item.on("click", function(e) { - var $this = $(this), - cfi = $this.data("cfi"); - - e.preventDefault(); - - Book.gotoCfi(cfi+"/1:0"); - - Book.on("renderer:chapterDisplayed", function() { - iframeDoc = $("#viewer iframe")[0].contentDocument; - $(iframeDoc).find('body').highlight(q, { element: 'span' }); - }) - - - - }); - $li.append($item); - $searchResults.append($li); - }); - - }); - - }; - - $searchBox.on("search", function(e) { - var q = $searchBox.val(); - - //-- SearchBox is empty or cleared - if(q == '') { - $searchResults.empty(); - if(reader.SidebarController.getActivePanel() == "Search") { - reader.SidebarController.changePanelTo("Toc"); - } - - $(iframeDoc).find('body').unhighlight(); - iframeDoc = false; - return; - } - - reader.SidebarController.changePanelTo("Search"); - - e.preventDefault(); - }); - - - - return { - "show" : onShow, - "hide" : onHide - }; -}; diff --git a/static/epub.js/reader.js b/static/epub.js/reader.js deleted file mode 100644 index 178a7e4..0000000 --- a/static/epub.js/reader.js +++ /dev/null @@ -1,1124 +0,0 @@ -EPUBJS.reader = {}; -EPUBJS.reader.plugins = {}; //-- Attach extra Controllers as plugins (like search?) - -(function(root, $) { - - var previousReader = root.ePubReader || {}; - - var ePubReader = root.ePubReader = function(path, options) { - return new EPUBJS.Reader(path, options); - }; - - _.extend(ePubReader, { - noConflict : function() { - root.ePubReader = previousReader; - return this; - } - }); - - //exports to multiple environments - if (typeof define === 'function' && define.amd) - //AMD - define(function(){ return Reader; }); - else if (typeof module != "undefined" && module.exports) - //Node - module.exports = ePubReader; - -})(window, jQuery); - -EPUBJS.Reader = function(bookPath, _options) { - var reader = this; - var book; - var plugin; - var $viewer = $("#viewer"); - var search = window.location.search; - var parameters; - - this.settings = _.defaults(_options || {}, { - bookPath : bookPath, - restore : true, - reload : false, - bookmarks : null, - annotations : null, - contained : null, - bookKey : null, - styles : null, - sidebarReflow: false, - generatePagination: false, - history: true - }); - - // Overide options with search parameters - if(search) { - parameters = search.slice(1).split("&"); - parameters.forEach(function(p){ - var split = p.split("="); - var name = split[0]; - var value = split[1] || ''; - reader.settings[name] = value; - }); - } - - this.setBookKey(this.settings.bookPath); //-- This could be username + path or any unique string - - if(this.settings.restore && this.isSaved()) { - this.applySavedSettings(); - } - - this.settings.styles = this.settings.styles || { - fontSize : "100%" - }; - - this.book = book = new EPUBJS.Book({ - bookPath: this.settings.bookPath, - restore: this.settings.restore, - reload: this.settings.reload, - contained: this.settings.contained, - bookKey: this.settings.bookKey, - styles: this.settings.styles - }); - - if(this.settings.previousLocationCfi) { - book.gotoCfi(this.settings.previousLocationCfi); - } - - this.offline = false; - this.sidebarOpen = false; - if(!this.settings.bookmarks) { - this.settings.bookmarks = []; - } - - if(!this.settings.annotations) { - this.settings.annotations = []; - } - - if(this.settings.generatePagination) { - book.generatePagination($viewer.width(), $viewer.height()); - } - - book.renderTo("viewer"); - - reader.ReaderController = EPUBJS.reader.ReaderController.call(reader, book); - reader.SettingsController = EPUBJS.reader.SettingsController.call(reader, book); - reader.ControlsController = EPUBJS.reader.ControlsController.call(reader, book); - reader.SidebarController = EPUBJS.reader.SidebarController.call(reader, book); - reader.BookmarksController = EPUBJS.reader.BookmarksController.call(reader, book); - reader.NotesController = EPUBJS.reader.NotesController.call(reader, book); - - // Call Plugins - for(plugin in EPUBJS.reader.plugins) { - if(EPUBJS.reader.plugins.hasOwnProperty(plugin)) { - reader[plugin] = EPUBJS.reader.plugins[plugin].call(reader, book); - } - } - - book.ready.all.then(function() { - reader.ReaderController.hideLoader(); - }); - - book.getMetadata().then(function(meta) { - reader.MetaController = EPUBJS.reader.MetaController.call(reader, meta); - }); - - book.getToc().then(function(toc) { - reader.TocController = EPUBJS.reader.TocController.call(reader, toc); - }); - - window.addEventListener("beforeunload", this.unload.bind(this), false); - - window.addEventListener("hashchange", this.hashChanged.bind(this), false); - - document.addEventListener('keydown', this.adjustFontSize.bind(this), false); - - book.on("renderer:keydown", this.adjustFontSize.bind(this)); - book.on("renderer:keydown", reader.ReaderController.arrowKeys.bind(this)); - - book.on("renderer:selected", this.selectedRange.bind(this)); - - return this; -}; - -EPUBJS.Reader.prototype.adjustFontSize = function(e) { - var fontSize; - var interval = 2; - var PLUS = 187; - var MINUS = 189; - var ZERO = 48; - var MOD = (e.ctrlKey || e.metaKey ); - - if(!this.settings.styles) return; - - if(!this.settings.styles.fontSize) { - this.settings.styles.fontSize = "100%"; - } - - fontSize = parseInt(this.settings.styles.fontSize.slice(0, -1)); - - if(MOD && e.keyCode == PLUS) { - e.preventDefault(); - this.book.setStyle("fontSize", (fontSize + interval) + "%"); - - } - - if(MOD && e.keyCode == MINUS){ - - e.preventDefault(); - this.book.setStyle("fontSize", (fontSize - interval) + "%"); - } - - if(MOD && e.keyCode == ZERO){ - e.preventDefault(); - this.book.setStyle("fontSize", "100%"); - } -}; - -EPUBJS.Reader.prototype.addBookmark = function(cfi) { - var present = this.isBookmarked(cfi); - if(present > -1 ) return; - - this.settings.bookmarks.push(cfi); - - this.trigger("reader:bookmarked", cfi); -}; - -EPUBJS.Reader.prototype.removeBookmark = function(cfi) { - var bookmark = this.isBookmarked(cfi); - if( bookmark === -1 ) return; - - delete this.settings.bookmarks[bookmark]; - - this.trigger("reader:unbookmarked", bookmark); -}; - -EPUBJS.Reader.prototype.isBookmarked = function(cfi) { - var bookmarks = this.settings.bookmarks; - - return bookmarks.indexOf(cfi); -}; - -/* -EPUBJS.Reader.prototype.searchBookmarked = function(cfi) { - var bookmarks = this.settings.bookmarks, - len = bookmarks.length, - i; - - for(i = 0; i < len; i++) { - if (bookmarks[i]['cfi'] === cfi) return i; - } - return -1; -}; -*/ - -EPUBJS.Reader.prototype.clearBookmarks = function() { - this.settings.bookmarks = []; -}; - -//-- Notes -EPUBJS.Reader.prototype.addNote = function(note) { - this.settings.annotations.push(note); -}; - -EPUBJS.Reader.prototype.removeNote = function(note) { - var index = this.settings.annotations.indexOf(note); - if( index === -1 ) return; - - delete this.settings.annotations[index]; - -}; - -EPUBJS.Reader.prototype.clearNotes = function() { - this.settings.annotations = []; -}; - -//-- Settings -EPUBJS.Reader.prototype.setBookKey = function(identifier){ - if(!this.settings.bookKey) { - this.settings.bookKey = "epubjsreader:" + EPUBJS.VERSION + ":" + window.location.host + ":" + identifier; - } - return this.settings.bookKey; -}; - -//-- Checks if the book setting can be retrieved from localStorage -EPUBJS.Reader.prototype.isSaved = function(bookPath) { - var storedSettings; - - if(!localStorage) { - return false; - } - - storedSettings = localStorage.getItem(this.settings.bookKey); - - if(storedSettings === null) { - return false; - } else { - return true; - } -}; - -EPUBJS.Reader.prototype.removeSavedSettings = function() { - if(!localStorage) { - return false; - } - - localStorage.removeItem(this.settings.bookKey); -}; - -EPUBJS.Reader.prototype.applySavedSettings = function() { - var stored; - - if(!localStorage) { - return false; - } - - stored = JSON.parse(localStorage.getItem(this.settings.bookKey)); - - if(stored) { - this.settings = _.defaults(this.settings, stored); - return true; - } else { - return false; - } -}; - -EPUBJS.Reader.prototype.saveSettings = function(){ - if(this.book) { - this.settings.previousLocationCfi = this.book.getCurrentLocationCfi(); - } - - if(!localStorage) { - return false; - } - - localStorage.setItem(this.settings.bookKey, JSON.stringify(this.settings)); -}; - -EPUBJS.Reader.prototype.unload = function(){ - if(this.settings.restore && localStorage) { - this.saveSettings(); - } -}; - - -EPUBJS.Reader.prototype.hashChanged = function(){ - var hash = window.location.hash.slice(1); - this.book.goto(hash); -}; - -EPUBJS.Reader.prototype.selectedRange = function(range){ - var epubcfi = new EPUBJS.EpubCFI(); - var cfi = epubcfi.generateCfiFromRangeAnchor(range, this.book.renderer.currentChapter.cfiBase); - var cfiFragment = "#"+cfi; - - // Update the History Location - if(this.settings.history && - window.location.hash != cfiFragment) { - // Add CFI fragment to the history - history.pushState({}, '', cfiFragment); - this.currentLocationCfi = cfi; - } -}; - -//-- Enable binding events to reader -RSVP.EventTarget.mixin(EPUBJS.Reader.prototype); -EPUBJS.reader.BookmarksController = function() { - var reader = this; - var book = this.book; - - var $bookmarks = $("#bookmarksView"), - $list = $bookmarks.find("#bookmarks"); - - var docfrag = document.createDocumentFragment(); - - var show = function() { - $bookmarks.show(); - }; - - var hide = function() { - $bookmarks.hide(); - }; - - var counter = 0; - - var createBookmarkItem = function(cfi) { - var listitem = document.createElement("li"), - link = document.createElement("a"); - - listitem.id = "bookmark-"+counter; - listitem.classList.add('list_item'); - - //-- TODO: Parse Cfi - link.textContent = cfi; - link.href = cfi; - - link.classList.add('bookmark_link'); - - link.addEventListener("click", function(event){ - var cfi = this.getAttribute('href'); - book.gotoCfi(cfi); - event.preventDefault(); - }, false); - - listitem.appendChild(link); - - counter++; - - return listitem; - }; - - this.settings.bookmarks.forEach(function(cfi) { - var bookmark = createBookmarkItem(cfi); - docfrag.appendChild(bookmark); - }); - - $list.append(docfrag); - - this.on("reader:bookmarked", function(cfi) { - var item = createBookmarkItem(cfi); - $list.append(item); - }); - - this.on("reader:unbookmarked", function(index) { - var $item = $("#bookmark-"+index); - $item.remove(); - }); - - return { - "show" : show, - "hide" : hide - }; -}; -EPUBJS.reader.ControlsController = function(book) { - var reader = this; - - var $store = $("#store"), - $fullscreen = $("#fullscreen"), - $fullscreenicon = $("#fullscreenicon"), - $cancelfullscreenicon = $("#cancelfullscreenicon"), - $slider = $("#slider"), - $main = $("#main"), - $sidebar = $("#sidebar"), - $settings = $("#setting"), - $bookmark = $("#bookmark"); - - var goOnline = function() { - reader.offline = false; - // $store.attr("src", $icon.data("save")); - }; - - var goOffline = function() { - reader.offline = true; - // $store.attr("src", $icon.data("saved")); - }; - - var fullscreen = false; - - book.on("book:online", goOnline); - book.on("book:offline", goOffline); - - $slider.on("click", function () { - if(reader.sidebarOpen) { - reader.SidebarController.hide(); - $slider.addClass("icon-menu"); - $slider.removeClass("icon-right"); - } else { - reader.SidebarController.show(); - $slider.addClass("icon-right"); - $slider.removeClass("icon-menu"); - } - }); - - $fullscreen.on("click", function() { - screenfull.toggle($('#container')[0]); - }); - - if(screenfull) { - document.addEventListener(screenfull.raw.fullscreenchange, function() { - fullscreen = screenfull.isFullscreen; - if(fullscreen) { - $fullscreen - .addClass("icon-resize-small") - .removeClass("icon-resize-full"); - } else { - $fullscreen - .addClass("icon-resize-full") - .removeClass("icon-resize-small"); - } - }); - } - - $settings.on("click", function() { - reader.SettingsController.show(); - }); - - $bookmark.on("click", function() { - var cfi = reader.book.getCurrentLocationCfi(); - var bookmarked = reader.isBookmarked(cfi); - - if(bookmarked === -1) { //-- Add bookmark - reader.addBookmark(cfi); - $bookmark - .addClass("icon-bookmark") - .removeClass("icon-bookmark-empty"); - } else { //-- Remove Bookmark - reader.removeBookmark(cfi); - $bookmark - .removeClass("icon-bookmark") - .addClass("icon-bookmark-empty"); - } - - }); - - book.on('renderer:locationChanged', function(cfi){ - var cfiFragment = "#" + cfi; - //-- Check if bookmarked - var bookmarked = reader.isBookmarked(cfi); - if(bookmarked === -1) { //-- Not bookmarked - $bookmark - .removeClass("icon-bookmark") - .addClass("icon-bookmark-empty"); - } else { //-- Bookmarked - $bookmark - .addClass("icon-bookmark") - .removeClass("icon-bookmark-empty"); - } - - reader.currentLocationCfi = cfi; - - // Update the History Location - if(reader.settings.history && - window.location.hash != cfiFragment) { - // Add CFI fragment to the history - history.pushState({}, '', cfiFragment); - } - }); - - book.on('book:pageChanged', function(location){ - // console.log("page", location.page, location.percentage) - }); - - return { - - }; -}; -EPUBJS.reader.MetaController = function(meta) { - var title = meta.bookTitle, - author = meta.creator; - - var $title = $("#book-title"), - $author = $("#chapter-title"), - $dash = $("#title-seperator"); - - document.title = title+" – "+author; - - $title.html(title); - $author.html(author); - $dash.show(); -}; -EPUBJS.reader.NotesController = function() { - var book = this.book; - var reader = this; - var $notesView = $("#notesView"); - var $notes = $("#notes"); - var $text = $("#note-text"); - var $anchor = $("#note-anchor"); - var annotations = reader.settings.annotations; - var renderer = book.renderer; - var popups = []; - var epubcfi = new EPUBJS.EpubCFI(); - - var show = function() { - $notesView.show(); - }; - - var hide = function() { - $notesView.hide(); - } - - var insertAtPoint = function(e) { - var range; - var textNode; - var offset; - var doc = book.renderer.doc; - var cfi; - var annotation; - - // standard - if (doc.caretPositionFromPoint) { - range = doc.caretPositionFromPoint(e.clientX, e.clientY); - textNode = range.offsetNode; - offset = range.offset; - // WebKit - } else if (doc.caretRangeFromPoint) { - range = doc.caretRangeFromPoint(e.clientX, e.clientY); - textNode = range.startContainer; - offset = range.startOffset; - } - - if (textNode.nodeType !== 3) { - for (var i=0; i < textNode.childNodes.length; i++) { - if (textNode.childNodes[i].nodeType == 3) { - textNode = textNode.childNodes[i]; - break; - } - } - } - - // Find the end of the sentance - offset = textNode.textContent.indexOf(".", offset); - if(offset === -1){ - offset = textNode.length; // Last item - } else { - offset += 1; // After the period - } - - cfi = epubcfi.generateCfiFromTextNode(textNode, offset, book.renderer.currentChapter.cfiBase); - - annotation = { - annotatedAt: new Date(), - anchor: cfi, - body: $text.val() - } - - // add to list - reader.addNote(annotation); - - // attach - addAnnotation(annotation); - placeMarker(annotation); - - // clear - $text.val(''); - $anchor.text("Attach"); - $text.prop("disabled", false); - - book.off("renderer:click", insertAtPoint); - - }; - - var addAnnotation = function(annotation){ - var note = document.createElement("li"); - var link = document.createElement("a"); - - note.innerHTML = annotation.body; - // note.setAttribute("ref", annotation.anchor); - link.innerHTML = " context »"; - link.href = "#"+annotation.anchor; - link.onclick = function(){ - book.gotoCfi(annotation.anchor); - return false; - }; - - note.appendChild(link); - $notes.append(note); - - }; - - var placeMarker = function(annotation){ - var doc = book.renderer.doc; - var marker = document.createElement("span"); - var mark = document.createElement("a"); - marker.classList.add("footnotesuperscript", "reader_generated"); - - marker.style.verticalAlign = "super"; - marker.style.fontSize = ".75em"; - // marker.style.position = "relative"; - marker.style.lineHeight = "1em"; - - // mark.style.display = "inline-block"; - mark.style.padding = "2px"; - mark.style.backgroundColor = "#fffa96"; - mark.style.borderRadius = "5px"; - mark.style.cursor = "pointer"; - - marker.id = "note-"+EPUBJS.core.uuid(); - mark.innerHTML = annotations.indexOf(annotation) + 1 + "[Reader]"; - - marker.appendChild(mark); - epubcfi.addMarker(annotation.anchor, doc, marker); - - markerEvents(marker, annotation.body); - } - - var markerEvents = function(item, txt){ - var id = item.id; - - var showPop = function(){ - var poppos, - iheight = renderer.height, - iwidth = renderer.width, - tip, - pop, - maxHeight = 225, - itemRect, - left, - top, - pos; - - - //-- create a popup with endnote inside of it - if(!popups[id]) { - popups[id] = document.createElement("div"); - popups[id].setAttribute("class", "popup"); - - pop_content = document.createElement("div"); - - popups[id].appendChild(pop_content); - - pop_content.innerHTML = txt; - pop_content.setAttribute("class", "pop_content"); - - renderer.render.document.body.appendChild(popups[id]); - - //-- TODO: will these leak memory? - Fred - popups[id].addEventListener("mouseover", onPop, false); - popups[id].addEventListener("mouseout", offPop, false); - - //-- Add hide on page change - renderer.on("renderer:locationChanged", hidePop, this); - renderer.on("renderer:locationChanged", offPop, this); - // chapter.book.on("renderer:chapterDestroy", hidePop, this); - } - - pop = popups[id]; - - - //-- get location of item - itemRect = item.getBoundingClientRect(); - left = itemRect.left; - top = itemRect.top; - - //-- show the popup - pop.classList.add("show"); - - //-- locations of popup - popRect = pop.getBoundingClientRect(); - - //-- position the popup - pop.style.left = left - popRect.width / 2 + "px"; - pop.style.top = top + "px"; - - - //-- Adjust max height - if(maxHeight > iheight / 2.5) { - maxHeight = iheight / 2.5; - pop_content.style.maxHeight = maxHeight + "px"; - } - - //-- switch above / below - if(popRect.height + top >= iheight - 25) { - pop.style.top = top - popRect.height + "px"; - pop.classList.add("above"); - }else{ - pop.classList.remove("above"); - } - - //-- switch left - if(left - popRect.width <= 0) { - pop.style.left = left + "px"; - pop.classList.add("left"); - }else{ - pop.classList.remove("left"); - } - - //-- switch right - if(left + popRect.width / 2 >= iwidth) { - //-- TEMP MOVE: 300 - pop.style.left = left - 300 + "px"; - - popRect = pop.getBoundingClientRect(); - pop.style.left = left - popRect.width + "px"; - //-- switch above / below again - if(popRect.height + top >= iheight - 25) { - pop.style.top = top - popRect.height + "px"; - pop.classList.add("above"); - }else{ - pop.classList.remove("above"); - } - - pop.classList.add("right"); - }else{ - pop.classList.remove("right"); - } - - } - - var onPop = function(){ - popups[id].classList.add("on"); - } - - var offPop = function(){ - popups[id].classList.remove("on"); - } - - var hidePop = function(){ - setTimeout(function(){ - popups[id].classList.remove("show"); - }, 100); - } - - var openSidebar = function(){ - reader.ReaderController.slideOut(); - show(); - }; - - item.addEventListener("mouseover", showPop, false); - item.addEventListener("mouseout", hidePop, false); - item.addEventListener("click", openSidebar, false); - - } - $anchor.on("click", function(e){ - - $anchor.text("Cancel"); - $text.prop("disabled", "true"); - // listen for selection - book.on("renderer:click", insertAtPoint); - - }); - - annotations.forEach(function(note) { - addAnnotation(note); - }); - - - renderer.registerHook("beforeChapterDisplay", function(callback, renderer){ - var chapter = renderer.currentChapter; - annotations.forEach(function(note) { - var cfi = epubcfi.parse(note.anchor); - if(cfi.spinePos === chapter.spinePos) { - try { - placeMarker(note); - } catch(e) { - console.log("anchoring failed", note.anchor); - } - } - }); - callback(); - }, true); - - - return { - "show" : show, - "hide" : hide - }; -}; -EPUBJS.reader.ReaderController = function(book) { - var $main = $("#main"), - $divider = $("#divider"), - $loader = $("#loader"), - $next = $("#next"), - $prev = $("#prev"); - var reader = this; - var book = this.book; - var slideIn = function() { - var currentPosition = book.getCurrentLocationCfi(); - if (reader.settings.sidebarReflow){ - $main.removeClass('single'); - $main.one("transitionend", function(){ - book.gotoCfi(currentPosition); - }); - } else { - $main.removeClass("closed"); - } - }; - - var slideOut = function() { - var currentPosition = book.getCurrentLocationCfi(); - if (reader.settings.sidebarReflow){ - $main.addClass('single'); - $main.one("transitionend", function(){ - book.gotoCfi(currentPosition); - }); - } else { - $main.addClass("closed"); - } - }; - - var showLoader = function() { - $loader.show(); - hideDivider(); - }; - - var hideLoader = function() { - $loader.hide(); - - //-- If the book is using spreads, show the divider - // if(book.settings.spreads) { - // showDivider(); - // } - }; - - var showDivider = function() { - $divider.addClass("show"); - }; - - var hideDivider = function() { - $divider.removeClass("show"); - }; - - var keylock = false; - - var arrowKeys = function(e) { - if(e.keyCode == 37) { - book.prevPage(); - $prev.addClass("active"); - - keylock = true; - setTimeout(function(){ - keylock = false; - $prev.removeClass("active"); - }, 100); - - e.preventDefault(); - } - if(e.keyCode == 39) { - book.nextPage(); - $next.addClass("active"); - - keylock = true; - setTimeout(function(){ - keylock = false; - $next.removeClass("active"); - }, 100); - - e.preventDefault(); - } - } - - document.addEventListener('keydown', arrowKeys, false); - - $next.on("click", function(e){ - book.nextPage(); - e.preventDefault(); - }); - - $prev.on("click", function(e){ - book.prevPage(); - e.preventDefault(); - }); - - book.on("renderer:spreads", function(bool){ - if(bool) { - showDivider(); - } else { - hideDivider(); - } - }); - - // book.on("book:atStart", function(){ - // $prev.addClass("disabled"); - // }); - // - // book.on("book:atEnd", function(){ - // $next.addClass("disabled"); - // }); - - return { - "slideOut" : slideOut, - "slideIn" : slideIn, - "showLoader" : showLoader, - "hideLoader" : hideLoader, - "showDivider" : showDivider, - "hideDivider" : hideDivider, - "arrowKeys" : arrowKeys - }; -}; -EPUBJS.reader.SettingsController = function() { - var book = this.book; - var reader = this; - var $settings = $("#settings-modal"), - $overlay = $(".overlay"); - - var show = function() { - $settings.addClass("md-show"); - }; - - var hide = function() { - $settings.removeClass("md-show"); - }; - - var $sidebarReflowSetting = $('#sidebarReflow'); - - $sidebarReflowSetting.on('click', function() { - reader.settings.sidebarReflow = !reader.settings.sidebarReflow; - }); - - $settings.find(".closer").on("click", function() { - hide(); - }); - - $overlay.on("click", function() { - hide(); - }); - - return { - "show" : show, - "hide" : hide - }; -}; -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 - }; -}; -EPUBJS.reader.TocController = function(toc) { - var book = this.book; - - var $list = $("#tocView"), - docfrag = document.createDocumentFragment(); - - var currentChapter = false; - - var generateTocItems = function(toc, level) { - var container = document.createElement("ul"); - - if(!level) level = 1; - - toc.forEach(function(chapter) { - var listitem = document.createElement("li"), - link = document.createElement("a"); - toggle = document.createElement("a"); - - var subitems; - - listitem.id = "toc-"+chapter.id; - listitem.classList.add('list_item'); - - link.textContent = chapter.label; - link.href = chapter.href; - - link.classList.add('toc_link'); - - listitem.appendChild(link); - - if(chapter.subitems.length > 0) { - level++; - subitems = generateTocItems(chapter.subitems, level); - toggle.classList.add('toc_toggle'); - - listitem.insertBefore(toggle, link); - listitem.appendChild(subitems); - } - - - container.appendChild(listitem); - - }); - - return container; - }; - - var onShow = function() { - $list.show(); - }; - - var onHide = function() { - $list.hide(); - }; - - var chapterChange = function(e) { - var id = e.id, - $item = $list.find("#toc-"+id), - $current = $list.find(".currentChapter"), - $open = $list.find('.openChapter'); - - if($item.length){ - - if($item != $current && $item.has(currentChapter).length > 0) { - $current.removeClass("currentChapter"); - } - - $item.addClass("currentChapter"); - - // $open.removeClass("openChapter"); - $item.parents('li').addClass("openChapter"); - } - }; - - book.on('renderer:chapterDisplayed', chapterChange); - - var tocitems = generateTocItems(toc); - - docfrag.appendChild(tocitems); - - $list.append(docfrag); - $list.find(".toc_link").on("click", function(event){ - var url = this.getAttribute('href'); - - event.preventDefault(); - - //-- Provide the Book with the url to show - // The Url must be found in the books manifest - book.goto(url); - - $list.find(".currentChapter") - .addClass("openChapter") - .removeClass("currentChapter"); - - $(this).parent('li').addClass("currentChapter"); - - }); - - $list.find(".toc_toggle").on("click", function(event){ - var $el = $(this).parent('li'), - open = $el.hasClass("openChapter"); - - event.preventDefault(); - if(open){ - $el.removeClass("openChapter"); - } else { - $el.addClass("openChapter"); - } - }); - - return { - "show" : onShow, - "hide" : onHide - }; -}; - -//# sourceMappingURL=reader.js.map \ No newline at end of file diff --git a/static/epub.js/reader.js.map b/static/epub.js/reader.js.map deleted file mode 100644 index 7ed25d6..0000000 --- a/static/epub.js/reader.js.map +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 3, - "file": "reader.js", - "sources": [ - "reader_src/reader.js", - "reader_src/controllers/bookmarks_controller.js", - "reader_src/controllers/controls_controller.js", - "reader_src/controllers/meta_controller.js", - "reader_src/controllers/notes_controller.js", - "reader_src/controllers/reader_controller.js", - "reader_src/controllers/settings_controller.js", - "reader_src/controllers/sidebar_controller.js", - "reader_src/controllers/toc_controller.js" - ], - "names": [], - "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gD;ACjUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AClEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AC9RA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACxHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;AChCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,E;ACjDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A" -} \ No newline at end of file diff --git a/static/epub.js/reader.min.js b/static/epub.js/reader.min.js deleted file mode 100644 index 4c607fe..0000000 --- a/static/epub.js/reader.min.js +++ /dev/null @@ -1,2 +0,0 @@ -EPUBJS.reader={},EPUBJS.reader.plugins={},function(a){var b=a.ePubReader||{},c=a.ePubReader=function(a,b){return new EPUBJS.Reader(a,b)};_.extend(c,{noConflict:function(){return a.ePubReader=b,this}}),"function"==typeof define&&define.amd?define(function(){return Reader}):"undefined"!=typeof module&&module.exports&&(module.exports=c)}(window,jQuery),EPUBJS.Reader=function(a,b){var c,d,e,f=this,g=$("#viewer"),h=window.location.search;this.settings=_.defaults(b||{},{bookPath:a,restore:!0,reload:!1,bookmarks:null,annotations:null,contained:null,bookKey:null,styles:null,sidebarReflow:!1,generatePagination:!1,history:!0}),h&&(e=h.slice(1).split("&"),e.forEach(function(a){var b=a.split("="),c=b[0],d=b[1]||"";f.settings[c]=d})),this.setBookKey(this.settings.bookPath),this.settings.restore&&this.isSaved()&&this.applySavedSettings(),this.settings.styles=this.settings.styles||{fontSize:"100%"},this.book=c=new EPUBJS.Book({bookPath:this.settings.bookPath,restore:this.settings.restore,reload:this.settings.reload,contained:this.settings.contained,bookKey:this.settings.bookKey,styles:this.settings.styles}),this.settings.previousLocationCfi&&c.gotoCfi(this.settings.previousLocationCfi),this.offline=!1,this.sidebarOpen=!1,this.settings.bookmarks||(this.settings.bookmarks=[]),this.settings.annotations||(this.settings.annotations=[]),this.settings.generatePagination&&c.generatePagination(g.width(),g.height()),c.renderTo("viewer"),f.ReaderController=EPUBJS.reader.ReaderController.call(f,c),f.SettingsController=EPUBJS.reader.SettingsController.call(f,c),f.ControlsController=EPUBJS.reader.ControlsController.call(f,c),f.SidebarController=EPUBJS.reader.SidebarController.call(f,c),f.BookmarksController=EPUBJS.reader.BookmarksController.call(f,c),f.NotesController=EPUBJS.reader.NotesController.call(f,c);for(d in EPUBJS.reader.plugins)EPUBJS.reader.plugins.hasOwnProperty(d)&&(f[d]=EPUBJS.reader.plugins[d].call(f,c));return c.ready.all.then(function(){f.ReaderController.hideLoader()}),c.getMetadata().then(function(a){f.MetaController=EPUBJS.reader.MetaController.call(f,a)}),c.getToc().then(function(a){f.TocController=EPUBJS.reader.TocController.call(f,a)}),window.addEventListener("beforeunload",this.unload.bind(this),!1),window.addEventListener("hashchange",this.hashChanged.bind(this),!1),document.addEventListener("keydown",this.adjustFontSize.bind(this),!1),c.on("renderer:keydown",this.adjustFontSize.bind(this)),c.on("renderer:keydown",f.ReaderController.arrowKeys.bind(this)),c.on("renderer:selected",this.selectedRange.bind(this)),this},EPUBJS.Reader.prototype.adjustFontSize=function(a){var b,c=2,d=187,e=189,f=48,g=a.ctrlKey||a.metaKey;this.settings.styles&&(this.settings.styles.fontSize||(this.settings.styles.fontSize="100%"),b=parseInt(this.settings.styles.fontSize.slice(0,-1)),g&&a.keyCode==d&&(a.preventDefault(),this.book.setStyle("fontSize",b+c+"%")),g&&a.keyCode==e&&(a.preventDefault(),this.book.setStyle("fontSize",b-c+"%")),g&&a.keyCode==f&&(a.preventDefault(),this.book.setStyle("fontSize","100%")))},EPUBJS.Reader.prototype.addBookmark=function(a){var b=this.isBookmarked(a);b>-1||(this.settings.bookmarks.push(a),this.trigger("reader:bookmarked",a))},EPUBJS.Reader.prototype.removeBookmark=function(a){var b=this.isBookmarked(a);-1!==b&&(delete this.settings.bookmarks[b],this.trigger("reader:unbookmarked",b))},EPUBJS.Reader.prototype.isBookmarked=function(a){var b=this.settings.bookmarks;return b.indexOf(a)},EPUBJS.Reader.prototype.clearBookmarks=function(){this.settings.bookmarks=[]},EPUBJS.Reader.prototype.addNote=function(a){this.settings.annotations.push(a)},EPUBJS.Reader.prototype.removeNote=function(a){var b=this.settings.annotations.indexOf(a);-1!==b&&delete this.settings.annotations[b]},EPUBJS.Reader.prototype.clearNotes=function(){this.settings.annotations=[]},EPUBJS.Reader.prototype.setBookKey=function(a){return this.settings.bookKey||(this.settings.bookKey="epubjsreader:"+EPUBJS.VERSION+":"+window.location.host+":"+a),this.settings.bookKey},EPUBJS.Reader.prototype.isSaved=function(){var a;return localStorage?(a=localStorage.getItem(this.settings.bookKey),null===a?!1:!0):!1},EPUBJS.Reader.prototype.removeSavedSettings=function(){return localStorage?void localStorage.removeItem(this.settings.bookKey):!1},EPUBJS.Reader.prototype.applySavedSettings=function(){var a;return localStorage?(a=JSON.parse(localStorage.getItem(this.settings.bookKey)),a?(this.settings=_.defaults(this.settings,a),!0):!1):!1},EPUBJS.Reader.prototype.saveSettings=function(){return this.book&&(this.settings.previousLocationCfi=this.book.getCurrentLocationCfi()),localStorage?void localStorage.setItem(this.settings.bookKey,JSON.stringify(this.settings)):!1},EPUBJS.Reader.prototype.unload=function(){this.settings.restore&&localStorage&&this.saveSettings()},EPUBJS.Reader.prototype.hashChanged=function(){var a=window.location.hash.slice(1);this.book.goto(a)},EPUBJS.Reader.prototype.selectedRange=function(a){var b=new EPUBJS.EpubCFI,c=b.generateCfiFromRangeAnchor(a,this.book.renderer.currentChapter.cfiBase),d="#"+c;this.settings.history&&window.location.hash!=d&&(history.pushState({},"",d),this.currentLocationCfi=c)},RSVP.EventTarget.mixin(EPUBJS.Reader.prototype),EPUBJS.reader.BookmarksController=function(){var a=this.book,b=$("#bookmarksView"),c=b.find("#bookmarks"),d=document.createDocumentFragment(),e=function(){b.show()},f=function(){b.hide()},g=0,h=function(b){var c=document.createElement("li"),d=document.createElement("a");return c.id="bookmark-"+g,c.classList.add("list_item"),d.textContent=b,d.href=b,d.classList.add("bookmark_link"),d.addEventListener("click",function(b){var c=this.getAttribute("href");a.gotoCfi(c),b.preventDefault()},!1),c.appendChild(d),g++,c};return this.settings.bookmarks.forEach(function(a){var b=h(a);d.appendChild(b)}),c.append(d),this.on("reader:bookmarked",function(a){var b=h(a);c.append(b)}),this.on("reader:unbookmarked",function(a){var b=$("#bookmark-"+a);b.remove()}),{show:e,hide:f}},EPUBJS.reader.ControlsController=function(a){var b=this,c=($("#store"),$("#fullscreen")),d=($("#fullscreenicon"),$("#cancelfullscreenicon"),$("#slider")),e=($("#main"),$("#sidebar"),$("#setting")),f=$("#bookmark"),g=function(){b.offline=!1},h=function(){b.offline=!0},i=!1;return a.on("book:online",g),a.on("book:offline",h),d.on("click",function(){b.sidebarOpen?(b.SidebarController.hide(),d.addClass("icon-menu"),d.removeClass("icon-right")):(b.SidebarController.show(),d.addClass("icon-right"),d.removeClass("icon-menu"))}),c.on("click",function(){screenfull.toggle($("#container")[0])}),screenfull&&document.addEventListener(screenfull.raw.fullscreenchange,function(){i=screenfull.isFullscreen,i?c.addClass("icon-resize-small").removeClass("icon-resize-full"):c.addClass("icon-resize-full").removeClass("icon-resize-small")}),e.on("click",function(){b.SettingsController.show()}),f.on("click",function(){var a=b.book.getCurrentLocationCfi(),c=b.isBookmarked(a);-1===c?(b.addBookmark(a),f.addClass("icon-bookmark").removeClass("icon-bookmark-empty")):(b.removeBookmark(a),f.removeClass("icon-bookmark").addClass("icon-bookmark-empty"))}),a.on("renderer:locationChanged",function(a){var c="#"+a,d=b.isBookmarked(a);-1===d?f.removeClass("icon-bookmark").addClass("icon-bookmark-empty"):f.addClass("icon-bookmark").removeClass("icon-bookmark-empty"),b.currentLocationCfi=a,b.settings.history&&window.location.hash!=c&&history.pushState({},"",c)}),a.on("book:pageChanged",function(){}),{}},EPUBJS.reader.MetaController=function(a){var b=a.bookTitle,c=a.creator,d=$("#book-title"),e=$("#chapter-title"),f=$("#title-seperator");document.title=b+" – "+c,d.html(b),e.html(c),f.show()},EPUBJS.reader.NotesController=function(){var a=this.book,b=this,c=$("#notesView"),d=$("#notes"),e=$("#note-text"),f=$("#note-anchor"),g=b.settings.annotations,h=a.renderer,i=[],j=new EPUBJS.EpubCFI,k=function(){c.show()},l=function(){c.hide()},m=function(c){var d,g,h,i,k,l=a.renderer.doc;if(l.caretPositionFromPoint?(d=l.caretPositionFromPoint(c.clientX,c.clientY),g=d.offsetNode,h=d.offset):l.caretRangeFromPoint&&(d=l.caretRangeFromPoint(c.clientX,c.clientY),g=d.startContainer,h=d.startOffset),3!==g.nodeType)for(var p=0;pm/2.5&&(o=m/2.5,pop_content.style.maxHeight=o+"px"),popRect.height+l>=m-25?(b.style.top=l-popRect.height+"px",b.classList.add("above")):b.classList.remove("above"),k-popRect.width<=0?(b.style.left=k+"px",b.classList.add("left")):b.classList.remove("left"),k+popRect.width/2>=n?(b.style.left=k-300+"px",popRect=b.getBoundingClientRect(),b.style.left=k-popRect.width+"px",popRect.height+l>=m-25?(b.style.top=l-popRect.height+"px",b.classList.add("above")):b.classList.remove("above"),b.classList.add("right")):b.classList.remove("right")},f=function(){i[d].classList.add("on")},g=function(){i[d].classList.remove("on")},j=function(){setTimeout(function(){i[d].classList.remove("show")},100)},l=function(){b.ReaderController.slideOut(),k()};a.addEventListener("mouseover",e,!1),a.addEventListener("mouseout",j,!1),a.addEventListener("click",l,!1)};return f.on("click",function(){f.text("Cancel"),e.prop("disabled","true"),a.on("renderer:click",m)}),g.forEach(function(a){n(a)}),h.registerHook("beforeChapterDisplay",function(a,b){var c=b.currentChapter;g.forEach(function(a){var b=j.parse(a.anchor);if(b.spinePos===c.spinePos)try{o(a)}catch(d){console.log("anchoring failed",a.anchor)}}),a()},!0),{show:k,hide:l}},EPUBJS.reader.ReaderController=function(a){var b=$("#main"),c=$("#divider"),d=$("#loader"),e=$("#next"),f=$("#prev"),g=this,a=this.book,h=function(){var c=a.getCurrentLocationCfi();g.settings.sidebarReflow?(b.removeClass("single"),b.one("transitionend",function(){a.gotoCfi(c)})):b.removeClass("closed")},i=function(){var c=a.getCurrentLocationCfi();g.settings.sidebarReflow?(b.addClass("single"),b.one("transitionend",function(){a.gotoCfi(c)})):b.addClass("closed")},j=function(){d.show(),m()},k=function(){d.hide()},l=function(){c.addClass("show")},m=function(){c.removeClass("show")},n=!1,o=function(b){37==b.keyCode&&(a.prevPage(),f.addClass("active"),n=!0,setTimeout(function(){n=!1,f.removeClass("active")},100),b.preventDefault()),39==b.keyCode&&(a.nextPage(),e.addClass("active"),n=!0,setTimeout(function(){n=!1,e.removeClass("active")},100),b.preventDefault())};return document.addEventListener("keydown",o,!1),e.on("click",function(b){a.nextPage(),b.preventDefault()}),f.on("click",function(b){a.prevPage(),b.preventDefault()}),a.on("renderer:spreads",function(a){a?l():m()}),{slideOut:i,slideIn:h,showLoader:j,hideLoader:k,showDivider:l,hideDivider:m,arrowKeys:o}},EPUBJS.reader.SettingsController=function(){var a=(this.book,this),b=$("#settings-modal"),c=$(".overlay"),d=function(){b.addClass("md-show")},e=function(){b.removeClass("md-show")},f=$("#sidebarReflow");return f.on("click",function(){a.settings.sidebarReflow=!a.settings.sidebarReflow}),b.find(".closer").on("click",function(){e()}),c.on("click",function(){e()}),{show:d,hide:e}},EPUBJS.reader.SidebarController=function(){var a=this,b=$("#sidebar"),c=$("#panels"),d="Toc",e=function(b){var e=b+"Controller";d!=b&&"undefined"!=typeof a[e]&&(a[d+"Controller"].hide(),a[e].show(),d=b,c.find(".active").removeClass("active"),c.find("#show-"+b).addClass("active"))},f=function(){return d},g=function(){a.sidebarOpen=!0,a.ReaderController.slideOut(),b.addClass("open")},h=function(){a.sidebarOpen=!1,a.ReaderController.slideIn(),b.removeClass("open")};return c.find(".show_view").on("click",function(a){var b=$(this).data("view");e(b),a.preventDefault()}),{show:g,hide:h,getActivePanel:f,changePanelTo:e}},EPUBJS.reader.TocController=function(a){var b=this.book,c=$("#tocView"),d=document.createDocumentFragment(),e=!1,f=function(a,b){var c=document.createElement("ul");return b||(b=1),a.forEach(function(a){var d=document.createElement("li"),e=document.createElement("a");toggle=document.createElement("a");var g;d.id="toc-"+a.id,d.classList.add("list_item"),e.textContent=a.label,e.href=a.href,e.classList.add("toc_link"),d.appendChild(e),a.subitems.length>0&&(b++,g=f(a.subitems,b),toggle.classList.add("toc_toggle"),d.insertBefore(toggle,e),d.appendChild(g)),c.appendChild(d)}),c},g=function(){c.show()},h=function(){c.hide()},i=function(a){{var b=a.id,d=c.find("#toc-"+b),f=c.find(".currentChapter");c.find(".openChapter")}d.length&&(d!=f&&d.has(e).length>0&&f.removeClass("currentChapter"),d.addClass("currentChapter"),d.parents("li").addClass("openChapter"))};b.on("renderer:chapterDisplayed",i);var j=f(a);return d.appendChild(j),c.append(d),c.find(".toc_link").on("click",function(a){var d=this.getAttribute("href");a.preventDefault(),b.goto(d),c.find(".currentChapter").addClass("openChapter").removeClass("currentChapter"),$(this).parent("li").addClass("currentChapter")}),c.find(".toc_toggle").on("click",function(a){var b=$(this).parent("li"),c=b.hasClass("openChapter");a.preventDefault(),c?b.removeClass("openChapter"):b.addClass("openChapter")}),{show:g,hide:h}}; -//# sourceMappingURL=reader.min.map \ No newline at end of file diff --git a/static/epub.js/reader.min.map b/static/epub.js/reader.min.map deleted file mode 100644 index 826c439..0000000 --- a/static/epub.js/reader.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reader.min.js","sources":["reader.js"],"names":["EPUBJS","reader","plugins","root","previousReader","ePubReader","path","options","Reader","_","extend","noConflict","this","define","amd","module","exports","window","jQuery","bookPath","_options","book","plugin","parameters","$viewer","$","search","location","settings","defaults","restore","reload","bookmarks","annotations","contained","bookKey","styles","sidebarReflow","generatePagination","history","slice","split","forEach","p","name","value","setBookKey","isSaved","applySavedSettings","fontSize","Book","previousLocationCfi","gotoCfi","offline","sidebarOpen","width","height","renderTo","ReaderController","call","SettingsController","ControlsController","SidebarController","BookmarksController","NotesController","hasOwnProperty","ready","all","then","hideLoader","getMetadata","meta","MetaController","getToc","toc","TocController","addEventListener","unload","bind","hashChanged","document","adjustFontSize","on","arrowKeys","selectedRange","prototype","e","interval","PLUS","MINUS","ZERO","MOD","ctrlKey","metaKey","parseInt","keyCode","preventDefault","setStyle","addBookmark","cfi","present","isBookmarked","push","trigger","removeBookmark","bookmark","indexOf","clearBookmarks","addNote","note","removeNote","index","clearNotes","identifier","VERSION","host","storedSettings","localStorage","getItem","removeSavedSettings","removeItem","stored","JSON","parse","saveSettings","getCurrentLocationCfi","setItem","stringify","hash","goto","range","epubcfi","EpubCFI","generateCfiFromRangeAnchor","renderer","currentChapter","cfiBase","cfiFragment","pushState","currentLocationCfi","RSVP","EventTarget","mixin","$bookmarks","$list","find","docfrag","createDocumentFragment","show","hide","counter","createBookmarkItem","listitem","createElement","link","id","classList","add","textContent","href","event","getAttribute","appendChild","append","item","$item","remove","$fullscreen","$slider","$settings","$bookmark","goOnline","goOffline","fullscreen","addClass","removeClass","screenfull","toggle","raw","fullscreenchange","isFullscreen","bookmarked","title","bookTitle","author","creator","$title","$author","$dash","html","$notesView","$notes","$text","$anchor","popups","insertAtPoint","textNode","offset","annotation","doc","caretPositionFromPoint","clientX","clientY","offsetNode","caretRangeFromPoint","startContainer","startOffset","nodeType","i","childNodes","length","generateCfiFromTextNode","annotatedAt","Date","anchor","body","val","addAnnotation","placeMarker","text","prop","off","innerHTML","onclick","marker","mark","style","verticalAlign","lineHeight","padding","backgroundColor","borderRadius","cursor","core","uuid","addMarker","markerEvents","txt","showPop","pop","itemRect","left","top","iheight","iwidth","maxHeight","setAttribute","pop_content","render","onPop","offPop","hidePop","getBoundingClientRect","popRect","setTimeout","openSidebar","slideOut","registerHook","callback","chapter","spinePos","console","log","$main","$divider","$loader","$next","$prev","slideIn","currentPosition","one","showLoader","hideDivider","showDivider","keylock","prevPage","nextPage","bool","$overlay","$sidebarReflowSetting","$sidebar","$panels","activePanel","changePanelTo","viewName","controllerName","getActivePanel","view","data","generateTocItems","level","container","subitems","label","insertBefore","onShow","onHide","chapterChange","$current","has","parents","tocitems","url","parent","$el","open","hasClass"],"mappings":"AAAAA,OAAOC,UACPD,OAAOC,OAAOC,WAEd,SAAUC,GAET,GAAIC,GAAiBD,EAAKE,eAEtBA,EAAaF,EAAKE,WAAa,SAASC,EAAMC,GACjD,MAAO,IAAIP,QAAOQ,OAAOF,EAAMC,GAGhCE,GAAEC,OAAOL,GACRM,WAAa,WAEZ,MADAR,GAAKE,WAAaD,EACXQ,QAKa,kBAAXC,SAAyBA,OAAOC,IAE3CD,OAAO,WAAY,MAAOL,UACA,mBAAVO,SAAyBA,OAAOC,UAEhDD,OAAOC,QAAUX,I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IAAII,GAAWZ,EAAiBvN,EAkChC,OAhCAwE,GAAQgB,YAAY2I,GAEpB7J,EAAMmB,OAAOjB,GACbF,EAAMC,KAAK,aAAa/D,GAAG,QAAS,SAAS8E,GAC3C,GAAI8I,GAAMlS,KAAKqJ,aAAa,OAE5BD,GAAMhE,iBAIN3E,EAAK4G,KAAK6K,GAEV9J,EAAMC,KAAK,mBACR6B,SAAS,eACTC,YAAY,kBAEftJ,EAAEb,MAAMmS,OAAO,MAAMjI,SAAS,oBAIhC9B,EAAMC,KAAK,eAAe/D,GAAG,QAAS,SAAS8E,GAC7C,GAAIgJ,GAAMvR,EAAEb,MAAMmS,OAAO,MACvBE,EAAOD,EAAIE,SAAS,cAEtBlJ,GAAMhE,iBACHiN,EACFD,EAAIjI,YAAY,eAEhBiI,EAAIlI,SAAS,kBAKf1B,KAASmJ,EACTlJ,KAASmJ"} \ No newline at end of file diff --git a/static/pdf.js/compatibility.js b/static/pdf.js/compatibility.js deleted file mode 100644 index 8ca6813..0000000 --- a/static/pdf.js/compatibility.js +++ /dev/null @@ -1,483 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* Copyright 2012 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* globals VBArray, PDFJS */ - -'use strict'; - -// Initializing PDFJS global object here, it case if we need to change/disable -// some PDF.js features, e.g. range requests -if (typeof PDFJS === 'undefined') { - (typeof window !== 'undefined' ? window : this).PDFJS = {}; -} - -// Checking if the typed arrays are supported -(function checkTypedArrayCompatibility() { - if (typeof Uint8Array !== 'undefined') { - // some mobile versions do not support subarray (e.g. safari 5 / iOS) - if (typeof Uint8Array.prototype.subarray === 'undefined') { - Uint8Array.prototype.subarray = function subarray(start, end) { - return new Uint8Array(this.slice(start, end)); - }; - Float32Array.prototype.subarray = function subarray(start, end) { - return new Float32Array(this.slice(start, end)); - }; - } - - // some mobile version might not support Float64Array - if (typeof Float64Array === 'undefined') - window.Float64Array = Float32Array; - - return; - } - - function subarray(start, end) { - return new TypedArray(this.slice(start, end)); - } - - function setArrayOffset(array, offset) { - if (arguments.length < 2) - offset = 0; - for (var i = 0, n = array.length; i < n; ++i, ++offset) - this[offset] = array[i] & 0xFF; - } - - function TypedArray(arg1) { - var result; - if (typeof arg1 === 'number') { - result = []; - for (var i = 0; i < arg1; ++i) - result[i] = 0; - } else if ('slice' in arg1) { - result = arg1.slice(0); - } else { - result = []; - for (var i = 0, n = arg1.length; i < n; ++i) { - result[i] = arg1[i]; - } - } - - result.subarray = subarray; - result.buffer = result; - result.byteLength = result.length; - result.set = setArrayOffset; - - if (typeof arg1 === 'object' && arg1.buffer) - result.buffer = arg1.buffer; - - return result; - } - - window.Uint8Array = TypedArray; - - // we don't need support for set, byteLength for 32-bit array - // so we can use the TypedArray as well - window.Uint32Array = TypedArray; - window.Int32Array = TypedArray; - window.Uint16Array = TypedArray; - window.Float32Array = TypedArray; - window.Float64Array = TypedArray; -})(); - -// URL = URL || webkitURL -(function normalizeURLObject() { - if (!window.URL) { - window.URL = window.webkitURL; - } -})(); - -// Object.create() ? -(function checkObjectCreateCompatibility() { - if (typeof Object.create !== 'undefined') - return; - - Object.create = function objectCreate(proto) { - function Constructor() {} - Constructor.prototype = proto; - return new Constructor(); - }; -})(); - -// Object.defineProperty() ? -(function checkObjectDefinePropertyCompatibility() { - if (typeof Object.defineProperty !== 'undefined') { - var definePropertyPossible = true; - try { - // some browsers (e.g. safari) cannot use defineProperty() on DOM objects - // and thus the native version is not sufficient - Object.defineProperty(new Image(), 'id', { value: 'test' }); - // ... another test for android gb browser for non-DOM objects - var Test = function Test() {}; - Test.prototype = { get id() { } }; - Object.defineProperty(new Test(), 'id', - { value: '', configurable: true, enumerable: true, writable: false }); - } catch (e) { - definePropertyPossible = false; - } - if (definePropertyPossible) return; - } - - Object.defineProperty = function objectDefineProperty(obj, name, def) { - delete obj[name]; - if ('get' in def) - obj.__defineGetter__(name, def['get']); - if ('set' in def) - obj.__defineSetter__(name, def['set']); - if ('value' in def) { - obj.__defineSetter__(name, function objectDefinePropertySetter(value) { - this.__defineGetter__(name, function objectDefinePropertyGetter() { - return value; - }); - return value; - }); - obj[name] = def.value; - } - }; -})(); - -// Object.keys() ? -(function checkObjectKeysCompatibility() { - if (typeof Object.keys !== 'undefined') - return; - - Object.keys = function objectKeys(obj) { - var result = []; - for (var i in obj) { - if (obj.hasOwnProperty(i)) - result.push(i); - } - return result; - }; -})(); - -// No readAsArrayBuffer ? -(function checkFileReaderReadAsArrayBuffer() { - if (typeof FileReader === 'undefined') - return; // FileReader is not implemented - var frPrototype = FileReader.prototype; - // Older versions of Firefox might not have readAsArrayBuffer - if ('readAsArrayBuffer' in frPrototype) - return; // readAsArrayBuffer is implemented - Object.defineProperty(frPrototype, 'readAsArrayBuffer', { - value: function fileReaderReadAsArrayBuffer(blob) { - var fileReader = new FileReader(); - var originalReader = this; - fileReader.onload = function fileReaderOnload(evt) { - var data = evt.target.result; - var buffer = new ArrayBuffer(data.length); - var uint8Array = new Uint8Array(buffer); - - for (var i = 0, ii = data.length; i < ii; i++) - uint8Array[i] = data.charCodeAt(i); - - Object.defineProperty(originalReader, 'result', { - value: buffer, - enumerable: true, - writable: false, - configurable: true - }); - - var event = document.createEvent('HTMLEvents'); - event.initEvent('load', false, false); - originalReader.dispatchEvent(event); - }; - fileReader.readAsBinaryString(blob); - } - }); -})(); - -// No XMLHttpRequest.response ? -(function checkXMLHttpRequestResponseCompatibility() { - var xhrPrototype = XMLHttpRequest.prototype; - if (!('overrideMimeType' in xhrPrototype)) { - // IE10 might have response, but not overrideMimeType - Object.defineProperty(xhrPrototype, 'overrideMimeType', { - value: function xmlHttpRequestOverrideMimeType(mimeType) {} - }); - } - if ('response' in xhrPrototype || - 'mozResponseArrayBuffer' in xhrPrototype || - 'mozResponse' in xhrPrototype || - 'responseArrayBuffer' in xhrPrototype) - return; - // IE9 ? - if (typeof VBArray !== 'undefined') { - Object.defineProperty(xhrPrototype, 'response', { - get: function xmlHttpRequestResponseGet() { - return new Uint8Array(new VBArray(this.responseBody).toArray()); - } - }); - return; - } - - // other browsers - function responseTypeSetter() { - // will be only called to set "arraybuffer" - this.overrideMimeType('text/plain; charset=x-user-defined'); - } - if (typeof xhrPrototype.overrideMimeType === 'function') { - Object.defineProperty(xhrPrototype, 'responseType', - { set: responseTypeSetter }); - } - function responseGetter() { - var text = this.responseText; - var i, n = text.length; - var result = new Uint8Array(n); - for (i = 0; i < n; ++i) - result[i] = text.charCodeAt(i) & 0xFF; - return result; - } - Object.defineProperty(xhrPrototype, 'response', { get: responseGetter }); -})(); - -// window.btoa (base64 encode function) ? -(function checkWindowBtoaCompatibility() { - if ('btoa' in window) - return; - - var digits = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - - window.btoa = function windowBtoa(chars) { - var buffer = ''; - var i, n; - for (i = 0, n = chars.length; i < n; i += 3) { - var b1 = chars.charCodeAt(i) & 0xFF; - var b2 = chars.charCodeAt(i + 1) & 0xFF; - var b3 = chars.charCodeAt(i + 2) & 0xFF; - var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4); - var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64; - var d4 = i + 2 < n ? (b3 & 0x3F) : 64; - buffer += (digits.charAt(d1) + digits.charAt(d2) + - digits.charAt(d3) + digits.charAt(d4)); - } - return buffer; - }; -})(); - -// window.atob (base64 encode function) ? -(function checkWindowAtobCompatibility() { - if ('atob' in window) - return; - - // https://github.com/davidchambers/Base64.js - var digits = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - window.atob = function (input) { - input = input.replace(/=+$/, ''); - if (input.length % 4 == 1) throw new Error('bad atob input'); - for ( - // initialize result and counters - var bc = 0, bs, buffer, idx = 0, output = ''; - // get next character - buffer = input.charAt(idx++); - // character found in table? - // initialize bit storage and add its ascii value - ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, - // and if not first of each 4 characters, - // convert the first 8 bits to one ascii character - bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 - ) { - // try to find character in table (0-63, not found => -1) - buffer = digits.indexOf(buffer); - } - return output; - }; -})(); - -// Function.prototype.bind ? -(function checkFunctionPrototypeBindCompatibility() { - if (typeof Function.prototype.bind !== 'undefined') - return; - - Function.prototype.bind = function functionPrototypeBind(obj) { - var fn = this, headArgs = Array.prototype.slice.call(arguments, 1); - var bound = function functionPrototypeBindBound() { - var args = Array.prototype.concat.apply(headArgs, arguments); - return fn.apply(obj, args); - }; - return bound; - }; -})(); - -// HTMLElement dataset property -(function checkDatasetProperty() { - var div = document.createElement('div'); - if ('dataset' in div) - return; // dataset property exists - - Object.defineProperty(HTMLElement.prototype, 'dataset', { - get: function() { - if (this._dataset) - return this._dataset; - - var dataset = {}; - for (var j = 0, jj = this.attributes.length; j < jj; j++) { - var attribute = this.attributes[j]; - if (attribute.name.substring(0, 5) != 'data-') - continue; - var key = attribute.name.substring(5).replace(/\-([a-z])/g, - function(all, ch) { return ch.toUpperCase(); }); - dataset[key] = attribute.value; - } - - Object.defineProperty(this, '_dataset', { - value: dataset, - writable: false, - enumerable: false - }); - return dataset; - }, - enumerable: true - }); -})(); - -// HTMLElement classList property -(function checkClassListProperty() { - var div = document.createElement('div'); - if ('classList' in div) - return; // classList property exists - - function changeList(element, itemName, add, remove) { - var s = element.className || ''; - var list = s.split(/\s+/g); - if (list[0] === '') list.shift(); - var index = list.indexOf(itemName); - if (index < 0 && add) - list.push(itemName); - if (index >= 0 && remove) - list.splice(index, 1); - element.className = list.join(' '); - return (index >= 0); - } - - var classListPrototype = { - add: function(name) { - changeList(this.element, name, true, false); - }, - contains: function(name) { - return changeList(this.element, name, false, false); - }, - remove: function(name) { - changeList(this.element, name, false, true); - }, - toggle: function(name) { - changeList(this.element, name, true, true); - } - }; - - Object.defineProperty(HTMLElement.prototype, 'classList', { - get: function() { - if (this._classList) - return this._classList; - - var classList = Object.create(classListPrototype, { - element: { - value: this, - writable: false, - enumerable: true - } - }); - Object.defineProperty(this, '_classList', { - value: classList, - writable: false, - enumerable: false - }); - return classList; - }, - enumerable: true - }); -})(); - -// Check console compatibility -(function checkConsoleCompatibility() { - if (!('console' in window)) { - window.console = { - log: function() {}, - error: function() {}, - warn: function() {} - }; - } else if (!('bind' in console.log)) { - // native functions in IE9 might not have bind - console.log = (function(fn) { - return function(msg) { return fn(msg); }; - })(console.log); - console.error = (function(fn) { - return function(msg) { return fn(msg); }; - })(console.error); - console.warn = (function(fn) { - return function(msg) { return fn(msg); }; - })(console.warn); - } -})(); - -// Check onclick compatibility in Opera -(function checkOnClickCompatibility() { - // workaround for reported Opera bug DSK-354448: - // onclick fires on disabled buttons with opaque content - function ignoreIfTargetDisabled(event) { - if (isDisabled(event.target)) { - event.stopPropagation(); - } - } - function isDisabled(node) { - return node.disabled || (node.parentNode && isDisabled(node.parentNode)); - } - if (navigator.userAgent.indexOf('Opera') != -1) { - // use browser detection since we cannot feature-check this bug - document.addEventListener('click', ignoreIfTargetDisabled, true); - } -})(); - -// Checks if navigator.language is supported -(function checkNavigatorLanguage() { - if ('language' in navigator) - return; - Object.defineProperty(navigator, 'language', { - get: function navigatorLanguage() { - var language = navigator.userLanguage || 'en-US'; - return language.substring(0, 2).toLowerCase() + - language.substring(2).toUpperCase(); - }, - enumerable: true - }); -})(); - -(function checkRangeRequests() { - // Safari has issues with cached range requests see: - // https://github.com/mozilla/pdf.js/issues/3260 - // Last tested with version 6.0.4. - var isSafari = Object.prototype.toString.call( - window.HTMLElement).indexOf('Constructor') > 0; - - // Older versions of Android (pre 3.0) has issues with range requests, see: - // https://github.com/mozilla/pdf.js/issues/3381. - // Make sure that we only match webkit-based Android browsers, - // since Firefox/Fennec works as expected. - var regex = /Android\s[0-2][^\d]/; - var isOldAndroid = regex.test(navigator.userAgent); - - if (isSafari || isOldAndroid) { - PDFJS.disableRange = true; - } -})(); - -// Check if the browser supports manipulation of the history. -(function checkHistoryManipulation() { - if (!window.history.pushState) { - PDFJS.disableHistory = true; - } -})(); diff --git a/static/pdf.js/css/videopdf.css b/static/pdf.js/css/videopdf.css deleted file mode 100644 index 6b51199..0000000 --- a/static/pdf.js/css/videopdf.css +++ /dev/null @@ -1,28 +0,0 @@ -.button { - position: absolute; - width: 20px; - height: 20px; - padding: 4px; - border: 2px solid rgb(255, 255, 255); - border-radius: 16px; - background-color: rgba(0, 0, 0, 0.5); - box-shadow: 0 0 2px rgb(0, 0, 0); - cursor: pointer; -} -.button.playButton { - left: 0; - top: 0; - right: 0; - bottom: 0; - margin: auto; -} -.button.editButton { - right: 8px; - bottom: 8px; -} -.interface { - position: absolute; -} -.interface.video { - cursor: pointer; -} diff --git a/static/pdf.js/debugger.js b/static/pdf.js/debugger.js deleted file mode 100644 index a70ad0c..0000000 --- a/static/pdf.js/debugger.js +++ /dev/null @@ -1,540 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* Copyright 2012 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* globals PDFJS */ - -'use strict'; - -var FontInspector = (function FontInspectorClosure() { - var fonts; - var panelWidth = 300; - var active = false; - var fontAttribute = 'data-font-name'; - function removeSelection() { - var divs = document.querySelectorAll('div[' + fontAttribute + ']'); - for (var i = 0, ii = divs.length; i < ii; ++i) { - var div = divs[i]; - div.className = ''; - } - } - function resetSelection() { - var divs = document.querySelectorAll('div[' + fontAttribute + ']'); - for (var i = 0, ii = divs.length; i < ii; ++i) { - var div = divs[i]; - div.className = 'debuggerHideText'; - } - } - function selectFont(fontName, show) { - var divs = document.querySelectorAll('div[' + fontAttribute + '=' + - fontName + ']'); - for (var i = 0, ii = divs.length; i < ii; ++i) { - var div = divs[i]; - div.className = show ? 'debuggerShowText' : 'debuggerHideText'; - } - } - function textLayerClick(e) { - if (!e.target.dataset.fontName || e.target.tagName.toUpperCase() !== 'DIV') - return; - var fontName = e.target.dataset.fontName; - var selects = document.getElementsByTagName('input'); - for (var i = 0; i < selects.length; ++i) { - var select = selects[i]; - if (select.dataset.fontName != fontName) continue; - select.checked = !select.checked; - selectFont(fontName, select.checked); - select.scrollIntoView(); - } - } - return { - // Properties/functions needed by PDFBug. - id: 'FontInspector', - name: 'Font Inspector', - panel: null, - manager: null, - init: function init() { - var panel = this.panel; - panel.setAttribute('style', 'padding: 5px;'); - var tmp = document.createElement('button'); - tmp.addEventListener('click', resetSelection); - tmp.textContent = 'Refresh'; - panel.appendChild(tmp); - - fonts = document.createElement('div'); - panel.appendChild(fonts); - }, - enabled: false, - get active() { - return active; - }, - set active(value) { - active = value; - if (active) { - document.body.addEventListener('click', textLayerClick, true); - resetSelection(); - } else { - document.body.removeEventListener('click', textLayerClick, true); - removeSelection(); - } - }, - // FontInspector specific functions. - fontAdded: function fontAdded(fontObj, url) { - function properties(obj, list) { - var moreInfo = document.createElement('table'); - for (var i = 0; i < list.length; i++) { - var tr = document.createElement('tr'); - var td1 = document.createElement('td'); - td1.textContent = list[i]; - tr.appendChild(td1); - var td2 = document.createElement('td'); - td2.textContent = obj[list[i]].toString(); - tr.appendChild(td2); - moreInfo.appendChild(tr); - } - return moreInfo; - } - var moreInfo = properties(fontObj, ['name', 'type']); - var m = /url\(['"]?([^\)"']+)/.exec(url); - var fontName = fontObj.loadedName; - var font = document.createElement('div'); - var name = document.createElement('span'); - name.textContent = fontName; - var download = document.createElement('a'); - download.href = m[1]; - download.textContent = 'Download'; - var logIt = document.createElement('a'); - logIt.href = ''; - logIt.textContent = 'Log'; - logIt.addEventListener('click', function(event) { - event.preventDefault(); - console.log(fontObj); - }); - var select = document.createElement('input'); - select.setAttribute('type', 'checkbox'); - select.dataset.fontName = fontName; - select.addEventListener('click', (function(select, fontName) { - return (function() { - selectFont(fontName, select.checked); - }); - })(select, fontName)); - font.appendChild(select); - font.appendChild(name); - font.appendChild(document.createTextNode(' ')); - font.appendChild(download); - font.appendChild(document.createTextNode(' ')); - font.appendChild(logIt); - font.appendChild(moreInfo); - fonts.appendChild(font); - // Somewhat of a hack, should probably add a hook for when the text layer - // is done rendering. - setTimeout(function() { - if (this.active) - resetSelection(); - }.bind(this), 2000); - } - }; -})(); - -// Manages all the page steppers. -var StepperManager = (function StepperManagerClosure() { - var steppers = []; - var stepperDiv = null; - var stepperControls = null; - var stepperChooser = null; - var breakPoints = {}; - return { - // Properties/functions needed by PDFBug. - id: 'Stepper', - name: 'Stepper', - panel: null, - manager: null, - init: function init() { - var self = this; - this.panel.setAttribute('style', 'padding: 5px;'); - stepperControls = document.createElement('div'); - stepperChooser = document.createElement('select'); - stepperChooser.addEventListener('change', function(event) { - self.selectStepper(this.value); - }); - stepperControls.appendChild(stepperChooser); - stepperDiv = document.createElement('div'); - this.panel.appendChild(stepperControls); - this.panel.appendChild(stepperDiv); - if (sessionStorage.getItem('pdfjsBreakPoints')) - breakPoints = JSON.parse(sessionStorage.getItem('pdfjsBreakPoints')); - }, - enabled: false, - active: false, - // Stepper specific functions. - create: function create(pageIndex) { - var debug = document.createElement('div'); - debug.id = 'stepper' + pageIndex; - debug.setAttribute('hidden', true); - debug.className = 'stepper'; - stepperDiv.appendChild(debug); - var b = document.createElement('option'); - b.textContent = 'Page ' + (pageIndex + 1); - b.value = pageIndex; - stepperChooser.appendChild(b); - var initBreakPoints = breakPoints[pageIndex] || []; - var stepper = new Stepper(debug, pageIndex, initBreakPoints); - steppers.push(stepper); - if (steppers.length === 1) - this.selectStepper(pageIndex, false); - return stepper; - }, - selectStepper: function selectStepper(pageIndex, selectPanel) { - if (selectPanel) - this.manager.selectPanel(1); - for (var i = 0; i < steppers.length; ++i) { - var stepper = steppers[i]; - if (stepper.pageIndex == pageIndex) - stepper.panel.removeAttribute('hidden'); - else - stepper.panel.setAttribute('hidden', true); - } - var options = stepperChooser.options; - for (var i = 0; i < options.length; ++i) { - var option = options[i]; - option.selected = option.value == pageIndex; - } - }, - saveBreakPoints: function saveBreakPoints(pageIndex, bps) { - breakPoints[pageIndex] = bps; - sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints)); - } - }; -})(); - -// The stepper for each page's IRQueue. -var Stepper = (function StepperClosure() { - // Shorter way to create element and optionally set textContent. - function c(tag, textContent) { - var d = document.createElement(tag); - if (textContent) - d.textContent = textContent; - return d; - } - - function glyphsToString(glyphs) { - var out = ''; - for (var i = 0; i < glyphs.length; i++) { - if (glyphs[i] === null) { - out += ' '; - } else { - out += glyphs[i].fontChar; - } - } - return out; - } - - var opMap = null; - - var glyphCommands = { - 'showText': 0, - 'showSpacedText': 0, - 'nextLineShowText': 0, - 'nextLineSetSpacingShowText': 2 - }; - - function Stepper(panel, pageIndex, initialBreakPoints) { - this.panel = panel; - this.breakPoint = 0; - this.nextBreakPoint = null; - this.pageIndex = pageIndex; - this.breakPoints = initialBreakPoints; - this.currentIdx = -1; - this.operatorListIdx = 0; - } - Stepper.prototype = { - init: function init() { - var panel = this.panel; - var content = c('div', 'c=continue, s=step'); - var table = c('table'); - content.appendChild(table); - table.cellSpacing = 0; - var headerRow = c('tr'); - table.appendChild(headerRow); - headerRow.appendChild(c('th', 'Break')); - headerRow.appendChild(c('th', 'Idx')); - headerRow.appendChild(c('th', 'fn')); - headerRow.appendChild(c('th', 'args')); - panel.appendChild(content); - this.table = table; - if (!opMap) { - opMap = Object.create(null); - for (var key in PDFJS.OPS) { - opMap[PDFJS.OPS[key]] = key; - } - } - }, - updateOperatorList: function updateOperatorList(operatorList) { - var self = this; - for (var i = this.operatorListIdx; i < operatorList.fnArray.length; i++) { - var line = c('tr'); - line.className = 'line'; - line.dataset.idx = i; - this.table.appendChild(line); - var checked = this.breakPoints.indexOf(i) != -1; - var args = operatorList.argsArray[i] ? operatorList.argsArray[i] : []; - - var breakCell = c('td'); - var cbox = c('input'); - cbox.type = 'checkbox'; - cbox.className = 'points'; - cbox.checked = checked; - cbox.onclick = (function(x) { - return function() { - if (this.checked) - self.breakPoints.push(x); - else - self.breakPoints.splice(self.breakPoints.indexOf(x), 1); - StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints); - }; - })(i); - - breakCell.appendChild(cbox); - line.appendChild(breakCell); - line.appendChild(c('td', i.toString())); - var fn = opMap[operatorList.fnArray[i]]; - var decArgs = args; - if (fn in glyphCommands) { - var glyphIndex = glyphCommands[fn]; - var glyphs = args[glyphIndex]; - var decArgs = args.slice(); - var newArg; - if (fn === 'showSpacedText') { - newArg = []; - for (var j = 0; j < glyphs.length; j++) { - if (typeof glyphs[j] === 'number') { - newArg.push(glyphs[j]); - } else { - newArg.push(glyphsToString(glyphs[j])); - } - } - } else { - newArg = glyphsToString(glyphs); - } - decArgs[glyphIndex] = newArg; - } - line.appendChild(c('td', fn)); - line.appendChild(c('td', JSON.stringify(decArgs))); - } - }, - getNextBreakPoint: function getNextBreakPoint() { - this.breakPoints.sort(function(a, b) { return a - b; }); - for (var i = 0; i < this.breakPoints.length; i++) { - if (this.breakPoints[i] > this.currentIdx) - return this.breakPoints[i]; - } - return null; - }, - breakIt: function breakIt(idx, callback) { - StepperManager.selectStepper(this.pageIndex, true); - var self = this; - var dom = document; - self.currentIdx = idx; - var listener = function(e) { - switch (e.keyCode) { - case 83: // step - dom.removeEventListener('keydown', listener, false); - self.nextBreakPoint = self.currentIdx + 1; - self.goTo(-1); - callback(); - break; - case 67: // continue - dom.removeEventListener('keydown', listener, false); - var breakPoint = self.getNextBreakPoint(); - self.nextBreakPoint = breakPoint; - self.goTo(-1); - callback(); - break; - } - }; - dom.addEventListener('keydown', listener, false); - self.goTo(idx); - }, - goTo: function goTo(idx) { - var allRows = this.panel.getElementsByClassName('line'); - for (var x = 0, xx = allRows.length; x < xx; ++x) { - var row = allRows[x]; - if (row.dataset.idx == idx) { - row.style.backgroundColor = 'rgb(251,250,207)'; - row.scrollIntoView(); - } else { - row.style.backgroundColor = null; - } - } - } - }; - return Stepper; -})(); - -var Stats = (function Stats() { - var stats = []; - function clear(node) { - while (node.hasChildNodes()) - node.removeChild(node.lastChild); - } - function getStatIndex(pageNumber) { - for (var i = 0, ii = stats.length; i < ii; ++i) - if (stats[i].pageNumber === pageNumber) - return i; - return false; - } - return { - // Properties/functions needed by PDFBug. - id: 'Stats', - name: 'Stats', - panel: null, - manager: null, - init: function init() { - this.panel.setAttribute('style', 'padding: 5px;'); - PDFJS.enableStats = true; - }, - enabled: false, - active: false, - // Stats specific functions. - add: function(pageNumber, stat) { - if (!stat) - return; - var statsIndex = getStatIndex(pageNumber); - if (statsIndex !== false) { - var b = stats[statsIndex]; - this.panel.removeChild(b.div); - stats.splice(statsIndex, 1); - } - var wrapper = document.createElement('div'); - wrapper.className = 'stats'; - var title = document.createElement('div'); - title.className = 'title'; - title.textContent = 'Page: ' + pageNumber; - var statsDiv = document.createElement('div'); - statsDiv.textContent = stat.toString(); - wrapper.appendChild(title); - wrapper.appendChild(statsDiv); - stats.push({ pageNumber: pageNumber, div: wrapper }); - stats.sort(function(a, b) { return a.pageNumber - b.pageNumber; }); - clear(this.panel); - for (var i = 0, ii = stats.length; i < ii; ++i) - this.panel.appendChild(stats[i].div); - } - }; -})(); - -// Manages all the debugging tools. -var PDFBug = (function PDFBugClosure() { - var panelWidth = 300; - var buttons = []; - var activePanel = null; - - return { - tools: [ - FontInspector, - StepperManager, - Stats - ], - enable: function(ids) { - var all = false, tools = this.tools; - if (ids.length === 1 && ids[0] === 'all') - all = true; - for (var i = 0; i < tools.length; ++i) { - var tool = tools[i]; - if (all || ids.indexOf(tool.id) !== -1) - tool.enabled = true; - } - if (!all) { - // Sort the tools by the order they are enabled. - tools.sort(function(a, b) { - var indexA = ids.indexOf(a.id); - indexA = indexA < 0 ? tools.length : indexA; - var indexB = ids.indexOf(b.id); - indexB = indexB < 0 ? tools.length : indexB; - return indexA - indexB; - }); - } - }, - init: function init() { - /* - * Basic Layout: - * PDFBug - * Controls - * Panels - * Panel - * Panel - * ... - */ - var ui = document.createElement('div'); - ui.id = 'PDFBug'; - - var controls = document.createElement('div'); - controls.setAttribute('class', 'controls'); - ui.appendChild(controls); - - var panels = document.createElement('div'); - panels.setAttribute('class', 'panels'); - ui.appendChild(panels); - - var container = document.getElementById('viewerContainer'); - container.appendChild(ui); - container.style.right = panelWidth + 'px'; - - // Initialize all the debugging tools. - var tools = this.tools; - var self = this; - for (var i = 0; i < tools.length; ++i) { - var tool = tools[i]; - var panel = document.createElement('div'); - var panelButton = document.createElement('button'); - panelButton.textContent = tool.name; - panelButton.addEventListener('click', (function(selected) { - return function(event) { - event.preventDefault(); - self.selectPanel(selected); - }; - })(i)); - controls.appendChild(panelButton); - panels.appendChild(panel); - tool.panel = panel; - tool.manager = this; - if (tool.enabled) - tool.init(); - else - panel.textContent = tool.name + ' is disabled. To enable add ' + - ' "' + tool.id + '" to the pdfBug parameter ' + - 'and refresh (seperate multiple by commas).'; - buttons.push(panelButton); - } - this.selectPanel(0); - }, - selectPanel: function selectPanel(index) { - if (index === activePanel) - return; - activePanel = index; - var tools = this.tools; - for (var j = 0; j < tools.length; ++j) { - if (j == index) { - buttons[j].setAttribute('class', 'active'); - tools[j].active = true; - tools[j].panel.removeAttribute('hidden'); - } else { - buttons[j].setAttribute('class', ''); - tools[j].active = false; - tools[j].panel.setAttribute('hidden', 'true'); - } - } - } - }; -})(); diff --git a/static/pdf.js/embeds.js b/static/pdf.js/embeds.js deleted file mode 100644 index 843003d..0000000 --- a/static/pdf.js/embeds.js +++ /dev/null @@ -1,147 +0,0 @@ -Ox.load({ - UI: { - loadCSS: false - } -}, function() { - var currentPage = PDFView.page; - window.addEventListener('pagechange', function (evt) { - var page = evt.pageNumber; - if (page && page != currentPage) { - currentPage = page; - Ox.$parent.postMessage('page', { - page: Math.round(page) - }); - } - }); - Ox.$parent.bindMessage({ - page: function(data) { - if (data.page != PDFView.page) { - PDFView.page = data.page; - } - }, - pdf: function(data) { - if (PDFView.url != data.pdf) { - PDFView.open(data.pdf); - } - } - }); -}); - -function getVideoOverlay(page) { - var links = (window.embeds || []).filter(function(embed) { - return embed.page == page && embed.type =='inline'; - }); - return (window.editable || links.length) ? { - beginLayout: function() { - this.counter = 0; - }, - endLayout: function() { - }, - appendImage: function(image) { - var id = ++this.counter, - video = links.filter(function(embed) { - return embed.id == id; - })[0], - $interface, $playButton, $editButton; - if (editable || video) { - $interface = Ox.$('
    ') - .addClass('interface') - .css({ - left: image.left + 'px', - top: image.top + 'px', - width: image.width + 'px', - height: image.height + 'px' - }); - $playButton = Ox.$('') - .addClass('button playButton') - .attr({ - src: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2Ij48cG9seWdvbiBwb2ludHM9IjU2LDMyIDI0OCwxMjggNTYsMjI0IiBmaWxsPSIjRkZGRkZGIi8+PC9zdmc+PCEtLXsiY29sb3IiOiJ2aWRlbyIsIm5hbWUiOiJzeW1ib2xQbGF5IiwidGhlbWUiOiJveGRhcmsifS0tPg==' - }) - .hide() - .appendTo($interface); - $editButton = Ox.$('') - .addClass('button editButton') - .attr({ - src: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2Ij48cG9seWdvbiBwb2ludHM9IjMyLDIyNCA2NCwxNjAgOTYsMTkyIiBmaWxsPSIjRkZGRkZGIi8+PGxpbmUgeDE9Ijg4IiB5MT0iMTY4IiB4Mj0iMTg0IiB5Mj0iNzIiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSI0OCIvPjxsaW5lIHgxPSIxOTIiIHkxPSI2NCIgeDI9IjIwOCIgeTI9IjQ4IiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iNDgiLz48bGluZSB4MT0iMTEyIiB5MT0iMjIwIiB4Mj0iMjI0IiB5Mj0iMjIwIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iOCIvPjxsaW5lIHgxPSIxMjgiIHkxPSIyMDQiIHgyPSIyMjQiIHkyPSIyMDQiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSI4Ii8+PGxpbmUgeDE9IjE0NCIgeTE9IjE4OCIgeDI9IjIyNCIgeTI9IjE4OCIgc3Ryb2tlPSIjRkZGRkZGIiBzdHJva2Utd2lkdGg9IjgiLz48L3N2Zz4=', - title: 'Click to add video' - }) - .on({click: edit}) - .hide() - .appendTo($interface); - if (editable) { - $editButton.show(); - } - if (video) { - enableVideoUI(); - } - this.div.appendChild($interface[0]); - Ox.$parent.bindMessage('update', function(data) { - if (video && data.id == video.id && data.page == video.page) { - video.src = data.src; - video.src !== '' ? enableVideoUI() : disableVideoUI(); - } - }); - } - function play(e) { - e.preventDefault(); - e.stopPropagation(); - var videoId = 'video' + page + id + Ox.uid(), - $iframe = Ox.Element('