OcttKB Cross-Repo Sync (HTML to Raw)

This commit is contained in:
2023-03-24 11:58:33 +00:00
parent e0528394e6
commit dc21b3c71c
1537 changed files with 93 additions and 1028 deletions

View File

@ -0,0 +1,26 @@
created: 20200603211101398
modified: 20200603211101398
tags:
title: $:/plugins/telmiger/details/about
Create HTML 5 `<details>` elements including a `<summary>` using this widget.
<$details summary="The details element W3C definition">
<<<
The [[details|http://w3c.github.io/html/interactive-elements.html#elementdef-details]] element represents a disclosure widget from which the user can obtain additional information or controls.
<<< W3C
</$details>
<$details summary="Code example" open="no">
```
<$details summary="This should be open" open="yes">
Content will be immediately visible if open is set to "yes".
</$details>
```
</$details>

View File

@ -0,0 +1,32 @@
created: 20180925155320737
creator: Thomas Elmiger
modified: 20180926204140772
modifier: Thomas Elmiger
tags: $:/tags/Stylesheet
title: $:/plugins/telmiger/details/colours.css
/* details and summary colours */
details {
background-color: <<colour tiddler-info-tab-background>>;
color: <<colour foreground>>;
}
details summary {
background-color: <<colour dropdown-tab-background>>;
}
details.notification summary {
background-color: <<colour notification-background>>;
/* TW leaves color undefined/uses foreground */
}
details.warning summary {
background-color: #ffbbaf;
color: #000;
}
details.success summary {
background-color: #88edc5;
color: #000;
}

View File

@ -0,0 +1,44 @@
created: 20170122140815442
creator: Thomas Elmiger
modified: 20180929131615369
modifier: Thomas Elmiger
tags: $:/tags/Stylesheet
title: $:/plugins/telmiger/details/details.css
/* details and summary */
details {
transition: height 1s ease;
padding: 0 0.5em 0 0.66em;
margin-top: 0.66em;
margin-bottom: 0.66em;
}
details + details {
margin-top: -0.46em;
}
details[open] {
padding-bottom: 1em;
}
details:not([open]) {
cursor: pointer;
}
details > summary {
display: list-item;
margin: 0 -0.5em 0 -0.66em;
padding: 0.2em 0.5em 0.2em 0.66em;
padding-left: 1.76em; /* adjust for indentation */
text-indent: -1.1em;
cursor: pointer;
}
details[open] > summary {
margin-bottom: 1em;
}
details[open] > *:first-child:not(summary) {
margin-top: 1em;
}

View File

@ -0,0 +1,247 @@
/*\
title: $:/plugins/telmiger/details/details.js
type: application/javascript
module-type: widget
Details widget v 0.8
Will output an HTML 5 <details> section including a <summary>
```
<details>
<summary>This sums it up</summary>
All the details follow here.
</details>
```
|Parameter |Description |h
|summary |Optional text to display as summary. Wins over field (see below). |
|open |Optional initial state, set to "open" to show details on load. Defaults to "". |
|state |An optional TextReference containing the state. Wins over open. |
|field |Optionally, the summary is taken from the field with this name in a given tiddler. Defaults to "title". |
|tiddler |Optional title of a tiddler to watch, connected to field. Defaults to current tiddler. |
|class |Optional CSS classes to be assigned to the details tag. |
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var DetailsWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
DetailsWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
DetailsWidget.prototype.render = function(parent,nextSibling) {
// Save the parent dom node
this.parentDomNode = parent;
// Compute attributes
this.computeAttributes();
// Execute logic
this.execute();
// Create elements
this.detailsDomNode = this.document.createElement("details");
if(this.detailsClass !== "") {
// this.detailsClass += " ";
// this.detailsClass += "tc-details";
this.detailsDomNode.setAttribute("class",this.detailsClass);
}
if(this.detailsOpen == "open") {
this.detailsDomNode.setAttribute("open","open");
}
if(this.detailsSummary !== "") {
this.summaryDomNode = this.document.createElement("summary");
// this.summaryDomNode.setAttribute("class","tc-summary");
this.detailsDomNode.appendChild(this.summaryDomNode);
this.summaryDomNode.appendChild(this.document.createTextNode(this.detailsSummary));
}
// register an event listener
/* Maybe this can be reactivated later, see below.
if(this.detailsStateTitle) {
$tw.utils.addEventListeners(this.detailsDomNode,[
{name: "toggle", handlerObject: this, handlerMethod: "handleToggleEvent"},
]);
}
*/
// As iOS mobile browsers lack support of toggle events on details
// we emulate the toggle event using click
if(this.detailsStateTitle && this.summaryDomNode) {
$tw.utils.addEventListeners(this.summaryDomNode,[
{name: "click", handlerObject: this, handlerMethod: "handleToggleEvent"},
]);
} else {
if(this.detailsStateTitle) {
$tw.utils.addEventListeners(this.detailsDomNode,[
{name: "click", handlerObject: this, handlerMethod: "handleToggleEvent"},
]);
}
}
// Insert the details into the DOM and render any children
this.parentDomNode.insertBefore(this.detailsDomNode,nextSibling);
this.renderChildren(this.detailsDomNode,null);
this.domNodes.push(this.detailsDomNode);
};
/*
Retrieve the value of the summary
*/
DetailsWidget.prototype.getSummary = function() {
var summary = "";
if(this.summaryTitle === "Tiddler not found" && this.summaryField === "") {
// nothing defined: leave empty
summary = "";
} else {
// tiddler defined? use defined field or title
if(this.myTiddler) {
if(this.summaryField === "title" || this.summaryField === "") {
summary = this.summaryTitle;
} else {
if(this.summaryField === "text") {
// getTiddlerText() triggers lazy loading of skinny tiddlers
summary = this.wiki.getTiddlerText(this.summaryTitle);
} else {
summary = this.myTiddler.fields[this.summaryField];
}
}
} else {
if(this.summaryField !== "" && this.summaryField !== "text") {
// try defined field in current tiddler
var tiddler = this.wiki.getTiddler(this.getVariable("currentTiddler"));
summary = tiddler.fields[this.summaryField];
} else {
summary = "";
}
}
}
return summary;
};
/*
Retrieve the value of the state text reference
*/
DetailsWidget.prototype.getStateFromReference = function() {
var state = this.detailsStateTitle ? this.wiki.getTextReference(this.detailsStateTitle,"",this.getVariable("currentTiddler")) : "";
return state;
};
/*
Check all open signals, state fields/tiddlers get priority
*/
DetailsWidget.prototype.getOpenState = function() {
var result = "";
if((this.detailsOpenDefault !== "" && this.detailsOpenDefault !== "no")
|| this.detailsState === "open") {
result = "open";
}
if(this.detailsStateTitle !=="" && this.detailsState !== "open") {
result = "";
}
return result;
};
/*
Update the state text reference after click event
*/
DetailsWidget.prototype.updateState = function(openState) {
var fieldValue = "false";
var currentTiddler = this.getVariable("currentTiddler");
// get the title for the (existing/new) tiddler
var tr = $tw.utils.parseTextReference(this.detailsStateTitle);
var tidTitle = tr.title || currentTiddler;
// is it an existing state tiddler?
var isStateTiddler = (tr.title === this.detailsStateTitle);
var hasStateTiddler = this.wiki.tiddlerExists(tr.title);
var currentStateTiddler = (tr.title === currentTiddler);
if(isStateTiddler || hasStateTiddler || (currentStateTiddler && tr.field !== "text")) {
// Set the state field (but never overwrite the current tiddlers text field
this.wiki.setText(tidTitle,tr.field,tr.index,openState);
} else {
if(!hasStateTiddler && tidTitle !== currentTiddler) {
this.createTiddler(tidTitle);
this.wiki.setText(tidTitle,tr.field,tr.index,openState);
} else {
console.log ("Something went wrong in updateState");
}
}
};
/*
Create a tiddler with a title only
*/
DetailsWidget.prototype.createTiddler = function(tidTitle) {
this.wiki.addTiddler(new $tw.Tiddler(
this.wiki.getCreationFields(),
this.wiki.getModificationFields(),
{
title: tidTitle,
tags: []
}
));
};
/*
Set openState according to click
*/
DetailsWidget.prototype.handleToggleEvent = function(event) {
// check if an open attribute is present
var newState = this.detailsDomNode.open ? "" : "open";
// update only, if the node has a new state
if(newState !== this.detailsState) {
this.updateState(newState);
}
};
/*
Compute the internal state of the widget
*/
DetailsWidget.prototype.execute = function() {
// Get the parameters from the attributes
var tryTiddler = this.getAttribute("tiddler");
this.myTiddler = this.wiki.getTiddler(tryTiddler);
this.summaryTitle = this.myTiddler ? tryTiddler : "Tiddler not found";
this.summaryField = this.getAttribute("field","");
this.detailsSummary = this.getAttribute("summary") || this.getSummary();
this.detailsStateTitle = this.getAttribute("state","");
this.detailsState = this.getStateFromReference();
this.detailsOpenDefault = this.getAttribute("open","");
this.detailsOpen = this.getOpenState();
this.detailsClass = this.getAttribute("class","");
// Construct the child widgets
this.makeChildWidgets();
};
/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
DetailsWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.summary || changedAttributes.state || changedAttributes.open || changedAttributes["class"]) {
this.refreshSelf();
return true;
} else {
var refreshed = false;
var testState = this.getStateFromReference();
if(testState !== this.detailsState) {
// state change
this.refreshSelf();
refreshed = true;
}
return this.refreshChildren(changedTiddlers) || refreshed;
}
};
exports.details = DetailsWidget;
})();

