-
Notifications
You must be signed in to change notification settings - Fork 1
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
TUP-703 TACC Home Banner Links Open in New Window #805
Conversation
//shouldForceSetTarget could be used in this if statement if passing in options. | ||
if (!isInternalLink || isMailto ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. (Thanks for the comment/reminder.) We avoid shouldForceSetTarget
for now, cuz it causes the bug.
I'll check that no client needs that feature, and if one does, how to not require this script to handle that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: No client needs shouldForceSetTarget
. Celebrate with Fire: You may burn all code and variables relevant to it e.g. pathsToExernalSite
, pathsToForceSetTarget
. Bonus: You may clean up even more cruft code, i.e. perform CMD-87, at your leisure, now or later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. 72e3d15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please delete shouldForceSetTarget
and related code.
//shouldForceSetTarget could be used in this if statement if passing in options. | ||
if (!isInternalLink || isMailto ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: No client needs shouldForceSetTarget
. Celebrate with Fire: You may burn all code and variables relevant to it e.g. pathsToExernalSite
, pathsToForceSetTarget
. Bonus: You may clean up even more cruft code, i.e. perform CMD-87, at your leisure, now or later.
taccsite_cms/static/site_cms/js/modules/setTargetForExternalLinks.js
Outdated
Show resolved
Hide resolved
/** | ||
* Whether to log debug info to console | ||
* @const {string} | ||
*/ | ||
const SHOULD_DEBUG = window.DEBUG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah. Control the burn. The SHOULD_DEBUG
is still used. Also, the jsDoc block (a docblock) is still accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. Click this: 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored via cbad538
/** | ||
* Set external links (automatically discovered) to open in new tab | ||
* @param {object} [options] - Optional parameters | ||
* @param {array.<string>} [options.pathsToExernalSite=[]] - (DEPRECATED) A list of relative URL paths that should be treated like external URLs | ||
* @param {array.<string|RegExp>} [options.pathsToForceSetTarget=[]] - A list of relative URL paths (or patterns) that should trigger setting a target | ||
* @param {HTMLElement|Document} [options.scopeElement=document] - The element within which to search for links | ||
* @param {setTargetCallback} [options.setTargetCallback] - A callback for after a target is set | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please retain the docblock sans @param
lines. The function description is still accurate.
Docblocks are written in jsDoc format. They provide manual definitions (in lieu of TypeScript), and can be used to auto-generate documentation e.g. vite.js on jsdocs.io.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored via cbad538 without params.
taccsite_cms/static/site_cms/js/modules/setTargetForExternalLinks.js
Outdated
Show resolved
Hide resolved
taccsite_cms/static/site_cms/js/modules/setTargetForExternalLinks.js
Outdated
Show resolved
Hide resolved
I msitakenly requested this be restored. My bad. (First time using Github on phone, so I misread.) https://github.com/TACC/Core-CMS/pull/805/files#r1509226199
Overview
Prevent banner links from opening in new windows.
Related
Changes
Changes what is considered an external link. Looks for the host name with or without www., then opens in new window if it isn't matching to the document's host.
Testing
A) If you'd like to troubleshoot in TUP-UI Repo:
B) If you'd like to just test these changes in TUP-UI using Core_CMS
UI
…
Notes
The
shouldForceSetTarget
function below:does not allow external links to open in a new window.
For instance. If you're in localhost, and have a
tacc.utexas.edu
link - it should open in a new window because it doesn't match the host.This might be something you test in tup-ui repo using the A) testing steps above