mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Replace obsolete hide macro with reveal macro
This commit is contained in:
parent
80fd563ccc
commit
73071f18ae
@ -1,48 +0,0 @@
|
||||
/*\
|
||||
title: $:/core/modules/macros/hide.js
|
||||
type: application/javascript
|
||||
module-type: macro
|
||||
|
||||
A macro that selectively hides its children
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.info = {
|
||||
name: "hide",
|
||||
params: {
|
||||
tiddler: {byName: "default", type: "tiddler"},
|
||||
notequal: {byName: true, type: "text"}
|
||||
}
|
||||
};
|
||||
|
||||
exports.executeMacro = function() {
|
||||
var attributes = {}, children, text, show = false;
|
||||
if(this.classes) {
|
||||
attributes["class"] = this.classes.slice(0);
|
||||
}
|
||||
if(this.hasParameter("tiddler")) {
|
||||
text = this.wiki.getTextReference(this.params.tiddler);
|
||||
if(this.hasParameter("notequal")) {
|
||||
if(text === this.params.notequal) {
|
||||
show = true;
|
||||
}
|
||||
}
|
||||
if(show) {
|
||||
children = this.content;
|
||||
for(var t=0; t<children.length; t++) {
|
||||
children[t].execute(this.parents,this.tiddlerTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tw.Tree.Element(this.isBlock ? "div" : "span",attributes,children,{
|
||||
events: ["tw-navigate"],
|
||||
eventHandler: this
|
||||
});
|
||||
};
|
||||
|
||||
})();
|
@ -5,6 +5,18 @@ module-type: macro
|
||||
|
||||
The reveal macro shows or hides content according to the value of the text in a specified tiddler.
|
||||
|
||||
The parameters are:
|
||||
|
||||
* ''state'' - text reference where the hide/reveal state is stored
|
||||
* ''type'' - type of the hide/reveal state:
|
||||
** //popup// - a popup - the state tiddler should contain the page coordinates of the button that triggered the popup
|
||||
** //match// - reveals if the state tiddler matches the match text
|
||||
* ''position'' - popup position: //left//, //above//, //right//, //below// or //belowleft//
|
||||
* ''text'' - match text
|
||||
* ''qualifyTiddlerTitles'' - if present, causes the title of the state tiddler to be qualified with the current tiddler stack
|
||||
* ''default'' - default hide/reveal state: `open` if visible, otherwise hidden
|
||||
* ''class'' - CSS class(es) to be assigned to the
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
@ -17,6 +29,7 @@ exports.info = {
|
||||
params: {
|
||||
state: {byPos: 0, type: "tiddler"},
|
||||
type: {byName: true, type: "text"},
|
||||
text: {byName: true, type: "text"},
|
||||
position: {byName: true, type: "text"},
|
||||
qualifyTiddlerTitles: {byName: true, type: "text"},
|
||||
"default": {byName: true, type: "text"},
|
||||
@ -36,10 +49,17 @@ exports.readState = function() {
|
||||
case "popup":
|
||||
this.readPopupState(state);
|
||||
break;
|
||||
case "match":
|
||||
this.readMatchState(state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.readMatchState = function(state) {
|
||||
this.isOpen = state === this.params.text;
|
||||
};
|
||||
|
||||
exports.readPopupState = function(state) {
|
||||
var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/,
|
||||
match = popupLocationRegExp.exec(state);
|
||||
@ -61,7 +81,7 @@ exports.readPopupState = function(state) {
|
||||
};
|
||||
|
||||
exports.handleEvent = function(event) {
|
||||
if(event.type === "click") {
|
||||
if(event.type === "click" && this.params.type === "popup") {
|
||||
// Cancel the popup if we get a click on it
|
||||
if(this.stateTextRef) {
|
||||
this.wiki.deleteTextReference(this.stateTextRef);
|
||||
@ -95,7 +115,7 @@ exports.executeMacro = function() {
|
||||
break;
|
||||
}
|
||||
attributes.style = {display: this.isOpen ? "block" : "none"};
|
||||
var child = $tw.Tree.Element("div",attributes,this.isOpen ? this.content : [],{
|
||||
var child = $tw.Tree.Element(this.isBlock ? "div" : "span",attributes,this.isOpen ? this.content : [],{
|
||||
events: ["click"],
|
||||
eventHandler: this
|
||||
});
|
||||
|
@ -31,9 +31,9 @@ title: $:/templates/PageTemplate
|
||||
<<reveal state:ViewDropDownState type:popup position:below><
|
||||
<div class="open">
|
||||
{{dropdown-menu tw-suppress-missing-tiddlylink{
|
||||
* <<link to:classic>< <<hide tiddler:[[$:/CurrentView]] notequal:classic>< <span class="tw-ticked-menu-item"></span> >> Classic>>
|
||||
* <<link to:sideways>< <<hide tiddler:[[$:/CurrentView]] notequal:sideways>< <span class="tw-ticked-menu-item"></span> >> Sideways>>
|
||||
* <<link to:zoomin>< <<hide tiddler:[[$:/CurrentView]] notequal:zoomin>< <span class="tw-ticked-menu-item"></span> >> Zoomin>>
|
||||
* <<link to:classic>< <<reveal state:[[$:/CurrentView]] type:match text:classic>< <span class="tw-ticked-menu-item"></span> >> Classic>>
|
||||
* <<link to:sideways>< <<reveal state:[[$:/CurrentView]] type:match text:sideways>< <span class="tw-ticked-menu-item"></span> >> Sideways>>
|
||||
* <<link to:zoomin>< <<reveal state:[[$:/CurrentView]] type:match text:zoomin>< <span class="tw-ticked-menu-item"></span> >> Zoomin>>
|
||||
}}}
|
||||
</div>
|
||||
>>
|
||||
|
@ -14,7 +14,7 @@ TiddlyWiki5 has many [[improvements|Improvements]] over the original. It is curr
|
||||
* Join the discussions on [[the TiddlyWikiDev Google Group|http://groups.google.com/group/TiddlyWikiDev]]
|
||||
* Follow [[@TiddlyWiki on Twitter|http://twitter.com/#!/TiddlyWiki]] for the latest news
|
||||
|
||||
<<hide tiddler:[[$:/CurrentView]] notequal:zoomin><
|
||||
<<reveal state:[[$:/CurrentView]] type:match text:zoomin><
|
||||
<<tiddler target:Introduction>>
|
||||
|
||||
>>
|
||||
|
Loading…
Reference in New Issue
Block a user