Pages of modern Web applications are modular: you build the page by adding modules, or Web Parts, each displaying content pulled from the application database or external sources. This is how pages of SharePoint, Google Apps, DotNetNuke, etc., work.

The purpose of the SPELL library is to allow users and developers to discover and interact with these Web Parts. Once the SPELL library has identified the Web Parts present on the page, you can apply progressive enhancement to the existing page:

  • modify their behavior, for example attach an expand/collapse button.
  • change their style (for example apply a specific background to the Web Part headers.
  • Target a specific Web Part. Example: draw a chart based on tabular data in the Web Part.

SPELL stands for SharePoint Progressive Enhancement Lightweight Library. It was written for SharePoint 2007 and 2010, but can be adapted to other applications (for example I created a variation for DotNetNuke).

I have chosen to write it in plain JavaScript, so that it doesn't have any dependency on existing libraries (jQuery or other).

Currently, the SPELL library is limited to one method:
SPELL.getWebParts([scope],[limit]) retrieves the properties of Web Parts and stores them in an array of objects:

[
{"id": [string] ,"title": [string] ,"caption": [string] ,"container": [DOM element] ,"header": [DOM element] ,"body": [DOM element] ,"display": ["":"none"] }
]

Both arguments are optional:

  • scope is an element on the page. SPELL will only discover Web Parts within scope. If omitted, SPELL will retrieve all the Web Parts within the page content:
    document.getElementById("MSO_ContentTable").
  • limit is the maximum number of Web Parts to retrieve. If omitted, SPELL retrieves all the Web Parts present on the page.

 

Last edited Jul 5, 2011 at 3:17 AM by ChristopheHumbert, version 1

Comments

No comments yet.