Skip to content

Commit

Permalink
Fixed zoom and highlight issues
Browse files Browse the repository at this point in the history
  • Loading branch information
semyonc committed Oct 1, 2021
1 parent 9d53c66 commit f771399
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion iXBRLViewerPlugin/viewer/dist/ixbrlviewer.js

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions iXBRLViewerPlugin/viewer/src/js/ixbrlviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ iXBRLViewer.prototype._inIframe = function() {
iXBRLViewer.prototype._detectPDF = function(document) {
var pageContainer = $("div#page-container", document);
if (pageContainer.length > 0) {
if (pageContainer.find("div.pf[style*='content-visibility']").length > 0) {
var generator = $('meta[name=generator]', this._contents).attr("content");
if (generator === 'pdf2htmlEX') {
return true;
}
var generator = $('meta[name=generator]', this._contents).attr("content");
if (generator === 'pdf2htmlEX') {
return true;
}
if (pageContainer.find("div.pf[style*='content-visibility']").length > 0) {
return true;
}
}
return false;
}
Expand Down Expand Up @@ -202,8 +203,9 @@ iXBRLViewer.prototype._load = function(ownerDocument) {

setTimeout(function(){

/* AMANA: In the chromium, pdf files do not use frames in case of content-visibility CSS style */
var useFrames = iv._inIframe() || !iv._detectPDF(ownerDocument);
/* AMANA: In the chromium, pdf files do not use frames in case of content-visibility CSS style */
var isPDF = iv._detectPDF(ownerDocument);
var useFrames = iv._inIframe() || !isPDF;
var iframes = $(iv._reparentDocument(ownerDocument, useFrames));

/* AMANA extension: In a case of multifile iXBRL attach JSON into every HTML page is too expensive --> */
Expand Down Expand Up @@ -252,7 +254,7 @@ iXBRLViewer.prototype._load = function(ownerDocument) {
});
}

var viewer = iv.viewer = new Viewer(iv, iframes, report, useFrames);
var viewer = iv.viewer = new Viewer(iv, iframes, report, useFrames, isPDF);

viewer.initialize()
.then(() => inspector.initialize(report))
Expand Down
23 changes: 19 additions & 4 deletions iXBRLViewerPlugin/viewer/src/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import { Fact } from './fact.js';

import 'bootstrap/js/dist/tooltip';

export function Viewer(iv, iframes, report, useFrames) {
export function Viewer(iv, iframes, report, useFrames, isPDF) {
this._iv = iv;
this._report = report;
this._iframes = iframes;
this._useFrames = useFrames;
this._isPDF = isPDF;

if (useFrames) {
this._contents = iframes.contents();
} else {
Expand Down Expand Up @@ -135,7 +137,10 @@ Viewer.prototype._preProcessiXBRL = function(n, docIndex, inHidden) {
if (!inHidden) {
/* Is the element the only significant content within a <td> or <th> ? If
* so, use that as the wrapper element. */
node = $(n).closest("td,th,span,div").eq(0);
node = $(n).closest("td,th").eq(0);
if (node.length == 0 && name == 'NONFRACTION') {
node = $(n).closest("span,div").eq(0);
}
const innerText = $(n).text();
if (node.length == 1 && innerText.length > 0) {
if (node.css('display') == 'none') {
Expand Down Expand Up @@ -542,8 +547,18 @@ Viewer.prototype._zoom = function () {
container = $('#zoom-container');
scrollParent = $(getScrollParent(container[0]));
} else {
container = $(this.ownerDocument.body);
scrollParent = $(this);
if (iv._isPDF) {
if (!iv._mzInit) {
let pagecontainer = $('#page-container', $(this));
pagecontainer.contents().wrapAll('<div id="zoom-container"></div>');
iv._mzInit = true;
}
container = $('#zoom-container', $(this));
scrollParent = $(getScrollParent(container[0]));
} else {
container = $(this.ownerDocument.body);
scrollParent = $(this);
}
}
var viewTop = scrollParent.scrollTop();
var viewLeft = scrollParent.scrollLeft();
Expand Down

0 comments on commit f771399

Please sign in to comment.