<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<meta name="generator" content="Adobe GoLive 6" />
		<title>Workflow Extension</title>
	</head>

	<body>
		<hr />
		<p>ADOBE SYSTEMS INCORPORATED</p>
		<p>Copyright 2001 - 2002 Adobe Systems Incorporated<br />
			All Rights Reserved</p>
		<p>NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it. If you have received this file from a source other than Adobe, then your use, modification, or distribution of it requires the prior written permission of Adobe.</p>
		<hr />
		<p><b>Extension Name:</b> Workflow</p>
		<p><b>Folder name:</b> Workflow</p>
		<hr />
		<p><b>Description:</b></p>
		<p>Workflow extension</p>
		<hr />
		<p><b>Module Definition:</b></p>
		<jsxmodule info="$$$/info=This extension adds a custom workflow palette and two columns to the site window that allow the user to set percent complete and edited columns." name="Workflow" version="1.1" /> 
		<p><b>Scripts:</b></p>
		<script><!--
//--------------------------------------------------------------------
// FUNCTIONS
//--------------------------------------------------------------------

function enableControls ()
{
	var enable = website && website.getSelectedFiles().length() == 1;
	workflowNotes.popup.enabled		= enable;
	workflowNotes.editorName.enabled	= enable;
	if (!enable)
	{
		workflowNotes.editorName.value	= '';
		workflowNotes.popup.selection	= 0;
		workflowNotes.popup.refresh();
	}
}

//--------------------------------------------------------------------
// CALLBACK FUNCTIONS
//--------------------------------------------------------------------

function onSiteOpen (data)
{
	website.completedID	= website.insertColumn(module.localize("$$$/compcol=Completed"),2,60);
	website.insertPrefColumn(module.localize("$$$/toeditcol=To be edited by"),"nextEditor",3,80);
	enableControls();
}

function onSiteClose (data)
{
	workflowNotes.editorName.enabled	= false;
	workflowNotes.editorName.value	= '';
	workflowNotes.popup.enabled		= false;
	workflowNotes.popup.selection	= 0;
	workflowNotes.popup.refresh();
	workflowNotes.siteName.value = '';
	workflowNotes.fileName.value = '';
}

function onSiteSwitch (data)
{
	if (website)
  		workflowNotes.siteName.value = website.sitename;
  	else
  		workflowNotes.siteName.value = '';

	enableControls();
}

function onFileSelectionChange ()
{
   	if (website.getSelectedFiles().length() == 1)
   	{
   		var selRef	= website.getSelectedFiles().first();
   		var editor	= selRef.getNamedString("nextEditor");

		workflowNotes.fileName.value		= decodeURIComponent(selRef.name);
		workflowNotes.editorName.enabled	= true;
		workflowNotes.editorName.value	= editor != null ? editor : '';
		workflowNotes.popup.selection	= selRef.getNamedLong("Completed");
		workflowNotes.popup.enabled		= true;
	}
	else
	{
		workflowNotes.fileName.value	= '';
		workflowNotes.editorName.value	= '';
		workflowNotes.editorName.enabled	= false;
		workflowNotes.popup.selection	= 0;
		workflowNotes.popup.enabled		= false;
	}
	workflowNotes.popup.refresh();
}

function onSiteColumnContentCallback (colID, url, data)
{
	// Called from GoLive whenever an SDK column requests its content

	//	in	colID	(the ID of the column as used by GoLive, it is the 
	//				 column ID you'll receive from GoLive when you add an SDK column)
	//	in	url		(the URL of an site object)
	//	out	data	(the string data which should be drawn under the column)

	data.content = '';
	if (colID == website.completedID)
	{
		var percentValue = data.ref.getNamedLong("Completed");
		switch (percentValue)
		{
			case 0: 	data.content = " "; 	break;
			case 1: 	data.content = "0%"; 	break;
			case 2: 	data.content = "10%"; 	break;
			case 3: 	data.content = "20%"; 	break;
			case 4: 	data.content = "30%"; 	break;
			case 5: 	data.content = "40%"; 	break;
			case 6: 	data.content = "50%"; 	break;
			case 7: 	data.content = "60%"; 	break;
			case 8: 	data.content = "70%"; 	break;
			case 9: 	data.content = "80%"; 	break;
			case 10: 	data.content = "90%"; 	break;
			case 11:	data.content = "100%";	break;
		}
	}
}


function onSiteColumnCompareCallback (colID, url1, url2, result)
{
	// Called from GoLive whenever an SDK column need to compare two objects

	// Proper sorting requires one of the return values:
	//	-1 (obj1 smaller obj2);
	//	 0 (obj1 equals	 obj2);
	//	+1 (obj1 greater obj2) 
	
	var percentValue1 = result.ref.getNamedLong("Completed");
	var percentValue2 = result.compareRef.getNamedLong("Completed");
	
	if (percentValue1 < percentValue2)
		result.compare = -1;
	else
		if (percentValue1 > percentValue2)
			result.compare = 1;
		else
			result.compare = 0;

}

function initializeModule()
{
	registerCallback ("onWebsiteOpen",				"onSiteOpen"					);
}

