Monday, January 14, 2019

Custom Callout


_spBodyOnLoadFunctionNames.push('_executeCallout');

function _executeCallout()

ExecuteOrDelayUntilScriptLoaded(executeCallout, 'callout.js');
}

function executeCallout()
{
        SP.SOD.executeFunc("callout.js", "Callout", function () {
            var itemCtx = {};
            itemCtx.Templates = {};
            itemCtx.BaseViewID = 'Callout';
            itemCtx.ListTemplateType = 101;
            itemCtx.Templates.Footer = function (itemCtx) {
                return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
            };
            SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
        });
}

        function AddCustomAction(renderCtx, calloutActionMenu) {
            CalloutOnPostRenderTemplate(renderCtx, calloutActionMenu);
           
            calloutActionMenu.addAction(new CalloutAction({
                text: Strings.STS.L_CalloutFollowAction,
                tooltip: Strings.STS.L_CalloutFollowAction_Tooltip,
                onClickCallback: function (calloutActionClickEvent, calloutAction) {
                    var callout = GetCalloutFromRenderCtx(renderCtx);
                    if (!(typeof (callout) === 'undefined' || callout === null))
                        callout.close();
                    SP.SOD.executeFunc('followingcommon.js', 'FollowSelectedDocument', function () { FollowSelectedDocument(renderCtx); });
                }
            }));
  if (renderCtx.CurrentItem.File_x0020_Type.toLowerCase() != "") {
            calloutActionMenu.addAction(new CalloutAction({
                text: "Ramesh Callout",
                tooltip: 'Ramesh Callout',
                onClickCallback: function () {
                    CallBackFunc(renderCtx, 'Lookup', '/sites/sitecollectionname/SitePages/SendDocument.aspx');
                }
            }));
}
        }

        function CallBackFunc(renderCtx, DispTitle, PageUrl) {
          //debugger;
         
              var docUrl = renderCtx.CurrentItem.FileRef;
            var FileName = renderCtx.CurrentItem.FileLeafRef;
            var listName = renderCtx.ListTitle;
            currentCtx = renderCtx;

            var currentItem = renderCtx.CurrentItem;
            var currentItemID = renderCtx.CurrentItem.ID;
            var PgURL = '/sites/sitecollectionname/SitePages/SendDocument.aspx?FileName=' + FileName + '&FilePath=' + docUrl + '&ListName='+ listName;
           //alert(pgURL);
         
            var viewportWidth = $(window).width();
            var viewportHeight = $(window).height();

            var options = {
                url: PgURL,
                title: '' + DispTitle,
width: viewportWidth * 0.8,
                height: viewportHeight
            }

            SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
            $('#lblFileName').val(FileName);
            $('#lblFileID').val(currentItemID);
        }

        function CloseSPUIPopoup() {
            SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
        }

No comments:

Post a Comment