From 1808b1597e5a61379e4e5381d6d78bb73fa3a523 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 10 Mar 2015 12:44:47 +0000 Subject: [PATCH] Support custom HTML element tags for reveal widget --- core/modules/widgets/reveal.js | 7 ++++++- editions/tw5.com/tiddlers/widgets/RevealWidget.tid | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/reveal.js b/core/modules/widgets/reveal.js index 2afa1d9ee..84f0b22e8 100755 --- a/core/modules/widgets/reveal.js +++ b/core/modules/widgets/reveal.js @@ -30,7 +30,11 @@ RevealWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; this.computeAttributes(); this.execute(); - var domNode = this.document.createElement(this.parseTreeNode.isBlock ? "div" : "span"); + var tag = this.parseTreeNode.isBlock ? "div" : "span"; + if($tw.config.htmlUnsafeElements.indexOf(this.revealTag) === -1) { + tag = this.revealTag; + } + var domNode = this.document.createElement(tag); var classes = this["class"].split(" ") || []; classes.push("tc-reveal"); domNode.className = classes.join(" "); @@ -83,6 +87,7 @@ Compute the internal state of the widget RevealWidget.prototype.execute = function() { // Get our parameters this.state = this.getAttribute("state"); + this.revealTag = this.getAttribute("tag"); this.type = this.getAttribute("type"); this.text = this.getAttribute("text"); this.position = this.getAttribute("position"); diff --git a/editions/tw5.com/tiddlers/widgets/RevealWidget.tid b/editions/tw5.com/tiddlers/widgets/RevealWidget.tid index 3940e91a0..acc8898be 100644 --- a/editions/tw5.com/tiddlers/widgets/RevealWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/RevealWidget.tid @@ -1,5 +1,5 @@ created: 20131024141900000 -modified: 20140211232346858 +modified: 20150310124305795 tags: Widgets title: RevealWidget type: text/vnd.tiddlywiki @@ -19,6 +19,7 @@ The content of the `<$reveal>` widget is displayed according to the rules given |!Attribute |!Description | |state |The title of the tiddler containing the state | +|tag |Overrides the default HTML element tag (`
` in block mode or `` in inline mode) | |type |The type of matching performed: ''match'', ''nomatch'' or ''popup'' | |text |The text to match when the type is ''match'' and ''nomatch'' | |position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveright'', ''right'', ''belowleft'' or ''below'' |