<?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>El Blog del Antonio &#187; JQuery</title>
	<atom:link href="http://www.ramirezcobos.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ramirezcobos.com</link>
	<description>Programming Web with PHP, CSS, Javascript and ∞</description>
	<lastBuildDate>Wed, 28 Dec 2011 18:26:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Livebuttons Plugin</title>
		<link>http://www.ramirezcobos.com/2010/12/15/jquery-livebuttons-plugin/</link>
		<comments>http://www.ramirezcobos.com/2010/12/15/jquery-livebuttons-plugin/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 15:45:23 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=716</guid>
		<description><![CDATA[Introduction
I normally develop CMS (control management systems) based on a heavy use of AJAX, and I normally endup writing tones of jQuery functions for different IDs and/or CLASSes. Thinking to create a library that will free me to create the same functions again and again and for different  [...]]]></description>
			<content:encoded><![CDATA[<h2><a rel="attachment wp-att-372" href="http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/picture-121-300x157/"><img class="alignright size-thumbnail wp-image-372" title="jQuery" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157-120x120.png" alt="" width="120" height="120" /></a>Introduction</h2>
<p>I normally develop CMS (control management systems) based on a heavy use of AJAX, and I normally endup writing tones of jQuery functions for different IDs and/or CLASSes. Thinking to create a library that will free me to create the same functions again and again and for different classes I thought about this simple plugin. The reason was that if I was to create a new CMS for my beloved Yii framework, I just wanted to have a system where, by setting some meta data into the HTML elements, the client script will smartly know what to do. I didn&#8217;t want to necessary worry about different classes on  my client scripts, I wanted to be just one class.</p>
<p>The idea behind goes a bit further and has something to do with Yii, I want to create extensions that will take care of the correct rendering of a button without having to worry about the client scripts **and** also the same extension could actually call jquery commands easily. I emphasized **and** because Yii already provides an ajaxLink and an ajaxButton but they are not listened to perform client jquery executions and that, as seen in its forums, is causing problems to PHP programmers a lot of times.</p>
<p>Also, I envision an environment where through this, Yii extension designers will be able to create CMS styles, completely different that the one coming from Yii, so Yii users could easily integrate a new layout without even tweaking CSS, or Themes, or Layouts, just their views and by integrating some specialized widgets API, user will be able to program a gallery (for example) with just one line of code on their views. Enough talking, here is the plugin for you to test it and tell me what do you think.</p>
<h2>How to use</h2>
<p>Include jquery and jquery.livebuttons.js on your document&#8217;s head and start monitoring for livebuttons like this:</p>
<pre class="brush: jscript; title: ; notranslate">
//
// .selector is the class name the HTML elements have
$('.selector').livebuttons();
$('.selector').livebuttons( options );
//
// we can have more than one
$('.otherselector').livebuttons( otheroptions );
</pre>
<h2>Options</h2>
<h3>useFirebug</h3>
<p>A useful property for debuggin processes. If set to true all logs will be displayed on firebug console (or chrome).</p>
<pre class="brush: jscript; title: ; notranslate">
var options = {
    useFirebug: true
}
$('.selector').livebuttons( options );
</pre>
<h3>events</h3>
<p>An array of options where to specify the events to monitor. In future releases, we will be able to specify which methods correspond for certain events.</p>
<pre class="brush: jscript; title: ; notranslate">
var options = {
    events: ['click','mouseover'] // not a good practice though *yet*
}
$('.selector').livebuttons( options );
</pre>
<h3>methods</h3>
<p>This is the most interesting part of the plugin. We could implement our own javascript methods to be used with livebuttons. All methods will receive a &#8216;command&#8217; parameter, which is actually the object in the meta-data of the HTML element (see below on the examples provided for default methods).</p>
<pre class="brush: jscript; title: ; notranslate">
var options = {
    methods: {
        alert: function( command ) {
              alert( command.message );
        }
   }
}
$('.selector').livebuttons( options );
</pre>
<p>When designing our own javascript functions to be attached to the plugin, we can access internal parser functions with <strong>this</strong> keyboard. All functions receive a command object and also a reference to the <strong>options</strong> object. This object have a reference to the parser it self and we could easily access parser&#8217;s functions by using <strong>this.parser</strong>.</p>
<h2>The Parser</h2>
<p>If you look at the code inside the plugin, you will see that the parser has a couple of good methods to use:</p>
<h3>stringify</h3>
<p>Converts an object to its JSON representation string</p>
<h3>createIFrame</h3>
<p>Creates an iframe to be used with FORMs with multipart/form-data. So you can easily send files to the server without the need of reloading the page. Check at its code to see its</p>
<h3>removeIFrame</h3>
<p>Removes the iFrame previously created with parser.createIFrame() method.</p>
<h3>parseJSON</h3>
<p>Parses a JSON string and converts it into an object. I know jQuery comes with one, but it throws an error when you include a function into a command object&#8217;s property.</p>
<h2>Default Methods</h2>
<p>You have a couple of methods that already come with the plugin. You can easily override them if required. Here they are:</p>
<h3>ajax</h3>
<p>Its name is self-explanatory. It receives a command object on the following format:</p>
<pre>
{method:'ajax',url:'',data:{},success:function(){},error:function(){}}</pre>
<p><strong>Example of live button markup</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;a class=&quot;livebutton&quot; href=&quot;#&quot;
data-cmd='{&quot;method&quot;:&quot;ajax&quot;,&quot;url&quot;:'http://localhost/',&quot;success&quot;:handleAJAX}&quot;&gt;test ajax&lt;/a&gt;
</pre>
<h3>getscript</h3>
<p>Its calling jQuery&#8217;s getScript method. It receives a command object on the following format:</p>
<pre>
{method:'getscript',url:''}</pre>
<p><strong>Example of live button markup</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;a href=&quot;#&quot; class=&quot;livebutton&quot;
   data-cmd='{method:&quot;getscript&quot;,url:'http://localhost/script.js'}' &gt;test getscript&lt;/a&gt;
</pre>
<h3>jquery</h3>
<p>Its calling any jQuery&#8217;s method. It receives a command object on the following format:</p>
<pre>
{"method":"jquery","jqmethod": "","target":"","arguments":["url",function(){}]}</pre>
<p><strong>Example of live button markup</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;a class=&quot;livebutton&quot; href=&quot;#&quot; data-cmd=&quot;{&quot;method&quot;:&quot;jquery&quot;,&quot;jqmethod&quot;:&quot;load&quot;,&quot;target&quot;:&quot;#layer&quot;,&quot;arguments&quot;:[&quot;url&quot;:&quot;http://localhost&quot;]&quot;&gt;test load jquery function&lt;/a&gt;
</pre>
<h2>Remarks</h2>
<p>As previously said, all functions also receive the command object extracted from the HTML element, but that&#8217;s not all. The parser automatically includes a jquery reference of the HTML element to the command&#8217;s element property.</p>
<pre class="brush: jscript; title: ; notranslate">
var options = {
    methods: {
        alert: function( command ) {
              alert( command.message );
             // do not use $( command.element ) as it would like $( $( element ) )
              command.element.attr('title','I have already been clicked');
        }
   }
}
$('.selector').livebuttons( options );
</pre>
<h2>Demo</h2>
<p>For the sake of having a demo (I will build a better one) the following script will create a live button that can perform jquery &#8216;append&#8217; commands. Please note that when you load new content via AJAX on a page that has the livebuttons plugin that you have successfuly initiated, the plugin will also listen to the specified events to those livebuttons loaded via AJAX.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
&lt;head&gt;
&lt;script src=&quot;path\to\jquery.livebuttons.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
$('.testbuttons').livebuttons();
&lt;body&gt;
&lt;a href=&quot;#&quot; class=&quot;testbuttons&quot;
  data-cmd=&quot;{&quot;method&quot;:&quot;jquery&quot;,&quot;jqmethod&quot;:&quot;append&quot;,&quot;target&quot;:&quot;#container&quot;,&quot;arguments&quot;:[&quot;new content&lt;br&gt;&quot;]}&quot;&gt;Test append&lt;/a&gt;
&lt;div id=&quot;container&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>Download</h2>
<p>I seriously would like to know what do you think about this system as, again, I am planning to develop extensions for Yii that will embrace it in order to easy the tasks of PHP programmers with client Javascript. I do use this system to create a new system for a personal project and it is working quite good; but I won&#8217;t dare to create Yii extensions if you think that what I envision is wrong.</p>
<p>If the below link doesn&#8217;t work (it happens normally because you are not registered), please use the following link to download: <a href="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/upload/jquery.livebuttons.js">jquery.livebuttons.js</a>.</p>
<div style="padding: 10px; text-align: center; background-color: #ffffff; border: 3px solid #dddddd;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=16">JQuery Livebuttons Plugin</a> <small>(15.33KB)</small><br />
      <b>added:</b> 15/12/2010 <br />
      <b>clicks:</b> 171 <br />
    </td>
  </tr>
</table></div>
<p><center><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20jQuery%20Livebuttons%20Plugin%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F12%2F15%2Fjquery-livebuttons-plugin%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/12/15/jquery-livebuttons-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>jqPrettyPhoto Extension for Yii</title>
		<link>http://www.ramirezcobos.com/2010/10/21/jqprettyphoto-extension-for-yii/</link>
		<comments>http://www.ramirezcobos.com/2010/10/21/jqprettyphoto-extension-for-yii/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 16:37:52 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=563</guid>
		<description><![CDATA[I am currently developing a site for a real estate business and it is all built with Yii Framework -I am alone here so I need the best allies for this job   . During this development I come up with the creation of some cool extensions that I am, of couse, going to share with all of you.
Introducing  [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-562" href="http://www.ramirezcobos.com/2010/10/21/jqprettyphoto-extension-for-yii/captura-de-pantalla-2010-10-21-a-las-18-37-26/"><img class="alignright size-medium wp-image-562" title="PrettyPhoto" src="http://www.ramirezcobos.com/wp-content/uploads/2010/10/Captura-de-pantalla-2010-10-21-a-las-18.37.26-300x260.png" alt="" width="300" height="260" /></a>I am currently developing a site for a real estate business and it is all built with Yii Framework -I am alone here so I need the best allies for this job <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . During this development I come up with the creation of some cool extensions that I am, of couse, going to share with all of you.</p>
<h2>Introducing jqPrettyPhoto</h2>
<blockquote><p>This extension is making use of the grrrreat jQuery plugin called <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/" target="_blank">PrettyPhoto</a>. Here is its description in detail:</p>
<p>rettyPhoto is a jQuery lightbox clone. Not only does it support  images, it also support for videos, flash, YouTube, iframes. It’s a full  blown media lightbox.</p>
<p>It is very easy to setup, yet very flexible if you want to customize  it a bit. Plus the script is compatible in every major browser, even  IE6.</p>
<p>It also comes with useful APIs so prettyPhoto can be launched from nearly anywhere (yes, that includes Flash)!</p></blockquote>
<h2>How to Install</h2>
<p>Unzip the contents of the downloaded package below and copy its contents into your application&#8217;s <strong>protected/extensions</strong> folder.</p>
<p>How to Use</p>
<p>Once we have move the contents of the zipped file into the extensions folder we are ready to go. Use it at your own will into your views like this:</p>
<pre class="brush: php; title: ; notranslate">&lt;/p&gt;
Yii::import('ext.jqPrettyPhoto');
jqPrettyPhoto::addPretty('.gallery a',jqPrettyPhoto::PRETTY_GALLERY,jqPrettyPhoto::THEME_FACEBOOK);
</pre>
<p>Wow! That was easy! Please allow me to explain the addPretty function. It comes with three parameters:</p>
<p>1) <strong>element/s selector</strong>: the JQUERY SELECTOR to the links you want to set pretty photo to. In the example above I had the following on the view&#8217;s HTML:</p>
<pre class="brush: xml; title: ; notranslate">&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;gallery&quot;&gt;&lt;br /&gt;
 &lt;a href=&quot;URL_TO_IMAGE_TO_OPEN&quot;&gt;&lt;img src=&quot;URL_TO_IMAGE_TO_SHOW&quot;/&gt;&lt;/a&gt;&lt;br /&gt;
</pre>
<p>2) The second parameter is of the value jqPrettyPhoto::PRETTY_GALLERY or jqPrettyPhoto::PRETTY_SINGLE, which tells the extension whether the selector will be a list of a gallery images or just a single file.</p>
<p>3) The third one is what theme to use -please refer to jqPrettyPhoto.php&#8217;s code to see more options on this one.</p>
<h2>Download</h2>
<p>** If you have problems please use <a href="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/upload/jqPrettyPhoto.zip">this link</a>.</p>
<p style="text-align: center;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=13">jqPrettyPhoto Yii Extension</a> <small>(72.29KB)</small><br />
      <b>added:</b> 21/10/2010 <br />
      <b>clicks:</b> 1267 <br />
    </td>
  </tr>
</table></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20jqPrettyPhoto%20Extension%20for%20Yii%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F10%2F21%2Fjqprettyphoto-extension-for-yii%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/10/21/jqprettyphoto-extension-for-yii/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jqAutocomplete Extension for Yii</title>
		<link>http://www.ramirezcobos.com/2010/10/21/jqautocomplete-extension-for-yii/</link>
		<comments>http://www.ramirezcobos.com/2010/10/21/jqautocomplete-extension-for-yii/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 16:34:59 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=553</guid>
		<description><![CDATA[It was only a matter of time until I try to develop an extension for the Yii Framework and I have chosen the Ajax Powered Autocomplet plugin for JQuery to exercise with this technology.
How to use the Extension
I have included a test within the downloadable package that shows how to implement this  [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-358" href="http://www.ramirezcobos.com/2009/12/29/ajax-powered-autocomplete-plugin-for-jquery-js/autocomplete-3/"><img class="alignright size-full wp-image-358" title="autocomplete" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/autocomplete.gif" alt="" width="240" height="262" /></a>It was only a matter of time until I try to develop an extension for the<a href="http://www.yiiframework.com/forum/index.php?/topic/12499-extension-jqautocomplete/"> Yii Framework</a> and I have chosen the <a href="http://www.ramirezcobos.com/labs/autocomplete-for-jquery-js/">Ajax Powered Autocomplet plugin for JQuery </a>to exercise with this technology.</p>
<h2>How to use the Extension</h2>
<p>I have included a test within the downloadable package that shows how to implement this extension. The test includes a TestController, a view and a test_layout; so I hope this will easy the way for you to check it.</p>
<p>First download and unzip its contents</p>
<ul>
<li>Move jqAutocomplete contents (I said contents) into your application&#8217;s <strong>protected/extension</strong> folder</li>
<li>Copy TestController.php and paste it in (you guessed well) your application&#8217;s <strong>protected/controllers</strong> folder</li>
<li>Move <strong>test</strong> folder (not the contents but the whole folder this time) into your application&#8217;s <strong>protected/views</strong> folder</li>
<li>Finally test_layout.php into your application&#8217;s <strong>protected/layouts</strong> folder</li>
</ul>
<p>That&#8217;s it! Ready for the test. Go to your browser and type http://&lt;replace_with_your_application_url&gt;/index.php?r=test/autocomplete. If everything was good, you will be able to see the first field (JSON TEST) working as an autocomplete.</p>
<p>Please check TestController.php to see an example of AJAX response from the client autocomplete&#8217;s Request calls -and yes, you can also do it from a database result query. Look also at the test view&#8217;s code for an example on how to use the extension.</p>
<p>Download<br />
** If you have problems to download from below; please <a href="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/upload/jqAutcomplete.zip">try it here</a>.</p>
<p style="text-align: center;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=12">Ajax Powered AutoComplete Extension for Yii</a> <small>(126.83KB)</small><br />
      <b>added:</b> 20/10/2010 <br />
      <b>clicks:</b> 231 <br />
    </td>
  </tr>
</table></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20jqAutocomplete%20Extension%20for%20Yii%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F10%2F21%2Fjqautocomplete-extension-for-yii%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/10/21/jqautocomplete-extension-for-yii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PalmStudios Model Agency</title>
		<link>http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/</link>
		<comments>http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 14:03:03 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portfolio]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=489</guid>
		<description><![CDATA[Hi there,
I would like to introduce you my last web project: http://www.palmstudios.com
For this project I have developed a sort of MVC (Model View Controller) over the RedBeanPHP DB library (PHP 5.3.2).  This project even though it looks quite simple it has a very power CMS (Content Management  [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-490" href="http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-03-00/"><img class="alignright size-medium wp-image-490" title="Captura de pantalla 2010-07-12 a las 16.03.00" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.03.00-300x248.png" alt="" width="300" height="248" /></a>Hi there,</p>
<p>I would like to introduce you my last web project: <a title="Palmstudios Model Agency" href="http://www.palmstudios.com" target="_blank">http://www.palmstudios.com</a></p>
<p>For this project I have developed a sort of MVC (Model View Controller) over the <a title="RedBean PHP" href="http://www.redbeanphp.com" target="_blank">RedBeanPHP</a> DB library (PHP 5.3.2).  This project even though it looks quite simple it has a very power CMS (Content Management System) on its backend that allows the model agency to control most of the aspects of its business:</p>
<ol>
<li>- Clients Management</li>
<li>- Models Management (Men, Women, Children &amp; Extras) -contact details, measurements, pictures, and so on&#8230;</li>
<li>- Promotional Packages Management &#8211; this is a special addon which allows the agency to create model promotional bundles to send to its clients</li>
</ol>
<p>There is a ton of client and server libraries that this application makes use of, such as:</p>
<ul>
<li>JQuery FancyBox</li>
<li>JQuery Livequery</li>
<li>JQuery AjaxQ</li>
<li>PHPMailer</li>
<li>RedBeanPHP</li>
<li>Savant3 Template Engine</li>
<li>PHPThumb</li>
<li>TinyMCE</li>
</ul>
<p>The CMS has a configuration section where site administrator can configure:</p>
<ul>
<li>Web site languages (has multiple language support)</li>
<li>Web site translations (you can even ask GOOGLE about a translation depending of the languages installed on the system)</li>
<li>Model properties (size, height, waist, etc&#8230;)</li>
<li>Hair Colors</li>
<li>Eye Colors</li>
<li>Users</li>
</ul>
<p>Here is a snapshot gallery of the Site and its CMS</p>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-03-00/' title='Captura de pantalla 2010-07-12 a las 16.03.00'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.03.00-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.03.00" title="Captura de pantalla 2010-07-12 a las 16.03.00" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-07-44/' title='Captura de pantalla 2010-07-12 a las 16.07.44'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.07.44-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.07.44" title="Captura de pantalla 2010-07-12 a las 16.07.44" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-08-21/' title='Captura de pantalla 2010-07-12 a las 16.08.21'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.08.21-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.08.21" title="Captura de pantalla 2010-07-12 a las 16.08.21" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-09-01/' title='Captura de pantalla 2010-07-12 a las 16.09.01'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.09.01-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.09.01" title="Captura de pantalla 2010-07-12 a las 16.09.01" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-09-27/' title='Captura de pantalla 2010-07-12 a las 16.09.27'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.09.27-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.09.27" title="Captura de pantalla 2010-07-12 a las 16.09.27" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-03-31/' title='Captura de pantalla 2010-07-12 a las 16.03.31'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.03.31-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.03.31" title="Captura de pantalla 2010-07-12 a las 16.03.31" /></a>
<a href='http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/captura-de-pantalla-2010-07-12-a-las-16-03-53/' title='Captura de pantalla 2010-07-12 a las 16.03.53'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2010/07/Captura-de-pantalla-2010-07-12-a-las-16.03.53-120x120.png" class="attachment-thumbnail" alt="Captura de pantalla 2010-07-12 a las 16.03.53" title="Captura de pantalla 2010-07-12 a las 16.03.53" /></a>
<h2>I am open for Freelance Jobs</h2>
<p>If any of you would like to create a model agency application like this, let me know, I will be more than happy to collaborate with you on it. I will also sell the source code of its panel for any of you who is interested.</p>
<p><center><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20PalmStudios%20Model%20Agency%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F07%2F14%2Fpalmstudios-model-agency%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/07/14/palmstudios-model-agency/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Speed Up Your Pages With Lazy Load JQuery Plugin</title>
		<link>http://www.ramirezcobos.com/2010/06/15/speed-up-your-pages-with-lazy-load-jquery-plugin/</link>
		<comments>http://www.ramirezcobos.com/2010/06/15/speed-up-your-pages-with-lazy-load-jquery-plugin/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 15:06:54 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=476</guid>
		<description><![CDATA[I would like to introduce you this simple but very efficient plugin that will help us speed up the downloading time of our web pages. I am talking about mr Mika Tuupola&#8217;s Lazy Load JQuery Plugin.
This plugin loads the images of a web page as the user scrolls to their position, that is, images wont  [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-372" href="http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/picture-121-300x157/"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a>I would like to introduce you this simple but very efficient plugin that will help us speed up the downloading time of our web pages. I am talking about mr <a href="http://www.appelsiini.net/projects/lazyload/enabled_gazillion.html" target="_blank">Mika Tuupola&#8217;s Lazy Load JQuery Plugin</a>.</p>
<p>This plugin loads the images of a web page as the user scrolls to their position, that is, images wont load until they are not within the visible viewport margins of the window.</p>
<p><strong>How to use</strong></p>
<p>First we need to insert the following references into our code</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- insert a reference to jquery and the jquery.lazyload plugin --&gt;
&lt;script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;jquery.lazyload.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>And now this few lines of code in our document.ready function</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() {
          $(&quot;img&quot;).lazyload({
              placeholder : &quot;img/grey.gif&quot;,
              effect      : &quot;fadeIn&quot;
           });
       });
&lt; /script&gt;
</pre>
<p>And that&#8217;s it! Easy right? </p>
<a href="http://twitter.com/?status=RT%20%40%3A%20Speed%20Up%20Your%20Pages%20With%20Lazy%20Load%20JQuery%20Plugin%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F06%2F15%2Fspeed-up-your-pages-with-lazy-load-jquery-plugin%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/06/15/speed-up-your-pages-with-lazy-load-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Torrenova Rentacar</title>
		<link>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/</link>
		<comments>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 09:32:14 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=408</guid>
		<description><![CDATA[
I would like to show you one of the reasons of why I have been so busy lately: torrenovarentacar.com.
One of the most complete sites in terms of rentacar systems. Fully synchronized with one of the most used rent a car management programs in Spain, CarPlus (www.cargestion.es) and with a highly  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/Imagen-5.png"></a><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Imagen-5-300x274.png"></a><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/Imagen-5-300x274.png"></a><strong><span style="font-weight: normal;"> </span></strong></p>
<div id="attachment_410" class="wp-caption alignright" style="width: 310px"><a rel="attachment wp-att-410" href="http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/picture-1-5/"><img class="size-medium wp-image-410" title="Torrenova Rentacar" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-11-300x165.png" alt="Torrenova Rentacar" width="300" height="165" /></a><p class="wp-caption-text">Torrenova Rentacar</p></div>
<p><em>I would like to show you one of the reasons of why I have been so busy lately: <a href="http://www.torrenovarentacar.com" target="_blank">torrenovarentacar.com</a>. </em></p>
<p>One of the most complete sites in terms of rentacar systems. Fully synchronized with one of the most used rent a car management programs in Spain, CarPlus (www.cargestion.es) and with a highly powerful control panel where the rent a car owner controls absolutely everything. Its web panel features:</p>
<ul>
<li>Company details</li>
<li>Contacts</li>
<li>Offices and their Google locations</li>
<li>CarPlus Settings and Sync</li>
<li>Users</li>
<li>Extras</li>
<li>Cars</li>
<li>Car Groups</li>
<li>Car Models</li>
<li>Translations (It can set new languages at will)</li>
</ul>
<p>If you have time, please check it out as I would love to get some feedback about it.<br />
Thanks!</p>
<a href="http://twitter.com/?status=RT%20%40%3A%20Torrenova%20Rentacar%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F03%2F31%2Ftorrenova-rentacar%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 -Are you ready?</title>
		<link>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/</link>
		<comments>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:17:48 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[News]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=241</guid>
		<description><![CDATA[jQuery lovers, today, 14th of January, the programmers of jQuery celebrate its anniversary releasing a new version of this wonderful library. Better iFrame support, great new shorthands, I don&#8217;t know what to say fellows but I am eager to find out what its new features are capable of.
The jQuery  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>jQuery lovers, today, 14th of January, the programmers of jQuery celebrate its anniversary releasing a new version of this wonderful library. Better iFrame support, great new shorthands, I don&#8217;t know what to say fellows but I am eager to find out what its new features are capable of.</p>
<p>The jQuery programmers not happy with a new release has also created a new  <a href="http://api.jquery.com/" target="_blank">jQuery API site</a>. Check what they have done on their API site <a href="http://jquery14.com/pre-release-1/new-jquery-api-site" target="_blank">here</a>.</p>
<p>John Resig will announce 1.4 release details tomorrow but meanwhile, you can download it and see for yourself.</p>
<ul>
<li><a rel="nofollow" href="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js">Download jQuery 1.4 from Google CDN</a></li>
<li><a rel="nofollow" href="http://code.jquery.com/jquery-1.4.js">Download jQuery 1.4 from Official jQuery website</a></li>
</ul>
<p>Also, if you want to learn more about what is new in jQuery 1.4 then you might find the following resources useful:</p>
<ol>
<li><a rel="nofollow" href="http://jquery14.com/">14 Days of jQuery</a></li>
<li><a rel="nofollow" href="http://blog.jquery.com/">Official jQuery Blog</a></li>
<li><a rel="nofollow" href="http://futurecolors.ru/jquery/">jQuery 1.4 Cheatsheet</a></li>
<li><a rel="nofollow" href="http://twitter.com/jquery">jQuery on Tweeter</a></li>
</ol>
<p>Check what is new or changed on this new release <a href="http://api.jquery.com/category/version/1.4/" target="_blank">here</a>.</p>
<p>Happy birthday jQuery! Thanks for the good work!<br />
</p>
<a href="http://twitter.com/?status=RT%20%40%3A%20jQuery%201.4%20-Are%20you%20ready%3F%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F01%2F14%2Fjquery-1-4-are-you-ready%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookie jQuery Plugin</title>
		<link>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/</link>
		<comments>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 12:18:29 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Plugin]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=148</guid>
		<description><![CDATA[As published on my last post, JSON gives us the great possibility to save objects on Cookies. I have already created a JSON Plugin for jQuery, then, why not create one Cookie Plugin that, in conjunction with the JSON plugin, allows us to save objects on cookies? Well, the challenge was simple and I  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>As published <a href="http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/">on my last post</a>, JSON gives us the great possibility to save objects on Cookies. I have already created a JSON Plugin for jQuery, then, why not create one Cookie Plugin that, in conjunction with the JSON plugin, allows us to save objects on cookies? Well, the challenge was simple and I decided to do it for those using jQuery.</p>
<h3>The code</h3>
<p>Remember than this plugin works in conjunction with my <a href="http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/">JSON jQuery Plugin</a>, also on this blog.</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.cookie = {
set : function(name,value,options){
options = $.extend({}, options);
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires &amp;&amp; (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
value = options.json ? encodeURIComponent($.JSON.encode(value)):encodeURIComponent(value);
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', value, expires, path, domain, secure].join('');
},
get : function(name,json){
var cookieValue = null;
if (document.cookie &amp;&amp; document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i &lt; cookies.length; i++) {
var cookie = $.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = json ? $.JSON.decode(decodeURIComponent(cookie.substring(name.length + 1))):decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
},
unset: function(name){
this.set(name,'',-1);
}
};
</pre>
<h3>How to use</h3>
<p>Note that you have to insert the jquery library on your head section and also the <a href="../2009/12/30/json-jquery-plugin/">JSON jQuery Plugin</a> -they are all included into the zip file below. Please, also refer to <a href="http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/">the example provided on my last article &#8216;cookies on roids&#8217; </a>to view more cookie options.</p>
<pre class="brush: jscript; title: ; notranslate">
var obj = {json:'this is a test json property',xml:'this is a test xml property'};
var arr = ['A','B of 2 index array','C','D'];
var str = 'This is a string test';
var num = 123;
$.cookie.set('testobject',obj,{json:true});
$.cookie.set('testarray',arr,{json:true});
$.cookie.set('teststring',str);
$.cookie.set('testnumber',num);
var a = $.cookie.get('testobject',true);
var b = $.cookie.get('testarray',true);
var c = $.cookie.get('teststring');
var d = $.cookie.get('testnumber');
$.cookie.unset('testobject');
$.cookie.unset('testarray');
$.cookie.unset('teststring');
$.cookie.unset('testnumber');
alert('object:'+a.xml);
alert('array:'+b[1]);
alert('string:'+c);
alert('number:'+d);
</pre>
<p><strong>DOWNLOAD</strong><br />
The zip file includes the JSON jQuery Plugin and Cookie jQuery Plugin together with an example page on how to use them.</p>
<div style="padding: 10px; text-align: center; background-color: #ffffff; border: 3px solid #dddddd;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=6">jQuery Cookie Plugin</a> <small>(23.84KB)</small><br />
      <b>added:</b> 02/01/2010 <br />
      <b>clicks:</b> 1695 <br />
    </td>
  </tr>
</table></div>
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<a href="http://twitter.com/?status=RT%20%40%3A%20Cookie%20jQuery%20Plugin%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2010%2F01%2F02%2Fcookie-jquery-plugin%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JSON jQuery Plugin</title>
		<link>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/</link>
		<comments>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:53:42 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=139</guid>
		<description><![CDATA[I finally got a bit of time and I started playing around with the creation of jQuery plugins and did created a couple of them that I believe all of you will find useful, one of them is a JSON plugin.
As you all know jQuery do not have a JSON encode function. I truly do not know the reason why but  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>I finally got a bit of time and I started playing around with the creation of jQuery plugins and did created a couple of them that I believe all of you will find useful, one of them is a JSON plugin.</p>
<p>As you all know jQuery do not have a JSON encode function. I truly do not know the reason why but to implement it was quite easy -maybe the guys from jQuery thought that it wasn&#8217;t really necessary and I agree with them. Most of us use JSON on the server side through PHP or whatever the server tech we use but sometimes, and I repeat, sometimes, we require to develop client applications that by using JSON (thanks David Crockford) we can reduce our server resources and the amount of data transmitted between client and server. But this is a subject that I will treat in the next posts.</p>
<p>Here is the plugin code:</p>
<pre class="brush: jscript; title: ; notranslate">
jQuery.JSON = {
useHasOwn : ({}.hasOwnProperty ? true : false),
pad : function(n) {
return n &lt; 10 ? "0" + n : n;
},
m : {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"' : '\\"',
"\\": '\\\\'
},
encodeString : function(s){
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if(c){
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
},
encodeArray : function(o){
var a = ["["], b, i, l = o.length, v;
for (i = 0; i &lt; l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : this.encode(v));
b = true;
}
}
a.push("]");
return a.join("");
},
encodeDate : function(o){
return '"' + o.getFullYear() + "-" +
pad(o.getMonth() + 1) + "-" +
pad(o.getDate()) + "T" +
pad(o.getHours()) + ":" +
pad(o.getMinutes()) + ":" +
pad(o.getSeconds()) + '"';
},
encode : function(o){
if(typeof o == "undefined" || o === null){
return "null";
}else if(o instanceof Array){
return this.encodeArray(o);
}else if(o instanceof Date){
return this.encodeDate(o);
}else if(typeof o == "string"){
return this.encodeString(o);
}else if(typeof o == "number"){
return isFinite(o) ? String(o) : "null";
}else if(typeof o == "boolean"){
return String(o);
}else {
var self = this;
var a = ["{"], b, i, v;
for (i in o) {
if(!this.useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');
}
a.push(self.encode(i), ":",
v === null ? "null" : self.encode(v));
b = true;
}
}
}
a.push("}");
return a.join("");
}
},
decode : function(json){
return eval("(" + json + ')');
}
};
</pre>
<p>How to use</p>
<p>Copy and paste the above code onto a file and name it whatever you like, for the sake of the example we will call it<strong> jquery.json.js</strong>. And then configure your head section like this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- jquery library (if you dont have it, then download it <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  --&gt;
&lt;script language="javascript" src="jquery.1.3.2.js" &gt;&lt;/script&gt;
&lt;!-- our plugin file --&gt;
&lt;script language="javascript" src="jquery.json.js"&gt;&lt;/script&gt;
</pre>
<p>That&#8217;s it, now we can call our plugin like this:</p>
<pre class="brush: jscript; title: ; notranslate">
// test variables
var obj = {json:'this is a test json property',xml:'this is a test xml property'};
var arr = ['A','B of 2 index array','C','D'];
// encoding an object
var a = $.JSON.encode(obj);
alert('json encoded object:'+a);
// decoding an object
var b = $.JSON.decode(a);
alert('json decoded object property:'+b.json);
// encoding an array
a = $.JSON.encode(arr);
alert('json encoded array:'+a);
// decoding the array
b = $.JSON.decode(a);
alert('json decoded array:'+b[1]);
</pre>
<p>On future posts we will make use of this plugin to show what we can do with it.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20JSON%20jQuery%20Plugin%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2009%2F12%2F30%2Fjson-jquery-plugin%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Ajax Powered Autocomplete Plugin for JQuery.js</title>
		<link>http://www.ramirezcobos.com/2009/12/29/ajax-powered-autocomplete-plugin-for-jquery-js/</link>
		<comments>http://www.ramirezcobos.com/2009/12/29/ajax-powered-autocomplete-plugin-for-jquery-js/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 10:44:23 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Autocomplete]]></category>
		<category><![CDATA[Plugin]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=134</guid>
		<description><![CDATA[I am glad to announce the launch of the successfull Ajax Powered Autocomplete for Prototype.js now as a plugin for JQuery. No much to say&#8230; if any of you want to have a look at this piece of code you can check it here.
Any feedback is highly appreciated.
Tweet this!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/autocomplete1.gif"><img class="alignright size-full wp-image-46" style="border: 3px solid #ddd; margin: 5px;" title="autocomplete" src="http://www.ramirezcobos.com/wp-content/uploads/2009/12/autocomplete1.gif" alt="" width="240" height="262" /></a>I am glad to announce the launch of the successfull Ajax Powered Autocomplete for Prototype.js now as a plugin for JQuery. No much to say&#8230; if any of you want to have a look at this piece of code <a href="http://www.ramirezcobos.com/labs/autocomplete-for-jquery-js/">you can check it here</a>.</p>
<p>Any feedback is highly appreciated.</p>
<p><center><br />
<br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20Ajax%20Powered%20Autocomplete%20Plugin%20for%20JQuery.js%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2009%2F12%2F29%2Fajax-powered-autocomplete-plugin-for-jquery-js%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2009/12/29/ajax-powered-autocomplete-plugin-for-jquery-js/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.ramirezcobos.com @ 2012-02-06 18:29:19 by W3 Total Cache -->
