Catégorie : English

How to hide the left navigation bar in Sharepoint without CSS

We can easily find some workarounds to hide the left navigation bar on Sharepoint using CSS…. But I wanted to remove it on a specific page, without using any CSS. It’s actually pretty simple. You need to add the below tag into your .aspx page: <asp:Content ContentPlaceHolderID= »PlaceHolderLeftNavBar » runat= »Server »></asp:Content> Tested with Sharepoint 2013 On-Promise.

How to cache the CSS Fonts with Sharepoint

If you use your own CSS file with your own CSS fonts, then we’ll notice that Sharepoint doesn’t send cache headers if you use the below CSS code: @font-face { font-family: ‘Roboto’; src: url(‘/_catalogs/masterpage/css/fonts/Roboto/Regular/Roboto-Regular.woff2’) format(‘woff2’), url(‘/_catalogs/masterpage/css/fonts/Roboto/Regular/Roboto-Regular.woff’) format(‘woff’), url(‘/_catalogs/masterpage/css/fonts/Roboto/Regular/Roboto-Regular.ttf’) format(‘truetype’); font-weight: 400; font-style: normal; } To have this resource sent back from the Sharepoint server with […]

Create an Unpublished Content view for the masterpage galery [Sharepoint]

With Sharepoint 2013 I wanted an easy way to list of the pages in my masterpage galery that haven’t been published yet. You first need to Create a new view named Unpublished Content. You can sort by Name, and scroll down to the Folders settings and choose Show all items without folders. We now have […]

Trigger an event when an element is visible in a scrollable area [JavaScript]

EDIT in 2022 It might also be interesting to look at Intersection Observer that is now available in most browsers, and there is also a polyfill. const observer = new IntersectionObserver((entries, observer) => { entries.forEach((entry) => { let isVisible=(entry.intersectionRatio===1); }); }, {threshold:1}); observer.observe(document.querySelector(‘#element’); END EDIT I have this specific need that is to trigger an […]

Check if an element is visible [JavaScript]

We can find plenty of answers about how to check if an element is visible. In my case the one which works with opacity, and into a scrollable area, is this one (that I have optimized): function isScrolledIntoView(el, holder) { var bndElem = el.getBoundingClientRect(); var bndHolder = holder.getBoundingClientRect(); return bndElem.top <= bndHolder.top ? !(bndHolder.top – […]

Resolve Promise one after another, in sequence

Below is the code that is handy when you want to execute several Promise actions in sequence: function PromiseChain(arr, fct) { var dfd = Promise.resolve(); var res = arr.map(function(item,idx) { dfd = dfd.then(function() { return fct(item,idx) }); return dfd }); return Promise.all(res) } // for short version: // function PromiseChain(n,r){var e=Promise.resolve(),i=n.map(function(n,i){return e=e.then(function(){return r(n,i)})});return Promise.all(i)} And […]

Deep clone an object in JavaScript

We can find many discussions and solutions about this issue. In my case the one that worked is this code. Below you’ll find a compressed version of the extend() function (with a fix): function extend(){var r,t,n,o,e=arguments[0]||{},f=1,i=arguments.length,u=!1,y=function(r){if(null===r|| »object »!=typeof r||r.nodeType||null!==r&&r===r.window)return!1;try{if(r.constructor&&!this.hasOwnProperty.call(r.constructor.prototype, »isPrototypeOf »))return!1}catch(t){return!1}return!0};for(« boolean »==typeof e&&(u=e,e=arguments[f]||{},f++), »object »!=typeof e&& »function »!=typeof e&&(e={}),!1;i>f;f+=1)if(null!==(r=arguments[f]))for(t in r)e!==r[t]&& »undefined »==typeof e[t]&&(u&&r[t]&&(y(r[t])||(n=Array.isArray(r[t])))?(n?(n=!1,o=e[t]&&Array.isArray(e[t])?e[t]:[]):o=e[t]&&y(e[t])?e[t]:{},e[t]=extend(u,o,r[t])):void 0!==r[t]&&(e[t]=r[t]));return e} And here an example: var object_a = { value_1: ‘a’, […]

Check permissions in Sharepoint based on a PermMask

In some cases you could get this kind of hexadecimal numbers from Sharepoint for the PermMask: 0xb008431061, or 0x1b03c4313ff, and so on. To verify the PermMask against the different level of permissions you can proceed with the below method (using functions from core.js): var permMask = ‘0x1b03c4313ff’; var permissions = new SP.BasePermissions(); permissions.initPropertiesFromJson({High:GetPermMaskH(permMask), Low:GetPermMaskL(permMask)}); // […]