Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
2 lines (1 sloc) 5.83 KB
javascript:!function(){%22use%20strict%22;window.spUserCustomActions={},window.spUserCustomActions.init=function(){function%20e(e,t){var%20o=_spPageContextInfo.webAbsoluteUrl,i=o+%22/_api/site/userCustomActions%22;SP.SOD.registerSod(%22sp.requestexecutor.js%22,o+%22/_layouts/15/sp.requestexecutor.js%22),SP.SOD.executeFunc(%22sp.requestexecutor.js%22,%22SP.RequestExecutor%22,function(){new%20SP.RequestExecutor(o).executeAsync({url:i,method:%22GET%22,headers:{Accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(t){var%20o=JSON.parse(t.body);e%26%26e(o.d.results),window.tolle=o,console.log(o)},error:t})})}function%20t(e){return%20e.map(function(e){var%20t=e.ScriptSrc%3F%22ScriptSrc%22:%22ScriptBlock%22,o=['%3Cdiv%20class=%22actionDetails%22%3E%3Ctable%3E'];for(var%20i%20in%20e)e.hasOwnProperty(i)%26%26o.push([%22%3Ctr%3E%3Cth%3E%22,i,%22%3C/th%3E%3Ctd%3E%22,e[i],%22%3C/tr%3E%22].join(%22%22));return%20o.push(%22%3C/table%3E%3C/div%3E%22),['%3Cdiv%20class=%22actionRow%22%3E%3Clabel%20onclick=%22spUserCustomActions.toggleDetails(this)%22%3E',t,'%3C/label%3E%3Cinput%20type=%22text%22%20value=%22',e.ScriptSrc||e.ScriptBlock,'%22%3E%3Ca%20href=%22javascript:spUserCustomActions.deleteUserCustomAction(\''+e.Id+%22');\%22%3E%26%23x2716;%3C/a%3E%22,%22%20(%22,e.Name,%22:%20%22,e.Title,%22)%20%22,o.join(%22%22),%22%3C/div%3E%22].join(%22%22)}).join(%22%22)}function%20o(e){var%20o=['%3Cstyle%20type=%22text/css%22%3E','.actionRow%20%3E%20label::before%20{content:%20%22+%22;display:%20inline-block;width:1em;line-height:1em;margin-right:%203px;%20background-color:%20%23ccc;%20border-radius:%2010px;%20text-align:%20center;}',%22.actionDetails%20{%20overflow:%20hidden;%20transition:%20height%20.5s;%20height:%200;%20box-sizing:%20border-box;%20}%22,%22.actionDetails%20table%20{%20margin:%205px;%20border-collapse:%20collapse;%20}%22,%22.actionDetails%20table%20td,%20.actionDetails%20table%20th%20{%20vertical-align:%20top;%20border:%201px%20solid%20%23ccc;%20text-align:%20left;%20}%22,'.actionRow.checked%20%3E%20label::before%20{content:%20%22-%22;}',%22%3C/style%3E%22].join(%22%22),i=[%22%3Cdiv%3EPlease%20click%20on%20the%20link%20for%20you%20web%20part%20to%20see%20all%20user%20custom%20actions%3C/div%3E%22,'%3Cdiv%3EThe%20tool%20is%20provided%20as%20is.%20Author:%20Anatoly%20Mironov%20%40mirontoli,%202016-03-17.%20See%20the%20details%20on%20my%20blog:%20%3Ca%20href=%22http://chuvash.eu%22%3ESee%20all%20User%20Custom%20Actions%3C/a%3E%3C/div%3E%3Ch3%3ESite%20User%20Custom%20Actions%3C/h3%3E'].join(%22%22),s=[%22%3Cdiv%3EAdd%20new%20user%20custom%20action%20ScriptBlock.%20You%20can%20also%20load%20scripts%20and%20css%20in%20this%20scriptblock.%3Cbr%3E%22,'%3Ctextarea%20id=%22new-uca%22%20style=%22width:100%25;box-sizing:border-box;min-height:%2050px;%22%3E%3C/textarea%3E%3Cbr%3E%3Cinput%20type=%22button%22%20value=%22Add%20new%22%20onclick=%22spUserCustomActions.submitUserCustomAction()%22%3E%3C/div%3E'].join(%22%22),n=[%22%3Cdiv%3EAdd%20new%20site%20action%20(title%20and%20url).%20For%20example:%20Documents%20-%20~site/Shared%2520Documents/Forms/AllItems.aspx%3Cbr%3E%22,'Title:%20%3Cinput%20type=%22text%22%20id=%22new-siteaction-title%22%3EUrl:%20%3Cinput%20type=%22text%22%20id=%22new-siteaction-url%22%3E%3Cinput%20type=%22button%22%20value=%22Add%20new%22%20onclick=%22spUserCustomActions.submitSiteAction()%22%3E%3C/div%3E'];return[o,i,t(e),s,n].join(%22%22)}function%20i(e){var%20t=document.createElement(%22div%22);t.innerHTML=o(e),OpenPopUpPageWithDialogOptions({title:%22Administer%20User%20Custom%20Actions%22,html:t,allowMaximize:!0,showClose:!0,autoSize:!0})}function%20s(){console.log(%22error.arguments%22,arguments)}spUserCustomActions.toggleDetails=function(e){var%20t=e.parentNode,o=t.querySelector(%22.actionDetails%22);o.clientHeight%3Fo.style.height=0:o.style.height=o.scrollHeight+%22px%22,t.className=%22actionRow%22==t.className%3F%22actionRow%20checked%22:%22actionRow%22},spUserCustomActions.deleteUserCustomAction=function(e){var%20t=_spPageContextInfo.webAbsoluteUrl,o=t+%22/_api/site/userCustomActions('%22+e+%22')%22;new%20SP.RequestExecutor(t).executeAsync({url:o,method:%22POST%22,headers:{%22X-HTTP-Method%22:%22DELETE%22},success:function(e){},error:function(){console.log(%22nope%22,arguments)}})},spUserCustomActions.submitUserCustomAction=function(){var%20e=document.getElementById(%22new-uca%22),t=e.value;console.log(t);var%20o=_spPageContextInfo.webAbsoluteUrl,i=o+%22/_api/site/userCustomActions%22;new%20SP.RequestExecutor(o).executeAsync({url:i,method:%22POST%22,body:%22{%20'__metadata':%20{%20'type':%20'SP.UserCustomAction'%20},%20'Location':'ScriptLink',%20'Sequence':'101',%20'Title':'Open%20Shared%20Docs','Description':'',%20ScriptBlock:%20'%22+t+%22'%20}%22,headers:{accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(){console.log(%22submitted%22,arguments)},error:function(){console.log(%22nope%22,arguments)}})},spUserCustomActions.submitSiteAction=function(){var%20e=document.getElementById(%22new-siteaction-title%22),t=document.getElementById(%22new-siteaction-url%22),o=e.value,i=t.value,s=_spPageContextInfo.webAbsoluteUrl,n=s+%22/_api/site/userCustomActions%22;new%20SP.RequestExecutor(s).executeAsync({url:n,method:%22POST%22,body:%22{%20'__metadata':%20{%20'type':%20'SP.UserCustomAction'%20},%20'Location':'Microsoft.SharePoint.StandardMenu',%20'Group':'SiteActions',%20'Sequence':'101',%20'Title':'%22+o+%22',%20'Description':'Added%20by%20javascript',%20'Url':'%22+i+%22'%20}%22,headers:{accept:%22application/json;%20odata=verbose%22,%22content-type%22:%22application/json;%20odata=verbose%22},success:function(){console.log(%22submitted%20site%20action%22,o,i,arguments)},error:function(){console.log(%22site%20action%20submission%20failed%22,arguments)}})},function(){e(i,s)}()},window.spUserCustomActions.init()}();