<?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>sylv3rblade dot com &#187; jQuery</title>
	<atom:link href="http://sylv3rblade.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://sylv3rblade.com</link>
	<description>Enjoying a Geek&#039;s Life with Anime, Rails, and Digital Photography!</description>
	<lastBuildDate>Fri, 02 Mar 2012 03:11:01 +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>Autofit an image in a div using JQuery</title>
		<link>http://sylv3rblade.com/2011/02/autofit-an-image-in-a-div-using-jquery/</link>
		<comments>http://sylv3rblade.com/2011/02/autofit-an-image-in-a-div-using-jquery/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 02:35:22 +0000</pubDate>
		<dc:creator>sylv3rblade</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://sylv3rblade.com/?p=67</guid>
		<description><![CDATA[I had a problem with one of my current projects where I was supposed to have an image enclosed in a div with fixed dimensions. For the dimensions of the div, you can set it inline or use css file: (&#8230;)</p><p><a href="http://sylv3rblade.com/2011/02/autofit-an-image-in-a-div-using-jquery/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I had a problem with one of my current projects where I was supposed to have an image enclosed in a div with fixed dimensions.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;resize-div&quot;&gt;
&lt;img src=&quot;someimage.jpg&quot;, :id=&quot;resize-div&quot;&gt;
&lt;/div&gt;
</pre>
<p>For the dimensions of the div, you can set it inline or use css file:</p>
<pre class="brush: css; title: ; notranslate">
#resize-div {
width:466px;
height:133px;
}
</pre>
<p>Now since not all images will fit this aspect ratio you&#8217;ll encounter problems easily enough.   With images smaller than the div, I had little problem letting the css to handle it so it&#8217;s situated perfectly center in the div.  I didn&#8217;t include it here to shorten the codes i need to display <img src='http://sylv3rblade.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Judging from the code shown above, you&#8217;ll not that if you have larger images that exceeded the div&#8217;s set height and width (especially those width different aspect ratios), a pure css solution simply won&#8217;t work (or at least I couldn&#8217;t make it work&#8230;. :/) so I thought of using JQuery to work it out for me.</p>
<p>Here&#8217;s my script to autofit images in a div using JQuery.</p>
<pre class="brush: jscript; title: ; notranslate">
$(function(){
	var divElem = $(&quot;#resize-div&quot;);
	var maxht = divElem.height();
	var maxwdt = divElem.width();
	var imgElem = $(&quot;#resize-image&quot;);
	var ht = imgElem.height();
	var wdt = imgElem.width();
	if (ht &lt; wdt){
		if (wdt &gt; maxwdt)
			$(&quot;#resize-image&quot;).css({'height' : &quot;auto&quot;, 'width' : maxwdt});
		else
			$(&quot;#resize-image&quot;).css({'height' : &quot;auto&quot;, 'width' : wdt});
	}
	else if (ht &gt; wdt){
		if (ht &gt; maxht)
			$(&quot;#resize-image&quot;).css({'height' : maxht, 'width' : &quot;auto&quot;});
		else
			$(&quot;#resize-image&quot;).css({'height' : ht, 'width' : &quot;auto&quot;});
	}
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sylv3rblade.com/2011/02/autofit-an-image-in-a-div-using-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using jQuery datepicker with Facebox</title>
		<link>http://sylv3rblade.com/2009/12/using-jquery-datepicker-with-facebox/</link>
		<comments>http://sylv3rblade.com/2009/12/using-jquery-datepicker-with-facebox/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 13:07:57 +0000</pubDate>
		<dc:creator>sylv3rblade</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Facebox]]></category>

		<guid isPermaLink="false">http://www.sylv3rblade.com/?p=10</guid>
		<description><![CDATA[Facebox is an interesting jquery plugin but it&#8217;s also one of those annoying things on the web that likes to break stuff around it.  For my current project, I needed to use jQuery&#8217;s datepicker plugin with facebox. As expected, facebox (&#8230;)</p><p><a href="http://sylv3rblade.com/2009/12/using-jquery-datepicker-with-facebox/">Read the rest of this entry &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://famspam.com/facebox">Facebox</a> is an interesting jquery plugin but it&#8217;s also one of those annoying things on the web that likes to break stuff around it.  For my current project, I needed to use jQuery&#8217;s datepicker plugin with facebox. As expected, facebox broke datepicker <img src='http://sylv3rblade.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> .  I wanted to try several other implementations but since <a href="http://jqueryui.com/demos/datepicker/">jQuery&#8217;s datepicker</a> was the simplest one I could find, I didn&#8217;t want to waste time trying make another script work.  So I took a few minutes to debug my problem.</p>
<p>The problem:</p>
<p>Turns out that datequery relies on an elements ID.  The problem?  Facebox duplicates all the contents of the div you wanted to display and all hell breaks loose.</p>
<p>The solution:</p>
<p>Quite simple actually.</p>
<p>Just use jQuery to replace the element id within facebox at run time.</p>
<p>Here&#8217;s the script:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).bind('reveal.facebox', function() {
  $('#facebox .datepicker').each( function(intIndex){
    $(this).attr('id',jQuery(this).attr('id') + '-2')
  });
});
</pre>
<p>Then just modify your binding for datepicker accordingly:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).bind('reveal.facebox', function() {
	$('#date_filed_for-2').datepicker();
})
</pre>
<p>And you&#8217;re done.  <img src='http://sylv3rblade.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I found this code using google-fu on <a href="http://www.frenzicmojo.net/2009/11/fun-with-jquery-datepicker-and-facebox/">frenzicmojo.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sylv3rblade.com/2009/12/using-jquery-datepicker-with-facebox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

