<?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>AjaxMasters Blog &#187; javascript</title> <atom:link href="http://blog.ajaxmasters.com/tag/javascript/feed/" rel="self" type="application/rss+xml" /><link>http://blog.ajaxmasters.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Thu, 24 Jun 2010 11:55:25 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Awesome CSS+JS form styling</title><link>http://blog.ajaxmasters.com/awesome-cssjs-form-styling/</link> <comments>http://blog.ajaxmasters.com/awesome-cssjs-form-styling/#comments</comments> <pubDate>Tue, 09 Mar 2010 17:23:39 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[css]]></category> <category><![CDATA[form]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[js]]></category> <category><![CDATA[sexy]]></category> <category><![CDATA[styling]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=309</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/awesome-cssjs-form-styling/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2010/03/sexy-form-170x170.png" class="alignleft tfe wp-post-image" alt="Sexy CSS+JS Form" title="sexy-form" /></a>I was working on our new open source project that i think you will like and I was working on the registration page. This is what I got in the end and i will walk you trough the process with me. This new tutorial is about styling the forms of your website, I find it very good looking and very simple to implement. We will use simple CSS and some [...]]]></description> <content:encoded><![CDATA[<div
id="attachment_312" class="wp-caption alignleft" style="width: 310px"><a
href="http://blog.ajaxmasters.com/awesome-cssjs-form-styling/sexy-form/" rel="attachment wp-att-312"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2010/03/sexy-form-300x214.png" alt="Sexy CSS Form" title="sexy-form" width="300" height="214" class="size-medium wp-image-312" /></a><p
class="wp-caption-text">Sexy CSS+JS Form</p></div><p>I was working on our new open source project that i think you will like and I was working on the registration page. This is what I got in the end and i will walk you trough the process with me. This new tutorial is about styling the forms of your website, I find it very good looking and very simple to implement. We will use simple CSS and some JavaScript.</p><p>Usually for inserting text into the inputs or our forms we set the value attribute with the text and then use javascript to check for different scenarios for doing some fancy things. This is different we will use labels to fill the text and move them under the inputs and then just do our magic with JS.</p><p>The JavaScript library that we will use to create this effect for our forms is <a
href="http://jquery.com" target="_blank">Jquery</a></p><p><br/><br
/> <strong
class="in_title">1. Creating the markup!</strong><br
/> <br/></p><pre class="brush: xml;">
            &lt;div id=&quot;login&quot;&gt;
                &lt;div class=&quot;sayit&quot;&gt;Log In:&lt;/div&gt;
                &lt;form action=&quot;javascript:void(0)&quot; onsubmit=&quot;login()&quot; autocomplete=&quot;off&quot;&gt;
                    &lt;label for=&quot;username&quot;&gt;Username&lt;/label&gt;
                    &lt;input type=&quot;text&quot; id=&quot;username&quot;/&gt;
                    &lt;label for=&quot;password&quot;&gt;Password&lt;/label&gt;
                    &lt;input type=&quot;password&quot; id=&quot;password&quot;/&gt;
                    &lt;input type=&quot;submit&quot; class=&quot;medium button green&quot; value=&quot;Log me In&quot;/&gt;
                &lt;/form&gt;
            &lt;/div&gt;
