mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 22:16:43 +00:00
Adds a javascript widget tutorial to the dev tiddlywiki edition (#7016)
* Initial widget tutorials extracted from https://btheado.github.io/tw-widget-tutorial/ * Fixes for refresh behavior change
This commit is contained in:
35
editions/dev/tiddlers/javascript-widget-tutorial/hello.js
Normal file
35
editions/dev/tiddlers/javascript-widget-tutorial/hello.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/*\
|
||||
|
||||
Hello, World widget
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
|
||||
var MyWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
};
|
||||
|
||||
/*
|
||||
Inherit from the base widget class
|
||||
*/
|
||||
MyWidget.prototype = new Widget();
|
||||
|
||||
/*
|
||||
Render this widget into the DOM
|
||||
*/
|
||||
MyWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.parentDomNode = parent;
|
||||
var textNode = this.document.createTextNode("Hello, World!");
|
||||
parent.insertBefore(textNode,nextSibling);
|
||||
this.domNodes.push(textNode);
|
||||
};
|
||||
|
||||
exports.hello = MyWidget;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user