Catégorie : Programmation

Gérer les évènements touch sur mobile [JavaScript]

J’ai un projet sur lequel j’ai deux évènements « mouseenter » et « mouseleave » gérés par jQuery (pour faire le « hover »), et je voulais un comportement similaire sur mobile. Pour ce faire, je voulais qu’un « tap » affiche ce que le « hover » affiche avec la souris, puis qu’un second « tap » permette d’accéder au contenu (comme un « clic »). La solution […]

How to expand Sharepoint 2010 calendar by default [JavaScript]

This code has been tested for Sharepoint 2010 only. It permits to expand by default (so as soon as the page is loaded) the events in the Month calendar view. See here a solution for Sharepoint 2013. Tested with IE8 and Firefox 34. You’ll have to add the below JavaScript code into your calendar page: […]

Breadcrumb / steps in CSS that works from IE8 [CSS]

I was looking for a simple code for a step by step process indicator. I found a few things, but everyone seems to have forgotten about IE8… I need to support this old browser at work. So I did my own that I’m sharing here: File Uploaded → File Reviewed → File Approved And the […]

How to read a remote file and convert it to a Base64 string [JavaScript]

This code is based on the one found on StackOverflow — it’s compatible with IE8+, and all modern browsers: // get the remote file binary content function getBinary(file, callback) { var convertResponseBodyToText = function(e) { return e }; var xhr = new XMLHttpRequest(); xhr.open(« GET », file, true); if (xhr.overrideMimeType) xhr.overrideMimeType(« text/plain; charset=x-user-defined ») else { // for IE8 […]

Problem with the People Picker of Sharepoint

For one of my list I’ve had a very weird issue: one people picker didn’t work properly. If I entered a name and clicked to check it, then it didn’t work. If I saved it and then got back to the form, the value didn’t appear. This strange behavior is due to a missing SPAN […]

Communication between iframe and parent window [JavaScript]

In the iframe you’ll use the below code: window.parent.postMessage(« Hello World ! », « http://your.site.web »); And in the parent window: // function that will be called when the message is received function receiveMessage(event) { alert(event.data); // it’ll show « Hello World ! » } // we listen to a message if (window.addEventListener) { window.addEventListener(‘message’, receiveMessage, false); } else if (window.attachEvent) […]

How to edit the default action for an icon in a Sharepoint Ribbon

I wanted to change the behavior of the « Edit Item » button from the Sharepoint 2010 ribbon of the Display Form (DispForm.aspx). It wasn’t really easy, so I finally found a solution that I’m going to share here. You’ll need to use JavaScript for that. In the below example, the click on the « Edit Item » will […]

Show/Hide a Sharepoint fields in the NewForm, EditForm and DispForm

With the Sharepoint WebServices it’s possible to hide a field into the NewForm, the Editform and/or the DispForm. You’ll need to use JavaScript with jQuery and SPServices. It’s the UpdateList service that will do the trick. Once you have loaded the both librairies you can use the below code: var fieldsToUpdate = ‘<Fields>’; fieldsToUpdate += […]

Delete a User Custom Action from Sharepoint [JavaScript]

The MSDN documentation is a nightmare…. For example Microsoft provides an example to create a User Custom Action for Sharepoint, however there is no code about how to delete it. So here is the code to use to delete the usercustomaction just created with the above example: var siteUrl = ‘/site collection/site/’; function deleteUserCustomAction() { […]