/*** |''Name''|TiddlerPopupPlugin| |''Description''|Allows you to create links to tiddlers causing them to open in a popup| |''Author''|Jon Robson| |''Version''|0.5.3| |''Status''|@@beta@@| |''Source''|http://svn.tiddlywiki.org/Trunk/contributors/JonRobson/plugins/TiddlerPopup/TiddlerPopupPlugin.js| |''License''|[[BSD|http://www.opensource.org/licenses/bsd-license.php]]| !Usage {{{<<TiddlerPopUp GettingStarted popup>>}}} creates a button with text popup which when clicked loads the GettingStarted tiddler. !Code ***/ //{{{ (function($){ config.macros.TiddlerPopUp = { handler: function(place,macroName,params,wikifier,paramString,tiddler){ var args = paramString.parseParams("anon")[0]; params = args.anon; var title = args.title ? args.title[0] : params[0]; var label = args.label ? args.label[0] : params[1] || "popup"; var autoposition = args.autoposition && args.autoposition[0] == "no" ? false : true; var classNames = args.className || []; $("<a class='button popupLink' />").text(label). click(function(ev) { var target = ev.target; var active = $(target).data("popupActive"); if(!active) { var popup = Popup.create(target); $(target).data("popupActive", true); $(popup).addClass(classNames.join(" ")); var text = store.getTiddlerText(title) || config.shadowTiddlers[title]; wikify(text, popup); Popup.show(); if(!autoposition) { $(popup).css({ left: "auto", top: "auto" }); } $(popup).click(function(ev) { // make it so only clicking on the document outside the popup removes the popup if(ev.target.parentNode != document) { ev.stopPropagation(); } }); ev.stopPropagation(); } else { Popup.remove(); $(target).data("popupActive", false); } return false; }).appendTo(place); } }; })(jQuery); //}}}