<?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>Travis Beck &#187; javascript</title>
	<atom:link href="http://travisjbeck.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://travisjbeck.com/blog</link>
	<description>The Modern Web</description>
	<lastBuildDate>Fri, 06 Apr 2012 19:33:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MooTools HideThisMessage plugin</title>
		<link>http://travisjbeck.com/blog/javascript/mootools-hidethismessage-plugin/</link>
		<comments>http://travisjbeck.com/blog/javascript/mootools-hidethismessage-plugin/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 05:07:00 +0000</pubDate>
		<dc:creator>Travis</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://travisjbeck.com/blog/?p=74</guid>
		<description><![CDATA[I&#8217;ve written another MooTools plugin (class) for facilitating the hiding of various help messages you may have scattered throughout your app. Download the script and demoView the demoDownload the MooTools framework What does it do? The basic premise is that you have a help message on one or more of your site&#8217;s pages which are [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve written another MooTools plugin (class) for facilitating the hiding of various help messages you may have scattered throughout your app.
</p>
<p><span id="more-74"></span></p>
<p>
<a onclick="javascript: pageTracker._trackPageview('/files/hidethismessage.zip'); " href="/files/HideThisMessage.zip">Download the script and demo</a><br/><a href="/demos/hidethismessage/">View the demo</a><br/><a href="http://mootools.net/download">Download the MooTools framework</a></p>
<p><h2>What does it do?</h2>
<p>The basic premise is that you have a help message on one or more of your site&#8217;s pages which are incredibly useful the first few times the user visits that section.  However, once the user understands how that page works, that once useful help message is now just in the way.   So to solve this problem you might put a &#8220;Close this message&#8221; or &#8220;Hide this message&#8221; link in there so that your users can get it off their screen since it&#8217;s no longer needed. That&#8217;s where HideThisMessage comes in.
</p>
<p>
HideThisMessage finds all the elements with the className you specify, hides them (with or without a snazzy animation) when the user clicks on the link within that element with the className you specify, and remembers via cookies which elements should be shown and which should be hidden/removed.  Each element needs its own unique id and the user must have cookies enabled.
</p>
<h2>Linking the required JavaScript files</h2>
<p>
You need to link the appropriate JavaScript files in the head of your document. HideThisMessage requires <a href="http://mootools.net/download">MooTools 1.2</a> or MooTools 1.11.  I&#8217;ve created classes for both versions. It also requires the <a href="http://mootools.net/docs/Plugins/Hash.Cookie">Hash.Cookie</a> Plugin for MooTools which i&#8217;ve included  in my download package for your convenience. Place the following lines before the closing<code> head </code> tag in the top of your document.
</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/path_to/mootools.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/path_to/hidethismessage.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>
Make sure you call the hidethismessage script AFTER mootols or it won&#8217;t work
</p>
<h2>Initializing HideThisMessage</h2>
<p>
Now you need to call the HideThisMessageclass passing to it the variables needed to get the plugin working. HideThisMessage takes 2 required and 1 optional arguments.
</p>
<ul class="argumentsList">
<li>
     <code>elementClass:</code> REQUIRED (String)(default: &#8216;hideWindow&#8217;) &#8211; The ClassName of the element that is to be hid.
   </li>
<li>
   <code>hideBtnClass:</code> REQUIRED (String)(default: &#8216;hideWindowBtn&#8217;)   &#8211; The ClassName of the link contained within elementClass that, when clicked, hides the window.
   </li>
<li>
<code>animate:</code> OPTIONAL (Boolean)(default: true)  &#8211; Whether or not the window animates closed when the hideBtnClass link is clicked.
</li>
</ul>
<p>
Now lets create a new instance of our HideThisMessage class.
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">         window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</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: #003366; font-weight: bold;">var</span> myMessageHider <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> HideThisMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
               elementClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'hideWindow'</span><span style="color: #339933;">,</span>   
               hideBtnClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'hideWindowBtn'</span><span style="color: #339933;">,</span>
               animate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</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;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Public Methods</h2>
<p>
HideThisMessage only has 1 public method
</p>
<ul class="argumentsList">
<li><code>reset()</code> Resets the hidden status of all hidden windows.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://travisjbeck.com/blog/javascript/mootools-hidethismessage-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The ImageSlider MooTools class</title>
		<link>http://travisjbeck.com/blog/javascript/the-imageslider-mootools-class/</link>
		<comments>http://travisjbeck.com/blog/javascript/the-imageslider-mootools-class/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 15:30:07 +0000</pubDate>
		<dc:creator>Travis</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://travisjbeck.com/blog/?p=53</guid>
		<description><![CDATA[I&#8217;ve written a proper MooTools class for the slider I made for the portfolio page that slides the thumbnails back and forth. Here&#8217;s how it works. Download the script and demo View the demo Download the MooTools framework Setting up your Markup In order for the script to work you need to setup your document [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve written a proper MooTools class for the slider I made for the <a href="http://travisjbeck.com/portfolio.html">portfolio </a>page that slides the thumbnails back and forth.  Here&#8217;s how it works.
</p>
<p><span id="more-53"></span></p>
<p>
<a href="/files/ImageSlider.zip" onclick="javascript: pageTracker._trackPageview('/files/ImageSlider.zip'); ">Download the script and demo</a><br />
<a href="/demos/imageslider/">View the demo</a><br />
<a href="http://mootools.net/download">Download the MooTools framework</a></p>
<p><h2>Setting up your Markup</h2>
<p>
In order for the script to work you need to setup your document to mask out the elements you&#8217;re sliding.  here&#8217;s a diagram of what I&#8217;m talking about:
</p>
<p>
<img src="http://travisjbeck.com/blog/wp-content/uploads/2008/10/imageslider-markup-setup.gif" alt="" title="imageslider-markup-setup" width="500" height="289" class="aligncenter size-full wp-image-55" />
</p>
<p>Example markup:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;maskDiv&quot;</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderContainer&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 6<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sliderElement&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Element 7<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;leftBtn&quot;</span>&gt;</span>move left<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;rightBtn&quot;</span>&gt;</span>move right<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>
Example CSS:
</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#maskDiv</span><span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sliderContainer</span><span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.sliderElement<span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">15px</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">70px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Linking the required JavaScript files</h2>
<p>
Now that your document is setup correctly to use the ImageSlider, you need to link the appropriate javascript files in the head of your document.  ImageSlider requires <a href="http://mootools.net/download">MooTools 1.2</a>. Place the following lines before the closing <code>head</code> tag in the top of your document.
</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/path_to/mootools.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/path_to/imageslider.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>
Make sure that you call the ImageSlider script AFTER Mootools or it won&#8217;t work.
</p>
<h2>Initializing the ImageSlider</h2>
<p>
Now you need to call the ImageSlider class passing to it the variables needed to get the ImageSlider working. ImageSlider takes 5 required and 3 optional arguments.
</p>
<ul class="argumentsList">
<li><code>objToSlide:</code> REQUIRED (String)   &#8211; The id of the holder element that will be sliding.</li>
<li><code>sliderElements:</code> REQUIRED (String)   &#8211; The type of elements contained within the slider can be any html element(div, p, a, span).</li>
<li><code>numOfElementsToSlide:</code> OPTIONAL (Number)   &#8211; Number of elements to slide.</li>
<li><code>numOfElementsShown:</code> REQUIRED (Number)   &#8211; Number of elements visible or unmasked</li>
<li><code>leftBtn:</code> REQUIRED (String)   &#8211; The ID of the element that when clicked will slide your imageslider left.</li>
<li><code>rightBtn:</code> REQUIRED (String)   &#8211; The ID of the element that when clicked will slide your imageslider right.</li>
<li><code>easing:</code> OPTIONAL (Function) &#8211; The type of easing to use on transition (<a href="http://mootools.net/docs/Fx/Fx.Transitions#Fx-Transitions">more info on easing</a>).</li>
<li><code>onSlideComplete:</code> OPTIONAL (Function) &#8211; Callback Function to fire once sliding is completed. returns index.</li>
</ul>
<p>
Now lets create a new ImageSlider using our markup example above:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</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: #003366; font-weight: bold;">var</span> mySlider <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ImageSlider<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      objToSlide<span style="color: #339933;">:</span> <span style="color: #3366CC;">'sliderContainer'</span><span style="color: #339933;">,</span>
      sliderElements<span style="color: #339933;">:</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span>
      numOfElementsToSlide<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> 
      numOfElementsShown<span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> 
      leftBtn<span style="color: #339933;">:</span> <span style="color: #3366CC;">'leftBtn'</span><span style="color: #339933;">,</span>
      rightBtn<span style="color: #339933;">:</span> <span style="color: #3366CC;">'rightBtn'</span><span style="color: #339933;">,</span>
      onSlideComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #006600; font-style: italic;">//callback function stuff here</span>
      <span style="color: #009900;">&#125;</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;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
You&#8217;ll notice that I&#8217;m using the <code>domready</code> Event to instantiate our new ImageSlider.  This is a custom MooTools Event which will execute when the DOM has loaded. To ensure that DOM elements exist when the code attempting to access them is executed, they should be placed within the &#8216;<a href="http://mootools.net/docs/Utilities/DomReady">domready</a>&#8216; event.
</p>
<p>
<a href="/demos/imageslider/">View the demo</a> of our newly created ImageSlider.
</p>
<h2>Public Methods</h2>
<p>
ImageSlider only has 1 public method.
</p>
<ul class="argumentsList">
<li><code>slideTo(position:Number)</code> This will slide to the position you specify where position is the number of the element you want to show up within the masked area.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://travisjbeck.com/blog/javascript/the-imageslider-mootools-class/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

