<?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>code and effect &#187; js</title>
	<atom:link href="http://www.codeandeffect.co.uk/blog/category/programming/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codeandeffect.co.uk/blog</link>
	<description>It's quite deliberate</description>
	<lastBuildDate>Mon, 08 Mar 2010 14:28:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Background Animations in Script.Aculo.Us</title>
		<link>http://www.codeandeffect.co.uk/blog/2008/programming/js/background-animations-in-scriptaculous/</link>
		<comments>http://www.codeandeffect.co.uk/blog/2008/programming/js/background-animations-in-scriptaculous/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 20:14:24 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[js]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Scriptaculous]]></category>
		<category><![CDATA[snook]]></category>

		<guid isPermaLink="false">http://www.codeandeffect.co.uk/blog/?p=302</guid>
		<description><![CDATA[Inspired by Jonathan Snook&#8217;s article on animating backgrounds using Jquery, I had a snoop around in Script.aculo.us for the equivalent methods to create moving background images. It wasn&#8217;t long before I hit a wall with the Effect.Morph method and its inability to parse the CSS values for background-position.



Effect.Morph simply examines current CSS values and calculates [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by Jonathan Snook&#8217;s article on <a title="Using jQuery for Background Image Animations" href="http://snook.ca/archives/javascript/jquery-bg-image-animations/">animating backgrounds using Jquery</a>, I had a snoop around in Script.aculo.us for the equivalent methods to create moving background images. It wasn&#8217;t long before I hit a wall with the Effect.Morph method and its <a title="Effect.Morph will not change vertical background position" href="http://groups.google.com/group/prototype-scriptaculous/msg/595e2867c1c80812">inability to parse the CSS values for background-position</a>.</p>
<p><center><br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="320" height="100" ID="Captivate1"><param name="movie" value="/demos/morphbgpos/bgpos.swf"><param name="quality" value="high"><param name="menu" value="false"><param name="loop" value="1"><embed src="/demos/morphbgpos/bgpos.swf" width="320" height="100" loop="1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed></object><br />
</center></p>
<p><a title="Effect.Morph" href="http://github.com/madrobby/scriptaculous/wikis/effect-morph">Effect.Morph</a> simply examines current CSS values and calculates new ones, iterating through a number of <em>transforms</em> according to the duration of the morph. Colour values are handled appropriately, but for positioning only a single value is anticipated. As the second value of <em>background-position</em> is never parsed, you&#8217;re limited to horizontal animation.</p>
<p>see a <a href="/demos/morphbgpos/example1.html" target="_blank">demo of the problem</a>.</p>
<p>So I&#8217;ve created an extension, similar to Alexander Farkas&#8217; for JQuery, to manipulate <em>background-position</em> both vertically and horizontally using the same syntax as Effect.Morph.</p>
<p>See it in action on <a title="Horizontal and Vertical example" href="http://codeandeffect.co.uk/demos/morphbgpos/example2.html" target="_blank">Horizontal and Vertical background animations</a> and <a href="http://codeandeffect.co.uk/demos/morphbgpos/example3.html" target="_blank">Vertical only</a>.</p>
<p><strong>Using the Effect.Morphbgpos extension</strong></p>
<p>Include in the <em>&lt;head&gt;</em> the Prototype and Script.aculo.us libraries as usual. Download the extension and include it <em>after </em>the main libraries:</p>
<pre>&lt;script src="bgposeffect.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>Jonathan did a great job describing his HTML and CSS markup (including how to show the final states of the animation using CSS just in case Javascript is not present) so I won&#8217;t repeat it all here. Suffice to say this is very similar: an unordered list with an id, containing three items, containing only links.</p>
<pre>&lt;body&gt;
...
&lt;ul id="a"&gt;
	&lt;li&gt;&lt;a href="#"&gt;Rivera&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Miro&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="#"&gt;Varo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
...</pre>
<p>Then (somewhere after the list) include the code observers that restyle your links on <em>mouseover </em>and <em>mouseout</em>:</p>
<pre>&lt;script type="text/javascript"&gt;
$$('#tabs a').each(
	function(s) {
		s.observe('mouseover', function(s){
			this.setStyle( {backgroundPosition: "0px 5px"});
			new Effect.Morphbgpos(this, {
			  style: 'background-position:0px -40px;color:#cc0000',
			  duration: 4.3
			});
		});
	 	s.observe('mouseout', function(s) {
			this.setStyle( {backgroundPosition: "0px -40px"});
			new Effect.Morphbgpos(this, {
			style: 'background-position:0px 5px;color:#c0c0c0',
			duration: 4.3
			});
		});
	});
&lt;/script&gt;</pre>
<p>Note that in the example each of the observer methods sets the state directly before animating it. <em>Mouseover</em> begins from the original state set in the CSS while <em>Mouseout </em>sets the finished state (as in the CSS link hover state ) before animating back to the original state.</p>
<p><strong>How it works</strong></p>
<p>Very simple. Effect.Morphbgpos is a modified version of Effect.Morph that anticipates having to handle two sets of pixel values. It reads the current states into x and y variables, manipulates them and writes out the appropriate CSS, repeating until the final state is reached.</p>
<p><strong>Handling Other <em>Effect.Morph</em> CSS properties<br />
</strong></p>
<p>The extension will pass any CSS that isn&#8217;t a background-position property to a new instance of Effect.Morph.</p>
<p>You should be able to replace all <em>Effect.Morph</em> calls with <em>Effect.Morphbgpos</em>, and then simply find+replace them when this functionality becomes available in a future version of the framework.</p>
<p><strong>Limitations<br />
</strong></p>
<p>This first version only handles explicit background-position statements, using pixel values, and <em>duration </em>is the only supported option.</p>
<p>As it&#8217;s only extending Script.aculo.us by a fraction it seems to be robust across the browsers I&#8217;ve tested.</p>
<p><strong>Download &amp; usage<br />
</strong></p>
<p>Download the <a title="download the Effect.Morphbgpos extension" href="http://codeandeffect.co.uk/demos/morphbgpos/bgposeffect.js" target="_blank">js file</a> here (or <a title="download the Effect.Morphbgpos extension (.txt)" href="http://codeandeffect.co.uk/demos/morphbgpos/bgposeffect.js.txt" target="_blank">here as text</a>). Use just as you would Effect.Morph by settings CSS property-value pairs, and a duration.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeandeffect.co.uk/blog/2008/programming/js/background-animations-in-scriptaculous/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Safari Beta for Windows</title>
		<link>http://www.codeandeffect.co.uk/blog/2007/programming/js/safari-beta-for-windows/</link>
		<comments>http://www.codeandeffect.co.uk/blog/2007/programming/js/safari-beta-for-windows/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 09:26:59 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.codeandeffect.co.uk/blog/2007/programming/js/safari-beta-for-windows/</guid>
		<description><![CDATA[Safari (beta, and for Windows), a bit of a damp squib this, I have a site in development for a client (and friend of old) with a strong Macintosh background.  The site makes good use of the script.aculo.us library to animate items to the screen. I&#8217;d hoped this would allow me to stop switching [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/safari/">Safari</a> (beta, and for Windows), a bit of a damp squib this, I have a site in development for a client (and friend of old) with a strong Macintosh background.  The site makes good use of the <a href="http://script.aculo.us">script.aculo.us</a> library to animate items to the screen. I&#8217;d hoped this would allow me to stop switching machines quite so often for testing.</p>
<p>Loading the site up, I get no body text where I would expect it to load. The beta doesn&#8217;t seem to contain a Script debugger either. Reading through the docs for Safari I have to add the debug menu via terminal window (so no Win specific help then!).</p>
<p>I&#8217;m stuck now with a site I need to be <em>exceptionally </em>Safari friendly, but can&#8217;t debug. So am also stuck with a browser beta I can&#8217;t test any further.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeandeffect.co.uk/blog/2007/programming/js/safari-beta-for-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple returns</title>
		<link>http://www.codeandeffect.co.uk/blog/2006/work-stuff/simple-returns/</link>
		<comments>http://www.codeandeffect.co.uk/blog/2006/work-stuff/simple-returns/#comments</comments>
		<pubDate>Fri, 22 Sep 2006 09:51:31 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[js]]></category>
		<category><![CDATA[work stuff]]></category>

		<guid isPermaLink="false">http://www.codeandeffect.co.uk/blog/?p=35</guid>
		<description><![CDATA[Simple Back Button generator (opens in a new window)
It&#8217;s not rocket science, in fact it&#8217;s probably not even breadmaker science, but it&#8217;s useful. Detects if there&#8217;s a history to return to before adding a back button to a menu of your choosing.
Our CMS generated breadcrumb trail reflects the site structure, not an individual user&#8217;s path [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" title="Simple but clever" href="/tests/jsback/">Simple Back Button generator</a> (opens in a new window)</p>
<p>It&#8217;s not rocket science, in fact it&#8217;s probably not even breadmaker science, but it&#8217;s useful. Detects if there&#8217;s a history to return to before adding a back button to a menu of your choosing.</p>
<p>Our CMS generated breadcrumb trail reflects the site structure, not an individual user&#8217;s path into the site &#8211; this was one possible solution to the loss of adequate return navigation when you go from one site area (say a school) to another (a service team perhaps).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeandeffect.co.uk/blog/2006/work-stuff/simple-returns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag n&#8217; Drop CAPTCHA puzzle</title>
		<link>http://www.codeandeffect.co.uk/blog/2006/programming/php/dragndrop-captcha/</link>
		<comments>http://www.codeandeffect.co.uk/blog/2006/programming/php/dragndrop-captcha/#comments</comments>
		<pubDate>Fri, 08 Sep 2006 13:33:09 +0000</pubDate>
		<dc:creator>Anthony</dc:creator>
				<category><![CDATA[js]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.codeandeffect.co.uk/blog/?p=28</guid>
		<description><![CDATA[
Simply re-arrange the images to make a visible key before clicking submit.

Fiddling with Scriptaculous earlier today I had an idea for a CAPTCHA mechanism. Cycling through the $_POST array in PHP gives you the form data, in order of submission.Scriptaculous&#8217; sortable feature allows you to change order of items in a List, so adding an [...]]]></description>
			<content:encoded><![CDATA[<div style="border: 0px solid #c0c0c0; padding: 0pt 0px 10px 5px; float: right; width: 218px"><a href="/tests/draganddropcaptcha/"><img id="image30" style="border: 0px none " alt="Drag n Drop CAPTCHA mechanism screenie" src="http://www.codeandeffect.co.uk/blog/wp-content/uploads/2006/09/dragndropcaptcha.png" /></a></p>
<div style="padding: 0pt 0px 5px 5px; text-align: center; font-family: serif; font-size: 90%">Simply re-arrange the images to make a visible key before clicking submit.</div>
</div>
<p>Fiddling with <a title="visit http://script.aculo.us/" href="http://script.aculo.us/">Scriptaculous</a> earlier today I had an idea for a <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Captcha">CAPTCHA</a> mechanism. Cycling through the $_POST array in PHP gives you the form data, in order of submission.Scriptaculous&#8217; <em>sortable</em> feature allows you to change order of items in a List, so adding an image with corresponding hidden input field gives you a basic puzzle  to satisfy the CAPTCHA requirement.</p>
<div><a title="Clickety" href="http://www.codeandeffect.co.uk/tests/draganddropcaptcha/">Simple Drag n&#8217; Drop CAPTCHA</a> (written 8th September, 2006, code available on request).</div>
<p>Still comes with all the same accessibility problems most mechanisms have (with the added JS requirement), but saves the need for image generation.This version *can* use any naming convention for the images and input field names, they&#8217;re generated and checked by an array so don&#8217;t need to be numerically ordered &#8211; which could be a giveaway.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeandeffect.co.uk/blog/2006/programming/php/dragndrop-captcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