View File

@ -0,0 +1,8 @@
created: 20170124173619910
creator: Thomas Elmiger
modified: 20180929212032187
modifier: Thomas Elmiger
module-type: widget
tags: Plugins
title: $:/plugins/telmiger/details/details.js
type: application/javascript

View File

@ -0,0 +1,10 @@
created: 20170205205314072
modified: 20171219183752113
tags:
title: $:/plugins/telmiger/details/icon
<svg class="tc-image-button telmiger-icon" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" viewBox="0 0 128 128" role="img" aria-labelledby="title"><title id="title">T</title><path class="circle" d="M64 2C30 2 2 29.753 2 64c0 34.235 27.753 62 62 62s62-27.752 62-62C126 29.753 98.221 2 64 2z"/><path class="t" d="M100.41 63.254c-2.886 1.92-7.544 2.883-13.979 2.883h-8.008c-4.246 0-7.331.845-9.254 2.536-1.922 1.69-3.449 5.086-4.576 10.19 0 0-.181 1.481-.503 1.481s-.369-.877-.518-1.586a37.897 37.897 0 0 0-.721-2.754c-.631-2.137-1.262-3.753-1.894-4.847-.764-1.359-1.727-2.452-2.889-3.28-1.162-.83-2.49-1.326-3.985-1.492l-2.092-.248H41.73c-6.144 0-10.711-.962-13.7-2.884-4.976-3.159-7.649-9.129-8.02-17.91-.03-.706.003-1.351.132-2.171h.585c.399 3.975 3.679 7.048 6.086 9.219 2.408 2.172 6.269 3.258 11.581 3.258h9.313c5.347 0 9.257 1.226 11.731 3.68 2.231 2.213 3.701 5.68 4.406 10.4.076.511.03.736.178.736.149 0 .11-.256.17-.783.713-6.122 3.085-10.219 7.117-12.294 2.487-1.292 6.434-1.906 11.841-1.839l6.368.1c4.311.066 7.942-.788 10.893-2.56 2.953-1.773 6.447-5.079 6.844-9.917h.595c.183.478.16 1.576.127 2.333-.371 8.752-2.894 14.668-7.567 17.749z"/></svg>
<style>
.telmiger-icon .circle { fill: #e2001a }
.telmiger-icon .t { fill: #fff }
</style>

View File

@ -0,0 +1,17 @@
created: 20170205213335455
modified: 20170205214435064
tags:
title: $:/plugins/telmiger/details/license
!! Plugin license
!!!The MIT License (MIT)
```
Copyright © 2017/2018 Thomas Elmiger thomas-elmiger.ch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

View File

@ -0,0 +1,10 @@
created: 20170205212323032
modified: 20200603211110057
tags:
title: $:/plugins/telmiger/details/readme
! ~DetailsWidget
{{$:/plugins/telmiger/details/about}}
Documentation can be found at http://tid.li/tw5/plugins.html#DetailsWidget

View File

@ -0,0 +1,6 @@
created: 20200603204816640
modified: 20220425065858878
tags:
title: $:/plugins/telmiger/details/support
{{$:/plugins/telmiger/support}}

View File

@ -0,0 +1,41 @@
created: 20181103150753927
creator: Thomas Elmiger
modified: 20181104091650389
modifier: Thomas Elmiger
tags:
title: $:/plugins/telmiger/support
!! Support the Author
''Hi!'' Im Thomas, the author of [[tid.li/tw5/plugins.html|https://tid.li/tw5/plugins.html]]. Feedback is always welcome, as well as funding for maintenance, support and new projects :)
---
!!! One Time Support
If using my plugins just makes you happy, consider a one time payment via ~PayPal to reward the effort:
https://www.paypal.me/telmiger
---
!!! Permanent Support
If my tools make you more productive or save you time in your job or your everyday life, you can support me as a Patron:
https://www.patreon.com/telmiger
---
!!! Thank You
Substantial parts of my availabe time go to the deveopment of useful plugins for [[TiddlyWiki|https://tiddlywiki.com/]]. Many others do the same and I would like to thank them all, especially [[Jeremy Ruston|https://tiddlywiki.com/#JeremyRuston]] and all the active members of the community!
//Hereby I promise to share future revenues (if any) with other developers whos works I use or who inspired me.//
If you like my work, I would be very happy to hear from you.
''Thank you very much for your support!''<br>
//Thomas//
https://thomas-elmiger.ch

View File

@ -0,0 +1,14 @@
{
"created": "20170205215504722",
"title": "$:/plugins/telmiger/details",
"author": "Thomas Elmiger",
"core-version": "5.1.13",
"description": "Disclosure HTML element",
"list": "readme license support",
"modified": "20220426222014097",
"name": "DetailsWidget",
"plugin-type": "plugin",
"source": "https://tid.li/tw5/plugins.html",
"version": "0.7.6",
"dependents": ""
}