mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Added docs for action-confirm widget, added default message for widget and improved logic for disabling it. (#5047)
This commit is contained in:
parent
fc1721709a
commit
d6e055368d
@ -10,6 +10,7 @@ ConfirmCancelTiddler: Do you wish to discard changes to the tiddler "<$text text
|
|||||||
ConfirmDeleteTiddler: Do you wish to delete the tiddler "<$text text=<<title>>/>"?
|
ConfirmDeleteTiddler: Do you wish to delete the tiddler "<$text text=<<title>>/>"?
|
||||||
ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<<title>>/>"?
|
ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<<title>>/>"?
|
||||||
ConfirmEditShadowTiddler: You are about to edit a ShadowTiddler. Any changes will override the default system making future upgrades non-trivial. Are you sure you want to edit "<$text text=<<title>>/>"?
|
ConfirmEditShadowTiddler: You are about to edit a ShadowTiddler. Any changes will override the default system making future upgrades non-trivial. Are you sure you want to edit "<$text text=<<title>>/>"?
|
||||||
|
ConfirmAction: Do you wish to proceed?
|
||||||
Count: count
|
Count: count
|
||||||
DefaultNewTiddlerTitle: New Tiddler
|
DefaultNewTiddlerTitle: New Tiddler
|
||||||
Diffs/CountMessage: <<diff-count>> differences
|
Diffs/CountMessage: <<diff-count>> differences
|
||||||
|
@ -36,8 +36,8 @@ ConfirmWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
Compute the internal state of the widget
|
Compute the internal state of the widget
|
||||||
*/
|
*/
|
||||||
ConfirmWidget.prototype.execute = function() {
|
ConfirmWidget.prototype.execute = function() {
|
||||||
this.message = this.getAttribute("$message");
|
this.message = this.getAttribute("$message",$tw.language.getString("ConfirmAction"));
|
||||||
this.prompt = (this.getAttribute("$prompt","yes") == "yes" ? true : false);
|
this.prompt = (this.getAttribute("$prompt","yes") == "no" ? false : true);
|
||||||
this.makeChildWidgets();
|
this.makeChildWidgets();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ Invoke the action associated with this widget
|
|||||||
ConfirmWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
ConfirmWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||||
var invokeActions = true,
|
var invokeActions = true,
|
||||||
handled = true;
|
handled = true;
|
||||||
if(this.message && this.prompt) {
|
if(this.prompt) {
|
||||||
invokeActions = confirm(this.message);
|
invokeActions = confirm(this.message);
|
||||||
}
|
}
|
||||||
if(invokeActions) {
|
if(invokeActions) {
|
||||||
|
40
editions/tw5.com/tiddlers/widgets/ActionConfirmWidget.tid
Normal file
40
editions/tw5.com/tiddlers/widgets/ActionConfirmWidget.tid
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
caption: action-confirm
|
||||||
|
created: 20201115150255011
|
||||||
|
modified: 20201115160335288
|
||||||
|
tags: Widgets ActionWidgets
|
||||||
|
title: ActionConfirmWidget
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
! Introduction
|
||||||
|
|
||||||
|
<<.from-version "5.1.23">>The ''action-confirm'' widget is an [[action widget|ActionWidgets]] that prompts the user for confirmation and invokes other action widgets contained within it only if the user confirms. ActionWidgets are used within triggering widgets such as the ButtonWidget.
|
||||||
|
|
||||||
|
! Content and Attributes
|
||||||
|
|
||||||
|
The ''action-confirm'' widget is invisible. Any content within it is only processed if the user confirms the action, or the confirmation has been disabled by the `$prompt` attribute.
|
||||||
|
|
||||||
|
|!Attribute |!Description |
|
||||||
|
|$message |Optional message displayed to the user when asking for confirmation.|
|
||||||
|
|$prompt |Optional flag, set to "no" to disable the prompt for confirmation. Defaults to "yes" |
|
||||||
|
|
||||||
|
! Examples
|
||||||
|
|
||||||
|
Here is an example of a button that asks the user for confirmation, before deleting the caption and tags fields of the current tiddler:
|
||||||
|
|
||||||
|
<$macrocall $name='wikitext-example-without-html'
|
||||||
|
src='<$button>
|
||||||
|
<$action-confirm $message="Do you wish to delete the caption and tags?">
|
||||||
|
<$action-deletefield caption tags/>
|
||||||
|
Delete "caption" and "tags"
|
||||||
|
</$action-confirm>
|
||||||
|
</$button>'/>
|
||||||
|
|
||||||
|
Here is an example of a button that uses the optional `$prompt` attribute to control whether to prompt the user before deleting the text field of the tiddler HelloThere:
|
||||||
|
|
||||||
|
<$macrocall $name='wikitext-example-without-html'
|
||||||
|
src='<$button>
|
||||||
|
<$action-confirm $message="Do you wish to delete the text field?" $prompt={{$:/state/promptUser}}>
|
||||||
|
<$action-deletefield $tiddler="HelloThere" $field="text"/>
|
||||||
|
</$action-confirm>
|
||||||
|
Delete text from ~HelloThere
|
||||||
|
</$button>'/>
|
Loading…
Reference in New Issue
Block a user