Remove jQuery
This commit is contained in:
parent
8c97a625e1
commit
e4b1c44aa3
|
@ -27,9 +27,7 @@ namespace Ooui.Forms.Renderers
|
||||||
if (e.NewElement != null) {
|
if (e.NewElement != null) {
|
||||||
if (Control == null) {
|
if (Control == null) {
|
||||||
var input = new Input (InputType.Checkbox);
|
var input = new Input (InputType.Checkbox);
|
||||||
input.SetAttribute ("data-toggle", "toggle");
|
|
||||||
SetNativeControl (input);
|
SetNativeControl (input);
|
||||||
input.Call ("$.bootstrapToggle");
|
|
||||||
Control.Change += OnControlValueChanged;
|
Control.Change += OnControlValueChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,19 +84,11 @@ function ooui (rootElementPath) {
|
||||||
const messages = JSON.parse (event.data);
|
const messages = JSON.parse (event.data);
|
||||||
if (debug) console.log("Messages", messages);
|
if (debug) console.log("Messages", messages);
|
||||||
if (Array.isArray (messages)) {
|
if (Array.isArray (messages)) {
|
||||||
const jqs = []
|
|
||||||
messages.forEach (function (m) {
|
messages.forEach (function (m) {
|
||||||
// console.log('Raw value from server', m.v);
|
// console.log('Raw value from server', m.v);
|
||||||
m.v = fixupValue (m.v);
|
m.v = fixupValue (m.v);
|
||||||
if (m.k.startsWith ("$.")) {
|
|
||||||
jqs.push (m);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
processMessage (m);
|
processMessage (m);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// Run jQuery functions last since they usually require a fully built DOM
|
|
||||||
jqs.forEach (processMessage);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -212,15 +204,14 @@ function msgCall (m) {
|
||||||
console.error ("Unknown node id", m);
|
console.error ("Unknown node id", m);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const isJQuery = m.k.startsWith ("$.");
|
const target = node;
|
||||||
const target = isJQuery ? $(node) : node;
|
|
||||||
if (m.k === "insertBefore" && m.v[0].nodeType == Node.TEXT_NODE && m.v[1] == null && hasText[id]) {
|
if (m.k === "insertBefore" && m.v[0].nodeType == Node.TEXT_NODE && m.v[1] == null && hasText[id]) {
|
||||||
// Text is already set so it clear it first
|
// Text is already set so it clear it first
|
||||||
if (target.firstChild)
|
if (target.firstChild)
|
||||||
target.removeChild (target.firstChild);
|
target.removeChild (target.firstChild);
|
||||||
delete hasText[id];
|
delete hasText[id];
|
||||||
}
|
}
|
||||||
const f = isJQuery ? target[m.k.slice(2)] : target[m.k];
|
const f = target[m.k];
|
||||||
if (debug) console.log ("Call", node, f, m.v);
|
if (debug) console.log ("Call", node, f, m.v);
|
||||||
const r = f.apply (target, m.v);
|
const r = f.apply (target, m.v);
|
||||||
if (typeof m.rid === 'string' || m.rid instanceof String) {
|
if (typeof m.rid === 'string' || m.rid instanceof String) {
|
||||||
|
|
|
@ -230,20 +230,6 @@ namespace Ooui
|
||||||
SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]);
|
SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool SaveStateMessageIfNeeded (Message message)
|
|
||||||
{
|
|
||||||
if (message.TargetId != Id)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (message.MessageType) {
|
|
||||||
case MessageType.Call when message.Key.StartsWith ("$.", StringComparison.Ordinal):
|
|
||||||
AddStateMessage (message);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return base.SaveStateMessageIfNeeded (message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual bool HtmlNeedsFullEndElement => false;
|
protected virtual bool HtmlNeedsFullEndElement => false;
|
||||||
|
|
||||||
public override void WriteOuterHtml (System.Xml.XmlWriter w)
|
public override void WriteOuterHtml (System.Xml.XmlWriter w)
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace Ooui
|
||||||
<title>@Title</title>
|
<title>@Title</title>
|
||||||
<meta name=""viewport"" content=""width=device-width, initial-scale=1"" />
|
<meta name=""viewport"" content=""width=device-width, initial-scale=1"" />
|
||||||
<link rel=""stylesheet"" href=""https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"" />
|
<link rel=""stylesheet"" href=""https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"" />
|
||||||
<link rel=""stylesheet"" href=""https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css"" />
|
|
||||||
<style>@Styles</style>
|
<style>@Styles</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -49,8 +48,6 @@ namespace Ooui
|
||||||
@InitialHtml
|
@InitialHtml
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type=""text/javascript"" src=""https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js""></script>
|
|
||||||
<script type=""text/javascript"" src=""https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js""></script>
|
|
||||||
<script src=""/ooui.js""></script>
|
<script src=""/ooui.js""></script>
|
||||||
<script>ooui(""@WebSocketPath"");</script>
|
<script>ooui(""@WebSocketPath"");</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue