<?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>computeraxe &#187; CSS</title>
	<atom:link href="http://computeraxe.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://computeraxe.com</link>
	<description>wordpress, php, mysql, jquery, css</description>
	<lastBuildDate>Tue, 15 May 2012 10:55:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Pause and Play Buttons for jQuery Slideshow</title>
		<link>http://computeraxe.com/pause-and-play-buttons-for-jquery-slideshow/</link>
		<comments>http://computeraxe.com/pause-and-play-buttons-for-jquery-slideshow/#comments</comments>
		<pubDate>Tue, 15 May 2012 07:05:07 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=1252</guid>
		<description><![CDATA[Continuing our slideshow journey with jQuery Cycle plugin, we&#8217;d like to improve our slider by adding two more buttons. Last time we looked at creating a slideshow with previous and next buttons, but now we&#8217;d like to add buttons for &#8230; <a href="http://computeraxe.com/pause-and-play-buttons-for-jquery-slideshow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Continuing our slideshow journey with jQuery Cycle plugin, we&#8217;d like to improve our slider by adding two more buttons. Last time we looked at creating a <a href="http://computeraxe.com/previous-next-buttons-jquery-cycle-slideshow/" title="Next and previous buttons for Cycle slideshow.">slideshow with previous and next buttons</a>, but now we&#8217;d like to add buttons for pause and resume. It would be nice to allow site visitors to stop a slideshow with a pause button and resume the slideshow with a play button whenever they&#8217;re ready to continue.</p>
<p>If we keep the overall design the same, we just need to do two things to modify the slider. First, we need to upload the images for the pause and resume buttons and add a couple of lines to the HTML markup for positioning the buttons. We&#8217;ll fit the pause and play buttons in between the previous and next buttons. Each button will use an anchor tag, an id for CSS and script targeting, and a title for a user-friendly tooltip.</p>
<p><strong>HTML Markup for Slideshow Controls:</strong></p>
<pre class="crayon-plain-tag">&lt;div id=&quot;nav-buttons&quot;&gt;
  &lt;a id=&quot;prev2&quot; href=&quot;#&quot; title=&quot;previous slide&quot;&gt;&lt;img src=&quot;../images/previous.png&quot; alt=&quot;Previous&quot; /&gt;&lt;/a&gt;
  &lt;a id=&quot;pauseButton&quot; href=&quot;#&quot; title=&quot;pause slideshow&quot;&gt;&lt;img src=&quot;../images/pause.png&quot; alt=&quot;Pause&quot; /&gt;&lt;/a&gt;
  &lt;a id=&quot;resumeButton&quot; href=&quot;#&quot; title=&quot;resume slideshow&quot;&gt;&lt;img src=&quot;../images/play.png&quot; alt=&quot;Play&quot; /&gt;&lt;/a&gt;
  &lt;a id=&quot;next2&quot; href=&quot;#&quot; title=&quot;next slide&quot;&gt;&lt;img src=&quot;../images/next.png&quot; alt=&quot;Next&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;</pre>
<p>Second, we need to add a couple of lines to the script to manage the action when someone clicks either button. Here, we&#8217;re assigning Cycle&#8217;s pause or resume option to the click function of the selected <code>id</code>, in this case <code>#slide_aft</code>. Adding a &#8216;return false&#8217; line assures that the site visitor won&#8217;t be taken to another page when the buttons are clicked.</p>
<p><strong>jQuery script portion for pause and resume buttons:</strong></p>
<p></p><pre class="crayon-plain-tag">$('#pauseButton').click(function() {
	   $('#slide_aft').cycle('pause');
		 return false;
 });
 $('#resumeButton').click(function() {
	   $('#slide_aft').cycle('resume');
		 return false;
 });</pre><p></p>
<p>The above script portion was placed in the <code>document.ready function($)</code> so that the buttons are able to be used as soon as practical.</p>
<p>Here&#8217;s the full slideshow example with button controls for pause, resume or play, previous slide, and next slide.</p>
<div id="contain">
<div id="slide_aft">
    <img src="../images/1.jpg" alt="one" /><br />
    <img src="../images/2.jpg" alt="two" /><br />
    <img src="../images/3.jpg" alt="three" /><br />
    <img src="../images/4.jpg" alt="four" />
  </div>
<div id="nav-buttons">
  <a id="prev2" href="#" title="previous slide"><img src="../images/previous.png" alt="Previous" /></a><br />
<a id="pauseButton" href="#" title="pause slideshow"><img src="../images/pause.png" alt="Pause" /></a><br />
  <a id="resumeButton" href="#" title="resume slideshow"><img src="../images/play.png" alt="Play" /></a><br />
  <a id="next2" href="#" title="next slide"><img src="../images/next.png" alt="Next" /></a>
</div>
<p><!-- end div#nav-buttons -->
</div>
<p>Now, that looks a little better. This slideshow looks more complete having the pause and play or resume buttons, as well as the prev and next buttons.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/pause-and-play-buttons-for-jquery-slideshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Previous and Next Buttons in a jQuery Cycle Slideshow</title>
		<link>http://computeraxe.com/previous-next-buttons-jquery-cycle-slideshow/</link>
		<comments>http://computeraxe.com/previous-next-buttons-jquery-cycle-slideshow/#comments</comments>
		<pubDate>Tue, 08 May 2012 12:27:01 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[Cycle]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=1230</guid>
		<description><![CDATA[A site visitor to computeraxe wanted to know how to incorporate previous and next buttons in their slideshow using jQuery Cycle plugin. It&#8217;s easy! Let&#8217;s see an example, ok? If you haven&#8217;t checked out the simplicity of the jQuery Cycle &#8230; <a href="http://computeraxe.com/previous-next-buttons-jquery-cycle-slideshow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A site visitor to computeraxe wanted to know how to incorporate previous and next buttons in their slideshow using jQuery Cycle plugin. It&#8217;s easy! Let&#8217;s see an example, ok?</p>
<p>If you haven&#8217;t checked out the simplicity of the jQuery Cycle plugin, you should because there&#8217;s a whole lot you can do with it. It&#8217;s a very versatile plugin and quite popular, which speaks to its usefulness &mdash; and cool factor, too. Previous posts here covered the basics about the <a href="http://computeraxe.com/javascript-plugin-jquery-cycle-for-slideshows/" title="jQuery Cycle plugin for slideshows">Cycle Plugin</a>, how to <a href="http://computeraxe.com/polaroid-slideshows-with-jquery-cycle-plugin/" title="Polaroid slideshow with Cycle">make slides look like Polaroids</a>, using <a href="http://computeraxe.com/slideshow-image-captions-with-jquery-cycle/" title="Slideshow image captions with jQuery Cycle">image captions with Cycle</a>, and discussions about a <a href="http://computeraxe.com/jquery-cycle-plugin-working-with-links/" title="Problems with transition effects and their solutions.">transition effects problem</a> with certain <em>fx</em>.</p>
<p>Let&#8217;s get into the example for making previous and next buttons for a slider in jQuery using the Cycle plugin. </p>
<p>Before writing any code it would be a good idea to sketch out the design for the slideshow. The photos or slides will be held in a container <code>div</code> that can be targeted for CSS styling and javascript. Captions and their container paragraph would also be placed inside the container <code>div</code>. In this example we&#8217;ll do away with the captions for simplicity and place the previous and next buttons inside the container <code>div</code>.</p>
<p>It turns out that Cycle has two options for creating the functionality for going to the next photo or the previous slide in a sequence. These options are appropriately named &#8216;next&#8217; and &#8216;prev&#8217;. The values to give for each are the locations of the next and previous buttons. To specify each location, create an <code>id</code>. </p>
<p>Here, we&#8217;re using <em>#next2</em> for the next button and <em>#prev2</em> for the previous button. Since we&#8217;re having only one next/previous button set for this slideshow, an <code>id</code> for each makes sense. If you have more than one slider on a page, a <code>class</code> would be more appropriate. When somebody wants to see the previous slide they&#8217;ll click on the &#8216;previous button&#8217;, so the best HTML tag for the slideshow controls is an anchor with a href of &#8216;#&#8217;. We don&#8217;t want to leave the page when clicking the previous button, we just want to see the previous slide in the show.</p>
<p><strong>HTML Markup:</strong></p>
<pre class="crayon-plain-tag">&lt;div id=&quot;contain&quot;&gt;
&lt;p&gt;Slideshow example using jQuery Cycle plugin with previous and next buttons.&lt;/p&gt;
  &lt;div id=&quot;slide_afta&quot;&gt;
    &lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;
    &lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;
    &lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;
    &lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;
  &lt;/div&gt;
&lt;div id=&quot;nav-buttonsa&quot;&gt;
  &lt;a id=&quot;prev2&quot; href=&quot;#&quot; title=&quot;previous slide&quot;&gt;&lt;img src=../images/previous.png&quot; alt=&quot;Previous&quot; /&gt;&lt;/a&gt;
  &lt;a id=&quot;next2&quot; href=&quot;#&quot; title=&quot;next slide&quot;&gt;&lt;img src=&quot;../images/next.png&quot; alt=&quot;Next&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;!-- end div#nav-buttons --&gt;
&lt;/div&gt;</pre>
<p>We&#8217;ll use a couple of small images to accommodate the previous and next slide functionality. One could use the words &#8216;prev&#8217; and &#8216;next&#8217; instead of images, if desired. In case a site visitor needs help, we&#8217;ve included a tooltip for each button by the way of a title for each anchor.</p>
<p>We want to hide all the images except the first image whenever the document is ready. Else, we&#8217;ll use the window load function for the slider action.</p>
<p><strong>jQuery:</strong></p>
<p></p><pre class="crayon-plain-tag">// jQuery Cycle options for slideshow with next/previous buttons

$(window).load(function() {
  $('#slide_afta').cycle({
     fx: 'fadeZoom',
     timeout: 2000,
     next: '#next2',
     prev: '#prev2',
     slideExpr: 'img'
   }); 	 
});

// hide all but the first image when document is ready

jQuery(document).ready(function($) {
  $('#slide_afta img:gt(0)').hide();
});</pre><p></p>
<p>Of course, there are many different ways to style your slideshow. Here&#8217;s our example Cycle slider with next and previous buttons.</p>
<div id="containa">
<p><em>Slideshow example using jQuery Cycle plugin with previous and next buttons.</em></p>
<div id="slide_afta">
    <img src="../images/1.jpg" alt="one" /><br />
    <img src="../images/2.jpg" alt="two" /><br />
    <img src="../images/3.jpg" alt="three" /><br />
    <img src="../images/4.jpg" alt="four" />
  </div>
<div id="nav-buttonsa">
  <a id="prev2" href="#" title="previous slide"><img src="../images/previous.png" alt="Previous" /></a><br />
  <a id="next2" href="#" title="next slide"><img src="../images/next.png" alt="Next" /></a>
</div>
<p><!-- end div#nav-buttonsa -->
</div>
<h3>What if you want two sliders on the same page?</h3>
<p>The first thing to recognize is that more than one <code>id</code> with the same name won&#8217;t work on the same page, so parts of the document for the second slider with an <code>id</code> will have to be changed over to a <code>class</code> or a different <code>id</code> name. CSS will have to be updated to reflect the changes, as will the javascript.</p>
<p>However, using the same <code>class</code> names for the next and previous controls for two sliders on the same page will result in both sliders being controlled by the same set of control buttons. That&#8217;s probably not what you&#8217;d want, nor what your site visitors would expect. Rename the action buttons (prev, next) and the container for the slides to different <code>class</code> names in order to be able to control the second slideshow. Of course, a second Cycle script would be needed to target the new container for the second slideshow.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/previous-next-buttons-jquery-cycle-slideshow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Putting Readable Code in a WordPress Post</title>
		<link>http://computeraxe.com/putting-readable-code-in-a-wordpress-post/</link>
		<comments>http://computeraxe.com/putting-readable-code-in-a-wordpress-post/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 07:05:47 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=1139</guid>
		<description><![CDATA[Writing about PHP or HTML code in WordPress posts or pages often requires that some actual code is shown on the screen for explanation. If special steps aren&#8217;t taken to illustrate the code as text, the result is often not &#8230; <a href="http://computeraxe.com/putting-readable-code-in-a-wordpress-post/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Writing about PHP or HTML code in WordPress posts or pages often requires that some actual code is shown on the screen for explanation. If special steps aren&#8217;t taken to illustrate the code as text, the result is often not what was intended to be seen because the WordPress engine will interpret the code as actual code, not text about code.</p>
<p>If all you want to do is highlight some text that includes code-related words like filenames, function names or plugin names, use <code>&lt;code&gt;&lt;/code&gt;</code> around those phrases in your text. Using <code>&lt;code&gt;&lt;/code&gt;</code> turns text into a <code>monospaced font </code>so that it appears differently in your posts than &#8220;normal&#8221; text. However, using <code>&lt;code&gt;&lt;/code&gt;</code> around an HTML tag doesn&#8217;t do anything except change the presentation of the tag, so the opening and closing angle brackets are interpreted to enclose an <em>actual HTML tag</em>. The result will be a mess and definitely not what you were hoping to see.</p>
<p>To make WordPress show code in a post without interpreting it, you have to do ONE of three things:</p>
<ol>
<li>Use special character codes to replace angle brackets of tags.</li>
<li>Use the HTML tag <code>&lt;pre&gt;&lt;/pre&gt;</code> around the code.</li>
<li>Use a plugin to highlight the code syntax.</li>
</ol>
<h3>1. Special Character Codes</h3>
<p>Angle brackets, &lt; or &gt;, are what WordPress uses to identify code, whether it&#8217;s HTML, inline styles of CSS, or PHP. Content inside angle brackets is interpreted as code by virtue of placement inside the brackets. Instead of interpreting this code we want WordPress to show the code to the site visitors and we can use special character codes to do that. </p>
<p>Character codes are special sequences of letters or digits that are used to represent textual characters. Every character that we see on the screen, including uppercase letters, lowercase letters, numbers, and symbols like &lt;, &gt;, #, $, %, ^, &#038; or *, can be represented by character codes, sometimes called character entities.</p>
<p>Using character codes in posts looks a little strange in the editing panel, but when a browser comes across these codes they are interpreted and their textual equivalent is shown on the screen.</p>
<p>ASCII (American Standard Code for Information Interchange) <a href="http://www.ascii.cl/htmlcodes.htm" title="ascii character entities"> character codes</a> were developed to represent text in electronic devices  and they follow a specific format. The format is that each character entity starts with an ampersand and ends with a semi-colon. The codes are a couple to a few letters or numbers. Numbered character codes always have a hash symbol right after the opening ampersand. Some entities can be represented by either numbered or named codes.</p>
<p><strong>Examples of special character codes:</strong></p>
<table>
<tr>
<th>Character name</th>
<th>Character symbol</th>
<th>Character ASCII Code</th>
<tr>
<tr>
<td>left angle bracket</td>
<td>&lt;</td>
<td>&amp;lt;</td>
</tr>
<tr>
<td>right angle bracket</td>
<td>&gt;</td>
<td>&amp;gt;</td>
</tr>
<tr>
<td>ampersand</td>
<td>&amp;</td>
<td>&amp;amp;</td>
</tr>
<tr>
<td>dollar sign</td>
<td>&#36;</td>
<td>&amp;#36;</td>
</tr>
<tr>
<td>long dash</td>
<td>&mdash;</td>
<td>&amp;mdash;</td>
</tr>
<tr>
<td>short dash</td>
<td>&ndash;</td>
<td>&amp;ndash;</td>
</tr>
<tr>
<td>double quotes</td>
<td>&quot;</td>
<td>&amp;quot;</td>
</tr>
<tr>
<td>at sign</td>
<td>&#64;</td>
<td>&amp;#64;</td>
</tr>
</table>
<p>If you need to find a code for language sets other than English, try the unicode site for all the <a href="http://www.unicode.org/charts/" title="unicode character code charts">code charts</a> you&#8217;ll ever need. There, you can find numeric codes for fun game pieces, like chess, mahjong or checkers, horoscope symbols, smiley faces, weather symbols, music notes, and much more.</p>
<p><strong>Take caution:</strong> Just because you can enter a special code to represent a symbol, that doesn&#8217;t mean your computer will let you see it. Many operating systems will not have the proper fonts installed to make use of all of these codes, especially if they represent symbols that aren&#8217;t on your keyboard. Stick to the ASCII codes as many of the unicodes won&#8217;t be seen by your site visitors.</p>
<h3>2. HTML tag: &lt;pre&gt;</h3>
<p>Perhaps you&#8217;d like to show a block of HTML code on your post and have it shown as text. To make sure that your block of code is not interpreted as actual code, wrap it with <code>&lt;pre&gt;&lt;/pre&gt;</code> tags. The <code>&lt;pre&gt;</code> tag will change the appearance of the code into a <code>monospace font</code>, just like <code>&lt;code&gt;</code> does, but the difference is that <code>&lt;pre&gt;</code> also illustrates the code exactly as it was typed. All text, characters, spaces and line feeds will be reproduced exactly how they were entered. No code will be run when it&#8217;s protected inside the opening <code>&lt;pre&gt;</code> and closing <code>&lt;/pre&gt;</code> tags.</p>
<h3>3. Syntax Highlighter Plugins</h3>
<p>A final way to illustrate code in a WordPress post or page is to use a plugin to highlight the code. Several plugins are available for syntax highlighting purposes. </p>
<p>One that I have been using lately is called <a href="http://wordpress.org/extend/plugins/crayon-syntax-highlighter/" title="crayon syntax highlighter plugin">Crayon Syntax Highlighter</a>. It&#8217;s a great plugin that will colorize or highlight code that you wrap with shortcodes. There are lots of options if you want fine control over the color scheme. Themes come with the plugin so you have several choices for making your code look good.</p>
<p>There are two modes where you can highlight code differently using shortcodes, <code>&#91;crayon&#93;&#91;/crayon&#93;</code> and <code>&#91;plain&#93;&#91;/plain&#93;</code>. Use <code>&#91;plain&#93;</code> shortcodes when the colorized crayon is overkill or when you just want to show a small section of code. Crayon Syntax Highlighter supports a wide range of languages, including HTML, CSS, PHP and JavaScript, for starters.</p>
<p>The colorful <code>&#91;crayon&#93;</code> shortcode is controlled by options where you can pick the colors that you want for representing different sections or purposes in your code. Inline crayons are supported so you could put a line of code within a line of text and the code would be colorized.</p>
<p>Some other popular code-highlighting plugins include <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/" title="SyntaxHighlighter Evolved plugin">SyntaxHighlighter Evolved</a>, <a href="http://wordpress.org/extend/plugins/wp-syntax/" title="WP Syntax plugin">WP-Syntax</a>, and <a href="http://wordpress.org/extend/plugins/codecolorer/" title="Code Colorer plugin">CodeColorer</a>. I don&#8217;t have any personal experience with these plugins, but they are listed high in popularity at the <a href="http://wordpress.org/extend/plugins/" title="WordPress Plugin Directory">WordPress Plugin Directory</a>.</p>
<h3>Need to Execute Code in a Post?</h3>
<p>If what you&#8217;re really after is to put executable code in a post or WordPress Page, check out this post on <a href="http://computeraxe.com/using-php-inside-content-wordpress-blogs/" title="run PHP inside a blog post">executing PHP in WordPress</a> blogs.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/putting-readable-code-in-a-wordpress-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Include jQuery or JavaScripts in WordPress</title>
		<link>http://computeraxe.com/include-jquery-or-javascripts-in-wordpress/</link>
		<comments>http://computeraxe.com/include-jquery-or-javascripts-in-wordpress/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 07:05:56 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=1006</guid>
		<description><![CDATA[Plugin and theme authors use jQuery for their special effects, but there seems to be some confusion about the proper way to include JavaScript files in WordPress. If you&#8217;d like to use jQuery effects on your pages or in your &#8230; <a href="http://computeraxe.com/include-jquery-or-javascripts-in-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Plugin and theme authors use jQuery for their special effects, but there seems to be some confusion about the proper way to include JavaScript files in WordPress. If you&#8217;d like to use jQuery effects on your pages or in your theme, or if you want to include any javascript plugin or personal script, read on to see how to do it properly with WordPress sites.</p>
<h2>Queue Up Your Scripts with Actions</h2>
<p>Since jQuery itself is already included in the core of WordPress, how should we include a javascript file that we&#8217;ve created or even one of the <a href="http://computeraxe.com/most-popular-jquery-plugins/" title="popular jQuery plugins">popular jQuery plugins</a> that rely on jQuery? WordPress helps us in this endeavor with a function called &#8216;<em>wp_enqueue_script()</em>&#8216; and two actions that are used to call this special function.</p>
<p>The actions are used for either the user side or the admin side, depending on the purpose of your javascript. Use the &#8216;<em>wp_enqueue_scripts</em>&#8216; action to call <code>wp_enqueue_script()</code> for use in your themes. If the script functionality is needed on the admin side, use &#8216;<em>admin_enqueue_scripts</em>&#8216; action instead.</p>
<p>The format of the <code>wp_enqueue_script()</code> function call is as follows:</p>
<pre class="crayon-plain-tag">wp_enqueue_script('$handle', '$src', '$deps', '$ver', '$in_footer');</pre>
<p>where <em>$handle</em> is the name of the script as a lowercase string, <em>$src</em> is the URL to the script<note - don't hard code_>, <em>$deps</em> is an array of scripts that the script you&#8217;re calling depends on or the scripts that must be loaded first for your script to work, <em>$ver</em> is the script&#8217;s version number in string format, and <em>$in_footer</em> is a boolean value to indicate whether the script should be loaded in the &lt;head&gt; or at the end of the &lt;body&gt; in the footer. </p>
<p>The <em>$handle</em> string is the only required parameter, so the other four parameters are optional. The <em>$src</em>, <em>$ver</em>, and <em>$in_footer</em> parameters default values are &#8216;false&#8217;, and <em>$deps</em> defaults to an empty array.</p>
<p>It seems that <em>$src</em> would need to be a required option, but WordPress already knows about several scripts and where to find them. Consult the list of <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress" title="Where to find the default scripts included with WordPress">default scripts included with WordPress</a> to pick up their handles.</p>
<p>For example, to queue the jQuery Color plugin, we&#8217;d simply use this:</p>
<pre class="crayon-plain-tag">wp_enqueue_script('jquery-color');</pre>
<p>To include a script and specify the source, try this for including the jQuery Cycle plugin in the &lt;head&gt;:</p>
<pre class="crayon-plain-tag">wp_enqueue_script('jquery-cycle', 'URL', array('jquery'), '1.3.2');</pre>
<p>The URL should not be a hard-coded value for local scripts. Refer to the Function Reference pages in the codex for proper <a href="http://codex.wordpress.org/Function_Reference/plugins_url" title="plugins reference">URL formats for plugins</a> and <a href="http://codex.wordpress.org/Function_Reference/get_template_directory_uri" title="themes reference">themes</a>.</p>
<h2>Register Your Scripts First</h2>
<p>Make sure that your scripts are registered first before calling them. Registering a script basically tells WordPress where to find the code for your script. Use the function <code>wp_register_script()</code> to specify the location and handle of your script. The format is similar to the <code>wp_enqueue_script()</code> function:</p>
<pre class="crayon-plain-tag">wp_register_script('$handle', '$src', '$deps', '$ver', '$in_footer');</pre>
<p>The parameters have the same meanings and default values as used with <code>wp_enqueue_script()</code>. When in doubt, see what the WordPress Codex has to say about <code><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="enqueue scripts">wp_enqueue_script()</a></code> and <code><a href="http://codex.wordpress.org/Function_Reference/wp_register_script" title="register scripts">wp_register_script()</a></code>.</p>
<h2>Create a Function for the Header</h2>
<p>Put it all together using <code>wp_register_script()</code>, <code>wp_enqueue_script()</code>, and the appropriate action to call the functions. Create a simple function, like <code>id_scripts()</code> below, and use the <code>add_action()</code> hook to queue up the scripts. </p>
<p></p><pre class="crayon-plain-tag">function id_scripts() {
   wp_register_script('script_alpha', 'URL', array('jquery'), '1.0');
   wp_enqueue_script('script_alpha');
}
add_action('wp_enqueue_scripts', 'id_scripts');</pre><p></p>
<p>As a side note jQuery itself doesn&#8217;t have to be queued via a statement like <code>wp_enqueue_script('jquery');</code>, because it is listed as a dependency of &#8216;<em>script-alpha</em>&#8216; in this case.</p>
<p>When enqueuing a custom script that depends on a jQuery plugin, specify jQuery and its plugin in the <em>$deps</em> parameter of the <code>wp_register_script()</code> action for the custom script. For example, if your custom script depends on the jQuery Cycle plugin, which itself depends on jQuery, use<code> array('jquery', 'jquery-cycle')</code> for the <em>$deps</em> parameter. This specifies that both jQuery and its plugin Cycle should be loaded (in that order) before the custom script.</p>
<p>Place this code in the <code>header.php</code> of your theme. Remember, first register the javascript file, then enqueue it and make sure this is done before the <code>wp_head();</code> statement. Your custom script can then be placed in <code>header.php</code> after the <code>wp_head()</code> call.</p>
<h2>Use Theme functions.php to Safely Reference Your Script</h2>
<p>When using a child theme take note that the <code>header.php</code> in a child theme will override the default <code>header.php</code> in the parent theme. Instead of placing the script-queuing code in the header, one could more safely put this code in <code>functions.php</code>. The advantage to that way is that the <code>functions.php</code> of a child theme is processed <em>before</em> the <code>functions.php</code> of the parent theme. Both the parent and child theme <code>functions.php</code> are processed, unlike <code>header.php</code> files.</p>
<p>If you&#8217;re the least bit unsure about messing with <code>header.php</code>, then just use <code>functions.php</code> to queue up your javascript files. Don&#8217;t forget the opening and closing PHP tags in <code>functions.php</code>, else it won&#8217;t work. Put the javascript that would come after the <code>wp_head()</code> call in a separate <code>.js</code> file in the child theme and you&#8217;re good to go.</p>
<p>Verify that everything is working correctly by viewing the source of the HTML document for a WordPress post that should have the script included. The &lt;script&gt; tags should be visible in the header or in the footer depending on how the scripts were called.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/include-jquery-or-javascripts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>camelCase OK for jQuery</title>
		<link>http://computeraxe.com/camelcase-ok-for-jquery/</link>
		<comments>http://computeraxe.com/camelcase-ok-for-jquery/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 07:05:50 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[properties]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=1070</guid>
		<description><![CDATA[CamelCase refers to a method of combining words into compound words. Instead of using a hyphen to connect two words, camelCase removes the hyphen or space between the words and capitalizes the second word. jQuery doesn&#8217;t mind if you use &#8230; <a href="http://computeraxe.com/camelcase-ok-for-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>CamelCase refers to a method of combining words into compound words. Instead of using a hyphen to connect two words, camelCase removes the hyphen or space between the words and capitalizes the second word. </p>
<p>jQuery doesn&#8217;t mind if you use camelCase when specifying CSS properties, so &#8216;border-color&#8217; means the same as &#8216;borderColor&#8217;. </p>
<p>The hyphenated property name should always be used in CSS stylesheets, for example, <em>background-color</em>.</p>
<pre class="crayon-plain-tag">.photos
{
  background-color: #fff;
  color: #000;
}</pre>
<p>In jQuery either the hyphenated <em>background-color</em> or camelCase <em>backgroundColor</em> could be used.</p>
<pre class="crayon-plain-tag">$(document).ready(function() {
  $('#b1').animate({
    height: '+=100px',
    backgroundColor: '#eee',
    color:'#2133aa'
  }, 2000, 'linear');
});</pre>
<p><strong>Tips:</strong></p>
<ol>
<li>Single quote marks are needed if the hyphenated property is used, but the non-hyphenated camelCase doesn&#8217;t require single quotes around the property name. </li>
<li>The <em>values</em> for each property should be inside single quotes.</li>
</ol>
<p>Which case you&#8217;ll use comes down to personal preference. I like to type fewer quotes and hyphens, so I tend to use camelCase where ever possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/camelcase-ok-for-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slideshow Loading Problems Solved in jQuery Cycle</title>
		<link>http://computeraxe.com/slideshow-loading-problems-solved-in-jquery-cycle/</link>
		<comments>http://computeraxe.com/slideshow-loading-problems-solved-in-jquery-cycle/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 07:05:13 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=979</guid>
		<description><![CDATA[When it comes to JavaScript components that act on elements of the page, it is highly important to have those elements in place before the script tries to manipulate them, else things won&#8217;t work as intended. So, that begs the &#8230; <a href="http://computeraxe.com/slideshow-loading-problems-solved-in-jquery-cycle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When it comes to JavaScript components that act on elements of the page, it is highly important to have those elements in place before the script tries to manipulate them, else things won&#8217;t work as intended. So, that begs the question, &#8220;What&#8217;s the best way to have JavaScript run on my page?&#8221; In this example we&#8217;ll focus on handling javascript while making slideshows with the jQuery Cycle plugin.</p>
<p>At any rate we want our pages to be seen by the visitor right away. We know if it takes more than a couple of seconds for anything to appear on the screen, the visitor is likely to click away to another site. Remember, text appears quickly when it&#8217;s not part of a table. The whole table has to be ready before you&#8217;ll see the table, so don&#8217;t use tables for design purposes, especially nested tables. Save your tables for presenting data.</p>
<p>A problem with big pages having slideshows is that if the page is not ready when a script tries to manipulate things, the effects may be all wrong. For example, when a script calculates the center position for an image it may get the positioning wrong, especially if all the images in the slideshow are not of the same size.</p>
<p>So, how do we improve our slideshow for the masses? We need to tell the javascript <em>when </em>to do its magic. In this example we&#8217;ll use this approach:</p>
<ol>
<li>Perform initial actions with the <code>.ready()</code> method. Actions in this case are to hide images with the <code>.hide()</code> method until they are called for by the script.</li>
<li>Run the slideshow after the content has loaded with the <code>.load()</code> method.</li>
<li>Use a function to calculate the center for each image. </li>
<li>Apply the function with the <em>before</em> option in jQuery Cycle.</li>
</ol>
<p>A previous post on <a href="http://computeraxe.com/centering-slideshows-with-jquery-cycle-plugin/" title="jQuery cycle centers slideshows">centering slideshows with jQuery Cycle</a> put all the javascript inside a <code>.ready()</code> statement. For many scripts this would be just fine, but for the slideshow it resulted in the action starting up before all the images were available.</p>
<p>For this example the slideshow is marked up as a group of images inside a &lt;div&gt; that has been assigned an id for JS targeting, <code>#big_show</code>, and a class for CSS targeting, <code>.photos</code>.</p>
<p>HTML Markup:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;big_show&quot; class=&quot;photos&quot;&gt;
    &lt;img src=&quot;http://computeraxe.com/images/1.jpg&quot; alt=&quot;one&quot; /&gt;
    &lt;img src=&quot;http://computeraxe.com/images/2.jpg&quot; alt=&quot;two&quot; /&gt;
    &lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;
    &lt;img src=&quot;http://computeraxe.com/images/4.jpg&quot; alt=&quot;four&quot; /&gt;
  &lt;/div&gt;</pre>
<h2>Hide Images While Page Loads</h2>
<p>Because it may take a while to load up all the photos for the slideshow, and everything else on the page, hide the photos except for the first one to start. Use a <code>.ready()</code> statement to hide the photos because we want to do that right away. Put everything in the <code>.ready()</code> method that you want to run first, even before the rest of the page or content has loaded. The <code>.ready()</code> function is a jQuery construct that allows you to bring functionality to the page before all the content has loaded. That way a page with lot of images can be useful even before all the images are visible. </p>
<p>For hiding images use the <code>.ready()</code> function so that this task will occur as soon as possible.</p>
<p></p><pre class="crayon-plain-tag">$(document).ready(function() {
    $('#s1 img:gt(0)').hide(); // hides all images with index greater than 0, so it shows the first image only - in one JS/jQuery call

    $('#s2 img').hide(); // hides all images
    $('#s2 img:first').show(); // shows the first image

    $('#s3 img').hide(); // hides all images
    $('#s3 img:eq(0)').show(); // shows the image with index equal to 0
});</pre><p></p>
<p>Many selectors could be used to target the first element in a series and the example above shows three ways of doing so for three different slideshows, <em>#s1</em>, <em>#s2</em> and <em>#s3</em>. The outcome of each is the same in that only the first image is shown until the rest of the slideshow is loaded.</p>
<h2>Control Slideshow Action After Window Loads</h2>
<p>It makes sense to run a slideshow only when all the components for the show are present. To do that run Cycle with a <code>.load()</code> statement so that the slideshow waits to start until all of the images are loaded.</p>
<p></p><pre class="crayon-plain-tag">$(window).load(function() {
  $('#big_show').cycle({ 
    fx:     'fadeZoom', 
    timeout:  2000,
    before: onBefore
  });
});</pre><p></p>
<p>If you have a big slide show with lots of images, you might want to present an <a href="http://computeraxe.com/generate-animated-loading-images/" title="where to find animated loading images">animated loading image</a> until the slideshow starts.
<link>
<h2>Calculate Image Size for Centering in Slideshow</h2>
<p>Take a look at the solution provided by &#8220;malsup&#8221; for users of his Cycle plugin:</p>
<p></p><pre class="crayon-plain-tag">function onBefore(curr,next,opts) {
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (400 - h) / 2,
        marginLeft: (300 - w) / 2
    });
};</pre><p></p>
<p>Basically, what his code is doing is creating a function that will run before any slides are manipulated by Cycle. The purpose of the <em>onBefore</em> function is to calculate the correct margins for images and set the CSS parameters margin-top and margin-left for centering the images. </p>
<p>The <em>onBefore</em> function creates a variable called <em>$slide</em> to hold an array of the parameters of the <code>$(next)</code> element in the slideshow. The variables <em>w</em> and <em>h</em> are set to the width and height of said element via the <code>$slide.outerWidth()</code> and <code>$slide.outerHeight()</code> methods, respectively. </p>
<p>Finally, the margins are calculated from knowing the width and height of the slide container as set in the CSS (in this example 400 px and 300 px) and subtracting the slide&#8217;s width (<em>w</em>) and height (<em>h</em>) values, respectively. The margins only need to have half of the total margin value to accommodate both sides of the box, so the difference is divided by 2.</p>
<h2>Use Cycle&#8217;s <em>Before</em> Option to Apply Centering Function</h2>
<p>Using the <em>onBefore</em> function with Cycle&#8217;s <em>before</em> option works beautifully with images of different sizes, see line 5 of the <code>.load()</code> method above. Margins are set using the <code>.css()</code> method after they are calculated by the <em>onBefore</em> function.</p>
<p>CSS:</p>
<pre class="crayon-plain-tag">#big_show {
    height: 400px;
    width: 300px;
    text-align: center;
    background-color: #f3c;
}
.photos img {
    margin: 0;
    padding: 4px;
    border: 1px solid #ccc;
    background-color: #eee;
    max-width: 290px;
    max-height: 390px;
}</pre>
<p>You have to specify some CSS to get this thing to work right, namely <strong>set the width and height on the slide container and slides themselves</strong>.</p>
<p>Setting the <em>max-width</em> and <em>max-height</em> for the images helps to keep them inside of the container. Note that adding up the padding and border for both sides of the box is 10 px of the slideshow box that can&#8217;t be used to show an image. Therefore, the maximum image dimensions are the overall width or height minus 10 px. By accounting for the padding and border sizes a large image won&#8217;t overflow its container.</p>
<p>Any comments on this improved slideshow using Cycle plugin with jQuery?</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/slideshow-loading-problems-solved-in-jquery-cycle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Polaroid Slideshows with jQuery Cycle Plugin</title>
		<link>http://computeraxe.com/polaroid-slideshows-with-jquery-cycle-plugin/</link>
		<comments>http://computeraxe.com/polaroid-slideshows-with-jquery-cycle-plugin/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 07:05:45 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=981</guid>
		<description><![CDATA[The Cycle plugin for jQuery has many options that can be modified to create stunning slideshows. The look and feel of the slideshows are controlled with CSS and the behavior or animation of the slides is controlled by JavaScript. The &#8230; <a href="http://computeraxe.com/polaroid-slideshows-with-jquery-cycle-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Cycle plugin for jQuery has many options that can be modified to create stunning slideshows. The look and feel of the slideshows are controlled with CSS and the behavior or animation of the slides is controlled by JavaScript. The Cycle plugin requires jQuery v1.3.2 or later.</p>
<h3>Polaroid Photos</h3>
<p>Sometimes you want to have a little fun with a project, like when somebody brings a Polaroid camera to a party. Taking Polaroid snapshots became wildly popular in the 1970s because it was the only camera that would produce a hand-held photo on the fly. All the other cameras had film that you would need to finish taking pictures on, and then send in to a photo developer to expose the negatives and print the photos. Polaroid cameras were like the iPhones of the 70s, and due to that popularity everybody knew what a Polaroid was &mdash; <em>an instant photo</em>.</p>
<p>Polaroid photos looked a little different from photo developer developed photos. They were always glossy and of a different format than the typical 3 1/2 inch tall x 4 7/8 inch wide snapshot that you&#8217;d get from the photo shop. With or without a border, the images on photo shop developed prints were rectangular, not square.</p>
<p>Polaroid cameras are still around today and their photos measure 3.5 inches wide by 4.25 inches tall. A white border around the image measures approximately 0.25 inch at the top, 0.1875 inch on the sides, and 0.875 inch at the bottom. The bottom border is larger so that you can write a caption there. Subtracting the size of the borders from the overall dimensions leaves 3.125 inches for the inner width and 3.125 inches for the inner height of the photographic image. Thus, Polaroid images are square instead of the standard rectangular format common in other photos.</p>
<h3>Styling the Polaroid Photo</h3>
<p>We can use CSS to make our images look like Polaroids. Introduce a dark, thin border and some padding for each image. In this case we&#8217;ll target the slides with the class <em>.polaroid</em>. Note that the container size may have to be enlarged to accommodate the padding and border from both sides of the image. This is especially important when all the images are not of the same dimensions.</p>
<p>CSS:</p>
<pre class="crayon-plain-tag">#slide_polaroid {
margin:10px;
z-index:3;
}
#write_caption {
position:relative;
top:-40px;
left:100px;
z-index:4;
}
.polaroid img {
padding:18px 14px 33px 14px;
}
.polaroid {
width:200px;
height:200px;
background-color:#fcfcfc;
color:#000;
padding:18px 14px 63px 14px;
border:1px solid #000;
position:relative;
}</pre>
<p>The jQuery Cycle plugin is used to control the slideshow action. A function is called after each slide is shown on the screen to print the image <em>alt</em> text for the <a href="http://computeraxe.com/?p=952" title="Slideshow Image Captions with jQuery Cycle">slideshow image captions</a>.</p>
<p>JavaScript:</p>
<p></p><pre class="crayon-plain-tag">$('#slide_polaroid').cycle({
   fx: 'fadeZoom',
   timeout: 2000,
   slideExpr: 'img',
   after: function() {
     $('#write_caption').html(this.alt);
   }
});</pre><p></p>
<p>Output:</p>
<div id="slide_polaroid">
<div class="polaroid">
    <img src="../images/1.jpg" alt="one" /><br />
    <img src="../images/2.jpg" alt="two" /><br />
    <img src="../images/3.jpg" alt="three" /><br />
    <img src="../images/4.jpg" alt="four" />
  </div>
<p id="write_caption">
</div>
<p>We&#8217;re getting close with the above, but a little better slideshow effect would be to bring the whole polaroid through the effect, not just the inner square image.</p>
<p>This brings up one of the nice features of using jQuery Cycle for slideshows: <em>any content can be used for the slides</em>. That means a &lt;div&gt; containing an image and textual content — such as a caption — could be identified as slides. </p>
<h3>Polaroid Slideshow</h3>
<p>For this example each image and caption is wrapped in a &lt;div&gt;, and Cycle is called like so:</p>
<p>HTML:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;slide_polaroids&quot;&gt;
   &lt;div class=&quot;pol&quot;&gt;&lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;&lt;p&gt;Slide 1 caption.&lt;/p&gt;&lt;/div&gt;
   &lt;div class=&quot;pol&quot;&gt;&lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;&lt;p&gt;Slide 2 caption.&lt;/p&gt;&lt;/div&gt;
   &lt;div class=&quot;pol&quot;&gt;&lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;&lt;p&gt;Slide 3 caption.&lt;/p&gt;&lt;/div&gt;
   &lt;div class=&quot;pol&quot;&gt;&lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;&lt;p&gt;Slide 4 caption.&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<p>JavaScript:</p><pre class="crayon-plain-tag">$('#slide_polaroids').cycle({ 
     fx:     'shuffle', 
     timeout: 3000, 
     delay:  -2000,
     slideExpr: 'div'
   });</pre><p></p>
<p>Output:</p>
<div id="slide_polaroids">
<div class="pol"><img src="../images/1.jpg" alt="one" />
<p>Slide 1 caption.</p>
</div>
<div class="pol"><img src="../images/2.jpg" alt="two" />
<p>Slide 2 caption.</p>
</div>
<div class="pol"><img src="../images/3.jpg" alt="three" />
<p>Slide 3 caption.</p>
</div>
<div class="pol"><img src="../images/4.jpg" alt="four" />
<p>Slide 4 caption.</p>
</div>
</div>
<p>This slideshow hard codes captions in the HTML instead of displaying the image <em>alt</em> text dynamically. It just depends on the purpose of the slideshow and how many slides you have as to which approach you&#8217;ll use for captions.</p>
<h3>Styling Double Mat Framed Prints</h3>
<p>Give your slides the look of double matted, framed photos with a little CSS and a different special <em>fx</em>.</p>
<div id="slide_pols">
<div class="frame"><img src="../images/1.jpg" alt="one" /></div>
<div class="frame"><img src="../images/2.jpg" alt="two" /></div>
<div class="frame"><img src="../images/3.jpg" alt="three" /></div>
<div class="frame"><img src="../images/4.jpg" alt="four" /></div>
</div>
<p>Here, the <code>.frame</code> class is set to &#8220;ridge&#8221; for the &lt;div&gt; and &lt;img&gt; border properties using slightly different colors to make a double matted picture frame look. Black and grey backgrounds and a small amount of padding serves as the mat boards for the illusion. The JavaScript Cycle <em>fx</em> parameter is set to &#8220;fade&#8221; for the slideshow.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/polaroid-slideshows-with-jquery-cycle-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Slideshow Image Captions with jQuery Cycle</title>
		<link>http://computeraxe.com/slideshow-image-captions-with-jquery-cycle/</link>
		<comments>http://computeraxe.com/slideshow-image-captions-with-jquery-cycle/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 07:05:56 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=952</guid>
		<description><![CDATA[If a picture is worth a thousand words, a photo slideshow would be worth a whole book. Images can be interpreted in many ways and without some accompanying text or captions for the images in a slide show, you force &#8230; <a href="http://computeraxe.com/slideshow-image-captions-with-jquery-cycle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If a picture is worth a thousand words, a photo slideshow would be worth a whole book. Images can be interpreted in many ways and without some accompanying text or captions for the images in a slide show, you force the visitor to draw their own conclusions about what they are viewing. In the art world this may be ok and perhaps what you&#8217;re striving for, but most of the time we want to provide additional information with images so the visitor really knows what the imagery is all about.</p>
<p>Some images are fairly meaningless without captions. Were those pictures taken before or after the event? And is that really Aunt Tillie as a hip youngster?! You get the idea&#8230;<strong>captions help us to tell our stories</strong>. They can be as short and sweet as you like or more explanatory in nature. It just depends on your purpose as to what kinds of captions your visitors would benefit from.</p>
<p>Presented here are three examples for producing image captions in slideshows with jQuery Cycle.</p>
<p>To make an image caption for jQuery Cycle slideshows, the examples that follow depend on passing selectors, like this.alt, to the .html() method to pick up the <em>alt</em> text from each &lt;img>. Also, we&#8217;re going to use Cycle&#8217;s <em>after</em> and <em>before</em> options to specify our image captions.</p>
<p><strong>Example 1:</strong> Use Cycle&#8217;s <em>after</em> option to specify a caption using the image&#8217;s <em>alt</em> text. Caption will appear after the slide is in place.</p>
<p></p><pre class="crayon-plain-tag">$('#slide_after').cycle({
   fx: 'shuffle',
   timeout: 2000,
   slideExpr: 'img',
   after: function() {
     $('#caption').html(this.alt);
   }
});</pre><p></p>
<p>Here, the <em>after</em> option takes the result of an anonymous function as its value. The function() inserts the <em>alt</em> text from <em>this</em>, the current image, into #caption. In the HTML markup below notice that #caption identifies a paragraph below the images.</p>
<p>Example 1 HTML Markup:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;slide1&quot;&gt;
  &lt;div id=&quot;slide_after&quot;&gt;
    &lt;img src=&quot;/images/1.jpg&quot; alt=&quot;one&quot; /&gt;
    &lt;img src=&quot;/images/2.jpg&quot; alt=&quot;two&quot; /&gt;
    &lt;img src=&quot;/images/3.jpg&quot; alt=&quot;three&quot; /&gt;
    &lt;img src=&quot;/images/4.jpg&quot; alt=&quot;four&quot; /&gt;
  &lt;/div&gt;
  &lt;p id=&quot;caption&quot;&gt;&lt;/p&gt;
&lt;/div&gt;</pre>
<p>Example 1 Slideshow:</p>
<div id="slide1">
<div id="slide_after">
  <img src="/images/1.jpg" alt="one" /><br />
  <img src="/images/2.jpg" alt="two" /><br />
  <img src="/images/3.jpg" alt="three" /><br />
  <img src="/images/4.jpg" alt="four" />
  </div>
<p id="caption">
</div>
<div class="clear"> </div>
<p><strong>Example 2:</strong> Use Cycle&#8217;s <em>before</em> option to specify a caption using the image&#8217;s <em>alt</em> text. Caption will appear before the next slide.</p>
<p></p><pre class="crayon-plain-tag">$('#slide_before').cycle({
    fx: 'shuffle',
    timeout: 2000,
    slideExpr: 'img',
    before: function() {
      $('#caption2').html(this.alt);
    }
});</pre><p></p>
<p>The only things changed from Example 1 are that we&#8217;re using Cycle&#8217;s <em>before</em> option instead of the <em>after</em> option and the captions are placed at the top of the images instead of below them.</p>
<p>Example 2 HTML Markup:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;slide2&quot;&gt;
  &lt;p id=&quot;caption2&quot;&gt;&lt;/p&gt;
  &lt;div id=&quot;slide_before&quot;&gt;
    &lt;img src=&quot;/images/pic1.jpg&quot; alt=&quot;Baby Sixtoes and his brothers.&quot; /&gt;
    &lt;img src=&quot;/images/pic2.jpg&quot; alt=&quot;Cat in a tree.&quot; /&gt;
    &lt;img src=&quot;/images/pic3.jpg&quot; alt=&quot;Cute runaway artist.&quot; /&gt;
    &lt;img src=&quot;/images/pic4.jpg&quot; alt=&quot;Darling kittens napping.&quot; /&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre>
<p>Example 2 Slideshow:</p>
<div id="slide2">
<p id="caption2">
<div id="slide_before">
  <img src="/images/pic1.jpg" alt="Baby Sixtoes and his brothers." /><br />
  <img src="/images/pic2.jpg" alt="Missy cat in snow." /><br />
  <img src="/images/pic3.jpg" alt="Momma cat in a tree." /><br />
  <img src="/images/pic4.jpg" alt="Darling kittens napping." />
 </div>
</div>
<div class="clear"> </div>
<p><strong>Example 3:</strong> Show slide number and total count of slides in addition to the image&#8217;s <em>alt</em> text for a caption.</p>
<p>To get the slide numbers we can take advantage of a couple of variables that keep track of the current slide and the number of total slides. We&#8217;ll pass three Cycle variables (curr,next,opts) to a new function.</p>
<p></p><pre class="crayon-plain-tag">$('#slideboth').cycle({
    fx: 'fadeZoom',
    timeout: 2000,
    slideExpr: 'img',
    after: slideAfter,
    before: function() {
      $('#caption3').html(this.alt);
    }
});

function slideAfter(curr,next,opts) {
   var caption_count = 'Image ' + (opts.currSlide + 1) + ' of ' + opts.slideCount;
   $('#caption4').html(caption_count);
}</pre><p></p>
<p>There&#8217;s something new going on here. A named function, <em>slideAfter</em>, is the value for the <em>after</em> option. Using a function we can make calculations and assignments to create some interesting captions. Cycle&#8217;s <em>before</em> option also may take a function as its value.</p>
<p>The function <em>slideAfter</em> calculates and specifies the number of the current image and the total number of slides in the slideshow. The calculated values are assigned to a variable, <em>caption_count</em>, which is then used as the image caption.</p>
<p>Example 3 HTML Markup:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;slide3&quot;&gt;
  &lt;div id=&quot;slideboth&quot;&gt;
    &lt;img src=&quot;/images/pic1.jpg&quot; alt=&quot;Baby Sixtoes and his brothers.&quot; /&gt;
    &lt;img src=&quot;/images/pic2.jpg&quot; alt=&quot;Missy cat in snow.&quot; /&gt;
    &lt;img src=&quot;/images/pic3.jpg&quot; alt=&quot;Momma cat in tree.&quot; /&gt;
    &lt;img src=&quot;/images/pic4.jpg&quot; alt=&quot;Darling kittens napping.&quot; /&gt;
  &lt;/div&gt;
  &lt;p id=&quot;caption5&quot;&gt;&lt;span id=&quot;caption3&quot;&gt;&lt;/span&gt;  (&lt;span id=&quot;caption4&quot;&gt;&lt;/span&gt;)&lt;/p&gt;
&lt;/div&gt;</pre>
<p>In this example #caption5 is used for CSS positioning, while #caption3 and #caption4 are targeted by the JavaScript in creating the caption.</p>
<p>Example 3 Slideshow:</p>
<div id="slide3">
<div id="slideboth">
  <img src="/images/pic1.jpg" alt="Baby Sixtoes and his brothers." /><br />
  <img src="/images/pic2.jpg" alt="Missy cat in snow." /><br />
  <img src="/images/pic3.jpg" alt="Momma cat in tree." /><br />
  <img src="/images/pic4.jpg" alt="Darling kittens napping." />
</div>
<p id="caption5"><span id="caption3"></span>  (<span id="caption4"></span>)</p>
</div>
<div class="clear"> </div>
<p>Examples borrowed from <a href="http://www.malsup.com/jquery/cycle/count.html" title="Demonstrate image count as slide caption.">jQuery Cycle image count caption demo</a>.</p>
<p>These examples showed how to create captions for images presented in slideshows with the jQuery Cycle plugin. </p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/slideshow-image-captions-with-jquery-cycle/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Specify Children for jQuery Cycle Slideshows</title>
		<link>http://computeraxe.com/specify-children-for-jquery-cycle-slideshows/</link>
		<comments>http://computeraxe.com/specify-children-for-jquery-cycle-slideshows/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 07:05:58 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=922</guid>
		<description><![CDATA[The jQuery Cycle plugin is a versatile JavaScript plugin for making slideshows. The default behavior is to fade in a new slide, let the viewer see the slide for four seconds, then fade out that slide as the next one &#8230; <a href="http://computeraxe.com/specify-children-for-jquery-cycle-slideshows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The jQuery Cycle plugin is a versatile JavaScript plugin for making slideshows.</p>
<p>The default behavior is to fade in a new slide, let the viewer see the slide for four seconds, then fade out that slide as the next one fades in. Slides are faded in and out continuously and in a sequential manner. Unless specified in the options, a slideshow starts with the first slide and cycles through all slides, then loops back to the first slide, running continuously.</p>
<p>Options are available to change every aspect of the slideshow behavior, so the kind and timing of the transitions can be easily changed, as well as the starting and ending slides of the show.</p>
<p>It&#8217;s beyond the scope of this post to review all the Cycle options, but one option that may come in handy is <a href="http://www.malsup.com/jquery/cycle/options.html" title="jQuery Cycle Option - slideExpr">the <em>slideExpr</em> option</a>. The default value is &#8216;<em>NULL</em>&#8216; and it&#8217;s described as the &#8220;expression for selecting slides (if something other than all children is required)&#8221;.</p>
<p>So far, there are two instances where <em>slideExpr</em> has saved my day. Basically, it lets you specify the children of the slideshow and that&#8217;s important if you&#8217;re using WordPress or if you&#8217;re wrapping slides in links.</p>
<h2>WordPress or Other CMS</h2>
<p>Using JavaScript inside WordPress posts can be tricky. One has to properly register and queue up the scripts with the methods <em>wp_register_script()</em> and <em>wp_enqueue_script()</em> instead of inserting &lt;script> tags in the page headers.</p>
<p>Still, things may not look right when a post is previewed because of the way that WordPress assembles the pages we see on the World Wide Web. WordPress or another content management system (CMS) may insert line breaks that interrupt the flow of a slideshow.</p>
<p>Remember, with the Cycle plugin every child element inside the slideshow container will become a slide. That means every CMS inserted &lt;br /&gt; will be treated as a slide. This produces a slideshow with long, blank pauses in between the actual slides, like the slideshow on the left below, #show_a.</p>
<p>Use <em>slideExpr</em> to specify the children elements for slideshows in WordPress. This avoids extraneous elements from the content management system from being interpreted as slides. See the slideshow on the right below, #show_b.</p>
<p>HTML Markup:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;show_a&quot;&gt;
  &lt;a href=&quot;/images/1.jpg&quot;&gt;&lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/2.jpg&quot;&gt;&lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/3.jpg&quot;&gt;&lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/4.jpg&quot;&gt;&lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/5.jpg&quot;&gt;&lt;img src=&quot;../images/5.jpg&quot; alt=&quot;five&quot; /&gt;&lt;/a&gt;
  &lt;p&gt;&nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;show_b&quot;&gt;
  &lt;a href=&quot;/images/1.jpg&quot;&gt;&lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/2.jpg&quot;&gt;&lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/3.jpg&quot;&gt;&lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/4.jpg&quot;&gt;&lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/5.jpg&quot;&gt;&lt;img src=&quot;../images/5.jpg&quot; alt=&quot;five&quot; /&gt;&lt;/a&gt;
  &lt;p&gt;&nbsp;&lt;/p&gt;
&lt;/div&gt;</pre>
<div class="outernum">
<div id="show_a">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p> </p>
</div>
<div id="show_b">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p> </p>
</div>
</div>
<div class="clear"> </div>
<p>The left slideshow, #show_a, shows a few different transitions without using <em>slideExpr</em>, which gives a background-colored pause or blank pause in between each slide. This slideshow assumes the first-level children are the elements to be manipulated in the slideshow.</p>
<p>The right slideshow, #show_b, shows the same transitions with <em>slideExpr</em> set to &#8216;img&#8217;. This gives the expected behavior where only the images, &lt;img&gt;, are treated as slides, not any other element that may be inserted by WordPress or by the developer.</p>
<p>JavaScript:</p>
<p></p><pre class="crayon-plain-tag">$('#show_a').cycle({ 
  fx: 'fade,toss,fadeZoom',
  speed: 700,
  timeout: 2000
});
	 
$('#show_b').cycle({
  fx: 'fade,toss,fadeZoom',
  speed: 700,
  timeout: 2000,
  slideExpr: 'img'
});</pre><p></p>
<h2>Wrapping slides</h2>
<p>If you&#8217;re not using WordPress or another CMS, there may still be unexpected behavior with the Cycle plugin with respect to children of the slide show.</p>
<p>Any children in a container element can be used as a slide with the jQuery Cycle plugin. Designers can get as fancy or as funky as they want to with their slideshows because they ultimately have complete control. If you want to wrap each image in an anchor which is wrapped in a styling div, that&#8217;s ok. </p>
<p>Just remember to use <em>slideExpr: &#8216;img&#8217;</em> if it is the images that you want to transition from slide to slide. HTML Markup is very similar to that above with different container ids for JavaScript and CSS targeting.</p>
<div class="outernum">
<div id="show_1">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p> </p>
</div>
<div id="show_2">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p> </p>
</div>
</div>
<div class="clear"> </div>
<p>In this example the slideshow on the left, #show_1, uses the &#8216;fadeZoom&#8217; transition effect without <em>slideExpr</em>. Slideshow #show_2 on the right uses the &#8216;fadeZoom&#8217; transition effect with <em>slideExpr: &#8216;img&#8217;</em>. Note how the actual transition effect is different depending on which element is serving as the slide. </p>
<p>JavaScript:</p>
<p></p><pre class="crayon-plain-tag">$('#show_1').cycle({ 
    fx: 'fadeZoom',
    speedIn: 700,
    speedOut: 1200,
    timeout: 2000
    });
	 
    $('#show_2').cycle({
    fx: 'fadeZoom',
    speedIn: 700,
    speedOut: 1200,
    timeout: 2000,
    slideExpr: 'img'
    });</pre><p></p>
<p>Note the empty paragraph in the HTML markup for each slideshow. Without specifying the <em>slideExpr</em> option, as in #show_1, the empty paragraph is treated as a slide and a blank space is shown for it. Slideshow #show_2 specifies that the images are to be the sliding elements, so no blank space is seen.</p>
<p>Certain <a href="http://computeraxe.com/jquery-cycle-plugin-working-with-links/" title="Problems with transition effects and their solutions.">transition effects problems</a> may appear when wrapping slides with links in jQuery Cycle. Using the <em>slideExpr</em> option is an easy solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/specify-children-for-jquery-cycle-slideshows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Cycle Plugin Working with Links</title>
		<link>http://computeraxe.com/jquery-cycle-plugin-working-with-links/</link>
		<comments>http://computeraxe.com/jquery-cycle-plugin-working-with-links/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 07:05:37 +0000</pubDate>
		<dc:creator>axe</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://computeraxe.com/?p=913</guid>
		<description><![CDATA[The Cycle plugin for use with the jQuery library can be described as a robust, mature and versatile JavaScript plugin. Plentiful options allow every aspect of a slideshow created with Cycle to be modified. For interactive slideshows where you&#8217;d like &#8230; <a href="http://computeraxe.com/jquery-cycle-plugin-working-with-links/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Cycle plugin for use with the jQuery library can be described as a robust, mature and versatile JavaScript plugin. Plentiful options allow every aspect of a slideshow created with Cycle to be modified.</p>
<p>For interactive slideshows where you&#8217;d like the user to be able to click on a slide to get more information, wrap an anchor around each slide. Then, when the user clicks on a slide they will be shown the target link. You could show the user a larger image, an expanded view of a portion of the image, or more descriptive text about the slide.</p>
<p>The markup is straightforward, using an unordered list of links:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;show&quot;&gt;
  &lt;a href=&quot;&quot;&gt;&lt;/a&gt;
  &lt;a href=&quot;&quot;&gt;&lt;/a&gt;
  &lt;a href=&quot;&quot;&gt;&lt;/a&gt;
  &lt;a href=&quot;&quot;&gt;&lt;/a&gt;
  &lt;a href=&quot;&quot;&gt;&lt;/a&gt;
&lt;/div&gt; &lt;!-- end div#show --&gt;</pre>
<h2>Transition Effects Problem</h2>
<p>Wrapping anchors around each slide makes them clickable, but that introduces a potential problem when using the Cycle plugin. Some of the transition effects just won&#8217;t work as expected. In this example the children that will be manipulated inside the #show container are the anchor links, <em>not the images</em>. Even though we know it&#8217;s supposed to be the images that are to be swapped in and out of this slideshow, technically, the children that will be swapped are the anchors, and that makes a difference in how things will look. Images are contained <em>inside the anchors</em>, so the images won&#8217;t be manipulated, just the anchors.</p>
<p>Most of the available transition effects modify the size of the slide&#8217;s width and/or height to achieve the desired effect. When an anchor is wrapped around an image, the anchor&#8217;s size can be manipulated, but the contained image won&#8217;t be resized. If one of the transitions that manipulate the slide width or height has been called, the effect won&#8217;t be seen as intended. </p>
<p>For example, the two slideshows below use the same HTML markup, except for having different container ids, which are targeted by the script and the CSS. Images are wrapped by &lt;a&gt; in both the left and right slideshows below.</p>
<p>Here&#8217;s the HTML Markup for the example slideshows below:</p>
<pre class="crayon-plain-tag">&lt;div id=&quot;showleft&quot;&gt;
  &lt;a href=&quot;/images/1.jpg&quot;&gt;&lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/2.jpg&quot;&gt;&lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/3.jpg&quot;&gt;&lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/4.jpg&quot;&gt;&lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/5.jpg&quot;&gt;&lt;img src=&quot;../images/5.jpg&quot; alt=&quot;five&quot; /&gt;&lt;/a&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;showright&quot;&gt;
  &lt;a href=&quot;/images/1.jpg&quot;&gt;&lt;img src=&quot;../images/1.jpg&quot; alt=&quot;one&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/2.jpg&quot;&gt;&lt;img src=&quot;../images/2.jpg&quot; alt=&quot;two&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/3.jpg&quot;&gt;&lt;img src=&quot;../images/3.jpg&quot; alt=&quot;three&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/4.jpg&quot;&gt;&lt;img src=&quot;../images/4.jpg&quot; alt=&quot;four&quot; /&gt;&lt;/a&gt;
  &lt;a href=&quot;/images/5.jpg&quot;&gt;&lt;img src=&quot;../images/5.jpg&quot; alt=&quot;five&quot; /&gt;&lt;/a&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;</pre>
<p>Using one of the <em>turn</em> effects illustrates how the different children behave. The slideshow on the left is manipulating anchors, while a slight change in the script allows the slideshow on the right to manipulate the images. Both slideshows below use the <em>turnDown</em> transition effect.</p>
<p>Watch each slide transition and you&#8217;ll see that the one on the left doesn&#8217;t show any turning behavior as the top slide is dragged off the lower slide. In the slideshow on the right the <em>turnDown</em> effect can be seen as the images are manipulated in a way to make it look like the next image is being turned down from above.</p>
<div class="outernum">
<div id="showleft">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p>&nbsp;</p>
</div>
<div id="showright">
  <a href="/images/1.jpg"><img src="../images/1.jpg" alt="one" /></a><br />
  <a href="/images/2.jpg"><img src="../images/2.jpg" alt="two" /></a><br />
  <a href="/images/3.jpg"><img src="../images/3.jpg" alt="three" /></a><br />
  <a href="/images/4.jpg"><img src="../images/4.jpg" alt="four" /></a><br />
  <a href="/images/5.jpg"><img src="../images/5.jpg" alt="five" /></a></p>
<p>&nbsp;</p>
</div>
<p> <!-- end div#showright -->
</div>
<p> <!-- end div.outernum --></p>
<div class="clear">&nbsp;</div>
<p>This phenomenon happens using the jQuery Cycle plugin when an anchor, &lt;div&gt;, or any other tag wraps around the images, in effect taking their place as children of the slideshow container.</p>
<h3>slideExpr Solution</h3>
<p>One solution is to use the <em>slideExpr</em> option. The default value for <em>slideExpr</em> is &#8216;<em>NULL</em>&#8216; which indicates that the default children will be manipulated as the slides, as in the slideshow on the left.</p>
<p></p><pre class="crayon-plain-tag">$('#showleft').cycle({
  fx: 'turnDown',
  speed: 700,
  timeout: 2000
});
	 
$('#showright').cycle({
  fx: 'turnDown',
  speed: 700,
  timeout: 2000,
  slideExpr: 'img'
});</pre><p></p>
<p>The slideshow on the right, #showright, has specified the option <em><strong>slideExpr: &#8216;img&#8217;</strong></em> to assure that the &lt;img&gt; should be treated as slides, see line 11. By specifying which element should be treated as the children of the slideshow container, the transition <em>fx</em> can be seen as intended. </p>
<p>Slideshows can use any content for slides, so remember that extra elements in the slideshow container will be treated as slides. Inspect the HTML markup above and take note of the blank paragraph in each slideshow container. The default slideshow on the left, #showleft, assumes that the &lt;p&gt; is a child that is part of the slideshow, so it shows a blank paragraph after the last slide. Only images are slides in the slideshow #showright, so its behavior is to wrap around to the first &lt;img&gt;, instead of showing the blank paragraph as the last slide.</p>
<h3>fx Solution</h3>
<p>Another way to avoid the transition effect problem is to stick with the slide transitions that aren&#8217;t affected when using wrappers around slides. When the design requires wrapping slides in anchors or divs, pick from the subset of transition effects that doesn&#8217;t modify the image size. To see the true effects use <em>fade</em>, <em>scrollUp</em>, <em>scrollDown</em>, <em>scrollLeft</em>, <em>scrollRight</em>, and <em>shuffle</em> for slide transitions.</p>
<p>Note: The blank spaces between each slide in #showleft are due to the way that WordPress assembles a webpage or post. Use <em>slideExpr</em> with WordPress to avoid having WordPress-injected elements acting as slides in slideshows with the jQuery Cycle plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://computeraxe.com/jquery-cycle-plugin-working-with-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

