<?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>Tutorial Dog &#187; Javascript Tutorial</title>
	<atom:link href="http://tutorialdog.com/topic/javascript_tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://tutorialdog.com</link>
	<description>Man's best friend for learning</description>
	<lastBuildDate>Mon, 24 Aug 2009 05:36:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Ruby on Rails to Create A Twitter-Like Message Form</title>
		<link>http://tutorialdog.com/using-ruby-on-rails-to-create-a-twitter-like-message-form/</link>
		<comments>http://tutorialdog.com/using-ruby-on-rails-to-create-a-twitter-like-message-form/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 18:54:51 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Javascript Tutorial]]></category>
		<category><![CDATA[Ruby on Rails Tutorials]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[web app]]></category>

		<guid isPermaLink="false">http://tutorialdog.com/?p=439</guid>
		<description><![CDATA[This tutorial will show you how to create a twitter message form that counts down the 140 characters and also allows you to input a message within the URL of the webpage as well. What's cool about Ruby on Rails is instead of writing javascript to recalculate the message length, we'll use Rails to automatically generate the correct javascript so that each time the field changes, the count is recalculated all through the controller object.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="ruby_on_rails_logo_3" src="http://tutorialdog.com/wp-content/uploads/2009/08/ruby_on_rails_logo_3.jpg" alt="ruby_on_rails_logo_3" width="200" />This tutorial will show you how to create a twitter message form that counts down the 140 characters and also allows you to input a message within the URL of the webpage as well. What&#8217;s cool about <a href="http://rubyonrails.org/">Ruby</a> on <a href="http://wiki.rubyonrails.org/">Rails</a> is instead of writing javascript to recalculate the message length, we&#8217;ll use Rails to automatically generate the correct javascript so that each time the field changes, the count is recalculated all through the controller object. Download the <a href="http://tutorialdog.com/wp-content/uploads/2009/08/twitter.zip">project code here</a>.</p>
<p>Firstly, I&#8217;ll assume you have ruby on rails installed and have create a new project. You&#8217;ll also need a basic knowledge of how Rails works, and how Rails utilizes the principle of Model-View-Controller (MVC). Having said that, create a new project and create a new controller file called <em>message_controller.rb</em>. We&#8217;ll first take care of an initial message specified in the URL of the page. Add this code to the file:</p>
<pre>class MessageController &lt; ApplicationController

  def index
    if params[:txt]
      @txt = params[:txt]
    else
      @txt = "";
    end
    @count = 140 - @txt.length()
  end

end</pre>
<p>The index method first check to see if a message was specified in the URL. If the a message was specified, then it sets the @txt instance variable to the string. If not, then the variable is set to an empty string. The count is also calculated here for the initial web page view.</p>
<p>Now we need to set up the view for the message controller, create a message folder in the views folder and create a new file called <em>index.rhtml</em> in this new folder. Copy this code to the file:</p>
<pre>&lt;h1&gt;Message&lt;/h1&gt;

&lt;% form_tag :action =&gt; 'stuff' do -%&gt;
	&lt;%= text_field_tag :message_field,value=@txt %&gt;
&lt;% end -%&gt;

&lt;div id='count'&gt;
	&lt;%= @count %&gt;
&lt;/div&gt;

&lt;%= observe_field(
	:message_field,
	:url =&gt;{:action =&gt;"update_message_length"},
	:frequency=&gt;1,
	:with =&gt; 'message',
	:update=&gt;:count ) -%&gt;</pre>
<p>The parts to focus on here are the text_field_tag and the observe_filed method. The div count is where the remaining count will be displayed. Looking at the text_field_tag, :message_field is the id of the tag, and the value is set to the @txt that was declared in the Message Controller. The observe_field method will automatically generate the javascript ajax code that will update the count tag. The parameters follow as such:</p>
<ol>
<li>:message_field &#8211; indicates which field is observed</li>
<li>:url &#8211; Decides which action is sent to the message controller. (More on that latter)</li>
<li>:frequency &#8211; Every time the field changes, make a AJAX request</li>
<li>:with &#8211; this will help us get the text in the field</li>
<li>:update &#8211; decides where the contents of the AJAX response goes</li>
</ol>
<p>At this point we need to go ahead and add the &#8220;update_message_length&#8221; method in the message controller. This function will be called every time the filed value is change as specified by the observe_field method. Append the following function to the controller:</p>
<pre>  def update_message_length
    pop = params[:message]
    count = 140 - pop.length()
    render :text =&gt;  count
  end</pre>
<p>This function gets the message include in the message parameter, and sends out the new count. One small, but vital part not to forget is to create a layout file that includes the needed javascript framework so this is included. Create a new file in the view/layouts folder called: message.html.erb. Add this code to the file:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&gt;
  &lt;title&gt;Posts: &lt;%= controller.action_name %&gt;&lt;/title&gt;
  &lt;%= stylesheet_link_tag 'scaffold' %&gt;
  &lt;%= javascript_include_tag :defaults %&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;p style="color: green"&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;

&lt;%= yield %&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Thats its! Now if you go to the URL <em>http://localhost:3000/message</em>, you&#8217;ll get a blank field, or you can include an initial message by <em>http://localhost:3000/message?txt=message+here</em>. Incase you have a flaw in your project, or are lazy, here is a copy of the <a href="http://tutorialdog.com/wp-content/uploads/2009/08/twitter.zip">working project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialdog.com/using-ruby-on-rails-to-create-a-twitter-like-message-form/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Javascript Dock Carousel Using Mootools (Part 2)</title>
		<link>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-2/</link>
		<comments>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-2/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 12:00:36 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Javascript Tutorial]]></category>
		<category><![CDATA[Photoshop Tutorial]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[jscript]]></category>
		<category><![CDATA[Mac OS X Tutorial]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[net tutorial]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://tutorialdog.com/?p=291</guid>
		<description><![CDATA[This tutorial is the second part of a tutorial that will build a javascript carousel that imitates the Mac OS X dock. In part one, we build a mock up in Photoshop and exported the nessecary images. In this part, we'll take those images and build it into a HTML &#038; CSS. Then we'll use javascript to make if interact.]]></description>
			<content:encoded><![CDATA[<p>This tutorial is the second part of a tutorial that will build a javascript carousel that imitates the Mac OS X dock. In part one, we build a <a href="http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-1/">mock up in Photoshop and exported the nessecary images</a>. In this part, we&#8217;ll take those images and build it into a HTML &amp; CSS. Then we&#8217;ll use javascript to make if interact.</p>
<p><a class="demo" href="/icon_carousel/">Demo</a> <a class="files" href="/icon_carousel/icon_carousel.zip">Files</a></p>
<p><strong>Step 1: The HTML</strong> To keep things organized, we&#8217;ll seperate the files into there own folders. So we&#8217;ll have a &#8220;js&#8221; folder to keep all the Javascript files, an &#8220;images&#8221; folder to hold all the webpage images, and a &#8220;icons&#8221; folder to hold the icon images. What needs to be in the HTML? Well, the links to move the stage left and right, the stage and all the icons and finally the text image. The &#8220;wrapper&#8221; class you will see later enables the icons on the next slide to hide. The icons are there own list elements.</p>
<div class="bannerimagead">Javascript applications run better with specialized <a href="http://www.webhostingsearch.com/jsp-web-hosting.php">Java hosting</a>. It ensures smooth, error free work of Java based websites or any Java script for that matter.</div>
<pre>
<span style="letter-spacing: 0.0px;">&lt;div id="stage-container"&gt;
 <span style="white-space: pre;"> </span>&lt;img src="images/text.gif" alt="image" width="111" height="24" /&gt;
 <span style="white-space: pre;"> </span>&lt;a id="moveleft"&gt;Left&lt;/a&gt;
 <span style="white-space: pre;"> </span>&lt;a id="moveright"&gt;Right&lt;/a&gt;
 <span style="white-space: pre;"> </span>&lt;div id="wrapper"&gt;&lt;ul id="items"&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/1.png" alt="image" width="32" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/2.png" alt="image" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/3.png" alt="image" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/4.png" alt="image"/&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/5.png" alt="image" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/10.png" alt="image"/&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/6.png"/&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/7.png"/&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/8.png" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;li&gt;&lt;a&gt;&lt;img src="icons/9.png" /&gt;&lt;/a&gt;&lt;/li&gt;
 <span style="white-space: pre;"> </span>&lt;/ul&gt;&lt;/div&gt;
 &lt;/div&gt;</span></pre>
<p>Now lets set up the header of the HTML document. We wan&#8217;t an XHTML tranistional document so that all the javascript is compliant and works. We need to reference the Mootools library, and the javascript that makes the stage work as well as the css file. We&#8217;ll deal with getting those files later.</p>
<pre>&lt;script src="js/mootools-12-core.js" type="text/javascript"&gt;&lt;!--mce:0--&gt;&lt;/script&gt; &lt;!-- MOOTOOLS 1.2  --&gt;
&lt;script src="js/mootools-12-more.js" type="text/javascript"&gt;&lt;!--mce:1--&gt;&lt;/script&gt; &lt;!-- MOOTOOLS 1.2  --&gt;
&lt;script src="js/dock.js" type="text/javascript"&gt;&lt;!--mce:2--&gt;&lt;/script&gt; &lt;!--   IMAGE GALLERY   --&gt;</pre>
<p><strong>Step 2: The CSS</strong> The trickiest part of the CSS is understanding the fact that we&#8217;re making the ul extend beyond the &#8216;div id=&#8221;wrapper&#8221;&#8216;. The image below explains how the tags appear with the CSS. The ul element extends because the class &#8220;items&#8221; has a width of 5000px, and the &#8220;wrapper&#8221; id has an overflow of hidden. The buttons are floated on either side of the stage, and the text is hidden with the text-indent attribute. To get a tag to conform to specified widths and heights, we use the &#8216;display: block&#8217; attribute.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/part2_1.gif" alt="image" width="540" height="308" /></div>
<pre>body{
background:#232323;
color:white;
}
#stage-container{
margin: 50px auto;
width: 420px;
}
#stage-container .text{text-align: center;}
#stage-container a{outline: none;}
/* — STAGE — */
#stage-container #wrapper{
overflow:hidden;
margin: 0px auto;
width:352px;
height:55px;
background: url(images/stage2.jpg);
position: relative;
}
#stage-container #items{
margin:0px;
padding:0px 6px;
list-style:none;
width:5000px;
position: relative;
}
#stage-container #items li{
float:left;
list-style:none;
margin-right:5px;
padding: 6px 6px;
margin-top: 5px;
}
/* — BUTTONS — */
#stage-container #moveleft{
float: left;
background: url(images/left.gif);
}
#stage-container #moveright{
background: url(images/right.gif);
float: right;
}
#stage-container #moveright,#moveleft{
height: 20px;
width: 20px;
display: block;
z-index: 10;
text-indent: -3000em;
margin-top: 18px;
}</pre>
<p><strong>Step 3: The Javascript</strong> First, we&#8217;ll be using the newly released <a href="http://mootools.net/">Mootools 1.2</a> for this javascript. Mootools is a &#8220;compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API.&#8221; We&#8217;ll be utilizing the scroller class and the Fx classes to achieve the entire effects on the icons. Like almost all mootools scripts, we need to enclose the javascript in a dom ready action. What this does is not let the javascript work until all the javascript is completely loaded by the user.</p>
<p class="code">window.addEvent(&#8217;domready&#8217;, function() {<br />
// Your code here<br />
});</p>
<p>The first part of javascript just deals with moving the stage left and right. We need to tell the javascript where to slide the stage, if it can slide the stage left or right and how much to slide. When a button is clicked it triggers an event to move the slide left or right depending on which is clicked. The slides must figure out though if it can move left or right. We don&#8217;t want to move left if there is no icons to the left of the current slide. These issues are what the variables at the top of the javascript deal with.</p>
<p>The image in step 2 will help illustrated how the javascript is working. The unordered list element (ul id=&#8221;items&#8221;) is being shifted left and right by the javascript (thats why is larger than the stage). The shift is triggered by a hyperlink tag (&#8217;a').</p>
<pre>var slides = 2; // CHANGE THIS TO THE NUMBER OF SLIDES
var pos = 0; // default setting, start at the first(0) pixel
var offset = 346; // How many pixels the slider should move to get to the next slide
var currentslide = 1; // first slide is the default slide
var items = $('items'); // items variable for the id 'items' in the html
var fx = items.effects({
duration: 800,
transition: Fx.Transitions.linear
}); // the way the items transition is described here
/* Scroll Object Initialized */
var scroll = new Fx.Scroll('wrapper', {
offset:{'x':0, 'y':0},
transition: Fx.Transitions.Elastic.easeOut
}); // the scroll stage is set up here, and each movement will be 'Elastic'
// other tranistions could be linear, quadratic, ect.
/* Trigger to move the slide left */
//when the #moveleft link is clicked, this tells the scroll to move left
$('moveleft').addEvent('click', function(event) {
event = new Event(event).stop(); // don't go to the actual link described in the href
if(currentslide == 1) return; // can't go more left than the first
currentslide--; // currentslide is one less than before
pos += -(offset); // slide the stage left by the offset's size
/* lower the opactiy, slide, then raise back opacity */
fx.start({
'opacity': .3 // the opacity of the icons will become 30 %
}).chain(function(){
this.start.delay(800, this, { 'opacity': 1 }); // bring the icons back to 100% opacity
scroll.start(pos); // move the stage to the new position
});
});
$('moveright').addEvent('click', function(event) {
event = new Event(event).stop();
if(currentslide &gt;= slides) return;
currentslide++;
pos += offset;
fx.start({
'opacity': .3
}).chain(function(){
this.start.delay(800, this, { 'opacity': 1 });
scroll.start(pos);
});
});
scroll.toLeft(); // We'll initalize the stage to left most position</pre>
<div class="rightmargin"><img src="/wp-content/uploads/carousel/visual.png" alt="Javascript Visual of Events" /></div>
<p>The next part of the Javascript strictly deals with what happens when you move the cursor over an icon. We want to make the icon bigger. When the cursor leaves the icon, we need to readjust the icon to different size settings.</p>
<pre>$$('.icon').each(function(item){  // for each icon, apply the follow events
item.addEvent('mouseover', function(event) { // when the icon is moused over, enlarge it
var fx2 = item.effects({
duration: 200,
transition: Fx.Transitions.linear
}); // initialize the icon transition properties
fx2.start({
'width': 40,
'height':40,
'margin-top': '-2',
'margin-left': '-5'
});
});
item.addEvent('mouseleave', function(event) { // when the icon is left by the mouse, reset icon
var fx2 = item.effects({duration: 200, transition: Fx.Transitions.linear });
fx2.start({
'width': 32,
'height':32,
'margin-top': '0',
'margin-left': '0'
});
});
});</pre>
<p><strong>Conclusion</strong> Thats all that&#8217;s need to create a dock carousel. The icons in the demo are kindly provided by <a href="http://www.jonasraskdesign.com/">Jonas Rask</a> and <a href="http://tutorialdog.com/">Devin Ross</a>. I&#8217;ve implemented the dock in the <a href="http://tutorialdog.com/resources/">resources section of Tutorial Dog</a> were you can download icons that I&#8217;ve created.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Javascript Dock Carousel Using Mootools (Part 1)</title>
		<link>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-1/</link>
		<comments>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-1/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 12:00:16 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Javascript Tutorial]]></category>
		<category><![CDATA[Photoshop Tutorial]]></category>
		<category><![CDATA[carousel]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://tutorialdog.com/?p=290</guid>
		<description><![CDATA[This tutorial will take you through creating the initial mockup in Photoshop, and creating a usable carousel that imitates the Mac OS X Leapard dock. This tutorial we'll acquiant you well with creating a slick button, and using the shape tools. We want to deal with shape layers instead of pixel because of the non-destructive nature of shapes. Non-desctructive shapes means you can edit and scale without distortion.]]></description>
			<content:encoded><![CDATA[<div class="floatl"><!--adsense#sr--></div>
<p><a href="http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-2/">Follow part 2 of this tutorial here.</a> This tutorial will take you through creating the initial mockup in Photoshop, and creating a usable carousel that imitates the Mac OS X Leapard dock. This tutorial we&#8217;ll acquiant you well with creating a slick button, and using the shape tools. We want to deal with shape layers instead of pixel because of the non-destructive nature of shapes. Non-desctructive shapes means you can edit and scale without distortion.</p>
<h3>Step 1</h3>
<p>Create a photoshop and create a new document 540px x 308px. Fill the background with #232323.</p>
<p>Take the Rounded Rectangle Tool, set it to a 5px radius and create an object that is 350px by 50px. Make the color of this shape layer #303030. Make sure you have the tool set to the &#8220;Shape Layers&#8221; option instead of the paths option. That way, you are creating non-destructive shapes so you can go back and edit &amp; reference them later without compromising distortion. Next, type out &#8220;CAROUSEL&#8221; (or whatever you like) at the top of the document with the color #080808. Find a good serif font like &#8220;Myriad Pro&#8221;. Apply the Inner Shadow below layer style to the text.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/dropshadow.gif" alt="image" width="550" /><br />
<img src="/wp-content/uploads/carousel/1.gif" alt="image" width="540" /></div>
<h3>Step 2: Buttons</h3>
<p>Next, we need to create buttons that will move the carousel from left to right. First, create a 20px circle shape with the color #232323 using the ellipse tool. Apply the following Bevel &amp; Emboss and Gradient Overlay layer styles.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/bevel.gif" alt="image" width="550" /><br />
<img src="/wp-content/uploads/carousel/gradientoverlay.gif" alt="image" width="550" /><br />
<img src="/wp-content/uploads/carousel/button1.gif" alt="image" width="129" height="129" /></div>
<p>Now create a new white layer for the reflection. Start by creating another circle shape, and use Direct Selection Tool to mend the shape into the shape you see below. Move the handles (the line that is asymptotic to the path) of each point to change the curvature of the path. Set this layer to blending mode Overlay, and an opacity of 82%.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/button2.gif" alt="image" width="184" height="184" /></div>
<p>Next we need arrows to specify the direction. Take the pencil tool set to a 1px brush, and create a arrow out of pixels ontop of the button. Apply the following Drop Shadow and Inner Shadow to give the look that the arrow is imbedded in the button.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/arrow1.gif" alt="image" width="550" /><br />
<img src="/wp-content/uploads/carousel/arrow2.gif" alt="image" width="550" /></div>
<p>Finally for this step, group these three layers in a group and duplicate the group. Then with the group selected in the layer palette, Edit &gt;&gt; Transform &gt;&gt; Flip Horizontal. Place the buttons on either side of the stage.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/buttons.gif" alt="image" width="540" height="308" /></div>
<p><!--adsense#bannerimg2--></p>
<h3>Step 3: Stage</h3>
<div class="right"><img src="/wp-content/uploads/carousel/stage2.gif" alt="image" width="241" height="49" /></div>
<p>Now we&#8217;ll recreate a the Leopard dock. Fist we need the Leopard wallpaper. Place the image inside the Photoshop document, and use the shape made in step one to mask of the wallpaper layer. To do this, select the shape, and right click and pick &#8220;Make Selection&#8221;. Now with the selection, make a mask on the wallpaper layer. Click the little link connecting the mask to the image, to disassociate the mask with the layer, so you can move the image around without moving the mask around with it. Place the wallpaper in the correct place.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/stage1.gif" alt="image" width="550" />
</div>
<p>The next step is to create the shelf, create a white rectangle shape, and use the Direct Selection Tool to select the corners, and transform the shape to give it the perspective of a shelf. Again, we want to use the path of the original stage layer. This time though copy that path and paste the path into the shelf layer. With both paths selected, click the &#8220;Intersect Shapes area&#8221; button. Set the opacity of the stage to 51%.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/stage3.gif" alt="image" width="556" height="379" /></div>
<p>Finally, we need to create a swoosh across the stage. Again, we want to create a shape, this time, use the pen tool to create the shape over the stage. Set the opacity of this layer to 14%.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/stage4.gif" alt="image" width="506" height="273" /></div>
<h3>Step 4: Icons</h3>
<p>This step is more for mocking up the final product which we&#8217;ll be finished in Part 2, but drag 32px icons onto the dock. Space them appropriately.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/icons.gif" alt="image" width="540" height="308" /></div>
<p>When creating the icons for Part 2, we need to make sure that the icons are transparent and that the size of the icons are 40px or greater. To get best looking transparent icon, make sure you use the PNG-24 setting in the Save to Web palette. This will create the best looking transparent icon. If you export with GIF, you tend to get more jagged edges that look bad.</p>
<h3>Step 5: Slicing and Exporting for the Web</h3>
<p>Next we need to slice up the document to get it ready for the web. There should only be 4 slices in this document: the two buttons, the stage and the text. You can name each slice by taking Slice Selection Tool and double clicking on a slice. A panel will pop up with input to rename the slice, that way when you export, it will automatically name the images.</p>
<div class="imagef"><img src="/wp-content/uploads/carousel/slice1.gif" alt="image" width="541" height="309" /></div>
<p>Now that you&#8217;ve sliced the image, go to File &gt;&gt; Save to Web&#8230; You can change the export setting for each slice, but for this particular document leave each slice as a gif. For more info on exporting, check out this article that walks through <a href="http://tutorialdog.com/a-guide-to-exporting-to-the-web-in-photoshop/">exporting for the web in Photoshop</a>. When you go to save, make sure you change the option &#8220;Slice:&#8221; from &#8220;All Slices&#8221; to &#8220;All User Slices&#8221; so you don&#8217;t have unnecessary slices.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialdog.com/javascript-dock-carousel-using-mootools-part-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Javascript Image Gallery Using Mootools (Part 2)</title>
		<link>http://tutorialdog.com/javascript-image-gallery-using-mootools-part-2/</link>
		<comments>http://tutorialdog.com/javascript-image-gallery-using-mootools-part-2/#comments</comments>
		<pubDate>Mon, 12 May 2008 15:02:14 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Javascript Tutorial]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://tutorialdog.com/?p=188</guid>
		<description><![CDATA[Last time, I provided a reasonably decent solution for creating a HTML friendly Javascript image gallery using mootools. After taking in some of its faults, and learning more about javascript, I've rewritten the whole code, and have came up with a new version, a simple, easy to use gallery that everyone can use.]]></description>
			<content:encoded><![CDATA[<p><a title="Javascript Image Gallery Part 1" href="http://tutorialdog.com/javascript-image-gallery-using-mootools/">Last time</a>, I provided a reasonably decent solution for creating a HTML friendly Javascript image gallery using mootools. After taking in some of its faults, and learning more about javascript, I&#8217;ve rewritten the whole code, and have came up with a new version, a simple, easy to use gallery that everyone can use.</p>
<p>
<a class="demo" title="Javascript Image Gallery Demo" href="http://tutorialdog.com/image_gallery/sample.html">Demo</a> </p>
<p><a class="files" href="http://tutorialdog.com/image_gallery/image_gallery.zip">Download Files</a>
</p>
<h3>Features</h3>
<ol>
<li><strong>Anybody Can Use It</strong> &#8211; If Javascript is confusing to you, no worries. This solution doesn&#8217;t require any javascript knowledge. The only work require is one variable in the javascript &amp; the actual HTML for the images.</li>
<li><strong>Thumbnails</strong> &#8211; Unlike the previous version, you can now embed a different/smaller image in the previews.</li>
<li><strong>Preview Slider</strong> &#8211; Easily slide through dozens of photos.</li>
<li><strong>HTML friendly</strong> &#8211; Like the last time, this solution doesn&#8217;t compromise google bots or people with javascript disabled.</li>
<li><strong>Better Transitions</strong> &#8211; The large photos ease in &amp; ease out when switching</li>
<li><strong>Image Descriptions</strong> &#8211; You have the ability to include a caption with every image</li>
</ol>
<p><strong>HTML</strong> To set up the gallery properly, we need to write the necessary HTML to create the large image stage and the thumbnail slides. For the thumbnail slides, we&#8217;ll use an unordered list (&lt;ul&gt;) and list-items with links. The link tag will provide the path to the larger image to show on the stage and the img tag displays the thumbnail. The &#8220;moveleft&#8221; and &#8220;moveright&#8221; links move the slides left and right on the page.</p>
<div class="code">
<pre name="code" class="html">
&lt;div id=”img_gallery”&gt;
	&lt;div id=”fullimg”&gt;
		&lt;img src=”images/ajax-loader.gif” alt=”loading” class=”loading” width=”24? height=”24? /&gt;
	&lt;/div&gt;
	&lt;a href=”#” id=”moveleft”&gt;Left&lt;/a&gt;
	&lt;div id=”wrapper”&gt;
		&lt;ul id=”items”&gt;
			&lt;li&gt;
				&lt;a href=”LARGE IMAGE” id=”first” class=”item”&gt;
					&lt;img class=”thumb” alt=”img” src=”THUMNAIL”/&gt;
				&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				&lt;a href=”LARGE IMAGE” class=”item”&gt;
					&lt;span&gt;DESCRIPTION HERE&lt;/span&gt;
					&lt;img class=”thumb” alt=”" src=”THUMBNAIL”/&gt;
				&lt;/a&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;a id=”moveright” href=”#”&gt;Right&lt;/a&gt;
&lt;/div&gt;&lt;br clear=”all”/&gt;
</pre>
</div>
<p>Now you need set up the top part of the web page. For this part, we’ll need to reference the <a href="http://tutorialdog.com/image_gallery/imagegallery.css">css for the gallery</a>, the <a href="http://tutorialdog.com/image_gallery/js/imagegallery.js">javascript for the image gallery</a> and the <a href="http://mootools.net/">mootools 1.2</a> release. Also, it’s always safe to declare the webpage DOCTYPE as XHTML so that it’s javascript compliant.</p>
<div class="code">
<pre class="html" name="code">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
	&lt;title&gt;Javascript Image Gallery Using Mootools&lt;/title&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;  

	&lt;script src="mootools-12b.js" type="text/javascript"&gt;&lt;/script&gt; &lt;!-- MOOTOOLS 1.2 BETA --&gt;
	&lt;script src="imagegallery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;!--   IMAGE GALLERY   --&gt;
	&lt;link rel='stylesheet' href='imagegallery.css' type='text/css' /&gt;

&lt;/head&gt;
</pre>
</div>
<p><strong>CSS</strong> Now comes the cascading style sheet to create the design for the image gallery. The trickiest parts of the CSS is definitely the slider. For the slider, we create the buttons for moving the slider forward and back, and thumbnail area. The unordered list tag holds the thumbnails, but what makes the slider work is that the width of the unordered list is very large and the parent div of the unordered list (called the #wrapper) is the width of what will actually be displayed. That way the javascript can move the position of the unordered list to show different thumbnails. The key to the #wrapper CSS is the “overflow: hidden” attribute which allows the thumbnails to stretch out horizontally and not be in view.</p>
<div class="code">
<pre name="code" class="css">
body{ background:black; color:white; }
#img_gallery{ margin:50px auto; width:500px; }
#img_gallery a{ outline:none; border:none; }
#img_gallery a img{border:none;}

/* --- IMAGE STAGE */
#fullimg{
	width:500px;
	overflow:hidden;
	height:380px;
}
#fullimg img{ width:500px; }
#fullimg p, #fullimg span{
	position:absolute;
	background:black;
	opacity:.5;
	color:white;
	margin:0px;
	width:500px;
	padding:6px;
	font-size:11px;
	font-family:Verdana, Arial, Helvetica, sans-serif;
}

/* --- SLIDER --- */
#img_gallery #wrapper{
	overflow:hidden;
	padding:4px 2px;
	width: 460px;
	float:left;
	height:50px;
	background-color:#181818;
	position: relative;

}

#items{
	margin:0px 0px;
	padding:0px;
	list-style:none;
	width:50000px;
	position: relative;
	letter-spacing:0em;
}
#items li{
	float:left;
	list-style:none;
	margin-right:2px;
}
#items .thumb{
	width:75px;
	height:50px;
	cursor:pointer;
	margin:0px;
	padding:0px;
}
#items .large{
	display:none;
	position:absolute;
}
#fullimg .loading{
	width: 24px;
	height: 24px;
}
#fullimg .thumb{display:none;}

#items .item  p, #items .item  span{
	display:none;
	text-indent: -2000em;
}
#moveleft, #moveright{
	margin:0px;
	height:58px;
	color: white;
	width: 16px;
	text-indent: -2000em;
	text-decoration: none;
	z-index: 1000;
	display:block;
	cursor: pointer;
	float:left;
}
#moveleft{background: url('images/left.gif');}
#moveright{background: url('images/right.gif');}
#moveleft:hover, #moveright:hover{ background-position:bottom; }
</pre>
</div>
<p><strong>Javascript</strong> The javascript is built for the most recent build of the mootools beta 1.2. I’ve heavily commented the code which you can <a href="http://tutorialdog.com/image_gallery/js/imagegallery.js">view here</a>. The only thing that needs to be changed in the javascript is the number of slides in the gallery.
</p>
<div class="code">
<pre name="code" class="js">
var slides = 2;
</pre>
</div>
<p><strong>License</strong> You are NOT allowed to distribute this software without attribution. This work is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons Attribution-Share Alike 3.0 United States License</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialdog.com/javascript-image-gallery-using-mootools-part-2/feed/</wfw:commentRss>
		<slash:comments>165</slash:comments>
		</item>
		<item>
		<title>Javascript Image Gallery Using Mootools</title>
		<link>http://tutorialdog.com/javascript-image-gallery-using-mootools/</link>
		<comments>http://tutorialdog.com/javascript-image-gallery-using-mootools/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 05:05:57 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Javascript Tutorial]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://tutorialdog.com/javascript-image-gallery-using-mootools/</guid>
		<description><![CDATA[This free image gallery based on javascript is a quick &#38; easy solution. Implementing the demo doesn't requre knowledge of any javascript. In this article, I'll explain and breakdown the javascript that runs the image gallery using the javascript framework Mootools.]]></description>
			<content:encoded><![CDATA[<p><em>Be sure to check out the </em><a href="http://tutorialdog.com/javascript-image-library-using-mootools-part-2/"><em>second iteration of the image gallery</em></a><em>.</em></p>
<p>This free image gallery based on javascript is a quick &amp; easy solution. Implementing the demo doesn&#8217;t requre knowledge of any javascript. In this article, I&#8217;ll explain and breakdown the javascript that runs the image gallery using the javascript framework Mootools.<br />
<script src="http://tutorialdog.com/wp-content/themes/tutorialdog3/js/mootools.svn.compressed.js" type="text/javascript"></script><br />
<script src="http://tutorialdog.com/wp-content/uploads/2008/01/imagegallery.js" type="text/javascript"></script></p>
<style type="text/css" media="screen">@import "http://tutorialdog.com/wp-content/uploads/2008/01/style.css";</style>
<h3>Demo:</h3>
<div id="imagegallery">
<div id="items">
<div class="item"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/167461515_05807d9fdc.jpg" alt="Doggie Image 1" />   </p>
<p>Image 1</p>
<p> </p>
</div>
<div class="item"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/229805603_e84bcf23bf.jpg" alt="Image 2" />   </p>
<p>Image 2</p>
<p> </p>
</div>
<div class="item"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/248397811_0e7f1991be.jpg" alt="Dog in Window" />   </p>
<p>Image 3</p>
<p> </p>
</div>
<div class="item"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/860213842_62e9bc4bcc.jpg" alt="Two Dogs" />   </p>
<p>Image 4</p>
<p> </p>
</div>
<div class="item"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/1058831139_3dbe9e47b9.jpg" alt="Dog on Leash" />   </p>
<p>Image 5</p>
<p> </p>
</div>
<p> </p>
</div>
<div id="large">
<div class="info">Click A Thumbnail Above</div>
<p> </p>
</div>
<p><!-- Image Gallery by http://tutorialdog.com --></p>
</div>
<p class="download"><strong><a title="Image Gallery" href="http://tutorialdog.com/wp-content/uploads/2008/01/imagegallery.zip"> Download  Image Gallery</a></strong></p>
<hr /><a href="http://mootools.net/"><img src="http://tutorialdog.com/wp-content/uploads/2008/01/mootools.gif" alt="Mootools Logo" align="left" /></a>The Javascript image gallery is built from <a href="http://mootools.net/">Mootools</a>, an open-source object-oriented Javascript framework. If you&#8217;ve seen some cool graphical interactions you wouldn&#8217;t expect on a web page, chances are they are Mootools or another similiar framework like jQuery.<br />
<!--adsense#bannerimg--><br />
<strong>The Javascript:</strong></p>
<pre name="code" class="javascript">
window.addEvent('domready', function() {
	var drop = $('large');
	var dropFx = drop.effect('background-color', {wait: false});
	$$('.item').each(function(item){
		item.addEvent('click', function(e) {
			drop.removeEvents();
			drop.empty();
			var a = item.clone();
			a.inject(drop);
			dropFx.start('7389AE').chain(dropFx.start.pass('ffffff', dropFx));
		});
	});
});
</pre>
<p><strong>The HTML:</strong></p>
<pre class="html" name="code">
&lt;div id="imagegallery"&gt;
	&lt;div id="items"&gt;
		&lt;div class="item"&gt;
			&lt;img src="images/167461515_05807d9fdc.jpg" alt="image" /&gt;
			&lt;p&gt;Image 1&lt;/p&gt;
		&lt;/div&gt;
		&lt;div class="item" &gt;
			&lt;img src="images/229805603_e84bcf23bf.jpg" alt="image" /&gt;
			&lt;p&gt;Image 2&lt;/p&gt;
		&lt;/div&gt;
		&lt;div class="item"&gt;
			&lt;img src="images/248397811_0e7f1991be.jpg" alt="image" width="373" height="500" /&gt;
			&lt;p&gt;Image 3&lt;/p&gt;
		&lt;/div&gt;
		&lt;div class="item" &gt;
			&lt;img src="images/1058831139_3dbe9e47b9.jpg" alt="image" width="500" height="333" /&gt;
			&lt;p&gt;Image 4&lt;/p&gt;
		&lt;/div&gt;
		&lt;div class="item" &gt;
			&lt;img src="images/860213842_62e9bc4bcc.jpg" alt="image" width="500" height="333" /&gt;
			&lt;p&gt;Image 5&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id="large"&gt;
		&lt;div class="info"&gt;Click A Thumbnail on the Left&lt;/div&gt;
	&lt;/div&gt;
	&lt;!– Image Gallery by http://tutorialdog.com –&gt;
&lt;/div&gt;
</pre>
<h3>How the Javascript Works</h3>
<p>The javascript you see above was the only part I needed to create- the rest is provided by the mootools framework. The first line, &#8220;window.addEvent(&#8217;domready&#8217;, function() {&#8221; and the closing brackets at the end is require of all (almost all) mootools scripts. The two variables at the beginning (var drop &amp; var dropFX) govern the element with id=&#8221;large&#8221; in the html and the background color of that element.</p>
<p>The next part is just a function to get the image from the &#8216;items&#8217; part of the html to the &#8216;large&#8217; part of the html. &#8220;$$(&#8217;.item&#8217;).each(function(item){&#8221; basically says that for each html element identified under the class &#8216;item&#8217;, apply the following conditions to element. Now there is only one condition which would be &#8220;item.addEvent(&#8217;click&#8217;, function(e) {&#8221;. This line of code says that when the item is clicked, apply the follow instructions in the functions brackets. If you wanted to, you could change the word &#8216;click&#8217; to &#8216;moueover&#8217; and instead of needing to click on each photo, you would simply need put the mouse over the thumbnail image to get the large image to appear and essential get the function to trigger.</p>
<p>The code inside that &#8216;click&#8217; function essential clears the items in the &#8216;large&#8217; element and creates a clone of that &#8216;item&#8217; class that was clicked and puts (injects) it into the &#8216;large&#8217; element in the html.</p>
<h3>Conclusion</h3>
<p>If you&#8217;re just looking for a quick yet cool javascript image gallery, then download the included zip file and tweak the css to your liking. If you want to find out more about Mootools and creating really cool web apps, then check out the <a href="http://demos.mootools.net/">mootool demos</a> which shows a variety of cool uses and a lot more functionality.<br />
<!--adsense#bannerimg2--></p>
]]></content:encoded>
			<wfw:commentRss>http://tutorialdog.com/javascript-image-gallery-using-mootools/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
	</channel>
</rss>
