-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserPeoplePicker.min.js
1 lines (1 loc) · 1.96 KB
/
UserPeoplePicker.min.js
1
!function(e){function t(e){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src","/_layouts/15/"+e),document.getElementsByTagName("head")[0].appendChild(t)}function n(e){if(null!=e){var t=e+"_TopSpan",n=null,r=this.SPClientPeoplePicker.SPClientPeoplePickerDict;for(var i in r)if(i==t){n=r[i];break}return n}}function r(t,r){var i=n(t);null!=i&&r.forEach(function(t){var n=function(t){var n="";return e.ajax({url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/getuserbyid("+t+")",method:"GET",async:!1,headers:{Accept:"application/json; odata=verbose"},success:function(e){n=e.d},error:function(e){console.log(e)}}),n}(t);null!=n&&i.AddUserKeys(n.LoginName,!1)})}function i(t){var n="";return e.ajax({url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/ensureuser",method:"POST",async:!1,contentType:"application/json;odata=verbose",data:JSON.stringify({logonName:t}),headers:{Accept:"application/json; odata=verbose","X-RequestDigest":e("#__REQUESTDIGEST").val()},success:function(e){n=e.d.Id},error:function(e){console.log(e)}}),n}t("clienttemplates.js"),t("clientforms.js"),t("clientpeoplepicker.js"),t("autofill.js"),e.fn.spPeoplePicker=function(){var t=e(this).attr("id");ExecuteOrDelayUntilScriptLoaded(function(){!function(e){var t={PrincipalAccountType:"User,DL,SecGroup,SPGroup",SearchPrincipalSource:15,ResolvePrincipalSource:15,AllowMultipleValues:!0,MaximumEntitySuggestions:50,Width:"280px"};this.SPClientPeoplePicker_InitStandaloneControlWrapper(e,null,t)}(t)},"sp.core.js")},e.fn.GetUserNames=function(){return function(e){var t=n(e);if(null!=t){for(var r=t.GetAllUserInfo(),i="",o=0;o<r.length;o++)i+=r[o].DisplayText+";#";return i}return""}(e(this).attr("id")).slice(0,-2)},e.fn.GetUserIDs=function(){return function(e){var t=n(e);if(null!=t){for(var r=t.GetAllUserInfo(),o=[],a=0;a<r.length;a++){var l=i(r[a].Key);o.push(l)}return o}return""}(e(this).attr("id"))},e.fn.SetUserIDs=function(t){if(t.length>0)return r(e(this).attr("id"),t)}}(jQuery);