Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show "Concealed fact" tag on transparent facts #559

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion iXBRLViewerPlugin/viewer/src/js/ixnode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// See COPYRIGHT.md for copyright information

import $ from 'jquery';
import { isTransparent } from './util.js';

/*
* Object to hold information related to iXBRL nodes in the HTML document.
Expand Down Expand Up @@ -44,6 +46,6 @@ export class IXNode {
}

htmlHidden() {
return this.wrapperNodes.is(':hidden');
return this.wrapperNodes.is(':hidden') || this.wrapperNodes.is((i,e) => isTransparent($(e).css('color')));
}
}
11 changes: 11 additions & 0 deletions iXBRLViewerPlugin/viewer/src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,14 @@ export function titleCase(text) {
.join('');
}).join(' ');
}

/**
* Extract the alpha value from an rgba(r,g,b,a) string and returns true if
* transparent (a < 10%). Returns false on rgb(r,g,b) strings.
* @param {String} rgba color string to parse
* @return {Boolean} whether the value is transparent
*/
export function isTransparent(rgba) {
const val = parseFloat(rgba.split(",")[3]);
return !isNaN(val) && val < 0.1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the isNaN check is redundant, but it's perhaps clearer to be explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't spotted that it's redundant, but I do think it is worth being explicit, as it documents that NaN is expected on some inputs, and makes it clear how it's handled.

}