-
Notifications
You must be signed in to change notification settings - Fork 16
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
OSOE-476: Extract inline javascript block into file, and register for usage in Lombiq.HelpfulExtensions #114
Changes from all commits
dc0de51
c64febc
207b4c0
12546f3
f593a67
7ac4d2f
c59f89b
e627ff1
fbbb03b
4cdedc7
53db90c
6692059
8842243
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(function initTargetBlank() { | ||
function targetBlank() { | ||
const links = document.querySelectorAll('a'); | ||
const currentHostname = window.location.hostname; | ||
|
||
for (let i = 0; i < links.length; i++) { | ||
if (!links[i].href.match(/^mailto:/) && | ||
(links[i].hostname !== currentHostname && | ||
(!links[i].href.match(/^javascript:/i)))) { | ||
links[i].setAttribute('target', '_blank'); | ||
} | ||
} | ||
} | ||
window.addEventListener( | ||
'load', | ||
() => { | ||
window.setTimeout(targetBlank, 100); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the timeout necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see it was in the original source. The whole |
||
}, | ||
false); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Lombiq.HelpfulExtensions.Constants; | ||
|
||
public static class ResourceNames | ||
{ | ||
public const string TargetBlank = nameof(TargetBlank); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.Options; | ||
using OrchardCore.ResourceManagement; | ||
using static Lombiq.HelpfulExtensions.Constants.ResourceNames; | ||
|
||
namespace Lombiq.HelpfulExtensions; | ||
|
||
public class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions> | ||
{ | ||
private const string WwwRoot = "~/Lombiq.HelpfulExtensions/"; | ||
private static readonly ResourceManifest _manifest = new(); | ||
|
||
static ResourceManagementOptionsConfiguration() => | ||
_manifest | ||
.DefineScript(TargetBlank) | ||
.SetUrl(WwwRoot + "scripts/target-blank.min.js", WwwRoot + "scripts/target-blank.js") | ||
.SetVersion("1.0.0"); | ||
|
||
public void Configure(ResourceManagementOptions options) => options.ResourceManifests.Add(_manifest); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"build:assets": "npm explore nodejs-extensions -- pnpm build:assets", | ||
"build:scripts": "npm explore nodejs-extensions -- pnpm build:scripts", | ||
"clean:scripts": "npm explore nodejs-extensions -- pnpm clean:scripts", | ||
"watch:scripts": "npm explore nodejs-extensions -- pnpm watch:scripts" | ||
}, | ||
"nodejsExtensions": { | ||
"scripts": { | ||
"source": "Assets/Scripts", | ||
"target": "wwwroot/scripts" | ||
} | ||
}, | ||
Comment on lines
+9
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole configuration is superfluous, if you're willing to accept the default path wwwroot/js for JS files. |
||
"devDependencies": { | ||
"eslint": "^8.25.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-only-warn": "^1.0.3", | ||
"eslint-plugin-promise": "^6.1.0" | ||
} | ||
Comment on lines
+15
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When used as part of OSOCE, this whole block should not be here. |
||
} |
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.
This has been merged now, but there are superfluous parentheses here: