<?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>JJ Is Me &#187; javascript</title>
	<atom:link href="http://jjis.me/a/tag/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://jjis.me</link>
	<description>Me And My Code</description>
	<lastBuildDate>Sun, 29 Jan 2012 22:14:15 +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>jQuery Multi-Accordion</title>
		<link>http://jjis.me/a/719</link>
		<comments>http://jjis.me/a/719#comments</comments>
		<pubDate>Sat, 27 Aug 2011 05:15:00 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=719</guid>
		<description><![CDATA[I&#8217;ve developed my previous accordion a little further now. I&#8217;ve turned into a full plugin, plus it allows for multiple accordions on the same page. The way this differs, however, is that it allows you to create one accordion that closes open elements in another accordion and vice-versa. You may ask how this is different [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve developed my previous accordion a little further now. I&#8217;ve turned into a full plugin, plus it allows for multiple accordions on the same page. The way this differs, however, is that it allows you to create one accordion that closes open elements in another accordion and vice-versa. You may ask how this is different than a single accordion with tedious amounts of HTML and CSS. Well, the answer is simple: this is less work. By using jQuery&#8217;s traversing, I allow you to have more freedom in your HTML and CSS design, as well as fewer restraints on the hierarchical relationship between each accordion.</p>
<p>There is no CSS required for this plugin to work. The only CSS I recommend is setting the collapsible elements to &#8216;display: none&#8217;. This will keep the browser from rendering them initially causing that jittery appearance when the page first loads for the user.</p>
<p><span id="more-719"></span><br />
You can view the code below, with an example following:</p>
<h2>HTML:</h2>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">
&lt;div id=&quot;content-container&quot;&gt;
	&lt;!-- subsection of content container accordion 1 and 2 --&gt;
	&lt;div class=&quot;sub-content&quot;&gt;
		&lt;!-- Clickable headers (the actual anchor tags) that trigger the accordion --&gt;
		&lt;div class=&quot;accordion-headers&quot;&gt;
			&lt;a href=&quot;#&quot; class=&quot;clickable-header-accordion-1&quot;&gt;Click Me&lt;/a&gt;
			&lt;a href=&quot;#&quot; class=&quot;clickable-header-accordion-2&quot;&gt;Click Me&lt;/a&gt;
		&lt;/div&gt;
		&lt;!-- Accordion 1 header shows/hides this group --&gt;
		&lt;ul class=&quot;collapsible accordion1-collapsibles&quot;&gt;
			&lt;li&gt;First Accordion :: Item 1&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 2&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 3&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 4&lt;/li&gt;
		&lt;/ul&gt;
		&lt;!-- Accordion 2 header shows/hides this group --&gt;
		&lt;ul class=&quot;collapsible accordion2-collapsibles&quot;&gt;
			&lt;li&gt;Second Accordion :: Item 1&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 2&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 3&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 4&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;!-- // --&gt;

	&lt;!-- next subsection of content container accordion 1 and 2 --&gt;
	&lt;div class=&quot;sub-content&quot;&gt;
		&lt;!-- Clickable headers (the actual anchor tags) that trigger the accordion --&gt;
		&lt;div class=&quot;accordion-headers&quot;&gt;
			&lt;a href=&quot;#&quot; class=&quot;clickable-header-accordion-1&quot;&gt;Click Me&lt;/a&gt;
			&lt;a href=&quot;#&quot; class=&quot;clickable-header-accordion-2&quot;&gt;Click Me&lt;/a&gt;
		&lt;/div&gt;
		&lt;!-- Accordion 1 header shows/hides this group --&gt;
		&lt;ul class=&quot;collapsible accordion1-collapsibles&quot;&gt;
			&lt;li&gt;First Accordion :: Item 1&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 2&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 3&lt;/li&gt;
			&lt;li&gt;First Accordion :: Item 4&lt;/li&gt;
		&lt;/ul&gt;
		&lt;!-- Accordion 2 header shows/hides this group --&gt;
		&lt;ul class=&quot;collapsible accordion2-collapsibles&quot;&gt;
			&lt;li&gt;Second Accordion :: Item 1&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 2&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 3&lt;/li&gt;
			&lt;li&gt;Second Accordion :: Item 4&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;!-- // --&gt;
&lt;/div&gt;
</pre>
<p>&nbsp;</p>
<p><strong>Again, please note: </strong>The CSS that is recommended is setting the collapsible elements to &#8216;disaply: none;&#8217;. Aside from that, there is no additional CSS required other than what is needed for your design.</p>
<p>&nbsp;</p>
<h2>jQuery and Javascript:</h2>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.multi-accordion.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
	var accordions = [
		{
			'parent'      : '.sub-content',                  // parent element containing the clickable header and collapsible
			'header'      : '.clickable-header-accordion-1', // clickable header
			'collapsible' : '.accordion1-collapsibles'        // collapsible element
		},
		{
			'parent'      : '.sub-content',                      // parent element containing the clickable header and collapsible
			'header'      : '.clickable-header-accordion-2',     // clickable header
			'collapsible' : '.accordion2-collapsibles',          // collapsible element
			'afterclose'  : function() { alert('after close'); },// callback that is fired onced the accordion is closed
			'afteropen'   : function() { alert('after open'); }  // callback that is fired after the accordion is opened
		}
	];
	$().accordion(accordions);
});
&lt;/script&gt;
</pre>
<p>&nbsp;</p>
<h2>Working Example:</h2>
<p>You can view a working example at <a href="http://jjis.me/jquery.multi-accordion.html">http://jjis.me/jquery.multi-accordion.html</a></p>
<p><a href="http://jjis.me/jquery.multi-accordion.js">Download the jQuery Multi-Accordion plugin</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/719/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>I forgot about this hidden gem: Internet Explorer and Fade-In pitfalls</title>
		<link>http://jjis.me/a/407</link>
		<comments>http://jjis.me/a/407#comments</comments>
		<pubDate>Thu, 16 Sep 2010 15:48:23 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=407</guid>
		<description><![CDATA[jQuery&#8217;s fadeIn() method is a wonderful thing. It&#8217;s a great way to bring things in and out of the UI without a sudden jolt, visually. The downside to this, however, is Internet Explorer and the way it handles filters for transparency. When an element is faded in, and it contains fonts, IE does not remove [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery&#8217;s fadeIn() method is a wonderful thing. It&#8217;s a great way to bring things in and out of the UI without a sudden jolt, visually. The downside to this, however, is Internet Explorer and the way it handles filters for transparency. When an element is faded in, and it contains fonts, IE does not remove the filter by default. This prevents the fonts from smoothing like they should.</p>
<h2>Internet Explorer post standard jQuery fadeIn() method</h2>
<p><a href="http://jjis.me/wp-content/uploads/2010/09/ie-fadeIn-filter-effects.jpg"><img class="size-full wp-image-408 alignnone" title="Internet Explorer with jQuery fadeIn() filter effects" src="http://jjis.me/wp-content/uploads/2010/09/ie-fadeIn-filter-effects.jpg" alt="" width="600" height="91" /></a></p>
<p><span id="more-407"></span></p>
<p>In searching for a solution, I stumbled across a rather simple removeFilter() method someone created. This worked nice, but it meant you had to do chaining or a callback in order for the fadeIn() to work and then have the filter removed so the fonts would smooth. I&#8217;m lazy and I like to do everything in a single method if I can. So, let combine the fadeIn/fadeOut methods in to a single method and add the filter removal as well.</p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
(function($) {
	 $.fn.removeFilter = function() {
		if ($.browser.msie) {
			x = this.get(0)
			x.style.removeAttribute(&quot;filter&quot;);
		 }
	 }
})(jQuery);

(function($){
	 $.fn.fadeToggle = function(options) {
		  options  = typeof(options) != 'undefined'?options:'';
		  speed    = typeof(options.speed)!='undefined'?options.speed:'';
		  easing   = typeof(options.easing)!='undefined'?options.easing:'';
		  callback = typeof(options.callback)!='undefined'?options.callback:'';
		  callback = function(callback) {
			   $(this).removeFilter();
			   callback;
		  }

		  this.animate(
			   {opacity: 'toggle'},
			   speed,
			   easing,
			   callback
		  );
	 }
})(jQuery);
</pre>
<p>&nbsp;</p>
<h2>Use:</h2>
<pre class="brush: jscript; title: ; notranslate">
// normal speed
$('#objectId').fadeToggle();

// set fade in/out speed
$('#objectId').fadeToggle({ speed: 'fast' });
</pre>
<p>&nbsp;</p>
<h2>Internet Explorer post fadeToggle() method</h2>
<p><a href="http://jjis.me/wp-content/uploads/2010/09/ie-fadeToggle.jpg"><img src="http://jjis.me/wp-content/uploads/2010/09/ie-fadeToggle.jpg" alt="" title="Internet Explorer with fadeToggle method" width="600" height="91" class="alignnone size-full wp-image-411" /></a></p>
<p>&nbsp;</p>
<h2>Using removeFilter() method as a standalone method</h2>
<p>There may instances where you just need to remove the filter. In that case, the following works:</p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">

// as callback within fadeIn() method
$('#objectId').fadeIn('fast', function() {
        $(this).removeFilter();
});

// simply remove the filer on a specific object or objects
$('#objectId').removeFilter();
</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/407/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tabs &amp; Lists With Selectability</title>
		<link>http://jjis.me/a/313</link>
		<comments>http://jjis.me/a/313#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:04:26 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=313</guid>
		<description><![CDATA[I&#8217;ve recently come up with a need to allow users to view a list of options from which to choose. Do to screen restraints and readability, I opted to use the tabbing functionality I wrote about previously. In the process, however, I wrote some javascript that allows me to add the &#8216;pick and choose&#8217; functionality [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently come up with a need to allow users to view a list of options from which to choose. Do to screen restraints and readability, I opted to use the <a href="http://jjis.me/a/280">tabbing functionality I wrote about previously</a>. In the process, however, I wrote some javascript that allows me to add the &#8216;pick and choose&#8217; functionality to any pair of lists, or single list, I choose.</p>
<p><strong>Single List Mode: </strong>This is real simple. The user has a list of items to select from. When the select the item, the &#8216;selected&#8217; class is added to that item. When they de-select the item, the &#8216;selected&#8217; class is removed. This is tracked with a hidden input element with the id &#8216;ls_update_list_array&#8217;.</p>
<p><strong>Dual List Mode: </strong>When the user views &#8216;Categories Selected&#8217; (in this case, shown by default), they will see a list of categories currently selected. Under &#8216;All Available Categories&#8217;, they get a complete list of categories to selected from (in this case, minus those categories already selected). We want the user to be able to either add to the list of &#8216;Currently Selected&#8217; by clicking on the &#8216;All Categories&#8217; list, or remove items by clicking on them under &#8216;Currently Selected&#8217;. When they click on an item in either list, it is moved from list to the other. This is tracked with a hidden input element with the id &#8216;ls_update_list_array&#8217;.</p>
<p><strong>ls_update_list_array: </strong>This is provided simply to allow for an easy form post action. Rather than having Javascript determine when the form is posted and then grabbing the list as an array and blah, blah, blah, you get the list automatically on post.</p>
<p><span id="more-313"></span></p>
<h2>The HTML</h2>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">
&lt;div id=&quot;tabs&quot;&gt;&lt;b class=&quot;active&quot;&gt;&lt;a href=&quot;#selected-categories&quot;&gt;Currently Selected Categories&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;inactive&quot;&gt;&lt;a href=&quot;#all-categories&quot;&gt;All Available Categories&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;ul id=&quot;selected-categories&quot; class=&quot;tab&quot;&gt;
	&lt;li id=&quot;item1&quot; class=&quot;li-item selected&quot;&gt;Item 1 text&lt;/li&gt;
	&lt;li id=&quot;item3&quot; class=&quot;li-item selected&quot;&gt;Item 3 text&lt;/li&gt;
	&lt;li id=&quot;item7&quot; class=&quot;li-item selected&quot;&gt;Item 7 text&lt;/li&gt;
	&lt;li id=&quot;item8&quot; class=&quot;li-item selected&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
&lt;ul id=&quot;all-categories&quot; class=&quot;tab&quot;&gt;
	&lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
	&lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 2 text&lt;/li&gt;
	&lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
	&lt;li id=&quot;item4&quot; class=&quot;li-item&quot;&gt;Item 4 text&lt;/li&gt;
	&lt;li id=&quot;item5&quot; class=&quot;li-item&quot;&gt;Item 5 text&lt;/li&gt;
	&lt;li id=&quot;item6&quot; class=&quot;li-item&quot;&gt;Item 6 text&lt;/li&gt;
	&lt;li id=&quot;item7&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
	&lt;li id=&quot;item8&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
</pre>
<h2>The CSS</h2>
<p>You do not need to use this. You can use your own CSS.</p>
<pre class="brush: css; title: ; wrap-lines: false; notranslate">
#tabs { margin: 0 0 -2px 0; height: 45px; }
	#tabs b { display: block; float: left; margin: 0px; background: #fff; font-weight: normal; }
		#tabs b.active { background: #e0d3e3; }
		#tabs b.active a { color: #663366; }
		#tabs b.inactive a:hover { background: #f5edf6; }

	#tabs b a { display: block; color: #a989b0; padding: 10px; border: 1px solid #d3d3d3; text-decoration: none; }
	#tabs b a:hover { background: #f5edf6; }

.tab { clear: both; width: 100%; height: 250px; margin: 0; padding: 0!important; overflow: hidden; overflow-y: scroll; background: #fff; border: 1px solid #d3d3d3; }
	.tab li { font-weight: normal; padding: 10px!important; margin: 0!important; border-bottom: 1px dotted #d3d3d3; cursor: pointer; color: #663366; background-image: none!important; }
		.tab li:hover { background: #e0d3e3; }
	.tab li.selected { background: #956a99; color: #fff; }
		.tab li.selected:hover { background: #b592b8; color: #fff; }
</pre>
<h2>The Javascript</h2>
<p>bind events to the lists</p>
<p><strong>Dual Lists Mode:</strong></p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
        if ( $('#selected-categories').length &gt; 0 ) {
                ls.init({
                        variable      : '#selected-categories',  // the list that is updated to reflect user's selections
                        clickable     : 'li',                             // the element on which to bind the click event
                        update_list  : true,
                        constant     : '#all-categories'          // the list the user makes selections from
                });
        }
</pre>
<p><strong>Single List Mode:</strong></p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
        if ( $('#selected-categories').length &gt; 0 ) {
                ls.init({
                        variable      : '#selected-categories',  // the list that is updated to reflect user's selections
                        clickable     : 'li',                             // the element on which to bind the click event
                        update_list  : false
                });
        }
</pre>
<p>the code that makes it work</p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
ls = {

	/* *************************************************************************
	*
	* start the initial binding of the list columns
	*
	************************************************************************* */
	init : function( params ) {

		var p = params;

		$(p._variable + &quot; &quot; + p._clickable).unbind('click');
		$(p._variable + &quot; &quot; + p._clickable).bind('click', function() {
			ls.move_left( p, $(this) );
		});

		if ( p._update_list ) {
			$(p._constant + &quot; &quot; + p._clickable).unbind('click');
			$(p._constant + &quot; &quot; + p._clickable).bind('click', function() {
				ls.move_right( p, $(this) );
			});
		}

		// update the list array field
		ls.track_selected_elements( p );

	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* Moves selected element from the variable list to the constant list
	*
	************************************************************************* */
	move_left : function( p, obj ) {

		var p = p;

		if ( p._update_list ) {

			obj_id = $( obj ).attr('id');

			// this object exists in the other list
			// just remove it from existing list
			if ( $( p._constant ).find( '#' + obj_id ).length &gt; 0 ) {
				obj.remove();
				$( p._constant ).find( '#' + obj_id ).removeClass('selected');

			} else {
				$(p._constant).append( obj );
				obj.removeClass( 'selected' );

				ls.sort_list( p, p._constant );
				obj.unbind('click');
				obj.bind('click', function() {
					ls.move_right( p, $(this) );
				});
			}

		} else {
			if ( obj.hasClass('selected') ) {
				obj.removeClass( 'selected' );
			} else {
				obj.addClass( 'selected' );
			}
		}

		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* Moves selected element from the contstant list to the variable list
	*
	************************************************************************* */
	move_right : function( p, obj ) {

		var p = p;

		obj_id = $( obj ).attr('id');

		// this object exists in the other list
		// just remove it from existing list
		if ( $( p._variable ).find( '#' + obj_id ).length &gt; 0 ) {
			obj.remove();

		} else {
			$(p._variable).append( obj );
			obj.addClass( 'selected' );

			ls.sort_list( p, p._variable );
			obj.unbind('click');
			obj.bind('click', function() {
				ls.move_left( p, $(this) );
			});
		}

		// update the list array field
		ls.track_selected_elements( p );
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* When append to the list(s), the ordering is off. This alphabetically
	* sort the list items
	*
	************************************************************************* */
	sort_list : function ( p, obj ) {

		var parent = obj;

		var items = $(obj + ' ' + p._clickable).get();
		items.sort(function(a,b){
			var keyA = $(a).text();
			var keyB = $(b).text();

			if (keyA &lt; keyB) return -1;
			if (keyA &gt; keyB) return 1;
			return 0;
		});
			var ul = $(parent);
			$.each(items, function(i, li){
				ul.append(li);
			});
	},
	/* *************************************************************************
	* END :::
	************************************************************************* */

	/* *************************************************************************
	*
	* appends the list of selected LI elements in a hidden input box. will
	* allow you to get the values on form post without any jquery or javascript
	*
	************************************************************************* */
	track_selected_elements : function( p ) {
			var p = p;
			var ls_list_array = [];

			_class = ( p._update_list ) ? '' : '.selected';

			/* *******************************************
			* remove the old list to null it out        */
				$('#ls_update_list_array').remove();

			/* ******************************************
			* get the complete list of selected li's   */
				$(p._variable + ' li' + _class).each(function() { ls_list_array.push($(this).attr('id')) });

			/* *******************************************
			* append the array list as an hidden input  */
				var ls_input = '&lt;input type=&quot;hidden&quot;'
							+ 'id=&quot;ls_update_list_array&quot; '
							+ 'name=&quot;ls_update_list_array&quot; '
							+ 'value=&quot;' + ls_list_array + '&quot; /&gt;'

				$(p._variable).append(ls_input)
	}
}
</pre>
<h2>Dual List Example</h2>
<div id="tabs"><strong class="active"><a href="#selected-categories">Currently Selected Categories</a></strong><strong class="inactive"><a href="#all-categories">All Available Categories</a></strong></div>
<ul id="selected-categories" class="tab">
<li id="item1" class="li-item selected">Item 1 text</li>
<li id="item3" class="li-item selected">Item 3 text</li>
<li id="item7" class="li-item selected">Item 7 text</li>
<li id="item8" class="li-item selected">Item 8 text</li>
</ul>
<ul id="all-categories" class="tab">
<li id="item2" class="li-item">Item 2 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item">Item 5 text</li>
<li id="item6" class="li-item">Item 6 text</li>
</ul>
<h2>Single List Eample</h2>
<div id="sel-cat-tab"><strong class="active"><a href="#">Currently Selected Categories</a></strong></div>
<ul id="selected-categories-single">
<li id="item1" class="li-item">Item 1 text</li>
<li id="item2" class="li-item">Item 2 text</li>
<li id="item3" class="li-item selected">Item 3 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item selected">Item 5 text</li>
<li id="item6" class="li-item selected">Item 6 text</li>
<li id="item7" class="li-item">Item 7 text</li>
<li id="item8" class="li-item">Item 8 text</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Tabs With Ease</title>
		<link>http://jjis.me/a/280</link>
		<comments>http://jjis.me/a/280#comments</comments>
		<pubDate>Sat, 03 Jul 2010 01:50:19 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=280</guid>
		<description><![CDATA[As usual, I always need something special in jQuery. I&#8217;m always able to find plugins out there, but they never everything I want, the way I want it done. Each always falls short somewhere. It either limits my design flexibility, is buggy or is just flat-out bloated with way more code than is necessary. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>As usual, I always need something special in jQuery. I&#8217;m always able to find plugins out there, but they never everything I want, the way I want it done. Each always falls short somewhere. It either limits my design flexibility, is buggy or is just flat-out bloated with way more code than is necessary.</p>
<p>I&#8217;ve written a tabs script for jQuery that is short and to the point while still allowing for design flexibility and ease. There&#8217;s nothing to it. Simply establish the tabs settings with your appropriate IDs and classes and you&#8217;re good to go. I&#8217;ve used on a few occasions and it has yet to fail me.</p>
<p>As usual, however, let me know if you have problems. I&#8217;ve supplied complete code for HTML, CSS and, of course, the jQuery/JavaScript.</p>
<p><span id="more-280"></span></p>
<h2></h2>
<h2>Let&#8217;s Start With The HTML</h2>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">
&lt;div id=&quot;tabs&quot;&gt;
	&lt;b class=&quot;active&quot;&gt;&lt;a href=&quot;#selected-categories&quot;&gt;Currently Selected Categories&lt;/a&gt;&lt;/b&gt;
	&lt;b class=&quot;inactive&quot;&gt;&lt;a href=&quot;#all-categories&quot;&gt;All Available Categories&lt;/a&gt;&lt;/b&gt;
&lt;/div&gt;

&lt;ul id=&quot;selected-categories&quot; class=&quot;tab&quot;&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
&lt;ul id=&quot;all-categories&quot; class=&quot;tab&quot;&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 1 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 2 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 3 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 4 text&lt;/li&gt;
        &lt;li id=&quot;item1&quot; class=&quot;li-item&quot;&gt;Item 5 text&lt;/li&gt;
        &lt;li id=&quot;item2&quot; class=&quot;li-item&quot;&gt;Item 6 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 7 text&lt;/li&gt;
        &lt;li id=&quot;item3&quot; class=&quot;li-item&quot;&gt;Item 8 text&lt;/li&gt;
&lt;/ul&gt;
</pre>
<h2>The CSS</h2>
<pre class="brush: css; title: ; wrap-lines: false; notranslate">
/* *****
* tab header properties
***** */
#tabs { margin: 0 0 -2px 0; height: 45px; }
	#tabs b { display: block; float: left; margin: 0px; background: #fff; font-weight: normal; }
	#tabs b.active { background: #e0d3e3; }
		#tabs b a { display: block; color: #a989b0; padding: 10px; border: 1px solid #d3d3d3; text-decoration: none; }
		#tabs b a:hover { background: #f5edf6; }

		#tabs b.active a { color: #663366; }
		#tabs b.inactive a:hover { background: #f5edf6; }

/* *****
* tab content
***** */
.tab { clear: both; width: 100%; height: 250px; margin: 0; padding: 0; overflow: hidden; overflow-y: scroll; background: #fff; border: 1px solid #d3d3d3; }
	.tab li { font-weight: normal; padding: 10px; border-bottom: 1px dotted #d3d3d3; cursor: pointer; color: #663366; }
	.tab li:hover { background: #e0d3e3; }
</pre>
<h2></h2>
<h2>The jQuery Code</h2>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">

/* *************************************************
*
* configuration: settings for class &amp; ids of tab
* elements
************************************************* */
var tabs = {
	default_tab    : 0,                    // the # of the tab that should be shown on page load
	// the tab itself
	tab : {
		wrapper   : '#tabs',          // parent that wraps around each tab header
		container : 'b',                // the container that wraps around the clickable tab text
		clickable : 'a',                 // the clickable tab text
		_class     : {
			active   : 'active',   // class for the active tab
			inactive : 'inactive' // class for all inactive tabs
		}
	},
	// the content for each tab
	content : {
		_class  : '.tab'                 // class of the content for the tabs
	},

	/* *************************************************
	*
	* bind tabbing events
	*
	************************************************* */
	init : function() {
		$( tabs.tab.wrapper + ' ' + tabs.tab.clickable ).click(function() {
			var id 	= $(this).attr('href');
			var par 	= $(this).parent();

			// hide all tab content
			$.each( $( tabs.content._class ), function(i) {
				$( this ).css( 'display','none' );
			});

			// display the tab content chosen
			$( id ).css('display','block');

			// show the tab as clicked
			$.each( $( tabs.tab.wrapper + ' ' + tabs.tab.container ), function() {
				$( this ).removeClass( tabs.tab._class.active );
				$( this ).addClass( tabs.tab._class.inactive );
			});

			par.removeClass( tabs.tab._class.inactive );
			par.addClass( tabs.tab._class.active );

			return false;
		});

		// hide all tab content except the first tab
		$.each( $( tabs.content._class ), function(i) {
			if (i &gt; tabs.default_tab) {
				$( this ).css('display','none');
			}
		});
	}

};
</pre>
<h2></h2>
<h2>Now Initiate the Code</h2>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
$(document).ready(function() {
        /* ************************************
        * only initiate the tab function if tabs are preset */
	        if ( $('#tabs').length &gt; 0 ) {
		        tabs.init();
	        }
});
</pre>
<p>There you go. That&#8217;s all there is to it. The code is definitely portable and you could make it a plugin yourself if you wanted. I will get it setup to allow multiple sets of tabs per page and update when it&#8217;s completed.</p>
<h2>Example</h2>
<div id="tabs"><b class="active"><a href="#tab-a">Tab A</a></b><b class="inactive"><a href="#tab-b">Tab B</a></b></div>
<ul id="tab-a" class="tab">
<li id="item1" class="li-item">Item 1 text</li>
<li id="item3" class="li-item">Item 3 text</li>
<li id="item7" class="li-item">Item 7 text</li>
<li id="item8" class="li-item">Item 8 text</li>
</ul>
<ul id="tab-b" class="tab">
<li id="item2" class="li-item">Item 2 text</li>
<li id="item4" class="li-item">Item 4 text</li>
<li id="item5" class="li-item">Item 5 text</li>
<li id="item6" class="li-item">Item 6 text</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/280/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Accordian without plug-ins &amp; with a bit of design freedom</title>
		<link>http://jjis.me/a/209</link>
		<comments>http://jjis.me/a/209#comments</comments>
		<pubDate>Sun, 13 Jun 2010 14:47:40 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=209</guid>
		<description><![CDATA[So you have a design and you have decided you want to use a jQuery accordion. You start to layout your design and implement the accordion only to find out that your design is going to cause problems with the standard accordion plug-ins. The problem with the standard accordion is that they require the child [...]]]></description>
			<content:encoded><![CDATA[<p>So you have a design and you have decided you want to use a jQuery accordion. You start to layout your design and implement the accordion only to find out that your design is going to cause problems with the standard accordion plug-ins.</p>
<p>The problem with the standard accordion is that they require the child and header elements to be nested within a parent.</p>
<p><span id="more-209"></span></p>
<h2>Example:</h2>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">
&lt;div id=&quot;accordion-wrapper&quot;&gt;
     &lt;h1&gt;Clickable Header 1&lt;/h1&gt;
          &lt;p&gt;Collapsible child 1&lt;/p&gt;
     &lt;h1&gt;Clickable Header 2&lt;/h1&gt;
          &lt;p&gt;Collapsible child 2&lt;/p&gt;
     &lt;h1&gt;Clickable Header 3&lt;/h1&gt;
          &lt;p&gt;Collapsible child 3&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>Where this limits us in our design is when we want to add some extra style to the accordion list. I tend to use lists when building a list. So, if we take the code above and wrap each header and collapsible child with an &lt;li&gt;, we would completely break the accordion.</p>
<h2>Let&#8217;s break it down</h2>
<p>The standard jQuery accordion would prohibit this because the layout would throw off the jQuery plugin. The plugins look at the wrapping element (in this case &#8220;accordion-wrapper&#8221;). It then finds all header (&lt;h1&gt;) elements and binds the click event. This click event finds the first occurrence of the collapsible element (&lt;p&gt;) and will either expand or collapse it depending on it&#8217;s current state.</p>
<h2>Let&#8217;s fix this</h2>
<p>With the following script, you simply specify what the header class is going to be and what the collapsible class is going to be. What this allows us to do is place our accordion headers and collapsible elements within structured list, thus allowing more design/layout freedom.</p>
<h2>Example:</h2>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">
&lt;ul id=&quot;accordion-list&quot;&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 1&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 2&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li class=&quot;accordion-item&quot;&gt;
		&lt;h1 class=&quot;accordion-header&quot;&gt;Clickable Header 3&lt;/h1&gt;
		&lt;p&gt;Just placed here for an example of how we don't have our header and collapsible elements stacked&lt;/p&gt;
			&lt;ul class=&quot;accordion-collapsible&quot;&gt;
				&lt;li&gt;Collapsible child 1&lt;/li&gt;
				&lt;li&gt;Collapsible child 2&lt;/li&gt;
				&lt;li&gt;Collapsible child 3&lt;/li&gt;
				&lt;li&gt;Collapsible child 4&lt;/li&gt;
			&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>&nbsp;</p>
<h2>The jQuery Code:</h2>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
$(document).ready(function() {
	/* ***
	* REQUIRED
	* set you classes accordingly below. */
	var accordion = {
		parent      : '.accordion-item',        // parent element containing the clickable header and collapsible
		header      : '.accordion-header',      // clickable header
		collapsible : '.accordion-collapsible'  // collapsible element
	};

	/* ***
	* hide all collapsible items */
	$(accordion.collapsible).css('display','none');

	/* ****
	* bind the accordion header click event */
	$(accordion.header).unbind('click');
	$(accordion.header).bind('click', function() {
		var header_obj      = $(this);          // The current header
		var next_parent_obj = $(this).parent(); // The parent of the header

		var content_obj = $(this).siblings(accordion.collapsible); // find the collapsible element

		if(content_obj.is(&quot;:hidden&quot;)) {
			// collapse all collapsible elements
			next_parent_obj.siblings(accordion.parent).each(function() {
				$(this).children(accordion.collapsible).slideUp('fast');
			});
			// show the content of the clicked header
			content_obj.slideDown('fast');
		} else {
			content_obj.slideUp('fast');
		}
	});
});
</pre>
<p>&nbsp;</p>
<h2>Seeing it in action</h2>
<p><span><br /></span></p>
<ul id="accordion-list">
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 1</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 2</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
<li class="accordion-item">
<h1 class="accordion-header">Clickable Header 3</h1>
<p>Just placed here for an example of how we don&#8217;t have our header and collapsible elements stacked</p>
<ul class="accordion-collapsible">
<li>Collapsible child 1</li>
<li>Collapsible child 2</li>
<li>Collapsible child 3</li>
<li>Collapsible child 4</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/209/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Load multiple JS files in one call</title>
		<link>http://jjis.me/a/94</link>
		<comments>http://jjis.me/a/94#comments</comments>
		<pubDate>Tue, 30 Mar 2010 21:44:34 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=94</guid>
		<description><![CDATA[With this script, you can easily load multiple JavaScript files in one call. The main purpose behind this is to simply cut down on the clutter in your source code. The function can be called from anywhere and the files are specified in an array]]></description>
			<content:encoded><![CDATA[<p>With this script, you can easily load multiple JavaScript files in one call. The main purpose behind this is to simply cut down on the clutter in your source code. </p>
<p>The function can be called from anywhere and the files are specified in an array</p>
<p><span id="more-94"></span></p>
<pre class="brush: jscript; title: ; wrap-lines: false; notranslate">
/* *********************************************************
*
* 	Setup a global config variable that
* 	stores all sitewide values such root
* 	url, absolute paths, Javascript library paths, etc.
*
********************************************************* */
	var config;
	config = {
		   URL : 'http://domain.com',
		   jsURL: &quot;http://domain.com/js&quot;
	};

/* **********************************************************************************************************
*
*	Function for looping through long lists of JS includes this function, when fed an array will
*	write the script tag to include the specified files as JS include files.
*
*	NOTE: This written to look in the 'js' folder under the site's root folder (http://domain.com/js/)
*
*	Directions:
*	config.loadComponents( { foldername:['filename.js'] } );
*
*	Example:
*	config.loadComponents( { jquery:['jquery-ui'] } );
*	OUTPUT: &lt;script src='http://domain.com/js/jquery/jquery-ui.js' type='text/javascript'&gt;&lt;/script&gt;
*
********************************************************************************************************** */
config.loadComponents = function (components) {
	for ( var key in components ) {
		var obj = components[key];
		for (var prop in obj) {
			var file = obj[prop];
			file = config.jsURL + '/' + key + &quot;/&quot; + file;
			document.write(unescape(&quot;%3Cscript src='&quot; + file + &quot;' type='text/javascript'%3E%3C/script%3E&quot;));
		}
	}
}

/* *********************************************************
*
*	Call the loadComponents() function
*	pay attention to how folder and file are called
*		folder: ['filename1.js', 'filename2.js']
*
********************************************************* */
config.loadComponents( {
	jquery:[
		'jquery-1.3.2.min.js',
		'jquery.easing.1.3.js',
	],
	app:[
		'app.js',
	],
	scripts:[
		'facbox.js'
	]
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/94/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery “characters remaining” script</title>
		<link>http://jjis.me/a/89</link>
		<comments>http://jjis.me/a/89#comments</comments>
		<pubDate>Tue, 30 Mar 2010 18:44:42 +0000</pubDate>
		<dc:creator>jj_jiles</dc:creator>
				<category><![CDATA[jQuery & Javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jjis.me/?p=89</guid>
		<description><![CDATA[This is a jQuery script for displaying &#8220;characters remaining&#8221; for input fields. It will look for any input element with the class &#8220;input&#8221; (or whatever you specify) and use the element&#8217;s maxlength attribute as the value to count against and update the &#8220;fieldName-counter&#8221; element. This is a very useful script for those occasions when you [...]]]></description>
			<content:encoded><![CDATA[<p>This is a jQuery script for displaying &#8220;characters remaining&#8221; for input fields.</p>
<p>It will look for any input element with the class &#8220;input&#8221; (or whatever you specify) and use the element&#8217;s maxlength attribute as the value to count against and update the &#8220;fieldName-counter&#8221; element.</p>
<p>This is a very useful script for those occasions when you want to limit the character entry for an input field.</p>
<p><span id="more-89"></span></p>
<pre class="brush: jscript; html-script: true; title: ; wrap-lines: false; notranslate">
&lt;!-- input and character count element --&gt;
    &lt;span id=&quot;fieldName-counter&quot;&gt;100&lt;/span&gt; characters remaining&lt;br /&gt;
    &lt;input type=&quot;text&quot; name=&quot;fieldName&quot; id=&quot;fieldName&quot; maxlength=&quot;100&quot; class=&quot;input&quot; /&gt;
&lt;!--/elements--&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
    // change .input to desired class
    $('.input').each(function() {
        var inp = $(this);
        var maxlen =inp.attr('maxlength');
        if (maxlen &amp;gt; 0) {
            inp.bind('keyup', function(e) {
                len = new Number(inp.val().length);
                counter = maxlen-len;
                counterObj = '#' + inp.attr('id') + '-counter';
                $(counterObj).text(counter);
            });
        }
    });
});
&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jjis.me/a/89/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 3/32 queries in 0.261 seconds using disk: basic
Object Caching 491/551 objects using disk: basic

Served from: jjis.me @ 2012-02-06 11:31:02 -->
