Your SlideShare is downloading. ×
0
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
SharePoint jQuery Script Management
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

SharePoint jQuery Script Management

2,319

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,319
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
32
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. SharePoint jQuery Shared & Common Include Files 16-jun-2009 Kjell-Sverre Jerijærvi
  • 2. jQuery Scripts <ul><li>jQuery is a library for manipulating web pages </li></ul><ul><li>Add jQuery scripts to SharePoint web pages using the ”Content Editor Web Part” (CEWP) </li></ul><ul><li>Script classification: </li></ul><ul><ul><li>Unique : the script is unique to the web page </li></ul></ul><ul><ul><li>Shared : the script is shared between multiple related web pages, typically for all view pages of a specific list </li></ul></ul><ul><ul><li>Common : the script is common for unrelated web pages, typically for view pages for more than one list </li></ul></ul>
  • 3. Unique, Shared, Common <ul><li>Recommended practices for managing scripts according to classification </li></ul><ul><ul><li>Unique : add the script as text directly on the page </li></ul></ul><ul><ul><li>Shared : add the script as a file included on the page </li></ul></ul><ul><ul><li>Common : add the script as a file included on the page </li></ul></ul><ul><li>Keep shared and common scripts in separate include files – do not mix scripts of different classification </li></ul><ul><li>Keep shared list scripts in separate include files, one per list – do not mix scripts for different lists </li></ul>
  • 4. Include Files <ul><li>Store common include files in a global document library called ” MasterScriptLibrary ” </li></ul><ul><li>Store shared include files in a document library per site-collection called ” ScriptLibrary ” </li></ul><ul><li>Store custom CSS style sheets also in the script libraries </li></ul><ul><li>Assign ”Read” permissions on the script libraries to the group ”Authenticated Users” </li></ul>
  • 5. Script Library Locations Farm Web Application Root Site-Collection Top-Level Site Subsite Subsite Managed Site-Collection ROOT /MasterScriptLibrary TOPSITE /ScriptLibrary TOPSITE /ScriptLibrary Assign ”Read” permissions on the script libraries to the group ”Authenticated Users”
  • 6. CEWP Script Include <ul><li>Add include files to web-pages using CEWP </li></ul><ul><ul><li>The jQuery library itself (specific version): </li></ul></ul><ul><ul><ul><li><script src=&quot;http://<ROOT>/MasterScriptLibrary/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;></script> </li></ul></ul></ul><ul><ul><li>Common include files: </li></ul></ul><ul><ul><ul><li><script src=&quot;http://<ROOT>/MasterScriptLibrary/ScrollingListFrozenHeader420px.js&quot; type=&quot;text/javascript&quot;></script> </li></ul></ul></ul><ul><ul><li>Shared include files: </li></ul></ul><ul><ul><ul><li><script src=&quot;http://<TOPSITE>/ScriptLibrary/<SiteListName>AdjustColumnWidth.js&quot; type=&quot;text/javascript&quot;></script> </li></ul></ul></ul><ul><ul><li>CSS include files: </li></ul></ul><ul><ul><ul><li><link href=&quot;http://<TOPSITE>/ScriptLibrary/datagrid.css&quot; rel=&quot;Stylesheet&quot;></link> </li></ul></ul></ul><ul><li>Use relative URLs, avoid absolute URLs at all cost </li></ul>
  • 7. <ul><li>Order the scripts like this in CWEP: </li></ul><ul><ul><li>Common include files </li></ul></ul><ul><ul><li>Shared include files </li></ul></ul><ul><ul><li>Unique script as plain CEWP source text </li></ul></ul>CEWP Script Order TOPSITE/ScriptLibrary ROOT/MasterScriptLibrary CEWP jQuery library v1.3.2 Scrolling list w/ frozen header SiteList A adjust column widths SiteList B change styles <script src= jQuery > <script src= common > <script src= shared > <script> page specific script </script>
  • 8. Common List Scripts <ul><li>A common script MUST NOT contain any hardcoded list specific data </li></ul><ul><li>Common scripts can reference JavaScript variables to avoid hardcoding </li></ul><ul><li>Use the list view web-page ContextInfo ”ctx” variable to inject list data into the script: </li></ul><ul><ul><li>$(&quot;TABLE[ID^=' &quot; + ctx.listName + &quot; ']:first&quot;, &quot;#MSO_ContentTable&quot;); </li></ul></ul>
  • 9. Shared List Scripts <ul><li>Shared scripts contain list specific data </li></ul><ul><li>Shared scripts are typically used across all view web-pages to set e.g. column widths based on the text of list headers </li></ul><ul><ul><li>$(&quot;TD.ms-vb:contains( 'Type of Work' ):first&quot;).css(&quot;width&quot;, &quot;200px&quot;); </li></ul></ul>
  • 10. Resources <ul><li>jQuery library latest versions: http://code.google.com/apis/ajaxlibs/ </li></ul><ul><li>jQuery for everyone: http://www.endusersharepoint.com/?p=1746 </li></ul><ul><li>My blog: http://kjellsj.blogspot.com </li></ul>

×