1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Add tooltip attribute to select widget

This commit is contained in:
Jermolene 2019-03-04 12:24:16 +00:00
parent 0b1ce30a04
commit 477c41f843
2 changed files with 8 additions and 3 deletions

View File

@ -145,6 +145,7 @@ SelectWidget.prototype.execute = function() {
this.selectDefault = this.getAttribute("default");
this.selectMultiple = this.getAttribute("multiple", false);
this.selectSize = this.getAttribute("size");
this.selectTooltip = this.getAttribute("tooltip");
// Make the child widgets
var selectNode = {
type: "element",
@ -160,6 +161,9 @@ SelectWidget.prototype.execute = function() {
if(this.selectSize) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"size",this.selectSize);
}
if(this.selectTooltip) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"title",this.selectTooltip);
}
this.makeChildWidgets([selectNode]);
};
@ -169,7 +173,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
SelectWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
// If we're using a different tiddler/field/index then completely refresh ourselves
if(changedAttributes.selectTitle || changedAttributes.selectField || changedAttributes.selectIndex) {
if(changedAttributes.selectTitle || changedAttributes.selectField || changedAttributes.selectIndex || changedAttributes.selectTooltip) {
this.refreshSelf();
return true;
// If the target tiddler value has changed, just update setting and refresh the children

View File

@ -1,6 +1,6 @@
caption: select
created: 20131024141900000
modified: 20160429175220241
modified: 20190304122040876
tags: Widgets
title: SelectWidget
type: text/vnd.tiddlywiki
@ -35,6 +35,7 @@ The content of the `<$select>` widget should be one or more HTML `<option>` or `
|field |The field name for the value in the current tiddler (defaults to "text") |
|index |The index of a property in a [[DataTiddler|DataTiddlers]] (takes precedence over the field attribute) |
|class |CSS classes to be assigned to the HTML select element |
|tooltip |Optional tooltip |
|default |Default value to be used if the tiddler, field or index specifies a missing value |
|multiple |If present, switches to multiple selection mode |
|size |The number of rows to display in multiple selection mode |
@ -46,7 +47,7 @@ The content of the `<$select>` widget should be one or more HTML `<option>` or `
This example sets the title of the current wiki [[$:/SiteTitle]] to one of a list of book titles:
<$macrocall $name="wikitext-example-without-html" src="<$select tiddler='$:/SiteTitle'>
<$macrocall $name="wikitext-example-without-html" src="<$select tiddler='$:/SiteTitle' tooltip='Choose a new site title'>
<option>A Tale of Two Cities</option>
<option>A New Kind of Science</option>
<option>The Dice Man</option>