<?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>All About Web &#38; Mobile Application Development &#187; jquery</title>
	<atom:link href="http://www.londatiga.net/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.londatiga.net</link>
	<description>All About Web &#38; Mobile Application Development</description>
	<lastBuildDate>Sat, 14 Jan 2012 16:56:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How to Overlay Video Using JQuery Tools and Flowplayer</title>
		<link>http://www.londatiga.net/featured-articles/how-to-overlay-video-using-jquery-tools-and-flowplayer/</link>
		<comments>http://www.londatiga.net/featured-articles/how-to-overlay-video-using-jquery-tools-and-flowplayer/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 10:07:57 +0000</pubDate>
		<dc:creator>lorenz</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[flash video]]></category>
		<category><![CDATA[flash video player]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[overlay video]]></category>
		<category><![CDATA[overlay video flowplayer]]></category>
		<category><![CDATA[overlay video javascript]]></category>
		<category><![CDATA[overlay video jquery]]></category>
		<category><![CDATA[web video player]]></category>

		<guid isPermaLink="false">http://www.londatiga.net/?p=500</guid>
		<description><![CDATA[In my previous tutorial, i&#8217;ve explained the basic usage of Flowplayer as your web video player. In this tutorial, i&#8217;ll will show you a little bit advanced usage of Flowplayer combined with Jquery Tools. JqueryTools is used to overlay video with a simple apple effect. This feature is usefull when making a video gallery, where [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a title="How to Use Flowplayer as Your Video Player (Beginner's Guide)" href="http://www.londatiga.net/it/how-to-use-flowplayer-as-your-web-video-player-beginners-guide/" target="_blank">previous tutorial</a>, i&#8217;ve explained the basic usage of <a title="Flowplayer" href="http://www.flowplayer.org" target="_blank">Flowplayer</a> as your web video player. In this tutorial, i&#8217;ll will show you a little bit advanced usage of Flowplayer combined with <a title="Jquery Tools" href="http://flowplayer.org/tools/index.html" target="_blank">Jquery Tools</a>. JqueryTools is used to overlay video with a simple<em> apple</em> effect. This feature is usefull when making a video gallery, where users directly play a video in larger size in an overlay mode without having to move to a new page.</p>
<div class="wp-caption alignnone" style="width: 408px"><img title="Overlay Video" src="http://londatiga.net/images/flowplayer2/flowplayer_overlay.jpg" alt="Overlay Video" width="398" height="314" /><p class="wp-caption-text">Overlay Video</p></div>
<p><strong><span style="text-decoration: underline;">How to Setup</span></strong></p>
<p><strong>Flowplayer</strong></p>
<p>Follow the instructions in <a title="How to Use Flowplayer as Your Video Player (Beginner's Guide)" href="http://www.londatiga.net/it/how-to-use-flowplayer-as-your-web-video-player-beginners-guide/" target="_blank">my previous tutorial</a> to setup Flowplayer</p>
<p><strong>JQuery Tools</strong></p>
<ul>
<li>Download Overlay component from Jquery Tools <a title="Download JQuery Tools" href="http://flowplayer.org/tools/index.html" target="_blank">download&#8217;s page</a> and save it as <span style="color: #800000;">jquery.tools.min.js</span>. You can download it with<span style="color: #800000;"> jQuery</span> (v1.3.2) as a single file (20.82 kb) or as a separated file (1.59 kb) if you already have jQuery.</li>
<div class="wp-caption alignnone" style="width: 460px"><img class=" " title="Download Overlay Component" src="http://londatiga.net/images/flowplayer2/download_overlay.jpg" alt="Download Overlay Component" width="450" height="278" /><p class="wp-caption-text">Download Overlay Component</p></div>
<li>Include the<span style="color: #800000;"> jquery.tools.min.j</span><span style="color: #800000;">s</span> with in the HEAD section of your HTML</li>
<pre class="brush: xml; title: ;">
&lt;script src=&quot;scripts/jquery.tools.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/flowplayer-3.1.4.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>or</p>
<pre class="brush: xml; title: ;">
&lt;script src=&quot;scripts/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/jquery.tools.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/flowplayer-3.1.4.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
</ul>
<p><strong><span style="text-decoration: underline;">How to Use</span></strong></p>
<p>To overlay a video,   use two div containers, one is for displaying video information (title and duration) and a splash image  as a video&#8217;s thumbnail and the second is for overlaying the video. To get thumbnail and duration of a video, you can use <span style="color: #800000;">mplayer</span> tool as <a title="Get video thumbnal and duration using mplayer" href="http://www.londatiga.net/it/programming/how-to-get-video-thumbnail-and-duration-using-mplayer-and-php/" target="_blank">explained here</a>.</p>
<p><span style="text-decoration: underline;">Overlay Single Video Player</span></p>
<p><span style="text-decoration: underline;"> </span></p>
<div class="wp-caption alignnone" style="width: 222px"><a title="View Demo Video Overlay" href="http://londatiga.net/tutorials/flowplayer2/single.html" target="_blank"><img class=" " title="View Demo" src="http://londatiga.net/images/flowplayer2/demo1.jpg" border="0" alt="View Demo" width="212" height="164" /></a><p class="wp-caption-text">View Demo</p></div>
<p><span style="text-decoration: underline;"><span style="text-decoration: underline;"> </span></span></p>
<p><span style="text-decoration: underline;">HTML</span></p>
<pre class="brush: xml; title: ;">
&lt;div class=&quot;video&quot; style=&quot;background-image:url(images/splash_01.jpg)&quot;&gt;
        &lt;a href=&quot;#&quot; rel=&quot;#orel&quot;&gt;
            &lt;img src=&quot;images/play.png&quot; alt=&quot;play&quot; title=&quot;play&quot; border=&quot;0&quot;&gt;
        &lt;/a&gt;
        &lt;div class=&quot;info&quot;&gt;
            PMDG Virtual Cockpit
            &lt;span&gt;00:27&lt;/span&gt;
        &lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;orel&quot; class=&quot;overlay&quot;&gt;&lt;a href=&quot;video/video01.flv&quot; id=&quot;player&quot;&gt;&lt;/a&gt;&lt;/div&gt;
</pre>
<p><span style="color: #800000;">line 01:</span> container for video information, splash image, play button, and video title and duration.<br />
<span style="color: #800000;"> line 02:</span> trigger button (play button), the button image is inside the <span style="color: #800000;"><em>a</em></span> tag that has <span style="color: #800000;"><em>rel</em></span> tag (<span style="color: #800000;">orel</span>) that match with the video overlay container&#8217;s id (<span style="color: #800000;">line 11</span>)<br />
<span style="color: #800000;"> line 11:</span> container for video overlay</p>
<p><span style="text-decoration: underline;">CSS</span></p>
<pre class="brush: css; title: ;">
div.overlay {
	z-index:9999;
	padding:40px;
	width:476px;
	display:none;
	background-image:url(../images/gray.png);
}
div.overlay div.close {
	background:url(../images/close.png) no-repeat;
	position:absolute;
	top:2px;
	right:5px;
	width:35px;
	height:35px;
	cursor:pointer;
}
div.overlay a {
	height:370px;
	display:block;
}
div.video {
	height:150px;
	width:200px;
	border:2px solid #fff;
	outline:1px solid #ccc;
	-moz-outline-radius:4px;
	cursor:pointer;
	text-align:center;
	float:left;
	margin:5px;
}
div.video img {
	margin-top:50px;
}
div.video div.info {
	height:40px;
	background:#000 url(../images/h80.png) repeat-x;
	opacity:0.7;
	color:#fff;
	margin-top:2px;
	text-align:left;
	padding:5px 5px;
	font-family:&quot;bitstream vera sans&quot;,&quot;trebuchet ms&quot;;
	font-size:11px;
	border-top:1px solid #ccc;

}
div.video div.info span {
	color:#99FF99;
	display:block;
}
</pre>
<p>The CSS style definition for vide overlay</p>
<p><span style="text-decoration: underline;">JavaScript</span></p>
<pre class="brush: jscript; title: ;">
$(function() {
      var player = $f(&quot;player&quot;, &quot;swf/flowplayer-3.1.5.swf&quot;);

      $('a[rel]').overlay({
            expose: '#111',
            effect: 'apple',

            onLoad: function() {
                 player.load();
            },

            onClose: function() {
                player.unload();
            }
       });
});
</pre>
<p><span style="color: #800000;">line 02:</span> install flowplayer into it&#8217;s container<br />
<span style="color: #800000;"> line 04:</span> the overlay function, fired when user clicks on play button<br />
<span style="color: #800000;"> line 05: </span>expose color<br />
<span style="color: #800000;"> line 06</span>: overlay effect<br />
<span style="color: #800000;"> line 08:</span><span style="color: #000000;"> load the player<br />
<span style="color: #800000;"> line 12:</span> </span><span style="color: #000000;">u</span>nload the player when user clicks on close button</p>
<p><span style="text-decoration: underline;">Overlay Multiple Player</span></p>
<p><span style="text-decoration: underline;"> </span></p>
<div class="wp-caption alignnone" style="width: 440px"><a title="Demo Multiple Video Overlay" href="http://londatiga.net/tutorials/flowplayer2/multi.html" target="_blank"><img title="View Demo" src="http://londatiga.net/images/flowplayer2/demo2.jpg" alt="View Demo" width="430" height="163" /></a><p class="wp-caption-text">View Demo</p></div>
<pre class="brush: xml; title: ;">
&lt;div style=&quot;float:left&quot;&gt;
   &lt;div class=&quot;video&quot; style=&quot;background-image:url(images/splash_01.jpg)&quot;&gt;
      &lt;a href=&quot;#&quot; rel=&quot;#orel1&quot;&gt;
         &lt;img src=&quot;images/play.png&quot; alt=&quot;play&quot; title=&quot;play&quot; border=&quot;0&quot;&gt;
      &lt;/a&gt;
      &lt;div class=&quot;info&quot;&gt;
          PMDG Virtual Cockpit
          &lt;span&gt;00:27&lt;/span&gt;
       &lt;/div&gt;
   &lt;/div&gt;

   &lt;div id=&quot;orel1&quot; class=&quot;overlay&quot;&gt;&lt;a href=&quot;video/video01.flv&quot; class=&quot;player&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div style=&quot;float:left&quot;&gt;
   &lt;div class=&quot;video&quot; style=&quot;background-image:url(images/splash_02.jpg)&quot;&gt;
       &lt;a href=&quot;#&quot; rel=&quot;#orel2&quot;&gt;
          &lt;img src=&quot;images/play.png&quot; alt=&quot;play&quot; title=&quot;play&quot; border=&quot;0&quot;&gt;
       &lt;/a&gt;
       &lt;div class=&quot;info&quot;&gt;
            PMDG Virtual Cockpit - Dark
            &lt;span&gt;02:38&lt;/span&gt;
       &lt;/div&gt;
    &lt;/div&gt;

    &lt;div id=&quot;orel2&quot; class=&quot;overlay&quot;&gt;&lt;a href=&quot;video/video02.flv&quot; class=&quot;player&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p><span style="color: #800000;">line 01:</span> container for video 1<br />
<span style="color: #800000;"> line 03:</span> <span style="color: #800000;"><em>rel</em></span> tag must have a unique value for each video (orel1 &amp; orel2 for the two videos)<br />
<span style="color: #800000;"> line 12:</span> overlay container, it&#8217;s id must match the <em><span style="color: #800000;">rel</span></em> tag in<span style="color: #000000;"> </span><span style="color: #000000;">line 03</span><br />
<span style="color: #800000;"> line 15:</span> container for video 2</p>
<p><span style="text-decoration: underline;">CSS</span></p>
<p>Look at example 1</p>
<p><span style="text-decoration: underline;">JavaScript</span></p>
<pre class="brush: jscript; title: ;">
$(function() {
    $(&quot;a[rel]&quot;).overlay ({
         effect: 'apple',
	 expose: '#111',

         onLoad: function(content) {
             this.getOverlay().find(&quot;a.player&quot;).flowplayer(0).load();
         },

         onClose: function(content) {
              $f().unload();
         }
     });

     $(&quot;a.player&quot;).flowplayer(&quot;swf/flowplayer-3.1.5.swf&quot;);
});
</pre>
<p><span style="color: #800000;">line 07:</span> load video, overlay function looks for <em><span style="color: #800000;">a</span></em> element with <span style="color: #800000;"><em>player</em></span> class name within it&#8217;s container to load the video<br />
<span style="color: #800000;"> line 11:</span> unload video<br />
<span style="color: #800000;"> line 15: </span> install flowplayer</p>
<div style="padding:10px;background:#2dd354;"><a title="Download example source code" href="http://londatiga.net/downloads/tutorial/flowplayer2.zip" target="_self">Download Example Source Code</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.londatiga.net/featured-articles/how-to-overlay-video-using-jquery-tools-and-flowplayer/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to Create Scrollable Image Slider Using JavaScript</title>
		<link>http://www.londatiga.net/featured-articles/how-to-create-scrollable-image-slider-using-javascript/</link>
		<comments>http://www.londatiga.net/featured-articles/how-to-create-scrollable-image-slider-using-javascript/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 04:07:56 +0000</pubDate>
		<dc:creator>lorenz</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[image slider]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[scrollable]]></category>
		<category><![CDATA[scrollable image gallery]]></category>
		<category><![CDATA[scrollable images]]></category>
		<category><![CDATA[scrolling image]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://www.londatiga.net/?p=286</guid>
		<description><![CDATA[Scrollable image slider  is one of the interesting features in the image gallery application. This allows us to display thumbnails in the form of slides that can be scrolled automatically or manually using the control buttons.
Figure below shows a scrollable image slider featuring four thumbnails per slide. To display thumbnails from another slide, simply by [...]]]></description>
			<content:encoded><![CDATA[<p>Scrollable image slider  is one of the interesting features in the image gallery application. This allows us to display thumbnails in the form of slides that can be scrolled automatically or manually using the control buttons.</p>
<p><span title="Gambar di bawah ini menunjukkan sebuah Ren yang menampilkan empat gambar per slide, untuk menampilan gambar dari slide lain, hanya dengan mengklik tombol navigasi yang terdapat di kanan dan kiri slide.">Figure below shows a scrollable image slider featuring four thumbnails per slide. To display thumbnails from another slide, simply by clicking the navigation buttons located on the right and left slide. </span><span title="Slide juga dapat digerakkan secara otomatis menggunakan panah kiri dan kanan keybord atau menggunakan mouse wheel.">Slides can also be scrolled automatically by using the  left and right arrow keyboard or using  the mouse wheel.</span></p>
<div class="wp-caption aligncenter" style="width: 510px"><img title="Scrollable image gallery" src="http://londatiga.net/images/scrollable/scrollable.jpg" alt="Scrollable image gallery" width="500" height="111" /><p class="wp-caption-text">Scrollable image slider</p></div>
<p>In this tutorial, i&#8217;ll use <a title="Scrollable component" href="http://flowplayer.org/tools/scrollable.html" target="_blank">Scrollable</a> component from <a title="jQuery Tools" href="http://flowplayer.org/tools/index.html" target="_blank">jQuery Tools</a> user interface (UI) library which is based on popular <a title="jQuery Framework" href="http://jquery.com" target="_blank">jQuery</a> javascript framework. Current version of jQuery Tools at the time of this writing is version<a title="Version 1.1.2" href="http://flowplayer.org/tools/release-notes/index.html" target="_blank"> 1.1.2</a>, which can be downloaded <a title="Download jQuery Tools" href="http://flowplayer.org/tools/download.html" target="_blank">here</a>. The library itself consists of six user interface components that can be easily combined:  <a href="http://flowplayer.org/tools/tabs.html" target="_blank">Tabs</a>, <a href="http://flowplayer.org/tools/tooltip.html" target="_blank">Tooltip</a>, <a href="http://flowplayer.org/tools/overlay.html" target="_blank">Overlay</a>, <a href="http://flowplayer.org/tools/scrollable.html" target="_blank">Scrollable</a>, <a href="http://flowplayer.org/tools/expose.html" target="_blank">Expose</a>, and <a href="http://flowplayer.org/tools/flashembed.html" target="_blank">Flashembed</a>.</p>
<p><strong><span style="text-decoration: underline;">How to Setup</span></strong></p>
<ul>
<li>Download <span style="color: #800000;">S</span><span style="color: #800000;"><span style="color: #800000;">c</span>rollable <span style="color: #000000;">component</span></span> from <a href="http://flowplayer.org/tools/download.html" target="_blank">download page</a> and save it as <span style="color: #800000;">jquery.tools.min.js</span>. You can download it with<span style="color: #800000;"> </span><span style="color: #000000;">jQuery</span> (v1.3.2)  as a single file (21.75 kb) or as a separated file (3.37 kb) if you already have<span style="color: #000000;"> </span><span style="color: #000000;">jQuery</span>.</li>
<p><img class="alignnone" title="Download scrollable ui library" src="http://londatiga.net/images/scrollable/download.jpg" alt="" width="500" height="354" /></p>
<li>Include the <span style="color: #800000;">jquery.tools.min.js</span> in the HEAD section of your HTML file</li>
<pre class="brush: xml; title: ;">
&lt;script src=&quot;scripts/jquery.tools.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>or</p>
<pre class="brush: xml; title: ;">
&lt;script src=&quot;scripts/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/jquery.tools.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
</ul>
<p><strong><span style="text-decoration: underline;">Using Scrollable UI library</span></strong></p>
<p><strong>HTML Code</strong></p>
<pre class="brush: xml; title: ;">
&lt;a class=&quot;prevPage left&quot;&gt;&lt;/a&gt;
&lt;div class=&quot;scrollable&quot;&gt;
    &lt;div class=&quot;items&quot;&gt;
        &lt;!-- 1-4 --&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img1.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img2.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img3.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img4.jpg&quot; /&gt;

        &lt;!-- 5-8 --&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img5.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img6.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img7.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img8.jpg&quot; /&gt;

        &lt;!-- 10-12 --&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img9.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img10.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img11.jpg&quot; /&gt;
        &lt;img src=&quot;http://londatiga.net/tutorials/scrollable/images/img12.jpg&quot; /&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;a class=&quot;nextPage right&quot;&gt;&lt;/a&gt;
</pre>
<p>line 01:  element for left/prev  button.</p>
<p>line 02: root element (div) for the scrollable.</p>
<p>line 03: wrapper element.</p>
<p>line 04-20: scrollable images (will be displayed  four images per slide).</p>
<p>line 24: element for right/next button.</p>
<p><strong>CSS Code</strong></p>
<p><em>Scrollable</em></p>
<pre class="brush: css; title: ;">
.scrollable {
	background: #ccc;
	position: relative;
	overflow: hidden;
	width: 690px;
	height:145px;
	border:1px solid #ccc;
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
}

.scrollable .items {
	width: 20000em;
	position: absolute;
	clear: both;
}

.scrollable img {
    opacity: 0.6;
	float:left;
	margin:15px 5px 15px 15px;
	background-color:#fff;
	cursor:pointer;
	width:150px;
	height:113px;
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
}

.scrollable .active {
    opacity:1;
	border:2px solid #000;
	z-index:9999;
	position:relative;
}
</pre>
<p>line 01, style for  container element, the length and width depends on image size and how many images you want displayed per slide.</p>
<p>line 12, style for wrapper element.</p>
<p>line 18,  style for images in a slide.</p>
<p>line 30, style for selected image.</p>
<p><em>Navigation button (prev &amp; next)</em></p>
<pre class="brush: css; title: ;">
.scrollable { float:left; }

a.left, a.right {
	display: block;
	width: 18px;
	height: 18px;
	float: left;
	margin: 60px 10px;
	cursor: pointer;
}

a.right { background: url(scrollable/arrow/right.png) no-repeat;  clear:right; margin-right: 0px;}
a.right:hover  { background-position:0px -18px; }
a.right:active 	{ background-position:0px 0px; }

a.left	{ background: url(scrollable/arrow/left.png) no-repeat;  margin-left: 0px; }
a.left:hover  { background-position:0px -18px; }
a.left:active  { background-position:-0px 0px; }

a.disabled { visibility:hidden !important; }
</pre>
<p>line 01, allow next and  prev buttons placed on each side of the slide.</p>
<p>line 12,  set size and position of prev and next buttons.</p>
<p>line 16,  set background image for prev and next buttons.</p>
<p><span style="text-decoration: underline;">Javascript Code</span></p>
<pre class="brush: jscript; title: ;">
&lt;script&gt;
	$(function()  { $(&quot;div.scrollable&quot;).scrollable({size: 4}); });
&lt;/script&gt;
</pre>
<p><span style="color: #800000;">$(&#8221;div.scrollable&#8221;) </span>is a jQuery selector for scrollabe container. On example above, we set four images for each slide using configuration parameter &#8216;<span style="color: #800000;">size</span>&#8216;. Default value of <span style="color: #800000;">&#8217;size</span>&#8216; parameter is 5. You can learn more about the API of the Scrollable component on <a title="Scrollable API" href="http://flowplayer.org/tools/scrollable.html" target="_blank">this page</a>.</p>
<div style="padding:10px;background:#2dd354;"><a title="Scrollable live demo" href="http://londatiga.net/tutorials/scrollable" target="_blank">View Live Demo</a> | <a title="Download scrollable demo source code" href="http://londatiga.net/downloads/tutorial/scrollable.zip" target="_self">Download Example Source Code</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.londatiga.net/featured-articles/how-to-create-scrollable-image-slider-using-javascript/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>How to Crop Image Using JavaScript and PHP</title>
		<link>http://www.londatiga.net/it/how-to-crop-image-using-javascript-and-php/</link>
		<comments>http://www.londatiga.net/it/how-to-crop-image-using-javascript-and-php/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 00:46:01 +0000</pubDate>
		<dc:creator>lorenz</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[Information Technology]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[image crop]]></category>
		<category><![CDATA[image crop guide]]></category>
		<category><![CDATA[image crop howto]]></category>
		<category><![CDATA[image crop javascript]]></category>
		<category><![CDATA[image crop php]]></category>
		<category><![CDATA[image crop tutorial]]></category>
		<category><![CDATA[image cropping]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php GD]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.londatiga.net/?p=250</guid>
		<description><![CDATA[Image cropping is a usefull feature in web application that allows user to crop an image on a web page and save it for later use. This feature is commonly used in user&#8217;s preferences tool for creating a profile image. User uploads an image from his local hardrive and then directly crop his desired part [...]]]></description>
			<content:encoded><![CDATA[<p>Image cropping is a usefull feature in web application that allows user to crop an image on a web page and save it for later use. This feature is commonly used in user&#8217;s preferences tool for creating a profile image. User uploads an image from his local hardrive and then directly crop his desired part  for used as his profile image without using an image editing software.</p>
<div class="wp-caption alignnone" style="width: 510px"><img title="Image Cropping" src="http://londatiga.net/images/imagecropping/imagecropping.jpg" alt="Image Cropping" width="500" height="375" /><p class="wp-caption-text">Image Cropping</p></div>
<p>Image cropping process can be separated into two separated process. The first process is  for acquaring  coordinates and dimensions of selected area of an image, which will be done in client side using JavaScript. The next is  process for creating a new image based on coordinates and dimensions from previously cropping process using PHP on server side. In this tutorial, i&#8217;ll use JavaScript <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/comment-page-27/" target="_blank">Image Cropper</a> library by David Spurr and PHP GD image processing functions.</p>
<p><strong>Client Side</strong></p>
<p>Image Cropper is an excellent JavaScript library written by David Spurr that makes image cropping easier. It allows us to crop an image using an interface with the same features and styling as found in commercial image editing software. It is based on <a href="http://www.prototypejs.org/" target="_blank">Prototype</a> JavaScript Framework and <a href="http://script.aculo.us/" target="_blank">Scriptaculous</a>.</p>
<p><span style="text-decoration: underline;">How to Setup</span></p>
<ol>
<li>Download the required library files</li>
<p>- <a href="http://www.prototypejs.org/download">Prototype Javascript Framework</a></p>
<p>- <a href="http://script.aculo.us/downloads">Scriptaculous (scriptaculous-js-1.8.3.zip)</a></p>
<p>- <a href="http://www.defusion.org.uk/code/javascript-image-cropper-ui-using-prototype-scriptaculous/download-zip/" target="_blank">Image Cropper (jsCropperUI-1.2.1.zip)</a></p>
<li>Extract <span style="color: #800000;">scriptaculous-js-1.8.3.zip <span style="color: #000000;"> </span></span> and copy <span style="color: #800000;">scriptaculous.js</span>, <span style="color: #800000;">builder.js</span>, <span style="color: #800000;">effect.js</span> and <span style="color: #800000;">dragdrop.js</span> from the extracted files into your web application directory.</li>
<li>Extract <span style="color: #800000;">jsCropperUI-1.2.1.zip</span> and copy <span style="color: #800000;">cropper.js, marqueeHoriz.gif, marqueeVert.gif, cropper.css</span> from the extracted files into your web application directory (  must reside in the same directory).</li>
<li>Include <span style="color: #800000;">Prototype.js</span>, <span style="color: #800000;">scriptaculous.js <span style="color: #000000;">and</span> </span><span style="color: #800000;">cropper.j</span><span style="color: #800000;">s</span> in the HEAD section of your HTML file.
<pre class="brush: xml; title: ;">
&lt;script src=&quot;scripts/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/scriptaculous.js?load=effects,builder,dragdrop&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/cropper.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
</li>
</ol>
<p><span style="text-decoration: underline;">Using Image Cropper Library</span></p>
<p><span style="text-decoration: underline;">With  Dynamic Crop Preview</span></p>
<pre class="brush: jscript; title: ;">
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
Event.observe (
	window,
	'load',
	function() {
		new Cropper.ImgWithPreview(
			't3soeta',
			{
				minWidth: 200,
				minHeight: 100,
                ratioDim: { x: 200, y: 100 },
				displayOnInit: true,
				onEndCrop: saveCoords,
                onloadCoords: { x1: 0, y1: 0, x2: 200, y2: 100 },
                previewWrap: 'preview'
			}
		)
	}
);

function saveCoords (coords, dimensions)
{
	$( 'x1' ).value = coords.x1;
	$( 'y1' ).value = coords.y1;
	$( 'width' ).value = dimensions.width;
	$( 'height' ).value = dimensions.height;
}
&lt;/script&gt;

&lt;form action=&quot;saveCrop.php&quot; method=&quot;post&quot;&gt;
&lt;div style=&quot;width:750px&quot;&gt;
    &lt;div style=&quot;float:left&quot;&gt;
        &lt;img src=&quot;images/t3soeta.jpg&quot; id=&quot;t3soeta&quot; width=&quot;500&quot; height=&quot;375&quot; /&gt;
    &lt;/div&gt;
    &lt;div id=&quot;preview&quot; style=&quot;float:right;&quot;&gt;&lt;/div&gt;
    &lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;x1&quot; id=&quot;x1&quot; value=&quot;&quot;&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;y1&quot; id=&quot;y1&quot; value=&quot;&quot;&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;width&quot; id=&quot;width&quot; value=&quot;&quot;&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;height&quot; id=&quot;height&quot; value=&quot;&quot;&gt;
&lt;/div&gt;
&lt;input type=&quot;submit&quot; name=&quot;Done&quot; value=&quot; Done &quot;&gt;
&lt;/form&gt;
</pre>
<p><strong>Line 06:</strong> Instantiate Image Cropper class.</p>
<p><strong>Line 07:</strong> Image Id.</p>
<p><strong>Line 09:</strong> <span style="color: #800000;">minWidth</span>, is the minimum width for  selected area in pixels.</p>
<p><strong>Line 10</strong>: <span style="color: #800000;">minHeight</span>, is the minimum height for selected area in pixels.</p>
<p><strong>Line 11:</strong> <span style="color: #800000;">ratioDim</span>, is the pixel dimensions to apply as a restrictive ratio, with properties x &amp; y.</p>
<p><strong>Line 12: </strong><span style="color: #800000;">displayOnInit</span>, whether display the selected area on initialisation. If set to <span style="color: #800000;">true</span>, <span style="color: #800000;">minWidth</span> and <span style="color: #800000;">minHeight</span> or <span style="color: #800000;">ratioDim</span> must be provided.</p>
<p><strong>Line 13:</strong> o<span style="color: #800000;">nEndCrop</span>, a callback function which will be called when user finished a crop movement. The function takes two arguments:</p>
<ul>
<li>coords, is the coordinates of selected area with properties <span style="color: #800000;">x1</span>, <span style="color: #800000;">y1</span>, <span style="color: #800000;">x2</span>,  <span style="color: #800000;">y2</span>.</li>
<li>dimensions , is the dimensions of selected area with properties <span style="color: #800000;">w</span><span style="color: #800000;">idth</span> and<span style="color: #800000;"> height</span>.</li>
</ul>
<p>On example above (Line 21), coordinates and dimensions are stored in hidden elements and will be sent to server side script (<span style="color: #800000;">s</span><span style="color: #800000;">aveCrop.php</span>) using HTTP POST method for later processing .</p>
<p><strong>Line 14: </strong><span style="color: #800000;">onloadCoords<span style="color: #000000;">, is the coordinates of the selected area to display onload</span></span></p>
<p><strong>Line 15: </strong><span style="color: #800000;">previewWra</span><span style="color: #800000;">p</span>, is the id of container for image crop preview.</p>
<p><strong>Line 21: </strong>callback function, as set on <span style="color: #800000;">onEndCrop</span> option (Line 13).</p>
<p><strong>Line 33:</strong> image to be cropped, it&#8217;s id must match the id set on Line 07.</p>
<p><strong>Line 35: </strong>div container for image crop preview.</p>
<p><strong>Line 37-40</strong>: Hidden elements to store coordinates and dimensions of selected area.</p>
<p>View live demo <a title="Image Cropping" href="http://londatiga.net/tutorials/imagecrop/example.html" target="_blank">here</a></p>
<p><span style="text-decoration: underline;">Without Dynamic Crop Preview</span></p>
<p>For using Image Cropper without dynamic preview, change the class from <span style="color: #800000;">Cropper.ImgWithPrevie</span><span style="color: #800000;">w</span> to <span style="color: #800000;">Cropper.Img<span style="color: #000000;"> and remove the <span style="color: #800000;">previewWrap</span> option.</span></span></p>
<pre class="brush: jscript; title: ;">
Event.observe (
	window,
	'load',
	function() {
		new Cropper.Img (
			't3soeta',
			{
				minWidth: 200,
				minHeight: 100,
                ratioDim: { x: 200, y: 100 },
				displayOnInit: true,
				onEndCrop: saveCoords,
                onloadCoords: { x1: 0, y1: 0, x2: 200, y2: 100 },
			}
		)
	}
);
</pre>
<p><span style="color: #800000;"><span style="color: #000000;">View live demo <a title="Image Cropping" href="http://londatiga.net/tutorials/imagecrop/example2.html" target="_blank">here</a></span></span></p>
<p><span style="color: #800000;"><span style="color: #000000;"><strong>Server Side</strong></span></span></p>
<p>On server side, image is processed using PHP GD image functions, which required GD library installed.</p>
<pre class="brush: php; title: ;">
&lt;?php
$x1      = $_POST['x1'];
$y1      = $_POST['y1'];
$width   = $_POST['width'];
$height  = $_POST['height'];

$srcImg  = imagecreatefromjpeg('images/t3soeta.jpg');
$newImg  = imagecreatetruecolor($width, $height);

imagecopyresampled($newImg, $srcImg, 0, 0, $x1, $y1, $width, $height, $width, $height);

imagejpeg($newImg, 'images/cropped_t3soeta.jpg');
?&gt;
</pre>
<p><strong>Line 02-05: </strong>get coordinates and dimensions sent from client.</p>
<p><strong>Line 07:</strong> create source image</p>
<p><strong>Line 08:</strong> create a new true color image for cropped image</p>
<p><strong>Line 10:</strong> copy selected area from source image into new image using coordinates and dimensions sent from client.</p>
<p><strong>Line 12</strong>: Output the new cropped image into a file.</p>
<div style="padding:10px;background:#2dd354;"><a title="Download image crop demo source code" href="http://londatiga.net/downloads/tutorial/imagecrop.zip" target="_self">Download Example Source Code</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.londatiga.net/it/how-to-crop-image-using-javascript-and-php/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

