<?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>Superdit.com &#187; snippet</title>
	<atom:link href="http://superdit.com/tag/snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://superdit.com</link>
	<description>blogging, design, tech, and web</description>
	<lastBuildDate>Thu, 19 Jan 2012 07:50:35 +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>Simple Ajax Pagination With JQuery and Codeigniter</title>
		<link>http://superdit.com/2011/11/22/simple-ajax-pagination-with-jquery-and-codeigniter/</link>
		<comments>http://superdit.com/2011/11/22/simple-ajax-pagination-with-jquery-and-codeigniter/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 01:41:31 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=9336</guid>
		<description><![CDATA[Codeigniter pagination class is really useful for me, it help to cut the repetitive task when we are creating pagination with large data, today I want to share a little of my thought, using codeigniter pagination class with ajax jquery. Here I show with a simple codeigniter code.  This post only show the code example,<a href="http://superdit.com/2011/11/22/simple-ajax-pagination-with-jquery-and-codeigniter/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Codeigniter pagination class is really useful for me, it help to cut the repetitive task when we are creating pagination with large data, today I want to share a little of my thought, using codeigniter pagination class with ajax jquery. Here I show with a simple codeigniter code.  This post only show the code example, cause i don&#8217;t think it necessary to provide a downloadable code.</p>
<p style="text-align: center;"><a title="Simple Ajax Pagination With JQuery and Codeigniter" href="http://superdit.com/2011/11/22/simple-ajax-pagination-with-jquery-and-codeigniter/"><img class="size-full wp-image-9343" title="codeigniter ajax pagination jquery" src="http://superdit.com/wp-content/uploads/2011/11/ci_ajax_pagination_jquery.jpg" alt="codeigniter ajax pagination jquery" width="500" height="56" /></a></p>
<h6>Controller</h6>
<p>Here are the controller, to make it easier the data in this example using a static array variable, so it very easy for us to get the data by the array index, and we need to load the url helper and of course the pagination library.<span id="more-9336"></span></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller {

  public function index($start = 0) {
    $data_paging = array('John 1', 'John 2', 'John 3', 'John 4',
      'John 5', 'John 6', 'John 7', 'John 8', 'John 9', 'John 10',
      'John 11', 'John 12', 'John 13', 'John 14', 'John 15', 'John 16',
      'John 17', 'John 18', 'John 19', 'John 20', 'John 21', 'John 22',
      'John 23', 'John 24', 'John 25', 'John 26', 'John 27', 'John 28',
      'John 29', 'John 30', 'John 31', 'John 32', 'John 33', 'John 34',
      'John 35', 'John 36', 'John 37', 'John 38', 'John 39', 'John 40',
      'John 41', 'John 42', 'John 43', 'John 44', 'John 45', 'John 46',
      'John 47', 'John 48', 'John 49', 'John 50', 'John 51', 'John 52',
      'John 53', 'John 54');

    $this-&gt;load-&gt;helper('url');
    $this-&gt;load-&gt;library('pagination');

    $config['base_url']   = site_url('user/index');
    $config['total_rows'] = count($data_paging);
    $config['per_page']   = 5;

    $data['user'] = array();

    for ($i=$start; $i&lt;$start+$config['per_page']; $i++) {
      if (isset($data_paging[$i])) {
        $data['user']['name'][] = $data_paging[$i];
      }
    }

    $this-&gt;pagination-&gt;initialize($config);
    $data['pagination'] = $this-&gt;pagination-&gt;create_links();

    if ($this-&gt;input-&gt;post('ajax')) {
      $this-&gt;load-&gt;view('user/ajax_index', $data);
    } else {
      $this-&gt;load-&gt;view('user/index', $data);
    }
  }
}

?&gt;
</pre>
<h6>View</h6>
<p>The jquery code I added on the top of the page, and these are where the idea lies, put the pagination content on some div element with unique id, and with jquery you can applied the click function on each pagination link. The content that will be updated is div#content you can add a loading message by your self, the ajax content will update not only the data but the pagination too.</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;header&gt;
  &lt;title&gt;CodeIgniter Ajax Jquery Pagination&lt;/title&gt;
  &lt;script src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/jquery-1.6.4.min.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
  $(function() {
    applyPagination();

    function applyPagination() {
      $(&quot;#ajax_paging a&quot;).click(function() {
        var url = $(this).attr(&quot;href&quot;);
        $.ajax({
          type: &quot;POST&quot;,
          data: &quot;ajax=1&quot;,
          url: url,
          beforeSend: function() {
            $(&quot;#content&quot;).html(&quot;&quot;);
          },
          success: function(msg) {
            $(&quot;#content&quot;).html(msg);
            applyPagination();
          }
        });
        return false;
      });
    }
  });
  &lt;/script&gt;
&lt;/header&gt;
&lt;body&gt;
&lt;div id=&quot;content&quot;&gt;
  &lt;div id=&quot;data&quot;&gt;
    &lt;?php foreach($user['name'] as $u): ?&gt;
        &lt;div&gt;&lt;?php echo $u; ?&gt;&lt;/div&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/data&gt;

  &lt;div id=&quot;ajax_paging&quot;&gt;
    &lt;?php echo $pagination; ?&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h6>Ajax View</h6>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;data&quot;&gt;
  &lt;?php foreach($user['name'] as $u): ?&gt;
      &lt;div&gt;&lt;?php echo $u; ?&gt;&lt;/div&gt;
  &lt;?php endforeach; ?&gt;
&lt;/data&gt;

&lt;div id=&quot;ajax_paging&quot;&gt;
  &lt;?php echo $pagination; ?&gt;
&lt;/div&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/11/22/simple-ajax-pagination-with-jquery-and-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sumon Math Game With JQuery</title>
		<link>http://superdit.com/2011/10/09/sumon-math-game-with-jquery/</link>
		<comments>http://superdit.com/2011/10/09/sumon-math-game-with-jquery/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 13:24:55 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=8736</guid>
		<description><![CDATA[In today post I want to share how I make a simple sumon math game based on JQuery, this game inspired by hyperandroid, this game it quite nice to practice your self concentration about math addition.   This post will create that simple nice game, just to show that you can make it with simple<a href="http://superdit.com/2011/10/09/sumon-math-game-with-jquery/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>In today post I want to share how I make a simple sumon math game based on JQuery, this game inspired by <a title="MathMayhem" href="http://labs.hyperandroid.com/mathmayhem" target="_blank">hyperandroid</a>, this game it quite nice to practice your self concentration about math addition.</p>
<p><a title="Sumon Math Game With JQuery" href="http://superdit.com/2011/10/09/sumon-math-game-with-jquery/"><img class="aligncenter size-full wp-image-9146" title="JQuery Sumon Game" src="http://superdit.com/wp-content/uploads/2011/10/JQuerySumGame-thumb.jpg" alt="JQuery Sumon Game" width="550" height="200" /> </a></p>
<p>This post will create that simple nice game, just to show that you can make it with simple jquery, please note that I only add the basic rule of the game, which are, we have to pick the total number that matched the appear random number thats all.<span id="more-8736"></span></p>
<p style="text-align: center;"><strong><a href="http://demo.superdit.com/jquery/sumon_game/" target="_blank">Demo</a> | <a href="http://www.box.net/shared/92ery0npfdqz2fch4pjv" target="_blank">Download</a></strong></p>
<h5>JQuery</h5>
<p>In this example i&#8217;m using a little JQuery UI effect, so not to forget to include it on your script.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
function randomFromTo(from, to){
    return Math.floor(Math.random() * (to - from + 1) + from);
}

Array.prototype.clean = function(deleteValue) {
    for (var i = 0; i &lt; this.length; i++) {
        if (this[i] == deleteValue) {
            this.splice(i, 1);
            i--;
        }
    }
    return this;
};

var sum = 0;
var tempindex = 0;
var numbers = new Array();

function generateRandomSum() {
    var looprand    = randomFromTo(1, 3);
    var total       = 0;
    var arrayIndex  = new Array();

    if (looprand &gt; numbers.length) {
        looprand = numbers.length;
    }

    for (j=0; j&lt;looprand; j++) {
        var randindex = randomFromTo(0, numbers.length - 1);
        randindex = getUnique(randindex, arrayIndex);

        total = total + numbers[randindex];
        arrayIndex[j] = randindex;
    }
    sum = total;
    $(&quot;#nextsum&quot;).html(total);
}

function getUnique(index, arrayIn) {
    if ((jQuery.inArray(index, arrayIn) == -1)) {
        return index;
    } else {
        rindex = randomFromTo(0, numbers.length - 1);
        return getUnique(rindex, arrayIn);
    }
}

var sumtemp = 0;
var numtemp = new Array();

// store temporary index in array
var arrIndex = new Array();
function boxClick(obj) {
    if (!$(obj).hasClass(&quot;disable&quot;)) {
        var clickedindex = parseInt($(obj).attr(&quot;id&quot;).replace(&quot;num&quot;, &quot;&quot;));
        var temp = parseInt($(obj).find(&quot;p&quot;).html());

        if (!$(obj).hasClass(&quot;red&quot;)) {
            $(obj).addClass(&quot;red clicked&quot;);
            // store clicked index in array
            arrIndex[tempindex] = clickedindex;
            sumtemp = sumtemp + temp;
            tempindex++;

            // temporary sum is match
            if (sumtemp == sum) {
                $(&quot;.clicked&quot;).unbind(&quot;click&quot;);
                $(&quot;.clicked&quot;).removeAttr(&quot;id&quot;);
                $(&quot;.clicked&quot;).addClass(&quot;disable&quot;);
                $(&quot;.clicked&quot;).animate({
                   backgroundColor: &quot;#e3e3e3&quot;,
                   color: &quot;#e3e3e3&quot;,
                   borderColor: &quot;#e3e3e3&quot;
                }, 500, function() {
                    $(&quot;.disable&quot;).removeClass(&quot;clicked&quot;);
                });

                // change each box id
                var y = 0;
                $(&quot;#dimcontainer div.boxnum&quot;).each(function(index) {
                    if (!$(this).hasClass(&quot;disable&quot;)) {
                        $(this).attr(&quot;id&quot;, &quot;num&quot;+y);
                        y++;
                    }
                });

                // delete matched number
                for ( z = 0; z &lt; arrIndex.length; z++) {
                    delete numbers[arrIndex[z]];
                }

                // delete temporay index
                for ( e = 0; e &lt;= arrIndex.length; e++) {
                    delete arrIndex[e];
                }
                arrIndex.clean(undefined);
                numbers.clean(undefined);

                sum = 0;
                sumtemp = 0;
                // reset index
                tempindex = 0;

                generateRandomSum();

                // Game Finished
                if (numbers.length == 0) {
                    $(&quot;#nextsum&quot;).html(&quot;Thanks For Playing!&quot;);
                }
            }

            // temporary sum not match
            if (sumtemp &gt; sum) {
                $(&quot;#dimcontainer&quot;).effect(&quot;shake&quot;, { times: 1 }, &quot;fast&quot;, function() {
                    sumtemp = 0;
                    $(&quot;.boxnum&quot;).removeClass(&quot;red&quot;);
                    $(&quot;.clicked&quot;).removeClass(&quot;clicked&quot;);
                    $(&quot;#sum&quot;).html(sumtemp);

                    // delete the temporary array &amp; reset index
                    numtemp = new Array();
                    tempindex = 0;
                });
            }
        } else {
            $(obj).removeClass(&quot;red&quot;);
            $(obj).removeClass(&quot;clicked&quot;);

            // remove clicked index
            for (x = 0; x &lt; arrIndex.length; x++) {
                if (arrIndex[x] == clickedindex) {
                    arrIndex.splice(x, 1);
                }
            }
            tempindex--;

            sumtemp = sumtemp - temp;
        }
    }
}

function start() {
    // create a number of box and generate random number in array
    sum          = 0;
    sumtemp      = 0;
    tempindex    = 0;
    var val          = parseInt($(&quot;#cbdim&quot;).val());
    var boxloop      = val * val;
    var boxleft      = ($(window).width() - (val * 78)) / 2;
    $(&quot;#dimcontainer&quot;).html('&lt;div id=&quot;boxclear&quot;&gt;&lt;/div&gt;');
    $(&quot;#dimcontainer&quot;).css({
        width: (val * 78) + &quot;px&quot;,
        left: boxleft + &quot;px&quot;
    });

    for ( i = 0; i &lt; boxloop; i++) {
        numbers[i] = randomFromTo(1, 15);
        $('#boxclear').before('&lt;div class=&quot;boxnum&quot; id=&quot;num'+i+'&quot; '+
            ' onclick=&quot;boxClick(this);&quot;&gt;&lt;p&gt;'+numbers[i]+'&lt;/p&gt;&lt;/div&gt;');
    }
    generateRandomSum();
}
&lt;/script&gt;
</pre>
<p>1. function<em> randomFromTo</em>, from <a title="JavaScript Tip: get a Random Number between two Integers" href="http://www.admixweb.com/2010/08/24/javascript-tip-get-a-random-number-between-two-integers/" target="_blank">admixweb</a>, this function will get random number between the two input parameter.</p>
<p>2. function  <em>Array.prototype.clean</em> , from <a href="http://stackoverflow.com/questions/281264/remove-empty-elements-from-an-array-in-javascript" target="_blank">stackoverflow</a>, this function will clean the array, I use this with javascript <em>delete</em> function to cleaning the array, since I haven&#8217;t found how to destroying an array in javascript.</p>
<p>3. function <em>generateRandomSum</em>, this function will pick the total random in array, the total picked number is random from one to three, and each index of the array must be unique.</p>
<p>4. function <em>getUnique</em>, this function will get unique index of array that stored in array, this are recursive function, it will continue run until find the unique array index.</p>
<p>5. function <em>boxClick, </em>this is the main event function of this example, many array variable used in this function, I admit I fell a little bit confuse when debugging this, that I have to delete array, change array, clean. etc.</p>
<p>6. function <em>start, </em>this is the initialization when displaying the box, it creating each box by looping on the fly, based on the dimensions size that picked.</p>
<h5>HTML</h5>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;container&quot;&gt;
    &lt;div id=&quot;pick&quot;&gt;
        Pick Dimension: &amp;nbsp;
        &lt;select id=&quot;cbdim&quot; style=&quot;font-size:18px;&quot;&gt;
            &lt;option value=&quot;3&quot;&gt;3 x 3&lt;/option&gt;
            &lt;option value=&quot;4&quot;&gt;4 x 4&lt;/option&gt;
            &lt;option value=&quot;5&quot;&gt;5 x 5&lt;/option&gt;
            &lt;option value=&quot;6&quot;&gt;6 x 6&lt;/option&gt;
            &lt;option value=&quot;7&quot;&gt;7 x 7&lt;/option&gt;
        &lt;/select&gt;
        &lt;button id=&quot;btnstart&quot; onclick=&quot;start();&quot;&gt;Start Game !&lt;/button&gt;
    &lt;/div&gt;
    &lt;p id=&quot;pnext&quot;&gt;Next Total: &amp;nbsp;&lt;span id=&quot;nextsum&quot;&gt;0&lt;/span&gt;&lt;/p&gt;

    &lt;div id=&quot;dimcontainer&quot;&gt;
        &lt;div id=&quot;boxclear&quot; style=&quot;clear:both&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<h5>CSS</h5>
<pre class="brush: css; title: ; notranslate">
* {
    font-family: Arial, &quot;Free Sans&quot;;
}
body {
    background: #fff url(&quot;circles.png&quot;) repeat right top;
}
#container {
    margin: 0 auto;
    text-align: center;
}
#dimcontainer {
    padding: 2px;
    margin: 0 auto;
    left: 500px;
}
.boxnum {
    text-align: center;
    cursor: pointer;
    border: 2px solid #e3e3e3;
    background: #fff;
    width: 70px;
    height: 70px;
    margin: 2px;
    float: left;
    color: #D80000;
    -webkit-border-radius: .3em;
    -moz-border-radius: .3em;
    border-radius: .3em;
}
.boxnum:hover {
    background: #e3e3e3;
}
.boxnum p {
    margin-top: 20px;
    font-size: 28px;
    font-weight: bold;
    text-shadow: -1px 1px 1px #fff;
}
.red {
    background: #ff0000;
    border-color: #ff0000;
}
.red:hover {
    background: #ff0000 !important;
}
#boxclear {
    clear: both;
}
#pnext {
    font-size: 18px;
}
#nextsum {
    font-weight: bold;
    font-size: 30px;
    position: relative;
    top: 3px;
}
#pick {
    font-size: 18px;
}
</pre>
<p>That&#8217;s all, I know this example is not perfect but at least this is one of the way how you make it, you can improve it by adding some several features like, game scoring, help instruction, difficulty (by adding range in the random number), some bug fixing for preventing rapid click, etc.</p>
<p style="text-align: center;"><strong><a href="http://demo.superdit.com/jquery/sumon_game/" target="_blank">Demo</a> | <a href="http://www.box.net/shared/92ery0npfdqz2fch4pjv" target="_blank">Download</a></strong></p>
<p style="text-align: center;"><a href="http://demo.superdit.com/jquery/sumon_game/" target="_blank"><img class="aligncenter size-full wp-image-9131" title="JQuery Sumon Game" src="http://superdit.com/wp-content/uploads/2011/10/JQuerySumGame.jpg" alt="JQuery Sumon Game" width="424" height="519" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/10/09/sumon-math-game-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swipe Like Effect Based On JQuery UI Draggable</title>
		<link>http://superdit.com/2011/08/28/swipe-like-effect-based-on-jquery-ui-draggable/</link>
		<comments>http://superdit.com/2011/08/28/swipe-like-effect-based-on-jquery-ui-draggable/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 12:34:34 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[swipe]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=8401</guid>
		<description><![CDATA[Swipe effect has becoming popular when mobile application usage increase, it a nice touch effect to slide between layout, and some of mobile web application framework has already have this feature for example you can see sencha touch carousel component, but I think the swipe effect can be good enough too, not only for mobile<a href="http://superdit.com/2011/08/28/swipe-like-effect-based-on-jquery-ui-draggable/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Swipe effect has becoming popular when mobile application usage increase, it a nice touch effect to slide between layout, and some of mobile web application framework has already have this feature for example you can see sencha touch carousel component, but I think the swipe effect can be good enough too, not only for mobile web but for web desktop too. Here I want to share a little idea creating swipe like effect based on jquery UI draggable. Basically the idea is really simple it is the combination of  revert option in jquery ui draggable, jquery animation for moving an element, and mouse event for firing when the item have to swipe.</p>
<h6>HTML</h6>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;container&quot;&gt;
    &lt;div id=&quot;swipe_container&quot;&gt;
        &lt;div class=&quot;item&quot;&gt;Item Swipe 1&lt;/div&gt;
        &lt;div class=&quot;item&quot;&gt;Item Swipe 2&lt;/div&gt;
        &lt;div class=&quot;item&quot;&gt;Item Swipe 3&lt;/div&gt;
        &lt;div class=&quot;item&quot;&gt;Item Swipe 4&lt;/div&gt;
        &lt;div class=&quot;item&quot;&gt;Item Swipe 5&lt;/div&gt;
        &lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<h6 style="text-align: center;"><a href="http://demo.superdit.com/jquery/swipe_like_effect.html" target="_blank"><span id="more-8401"></span>Demo</a></h6>
<h6>CSS</h6>
<p>Make sure the swipe container width equal or larger than total items width for example you have 3 item swipe with 300px width, use minimum 900px for swipe container width.</p>
<pre class="brush: css; title: ; notranslate">
#container {
    width: 320px;
    height: 480px;
    overflow: hidden;
    border: 5px solid #0099cc;
    margin:0 auto;
}
#swipe_container {
    width: 1600px;
    background: #999;
}
.item {
    font-size: 24px;
    width: 320px;
    height: 480px;
    float: left;
    background: #e3e3e3;
}
</pre>
<h6>JQuery</h6>
<p>This jquery code will count the items inside the swipe container, this used for detecting whether it is the first item or the last item to swipe, if true, the position not change and to make it look like swiping an item, add the <em>revent </em>option on the draggable function.</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
    var cont_pos = $(&quot;#swipe_container&quot;).position();
    var item_width = $(&quot;.item&quot;).width();
    var items = $(&quot;#swipe_container &gt; div.item&quot;).length;
    var item_index = 1;
    var cont_post_temp;

    $(&quot;#swipe_container&quot;).draggable({ axis: &quot;x&quot;, revert: true });

    function bindMouseUp() {
        $(&quot;#swipe_container&quot;).unbind('mouseup');
        cont_post_temp = $(&quot;#swipe_container&quot;).position().left;
        if (cont_pos.left &gt; cont_post_temp &amp;&amp; item_index != items) {
            // swipe to right
            $(&quot;#swipe_container&quot;).draggable(&quot;option&quot;, &quot;revert&quot;, false);
            var moveLeft = cont_pos.left - cont_post_temp;
            moveLeft = Math.abs(item_width - moveLeft);
            $(&quot;#swipe_container&quot;).animate({
                left: '-=' + moveLeft
            }, 500, function() {
                $(&quot;#swipe_container&quot;).draggable(&quot;option&quot;, &quot;revert&quot;, true);
                cont_pos = $(&quot;#swipe_container&quot;).position();
                $(&quot;#swipe_container&quot;).bind('mouseup', function() {
                    bindMouseUp();
                });
            });
            item_index++;;
        } else if (cont_pos.left &lt; cont_post_temp &amp;&amp; item_index != 1) {
            // swipe to left
            $(&quot;#swipe_container&quot;).draggable(&quot;option&quot;, &quot;revert&quot;, false);
            var moveLeft = cont_post_temp - cont_pos.left;
            moveLeft = Math.abs(item_width - moveLeft);
            $(&quot;#swipe_container&quot;).animate({
                left: '+=' + moveLeft
            }, 500, function() {
                $(&quot;#swipe_container&quot;).draggable(&quot;option&quot;, &quot;revert&quot;, true);
                cont_pos = $(&quot;#swipe_container&quot;).position();
                $(&quot;#swipe_container&quot;).bind('mouseup', function() {
                    bindMouseUp();
                });
            });
            item_index = item_index - 1;
        } else {
            // on the beginning or end item swipe
            $(&quot;#swipe_container&quot;).draggable( &quot;option&quot;, &quot;revert&quot;, true );
            $(&quot;#swipe_container&quot;).bind('mouseup', function() {
                bindMouseUp();
            });
        }
    }

    $(&quot;#swipe_container&quot;).mouseup(function() {
        bindMouseUp();
    });
});
</pre>
<p>In above code the swipe function is triggered on <em>bingMouseUp, </em>in this function I have to bind and unbind the mouse event and the revert for preventing abuse mouse event, from user. That is all I know this not perfect, like this swipe only happen when the mouse up, but when mouse leave an item it came back to previous position.</p>
<h6 style="text-align: center;"><a href="http://demo.superdit.com/jquery/swipe_like_effect.html" target="_blank">Demo</a></h6>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/08/28/swipe-like-effect-based-on-jquery-ui-draggable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create Simple Ribbon With CSS</title>
		<link>http://superdit.com/2011/06/13/create-simple-ribbon-with-css/</link>
		<comments>http://superdit.com/2011/06/13/create-simple-ribbon-with-css/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 01:05:56 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[ribbon]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=7069</guid>
		<description><![CDATA[Ribbon style right now has became one of web design trend, it has been used in main menu navigation, background, header style, and any other part of web design, when I find some design with ribbon style web design, I found a post on myinkblog showcase ribbons in web design, many of these design using<a href="http://superdit.com/2011/06/13/create-simple-ribbon-with-css/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Ribbon style right now has became one of web design trend, it has been used in main menu navigation, background, header style, and any other part of web design, when I find some design with ribbon style web design, I found a post on <a title="Ribbons in Web Design: A Showcase" href="http://www.myinkblog.com/2011/05/16/a-showcase-of-ribbons-in-web-design" target="_blank">myinkblog showcase ribbons in web design</a>, many of these design using image as a ribbon, and here I try to forcing on creating simple ribbon style using CSS.</p>
<p><a title="Create Simple Ribbon With CSS" href="http://superdit.com/2011/06/13/create-simple-ribbon-with-css/"><img class="alignnone size-full wp-image-7294" title="CSS Ribbon" src="http://superdit.com/wp-content/uploads/2011/06/CSS-Ribbon.png" alt="CSS Ribbon" width="590" height="130" /></a></p>
<p>To achieve this I&#8217;m using a <a href="http://jonrohan.me/guide/css/creating-triangles-in-css/" target="_blank">CSS triangle tricks</a> from Jon Rohan, placed on the edge of the ribbon, and another two css triangle to create a shadow effect below the center ribbon.<span id="more-7069"></span></p>
<p style="text-align: center;"><a class="button large blue" href="http://demo.superdit.com/css/simple_ribbon.html" target="_blank">Demo</a></p>
<h5>All Code</h5>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;CSS Ribbon&lt;/title&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
        &lt;style type=&quot;text/css&quot;&gt;
            #main {
                border: 1px solid #fff;
                padding: 100px;
            }
            #menu {
                background: #c66969;
                width: 500px;
                height: 50px;
                color: #fff;
                font-size: 18px;
                text-align: center;
                position: relative;
                top: -20px;
            }
            #menu span {
                position: relative;
                top: 13px;
            }
            .cont {
                background: #b14444;
                width: 100px;
                height: 50px;
            }
            .edge-right {
                border-color: #b14444 white #b14444 #b14444;
                border-style:solid;
                border-width:25px;
                width:0;
                height:0;
                position: relative;
            }
            .edge-left {
                border-color: #b14444 #b14444 #b14444 white;
                border-style:solid;
                border-width:25px;
                width:0;
                height:0;
                position: relative;
            }
            .left {
                float: left;
            }
            .right {
                float: right;
            }
            .clear {
                clear: both;
            }
            .edge-right-small {
                position: absolute;
                top: 138px;
                left: 734px;
                border-color: #fff #fff #b14444 #873434;
                border-style:solid;
                border-width:0 0 21px 25px ;
                width:0;
                height:0;
            }
            .edge-left-small {
                position: absolute;
                top: 138px;
                left: 258px;
                border-color: #b14444 #873434 #b14444 red;
                border-style:solid;
                border-width:0 25px 21px 0;
                width:0;
                height:0;
            }
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id=&quot;main&quot;&gt;
            &lt;div class=&quot;edge-left left&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;cont left&quot;&gt;&lt;/div&gt;
            &lt;div id=&quot;menu&quot; class=&quot;left&quot;&gt;&lt;span&gt;Example of CSS ribbon&lt;span&gt;&lt;/div&gt;
            &lt;div class=&quot;cont left&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;edge-right left&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;

        &lt;div class=&quot;edge-right-small&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;edge-left-small&quot;&gt;&lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/06/13/create-simple-ribbon-with-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ExtJS: Simple File Browser</title>
		<link>http://superdit.com/2011/06/01/extjs-simple-file-browser/</link>
		<comments>http://superdit.com/2011/06/01/extjs-simple-file-browser/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 06:59:01 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=6871</guid>
		<description><![CDATA[ExtJS has a lot of great components to build complete web application that can be look like desktop application, In today post I want to show how to create a very simple file browser in ExtJS, with PHP backend we can easily get file and folder on the system. First this example have some limitation,<a href="http://superdit.com/2011/06/01/extjs-simple-file-browser/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>ExtJS has a lot of great components to build complete web application that can be look like desktop application, In today post I want to show how to create a very simple file browser in ExtJS, with PHP backend we can easily get file and folder on the system.</p>
<p><a title="ExtJS Simple File Browser" href="http://superdit.com/2011/06/01/extjs-simple-file-browser/" target="_blank"><img class="alignnone size-full wp-image-6873" title="ExtJS File Browser" src="http://superdit.com/wp-content/uploads/2011/06/screenshot.jpg" alt="ExtJS File Browser" width="540" height="200" /></a></p>
<p>First this example have some limitation, I try it on my XAMPP localhost, so I assumed the it is the top parent of all directories, the tree directory only load once when the page is loaded, file preview only in grid component.<span id="more-6871"></span></p>
<p style="text-align: center;"><a title="ExtJS File Browser Download" href="http://www.box.net/shared/eoby0n0ti5" target="_blank" class="button large green">download</a></p>
<h5>ExtJS</h5>
<p>The example container is based on window component, which have two items inside, they are treePanel and gridPanel, the gridPanel will load dynamically, trigerred when user click on of the tree node.</p>
<pre class="brush: jscript; title: ; notranslate">
Ext.onReady(function() {
    store_dir = Ext.create('Ext.data.TreeStore', {
        proxy: {
            type: 'ajax',
            url: 'get_dir.php'
        }
    });

    tree_dir = Ext.create('Ext.tree.Panel', {
        title: 'Localhost Directory',
        rootVisible: false,
        store: store_dir,
        split: true,
        region: 'west',
        collapsible: true,
        floatable: false,
        width: 200,
        useArrows: true,
        listeners: {
            itemclick: {
                fn: function(view, record, item, index, event) {
                    store_file.load({
                        url: 'get_file.php?dir=' + record.data.id
                    });

                    nodeId = record.data.id;
                    htmlId = item.id;
                }
            }

        }
    });

    Ext.define('File', {
       extend: 'Ext.data.Model',
       fields: ['filename', 'filesize', 'filedate']
    });

    store_file = Ext.create('Ext.data.Store', {
        model: 'File',
        proxy: {
          type: 'ajax',
          url: 'get_file.php',
          reader: {
              type: 'json',
              root: 'files'
          }
        }
    });

    grid_file = Ext.create('Ext.grid.Panel', {
        title: 'File List',
        region: 'center',
        store: store_file,
        columns: [
            { header: 'Name', width: 170, dataIndex: 'filename' },
            { header: 'Size', width: 100, dataIndex: 'filesize' },
            { header: 'Last Modified', width: 200, dataIndex: 'filedate' }
        ],
        viewConfig: {
            stripeRows: true
        }
    });

    win = Ext.create('widget.window', {
        title: 'ExtJS Simple File Browser',
        width: 700,
        height: 400,
        layout: 'border',
        bodyStyle: 'padding: 5px;',
        items: [tree_dir, grid_file]
    });

    win.show();
});
</pre>
<h5>PHP (get_dir.php)</h5>
<p>This file is for fetching all directory on your XAMPP htdocs directory, using <em>$_SERVER['DOCUMENT_ROOT']</em> variable. If you have many directory on htdocs, it will take time to load. In this php file I used a recursive function to get all the directory with all the sub directory by one call function, that&#8217;s why it will take time to load, and create a json format from it.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class MyDirectory {

    public $json = '[';

    public function get_children($dir, $child) {
        $dh = opendir($dir);
        while (($file = readdir($dh)) !== false) {
            if ($file != '.' AND $file != '..' ) {
                if (filetype($dir . $file) == 'dir') {
                    // must be checked if this folder have other subfolder
                    if ($this-&gt;count_sub_dir($dir . $file . '/') == 0) {
                        $this-&gt;json .= '{text:&quot;'.$file.'&quot;, leaf: true, id: &quot;'.$dir . $file.'&quot;},';
                    } else {
                        $this-&gt;json .= '{text:&quot;'.$file.'&quot;, id: &quot;'.$dir . $file.'&quot;, children: [';
                        $this-&gt;get_children($dir . $file . '/', true);
                    }
                }
            }
        }
        if ($child) {
            $this-&gt;json .=  ']},';
        }
        closedir($dh);
    }

    public function count_sub_dir($dir) {
        $dh = opendir($dir);
        $countdir = 0;
        while (($file = readdir($dh)) !== false) {
            if ($file != '.' AND $file != '..' ) {
                if (filetype($dir . $file) == 'dir') {
                    $countdir++;
                }
            }
        }
        closedir($dh);
        return $countdir;
    }
}

$host_dir = $_SERVER['DOCUMENT_ROOT'].&quot;/&quot;;

$dir = new MyDirectory();

$dir-&gt;get_children($host_dir, false);

$dir-&gt;json .= ']';
$dir-&gt;json = str_replace(&quot;,]&quot;, &quot;]&quot;, $dir-&gt;json);

echo($dir-&gt;json);

?&gt;
</pre>
<h5>PHP (get_file.php)</h5>
<p>And this is the last file to get all the file (without any directory) in specific directory, the parameter sent from ExtJS tree node, when it clicked.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

$dir = $_GET['dir'] . &quot;/&quot;;

$dh = opendir($dir);
$files = array();
while (($file = readdir($dh)) !== false) {
    if ($file != '.' AND $file != '..' ) {
        if (filetype($dir . $file) == 'file') {
            $files[] = array(
                'filename' =&gt; $file,
                'filesize' =&gt; filesize($dir . $file). ' bytes',
                'filedate' =&gt; date(&quot;F d Y H:i:s&quot;, filemtime($dir . $file))
            );
        }
    }
}
closedir($dh);

echo(json_encode(array('files' =&gt; $files)));

?&gt;
</pre>
<p>Well that all hope can give some idea to create much larger application or adding some more feature like icons view (using DataView component), create, edit, delete file, etc.</p>
<p style="text-align: center;"><a title="ExtJS File Browser Donwload" href="http://www.box.net/shared/eoby0n0ti5" target="_blank" class="button large green">download</a><br />
<img class="alignnone size-full wp-image-6872" title="ExtJS File Browser" src="http://superdit.com/wp-content/uploads/2011/06/screenshot-2.png" alt="ExtJS File Browser" width="540" height="318" /></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/06/01/extjs-simple-file-browser/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Create CSS Circle Button</title>
		<link>http://superdit.com/2011/05/20/create-css-circle-button/</link>
		<comments>http://superdit.com/2011/05/20/create-css-circle-button/#comments</comments>
		<pubDate>Fri, 20 May 2011 07:38:44 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=5950</guid>
		<description><![CDATA[With the new features that CSS3 have creating a variety of button can be fun, few days ago I read a great tutorial (in germany) about creating CSS3 push down button, basically this example just continuing from that post. In this example I modified the border radius, button padding, height and width so, it can<a href="http://superdit.com/2011/05/20/create-css-circle-button/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>With the new features that CSS3 have creating a variety of button can be fun, few days ago I read a great tutorial (in germany) about <a title="Tutorial: CSS3 push-down Buttons" href="http://joquery.com/2011/tutorial-css3-push-down-buttons" target="_blank">creating CSS3 push down button</a>, basically this example just continuing from that post.</p>
<p style="text-align: center;"><a title="Create CSS Circle Button" href="http://superdit.com/2011/05/20/create-css-circle-button" target="_blank"><img class="size-full wp-image-6674 aligncenter" title="CSS 3D Circle Button" src="http://superdit.com/wp-content/uploads/2011/05/shot.png" alt="CSS 3D Circle Button" width="341" height="173" /></a></p>
<p style="text-align: left;">In this example I modified the border radius, button padding, height and width so, it can look like a circle. And added the rotateX property that currently only supported in web kit browser, to make it look like from different angle.<span id="more-5950"></span></p>
<p style="text-align: center;"><a href="http://demo.superdit.com/css/circle_button.html" target="_blank">View Demo</a></p>
<p style="text-align: left;">This all the simple code you can directly copy paste on your editor</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
    &lt;style type=&quot;text/css&quot;&gt;
    body {
        font-family: Arial, sans-serif;
    }

    #container {
        margin: 120px auto;
        text-align: center;
    }

    .button {
        -webkit-transform: rotateX( 35deg );
        position: relative;
        display: inline-block;
        width: 100px;
        padding: 42px 15px;
        margin: 0px 10px;
        background-color: #C91826;
        color: #fff;
        font-weight: bold;
        font-size: 40px;
        text-decoration: none;
        text-align: center;
        text-shadow: 0px -1px 0px rgba(0,0,0,0.5);

        border: 1px solid;
        border-color: #B21522;
        border-radius: 78px;
        -moz-border-radius: 78px;
        -webkit-border-radius: 78px;

        box-shadow: 		inset 0px -4px 5px rgba(255,255,255,0.2),
                            inset 0px 1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 12px 0px #231F20,
                            0px 14px 0px #231F20,
                            0px 16px 0px #231F20,
                            /**/
                            0px 8px 5px rgba(0,0,0,0.5);

        -moz-box-shadow: 	inset 0px -4px 5px rgba(255,255,255,0.2),
                            inset 0px 1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 12px 0px #231F20,
                            0px 14px 0px #231F20,
                            0px 16px 0px #231F20,
                            /**/
                            0px 8px 5px rgba(0,0,0,0.5);

        -webkit-box-shadow: inset 5px -4px 5px rgba(255,255,255,0.2),
                            inset 5px 1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 12px 0px #231F20,
                            0px 14px 0px #231F20,
                            0px 16px 0px #231F20;
    }

    .button:hover {
        background-color: #B21522;
        color: #e3e3e3;
    }

    .button:active {
        top: 8px;
        box-shadow: 		inset 0px 4px 5px rgba(255,255,255,0.4),
                            inset 0px -1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 8px 0px #231F20,
                            /**/
                            0px 9px 5px rgba(0,0,0,0.5);

        -moz-box-shadow: 	inset 0px 4px 5px rgba(255,255,255,0.4),
                            inset 0px -1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 8px 0px #231F20,
                            /**/
                            0px 9px 5px rgba(0,0,0,0.5);

        -webkit-box-shadow: inset 0px 4px 5px rgba(255,255,255,0.4),
                            inset 0px -1px 5px rgba(255,255,255,0.2),
                            /**/
                            0px 8px 0px #231F20,
                            /**/
                            0px 9px 5px rgba(0,0,0,0.5);
    }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div id=&quot;container&quot;&gt;
    &lt;a href=&quot;#&quot; class=&quot;button&quot;&gt;Push&lt;/a&gt;
    &lt;a href=&quot;#&quot; class=&quot;button&quot;&gt;Stop&lt;/a&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h6>Resources</h6>
<p>joQuery : <a title="CSS3 Push Down Button" href="http://joquery.com/2011/tutorial-css3-push-down-buttons" target="_blank">CSS3 Push Down Buttons</a></p>
<p>Line 25: <a title="CSS DEsign stylish Button" href="http://line25.com/tutorials/css-basics-how-to-design-code-a-stylish-button" target="_blank">CSS Design Stylish Button</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/05/20/create-css-circle-button/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create Dynamic Tabs With JQuery</title>
		<link>http://superdit.com/2011/05/08/create-dynamic-tabs-with-jquery/</link>
		<comments>http://superdit.com/2011/05/08/create-dynamic-tabs-with-jquery/#comments</comments>
		<pubDate>Sun, 08 May 2011 11:58:12 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=6483</guid>
		<description><![CDATA[Tabs has become a common feature in web user interface, in this post I create an example creating a dynamic tab with JQuery. In JQuery UI there is already ready to use plugin to create tabbed content, but I did not find a way to adding dynamic tab function. This example using li tag as<a href="http://superdit.com/2011/05/08/create-dynamic-tabs-with-jquery/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Tabs has become a common feature in web user interface, in this post I create an example creating a dynamic tab with JQuery. In JQuery UI there is already ready to use plugin to create tabbed content, but I did not find a way to adding dynamic tab function.</p>
<p><img class="alignnone size-full wp-image-6486 aligncenter" title="jquery dynamic tab" src="http://superdit.com/wp-content/uploads/2011/05/thumb_tab.png" alt="jquery dynamic tab" width="509" height="111" /></p>
<p>This example using <em>li </em>tag as tab element, the technique are really simple, when new tab created, an id generated with counter variable, also the content element created too, with the matched counter.<span id="more-6483"></span></p>
<p style="text-align: center;"><a title="jquery dynamic tab" href="http://demo.superdit.com/jquery/dynamic_tab.html" target="_blank">view demo</a></p>
<h5>HTML</h5>
<p>This code only the container, there is only one <em>li </em>tag that contain add new tab button.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;ul id=&quot;tabul&quot;&gt;
    &lt;li id=&quot;litab&quot; class=&quot;ntabs add&quot;&gt;&lt;a href=&quot;&quot; id=&quot;addtab&quot;&gt;+&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&quot;tabcontent&quot;&gt;&lt;/div&gt;
</pre>
<h5>JQuery</h5>
<p>If we talk about dynamic element, we must be create an element on the fly, in this case we create the new tab and new content element. In <em>addtab </em>function we have to bind the &#8220;click&#8221; event because the element that created on fly will not work, if we applied the event on ready function.</p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
    var total_tabs = 0;

    // initialize first tab
    total_tabs++;
    addtab(total_tabs);

    $(&quot;#addtab, #litab&quot;).click(function() {
        total_tabs++;
        $(&quot;#tabcontent p&quot;).hide();
        addtab(total_tabs);
        return false;
    });

    function addtab(count) {
        var closetab = '&lt;a href=&quot;&quot; id=&quot;close'+count+'&quot; class=&quot;close&quot;&gt;&amp;times;&lt;/a&gt;';
        $(&quot;#tabul&quot;).append('&lt;li id=&quot;t'+count+'&quot; class=&quot;ntabs&quot;&gt;Tab '+count+'&amp;nbsp;&amp;nbsp;'+closetab+'&lt;/li&gt;');
        $(&quot;#tabcontent&quot;).append('&lt;p id=&quot;c'+count+'&quot;&gt;Tab Content '+count+'&lt;/p&gt;');

        $(&quot;#tabul li&quot;).removeClass(&quot;ctab&quot;);
        $(&quot;#t&quot;+count).addClass(&quot;ctab&quot;);

        $(&quot;#t&quot;+count).bind(&quot;click&quot;, function() {
            $(&quot;#tabul li&quot;).removeClass(&quot;ctab&quot;);
            $(&quot;#t&quot;+count).addClass(&quot;ctab&quot;);
            $(&quot;#tabcontent p&quot;).hide();
            $(&quot;#c&quot;+count).fadeIn('slow');
        });

        $(&quot;#close&quot;+count).bind(&quot;click&quot;, function() {
            // activate the previous tab
            $(&quot;#tabul li&quot;).removeClass(&quot;ctab&quot;);
            $(&quot;#tabcontent p&quot;).hide();
            $(this).parent().prev().addClass(&quot;ctab&quot;);
            $(&quot;#c&quot;+count).prev().fadeIn('slow');

            $(this).parent().remove();
            $(&quot;#c&quot;+count).remove();
            return false;
        });
    }
});
</pre>
<h5>CSS</h5>
<pre class="brush: css; title: ; notranslate">
#tabul {
    padding: 0;
    margin: 0;
    padding: 5px 0;
}
#tabul li {
    display: inline;
    -webkit-border-radius: .3em .3em 0 0;
    -moz-border-radius: .3em .3em 0 0;
    border-radius: .3em .3em 0 0;
    cursor: pointer;
}
.ntabs {
    background: #BDC7D5;
    margin-right: 1px;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    border: 1px solid #BDC7D5;
    padding: 5px 3px 5px 8px;
}
.add {
    padding: 5px 8px;
}
#addtab {
    font-size: 16px;
    text-decoration: none;
    position: relative;
    top: 2px;
    color: #333;
}
#addtab:hover {
    color: #999;
}
.ctab {
    background: #E7EDF6;
    position: relative;
    top: 2px;
    border-bottom-width: 0;
}
.close {
    text-decoration: none;
    color: #999;
    font-weight: bold;
    font-size: 14px;
    padding: 0 4px;
    -webkit-border-radius: .2em;
    -moz-border-radius: .2em;
    border-radius: .2em;
}
.close:hover {
    background: #999;
    color: #333;
}
#tabcontent {
    border: 1px solid #BDC7D5;
    background: #E7EDF6;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    color: #666;
    font-size: 24px;
}
</pre>
<p style="text-align: left;">Yep, thats all, some suggestion are you can put the tab in an div element and show as a hidden content, expand the <em>ul </em>tag dynamically so you can have unlimited tabs horizontally, and add a navigation button to browse the tab by playing the <em>left </em>css property.</p>
<p style="text-align: center;"><a title="jquery dynamic tab" href="http://demo.superdit.com/jquery/dynamic_tab.html" target="_blank">view demo</a></p>
<p style="text-align: center;"><a href="http://demo.superdit.com/jquery/dynamic_tab.html" target="_blank"><img class="alignnone size-full wp-image-6493" title="jquery dynamic tab demo" src="http://superdit.com/wp-content/uploads/2011/05/dyamic-tab.png" alt="jquery dynamic tab demo" width="540" height="165" /></a></p>
<h5 style="text-align: left;">Other Sources</h5>
<p><a href="http://viralpatel.net/blogs/2009/04/jquery-tabs-create-html-tabs-using-jquery-ui.html" target="_blank">jQuery tabs: Create HTML tabs using jQuery UI</a></p>
<p><a href="http://jqueryfordesigners.com/jquery-tabs/" target="_blank">jQuery Tabs</a></p>
<p><a title="How To Create Tabs Using jQuery" rel="bookmark" href="http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery" target="_blank">How To Create Tabs Using jQuery</a></p>
<p><a href="http://www.ilovecolors.com.ar/jquery-tabs/" target="_blank">jQuery Tabs Made Easy</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/05/08/create-dynamic-tabs-with-jquery/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JQuery Detect Mouse Click Event</title>
		<link>http://superdit.com/2011/04/23/jquery-detect-mouse-click-event/</link>
		<comments>http://superdit.com/2011/04/23/jquery-detect-mouse-click-event/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 11:10:46 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=6237</guid>
		<description><![CDATA[This short post I want to share how JQuery handle the mouse click event, that include left click, right click and middle click, also this example show how to moving an html element based on cursor position. With CSS capability, I create some html element that shows like a physical mouse, when the appropriate button<a href="http://superdit.com/2011/04/23/jquery-detect-mouse-click-event/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>This short post I want to share how JQuery handle the mouse click event, that include left click, right click and middle click, also this example show how to moving an html element based on cursor position.</p>
<p style="text-align: center;"><a href="http://superdit.com/2011/04/23/jquery-detect-mouse-click-event/"><img class="size-full wp-image-6247 aligncenter" title="Jquery Mouse Click" src="http://superdit.com/wp-content/uploads/2011/04/thumb.png" alt="Jquery Mouse Click" width="312" height="373" /></a></p>
<p>With CSS capability, I create some html element that shows like a physical mouse, when the appropriate button clicked the color change as well. The result may something look like on the picture above.<span id="more-6237"></span></p>
<p style="text-align: center;"><a title="JQuery detect mouse click" href="http://demo.superdit.com/jquery/detect_mouse_click.html" target="_blank">View Demo</a></p>
<h5>The HTML</h5>
<p>These are the html element used for this example, very simple, the mouse scroll using relative position, that relative from the container, and as usual on each corner, rounded corner property used.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;content&quot;&gt;
  &lt;div class=&quot;top&quot; id=&quot;topleft&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;top&quot; id=&quot;topright&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;topmiddle&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;mbody&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<h5>The JQuery</h5>
<p>The right click menu is turned off. To make the main element following the cursor position, <em>mousemove</em> event applied to document selector, with the change of the top and left css property. The background change when the <em>mousedown</em> event triggered and back to current condition when <em>mouseup </em>event triggered.</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
    var cwidth_half = $(&quot;#content&quot;).width() / 2;
    var cheight_half = $(&quot;#content&quot;).height() / 2;

    $(document).mousemove(function(e) {
        $(&quot;#content&quot;).css({
            left: (e.pageX-cwidth_half)+'px',
            top: (e.pageY-cheight_half)+'px'
        });
    });

    $(document).bind(&quot;contextmenu&quot;, function(e) {
        return false;
    });

    $(document).mousedown(function(event) {
        switch (event.which) {
            case 1:
                $(&quot;#topleft&quot;).css(&quot;background&quot;, &quot;#333&quot;);
                break;
            case 2:
                $(&quot;#topmiddle&quot;).css(&quot;background&quot;, &quot;#333&quot;);
                break;
            case 3:
                $(&quot;#topright&quot;).css(&quot;background&quot;, &quot;#333&quot;);
                break;
        }
    });

    $(document).mouseup(function(event) {
        switch (event.which) {
            case 1:
                $(&quot;#topleft&quot;).css(&quot;background&quot;, &quot;#d3d3d3&quot;);
                break;
            case 2:
                $(&quot;#topmiddle&quot;).css(&quot;background&quot;, &quot;#999&quot;);
                break;
            case 3:
                $(&quot;#topright&quot;).css(&quot;background&quot;, &quot;#d3d3d3&quot;);
                break;
        }
    });

});
</pre>
<h5>The CSS</h5>
<pre class="brush: css; title: ; notranslate">
#content {
    position: relative;
    width: 310px;
    height: 310px;
}
.top {
    float:left;
    width:150px;
    height: 150px;
    background: #d3d3d3;
    border: 1px solid #666;
}
#topleft {
    -webkit-border-radius: 10em .5em 0 0;
    -moz-border-radius: 10em .5em 0 0;
    border-radius: 10em .5em 0 0;
    border-right-width: 0;
}
#topright {
    -webkit-border-radius: .5em 10em 0 0;
    -moz-border-radius: .5em 10em 0 0;
    border-radius: .5em 10em 0 0;
}
#topmiddle {
    width:30px;
    height: 100px;
    position: relative;
    -webkit-border-radius: 5.5em;
    -moz-border-radius: 5.5em;
    border-radius: 5.5em;
    background: #999;
    border: 1px solid #666;
    z-index: 1;
    top: 15px;
    left: 135px;
}
.clear {
    clear: both;
}
#mbody {
    border: 1px solid #666;
    border-top-width: 0;
    background: #d3d3d3;
    width: 301px;
    height: 250px;
    -webkit-border-radius: 0 0 15.5em 15.5em;
    -moz-border-radius: 0 0 15.5em 15.5em;
    border-radius: 0 0 15.5em 15.5em;
}
</pre>
<p style="text-align: center;"><a title="JQuery detect mouse click" href="http://demo.superdit.com/jquery/detect_mouse_click.html" target="_blank">View Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/04/23/jquery-detect-mouse-click-event/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple Images Slideshow With JQuery</title>
		<link>http://superdit.com/2011/04/18/simple-images-slideshow-with-jquery/</link>
		<comments>http://superdit.com/2011/04/18/simple-images-slideshow-with-jquery/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 03:23:19 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[slideshow]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=6172</guid>
		<description><![CDATA[Slideshow is one of the most used feature in a web application, especially in a photo sharing site like flickr, photobucket, or maybe for used is some online store to showcasing some available new product, whatever it for, it is up to you as developer, In this post I want to share my example creating<a href="http://superdit.com/2011/04/18/simple-images-slideshow-with-jquery/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Slideshow is one of the most used feature in a web application, especially in a photo sharing site like flickr, photobucket, or maybe for used is some online store to showcasing some available new product, whatever it for, it is up to you as developer, In this post I want to share my example creating very simple slideshow base on JQuery.</p>
<p><a title="JQuery Slideshow" href="http://superdit.com/2011/04/18/simple-images-slideshow-with-jquery" target="_blank"><img class="aligncenter size-full wp-image-6178" title="jquery slideshow" src="http://superdit.com/wp-content/uploads/2011/04/jquery_slideshow_thumb.png" alt="jquery slideshow" width="540" height="160" /></a></p>
<p>I assume all the images have the same size, and there are the navigation to switch between the images, like prev, next, first and last.<span id="more-6172"></span></p>
<p style="text-align: center;"><a title="JQuery Slideshow Demo" href="http://demo.superdit.com/jquery/slideshow/" target="_blank">View Demo</a> | <a title="JQuery Slideshow Download" href="http://www.box.net/shared/a53ldhpthf" target="_blank">Download Source</a></p>
<h5>The HTML</h5>
<p>Here are the html code, this example using 6 images, they are hardcoded in html, and there are a list of thumbnail images, to switch directly to seletected images.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;container&quot;&gt;
  &lt;div id=&quot;navigate&quot;&gt;
      &lt;a href=&quot;&quot; id=&quot;linkfirst&quot;&gt;&amp;laquo; first&lt;/a&gt;
      &lt;span id=&quot;spanfirst&quot;&gt;&amp;laquo; first&lt;/span&gt;
      &lt;a href=&quot;&quot; id=&quot;linkprev&quot;&gt;&amp;lsaquo; prev&lt;/a&gt;
      &lt;span id=&quot;spanprev&quot;&gt;&amp;lsaquo; prev&lt;/span&gt;
      &lt;a href=&quot;&quot; id=&quot;linknext&quot;&gt;next &amp;rsaquo;&lt;/a&gt;
      &lt;span id=&quot;spannext&quot;&gt;next &amp;rsaquo;&lt;/span&gt;
      &lt;a href=&quot;&quot; id=&quot;linklast&quot;&gt;last &amp;raquo;&lt;/a&gt;
      &lt;span id=&quot;spanlast&quot;&gt;last &amp;raquo;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div id=&quot;img_container&quot;&gt;
      &lt;div id=&quot;img_box&quot;&gt;
          &lt;img id=&quot;img1&quot; src=&quot;img/original/01.jpg&quot;/&gt;
          &lt;img id=&quot;img2&quot; src=&quot;img/original/02.jpg&quot;/&gt;
          &lt;img id=&quot;img3&quot; src=&quot;img/original/03.jpg&quot;/&gt;
          &lt;img id=&quot;img4&quot; src=&quot;img/original/04.jpg&quot;/&gt;
          &lt;img id=&quot;img5&quot; src=&quot;img/original/05.jpg&quot;/&gt;
          &lt;img id=&quot;img6&quot; src=&quot;img/original/06.jpg&quot;/&gt;
          &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id=&quot;imgthumb_box&quot;&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink1&quot;&gt;&lt;img src=&quot;img/thumb/01.jpg&quot;/&gt;&lt;/a&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink2&quot;&gt;&lt;img src=&quot;img/thumb/02.jpg&quot;/&gt;&lt;/a&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink3&quot;&gt;&lt;img src=&quot;img/thumb/03.jpg&quot;/&gt;&lt;/a&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink4&quot;&gt;&lt;img src=&quot;img/thumb/04.jpg&quot;/&gt;&lt;/a&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink5&quot;&gt;&lt;img src=&quot;img/thumb/05.jpg&quot;/&gt;&lt;/a&gt;
      &lt;a href=&quot;&quot; class=&quot;thumblink&quot; id=&quot;imglink6&quot;&gt;&lt;img src=&quot;img/thumb/06.jpg&quot;/&gt;&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<h5>The JQuery</h5>
<p>Here are the main function for sliding the images, basically it just playing with <em>left</em> css property in image box element, default condition for the image box is <em>left = 0px</em> (in firefox), or <em>left = &#8216;auto&#8217;</em> (in Chrome, Opera, IE).</p>
<p>For &#8220;next&#8221; navigation, if current position is on the last image, it will back to the first image, for &#8220;prev&#8221; navigation, if current position is on the first image, it will move to the last image, and when one of the image selected, the matched thumbnail will change it style.</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
    var total = $(&quot;#img_box img&quot;).length;

    $(&quot;#imglink1 img&quot;).css({
        &quot;border-color&quot;: &quot;#0099cc&quot;,
        &quot;top&quot;: &quot;-5px&quot;
    });

    $(&quot;.thumblink&quot;).click(function() {
        var imgnumber = parseInt($(this).attr('id').replace(&quot;imglink&quot;, &quot;&quot;));
        var move = -($(&quot;#img&quot;+imgnumber).width() * (imgnumber - 1));

        $(&quot;#img_box&quot;).animate({
            left: move
        }, 500);

        $(&quot;#imgthumb_box&quot;).find(&quot;img&quot;).removeAttr(&quot;style&quot;);
        $(this).find(&quot;img&quot;).css({
            &quot;border-color&quot;: &quot;#0099cc&quot;,
            &quot;top&quot;: &quot;-5px&quot;,
            &quot;border-top-width&quot;: &quot;-5px&quot;
        });
        return false;
    });

    $(&quot;#navigate a&quot;).click(function() {
        var imgwidth = $(&quot;#img1&quot;).width();
        var box_left = $(&quot;#img_box&quot;).css(&quot;left&quot;);
        var el_id = $(this).attr(&quot;id&quot;);
        var move, imgnumber;

        if (box_left == 'auto') {
            box_left = 0;
        } else {
            box_left = parseInt(box_left.replace(&quot;px&quot;, &quot;&quot;));
        }

        // if prev
        if (el_id == 'linkprev') {
            if ((box_left - imgwidth) == -(imgwidth)) {
                move = -(imgwidth * (total - 1));
            } else {
                move = box_left + imgwidth;
            }

            imgnumber = -(box_left / imgwidth);
            if (imgnumber == 0) {
                imgnumber = total;
            }
        } else if (el_id == 'linknext') {
            // if in the last image, move to first
            if (-(box_left) == (imgwidth * (total - 1))) {
                move = 0;
            } else {
                move = box_left - imgwidth;
            }

            imgnumber = Math.abs((box_left / imgwidth)) + 2;
            if (imgnumber == (total + 1)) {
                imgnumber = 1;
            }
        } else if (el_id == 'linkfirst') {
            move = 0;
            imgnumber = 1;
        } else if (el_id == 'linklast') {
            move = -(imgwidth * (total - 1));
            imgnumber = total;
        }

        // styling selected image
        $(&quot;#imgthumb_box&quot;).find(&quot;img&quot;).removeAttr(&quot;style&quot;);
        $(&quot;#imglink&quot;+imgnumber).find(&quot;img&quot;).css({
            &quot;border-color&quot;: &quot;#0099cc&quot;,
            &quot;top&quot;: &quot;-5px&quot;,
            &quot;border-top-width&quot;: &quot;-5px&quot;
        });

        $(&quot;#navigate a&quot;).hide();
        $(&quot;#navigate span&quot;).show();

        $(&quot;#img_box&quot;).animate({
            left: move+'px'
        }, 400, function() {
            $(&quot;#navigate a&quot;).show();
            $(&quot;#navigate span&quot;).hide();
        });

        return false;
    });
});
</pre>
<h5>The CSS</h5>
<p>Make sure the image container apply <em>overflow: hidden </em>property, these are the main image container that contain all the images, actually all the images are placed inline, inside the container.</p>
<pre class="brush: css; title: ; notranslate">
#container {
    margin-top: 40px;
}
#navigate {
    text-align: center;
}
#navigate a, span {
    position: relative;
    top: 3px;
    background: #0099cc;
    text-decoration: none;
    color: #fff;
    padding: 4px 8px 0 8px;
    font-size: 20px;
    font-weight: bold;
    -webkit-border-radius: .3em .3em 0 0;
    -moz-border-radius: .3em .3em 0 0;
    border-radius: .3em .3em 0 0;
}
#navigate a:hover {
    color: #d3d3d3;
}
#navigate span {
    display: none;
    color: #999;
}
#img_container {
    overflow: hidden;
    width: 500px;
    margin: 0 auto;
    border: 8px solid #0099cc;
    -webkit-border-radius: .5em;
    -moz-border-radius: .5em;
    border-radius: .5em;
}
#img_box {
    position: relative;
    width: 3000px;
    margin: 0;
}
#img_box img {
    float: left;
}
#imgthumb_box {
    text-align: center;
}
#imgthumb_box a {
    margin-left: 4px;
}
#imgthumb_box a img {
    border: 6px solid #e3e3e3;
    position: relative;
    top: 10px;
    -webkit-border-radius: .3em;
    -moz-border-radius: .3em;
    border-radius: .3em;
}
#imgthumb_box a img:hover {
    border-color: #666;
}
</pre>
<p style="text-align: center;"><a title="JQuery Slideshow Demo" href="http://demo.superdit.com/jquery/slideshow/" target="_blank">View Demo</a> | <a title="JQuery Slideshow Download" href="http://www.box.net/shared/a53ldhpthf" target="_blank">Download Source</a></p>
<p><a title="JQuery Slideshow Demo" href="http://demo.superdit.com/jquery/slideshow/" target="_blank"><img class="aligncenter size-full wp-image-6184" title="jquery slideshow" src="http://superdit.com/wp-content/uploads/2011/04/jquery_slideshow.png" alt="jquery slideshow" width="540" height="402" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/04/18/simple-images-slideshow-with-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Displaying Twitter Search Result With Sencha Touch</title>
		<link>http://superdit.com/2011/04/15/displaying-twitter-search-result-with-sencha-touch/</link>
		<comments>http://superdit.com/2011/04/15/displaying-twitter-search-result-with-sencha-touch/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 08:23:16 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Sencha Touch]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=6156</guid>
		<description><![CDATA[Today I want to take another step in Learning Sencha Touch, if you already browse on all sencha touch official examples there are already have the same twitter search example and that is a better one, but when I try it look like the interface only optimized for tablet. This example only created for smartphone<a href="http://superdit.com/2011/04/15/displaying-twitter-search-result-with-sencha-touch/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>Today I want to take another step in Learning Sencha Touch, if you already browse on all sencha touch official examples there are already have the same twitter search example and that is a better one, but when I try it look like the interface only optimized for tablet.</p>
<p><a title="Displaying Twitter Search Result With Sencha Touch" href="http://superdit.com/2011/04/15/displaying-twitter-search-result-with-sencha-touch/"><img class="aligncenter size-full wp-image-6158" title="Sencha Touch Twitter Search" src="http://superdit.com/wp-content/uploads/2011/04/thumbnail.png" alt="Sencha Touch Twitter Search" width="540" height="170" /></a></p>
<p>This example only created for smartphone resolution, and very simple single twitter search without pagination or load more function, and to fetch data twitter server here is using PHP.<span id="more-6156"></span></p>
<p style="text-align: center;"><a title="Sencha Touch Twitter Search Demo" href="http://demo.superdit.com/sencha-touch/twitter_search/" target="_blank">View Demo</a> | <a title="Sencha Touch Twitter Search Download" href="http://www.box.net/shared/fep0g6lhdr" target="_blank">Download Source</a></p>
<p style="text-align: center;"><em>(use mobile webkit browser to see demo)</em></p>
<h5>Sencha Touch Code</h5>
<p>The Sencha Touch code consist of four panel component one for main component, one for top toolbar, this panel not doing nothing but just showing application title, one for search textfield and button, and the last one for displaying search result</p>
<pre class="brush: jscript; title: ; notranslate">
Ext.setup({
    onReady: function() {
        var topToolbar = new Ext.Toolbar({
            dock : 'top',
            ui: 'dark',
            title: 'Sencha Twitter Search'
        });

         var tpl = new Ext.XTemplate(
            '&lt;div id=&quot;tweet_container&quot;&gt;',
                '&lt;tpl for=&quot;.&quot;&gt;',
                    '&lt;div class=&quot;tweet_data&quot;&gt;',
                    '&lt;div class=&quot;tweet_avatar&quot;&gt;',
                        '&lt;img width=&quot;30&quot; height=&quot;30&quot; src=&quot;{profile_image_url}&quot;/&gt;',
                    '&lt;/div&gt;',
                    '&lt;div class=&quot;tweet_content&quot;&gt;',
                        '&lt;a class=&quot;user&quot; href=&quot;http://twitter.com/{from_user}&quot;&gt;{from_user}&lt;/a&gt;&amp;nbsp;',
                        '{text}',
                    '&lt;/div&gt;',
                    '&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;',
                    '&lt;/div&gt;',
                '&lt;/tpl&gt;',
            '&lt;/div&gt;'
         );

        var resultPanel = new Ext.Panel({
            layout: 'fit',
            style: 'padding-bottom: 10px;',
            tpl: tpl
        });

        var searchPanel = new Ext.Panel({
            padding: 10,
            layout: {
                type: 'hbox',
                align: 'stretch'
            },
            items: [{
                flex: 4,
                xtype: 'textfield',
                style: 'margin-right: 10px;',
                id: 'textquery'
            },{
                flex: 2,
                xtype: 'button',
                text: 'Search',
                handler: function() {
                    var query = Ext.getCmp(&quot;textquery&quot;).getValue();
                    Ext.Ajax.request({
                        url: 'index.php?act=search&amp;q='+query,
                        success: function(e) {
                            var obj = Ext.util.JSON.decode(e.responseText);
                            var msg = obj.results;
                            var html = tpl.apply(msg);
                            resultPanel.update(html);
                        }
                    });
                }
            }]
        });

        var myPanel = new Ext.Panel({
            dockedItems: [topToolbar],
            items: [searchPanel, resultPanel],
            scroll: 'vertical',
            style: 'background: #DDEEF6;',
            fullscreen : true
        });
    }
});
</pre>
<p>The result panel using XTemplate to displaying search result, and remember to set the config layout value to &#8216;fit&#8217; , so it can be scrollable.</p>
<h5>PHP Code</h5>
<p>The PHP code fetch the search result as a JSON format, this is only using twitter search api, so we don&#8217;t need to register for using this api, here is the link to know more about <a title="twitter search api" href="http://search.twitter.com/api/" target="_blank">twitter search api</a>, in case you wanna know about other parameter or getting as other format.</p>
<pre class="brush: php; title: ; notranslate">
if (isset($_GET[&quot;act&quot;]) &amp;&amp; $_GET[&quot;act&quot;] == &quot;search&quot;) {
    $url = 'http://search.twitter.com/search.json?q='.$_GET[&quot;q&quot;];

    $content = file_get_contents($url);
    $array = json_decode($content);

    $data = array();

    foreach ($array-&gt;results as $var =&gt; $value)
    {
        // adding url
        $pattern = '/\b(https?:\/\/[-A-Z0-9+&amp;@#\/%?=~_|$!:,.;]*[A-Z0-9+&amp;@#\/%=~_|$])/i';
        preg_match_all($pattern, $value-&gt;text, $regs);
        $loop = count($regs[0]);

        for ($i = 0; $i &lt; $loop; $i++) {
            $value-&gt;text = str_replace($regs[0][$i], '&lt;a class=&quot;outlink&quot; href=&quot;'.$regs[0][$i].'&quot;&gt;'.$regs[0][$i].'&lt;/a&gt;', $value-&gt;text);
        }

        $data[] = array(
            &quot;profile_image_url&quot; =&gt; $value-&gt;profile_image_url,
            &quot;from_user&quot;         =&gt; $value-&gt;from_user,
            &quot;text&quot;              =&gt; $value-&gt;text
        );
    }

    $out = array(
        &quot;success&quot; =&gt; true,
        &quot;results&quot; =&gt; $data
    );

    echo json_encode($out);
    exit;
}
</pre>
<p>In PHP code there are a regex function I get from <a title="PHP If text contains url" href="http://www.phpfreaks.com/forums/index.php?topic=259451.0" target="_blank">phpfreak</a> to check whether the tweets contain some url, if yes it will change directly to html link element. Last this are the screen example, if you want to see the demo, better using your iphone, android smartphone or using the android emulator, cause I&#8217;m not creating condition for desktop browser or tablet.</p>
<p style="text-align: center;"><a title="Sencha Touch Twitter Search Demo" href="http://demo.superdit.com/sencha-touch/twitter_search/" target="_blank">View Demo</a> | <a title="Sencha Touch Twitter Search Download" href="http://www.box.net/shared/fep0g6lhdr" target="_blank">Download Source</a></p>
<p><img class="aligncenter size-full wp-image-6161" title="Sencha Touch Twitter Search" src="http://superdit.com/wp-content/uploads/2011/04/screenshot2.png" alt="Sencha Touch Twitter Search" width="540" height="314" /></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2011/04/15/displaying-twitter-search-result-with-sencha-touch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

