// define functions to render shareForm // the 'type' paramater tells which shareform type to render // either Pageshare, Docshare, FAQshare etc.. function closemodal() { location.reload(); //$("#share-modal").modal("hide"); //$("#thankyoumsg").hide(); } function renderShareForm(type, index, documenturl) { init(); // for Pageshare if (type=="contentshare") { var pagetitle = $("h1").first().text(); $(".sharecomponent-subhead").text(pagetitle); $(".sharecomponent-title").text("Share this Page"); $("#sharecomponent-submit").click(function() { shareformsubmit("contentshare"); }); } // for FAQ shares if (type=="faqshare") { var $this = $(".support-share-icon").eq(index); $(".sharecomponent-subhead").html($this.prev().html()); $(".sharecomponent-title").text("Share this topic"); $("#sharecomponent-submit").click(function() { shareformsubmit("faqshare",index); }); } // for Doc shares if (type=="docshare") { var $this = $(".doc-share").eq(index); $(".sharecomponent-subhead").html($this.prev().html()); $(".sharecomponent-title").text("Share this Document"); $("#sharecomponent-submit").click(function() { shareformsubmit("docshare",index); }); } // for BBEG shares if (type=="bbegshare") { $(".sharecomponent-title").text("Share this Document"); $(".sharecomponent-subhead").html(index); $("#sharecomponent-submit").click(function() { shareformsubmit("bbegshare", index, documenturl); }); } } //Init function common to all form types function init() { var contentURLF = contentURL.replace(/&/g, '&').replace('current=true&',''); var fullurl = "https://" + window.location.hostname + contentURLF; $("#sharecomponent-Page, #sharecomponent-redirect_success").val(fullurl); //Prepopulate name and email if user is logged in if (loggedIn()) { $("#sharecomponent-yourname").val(_empName); $("#sharecomponent-youremail").val(_email); } } //Form submit actions - these parameters are filled in from renderShareform function shareformsubmit(type, index, documenturl) { var contentURLF = contentURL.replace(/&/g, '&').replace('current=true&',''); if (contentURLF.contains("PeopleFluentLinks/Dynamic/BenefitsContent")) { var pageparam = window.location.href.split("?PageName=")[1]; contentURLF+= "?PageName=" + pageparam; console.log("final url for dynamic page: " + contentURLF); } var fullurl = "https://" + window.location.hostname + contentURLF; var subjectcontent; //var val = document.myhrContentForm.contentURL.value; var uniqueurl = decodeURIComponent(URLComponent).split("wcm:path:")[1]; var pagetitle = $("h1").first().text(); //Capture the To, User name, Friend email values from the form fields var toval = $("#sharecomponent-friendemail").val(); $("#sharecomponent-to").val(toval); var sharecomponentyourname = $("#sharecomponent-yourname").val(); var sharemsg = $("#sharecomponent-message").val(); var sharecomponentcomments = $('#sharecomponent-comments').val(); var bannertitle; // sharedmsg value is unique to each form type and will be added to // the email message that is composed var sharedmsg; if (type=="contentshare") { bannertitle = "Page Share"; // append dcsMultitrack function to submit button if (typeof cgs2 === 'undefined') { var outboundcgs2 = "outbound_HRContent"; var inboundcgs2 = "inbound_HRContent"; } else { var outboundcgs2 = "outbound_" + cgs2; var inboundcgs2 = "inbound_" + cgs2; } dcsMultiTrack('DCS.dcsuri','EmailContentShareForm/ButtonSubmit','WT.ti','Email Content Share Form: Submit Button','WT.dl','28','WT.cg_s','Email_Link','WT.cg_s2',outboundcgs2,'DCSext.UniqueURL',uniqueurl,'dcsqry',''); fullurl = "https://" + window.location.hostname + contentURLF + "&WT.cg_s=Email_Link&WT.trsc=Email&UniqueURL=" + uniqueurl + "&WT.cg_s2=" + inboundcgs2; console.log("full url with dcs track: " + fullurl); sharedmsg = "" + pagetitle + ""; subjectcontent = sharecomponentyourname + " sent you a link from HRconnect Portal"; $("#sharecomponent-Page, #sharecomponent-redirect_success").val(fullurl); } if (type=="docshare") { bannertitle = pagetitle + " Share"; subjectcontent = sharecomponentyourname + " sent you content from HRconnect Portal"; var $this = $(".doc-share").eq(index); var docurl = "https://" + window.location.hostname + $this.prev().attr("href"); sharedmsg = "Document: " + $this.prev().html() + "
"; sharedmsg += "Page: " + pagetitle + ""; } if (type=="bbegshare") { bannertitle = "Benefits by Employee Group Document Share"; subjectcontent = sharecomponentyourname + " sent you a document from HRConnect"; var docurl = "https://" + window.location.hostname + documenturl; sharedmsg = "Document: " + index + "
"; sharedmsg += "Page: " + pagetitle + ""; } if (type=="faqshare") { bannertitle = "Support Q & A" subjectcontent = sharecomponentyourname + " sent you a Support Q & A from HRconnect Portal"; var $this = $(".support-share-icon").eq(index); var faqcontentid = $this.parent().attr("data-contentid"); $("#faq-contentid").val(faqcontentid); var thisques = "Question: " + $this.prev().html() + "
"; var ans = $this.parent().next().html(); var anselem = $this.parent().next(); $(anselem).find("img").remove(); $(anselem).find("script").remove(); var quescontent = encodeURIComponent($this.prev().html()); $(anselem).find('p').contents().unwrap(); var faqtype; var anslen = ans.replace(/ /g,'').length; if (ans.contains('
')) { faqtype = 'type3'}; if (anslen < 2000) { faqtype = 'type1' }; if (anslen > 2000) { faqtype = 'type2' }; var faqcategory = $this.parent().attr("data-contentcategory"); if (faqtype == 'type1') { var thisans = $(anselem).html(); thisans += "

