<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>McArthur GFX</title>
	<link>http://mcarthurgfx.com</link>
	<description>Freelance Web Design</description>
	<pubDate>Wed, 19 Nov 2008 17:02:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>ParentNode of New Elements</title>
		<link>http://mcarthurgfx.com/blog/javascript/parentnode-of-new-elements/</link>
		<comments>http://mcarthurgfx.com/blog/javascript/parentnode-of-new-elements/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 16:57:24 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/javascript/parentnode-of-new-elements/</guid>
		<description><![CDATA[<p>I wrote a simple script to pop-up a modal-like element when clicking on an "Add" button on the page. I wanted to insert the element into the DOM on first click, and on subsequent clicks, simply reset the form. A bug popped up in IE7 (surprise) that prevented me from checking if I had inserted the element already.</p>]]></description>
			<content:encoded><![CDATA[<p>I wrote a simple script to pop-up a modal-like element when clicking on an &#8220;Add&#8221; button on the page.  I wanted to insert the element into the DOM on first click, and on subsequent clicks, simply reset the form.   A bug popped up in IE7 (surprise) that prevented me from checking if I had inserted the element already.</p>
<h4> What I tried to do</h4>
<p>I performed the case check by simply checking the parentNode of the element, which obviously shouldn&#8217;t exist until it&#8217;s inserted into the DOM.</p>
<pre>if(!this.form.parentNode)
	$('Admin').insert(this.form);
else
	this.form.reset();</pre>
<p>As I expected, worked perfectly.  <em>Until I popped open IE7</em>.</p>
<h5>IE Ignores Specs</h5>
<p>Apparently, IE7 assigns a parentNode to nodes upon creation, before it has been inserted into the DOM.  Well that&#8217;s silly, because the specifications say nothing about setting the parentNode.  In fact, they state the opposite:</p>
<blockquote><p> However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is <code>null</code>.</p></blockquote>
<p>That&#8217;s fine.  Doing some debugging, I find there is indeed a parentNode.  And that parentNode has a nodeType of 9, or DOCUMENT_NODE.  So it makes a new, off-screen document to hold onto created Elements.  Whatever.</p>
<h5>Excusing IE</h5>
<p>A simple modification to my if statement fixed everything, once I finally knew IE gives it a parentNode.  The good part (<em>there&#8217;s good here?</em>), is that it assigns the new Element a parent that only the HTML node should have, a document.  So here it is modified:</p>
<pre>if(!this.form.parentNode || this.form.parentNode.nodeType == 9) // 9 == DOCUMENT_NODE, but IE is freaking retarded. I'm ganna kill Microsoft 100 times over.
	$('Admin').insert(this.form);
else
	this.form.reset();</pre>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/javascript/parentnode-of-new-elements/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hide Overflowing Floats</title>
		<link>http://mcarthurgfx.com/blog/css/hide-overflowing-floats/</link>
		<comments>http://mcarthurgfx.com/blog/css/hide-overflowing-floats/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 18:15:31 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/css/hide-overflowing-floats/</guid>
		<description><![CDATA[<p>Floating elements on a page is easily the most common way to achieve columned layouts on the web.  You can also use the <code>position</code> property, but I find floating to be far better to keep the element in the flow of the page.</p>
<p>One problem that shows it self a lot, is when you have floated items inside a container, and that container has a background.  You will find that the container does a poor job of containing the floated items.</p>]]></description>
			<content:encoded><![CDATA[<p>Floating elements on a page is easily the most common way to achieve columned layouts on the web.  You can also use the <code>position</code> property, but I find floating to be far better to keep the element in the flow of the page.</p>
<h4>Floaters Have Bad Parenting</h4>
<p>One problem that shows it self a lot, is when you have floated items inside a container, and that container has a background.  You will find that the container does a poor job of containing the floated items.</p>
<div style="width: 500px; background-color:#ccc;">
<div style="width:250px; float:left; border:1px solid #aaa;">
<p><strong>Floating 1</strong></p>
<p>Fusce eu tellus. Aenean ipsum. Nam et diam sed urna rhoncus facilisis. Phasellus metus neque, auctor non, aliquet eu, venenatis nec, mi. Donec ultricies auctor lacus.</p>
</p></div>
<p>Fusce eu tellus. Aenean ipsum. Nam et diam sed urna rhoncus facilisis.</p>
</div>
<div style="clear:both;"></div>
<p>Quite often, the solution to something like this, is putting a <code>clear div</code> at the bottom of the container.  But while that works, it adds extra markup, which sometimes a designer doesn&#8217;t have access to do so.</p>
<p>For instance, on Blazonco, the XHTML markup  is generated by the server, and so adding extra <code>div</code>s to an element that the designer wants floated just isn&#8217;t feasible.  Well, thankfully, <em>there&#8217;s an easy CSS solution with no additional markup</em>.</p>
<h5>Overflow: hidden</h5>
<pre>
<code>
.container {
	overflow:hidden;
}
</code>
</pre>
<p>That&#8217;s it!  Just place an overflow property on your container, and it will stretch down to encapsulate all of its floating children.</p>
<div style="width: 500px; background-color:#ccc; overflow:hidden;">
<div style="width:250px; float:left; border:1px solid #aaa;">
<p><strong>Floating 1</strong></p>
<p>Fusce eu tellus. Aenean ipsum. Nam et diam sed urna rhoncus facilisis. Phasellus metus neque, auctor non, aliquet eu, venenatis nec, mi. Donec ultricies auctor lacus. Nullam dolor ante, aliquet et, aliquet ac, dignissim sed, urna. Duis pharetra nisi vitae ipsum. Etiam sit amet nulla. Nulla pellentesque odio in mi. Sed ac massa. Donec tempus magna tempus ante. Nam velit quam, sagittis in, aliquam quis, suscipit quis, arcu.</p>
</p></div>
<p>Fusce eu tellus. Aenean ipsum. Nam et diam sed urna rhoncus facilisis.</p>
</div>
<p>The only downside I&#8217;ve found is that you can&#8217;t also absolutely position any children to be outside of the box, or it will hide!  Other than that (<a href="http://savethedevelopers.org">IE6 doesn&#8217;t behave correctly</a>, and <em>I don&#8217;t care</em>), everything works great!</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/css/hide-overflowing-floats/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Almost There</title>
		<link>http://mcarthurgfx.com/blog/blog/almost-there/</link>
		<comments>http://mcarthurgfx.com/blog/blog/almost-there/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 18:28:01 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/blog/almost-there/</guid>
		<description><![CDATA[<p><a title="Design Sneak Peak" rel="attachment wp-att-49" href="http://mcarthurgfx.com/blog/blog/almost-there/"><img alt="Design Sneak Peak" src="http://mcarthurgfx.com/wp-content/uploads/2008/11/preview.jpg"/></a></p>]]></description>
			<content:encoded><![CDATA[<p>I apologize for the lull in my posting schedule.  At my <a href="http://pinacol.com" target="_blank">day job</a>, I&#8217;m busy making our <a href="http://www.blazonco.com" title="Blazonco" target="_blank">CMS</a> have a fully usable blogging addon.  As a starter, it just had very basic date-based posting for our customers.  But now the need has arrived to <em>turn it into a powerhouse equivalent to WordPress</em>.</p>
<p>I&#8217;m currently finishing out all details of blogging, major and minor.  <em>Because the ease and power of the CMS, I&#8217;ve ported my design over from this site</em>.  It&#8217;s sitting on its own, brand new site.  I&#8217;m just waiting to make our next update to the live servers, as well as making some design upgrades.</p>
<p>Here&#8217;s a sneak peak at the design improvements.</p>
<p><a href="http://mcarthurgfx.com/blog/blog/almost-there/design-sneak-peak/" rel="attachment wp-att-49" title="Design Sneak Peak"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/11/preview.jpg" alt="Design Sneak Peak" /></a></p>
<p>I should have myself moved over by next week, and blogging will resume.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/blog/almost-there/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Use Trac Effectively</title>
		<link>http://mcarthurgfx.com/blog/freelance/how-to-use-trac-effectively/</link>
		<comments>http://mcarthurgfx.com/blog/freelance/how-to-use-trac-effectively/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 17:14:49 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[Freelance]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/freelance/how-to-use-trac-effectively/</guid>
		<description><![CDATA[<p>Trac is a wonderful piece of software for use developers. I use it at my day job, and wanted to show how we use it effectively:</p>
<p><a href="http://mcarthurgfx.com/blog/freelance/how-to-use-trac-effectively"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/10/tickets.thumbnail.jpg" alt="List of bugs ordered by most severe" /></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://trac.edgewall.org/" target="_blank">Trac</a> is a wonderful piece of software for use developers.  It has a large amount of customization, if you dig into it.  If you&#8217;re not in the know, here&#8217;s what it&#8217;s great for:</p>
<ul>
<li>It has an easy bug tracker, allowing bugs to be marked for different components and assigned to programmers, and reassigned for testing, and so forth.</li>
<li>You can mark these bugs (or enhancements) for different milestones, so you can setup a timeline of new releases and patches.</li>
<li>It can connect to your svn repository, and use the logging from svn to update tickets.</li>
<li>It has it&#8217;s own wiki section, allowing documentation and general information to be setup about different parts of the project.</li>
<li>You can setup time tracking, to keep track how long certain bugs and new enhancements take, so you can charge accordingly.</li>
<li>It&#8217;s <strong>Open Source</strong>!</li>
</ul>
<p>So, we use it internally at my <a href="http://www.blazonco.com" title="Blazonco" target="_blank">day job</a>, and needed to show <em>how we use it effectively</em>:</p>
<p><a href="http://mcarthurgfx.com/wp-content/uploads/2008/10/tickets.jpg" title="Bugs ordered by most severe"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/10/tickets.jpg" alt="Bugs ordered by most severe" /></a></p>
<p>Clicking on a ticket from the list brings up the details:</p>
<p><a href="http://mcarthurgfx.com/wp-content/uploads/2008/10/beer_ticket.jpg" title="There is no more beer"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/10/beer_ticket.jpg" alt="There is no more beer" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/freelance/how-to-use-trac-effectively/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Implementing ArrayAccess for Easy Array Usage</title>
		<link>http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/</link>
		<comments>http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 17:15:05 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/</guid>
		<description><![CDATA[<p><a title="arrayaccess.jpg" rel="attachment wp-att-44" href="http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/"><img alt="arrayaccess.jpg" src="http://mcarthurgfx.com/wp-content/uploads/2008/10/arrayaccess.jpg"/></a></p>]]></description>
			<content:encoded><![CDATA[<p>This past week, I was using PHP&#8217;s DOMDocument class to work with some XML generation.  It&#8217;s pretty similar to Javascript&#8217;s DOM manipulation.  The XML I was generating was a bunch of items with key attributes. (&lt;item key=&#8221;object&#8221;&gt;) Learning how to extend a new class so that it behaves like a PHP Array made me <em>outright excited for PHP</em>!  Let&#8217;s delve into the magic.</p>
<p><a href="http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/44/" rel="attachment wp-att-44" title="arrayaccess.jpg"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/10/arrayaccess.jpg" alt="arrayaccess.jpg" /></a></p>
<p>I needed to create in XML:</p>
<pre>&lt;item key="object"&gt;DOMAIN&lt;/item&gt;</pre>
<p>I needed to create items in this nature for various different properties to communicate to a domain API.  <em>Since this is essentially a hash, or associate array, it&#8217;d be awesome if it could work like one.</em>  <strong>Well, it can!</strong></p>
<pre>$dt_assoc['object'] = 'DOMAIN';</pre>
<p>After writing my class, that&#8217;s how I&#8217;m able to create XML items.  It all lies in using an object that implements the <em>ArrayAccess interface</em>.  Doing so gives the object functions that are called when you try to access the object like an array.  So by implementing the functions, you can write custom logic that happens, besides just simply holding a value like normal arrays do.</p>
<p>The above statement calls <a href="http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html#_details">ArrayAccess::offsetSet($offset,$value);</a>, so here&#8217;s the implementation.</p>
<pre> public function offsetSet($offset,$value) {
	$item = $this-&gt;dom-&gt;createElement('item',$value);
	$attr = $this-&gt;dom-&gt;createAttribute('key');
	$item-&gt;appendChild($attr);
	$text = $this-&gt;dom-&gt;createTextNode($offset);
	$attr-&gt;appendChild($text);

	$this-&gt;items[$offset] = $item;
	$this-&gt;el-&gt;appendChild($item);
}</pre>
<p>Using DOMDocument to create XML for me, I create an item wrapped around the value, create an attribute called key, and give text of the offset.  So instead of needing to write this process out for every new item, I just need to set a new key and value of an object that implements this interface.</p>
<p>There are 3 other methods to the interface, as well as one more function I define to export the data of this object into XML.</p>
<p>The constructor takes a name of an element to wrap all the items in, as well as the instance of the DOMDocument. You need to hold onto the original instance.  This class creates an XML element of <em>&lt;$name&gt;items go here&lt;/$name&gt;</em>.</p>
<p>The array $data is an associate array in the object to keep track of all the values of every item.  The array items keeps a reference to the item nodes in the DOMDocument, so they can be easily removed with <em>offsetUnset()</em>.</p>
<p>offsetExists simply checks if there is an item with the key of offset, and offsetGet returns the value of the item with the appropriate key.</p>
<p>Lastly, toXML() is a new function unrelated to ArrayAccess, but useful to me, which just returns the DOMElement that is holding onto all these items.</p>
<p>Here&#8217;s the full class.  You&#8217;ll find <a href="http://php.net/domdocument" target="_blank">DOMDocument </a>and <a href="http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html#_details" target="_blank">ArrayAccess</a> useful as well, if you need to do something similar.</p>
<pre>&lt;?php
	class SRSData implements ArrayAccess {

		var $el;
		var $dom;
		var $data;
		var $items;

		public function __construct($name,$dom) {
			$this-&gt;dom = $dom;
			$this-&gt;el = $this-&gt;dom-&gt;createElement($name);
		}

		public function offsetExists($offset) {
			return isset($this-&gt;items[$offset]);
		}

		public function offsetGet($offset) {
			return $this-&gt;data[$offset];
		}

		public function offsetSet($offset,$value) {
			if($value instanceof SRSData) {
				$item = $this-&gt;dom-&gt;createElement('item');
				$item-&gt;appendChild($value-&gt;toXML());
			} else {
				if(!empty($value))
					$item = $this-&gt;dom-&gt;createElement('item',$value);
				else
					$item = $this-&gt;dom-&gt;createElement('item');
			}
			$this-&gt;data[$offset] = $value;
			$attr = $this-&gt;dom-&gt;createAttribute('key');
			$item-&gt;appendChild($attr);
			$text = $this-&gt;dom-&gt;createTextNode($offset);
			$attr-&gt;appendChild($text);

			$this-&gt;items[$offset] = $item;
			$this-&gt;el-&gt;appendChild($item);
		}

		public function offsetUnset($offset) {
			$this-&gt;el-&gt;removeChild($this-&gt;items[$offset]);
			unset($this-&gt;data[$offset]);
			unset($this-&gt;items[$offset]);
		}

		public function toXML() {
			return $this-&gt;el;
		}

	}
?&gt;</pre>
<p>Learning this was one of those time where I was actually gleeful about programming.  Hopefully, this helps show how powerful PHP really is.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/php/implementing-arrayaccess-for-easy-array-usage/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cross-browser addEvent Function without Frameworks</title>
		<link>http://mcarthurgfx.com/blog/javascript/cross-browser-addevent-function-without-frameworks/</link>
		<comments>http://mcarthurgfx.com/blog/javascript/cross-browser-addevent-function-without-frameworks/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 23:31:30 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/javascript/cross-browser-addevent-function-without-frameworks/</guid>
		<description><![CDATA[<p><a title="addEvent" rel="attachment wp-att-42" href="http://mcarthurgfx.com/?attachment_id=42"><img alt="addEvent" src="http://mcarthurgfx.com/wp-content/uploads/2008/10/addevent.jpg"/></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://mcarthurgfx.com/blog/javascript/cross-browser-addevent-function-without-frameworks/addevent/" rel="attachment wp-att-42" title="addEvent"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/10/addevent.jpg" alt="addEvent" /></a></p>
<p>Javascript is a very event-driven language.  Considering the interactivity of the medium (the web), the most common need of Javascript by far is to respond to user interaction.  Unfortunately, a problem that plagues Javascript that most other languages take for granted, is that the standard library isn&#8217;t very standard.  So even the way to add event listeners in Javascript, a function of utmost importance, is implemented differently among browsers.  So how do we fix this without a framework?</p>
<p>If you haven&#8217;t done much Javascript programming without a framework, it&#8217;s easy to miss what all a framework is doing for you.  And sometimes, there isn&#8217;t enough Javascript functionality needed to warrant the overhead kilobytes of a framework.   So, what really goes on underneath?  Well, I&#8217;m not going to show you everything, because a lot of <em>convenience can be put into wrapper functions</em>.</p>
<p>To simply make adding event listeners easier in all browsers, we make one function, I&#8217;ll call it addEvent &#8217;cause I&#8217;m used to Mootools.</p>
<pre>window.addEvent = function(event, target, method) {
	if (target.addEventListener) {
		target.addEventListener(event, method, false);
	} else if (target.attachEvent) {
		target.attachEvent("on" + event, method);
	}
}</pre>
<p>It takes for parameters a <em>string of the event</em>, the <em>target element</em>, and the <em>function to execute</em>.  We&#8217;re checking which function exists in the browser.  addEventListener is most standard browsers, and attachEvent is for IE.  It also takes care of adding &#8220;on&#8221; to the start of the Event for IE.</p>
<p>Now then, you can access this function in another function by calling window.addEvent().</p>
<pre>var someFunc = function() {
	var el = document.getElementById('someEl');
	window.addEvent('click',el,funtion(){

		//do stuffz...

	});

	var formEl = document.getElementById('someFormEl');
	window.addEvent('submit',formEl,funtion(){

		//do stuffz...

	});
}</pre>
<p>This is the simplest way, as we just create a global function.  Frameworks will add to the convenience by allowing you to call Element.addEvent instead of passing the element as a parameter.  But this works fine when you just have a few simple Events to watch in a simple script.</p>
<p>Any tips or convenience that you add to your own addEvent function?</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/javascript/cross-browser-addevent-function-without-frameworks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Life-changing Event</title>
		<link>http://mcarthurgfx.com/blog/blog/life-changing-event/</link>
		<comments>http://mcarthurgfx.com/blog/blog/life-changing-event/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 03:16:18 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/blog/life-changing-event/</guid>
		<description><![CDATA[<p>So tomorrow is one of the biggest life-changing events to happen to me. And to <em>celebrate in my own geek fashion</em>, I wrote a script countdown, but WordPress hates me and won't let me post it in the excerpt.  Hit the jump to see!</p>]]></description>
			<content:encoded><![CDATA[<p>So tomorrow is one of the biggest life-changing events to happen to me.  And to <em>celebrate in my own geek fashion</em>, I wrote a <a href="javascript:(function(){var B=document.createElement('p');B.setAttribute('style','font-size:40px;color:#000;position:fixed;top:0');document.body.appendChild(B);function A(){var E=new Date('Sep 12, 2008 16:00:00');var D=new Date();if(E&gt;D){var I=E-D;var H=parseInt(I/(1000*60*60*24));I-=1000*60*60*24*H;var C=parseInt(I/(1000*60*60));I-=1000*60*60*C;var F=parseInt(I/(1000*60));I-=1000*60*F;var G=parseInt(I/(1000));B.innerHTML=H+':'+C+':'+F+':'+G}else{B.innerHTML='&lt;h2&gt;I\'m married!!!&lt;/h2&gt;'}}A();setInterval(A,1000)})()" title="4:00PM, Sep 12, 2008">script countdown.</a></p>
<p>It can be bookmarked and then activated from any page.  It will countdown and then reveal my new life.</p>
<h5>Cheers, Sean!</h5>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/blog/life-changing-event/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making a Toggle All Checkbox</title>
		<link>http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox/</link>
		<comments>http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 18:18:18 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox/</guid>
		<description><![CDATA[<p><a href="http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox" title="Toggle All Checkboxes"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/09/toggle.jpg" alt="Toggle All Checkboxes" /></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox" title="Toggle All Checkboxes"><img src="http://mcarthurgfx.com/wp-content/uploads/2008/09/toggle.jpg" alt="Toggle All Checkboxes" /></a></p>
<p>You&#8217;ve seen them on other sites.  When you have a long list of checkboxes, and you know you need to check them all.  Thankfully, the developer gave you a &#8220;Toggle All&#8221; and &#8220;Check All&#8221; box at the top, so you don&#8217;t have to check each individual box.  They don&#8217;t make or break an application, but they <em>subconsciously make a better user experience</em>.  It&#8217;s really easy to get this working, and I can show you how to do it in Mootools, Prototype, and even without any framework, since if this is the only thing you need in Javascript, you need the overhead of a framework to do this.</p>
<p>I recently had to make a permissions page for a CMS, allowing users to set the permissions of new users for various features.  Adding a way to toggle all options would be nice, because there&#8217;s a lot of options!  Here it is with <em>Mootools goodness</em>, thought for the CMS I wrote it with Prototype:</p>
<pre>$('toggler').addEvent('click',function (e) {
	var toggle = $('toggler').checked;
	$$('#formId input[type=checkbox]').each(function(check) {
		check.checked = toggle;
	});
});</pre>
<p>I&#8217;ve added an event listener to the checkbox with id &#8220;toggler&#8221;, listening for a <code>click</code>.  When clicked, I store its <code>checked</code> state (true if checked, false if unchecked), and then set every other checkbox to the same state.  This way of doing it, as opposed to just using <code>check.checked = !check.checked</code> (using NOT to pick the opposite state), prevents double toggling the Toggler checkbox.  Here it is originally in <em>Prototype:</em></p>
<pre>$('toggler').observe('click',function (e) {
	var toggle = $('toggler').checked;
	$$('#formId input[type=checkbox]').each(function(check) {
		check.checked = toggle;
	});
});</pre>
<p>The only difference between Mootools and Prototype is the <code>attachEventListener</code> implementation: <em>Mootools uses <code>addEvent</code>, Prototype uses <code>observe</code></em>.</p>
<p>And like I said in the beginning, if this is your only need of Javascript (unlikely), I recommend not bogging down the page with a framework, and <em>use native Javascript</em>.  It&#8217;s really not hard.  Here it is:</p>
<pre>var toggleFunction = function() {
	var toggle = document.getElementById('toggler').checked;
	var inputs = document.getElementsByTagName('input');
	for(var i = 0; i &lt; inputs.length &lt; i++) {
		if(inputs[i].type == 'checkbox') {
			inputs[i].checked = toggle;
		}
	}
}

//If Good Browser
if(window.addEventListener) {
	document.getElementById('toggler').addEventListener('click',toggleFunction(),false);
// If IE
} else if (window.attachEvent) {
	document.getElementById('toggler').attachEvent('onclick',toggleFunction());
}</pre>
<p>If you&#8217;re used to only using frameworks, this looks like more work.  And it is, slightly.  But if you&#8217;ve done any kind of programming, you realize <em>it&#8217;s just a simple <code>for</code> loop</em>, used normally.</p>
<p>Of course, this does show-off some of <strong>the things frameworks do for you</strong>.  The framework will check the type of input for me, instead of me having to write an <code>if</code> statement.  It also gives you a cross-browser <code>addEvent</code> function, instead of having to check for <em>browser inconsistancies</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/javascript/making-a-toggle-all-checkbox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make YUI&#8217;s Editor More Pluggable</title>
		<link>http://mcarthurgfx.com/blog/javascript/make-yui-editor-more-pluggable/</link>
		<comments>http://mcarthurgfx.com/blog/javascript/make-yui-editor-more-pluggable/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 18:05:11 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/javascript/make-yui-editor-require-less-setup/</guid>
		<description><![CDATA[<p>I got to play around a little bit with YUI&#8217;s (I pronounce it <em>yoo-ey</em>) <a href="http://developer.yahoo.com/yui/editor/" title="YUI Editor">Rich Text Editor</a> as I implemented a low-level CMS for one of my current projects.  I&#8217;ve used TinyMCE a-plenty, and wanted to check out YUI&#8217;s implementation because theoretically <em>YUI is far easier to extend.</em> One thing that tripped me up was the styling, which in retrospect I should have noticed, but it irked me, so I solved it in my <strike>lazy</strike> efficient programmer fashion.</p>]]></description>
			<content:encoded><![CDATA[<p>I got to play around a little bit with YUI&#8217;s (I pronounce it <em>yoo-ey</em>) <a href="http://developer.yahoo.com/yui/editor/" title="YUI Editor">Rich Text Editor</a> as I implemented a low-level CMS for one of my current projects.  I&#8217;ve used TinyMCE a-plenty, and wanted to check out YUI&#8217;s implementation because theoretically <em>YUI is far easier to extend.</em> One thing that tripped me up was the styling, which in retrospect I should have noticed, but it irked me, so I solved it in my <strike>lazy</strike> efficient programmer fashion.</p>
<p>After ripping the stylesheet and scripts straight out of the YUI demo, and start up my page, you notice that the Editor loads in, but it looks way wacked.   That&#8217;s because I forgot the subtle declaration of a new class on the body element:</p>
<pre>&lt;body class="yui-skin-sam"&gt;</pre>
<p>Once finally catching this, I felt disappointed that the YUI Editor didn&#8217;t do that in the Editor.render() function that you call to display the editor.  My opinion of plug-ins is that they should be as pluggable as possible.  <em>The less I have to do to make a plug-in work, the better the plug-in, in my opinion.</em></p>
<p>Having to add a class name in HTML that&#8217;s <em>just as easily done in Javascript</em> didn&#8217;t make sense.  If Javascript wouldn&#8217;t is disabled and isn&#8217;t able to add the class to the document body, then the class is useless anyways, since the YUI Editor won&#8217;t be using it.</p>
<pre>var myEditor = new YAHOO.widget.Editor('msgpost', {
    height: '300px',
    width: '522px',
    dompath: true,
    animate: true
});
myEditor.render();
YAHOO.util.Event.onDOMReady(function(){ YAHOO.util.Dom.addClass(document.body,'yui-skin-sam')});</pre>
<p>The last line uses YUI&#8217;s onDOMReady function to wait until the DOM is accessible, then uses YUI&#8217;s Dom object to add <em>&#8220;yui-skin-sam&#8221; </em>to the body tag.</p>
<p>This may seem like a useless modification, but now, I can simply copy and paste this code snippet, or even externalize and just include the Javascript file, into any page I want, and not have to remember to add a class to my HTML.</p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/javascript/make-yui-editor-more-pluggable/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Styling Status Messages for Your Application</title>
		<link>http://mcarthurgfx.com/blog/css/styling-status-messages-for-your-application/</link>
		<comments>http://mcarthurgfx.com/blog/css/styling-status-messages-for-your-application/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 15:39:52 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://mcarthurgfx.com/blog/css/styling-status-messages-for-your-application/</guid>
		<description><![CDATA[<p>Status messages are quite common in web applications.  It can be very useful for the user to get feedback from his input.  And it's a good idea to style some status messages in a way that makes sense according to their message.</p>
<blockquote class="info">This is an Informational message.</blockquote>]]></description>
			<content:encoded><![CDATA[<p>Status messages are quite common in web applications.  It can be very useful for the user to get feedback from his input.  And it&#8217;s a good idea to style some status messages in a way that makes sense according to their message.</p>
<blockquote class="info"><p>This is an Informational message.</p></blockquote>
<p>The following are common messages used for during form submittal, or even simply navigating certain dynamic pages.</p>
<blockquote class="error"><p>This is an Error message.</p></blockquote>
<blockquote class="warning"><p>This is a Warning message.</p></blockquote>
<blockquote class="success"><p>This is a Success message.</p></blockquote>
<p>It&#8217;s not to hard to style these as such.  I felt that semantically, these messages could be blockquotes, as they stand out from the rest of the context.  I&#8217;ve used the <a href="http://www.famfamfam.com/lab/icons/silk/" title="Silk Icon Set">Silk</a> icons, as is pretty common, but <a href="http://wefunction.com/2008/07/function-free-icon-set/" title="weFunction Icon Set">weFunction</a> also has great icons for this use.</p>
<pre>
.success, .error, .warning, .info {
	border-top:1px dotted;
	border-bottom:1px dotted;
	color:#777;
	margin-bottom:3px;
	padding:5px 40px;
}
.success {
	background:#dfd url('images/success.gif') no-repeat 10px center;
	border-color:#9d8;
}
.error {
	background:#fdd url('images/error.gif') no-repeat 10px center;
	border-color:#d98;
}
.warning {
	background:#ffc url('images/warning.gif') no-repeat 10px center;
	border-color:#dd7;
}
.info {
	background:#ccf url('images/info.gif') no-repeat 10px center;
	border-color:#89d;
}
</pre>
<p>I&#8217;ve done them fairly straightforward.  They all get the same spacing, with enough padding to allow the background icon to be on the left.  They also get a dotted border on top and bottom.  And <em>information is blue</em>, <em>success is green</em>, <em>warning is yellow</em>, and <em>error is red</em>.</p>
<p>That&#8217;s how I do it.  <strong>How do you style your status messages?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://mcarthurgfx.com/blog/css/styling-status-messages-for-your-application/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
