filesbox/web/dist/reader/js/plugins/hypothesis.js
2024-07-26 14:10:54 +08:00

2 lines
1.3 KiB
JavaScript

window.hypothesisConfig=function(){var n=window.Annotator,e=$("#main");function r(i,o){o={server:!0,origin:!0,showHighlights:!0,Toolbar:{container:"#annotation-controls"}},n.Host.call(this,i,o)}return r.prototype=Object.create(n.Host.prototype),r.prototype.show=function(){this.frame.css({"margin-left":-1*this.frame.width()+"px"}),this.frame.removeClass("annotator-collapsed"),e.hasClass("single")||(e.addClass("single"),this.toolbar.find("[name=sidebar-toggle]").removeClass("h-icon-chevron-left").addClass("h-icon-chevron-right"),this.setVisibleHighlights(!0))},r.prototype.hide=function(){this.frame.css({"margin-left":""}),this.frame.addClass("annotator-collapsed"),e.hasClass("single")&&(e.removeClass("single"),this.toolbar.find("[name=sidebar-toggle]").removeClass("h-icon-chevron-right").addClass("h-icon-chevron-left"),this.setVisibleHighlights(!1))},{constructor:r}},EPUBJS.reader.plugins.HypothesisController=function(n){var e=this,r=$("#main"),i=function(){var t=n.renderer.render.window.annotator;if(t&&t.constructor.$){var a=o(t.constructor.$);t.showAnnotations(a)}},o=function(t){var a=n.renderer.render.iframe.clientWidth;return t(".annotator-hl").map(function(){var l=t(this),s=this.getBoundingClientRect().left;if(s>=0&&s<=a)return l.data("annotation")}).get()};return n.on("renderer:locationChanged",i),{}};