<?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>Not A n00b &#187; plugin</title>
	<atom:link href="http://notan00b.com/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://notan00b.com</link>
	<description>Tutorials, Scripts, and Rants</description>
	<lastBuildDate>Wed, 12 May 2010 08:08:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress Database Tutorial posted!</title>
		<link>http://notan00b.com/2009/08/wordpress-database-tutorial-posted/</link>
		<comments>http://notan00b.com/2009/08/wordpress-database-tutorial-posted/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 19:18:37 +0000</pubDate>
		<dc:creator>pyr0t3chnician</dc:creator>
				<category><![CDATA[Post]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[creation]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plug-in]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-db.php]]></category>

		<guid isPermaLink="false">http://notan00b.com/?p=190</guid>
		<description><![CDATA[I just created an in depth tutorial that covers the entire wp-db.php file and how WordPress uses it, and how to use it to create plug-ins for WordPress.  It is posted in the tutorials section, here.  Check it out and let me know what you think.
]]></description>
			<content:encoded><![CDATA[<p>I just created an in depth tutorial that covers the entire wp-db.php file and how WordPress uses it, and how to use it to create plug-ins for WordPress.  It is posted in the tutorials section, <a href="http://notan00b.com/tutorials/">here</a>.  Check it out and let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://notan00b.com/2009/08/wordpress-database-tutorial-posted/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>jQuery &#8211; Lesson 2</title>
		<link>http://notan00b.com/2009/07/jquery-lesson-2/</link>
		<comments>http://notan00b.com/2009/07/jquery-lesson-2/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 00:05:25 +0000</pubDate>
		<dc:creator>pyr0t3chnician</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[child]]></category>
		<category><![CDATA[click]]></category>
		<category><![CDATA[each]]></category>
		<category><![CDATA[hover]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[parent]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sibling]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://notan00b.com/?p=125</guid>
		<description><![CDATA[I have been working pretty intensely with jQuery and have learned a lot.  It is a difficult language to work with because it is picky.  But once you understand it, it is actually quite simple to manipulate.
Today I want to cover parent/child/sibling relationships and how jQuery can be very effective here.  I [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working pretty intensely with jQuery and have learned a lot.  It is a difficult language to work with because it is picky.  But once you understand it, it is actually quite simple to manipulate.</p>
<p>Today I want to cover parent/child/sibling relationships and how jQuery can be very effective here.  I spent a while trying to figure this out in javascript, and yes, it is completely do-able in just a little more code, but jQuery always has the UI plugins that make coding super easy.  Let me show you some code I currently have:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rows'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span>
         <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rows-add-class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
         <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rows-add-class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.section2, .section3, .section4, .section5'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;viewClient.php?id=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.small'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.section1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.small'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.small'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">else</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.small'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#cb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I know this looks complicated, but lets break it down line by line.</p>
<ol>
<li><code>$('div').each(function (){</code></li>
<p>This code goes through each &lt;div&gt; in my code, and with each &lt;div&gt; it finds, it executes a function, which is the remainder of the code.</p>
<li><code>if($(this).is('#rows')) {</code></li>
<p>So when it finds a
<div>, it checks to see if the &lt;div&gt; that was found &#8220;is&#8221; (or has the property of) &#8216;#rows&#8217;.  The # in the front means the &lt;div&gt; id.  If there is a &#8220;.&#8221; in front, it means the &lt;div&gt; class.  If there is nothing, then it means that it is a tag itself.  So when it finds the div tag with the id=&#8221;rows&#8221;, it will execute the following code.</p>
<li><code>$(this).hover(</code></li>
<p>Simply, it adds a hover class to the div with the id=&#8221;rows&#8221;.  When you add a hover, you need to have it do 2 things, mouseover and mouseout.  So the next parts of the code describe mouseover and mouseout respectively.</p>
<li><code>function() { $(this).addClass('rows-add-class'); },</code></li>
<p>So on mouseover, it will execute this function, which is, it will add a class called &#8216;rows-add-class&#8217; to the div we have selected.  Note the &#8220;,&#8221; at the end, which means that this is the next line is also part of hover().</p>
<li><code>function() { $(this).removeClass('rows-add-class'); }</code></li>
<p>On mouseout, it will remove the class.  We could have it add another class or give us an alert if we wanted, but typically when you hover over something with the mouse, you want to emphasize/change something, and when you move it out, you want it to return to normal.</p>
<li><code>);</code></li>
<p>So finally we start closing stuff up.  This closes up the hover statement.</p>
<li><code>$(this).children('.section2, .section3, .section4, .section5').click(function(){</code></li>
<p>Here we are getting into children.  If you have a div, and inside that div, you have multiple other divs, you may want to do something to those divs.  What I am doing here is adding an &#8220;onclick&#8221; function to the children divs with classes &#8220;section2&#8243;, &#8220;section3&#8243;, &#8220;section4&#8243;, &#8220;section5&#8243;.  Notice how here I used &#8216;.section1, etc&#8217;, the &#8220;.&#8221; signifies classes.  So this is statement, I am adding an &#8220;onclick&#8221; to the child tags under &#038;ltldiv id=&#8221;rows&#8221;&gt;.  The next line will tell me what exactly I am going to do when I click on one of those 4 child divs.</p>
<li><code>window.location.href= "viewClient.php?id="+$(this).siblings('.small').children('#cb').val();</code></li>
<p>Wow, thats a long line of code!  window.location.href= is a redirect, so basically, when you click the divs, it will act like a link and take you somewhere else.  It looks like it will take you to a viewClient.php page with the id= whatever $(this).siblings(&#8216;.small&#8217;).children(&#8216;#cb&#8217;).val(); equals.  It gets a little confusing here.  So &lt;div id=&#8221;rows&#8221;&gt; is set up with a few children tags, and those children have a few tags.  All of the children are siblings.  So if I was to click on one of the children, say one with the class &#8220;section2&#8243;, I want to find out info about his sibling, with the class &#8220;small&#8221;.  Now &#8220;small&#8221; has a child with the id=&#8221;cb&#8221;.  Cb stands for check box.  Basically, when you click on the div, it will find its sibling&#8217;s, child&#8217;s value, which is the ID # we are looking for.  At the bottom of the page you can see the layout of the div with children and grandchildren.  So to recap, this line redirects us to &#8220;viewClient.php?id=1&#8243;.<br />
Why did I do this?  Well I am pulling data out of a database, and I don&#8217;t want to make a link in every div so they have to click on the words to be redirected.  These couple lines of code make it much easier for the user to redirect to the page they want.</p>
<li><code>});</code></li>
<p>Just closing up the &#8220;onclick&#8221; that we added to those 4 divs.</p>
<li><code>$(this).children('.section1').click(function(){</code></li>
<p>Here is the div with class=&#8221;section1&#8243; and we are adding a different &#8220;onclick&#8221; function to it.  Let&#8217;s see what we want it to do.</p>
<li><code>if($(this).siblings('.small').children('#cb').attr('checked'))</code></li>
<p>This looks similar to line 8 where we locate the sibling with the class=&#8221;small&#8221; and the child it has with the id=&#8221;cb&#8221;.  So we are locating our checkbox.  If our checkbox is checked (.attr(&#8216;checked&#8217;) returns true if checked, false if not checked), we are going to do something.  That was pretty easy now that siblings and children make a little sense.</p>
<li><code>$(this).siblings('.small').children('#cb').attr('checked',false);</code></li>
<p>Ok, so if it was checked, all this will do is set &#8216;checked&#8217; to false, meaning it will un-check the check box.  </p>
<li><code>else</code></li>
<p>If it wasn&#8217;t checked, then what.</p>
<li><code>$(this).siblings('.small').children('#cb').attr('checked',true);</code></li>
<p>Well then, check it!  So why did I add this code?  Well just to add it really.  It makes clicking the check box slightly easier.  They can click on this div, and it will check/uncheck the checkbox for them.
</ol>
<p>The rest of the code simply closes up the function that I created.  This is something I would have it do on start up, rather than allowing the user to click a button to enable these features.</p>
<p>This is the HTML markup that was used in the code.  The classes are easily created and is something you can do on your own.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;rows&quot;&gt;
   &lt;div class=&quot;small&quot;&gt;&lt;input type=&quot;checkbox&quot; id=&quot;cb&quot; value=&quot;1&quot;&gt;&lt;/div&gt;
   &lt;div class=&quot;section1&quot;&gt;1 (Clients ID)&lt;/div&gt;
   &lt;div class=&quot;section2&quot;&gt;Bob (Clients Name)&lt;/div&gt;
   &lt;div class=&quot;section3&quot;&gt;123 Fast Lane (Clients Address)&lt;/div&gt;
   &lt;div class=&quot;section4&quot;&gt;12345 (Clients Zip)&lt;/div&gt;
   &lt;div class=&quot;section5&quot;&gt;(123)555-1212 (Clients Phone)&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>Pretty simple layout causes pretty intense code.  Hopefully my explanation shows you some of what jQuery can do for you and provides a plan of attack for you.  If you want any help, let me know and I will be willing to explain something, review your code, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://notan00b.com/2009/07/jquery-lesson-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