</pre><p>The above code is our markup and as you can see is very simple and it can be changed as you like because the code that we will use for checking for different scenarios in javascript will work without necessary classes or ids. We have 2 inputs and 2 labels, one is password one is text and we can work with these ones, you can add as many as you like.</p><p>Now let&#8217;s style these bastards! <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile-big.png' alt=':D' class='wp-smiley' /></p><p><strong
class="in_title">2. Use CSS to style the form elements!</strong><br
/> <br/></p><pre class="brush: css;">
input[type=text],input[type=password]{padding: 5px 10px; background-color: transparent;	position: relative; z-index: 2;}
label{position: absolute; z-index: 1;-webkit-transition: opacity 0.15s linear; color: #bababa; background-color: #FFFFFF; }

#login{width: 290px; margin: 0 auto;}
#login input[type=text],#login input[type=password]{width:270px; margin: 5px 0; font-size: 24px; font-weight: bold; border: 1px solid #ccc; -moz-border-radius:5px; -webkit-border-radius:5px; color: #595959;}
#login label{font-size: 24px; margin: 14px 10px;}

#login .sayit{font-size:24px; color: #595959; font-style: italic; padding-bottom: 5px;}
</pre><p>What we did here is make the label absolute so it will go under the input. This is important you will have to place the label before the input so remember this! The input will have a position relative and a z-index of 2 so we can be sure it will land above the label. Next we define the login div by using his id(<i>#login</i>). We use CSS3 for creating the round borders for the input and style the label by setting a big font-size to fit the input. The rest is pretty obvious, if you have trouble understanding this then let us know in the comments.</p><p><strong
class="in_title">3. Make everything move with JS!</strong><br
/> <br/></p><pre class="brush: jscript;">
$(document).ready(function(){
    $.string(String.prototype);
    $(&quot;input,textarea&quot;).each(function (type) {
        $(this).focus(function () {
            if($(this).val().blank())
                $(this).prev(&quot;label&quot;).fadeTo('fast',0.45);
        });

        $(this).keypress(function () {
            $(this).prev(&quot;label&quot;).fadeTo('fast',0);
        });

        $(this).blur(function () {
            if($(this).val().blank()){
                $(this).prev(&quot;label&quot;).fadeTo('fast',1);
            }
        });
    });
});
</pre><p>We use here jQuery of course that we add using the google api like this:</p><pre class="brush: xml;">
        &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&gt;&lt;/script&gt;
</pre><p>And one plugin that I use to extend the jQuery string properties and that is <a
href="http://stilldesigning.com/dotstring/">$.string plugin</a>. After we do that we create the above code and we assign to input and textarea elements a focus, keypress and blur actions. We use the focus action to lower the labels opacity to 45% then on keypress we just hide it for good. Then on blur we check to see if anything was written in our sexy element and if not then we fade the label back to 100%. This is kind of everything we do here, pretty simple. <img
src='http://blog.ajaxmasters.com/wp-content/plugins/smilies-themer/pidgin/smile.png' alt=':)' class='wp-smiley' /></p><p><strong
class="in_title">4. Showing of a demo and download source</strong><br
/> <br/></p><p>I&#8217;ve set up a demo here: <a
href="http://tutorials.ajaxmasters.com/sexy-form/" target="_blank"><b><i>DEMO</i></b></a></p><p>The source code you can either pick it from the demo page or from here: <a
href="http://tutorials.ajaxmasters.com/sexy-form/source.zip"><b><i>SOURCE</i></b></a></p><p><strong
class="in_title">5. Wrapping up!</strong><br
/> <br/></p><p>So here is our nice form styling that you can use on your website and that can be done very easily. Feel free to leave us comments and suggestions. <b>Thanks a lot!</b></p><p>Have fun coding!</p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/awesome-cssjs-form-styling/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Use ajax to create a cacheing system</title><link>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/</link> <comments>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/#comments</comments> <pubDate>Tue, 29 Sep 2009 10:49:52 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[cache]]></category> <category><![CDATA[html]]></category> <category><![CDATA[imageroll]]></category> <category><![CDATA[images]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[php]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[system]]></category> <category><![CDATA[vi.sualize.us]]></category> <category><![CDATA[wordpress]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=163</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache-170x170.png" class="alignleft wp-post-image tfe" alt="Cache Pic" title="cache" /></a><p>As I said in my last post, I wanted from the first time to make a cacheing system for my imageroll page. Because i take the images from vi.sualize.us servers and we don't want to make to much trafic and make stuff worse for them.</p><p>So what i did is simple, i made a class that extracts the rss data from theirs servers and get the images to display them. I do this every time someone visits the page.</p>]]></description> <content:encoded><![CDATA[<p><div
id="attachment_164" class="wp-caption alignleft" style="width: 287px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/cache.png" alt="Cache Pic" title="cache" width="277" height="277" class="size-full wp-image-164" /></a><p
class="wp-caption-text">Cache Pic</p></div><p>As I said in my last post, I wanted from the first time to make a cacheing system for my imageroll page. Because i take the images from vi.sualize.us servers and we don&#8217;t want to make to much trafic and make stuff worse for them.</p><p>So what i did is simple, i made a class that extracts the rss data from theirs servers and get the images to display them. I do this every time someone visits the page. If any image is new for the first time we display the image from vi.sualize.us and run a functions in javascript to check for new images. If any new images exist then we cache them in a folder on our server and the next time a user visits the page that image will be shown from our server. Pretty simple.</p><p>For now i&#8217;ll just show you the stuff that makes this thing run and if you want i can share the whole script so that you can make one for your blog or website.</p><p>I&#8217;ll also try to make a WordPress plugin so you can integrate it easily in your blog.</p><p>So here we go. We start with the function that checks for new images:</p><pre class="brush: php;">
functio checkCache($image_url){
            $path=pathinfo($image_url);
            $img_cached = 'cache/'.$path['filename'].'.'.$path['extension'];
            if(!file_exists($img_cached)) {
                createCacheImg($image_url);
            }
}
</pre><p>This function just checks if the image exists in the &#8220;<b>cache</b>&#8221; folder. If it&#8217;s not there then we run the &#8220;<b>createCacheImg</b>&#8221; function.</p><p>We now need a function to get the image so we check if the image is in the cache folder or not so we know what to display.</p><pre class="brush: php;">
    function getImage($or_img) {
        $path=pathinfo($or_img);
        $filename=$path['filename'];
        $img_cached = 'cache/'.$filename.'.'.$path['extension'];
        if(file_exists($img_cached)) {
            $url=$img_cached;
        }else {
            $url=$or_img;
        }

        return $url;
    }
</pre><p>Very simple function that just returns the right url of the image.</p><p>Now we cache the image.</p><pre class="brush: php;">
function createCacheImg($image){
        $srcsize = getimagesize($image);
        $w = $srcsize[0];
        $h = $srcsize[1];

        $path=pathinfo($image);
        $dest='cache/'.$path['filename'].'.'.$path['extension'];
        if($path['extension']=='jpg' || $path['extension']=='jpeg' || $path['extension']=='JPG') {
            $src_img = imagecreatefromjpeg($image);
        }else if($path['extension']=='gif') {
                $src_img = imagecreatefromgif($image);
            }else if($path['extension']=='png') {
                    $src_img = imagecreatefrompng($image);
                }
        $img_cpy=imagecreatetruecolor($w,$h);
        imagecopy($img_cpy, $src_img, 0, 0, 0, 0, $w, $h);
        if($path['extension']=='jpg' || $path['extension']=='jpeg' || $path['extension']=='JPG') {
            imagejpeg($img_cpy,$dest);
        }else if($path['extension']=='gif') {
                imagegif($img_cpy,$dest);
            }else if($path['extension']=='png') {
                    imagepng($img_cpy,$dest);
                }
        imagedestroy($src_img);
}
</pre><p>This function will save the image into the cache folder. Now we need a new file &#8220;<b>checkcache.php</b>&#8221; where we put this code:</p><pre class="brush: php;">
include('functions.php');
$image=$_GET['image'];
checkCache($image);
</pre><p> Right now we should have this kind of structure in our imageroll folder: A folder &#8220;<b>cache</b>&#8221; a file &#8220;<b>functions.php</b>&#8221; where we place all these functions we just did and a file &#8220;<b>index.php</b>&#8221; where we run the javascript function and display the images.</p><p>The &#8220;<b>index.php</b>&#8221; file requires this code:</p><pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;

        &lt;title&gt;
            Image ROLL
        &lt;/title&gt;

        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
        &lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;  google.load(&quot;jquery&quot;, &quot;1.3.2&quot;); &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
&lt;input type=&quot;hidden&quot; id=&quot;image&quot; value=&quot;http://test.com/image.jpg&quot;&gt;
&lt;img src=&quot;&lt;?=getImage($image)?&gt;&quot; alt=&quot;test image&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>We have here a simple index.php file that imports the google api and jquery so we can run a simple ajax function. This is the javascript code that you should insert in this file or a separate one if you want:</p><pre class="brush: jscript;">

            $(document).ready(function() {
                checkCache();
            });

            function checkCache(){
                var page=$('#image');
                var url='checkcache.php';
                var pars='page='+page.val();
                $.get(url,pars);
            }
</pre><p>This will run this function after the page loads and it will check for new images. So this is just a simple script that will make you pages load faster expecialy if you load the images from outside of your server.</p><p>If you liked this i&#8217;ll go and make a more complex one and even share the imageroll script i did. That until i find the time and make a Wordpress Plugin.</p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/use-ajax-to-create-a-cacheing-system/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>jQuery Pagination Plugin</title><link>http://blog.ajaxmasters.com/jquery-pagination-plugin/</link> <comments>http://blog.ajaxmasters.com/jquery-pagination-plugin/#comments</comments> <pubDate>Tue, 22 Sep 2009 22:15:03 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[pagination]]></category> <category><![CDATA[plugin]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=26</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/jquery-pagination-plugin/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/jquery-pag-pic-170x170.png" class="alignleft wp-post-image tfe" alt="jQuery pagination" title="jquery-pag-pic" /></a>Description
When you have a a large list of items (e.g. search results or news articles), you can display them grouped in pages and present navigational elements to move from one page to another. This plugin creates these navigational elements.
Usage
Include the pagination plugin script and the pagination.css file in your HTML page. In your HTML body create a container tag pair that will hold the link elements. Give it an id [...]]]></description> <content:encoded><![CDATA[<div
id="attachment_27" class="wp-caption aligncenter" style="width: 510px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/jquery-pag-pic.png"><img
class="size-full wp-image-27" title="jquery-pag-pic" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/jquery-pag-pic.png" alt="jQuery pagination" width="500" height="300" /></a><p
class="wp-caption-text">jQuery pagination</p></div><p><strong>Description</strong></p><p>When you have a a large list of items (e.g. search results or news articles), you can display them grouped in pages and present navigational elements to move from one page to another. This plugin creates these navigational elements.</p><p><strong>Usage</strong></p><p>Include the pagination plugin script and the pagination.css file in your HTML page. In your HTML body create a container tag pair that will hold the link elements. Give it an id attribute (e.g. &#8220;News-Pagination&#8221;)</p><p>After you have loaded the contents and know how many items you want to display overall, create the pagination like this:</p><pre class="brush: jscript;">
	// First Parameter: number of items
	// Second Parameter: options object
	$(&quot;#News-Pagination&quot;).pagination(122, {
		items_per_page:20,
		callback:loadContents
	});
</pre><p>This will create the navigation links inside the container. You will see the numbers 1-7, the first number is highlighted. When you click on another number, the highlighting changes and your callback function &#8220;loadContents&#8221; is called.</p><p>The plugin is highly configurable through the option parameter and all elements can be styled separately.</p><p>You can check out a demo <a
href="http://tutorials.ajaxmasters.com/pagination-demo/">here</a>.<br
/> And download the source code <a
href="http://tutorials.ajaxmasters.com/pagination-demo/source.zip">here</a>.</p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/jquery-pagination-plugin/feed/</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>PNG rollover function for IE 6 using JavaScript</title><link>http://blog.ajaxmasters.com/png-rollover-function-for-ie-6-using-javascript/</link> <comments>http://blog.ajaxmasters.com/png-rollover-function-for-ie-6-using-javascript/#comments</comments> <pubDate>Tue, 22 Sep 2009 21:38:35 +0000</pubDate> <dc:creator>Chocksy</dc:creator> <category><![CDATA[Tutorial]]></category> <category><![CDATA[fix]]></category> <category><![CDATA[ie6]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[png]]></category> <category><![CDATA[transparency]]></category><guid
isPermaLink="false">http://blog.ajaxmasters.com/?p=19</guid> <description><![CDATA[<a
href="http://blog.ajaxmasters.com/png-rollover-function-for-ie-6-using-javascript/"><img
align="left" hspace="5" width="150" height="150" src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/PNG-fixie6-170x170.png" class="alignleft wp-post-image tfe" alt="PNG Fix for IE6" title="PNG-fixie6" /></a>Last night i was working on a site that uses a lot of transparent .png&#8217;s . As we all know, our dear MS IE 6 doesn&#8217;t know how to handle the transparency of PNG files.
For quite a while, i was using a Javascript png fix called SUPERSLEIGHT and i was very happy about how it worked.
But last night i came into a problem. I needed to make some rollover images [...]]]></description> <content:encoded><![CDATA[<p><div
id="attachment_23" class="wp-caption alignleft" style="width: 310px"><a
href="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/PNG-fixie6.png"><img
src="http://blog.ajaxmasters.com/wp-content/uploads/2009/09/PNG-fixie6.png" alt="PNG Fix for IE6" title="PNG-fixie6" width="300" height="300" class="size-full wp-image-23" /></a><p
class="wp-caption-text">PNG Fix for IE6</p></div>Last night i was working on a site that uses a lot of transparent .png&#8217;s . As we all know, our dear MS IE 6 doesn&#8217;t know how to handle the transparency of PNG files.</p><p>For quite a while, i was using a Javascript png fix called <a
href="http://snipplr.com/view/4224/ie-6-transparent-png-fix--supersleight/">SUPERSLEIGHT</a> and i was very happy about how it worked.</p><p>But last night i came into a problem. I needed to make some rollover images which were transparent PNG&#8217;s, and when the images change, the transparency fix will break. So i started looking for a solution and i came over <a
href="http://homepage.ntlworld.com/bobosola/png_mouseover.htm">this</a> function, which works perfect. The only thing was that this won`t work togheter with the original SUPERSLEIGHT script and it only fixes the png`s in IMG tags, and i had a lot of PNG images as backgrounds, inputs, etc.</p><p>So i changed the supersleight script to ignore PNG`s in IMG tags, and i merged it with the other script.</p><p><strong
class="in_title">How it works :</strong></p><p>- Link the &#8217;supersleight-swap.js&#8217; file into your document inside conditional comments so that it is delivered to only Internet Explorer 6 or older.</p><pre class="brush: xml;">
&lt;!--[if lte IE 6]&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;path/to/supersleight-swap.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
</pre><p>- Copy &#8216;x.gif&#8217; in the same directory as the page you&#8217;re using PNG&#8217;s on.</p><p>- Put in the function that swaps the images (for NORMAL browsers) :</p><pre class="brush: jscript;">
function imgSwap(oImg)
{
   var strOver  = &quot;_on&quot;    // image to be used with mouse over
   var strOff = &quot;_off&quot;     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1)
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}
</pre><p>- Call the function in the &#8216;onmouseover&#8217; and &#8216;onmouseout&#8217; event of the IMG.</p><pre class="brush: xml;">
&lt;img alt=&quot;a png image&quot; src=&quot;path/to/image_off.png&quot; onmouseover=&quot;imgSwap(this)&quot; onmouseout=&quot;imgSwap(this)&quot; id=&quot;img1&quot;&gt;
</pre><p>Note that each PNG must have an ID attribute for this to work.</p> ]]></content:encoded> <wfw:commentRss>http://blog.ajaxmasters.com/png-rollover-function-for-ie-6-using-javascript/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 10/33 queries in 0.023 seconds using disk

Served from: blog.ajaxmasters.com @ 2010-07-31 13:33:59 -->