View more questions

"; } if (faqtype == 'type2') { var thisans = $(anselem).html().substring(0,1980); thisans += "...

Visit HRconnect Portal for full answer

"; } if (faqtype == 'type3') { var thisans = "We need a little bit more information to answer this question.

Visit HHRconnect Portal for full answer

"; } var thisanswer = "Answer: " + thisans; sharedmsg = thisques + thisanswer; } //Construct email message from the form fields and the sharedmsg variable var emlmsg = "

Hello,
I would like to share this with you:

" + sharedmsg + "

Comments: " + sharecomponentcomments + "

From: " + sharecomponentyourname +"

"; $("#sharecomponent-message").val(emlmsg); $("#sharecomponent-subject").val(subjectcontent); $("#shareform").validate(); // target hidden iframe to show thank you message and close after 2 seconds //$("#thankyoumsg").show(); //setTimeout(closemodal,2000); } // Sharing FAQs from Support page function shareFAQ() { $(".support-share-icon").each(function(index) { $(this).click(function() { renderShareForm("faqshare",index); }); }); } $(document).ready(function() { // Generic Content Share - Announcement or Page $("#sharebutton").click(function() { renderShareForm("contentshare"); }); // Policies Sharing $(".doc-share").each(function(index) { $(this).click(function() { renderShareForm("docshare",index); }); }); // BBEG Sharing // This is different from other share types. Need share type, the bbeg // category and bbeg doc urlsince there are multiple categories within bbeg $(".bbegshare").click(function() { var bbegcategory = $(this).attr("data-bbegcategory"); var bbegdocurl = $(this).attr("data-docurl"); renderShareForm("bbegshare", bbegcategory, bbegdocurl); }); $("img[name='share']").attr("title","Share"); $(".doc-share img").attr("title","Share"); //Print function $("#printbutton").click(function() { window.print(); }); });