Tips and tricks for using the Facebox jQuery Pop-up plugin

Tips and tricks for using the Facebox jQuery Pop-up plugin

I’ve been using this Facebox plugin for a while now in several SharePoint solutions that I’ve created, it’s not perfect but it grew on me, I find it easy to deploy and useful, and I like the modern look it gives to your web solution.


So here are a few tips and tricks for using this plugin:
1. Make your Facebox window draggable:

1
2
3
4
$(document).ready(function() {
//Make facebox popup window draggable
$(document).bind('reveal.facebox', function(){ $("#facebox").draggable( { cursor: "pointer" } ); });
});

*For the draggable code to work you have to add a reference to jQuery UI.

2. Open a facebox pop-up window from within a facebox box window –
Create this function -

1
2
//Open facebox from facebox - used in Day Pop up
function launchNextFaceboxPage(url) { $.facebox({ ajax:url }); }

Call it when clicking your link -

1
<a href="javascript:launchNextFaceboxPage('https://www.google.com');">My Link</a>

3. The preloader gif image did not load for me, I found this quick fix for it –
You need to change line 106 on the facebox.js file from –

1
$('#facebox .body').children().hide().end().

to:

1
$('#facebox .content').children().hide().end().

Getting all current user’s SharePoint permissions groups in InfoPath 2010

Getting all current user’s SharePoint permissions groups in InfoPath 2010

I followed this great post by Jaliya Udagedara on how to get a current user SharePoint group name in InfoPath, but I needed something a bit different, first of all I was working with an InfoPath form library and not a customized SharePoint list form, secondly I had a scenario where I wanted to show or hide different sections of my InfoPath form to different users according to their permission group, while it’s possible that they belong to several groups.
The basic idea was that I published my InfoPath form as a content type and added this content type to several libraries, than I’d modified my form to include submit data connections to each library.
Afterwards I’d added several buttons each of them submitting the form to a different library, each button is visible only to users belonging to the corresponding library’s permissions group, or to administrative users that are able to choose the library they wish to submit the form to.


So in order to get all of the current’s user permission groups in an InfoPath text field, follow Jaliya’s post up until step 5 (not including).
Then go to Data -> Form Load and create these 2 actions:

Add 2 Form Load actions

Add 2 Form Load actions

1. Set a field’s value: set the ‘userLoginName’ field on the GetGroupCollectionFromUser data connection (make sure you update this field under the connection’s queryFields group and not under the dataFields group where there is a field with the same name), set its value with the value returned by the GetUserProfileByName connection where – Filter (Name = “AccountName”).

Set a field's value: set the 'userLoginName'

Set a field’s value: set the ‘userLoginName’

Filter GetUserProfileByName Value

Filter GetUserProfileByName Value

2. Query for data the GetGroupCollectionFromUser data connection.

Query Data Connection

Query Data Connection

Create a new text field (I’ve named it CurrentUserPermissionGroups but you can name it anything you’d like), set its default value to contain this formula –
eval(eval(Group, ‘concat(@Name, “;”)’), “..”)

You can copy and paste this formula in to your text field’s default value formula, and then just re-select your group from your GetGroupCollectionFromUser data connection like so –

Update group from GetGroupCollectionFromUser in Formula

Update group from GetGroupCollectionFromUser in Formula

That’s all! Now your field should show all of the current user permission groups (under the site collection of your data connections) -

All the current user's permission groups in InfoPath result

All the current user’s permission groups in InfoPath result

To hide or show fields simply add formatting rules checking if this field contains the group in question -

Formatting Rule Example

Formatting Rule Example

Enjoy!