function startModule()
{
	enableControls();

    registerCallback ("onWebsiteSwitch",			"onSiteSwitch"					);
	registerCallback ("onFileSelectionChange",		"onFileSelectionChange"			);
	registerCallback ("onWebsiteClose",				"onSiteClose"					);

    registerCallback ("onFilesTabContentCallback",	"onSiteColumnContentCallback"	);
    registerCallback ("onFilesTabCompareCallback",	"onSiteColumnCompareCallback"	);

	var folder	= module.folder;
	var url		= module.folder.url;

}

//---------------------------------------------------------
// controlSignal -  called when the state of a control has changed
//
// Description:
//   Use to extract the state of the control, and react to the state
//   change.
//

function controlSignal(control) 
{
	// If there is a website and there is only one file/folder selected.
	if (website && website.getSelectedFiles().length() == 1)
	{
		// Determine which control changed and set the website property
		switch (control.name)
		{
			case "popup":
				website.getSelectedFiles().first().setNamedLong("Completed",workflowNotes.popup.selection);
				break;
				
			case "editorName":
				website.getSelectedFiles().first().setNamedString("nextEditor",workflowNotes.editorName.value);
				break;
		}
	}
}

//
//-->
</script>
		<p><b>Palette</b></p>
		<jsxpalette height="120" name="workflowNotes" order="8050" title="$$$/title=Workflow" menu="0153" width="220" minwidth="220" minheight="115">
			<table width="200" border="0" cellspacing="0" cellpadding="0" cool="cool" gridx="10" gridy="10" height="120" showgridx="showgridx" showgridy="showgridy">
				<tr height="15">
					<td rowspan="5" width="10" height="119"></td>
					<td colspan="3" width="189" height="15"></td>
					<td width="1" height="15"><spacer height="15" type="block" width="1" /></td>
				</tr>
				<tr height="23">
					<td align="left" valign="top" width="90" height="23" xpos="10">
						<jsxcontrol height="15" name="static1" posx="10" posy="15" type="static" value="$$$/static1=Active Site:" width="80"></jsxcontrol>
					</td>
					<td colspan="2" align="left" valign="top" width="99" height="23" xpos="100">
						<jsxcontrol halign="scale" height="15" name="siteName" posx="105" posy="15" type="static" value="" width="83"></jsxcontrol>
					</td>
					<td width="1" height="23"><spacer height="23" type="block" width="1" /></td>
				</tr>
				<tr height="25">
					<td align="left" valign="top" width="90" height="25" xpos="10">
						<jsxcontrol height="15" name="static2" posx="10" posy="38" type="static" value="$$$/static2=Name:" width="80"></jsxcontrol>
					</td>
					<td colspan="2" align="left" valign="top" width="99" height="25" xpos="100">
						<jsxcontrol halign="scale" height="15" name="fileName" posx="105" posy="38" type="static" value="" width="83"></jsxcontrol>
					</td>
					<td width="1" height="25"><spacer height="25" type="block" width="1" /></td>
				</tr>
				<tr height="29">
					<td align="left" valign="top" width="90" height="29" xpos="10">
						<jsxcontrol height="15" name="static3" posx="10" posy="63" type="static" value="$$$/static3=To be edited by:" width="80"></jsxcontrol>
					</td>
					<td colspan="2" align="left" valign="top" width="99" height="29" xpos="100">
						<jsxcontrol halign="scale" height="19" name="editorName" onEnter="onEnter" posx="105" posy="63" type="edit" value="" width="83"></jsxcontrol>
					</td>
					<td width="1" height="29"><spacer height="29" type="block" width="1" /></td>
				</tr>
				<tr height="27">
					<td align="left" valign="top" width="90" height="27" xpos="10">
						<jsxcontrol height="15" name="static4" posx="10" posy="92" type="static" value="$$$/static4=Completed:" width="80"></jsxcontrol>
					</td>
					<td align="left" valign="top" width="62" height="27" xpos="100">
						<jsxcontrol halign="scale" height="19" name="popup" posx="105" posy="92" type="popup" value=" ,0,10,20,30,40,50,60,70,80,90,100" width="50"></jsxcontrol>
					</td>
					<td align="left" valign="top" width="37" height="27" xpos="162">
						<jsxcontrol halign="right" height="15" name="static5" posx="167" posy="92" type="static" value="%" width="18"></jsxcontrol>
					</td>
					<td width="1" height="27"><spacer height="27" type="block" width="1" /></td>
				</tr>
				<tr cntrlrow="cntrlrow" height="1">
					<td width="10" height="1"><spacer height="1" type="block" width="10" /></td>
					<td width="90" height="1"><spacer height="1" type="block" width="90" /></td>
					<td width="62" height="1"><spacer height="1" type="block" width="62" /></td>
					<td width="37" height="1"><spacer height="1" type="block" width="37" /></td>
					<td width="1" height="1"></td>
				</tr>
			</table>
			<jsxlayoutline direction="false" x="95" y="10" length="100" />
		</jsxpalette>
	</body>

</html>