<?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>Tatva-Artha &#187; image manipulation</title>
	<atom:link href="http://www.tatvartha.com/tag/image-manipulation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tatvartha.com</link>
	<description>meaning of &#34;it&#34;</description>
	<lastBuildDate>Sat, 22 Oct 2011 22:00:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Voting fixtures in jQuery &#8211; Thumbs Up, Thumbs Down</title>
		<link>http://www.tatvartha.com/2009/05/voting-fixtures-in-jquery-thumbs-up-thumbs-down/</link>
		<comments>http://www.tatvartha.com/2009/05/voting-fixtures-in-jquery-thumbs-up-thumbs-down/#comments</comments>
		<pubDate>Sun, 03 May 2009 18:57:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[image manipulation]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[live-query]]></category>
		<category><![CDATA[voting]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=102</guid>
		<description><![CDATA[Recently I had to implement voting system for one of my projects. In summary, the system had to allow user to easily vote Yay or Nay for a given item. I implemented this using thumbs-up thumbs-down images in jQuery/Ajax. First I wrote a re-usable function/plugin in jQuery: $.fn.mouseOverImageSwitch = function(default_image, mouse_over_image) { $(this).livequery('mouseout', function (){ [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Recently I had to implement voting system for one of my projects. In summary, the system had to allow user to easily vote Yay or Nay for a given item. I implemented this using thumbs-up thumbs-down images in jQuery/Ajax.</p>
<p><img src="http://www.tatvartha.com/wp-content/uploads/2009/05/voting-in-jquery.png" style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; DISPLAY: inline; BORDER-LEFT: #000000 1px solid; WIDTH: 583px; BORDER-BOTTOM: #000000 1px solid; HEIGHT: 165px" height="165" alt="voting-in-jquery.png" width="583"/></p>
<p> <span id="more-102"></span>
<p>First I wrote a re-usable function/plugin in jQuery:</p>
<p><code>$.fn.mouseOverImageSwitch = function(default_image, mouse_over_image) { <br/>$(this).livequery('mouseout', function (){ <br/>$(this).attr('src',default_image); <br/>}); <br/>$(this).livequery('mouseover', function (){ <br/>$(this).attr('src',mouse_over_image); <br/>}); <br/>};</code> <br/></p>
<p>This function would allow me to call image-switching on mouse-over event on any element. Now we need to hook this call to an img element so we can switch images when the user brings mouse over a voting icon. Assuming, I had following elements with img elements with class attributes like &#8220;thumbs_up&#8221; and &#8220;thumbs_down&#8221;:</p>
<pre id="line60">
&lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"</span>&gt;&lt;<span class="start-tag">img</span><span class="attribute-name"> </span><span class="attribute-name">class</span>=<span class="attribute-value">"thumbs_up" </span><span class="attribute-name">src</span>=<span class="attribute-value">"/images/thumbs_up_grey.png"</span>&gt;&lt;/<span class="end-tag">a</span>&gt;
&lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"</span>&gt;&lt;<span class="start-tag">img</span><span class="attribute-name"> class</span>=<span class="attribute-value">"thumbs_down" </span><span class="attribute-name">src</span>=<span class="attribute-value">"/images/thumbs_down_grey.png"</span>&gt;&lt;/<span class="end-tag">a</span>&gt;
</pre>
<p>I did following to hook the call up.</p>
<p><code>&lt;script type="text/javascript"&gt; <br/>(function($) { <br/>$(document).ready(function(){ <br/>$('.thumbs_up').mouseOverImageSwitch('/images/thumbs_up_grey.png','/images/thumbs_up_colored.png'); <br/>$('.thumbs_down').mouseOverImageSwitch('/images/thumbs_down_grey.png','/images/thumbs_down_colored.png'); <br/>}); <br/>&lt;/script&gt;</code></p>
<p>In the original plugin function, I used livequery which allows me to bind mouse-over hook to elements that were added using ajax. I can image that too many such hooks would <a href="http://groups.google.com/group/jquery-en/browse_thread/thread/432a0d9caae734db?pli=1">degrade performance</a>. I will wait to see how this works before performing performance optimizations &#8230;</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2009/05/voting-fixtures-in-jquery-thumbs-up-thumbs-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

