User:neilw > Popup extension

Popup extension

Installation

Follow these steps to install this script on your wiki.

  1. Go to System Settings inside the Control Panel.
  2. Under Extensions, click Add Script.
  3. Enter a descriptive name for the extension
  4. Under Configuration add the following to the Manifest field: http://wiki.developer.mindtouch.com/@api/deki/files/3100/=popup.xml
  5. Add extra configuration values as listed below under Configuration (If Configuration is not listed below, ignore this step.)
  6. Click on add script.

Related Links: DekiScript service, Extension Overview, DekiScript Overview, Extension Demos.


Overview

Produces various popup windows from within the wiki This script requires MindTouch Deki 1.8.3 or later.

Functions:

  1. popup.div
  2. popup.list

popup.div(divID, label, height, width) : xml

Generate popup window from div embedded on wiki page

Parameters:

NameTypeDescription
divIDstrName of div to put in popup
labelstrLink text
heightnum(optional) Height of popup window (default=300)
widthnum(optional) Width of popup window (default=200)


popup.list(header, valueList, label, height, width) : xml

Generate popup window with list passed to extension

Parameters:

NameTypeDescription
headerstrtext to put before the list of values
valueListlistlist of stuff to put in popup
labelstrLink text
heightnum(optional) Height of popup window (default=300)
widthnum(optional) Width of popup window (default=200)


Source Code

<extension>
<title>Popup</title>
<description>Produces various popup windows from within the wiki</description>
<namespace>popup</namespace>
<function>
	<name>div</name>
	<description>Generate popup window from div embedded on wiki page</description>
	<param name="divID" type="str">Name of div to put in popup</param>
	<param name="label" type="str">Link text</param>
	<param name="height" type="num" optional="true">Height of popup window (default=300)</param>
	<param name="width"  type="num" optional="true">Width of popup window (default=200)</param>
	<return>
	<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
		<head>
			<script type="text/javascript">
				function doPopup_<eval:expr>@id</eval:expr>() {
					var h = <eval:js>args.height ?? 300</eval:js>;
					var w = <eval:js>args.width  ?? 200</eval:js>;
					var popwin = window.open("","deki_popup","scrollbars=1,height="+h+",width="+w);
					popwin.document.write(document.getElementById(<eval:js>args.divID</eval:js>).innerHTML);
					popwin.document.close();
					popwin.focus();
					return false;
				 }
			</script>
		</head>
		<body>
			<a href="#" eval:onClick="'return doPopup_'..@id..'();'" class="internal">
				<eval:expr>args.label</eval:expr></a>
		</body>
		<tail>
			<script type="text/javascript">
				document.getElementById(<eval:js>args.divID</eval:js>).style.display = "none";
			</script>
		</tail>
	</html>
	</return>
</function>
<function>
	<name>list</name>
	<description>Generate popup window with list passed to extension</description>
	<param name="header" type="str">text to put before the list of values</param>
	<param name="valueList" type="list">list of stuff to put in popup</param>
	<param name="label" type="str">Link text</param>
	<param name="height" type="num" optional="true">Height of popup window (default=300)</param>
	<param name="width"  type="num" optional="true">Width of popup window (default=200)</param>
	<return>
	<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
		<head>
			<script type="text/javascript">
				function doPopup_<eval:expr>@id</eval:expr>() {
					var h = <eval:js>args.height ?? 300</eval:js>;
					var w = <eval:js>args.width  ?? 200</eval:js>;
					var popwin = window.open("","deki_popup","scrollbars=1,height="+h+",width="+w);
					popwin.document.write(<eval:js>(args.header ?? "") .. "&lt;ul&gt;"</eval:js>);
					<eval:foreach var="text" in="args.valueList">
						popwin.document.write(<eval:js>"&lt;li&gt;"..text.."&lt;/li&gt;"</eval:js>);
					</eval:foreach>
					popwin.document.write("&lt;/ul&gt;");
					popwin.document.close();
					popwin.focus();
					return false;
				 }
			</script>
		</head>
		<body>
			<a href="#" eval:onClick="'return doPopup_'..@id..'();'" class="internal">
				<eval:expr>args.label</eval:expr></a>
		</body>
		<tail>
		</tail>
	</html>
	</return>
</function>
</extension>

Samples

To pop up a simple list:

{{ popup.list("This is a list:", ["1", "2", "three"], "click to pop!", 200,200) }}

  

To pop up a list of first 20 users on this wiki:

{{ popup.list("Users:", web.list(uri.build(site.api,"users",{ limit:20 })), "show users!", 200, 500) }}

  

To show the list of functions in this extension:

{{ popup.list("Functions in 'Popup' extension:", web.list("http://wiki.developer.mindtouch.com/@api/deki/files/3100/=popup.xml","/extension/function/name"), "show functions!", 100, 300) }}
Tag page

Files 1

FileSizeDateAttached by 
 popup.xml
No description
2.8 kB20:48, 8 Aug 2008neilwActions
You must login to post a comment.
Powered by MindTouch Deki v.8.08.2