<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rickey Whitworth&#039;s Blog &#187; Rounded Corners</title>
	<atom:link href="http://www.whitworth.org/tag/rounded-corners/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whitworth.org</link>
	<description>insights from managing a microsoft enterprise infrastructure</description>
	<lastBuildDate>Tue, 22 Jun 2010 17:12:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rounded Corners in Sharepoint Webpart Title Bar Using JQuery</title>
		<link>http://www.whitworth.org/2009/03/09/rounded-corners-in-sharepoint/</link>
		<comments>http://www.whitworth.org/2009/03/09/rounded-corners-in-sharepoint/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 20:29:50 +0000</pubDate>
		<dc:creator>rwhitworth</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Rounded Corners]]></category>
		<category><![CDATA[Sharepoint Customization]]></category>

		<guid isPermaLink="false">http://www.whitworth.org/2009/03/09/rounded/</guid>
		<description><![CDATA[Goal
A web part title bar with scripted rounded corners that can be displayed with or without a border.

Background
I wanted to create Sharepoint web part title bars with curved corners, and my search of the web led me to a couple of really good articles that got me started. Heather Solomon’s Post on Branding Sharepoint discusses [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Goal</strong></p>
<p>A web part title bar with scripted rounded corners that can be displayed with or without a border.</p>
<p><a href="http://www.whitworth.org/wp-content/uploads/image.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="image" src="http://www.whitworth.org/wp-content/uploads/image-thumb.png" border="0" alt="image" width="515" height="136" /></a></p>
<p><strong>Background</strong></p>
<p>I wanted to create Sharepoint web part title bars with curved corners, and my search of the web led me to a couple of really good articles that got me started. <a href="http://www.heathersolomon.com/blog/articles/brandsppart3a.aspx">Heather Solomon’s Post on Branding Sharepoint</a> discusses how you can use gif files of the rounded corners to do this. I knew I did not want to use images since there are plenty of scripting solutions out there for creating rounded corners on the fly, but Heather’s post was invaluable in knowing which styles I would need to modify. As I am sure you have heard, Sharepoint is a horrible mix of tables, css styles, and inline styles, so it was great that someone had already waded through this problem and documented it.</p>
<p>I had been following <a href="http://www.endusersharepoint.com/?s=paul+grenier">Paul Grenier’s</a> series about JQuery for Sharepoint at the EndUserSharepoint site, so I started searching for a way to do rounded corners with JQuery. I found a JQuery Plugin for Corner’s that is <a href="http://www.malsup.com/jquery/corner/">documented here</a>.</p>
<p>I did not want to get into editing master pages, or creating custom style sheets for my solution, I wanted to keep it a simple solution that could be added on a page in a content editor web part, and would only affect the rendering of that page. Obviously, if you are interested in having curved web part corners on every page of your site, then you could adapt this solution for that. But for demo purposes, my solution has the following guidelines:</p>
<ol>
<li>The jquery script libraries are stored as two files in a document library on the site.</li>
<li>A content editor web part contains a reference to the two script libraries.</li>
<li>The content editor web part also has a couple of styles defined that override the styles inherited by the site</li>
<li>The content editor web part has all of the scripts.</li>
</ol>
<p>So, while this is not the best solution for a site wide change, it is perfect for testing and getting a feel for what you can do.</p>
<p><strong>Solution</strong></p>
<ol>
<li>Pick a document library on your site to store the two jquery library files. Upload these two files to the document library
<ol>
<li><a href="http://www.whitworth.org/downloads/jquery-1.3.1.js">jquery-1.3.1.js</a> – This is version 1.3.1 of the jquery.js library</li>
<li><a href="http://www.whitworth.org/downloads/jquery.corner.js">jquery.corner.js</a> – This is a rounded corner plug-in for jquery.</li>
</ol>
</li>
<li>Edit the page you want the rounded corner’s to appear on, and add a Content Editor Webpart. Edit the web part, choose Source Editor, and paste the following code into the web part, without the line numbers. Be sure to adjust the line where the script libraries are referenced to point to the document library you used for step 1.</li>
</ol>
<pre class="brush: xml">

&lt;style type=&quot;text/css&quot;&gt;

.ms-WPHeader TD h3 {
margin: 0;
padding: 3px 0px 2px 5px;
height:24px;
}

.ms-HoverCellInActive {
margin: 0;
padding: 3px 0px 3px 0px;
height: 10px;
//}

.ms-WPBorder {
border-color: #85B2ED;
border-width: 1px;
}

&lt;/style&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;a href=&quot;http://site/Documents/jquery-1.3.1.js%22%3E%3C/script&quot;&gt;http://site/Documents/jquery-1.3.1.js&quot;&gt;&lt;/script&lt;/a&gt;&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;a href=&quot;http://site/Documents/jquery.corner.js%22%3E%3C/script&quot;&gt;http://site/Documents/jquery.corner.js&quot;&gt;&lt;/script&lt;/a&gt;&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
//Change these variables
var backColor = &quot;#85B2ED&quot;
var textColor = &quot;white&quot;

AddWebPartCorners();

function AddWebPartCorners(){
    $(&quot;.ms-WPHeader TD h3&quot;).css(&quot;color&quot;,textColor);
    $(&quot;.ms-WPHeader TD h3 a:link, .ms-WPHeader TD h3 a:visited&quot;).css(&quot;color&quot;,textColor);
    $(&quot;.ms-WPHeader TD h3&quot;).css(&quot;background-color&quot;,backColor).corner(&quot;tl 7px&quot;);
    $(&quot;.ms-WPHeader td&quot;).css(&quot;padding-right&quot;,&quot;0px&quot;);
    $(&quot;.ms-WPHeader td&quot;).css(&quot;border-bottom&quot;,&quot;0px&quot;);
    $(&quot;.ms-HoverCellInActive&quot;).css(&quot;background-color&quot;,backColor).corner(&quot;tr 7px&quot;);
}
&lt;/script&gt;
</pre>
<p><strong>How Does it Work?</strong></p>
<p>Lines 1-20 provide overrides for a couple of styles that are set by Sharepoint in the Core.css file. There are 3 classes we are concerned with here, .<strong>ms-WPHeader TD h3</strong>, .<strong>ms-HoverCellInActive</strong>, and .<strong>ms-WPBorder</strong>.</p>
<p> </p>
<table border="1" cellspacing="0" cellpadding="2" width="604">
<tbody>
<tr>
<td width="423" valign="top">Web Part Title (.ms-WPHeader TD h3)</td>
<td width="179" valign="top">.ms-HoverCellInActive</td>
</tr>
</tbody>
</table>
<p>Above is a sample of the table that is used for the Web Part Header. It consists of one row and two columns. Here is an overview of each style.</p>
<ol>
<li>.ms-WPHeader TD h3 – This is the style for the the web part title column. I is  I use it to hard code a height and control the padding. I tried finding a way around this, but, the problem is that the .ms-HoverCellInActive tag is a div, and from what I have researched, you can’t set the height of a div to fully fill a table cell unless that table cell has a height.</li>
<li>.ms-HoverCellInActive – This is the style for the second column in the header. It is the portion of the web part where the menu selector is placed. It is also the place where we need to have the second rounded corner. Again, I am hard coding a height here, and setting the padding so that this div lines up with the first column.</li>
<li>.ms-WPBorder – This is the style that controls the border of the content portion of the web part. I wanted to be able to match the border with the color I use for the web part title bar, so I just copied the style for it into here. You need to set this color manually to match whatever color you choose for the web part title bar.</li>
<li>.ms-WPHeader td<strong> –</strong> This style is not labeled above, but it controls the style for each column in addition to the styles above. I am handling the styling of the <strong>.ms-WPHeader td</strong> with script, so it is not defined in the style section. But basically it is used to remove the bottom border of the web part title bar and more importantly to remove the right padding for the HoverCell. If this right padding is not removed, the web part title bar does not cleanly line up with the border on the right side.</li>
</ol>
<p>Lines 22-23 add a reference to our two script libraries. Remember to point these to the location where you downloaded them. It could be a relevant site link, but for my purposes I didn’t want to have to change the line based on which level of the site it was placed at.</p>
<p>Lines 25-40 are where the actual rounding work is done. This is a script block.</p>
<p>Line 27 and 28 are variables used to hold the background color of the Webpart title bar and the text color. If you are using a dark background color you will most likely want to change the text color to a light color.</p>
<p>Line 30 is just a call to the function defined in Lines 32-38</p>
<p>As for the function, most of the code should be self-explanatory. Lines 33 and 34 just set the color of the text.</p>
<p>Line 35 sets the background color of the first column, and then calls the actual corner function of our library. Because this is the first column, I am only rounding the top-left corner (tl) with a radius of 7px.</p>
<p>In lines 36 and 37, I am changing the style for .ms-WPHeader td. This is used to remove the padding for the HoverCell column, and to remove the bottom border of both columns.</p>
<p>And finally, line 38 sets the background of the HoverCell column and rounds the top right corner of it</p>
<p>   </p>
<p><strong>What I have and have not Tested</strong></p>
<p>Working with stylesheets requires that you take into account different browsers that might access your site. In my case, this is an internal intranet site where the browser is controlled. So, I have only verified this with IE 7. I did test in Firefox, and it did not work, but Sharepoint has other problems with Firefox anyway. I have tested on both a MOSS site and a WSS team site. On a WSS team site, the Links web part does not appear to be styled the same as others, so I will have to research that further. There may be other web parts that do not use the same styles. If you run across others, let me know. I tested using the default theme, and also with a theme we had customized internally.</p>
<p><strong>Where to go from here?</strong></p>
<p>I’m not sure how much more work I will put into this, as it accomplishes the goal I set out to achieve. But others may want to build on this or may have a better way to handle the css. <a href="http://weblogs.asp.net/jan/default.aspx">Jan Tielens</a> has written a <a href="http://weblogs.asp.net/jan/archive/2008/11/20/sharepoint-2007-and-jquery-1.aspx">Feature for Sharepoint</a> that will include the JQuery library for you (though I’m not sure that it will include the jquery.corner plugin), and I plan to investigate that. As stated above, <a href="http://www.endusersharepoint.com/?s=paul+grenier">Paul Grenier</a> has a huge collection of cool things you can do with JQuery and Sharepoint. If you want to round the corners of the quick launch bar, there is an <a href="http://sharethelearning.blogspot.com/2008/11/jquery-in-sharepoint-example-rounded.html">article at Share The Learning for that</a>. I had a few problems getting it to work, but it was a great resource for this project. And finally, if you want to include any of this site wide, <a href="http://www.heathersolomon.com/blog/">Heather Solomon</a> is the place to go for customization tips.</p>
<p> </p>
<p><a href="http://www.whitworth.org/wp-content/uploads/image1.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" title="image" src="http://www.whitworth.org/wp-content/uploads/image-thumb1.png" border="0" alt="image" width="766" height="476" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whitworth.org/2009/03/09/rounded-corners-in-sharepoint/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>
