1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add action-deletetiddler widget

This commit is contained in:
Jermolene 2014-11-06 18:23:48 +00:00
parent 741f853986
commit 0a2a5184c4
3 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,65 @@
/*\
title: $:/core/modules/widgets/action-deletetiddler.js
type: application/javascript
module-type: widget
Action widget to delete a tiddler.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var DeleteTiddlerWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
DeleteTiddlerWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
DeleteTiddlerWidget.prototype.render = function(parent,nextSibling) {
this.computeAttributes();
this.execute();
};
/*
Compute the internal state of the widget
*/
DeleteTiddlerWidget.prototype.execute = function() {
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
this.actionConfirm = this.getAttribute("$confirm");
};
/*
Refresh the widget by ensuring our attributes are up to date
*/
DeleteTiddlerWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["$tiddler"] || changedAttributes["$confirm"]) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};
/*
Invoke the action associated with this widget
*/
DeleteTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue);
return true; // Action was invoked
};
exports["action-deletetiddler"] = DeleteTiddlerWidget;
})();

View File

@ -0,0 +1,33 @@
caption: action-deletetiddler
created: 20141025120850184
modified: 20141106173455527
tags: Widgets ActionWidgets
title: ActionDeleteTiddlerWidget
type: text/vnd.tiddlywiki
! Introduction
The ''action-deletetiddler'' widget is an [[action widget|ActionWidgets]] that deletes a tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget.
There are several differences compared to the [[WidgetMessage: tm-delete-tiddler]]:
* The user is not prompted to confirm the deletion
* No automatic updating of the story list
* No special handling of draft tiddlers
! Content and Attributes
The ''action-deletetiddler'' widget is invisible. Any content within it is ignored.
|!Attribute |!Description |
|$tiddler |The title of the tiddler to be deleted (if not provided defaults to the [[WidgetVariable: currentTiddler]] |
! Examples
Here is an example of a button that deletes the tiddler HelloThere. Note:
<$macrocall $name='wikitext-example-without-html'
src='<$button>
<$action-deletetiddler $tiddler="HelloThere"/>
Go to Control Panel "Appearance" tab
</$button>'/>

View File

@ -21,7 +21,7 @@ type: text/vnd.tiddlywiki
!! Hackability Improvements
* Introduced new ActionSetFieldWidget, ActionSetFieldsWidget and ActionDeleteFieldWidget for manipulating tiddler fields
* Introduced new ActionSetFieldWidget, ActionSetFieldsWidget, ActionDeleteFieldWidget and ActionDeleteTiddlerWidget for manipulating tiddler fields and values
* [[Enhanced|https://github.com/Jermolene/TiddlyWiki5/commit/4a172125768e3b33c30e725e8550454a9d26c5c4]] the EditTextWidget to allow more control over the sizing of textarea editors
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/13726ef73157d9e9d65ae4027d9c32aaa7cdcc90]] new canned filter for recently modified system tiddlers in [[$:/AdvancedSearch]]
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/c20c935faabbb63f679bc4720b52162c56b6af64]] new system image for videos: [[$:/core/images/video]]