<?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>Prism Studio</title>
	<atom:link href="http://www.prismstudio.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prismstudio.co.uk/blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Sat, 04 Jun 2011 09:20:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>jQuery plugin: Stylish Select Box &#8211; Unobtrusive select box replacement</title>
		<link>http://www.prismstudio.co.uk/blog/2009/05/jquery-plugin-stylish-select-unobstrusive-select-box-replacement/</link>
		<comments>http://www.prismstudio.co.uk/blog/2009/05/jquery-plugin-stylish-select-unobstrusive-select-box-replacement/#comments</comments>
		<pubDate>Thu, 28 May 2009 15:20:32 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.scottdarby.com/?p=158</guid>
		<description><![CDATA[I have released a new jQuery plugin that allows you to style the standard &#60;select&#62; form element with CSS so that it looks the same in all major browsers. View Demo Checkout the latest source on GitHub Tested and works with: Firefox 3.0, Firefox2.0, Chrome 3, Safari 4, IE8, IE7, IE6 Why? Because sometimes the [...]]]></description>
			<content:encoded><![CDATA[<p>I have released a new jQuery plugin that allows you to style the standard <span class="codeEl">&lt;select&gt;</span> form element with CSS so that it looks the same in all major browsers.</p>
<p><a href="http://www.prismstudio.co.uk/plugins/stylish-select/0.4">View Demo</a></p>
<p><a href="http://github.com/sko77sun/Stylish-Select">Checkout the latest source on GitHub</a></p>
<p>Tested and works with:</p>
<p>Firefox 3.0, Firefox2.0, Chrome 3, Safari 4, IE8, IE7, IE6</p>
<h2>Why?</h2>
<p>Because sometimes the browser default form styles look ugly with the rest of your site and <span class="codeEl">&lt;select&gt;</span> elements are notoriously difficult to style with <acronym title="Cascading Style Sheets">CSS</acronym>. You can see how wildly different <span class="codeEl">&lt;select&gt;</span> elements can look in different browsers with the same <acronym title="Cascading Style Sheets">CSS</acronym> applied <a rel="blank" href="http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single/">here</a>.</p>
<h3>The IE6 issue(s)</h3>
<p>IE6 has a nasty habit of always displaying <span class="codeEl">&lt;select&gt;</span> elements on top of any other content, regardless of any z-index. This can be very annoying when using JavaScript overlays, drop down navigation etc. The only way around this issue is to use the <a rel="blank" href="http://www.cssplay.co.uk/menus/pro_drop8.html">iframe shim technique</a> which places an iframe around the content that needs to appear above the <span class="codeEl">&lt;select&gt;</span>.</p>
<p>Then there&#8217;s that <a rel="blank" href="http://css-tricks.com/select-cuts-off-options-in-ie-fix/"> other issue of not being able to set a width</a> on <span class="codeEl">&lt;select&gt;</span> elements without clipping off any options wider than the set width.</p>
<p>While workarounds do exist for these issues, I wanted to create a drop down menu that worked exactly the same in every browser and did away with these IE6 oddities.</p>
<h2>So how does it work?</h2>
<p>Stylish Select basically grabs all of the options from your select menu, puts them into an unordered list and hides the original <span class="codeEl">&lt;select&gt;</span>. This unordered list is then made interactive, so that it functions like a browser native <span class="codeEl">&lt;select&gt;</span>. When you click on or navigate through the list with the keyboard, it updates the <span class="codeEl">&lt;select&gt;</span> in the background, so that when you submit your form, it is just like you were using the original <span class="codeEl">&lt;select&gt;</span>.</p>
<p>This newly created <span class="codeEl">&lt;select&gt;</span> now has the flexibility to be styled in whatever way you choose.</p>
<p>Alot of work has been done to make the newly created <span class="codeEl">&lt;select&gt;</span> to function like the original browser default. The plugin offers the following features:</p>
<p>Supports keyboard navigation including alpha-numerical keys<br />
If the <span class="codeEl">&lt;select&gt;</span> is at the bottom of the screen, the drop down menu stays on the screen<br />
Support for grouped options with <span class="codeEl">&lt;optgroup&gt;</span><br />
If a value is selected, the new select menu shows this option as selected</p>
<p>You can invoke the plugin on any <span class="codeEl">&lt;optgroup&gt;</span> with the following method:</p>
<p><span class="codeEl">$(&#8216;.my-dropdown&#8217;).sSelect();</span></p>
<p><span class="codeEl"><a href="http://www.prismstudio.co.uk/plugins/stylish-select/0.4">View Demo</a><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.prismstudio.co.uk/blog/2009/05/jquery-plugin-stylish-select-unobstrusive-select-box-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to build an expandable sitemap with jQuery and CSS</title>
		<link>http://www.prismstudio.co.uk/blog/2009/05/how-to-build-an-expandable-sitemap-with-jquery-and-css/</link>
		<comments>http://www.prismstudio.co.uk/blog/2009/05/how-to-build-an-expandable-sitemap-with-jquery-and-css/#comments</comments>
		<pubDate>Wed, 13 May 2009 12:15:04 +0000</pubDate>
		<dc:creator>scott</dc:creator>
		
		<guid isPermaLink="false">http://www.scottdarby.com/?p=83</guid>
		<description><![CDATA[If you are working on a site with hundreds of pages, it&#8217;s sitemap can become huge and unmanageable, leaving you to scroll through a page of links before you find what you want (yes you could just hit ctrl+f, but that&#8217;s not the point). Computer operating systems often employ tree-view navigation to aid users in [...]]]></description>
			<content:encoded><![CDATA[<p>If you are working on a site with hundreds of pages, it&#8217;s sitemap can become huge and unmanageable, leaving you to scroll through a page of links before you find what you want (yes you could just hit ctrl+f, but that&#8217;s not the point). Computer operating systems often employ <a href="http://en.wikipedia.org/wiki/Tree_view" target="_blank">tree-view navigation</a> to aid users in navigating hierarchical data. In this tutorial I will use the power of jQuery to transform an unordered list of hierarchically structured pages into an expandable, tree-view navigation system &#8211; the perfect way to tame those huge sitemaps produced by your CMS.</p>
<p><a href="http://www.prismstudio.co.uk/tutorials/quickTree/0.4/index.html" target="_blank">View a working example</a></p>
<p><a href="http://www.prismstudio.co.uk/tutorials/quickTree/0.4/jquery.quickTree.zip">Download</a></p>
<h2>Getting started</h2>
<p>We will start with a simple unordered list:</p>
<pre class="brush: html">
<ul class="sitemap">
<li>Top level page
<ul>
<li>Sub page - level one
<ul>
<li>Sub page - level two
<ul>
<li>Sub page - level three</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</pre>
<p>Nothing fancy there, hopefully your sitemap is already structured in this way.</p>
<h2>jQuery time</h2>
<p>We will now create a jQuery plugin which will do the following:</p>
<ol>
<li>Hide all lists that are not on the top level</li>
<li>Add an expand/contract button next to each list-item that contains a list</li>
<li>Add classes to the last item in the each list for presentational purposes</li>
<li>Add interactivity so that if the expand/contract button is clicked, the list will show/hide</li>
</ol>
<p>We will use jQuery&#8217;s plugin interface, so begin by starting the plugin:</p>
<pre class="brush: javascript">
jQuery.fn.quickTree = function() {
    return this.each(function(){
</pre>
<p>This adds a new function to jQuery called &#8216;quickTree&#8217;. We will pass the <span class="codeEl">&lt;ul&gt;</span> element we want to transform to this function. We then use jQuery&#8217;s built in .each() iterator method to access each of the elements passed to this function.</p>
<p>Now we need to set our variables to be used in the function, by setting them once here, we can then use them again in our plugin without having to search through the <acronym title="Document Object Model">DOM</acronym> each time, saving valuable processor cycles. N.B. I am prefixing variables that are jQuery objects with a &#36; sign to aid readability
</p>
<pre class="brush: javascript">
	//access element passed to the plugin
    var $tree = $(this);

	//get all of the list-items
    var $roots = $tree.find('li');

	//add class to last item in each list for styling
	$tree.find('li:last-child').addClass('last');
</pre>
<p>We now need to hide all lists lower than the top level which can be done simply by finding all of the <span class="codeEl">&lt;ul&gt;</span> elements inside the main list and using jQuery&#8217;s .hide() method:</p>
<pre class="brush: javascript">
        $tree.find('ul').hide();
</pre>
<p>We now need to iterate through all of the list items and if they contain any child <span class="codeEl">&lt;ul&gt;</span> elements, place a <span class="codeEl">&lt;span&gt;</span> element in front of them. This <span class="codeEl">&lt;span&gt;</span> will act as our button to expand &amp; contract the list.</p>
<pre class="brush: javascript">
		//iterate through all list items
        $roots.each(function(){

			//if list-item contains a child list
            if ($(this).children('ul').length > 0) {

				//add expand/contract control
                $(this).addClass('root').prepend('<span class="expand"></span>');

            }

        }); //end .each
</pre>
<p>We will now add interactivity to the buttons with jQuery&#8217;s .toggle() method. .toggle() acts like a switch and alternates between two functions on click. Here, the first function toggles the class of the expand button (so that it can show a contract symbol with <acronym title="Cascading Style-Sheets">css</acronym>) and uses jQuery&#8217;s .slideDown() method to reveal the next level of <span class="codeEl">&lt;ul&gt;</span> elements. The second function is essentially the first function in reverse.</p>
<pre class="brush: javascript">
        $('span.expand').toggle(
			//if it's clicked once, find all child lists and expand
            function(){
                $(this).toggleClass('contract').nextAll('ul').slideDown();
            },
			//if it's clicked again, find all child lists and contract
            function(){
                $(this).toggleClass('contract').nextAll('ul').slideUp();
            }
        );
    });
};
</pre>
<h2>Presentation</h2>
<p>Now we need to use <acronym title="Cascading Style-Sheets">CSS</acronym> to enhance the presentation of the list so that it resembles a tree-structure.</p>
<p>First of all, we will reset all the margins and padding of the elements within the list with the * selector, to level the playing field. We then add some spacing to the list-items so that each consecutive lower level is indented. We also add a tree-branch background image to each list-item. This tree-branch image is a &#8216;T&#8217; shape rotated left 90&deg; and is positioned so that it is vertically centered, but horizontally fixed. The graphic has been constructed so that it is much taller than the size of the text, so that if the text size is increased, the connecting lines do not have a gap.</p>
<p>We also give the list-items that are the last in their list an &#8220;L&#8221; shaped background image. We have to then write a new rule for any list-items that are the last item in their list, but also contain lists themselves so that the &#8220;L&#8221; shaped background image is removed.</p>
<pre class="brush: css">
.tree * {
	margin:0; padding:0;
}
.tree li {
	list-style:none;
	padding-left:21px;
}
.tree li.root {
	padding-left:0;
}
.tree li li {
	background:url(rootNode.gif) no-repeat 17px center;
	margin-left:10px;
	padding-left:31px;
}
.tree li li.root {
	padding-left:10px;
	background:url(justOne.gif) repeat-y 17px 0;
}
.tree li li.root.last {
	background:none;
}
.tree li li.last {
	background:url(lastRoot.gif) no-repeat 17px 0;
}
</pre>
<p>The last thing left to do presentation-wise is to create our expand/contract button style. I have used an image replacement technique to change the span element added with JavaScript into a button (<a href="http://css-tricks.com/nine-techniques-for-css-image-replacement/" target="_blank">read more about image replacement</a>). Rather than create two images for the expanded/contracted state, I have rolled them into one image, then all I have to do is change the background-position property to change the background image.</p>
<pre class="brush: css">
.expand {
	background:url(plusMinus.gif) no-repeat;
	width:16px;
	_width:13px;
	height:16px;
	display:block;
	float:left;
	margin-top:2px;
	padding:0 5px 0 0;
	text-indent:-9999px;
	line-height:0;
	font-size:0;}
.contract {
	background-position:0 -16px;
}
.expand:hover {
	cursor:pointer;
}
</pre>
<p>The plug-in can now be used on any unordered list element on your page with the following jQuery statement:</p>
<pre class="brush: javascript">
	$(document).ready(function(){
		$('ul.my-class').quickTree();
	});
</pre>
<p><a href="http://www.prismstudio.co.uk/tutorials/quickTree/0.4/index.html" target="_blank">View a working example</a></p>
<p><a href="http://www.prismstudio.co.uk/tutorials/quickTree/0.4/jquery.quickTree.zip">Download</a></p>
<p>If you liked this post, please share it with others!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.prismstudio.co.uk/blog/2009/05/how-to-build-an-expandable-sitemap-with-jquery-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

