<?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>Midstride Solutions &#187; tooltip</title>
	<atom:link href="http://blog.midstride.com/tag/tooltip/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.midstride.com</link>
	<description>Powerful, simple &#38; easy to use.</description>
	<lastBuildDate>Sat, 18 Apr 2009 20:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating custom tooltips by extending Dojo&#8217;s Dijits &#8211; in 8 Steps</title>
		<link>http://blog.midstride.com/2008/08/25/creating-custom-tooltips-by-extending-dojos-dijits-in-8-steps/</link>
		<comments>http://blog.midstride.com/2008/08/25/creating-custom-tooltips-by-extending-dojos-dijits-in-8-steps/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 20:15:07 +0000</pubDate>
		<dc:creator>andre</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[dijittooltip]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[tooltip]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://blog.midstride.com/?p=5</guid>
		<description><![CDATA[Tooltips are nice small additions that can improve the user experience. They are so common that Dojo and other javascript frameworks provide precanned ways of creating them.]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p><img class="alignleft" style="float: left;" src="http://blog.midstride.com/wp-admin/resources/tooltip2.png" alt="dojo tooltip" />Tooltips are nice small additions that can improve the user experience.  They are so common that <a title="dojotoolkit" href="http://dojotoolkit.org/" target="_blank">Dojo</a> and other javascript frameworks provide precanned ways of creating them.  In dojo, they provide <a title="dojo dijit" href="http://dojotoolkit.org/projects/dijit" target="_blank">dijits</a> (their widgets) that can do some amazing things on the user interaction side.  That being said, when you want to customize them in any way, you can run into many walls.<br />
<span id="more-5"></span></p>
<p><strong>Dojo tooltip</strong><br />
<img src="http://blog.midstride.com/wp-admin/resources/tooltip.png" alt="dojo tooltip" width="90" height="30" /></p>
<h3>Problem &amp; Goal of this Article</h3>
<p>The main goal of this article is to show you how to stylize the tooltips so that you can create your own type of tooltip.  This article will go through the css required and how to structure your code so that you can create more than one tooltip.</p>
<p>To extend the style of dojo&#8217;s dijit, it&#8217;s best to copy one of the existing themes and create your own custom theme.  In this tutorial, I&#8217;ve copied the &#8220;tundra&#8221; theme so all the following css code will use the &#8220;tundra&#8221; selector.  You could replace the tundra selectors with your own custom name, but it may be more work than it&#8217;s worth.</p>
<h3>Prerequisites &#8211; tools you&#8217;ll need setup:</h3>
<ul>
<li> <a title="Firefox" href="http://www.firefox.com" target="_blank">Firefox</a><br />
<em>You should have this</em></li>
<li>IE 6 or <a href="http://www.my-debugbar.com/wiki/IETester/HomePage" target="_blank">IETester</a><br />
<em>You&#8217;ll want to make it IE6 compliant right?  Or maybe not&#8230; <img src='http://blog.midstride.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </em></li>
<li><a href="http://getfirebug.com/">Firebug</a><br />
<em> Every developer and especially UI developer should have this.</em></li>
<li><a title="dojo framework" href="http://dojotoolkit.org/" target="_blank">Dojo framework setup</a><br />
<em> Follow their <a href="http://sitepen.com/labs/guides/?guide=DojoQuickStart">documentation </a>on setting up the includes</em></li>
</ul>
<h3>The Steps</h3>
<p><strong>1. Setup a new theme</strong><br />
-Open up the dojo dijit theme folder<br />
-dojo-release-1.1.1dijitthemes<br />
<strong>2. Create a copy of the &#8220;tundra&#8221; folder.</strong><br />
<strong>3. Rename it to the name of your theme.  (e.g. &#8211;  &#8220;tundraextended&#8221;)</strong><br />
<strong>4. Include the dojo style and your extended theme in your header code:</strong></p>
<blockquote><p>&lt;style type=&#8221;text/css&#8221;&gt;<br />
@import &#8220;pathtodojo/dojo-release-1.1.1/dijit/themes/tundraextended/tundra.css&#8221;;<br />
@import &#8220;pathtodojo/dojo-release-1.1.1/dojo/resources/dojo.css&#8221;<br />
&lt;/style&gt;</p></blockquote>
<p><strong>5.  Include the tool tip dijit:</strong></p>
<blockquote><p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
dojo.require(&#8221;dojo.parser&#8221;);<br />
dojo.require(&#8221;dijit.Tooltip&#8221;);<br />
&lt;/script&gt;</p></blockquote>
<p><strong>6. Add the tool tip code</strong></p>
<blockquote><p>&lt;body class=&#8221;tundra&#8221;&gt; &lt;!&#8211; you need to set the body to load the dijit styles &#8211;&gt;</p>
<p>&lt;a id=&#8221;theId&#8221; href=&#8221;#&#8221;&gt;Hover over this&lt;/a&gt;</p>
<p>&lt;div dojoType=&#8221;dijit.Tooltip&#8221; style=&#8221;display:none&#8221; position=&#8221;left&#8221; connectId=&#8221;theId&#8221;&gt;<br />
&lt;div class=&#8221;custom_tooltip&#8221;&gt;tool tip content&lt;/div&gt;<br />
&lt;/div&gt;</p></blockquote>
<p><em>Note the attribute &#8220;position=left&#8221;.  This should remain the same for all tooltips that are defined by the inner class &#8220;custom_tooltip&#8221;.  I don&#8217;t really use the position attribute and rely on css position.<br />
</em><br />
At this point you should have a simple tool tip hover when the mouse goes over the link.  If you don&#8217;t, then open up firebug and see if you have any errors.  If you do, then you most likely didn&#8217;t setup dojo properly.</p>
<p>If all is good now, then you have a nice basic tooltip.  Now, the hard part is how to extend the look:<br />
<strong>7. Create a new css file &#8211; dojoextended.css</strong><br />
This style sheet should be included last.  As its name suggests, it extends (overrides and resets) the dojo stylesheet.</p>
<blockquote><p>&lt;style type=&#8221;text/css&#8221;&gt;<br />
@import &#8220;pathtodojo/dojo-release-1.1.1/dijit/themes/tundraextended/tundra.css&#8221;;<br />
@import &#8220;pathtodojo/dojo-release-1.1.1/dojo/resources/dojo.css&#8221;<br />
<strong>@import &#8220;pathtocss/dojoextended.css&#8221;</strong><br />
&lt;/style&gt;</p></blockquote>
<p><strong>8. Add the following css to the extended css file</strong></p>
<blockquote><p>/*Reset the generic tooltip container */<br />
.tundra .dijitTooltipContainer<br />
{<br />
background:none;<br />
padding:0;<br />
margin:0;<br />
border:none;<br />
height:auto;<br />
width:auto;<br />
}</p>
<p>/*defines the div inside the tooltip &#8211; your custom tooltip*/<br />
.custom_tooltip<br />
{<br />
/*this defines your tooltip*/<br />
position:relative;<br />
left:5px; /*use left and top to position it */<br />
top:15px;<br />
width:125px;<br />
height:100px;<br />
background-image:url(&#8221;yourimage.png&#8221;);<br />
}</p>
<p>/*if your tooltip uses transparency, define a ie6 specific one below */<br />
.dj_ie6 .tundra  .custom_tooltip<br />
{<br />
background-image:url(&#8221;yourimage_ie6.png&#8221;); /*an 8-bit png*/<br />
}</p>
<p>/*hide the connector &#8211; an arrow that connects the tooltip to the hovered item */</p>
<p>.tundra  .dijitTooltipAbove .dijitTooltipConnector  { background:none; }<br />
.tundra .dijitTooltipLeft .dijitTooltipConnector { background:none; }<br />
.tundra .dijitTooltipBelow .dijitTooltipConnector { background:none; }<br />
.tundra .dijitTooltipRight .dijitTooltipConnector { background:none; }</p></blockquote>
<h3>You&#8217;re done!</h3>
<p>You can now create as many styles for your tooltips as you need by defining a specific div and a new style (e.g. &#8211; custom_tooltip2).  You will likely have to do a lot of tweaking on the positioning image, but it&#8217;s pretty straightforward when you look at it.  The longest part is determining which css selectors you need to use, if you look at the tundra.css class you&#8217;ll notice there are more selectors I didn&#8217;t look at.</p>
<h3>Pros</h3>
<p>-Quick to code.<br />
-Easy to understand, there&#8217;s only one div to deal with.<br />
-IE6 compliant.  It&#8217;s always a bonus <img src='http://blog.midstride.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
-Extendability.  You can now create as many tooltips as you want for one project.  With the standard tooltip, you would be stuck with one tooltip for an entire project.</p>
<h3>Cons</h3>
<p>-Inefficient: Resetting styles is cumbersome and requires more data to be loaded.<br />
-Upgrading dojo could break the custom tooltips if they change the way the tooltip are rendered.<br />
-Tooltipconnector: I didn&#8217;t use the tooltipconnector which allows you to position the tooltip in various positions easily.</p>
<p><strong>Conclusion<br />
</strong>That wraps up the first tutorial on dojo.   I hope you found it useful, and I appreciate all feedback.  If you have a better way, I would like to know about it.  My next article will look at how to combine dojo&#8217;s ajax with the zend framework.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" onmouseover="a2a_show_dropdown(this)" onmouseout="a2a_onMouseOut_delay()" href="http://www.addtoany.com/share_save?sitename=Midstride%20Solutions&amp;siteurl=http%3A%2F%2Fblog.midstride.com%2F&amp;linkname=Creating%20custom%20tooltips%20by%20extending%20Dojo%E2%80%99s%20Dijits%20%E2%80%93%20in%208%20Steps&amp;linkurl=http%3A%2F%2Fblog.midstride.com%2F2008%2F08%2F25%2Fcreating-custom-tooltips-by-extending-dojos-dijits-in-8-steps%2F"><img src="http://blog.midstride.com/wp-content/plugins/add-to-any/share_save_120_16.gif" width="120" height="16" alt="Share/Save/Bookmark"/></a>
    <script type="text/javascript">
		a2a_linkname="Creating custom tooltips by extending Dojo’s Dijits – in 8 Steps";
		a2a_linkurl="http://blog.midstride.com/2008/08/25/creating-custom-tooltips-by-extending-dojos-dijits-in-8-steps/";
						    </script>
    <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>

	</p>]]></content:encoded>
			<wfw:commentRss>http://blog.midstride.com/2008/08/25/creating-custom-tooltips-by-extending-dojos-dijits-in-8-steps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
