Thursday, May 30, 2013

SharePoint 2010 - Add Popup In SharePoint 2010

Create a new element and copy the following script into your element.xml file.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction ScriptSrc="~site/Scripts/main.js" Location="ScriptLink" Sequence="100">
</CustomAction>
<CustomAction
 Id="CreateDS"
 RegistrationType="ContentType"
 RegistrationId="0x0101"
 Location="EditControlBlock"
 Title="Create Data Set - Beta V 1.0"
 ImageUrl="/_layouts/images/FOLDER16.GIF"
 Sequence="0"
 Rights ="EditListItems">
<UrlAction Url="javascript:showDSWindow();
var statusId;
function notifyMe(msg)
{
var statusId = SP.UI.Status.addStatus(msg);         
visibleStatusIds.push(statusId); 
enableRemoveStatusButton(); 
RefreshCommandUI();
}
 
function RemoveStatus() {
SP.UI.Status.removeStatus(this.statusId);
}
function demoCallback(dialogResult, returnValue)
{    
 /*alert(returnValue);
 this.statusId = SP.UI.Status.addStatus('DataSet Created','New Data Set Created.',true);
 SP.UI.Status.setStatusPriColor(this.statusId, 'Green');
 setTimeout(RemoveStatus, 1000);*/
 SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

function CreateDSWindow()
{
var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var myItems = '';
var k;
var enable = true;
if (items.length=='0'){alert('You must select at least one document to continue.');return;}
for (k in items)
{
myItems += '|' + items[k].id;
if (items[k].fsObjType != 0)
enable = false;
}
if (!enable) {alert(' The files will NOT be moved to new Document Set, unselect the DataSet/Folder ...');return;}
var options = {              
url: '{SiteUrl}/_layouts/CreateDocumentSet/ChooseDS.aspx?ListId={ListId}&amp;items=' + myItems + '&amp;source=' + SP.ListOperation.Selection.getSelectedList(),
tite: 'Move Documents - Stellar Demo V 1.0',
allowMaximize: false,
showClose: true,
width: 500,
height: 380,
dialogReturnValueCallback: demoCallback };
SP.UI.ModalDialog.showModalDialog(options);}

function showDSWindow()
{
CreateDSWindow();
}   
" />
</CustomAction>
</Elements>

2. Create an ASPX file called ChooseDS.aspx

No comments:

Post a Comment