SharePoint ECB Customization-Add menu to 'sendto'

Source: Internet
Author: User
In DIN
In the Project, we have the following requirement: add the Menu we specified in the default SendTo sub Menu of the DIN Library ECB. note: 1. join Location 2. add only to DIN Library. idea: Find _ layouts/1033/Core. the AddSendSubMenu method under js, through the Delegate
The Override Core. js method in Control to meet our needs. Solution:1. Create a Delegate
Control, deploy delegate control through feature. 2. ovrride Core. js in delegate control
AddSendSubMenu. The key code is as follows (note ..):
$ (Function () {var spAddSendSubMenu =
AddSendSubMenu; AddSendSubMenu =
Function (m, ctx) {// use the listTemplate of ctx
Attribute to determine whether it is DIN Library. // If yes, Copy
In core. js, modify the AddSendSubMenu function and add our requirements. // If not, execute Core. js
Default AddSendSubMenu if
(Ctx. listTemplate = '20140901 '){
StrDisplayText =
Rochelle send_text;
Var currentItemUrl =
GetAttributeFromItemTable (itemTable, "Url", "ServerUrl ");
Var
CurrentItemEscapedFileUrl;
Var
CurrentItenUnescapedUrl;
Var strExtension;

If (currentItemFileUrl! = Null ){
CurrentItenUnescapedUrl
= UnescapeProperly (currentItemFileUrl );

CurrentItemEscapedFileUrl =
EscapeProperly (currentItenUnescapedUrl );
StrExtension =
SzExtension (currentItenUnescapedUrl );
If (strExtension! =
Null & strExtension! = "")
StrExtension =
StrExtension. toLowerCase ();
}
Var sm =
CASubM (m, strDisplayText, "", "", 400 );
Sm. id =
"ID_Send ";
Var menuOption;
Var
ServerFileRedirect = itemTable. getAttribute ("SRed ");
If
(CurrentItemProgId! = "SharePoint. WebPartPage. Document"
&&
(ServerFileRedirect = null | serverFileRedirect = "" |
HasRights (0x0, 0x20) & strExtension! = "Aspx ")
{
If (typeof (ctx. SendToLocationName )! = "Undefined"
&&
Ctx. SendToLocationName! = Null
&&
Ctx. SendToLocationName! = ""&&
Typeof
(Ctx. SendToLocationUrl )! = "Undefined "&&
Ctx. SendToLocationUrl! =
Null &&
Ctx. SendToLocationUrl! = ""){

StrAction = "STSNavigate ('" + ctx. HttpRoot + "/_ layouts/copy. aspx? "+
"SourceUrl =" + currentItemEscapedFileUrl + "& Source =" + GetSource () +
"& FldUrl =" + escapeProperly (ctx. SendToLocationUrl) +
"')";
MenuOption =
CAMOpt (sm,
Ctx. SendToLocationName,
StrAction,
"");

}
If (typeof (itemTable. getAttribute ("HCD "))! =
"Undefined" & itemTable. getAttribute ("HCD") = "1 ")
{
StrDisplayText =
Rochelle existingcopies_text;
StrAction = "STSNavigate ('" +
Ctx. HttpRoot + "/_ layouts/updatecopies. aspx? "+" SourceUrl = "+
CurrentItemEscapedFileUrl + "& Source =" + GetSource () +
"')";
StrImagePath = ctx. imagesPath +
"ExistingLocations.gif ";
MenuOption = CAMOpt (sm,
StrDisplayText, strAction, strImagePath );

MenuOption. id = "ID_ExistingCopies ";

}
StrDisplayText =
Rochelle otherlocation_text;
StrAction = "STSNavigate ('" +
Ctx. HttpRoot + "/_ layouts/copy. aspx? "+" SourceUrl = "+ currentItemEscapedFileUrl
+ "& Source =" + GetSource () + "')";
StrImagePath =
Ctx. imagesPath + "sendOtherLoc.gif ";
MenuOption =
CAMOpt (sm, strDisplayText, strAction, strImagePath );

MenuOption. id = "ID_OtherLocation ";
If
(Ctx. OfficialFileName! = Null & ctx. OfficialFileName! = "")
{
StrDisplayText =
Ctx. OfficialFileName;
StrAction = "STSNavigate ('" +
Ctx. HttpRoot + "/_ layouts/SendToOfficialFile. aspx? "+" SourceUrl = "+
CurrentItemEscapedFileUrl + "& Source =" + GetSource () +
"')";
StrImagePath = "";

CAMOpt (sm, strDisplayText, strAction, strImagePath );

}
CAMSep (sm );
}
If
(HasRights (0x10, 0x0 )){
StrDisplayText =
Rochelle sendtoemail_text;
Var currentItemUrl =
GetAttributeFromItemTable (itemTable, "Url", "ServerUrl ");

Var httpRootWithSlash = ctx. HttpRoot. substr (0 );
If
(HttpRootWithSlash [httpRootWithSlash. length-1]! =
'/')
HttpRootWithSlash + = '/';

Var slashLoc =-1;
Var fileUrl =
"";
SlashLoc =
HttpRootWithSlash. substring (8). indexOf ('/') + 8;
FileUrl
= HttpRootWithSlash. substr (0, slashLoc) +
EscapeProperlyCore (unescapeProperly (currentItemUrl ),
True );
Var serverFileRedir =
ItemTable. getAttribute ("SRed ");
If (serverFileRedir! =
Null )&&
(ServerFileRedir! = "")&&
(ServerFileRedir
! = "1 ")){
If (serverFileRedir. substring (0, 1 )! =
"1 "){
FileUrl =
ServerFileRedir;
}
Else
{
FileUrl =
ServerFileRedir. substring (1 );

}
}
StrAction =
"Javascript: navigateMailToLinkNew ('" + fileUrl + "')";

StrImagePath = ctx. imagesPath + "gmailnew.gif ";

MenuOption = CAMOpt (sm, strDisplayText, strAction,
StrImagePath );
MenuOption. id =
"ID_SendToEmail ";
} // Add our DIN here
Logic: determines whether the current Document is a Main document through web Service.

// Customize
$ (). SPServices ({

Operation: "GetListItems ",
Async:
False,
ListName: ctx. listName,

CAMLViewFields: "<ViewFields> </ViewFields> ",

CAMLQuery: "<Query> <Where> <Eq> <FieldRef Name = 'id'
/> <Value Type = 'integer'> "+ currentItemID +
"</Value> </Eq> </Where> </Query> ",

Completefunc: function (xData, Status ){

$ (XData. responseXML). find ("[nodeName = z: row]"). each (function ()
{
// Main document

If ($ (this). attr ("ows _ DINMainDocument") = "1 ")
{
CAMOpt (sm, "Download DIN Document ",
"Window. location. href = 'HTTP: // icon-vpc-wss/DIN % 20 Document % 20 Template % 20 Gallery/function%20specification%20for%20qa%20alert%20system% ';",
"/_ Layouts/icondin/images/icon-dinn-dindoc.gif ");

}
CAMOpt (sm, "Download Entire Bundle", "alert ('"
+ CurrentItemID + "');",
"/_ Layouts/icondin/images/icon-dinn-bundle.gif ");

});
}
});
// End
Customize
Var serverFileRedirect =
ItemTable. getAttribute ("SRed ");
If (currentItemFSObjType! = 1
&&
Ctx. listBaseType = 1 &&
(ServerFileRedirect =
Null | serverFileRedirect = ""
| HasRights (0x0, 0x20 )))
{

StrAction = "STSNavigate ('" +
Ctx. HttpRoot + "/_ layouts/download. aspx? "+" SourceUrl = "+
CurrentItemEscapedFileUrl + "& Source =" + GetSource () + "& FldUrl =" +
EscapeProperly (ctx. SendToLocationUrl) + "')";;

MenuOption = CAMOpt (sm, L_DownloadACopy_Text, strAction,
"");
MenuOption. id =
"ID_DownloadACopy ";
If (ctx. listTemplate! = 109
&&
Ctx. listTemplate! = 119)

AddWorkspaceMenuItem (sm, ctx );
}

}
Else {
SpAddSendSubMenu (m,
Ctx );
}
}
});

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.