improved dynamic CSS handling
This commit is contained in:
parent
c3ff9ff12b
commit
ddf7cdbec7
|
@ -57,6 +57,21 @@ namespace Oqtane.Shared
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task RemoveCSS(string filepattern)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsRuntime.InvokeAsync<string>(
|
||||||
|
"interop.removeCSS",
|
||||||
|
filepattern);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ValueTask<string> GetElementByName(string name)
|
public ValueTask<string> GetElementByName(string name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
@using Oqtane.Shared
|
@using Oqtane.Shared
|
||||||
@using Oqtane.Modules
|
@using Oqtane.Modules
|
||||||
|
@using Microsoft.JSInterop
|
||||||
@namespace Oqtane.Shared
|
@namespace Oqtane.Shared
|
||||||
|
@inject IJSRuntime jsRuntime
|
||||||
|
|
||||||
@DynamicComponent
|
@DynamicComponent
|
||||||
|
|
||||||
|
@ -28,4 +30,12 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
// remove any custom CSS
|
||||||
|
var interop = new Interop(jsRuntime);
|
||||||
|
await interop.RemoveCSS("Themes/");
|
||||||
|
await interop.RemoveCSS("Modules/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,16 @@ window.interop = {
|
||||||
|
|
||||||
head.appendChild(link);
|
head.appendChild(link);
|
||||||
},
|
},
|
||||||
|
removeCSS: function (filePattern) {
|
||||||
|
var head = document.head;
|
||||||
|
var links = document.getElementsByTagName("link");
|
||||||
|
for (var i = 0; i < links.length; i++) {
|
||||||
|
var link = links[i];
|
||||||
|
if (link.rel === 'stylesheet' && link.href.includes(filePattern)) {
|
||||||
|
head.removeChild(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
submitForm: function (path, fields) {
|
submitForm: function (path, fields) {
|
||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
form.method = 'post';
|
form.method = 'post';
|
||||||
|
|
|
@ -38,6 +38,16 @@ window.interop = {
|
||||||
|
|
||||||
head.appendChild(link);
|
head.appendChild(link);
|
||||||
},
|
},
|
||||||
|
removeCSS: function (filePattern) {
|
||||||
|
var head = document.head;
|
||||||
|
var links = document.getElementsByTagName("link");
|
||||||
|
for (var i = 0; i < links.length; i++) {
|
||||||
|
var link = links[i];
|
||||||
|
if (link.rel === 'stylesheet' && link.href.includes(filePattern)) {
|
||||||
|
head.removeChild(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
submitForm: function (path, fields) {
|
submitForm: function (path, fields) {
|
||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
form.method = 'post';
|
form.method = 'post';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user