-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'OrchardCMS:main' into liquid-tryiteditor
- Loading branch information
Showing
28 changed files
with
201 additions
and
88 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
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
10 changes: 8 additions & 2 deletions
10
src/OrchardCore.Modules/OrchardCore.Resources/Assets/trumbowyg/js/trumbowyg.theme.js
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
2 changes: 1 addition & 1 deletion
2
...rchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/trumbowyg/trumbowyg.theme.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ore.Resources/wwwroot/Styles/ui/icons.svg → ...es/wwwroot/Scripts/trumbowyg/ui/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion
1
src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/ui/icons.svg
This file was deleted.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
...ardCore.Themes/Assets/js/theme-manager.js → ...OrchardCore.Themes/Assets/js/constants.js
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
2 changes: 0 additions & 2 deletions
2
...min/Assets/js/header/theme/themeLoader.js → ...hardCore.Themes/Assets/js/theme-loader.js
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
File renamed without changes.
24 changes: 13 additions & 11 deletions
24
src/OrchardCore.Modules/OrchardCore.Themes/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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
using Microsoft.Extensions.Options; | ||
using OrchardCore.Environment.Shell; | ||
using OrchardCore.ResourceManagement; | ||
|
||
namespace OrchardCore.Themes; | ||
|
||
public sealed class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions> | ||
{ | ||
private readonly ShellSettings _shellSettings; | ||
private static readonly ResourceManifest _manifest; | ||
|
||
public ResourceManagementOptionsConfiguration(ShellSettings shellSettings) | ||
static ResourceManagementOptionsConfiguration() | ||
{ | ||
_shellSettings = shellSettings; | ||
} | ||
_manifest = new ResourceManifest(); | ||
|
||
public void Configure(ResourceManagementOptions options) | ||
{ | ||
var manifest = new ResourceManifest(); | ||
_manifest | ||
.DefineScript("theme-head") | ||
.SetUrl("~/OrchardCore.Themes/Scripts/theme-head.min.js", "~/OrchardCore.Themes/Scripts/theme-head.js") | ||
.SetVersion("1.0.0"); | ||
|
||
manifest | ||
_manifest | ||
.DefineScript("theme-manager") | ||
.SetAttribute("data-tenant-name", _shellSettings.Name) | ||
.SetUrl("~/OrchardCore.Themes/Scripts/theme-manager.min.js", "~/OrchardCore.Themes/Scripts/theme-manager.js") | ||
.SetDependencies("theme-head") | ||
.SetVersion("1.0.0"); | ||
} | ||
|
||
options.ResourceManifests.Add(manifest); | ||
public void Configure(ResourceManagementOptions options) | ||
{ | ||
options.ResourceManifests.Add(_manifest); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/OrchardCore.Modules/OrchardCore.Themes/wwwroot/Scripts/theme-head.js
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,59 @@ | ||
/* | ||
** NOTE: This file is generated by Gulp and should not be edited directly! | ||
** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. | ||
*/ | ||
|
||
var darkThemeName = 'dark'; | ||
var lightThemeName = 'light'; | ||
var themeStoreKeySuffix = 'theme'; | ||
var getTenantName = function getTenantName() { | ||
return document.documentElement.getAttribute('data-tenant') || 'default'; | ||
}; | ||
var getStoreKeySuffix = function getStoreKeySuffix() { | ||
return themeStoreKeySuffix || 'theme'; | ||
}; | ||
var getStoreKey = function getStoreKey() { | ||
return "".concat(getTenantName(), "-").concat(getStoreKeySuffix()); | ||
}; | ||
var getStoredTheme = function getStoredTheme() { | ||
return localStorage.getItem(getStoreKey()); | ||
}; | ||
var setStoredTheme = function setStoredTheme(theme) { | ||
return localStorage.setItem(getStoreKey(), theme); | ||
}; | ||
var isDarkMedia = function isDarkMedia() { | ||
return window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
}; | ||
var getPreferredTheme = function getPreferredTheme() { | ||
var storedTheme = getStoredTheme(); | ||
if (storedTheme) { | ||
return storedTheme; | ||
} | ||
return isDarkMedia() ? darkThemeName : lightThemeName; | ||
}; | ||
var setTheme = function setTheme(theme) { | ||
if (theme === 'auto') { | ||
document.documentElement.setAttribute('data-bs-theme', isDarkMedia() ? darkThemeName : lightThemeName); | ||
} else { | ||
document.documentElement.setAttribute('data-bs-theme', theme); | ||
} | ||
}; | ||
// We need to apply the classes BEFORE the page is rendered. | ||
// That is why we use a MutationObserver instead of document.Ready(). | ||
var themeObserver = new MutationObserver(function (mutations) { | ||
for (var i = 0; i < mutations.length; i++) { | ||
for (var j = 0; j < mutations[i].addedNodes.length; j++) { | ||
if (mutations[i].addedNodes[j].tagName == 'BODY') { | ||
setTheme(getPreferredTheme()); | ||
|
||
// we're done: | ||
themeObserver.disconnect(); | ||
} | ||
; | ||
} | ||
} | ||
}); | ||
themeObserver.observe(document.documentElement, { | ||
childList: true, | ||
subtree: true | ||
}); |
1 change: 1 addition & 0 deletions
1
src/OrchardCore.Modules/OrchardCore.Themes/wwwroot/Scripts/theme-head.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
src/OrchardCore.Modules/OrchardCore.Themes/wwwroot/Scripts/theme-manager.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.