-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
OSOE-476: Extract inline javascript block into file, and register for usage in Lombiq.HelpfulExtensions
- Loading branch information
Showing
8 changed files
with
1,382 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
false); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Lombiq.HelpfulExtensions/ResourceManagementOptionsConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
}, | ||
"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" | ||
} | ||
} |
Oops, something went wrong.