<?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>(function() { &#187; javascript</title>
	<atom:link href="http://maxb.net/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://maxb.net/blog</link>
	<description>// MAXB.NET LABS</description>
	<lastBuildDate>Mon, 16 May 2011 19:12:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>jbgallery 3.0</title>
		<link>http://maxb.net/blog/2010/12/19/jbgallery-3-0/</link>
		<comments>http://maxb.net/blog/2010/12/19/jbgallery-3-0/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 18:31:46 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jbgallery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=646</guid>
		<description><![CDATA[DEMO SITE &#8211; (UPDATED 2011-05-16) WHAT&#8217;S NEW New option! &#8211; fullscreen : false(resize box &#38; refresh to test. use menu on bottom.) Many gallery Randomize your galleries Try new API to push/pop, shift/unshift images from outside (mandatory one image in &#8230; <a href="http://maxb.net/blog/2010/12/19/jbgallery-3-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="/scripts/jbgallery/" target="_blank">DEMO SITE</a> &#8211; <strong>(UPDATED 2011-05-16)</strong></p>
<h2>WHAT&#8217;S NEW</h2>
<ul>
<li><a href="/scripts/jbgallery/docs/jbox/test_jbox.html" class="blank">New option! &#8211; fullscreen : false</a><br /><strong>(resize box &amp; refresh to test. use menu on bottom.)</strong></li>
<li><a href="/scripts/jbgallery/docs/jbox/test_jbox_multi.html" class="blank">Many gallery</a></li>
<li><a href="/scripts/jbgallery/docs/options/randomize_slideshow.html" class="blank">Randomize your galleries</a></li>
<li><a href="/scripts/jbgallery/docs/advanced/api.html" class="blank">Try new API to push/pop, shift/unshift images from outside</a> (mandatory one image in markup)</li>
<li><a href="/scripts/jbgallery/docs/advanced/push.html" class="blank">See a basic push example</a></li>
<li><a href="/scripts/jbgallery/docs/advanced/push_hundreds_from_picasa_menuslider.html" class="blank">See how push hundreds images from outside</a> (my picasa feed)</li>
<li><a href="/scripts/jbgallery/docs/adapters/picasa_api.html" class="blank">See an example of adapter that use new API</a></li>
<li><a href="/scripts/jbgallery/docs/debug/test.html" class="blank">Test zoom, centered and original style option</a></li>
<li><a href="/scripts/jbgallery/docs/caption/caption.html" class="blank">Caption simplified and improved</a> (see html markup)</li>
</ul>
<p>
    jbgallery is a UI widget webpage written in javascript on top of the jQuery library.<br />
    Its function is to show a single big image, multiple images, multiple galleries, slideshows, as a site&#8217;s background, in a &#8220;dialog&#8221; mode or as a common pop-up.</p>
<p>    jbgallery has two basic menus: the first one has music player buttons while the other one links  directly to single images.<br />
    I added a &#8220;complex&#8221; menu on the 2.0 version, which is inspired by the <a href="http://www.flickr.com/search/show/?q=assisi" class="blank">flickr</a> slider-equipped slideshow that allows to scroll the thumbnail previews.<br />
    jbgallery provides a pubblic API to remote control the component, so it would be easier to bind also with a more complex menu.</p>
<p>    Examples:
    </p>
<ul>
<li>Option &#8220;fullscreen&#8221; &#8211; default true (jQuery UI resizable only for test):
<ul>
<li><a href="/scripts/jbgallery/docs/jbox/test_jbox.html" class="blank">box gallery</a> <strong>(NEW option! fullscreen : false)</strong></li>
<li><a href="/scripts/jbgallery/docs/jbox/test_jbox_multi.html" class="blank">multi box gallery</a> <strong>(NEW option! fullscreen : false)</strong></li>
</ul>
</li>
<li>Option &#8220;style&#8221; &#8211; default &#8220;centered&#8221;:
<ul>
<li><a href="/scripts/jbgallery/docs/background/centered.html" class="blank">centered</a> <strong>(default)</strong></li>
<li><a href="/scripts/jbgallery/docs/background/zoom.html" class="blank">zoom</a></li>
<li><a href="/scripts/jbgallery/docs/background/original.html" class="blank">original</a></li>
</ul>
</li>
<li>Option &#8220;menu&#8221; &#8211; default &#8220;simple&#8221;:
<ul>
<li><a href="/scripts/jbgallery/docs/menusimple/simple.html" class="blank">simple</a> <strong>(default)</strong></li>
<li><a href="/scripts/jbgallery/docs/menuslider/menuslider.html" class="blank">slider</a></li>
<li><a href="/scripts/jbgallery/docs/menunumbers/centered.html" class="blank">numbers</a></li>
<li><a href="/scripts/jbgallery/docs/background/slideshow.html" class="blank">nothing</a> (slideshow true, use arrows)</li>
</ul>
</li>
<li>Option &#8220;caption&#8221; &#8211; default true:
<ul>
<li><a href="/scripts/jbgallery/docs/caption/caption.html" class="blank">caption</a> (see html markup)</li>
<li><a href="/scripts/jbgallery/docs/caption/caption.html" class="blank">no caption</a> (caption disabled)</li>
</ul>
</li>
<li>Option &#8220;timers&#8221;:
<ul>
<li><a href="/scripts/jbgallery/docs/options/interval.html" class="blank">interval</a></li>
<li><a href="/scripts/jbgallery/docs/options/nofade.html" class="blank">No fade effect</a> (menu simple)</li>
<li><a href="/scripts/jbgallery/docs/options/nofade2.html" class="blank">No fade effect</a> (menu slider)</li>
</ul>
</li>
<li>Option &#8220;autohide&#8221; &#8211; default false:
<ul>
<li><a href="/scripts/jbgallery/docs/options/autohide_ms.html" class="blank">autohide</a> (menu slider)</li>
<li><a href="/scripts/jbgallery/docs/options/autohide_mn.html" class="blank">autohide</a> (menu numbers)</li>
</ul>
</li>
<li>Option &#8220;randomize&#8221; &#8211; default 0:
<ul>
<li><a href="/scripts/jbgallery/docs/options/randomize.html" class="blank">randomize first image</a> &#8211; randomize : 1</li>
<li><a href="/scripts/jbgallery/docs/options/randomize_slideshow.html" class="blank">randomize slideshow</a> &#8211; randomize : 2</li>
</ul>
</li>
<li><a href="/scripts/jbgallery/docs/options/labels.html" class="blank">custom labels</a></li>
<li><a href="/scripts/jbgallery/docs/options/clickable.html" class="blank">clickable</a> &#8211; option clickable (default : false)</li>
<li><a href="/scripts/jbgallery/docs/debug/test.html" class="blank">Debug style</a> (debug style)</li>
<li>Option &#8220;popup&#8221; &#8211; default 0:
<ul>
<li><a href="/scripts/jbgallery/docs/multi/multi.html" class="blank">multiple gallery same page</a></li>
<li><a href="/scripts/jbgallery/docs/multi/popup_launcher.html" class="blank">&#8220;overlay&#8221; vs window.open</a> (see &#8220;permalink&#8221;)</li>
</ul>
</li>
<li>&#8220;Old Hack&#8221; &#8211; deprecated (use caption):
<ul>
<li><a href="/scripts/jbgallery/docs/advanced/links.html" class="blank">links over image</a></li>
</ul>
</li>
<li>API &amp; Advanced options for developers/designers:
<ul>
<li><a href="/scripts/jbgallery/docs/advanced/callback.html" class="blank">callback</a> (basic callback)</li>
<li><a href="/scripts/jbgallery/docs/advanced/api.html" class="blank">api</a> (menu slider)</li>
<li><a href="/scripts/jbgallery/docs/advanced/api_menunumbers.html" class="blank">api</a> (menu numbers)</li>
<li><a href="/scripts/jbgallery/docs/advanced/api_menusimple.html" class="blank">api</a> (menu simple)</li>
<li><a href="/scripts/jbgallery/docs/advanced/api_callback.html" class="blank">callback on push/pop/unshift/shift</a></li>
</ul>
</li>
<li>API demo (hundreds images push via yql &amp; picasa):
<ul>
<li><a href="/scripts/jbgallery/docs/advanced/push_hundreds_from_picasa_menuslider.html" class="blank">slider</a></li>
<li><a href="/scripts/jbgallery/docs/advanced/push_hundreds_from_picasa_menusimple.html" class="blank">simple</a></li>
<li><a href="/scripts/jbgallery/docs/advanced/push_hundreds_from_picasa_menunumbers.html" class="blank">numbers</a> &#8211; note the limitations of this menu</li>
<li><a href="/scripts/jbgallery/docs/advanced/push.html" class="blank">basic example of push</a></li>
</ul>
</li>
<li>ADAPTERS (picasa):
<ul>
<li><a href="/scripts/jbgallery/docs/adapters/picasa_api.html" class="blank">all album</a> &#8211; new version with api</li>
<li><a href="/scripts/jbgallery/docs/adapters/picasa_album_api.html" class="blank">filter by album</a> &#8211; new version with api</li>
<li><a href="/scripts/jbgallery/docs/adapters/picasa.html" class="blank">all album</a> &#8211; old version</li>
<li><a href="/scripts/jbgallery/docs/adapters/picasa-album.html" class="blank">filter by album</a> &#8211; old version</li>
</ul>
</li>
</ul>
<h2>Installation</h2>
<h3>Download and extract</h3>
<p><a href="/scripts/jbgallery/jbgallery-3.0.beta.zip">jbgallery-3.0.beta.zip</a></p>
<p>Download single files : </p>
<ul>
<li>jbgallery-3.0.js : <a href="/scripts/jbgallery/jbgallery-3.0.js" class="blank">source</a> | <a href="/scripts/jbgallery/jbgallery-3.0.min.js" class="blank">min</a></li>
<li><a href="/scripts/jbgallery/jbgallery-3.0.css" class="blank">jbgallery-3.0.css</a></li>
<li><a href="/scripts/jbgallery/img/ajax-loader.gif" class="blank">ajax-loader.gif</a></li>
<li><a href="/scripts/jbgallery/img/sprite.png" class="blank">sprite.png</a></li>
<li><a href="/scripts/jbgallery/img/opacity.png" class="blank">opacity.png</a></li>
<li><a href="/scripts/jbgallery/libs/jquery-1.4.4.min.js" class="blank">jquery-1.4.4.min.js</a></li>
</ul>
<p>Extra files : </p>
<ul>
<li>jbpicasa.js : <a href="/scripts/jbgallery/adapters/jbpicasa-3.0.js" class="blank">source</a> &#8211; new version.</li>
<li>jbpicasa.js : <a href="/scripts/jbgallery/adapters/jbpicasa.js" class="blank">source</a> &#8211; test adapter that you can use building an html structure, getting data from an external rss feed.</li>
</ul>
<h2>Usage</h2>
<h3>js and css (include in head tag)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;link href=&quot;jbgallery-3.0.css&quot; rel=&quot;stylesheet&quot; media=&quot;screen&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.1.4.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jbgallery-3.0.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>HTML structure (minimal menu)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;1.jpg&quot; &gt;1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;2.jpg&quot; &gt;2&lt;/a&gt;&lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>HTML structure (thumbnails &#8211; menu with slider)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;big1.jpg&quot;&gt;&lt;img src=&quot;small1.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;big2.jpg&quot;&gt;&lt;img src=&quot;small2.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>HTML structure (caption)</h3>
<pre class="brush: xml; title: ; notranslate">[/html]
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;
   &lt;a href=&quot;big.jpg&quot; title=&quot;Caption title&quot; rel=&quot;Caption title link&quot;&gt;&lt;img src=&quot;small.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
   &lt;div class=&quot;caption&quot;&gt;Long long long text&lt;/div&gt;
  &lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;

1</pre>
<h3>JS</h3>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function(){
  jQuery(&quot;.jbgallery&quot;).jbgallery();
});
&lt;/script&gt;
</pre>
<h2>OPTIONS &amp; DEFAULTS</h2>
<p>Write options HERE : </p>
<pre class="brush: jscript; title: ; notranslate">
    jQuery('.jbgallery').jbgallery({HERE});
</pre>
<pre class="brush: jscript; title: ; notranslate">
{
  //option   : default value     //see docs/demo for usage - PLEASE FIX MY ENGLISH IF YOU CAN &amp;amp; SEND ME  (thanks!)
    style    : &quot;centered&quot;,       //&quot;centered&quot;|&quot;zoom&quot;|&quot;original&quot; - image style
    menu     : &quot;slider&quot;,         //false|&quot;numbers&quot;|&quot;simple&quot;|&quot;slider&quot; - menu type
    shortcuts: [37, 39],         //[prev,next] - keyboard code shortcuts
    slideshow: false,            //true|false - autostart slideshow
    fade     : true,             //true|false - disable all fade effects
    popup    : false,            //true|false - modal box &amp;amp; traditional popup hack to display multiple gallery (3.0 : fullscreen:false)
    randomize: 0,                //0|1|2 - randomize first image (1) or randomize &quot;slideshow&quot; (2) - blackout: http://www.grayhats.org
    caption  : true,             //true|false - show/disable internal caption system
    autohide : false,            //true|false - auto hide menu &amp;amp; caption
    clickable: false,            //true|false - &quot;image click &amp;amp; go&quot;
    current  : 1,                //number     - set initial photo (modal &quot;hack&quot; - see demo. don't use &quot;hash&quot;. jbgallery use &quot;location.hash&quot; only in popup mode)
    webkit   : (navigator.userAgent.toLowerCase().search(/webkit/) != -1),  //boolean - used for specific browser hack. if you want, you can force disable this flag &amp;amp; try to find crossbrowser solution
    ie6      : (/MSIE 6/i.test(navigator.userAgent)), //boolean - IDEM
    ie7      : (/MSIE 7/i.test(navigator.userAgent)), //boolean - IDEM
    labels   : {                 //labels of internal menu
        play : &quot;play&quot;,
        next : &quot;next&quot;,
        prev : &quot;prev&quot;,
        stop : &quot;stop&quot;,
        close: &quot;close&quot;,
        info : &quot;info&quot;
    },
    timers   : {                 //timers
        fade    : 400,           //fade duration
        interval: 7000,          //slideshow interval
        autohide: 7000           //autohide timeout
    },
    delays: {                    //delays (timers) to improve usability and reduce events
        mousemove: 200,          //used by autohide. cancel autohide timeout every XXXms.
        resize   : 500,          //used by ie6 to reduce events handled by window.resize
        mouseover: 800           //used by tooltip. show tooltip only if the mouse STAY over thumb for XXXms
    },
    close    : function(){},     //callback handled by menu's button close. see demo. example : close : function(){window.close()}
    before   : function(){},     //callback handled BEFORE image gallery loaded
    after    : function(ev){},   //callback(ev) handled AFTER image gallery loaded. receive the native load event.
    load     : function(ev){},   //callback(ev) handled AFTER native image load event. receive the native load event.
    ready    : function(el){},   //callback(el) handled AFTER jbgallery render. receive the HTML element.
    //WHAT'S NEW - 3.0
    fullscreen: true,            //true|false : the most important feature of jbgallery 3.0. now jbgallery can &quot;stay in a box&quot; and have multiple istance in one page.
    push      : function(o){},   //callback handled by push public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external. useful for external menu system
    unshift   : function(o){},   //callback handled by unshift public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external.
    shift     : function(){},    //callback handled by shift public method
    pop       : function(){},    //callback handled by pop public method
    empty     : function(){}     //callback handled by empty public method
}
</pre>
<h2>API (developers/designers)</h2>
<pre class="brush: jscript; title: ; notranslate">
var obj = jQuery(&quot;#jbg&quot;).jbgallery({menu : &quot;slider&quot;}, true);//GET API
obj.left();
obj.right();
obj.go(3);
obj.current();
obj.play(4000);
obj.stop();
obj.push(single);//single = 'http://url'
obj.push(aobj);//aobj is array of object
obj.unshift(obj);//obj is a single object
obj.unshift(arr);//arr is an array of string (url)
obj.shift();
obj.pop();
obj.empty();
obj.destroy();
</pre>
<h3>EXAMPLE</h3>
<pre class="brush: jscript; title: ; notranslate">
var images = {
    single : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvbyPhCHI/AAAAAAAAA-w/rf8dATWiOK8/100_2274.jpg',
    arr : ['http://lh3.ggpht.com/_JJJpzXdPAI4/SpzvrjvU83I/AAAAAAAABAU/8tbAipa9wgk/P1020533.jpg','http://lh5.ggpht.com/_JJJpzXdPAI4/SpzuSpC-0zI/AAAAAAAAA48/M2GPV81K4Ak/100_2090.jpg'],
    obj : {
        href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/P1020744.jpg',
        title: 'Hiroshima',
        rel  : 'http://en.wikipedia.org/wiki/Hiroshima',
        caption : 'Hiroshima (広島市, Hiroshima-shi?) (About this sound listen (help·info)) is the capital of Hiroshima Prefecture, and the largest city in the Chūgoku region of western Honshū',
        caption_css : 'custom'
    },
    aobj : [{
        href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/P1020744.jpg',
        thumb: 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvjOmg5-I/AAAAAAAAA_g/S8wow3zLays/s288/P1020744.jpg',
        title: 'Hiroshima',
        rel  : 'http://en.wikipedia.org/wiki/Hiroshima',
        caption : 'Hiroshima (広島市, Hiroshima-shi?) (About this sound listen (help·info)) is the capital of Hiroshima Prefecture, and the largest city in the Chūgoku region of western Honshū',
        caption_css : 'custom'
    },{
        href : 'http://lh5.ggpht.com/_JJJpzXdPAI4/SpzvbyPhCHI/AAAAAAAAA-w/rf8dATWiOK8/100_2274.jpg',
        title: 'Magome-juku'
    }]
};
obj = jQuery(&quot;#jbgallery-api&quot;).jbgallery({menu : &quot;slider&quot;}, true);//GET API
jQuery(&quot;#mm-empty&quot;).click(function(){
    obj.empty();
});
jQuery(&quot;#mm-push&quot;).click(function(){
    obj.push(images.single);
});
jQuery(&quot;#mm-pushmany&quot;).click(function(){
    obj.push(images.aobj);
});
jQuery(&quot;#mm-shift&quot;).click(function(){
    obj.shift();
});
jQuery(&quot;#mm-pop&quot;).click(function(){
    obj.pop();
});
jQuery(&quot;#mm-unshift&quot;).click(function(){
    obj.unshift(images.obj);
});
jQuery(&quot;#mm-unshiftmany&quot;).click(function(){
    obj.unshift(images.arr);
});
</pre>
<h2>NOTES</h2>
<h3>BROWSERS TESTED</h3>
<ul>
<li>Firefox 3.6</li>
<li>Chrome 8,9</li>
<li>IE6,7,8,9</li>
<li>Opera</li>
<li>Safari</li>
</ul>
<h3>DESIGN</h3>
<p>
    This component is published with two graphic layout.</p>
<p>    You are free to customize css and to ask me any change to add classes to the menus edited by me.<br />
    If you use API or design more complex menus, or if you write plugins <del datetime="2010-12-19T18:37:54+00:00">populating html lists</del> <strong>pushing images</strong><br />
    (see <a href="/scripts/jbgallery/adapters/jbpicasa-3.0.js" class="blank">picasa 3.0 adapter</a>) via ajax by flickr<br />
    or similar services, please share with me for the next version of this plugin.
    </p>
<h3>CREDITS</h3>
<p>
        This work is inspired by <a href="http://www.ringvemedia.com/" class="blank">http://www.ringvemedia.com/</a> and <a href="http://www.chicchicken.cc/" class="blank">Chicca</a><br />
        The slider is inspired by <a href="http://www.flickr.com/search/show/?q=assisi" class="blank">http://www.flickr.com/search/show/</a><br />
        </p>
<p>        Depends on jQuery (1.4.4) by <a href="http://ejohn.org/" class="blank">John Resig</a>.<br />
        <br />
        Thanks to Carlo Denaro, Simone Parato, Aaron Hutten, Alain Bourgeoa, Steffen Wenzel
    </p>
<h2>CONTACTS</h2>
<p>
    Post a comment on this post. 
    </p>
<h3>LICENSE</h3>
<p>
    Copyright (c) 2010 Massimiliano Balestrieri</p>
<p>    Licensed GPL licenses:<br />
    <a href="http://www.gnu.org/licenses/gpl.html" class="blank">http://www.gnu.org/licenses/gpl.html</a>
    </p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/12/19/jbgallery-3-0/feed/</wfw:commentRss>
		<slash:comments>143</slash:comments>
		</item>
		<item>
		<title>jbgallery 2.0</title>
		<link>http://maxb.net/blog/2010/03/29/jbgallery-2-0/</link>
		<comments>http://maxb.net/blog/2010/03/29/jbgallery-2-0/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 14:48:42 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jbgallery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=616</guid>
		<description><![CDATA[ATTENTION : jbgallery 3.0 BETA DEMO SITE &#8211; (UPDATED 2010-12-20) jbgallery is a UI widget webpage written in javascript on top of the jQuery library. Its function is to show a single big image, multiple images, multiple galleries, slideshows, as &#8230; <a href="http://maxb.net/blog/2010/03/29/jbgallery-2-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;font-weight:bold;border:3px dashed red;padding:5px;">
ATTENTION : <a href="http://maxb.net/blog/2010/12/19/jbgallery-3-0/">jbgallery 3.0 BETA</a>
</div>
<p><a href="/scripts/old/jbgallery-2.0/" target="_blank">DEMO SITE</a> &#8211; <strong>(UPDATED 2010-12-20)</strong></p>
<p>
   jbgallery is a UI widget webpage written in javascript on top of the jQuery library.<br />
    Its function is to show a single big image, multiple images, multiple galleries, slideshows, as a site&#8217;s background, in a &#8220;dialog&#8221; mode or as a common pop-up.<br />
    jbgallery has two basic menus: the first one has music player buttons while the other one links  directly to single images.<br />
    I added a &#8220;complex&#8221; menu on the 2.0 version, which in inspired by the <a href="http://www.flickr.com/search/show/?q=assisi" class="blank">flickr</a> slider-equipped slideshow that allows to scroll the thumbnail previews.<br />
    jbgallery provides a pubblic API to remote control the component, so it would be easier to bind also with a more complex menu.</p>
<p>    Examples:
    </p>
<ul>
<li>Option &#8220;style&#8221;:
<ul>
<li><a href="/scripts/old/jbgallery-2.0/docs/centered.html" class="blank">centered</a> (default)</li>
<li><a href="/scripts/old/jbgallery-2.0/docs/zoom.html" class="blank">zoom</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/original.html" class="blank">original</a> (NEW : 2010-09-01)</li>
</ul>
</li>
<li>Option &#8220;menu&#8221;:
<ul>
<li><a href="/scripts/old/jbgallery-2.0/docs/menuslider.html" class="blank">slider</a> (default) *NEW</li>
<li><a href="/scripts/old/jbgallery-2.0/docs/numbers.html" class="blank">numbers</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/simple.html" class="blank">simple</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/nomenu.html" class="blank">nothing</a> (slideshow true, use arrows)</li>
</ul>
</li>
<li><a href="/scripts/old/jbgallery-2.0/docs/background.html" class="blank">Single image background</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/bgcentered.html" class="blank">Single image centered</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/multi.html" class="blank">Multi &#8220;fullscreen lightbox&#8221; gallery (2010-12-15 &#8211; update)</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/randomize.html" class="blank">Randomize first image (2010-12-15 &#8211; update)</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/randomize_slideshow.html" class="blank">Randomize slideshow (2010-12-15 &#8211; update)</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/popup_launcher.html" class="blank">&#8220;Fullscreen lightbox&#8221; vs Traditional popup  (2010-12-15 &#8211; update)</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/labels.html" class="blank">Custom labels</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/nofade.html" class="blank">No fade effect</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/nofade2.html" class="blank">No fade effect</a> (slider)</li>
<li><a href="/scripts/old/jbgallery-2.0/docs/interval.html" class="blank">Timers: interval</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/autohide.html" class="blank">Timers: autohide</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/callback.html" class="blank">Callback for developers</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/api.html" class="blank">Api for designer/developers</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/click.html" class="blank">Clickable</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/picasa.html" class="blank">Picasa adapter (NEW)</a></li>
<li><a href="/scripts/old/jbgallery-2.0/docs/picasa-album.html" class="blank">Picasa adapter (NEW)</a> (album)</li>
<li><a href="/scripts/old/jbgallery-2.0/docs/style_test.html" class="blank">Style test</a></li>
</ul>
<h2>Installation</h2>
<h3>Download and extract</h3>
<p><a href="/scripts/old/jbgallery-2.0/jbgallery-2.0.zip">jbgallery-2.0.zip</a> (<strong>update: 2010-12-20</strong>)</p>
<p>Download single files : </p>
<ul>
<li>jbgallery-2.0.js : <a href="/scripts/old/jbgallery-2.0/jbgallery-2.0.js" class="blank">source</a> | <a href="/scripts/old/jbgallery-2.0/jbgallery-2.0.min.js" class="blank">min</a></li>
<li><a href="/scripts/old/jbgallery-2.0/jbgallery-2.0.css" class="blank">jbgallery-2.0.css</a></li>
<li><a href="/scripts/old/jbgallery-2.0/ajax-loader.gif" class="blank">ajax-loader.gif</a></li>
<li><a href="/scripts/old/jbgallery-2.0/sprite.png" class="blank">sprite.png</a></li>
<li><a href="/scripts/old/jbgallery-2.0/jquery-1.4.2.min.js" class="blank">jquery-1.4.2.min.js</a></li>
</ul>
<p>Extra files : </p>
<ul>
<li>jbpicasa.js : <a href="/scripts/old/jbgallery-2.0/adapters/jbpicasa.js" class="blank">source</a> &#8211; test adapter that you can use building an html structure, getting data from an external rss feed.</li>
</ul>
<h3>js and css (include in head tag)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;link href=&quot;jbgallery-2.0.css&quot; rel=&quot;stylesheet&quot; media=&quot;screen&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.1.4.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jbgallery-2.0.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>HTML structure (minimal menu)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;1.jpg&quot; &gt;1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;2.jpg&quot; &gt;2&lt;/a&gt;&lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>HTML structure (thumbnails &#8211; menu with slider)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;big1.jpg&quot;&gt;&lt;img src=&quot;small1.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;big2.jpg&quot;&gt;&lt;img src=&quot;small2.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>HTML structure (caption)</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jbgallery&quot;&gt;
 &lt;ul&gt;
  &lt;li&gt;
   &lt;a href=&quot;big.jpg&quot; title=&quot;Caption title&quot;&gt;&lt;img src=&quot;small.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
   &lt;div class=&quot;caption&quot;&gt;Long long long text&lt;/div&gt;
  &lt;/li&gt;
  &lt;!-- etc --&gt;
 &lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>JS</h3>
<pre class="brush: xml; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(document).ready(function(){
  jQuery(&quot;.jbgallery&quot;).jbgallery();
});
&lt;/script&gt;
</pre>
<h2>OPTIONS &amp; DEFAULTS</h2>
<p>Write options HERE : </p>
<pre class="brush: jscript; title: ; notranslate">
 jQuery(&quot;.jbgallery&quot;).jbgallery({HERE});
</pre>
<div class="code">
    jQuery(&#8220;.jbgallery&#8221;).jbgallery({HERE});
</div>
<h3>DEFAULTS</h3>
<pre class="brush: jscript; title: ; notranslate">
{
  style     : &quot;centered&quot;,//centered, zoom, original
  menu      : 'slider', //false, numbers, simple, slider
  shortcuts : [37,39],
  slideshow : false,
  fade      : true,
  popup     : false,
  caption   : true,  //NEW 2.0
  autohide  : false, //NEW 2.0
  clickable : false, //NEW 2.0
  current   : 1,   //NEW 2.0
  randomize : 0,   //NEW 2.0
  webkit    : (navigator.userAgent.toLowerCase().search(/webkit/) != -1),
  ie6       : (/MSIE 6/i.test(navigator.userAgent)),
  ie7       : (/MSIE 7/i.test(navigator.userAgent)),
  labels    : {
    play : &quot;play&quot;,
    next : &quot;next&quot;,
    prev : &quot;prev&quot;,
    stop : &quot;stop&quot;,
    close: &quot;close&quot;,
    info : &quot;info&quot;
  },
  timers    : {
    fade      : 400,
    interval  : 7000,
    autohide  : 7000
  },
  delays    : {
    mousemove : 200,
    resize    : 500,
    mouseover : 800
  },
  close     : function(){},
  before    : function(){},
  after     : function(ev){},
  load      : function(ev){},
  ready      : function(){}
}
</pre>
<h3>OPTIONS</h3>
<ul>
<li>style : string (&#8216;zoom&#8217;/'centered&#8217;/'original&#8217;)</li>
<li>slideshow : boolean (true/false)</li>
<li>menu  : string/boolean (&#8216;slider&#8217;/'simple&#8217;/'numbers&#8217;/false)</li>
<li>caption : boolean (show info button in menu &#8211; NEW)</li>
<li>autohide: boolean (autohide interface &#8211; NEW)</li>
<li>clickable: boolean (NEW)</li>
<li>current: number (set the initial photo NEW)</li>
<li>randomize : numeric (0/1/2 &#8211; NEW &#8211; 0 default | 1 randomize first image | 2 randomize slidshow/prev/next &#8211; thanks to Carlo Denaro &#8211; blackout: http://www.grayhats.org)</li>
<li>fade  : boolean (false/true)</li>
<li>shortcuts : array (keycodes for trigger events left/right via keyboard)</li>
<li>before: function (callback)</li>
<li>load  : function(ev) (callback &#8211; native image load event)</li>
<li>after : function (callback)</li>
<li>ready : function (callback &#8211; interface ready)</li>
<li>popup : boolean (show close button)</li>
<li>close : function(ev) (callback after click close button. i.e. window.close())</li>
<li>labels: object &#8211; default:
<pre class="brush: jscript; title: ; notranslate">
{
   play : &quot;play&quot;,
   next : &quot;next&quot;,
   prev : &quot;prev&quot;,
   stop : &quot;stop&quot;,
   close: &quot;close&quot;,
   info : &quot;info&quot;
}
</pre>
</li>
<li>timers: object &#8211; default:
<pre class="brush: jscript; title: ; notranslate">
{
  fade      : 400,  //fadeIn-Out timer
  interval  : 7000, //slideshow timer
  autohide  : 7000  //autohide timer
}
</pre>
</li>
<li>delays: object &#8211; default:
<pre class="brush: jscript; title: ; notranslate">
{
  mousemove : 200,
  resize    : 500,
  mouseover : 800
}
</pre>
</li>
</ul>
<h3>API (developers/designers)</h3>
<ul>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(); // build object FIRST</li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;go&#8221; , 2); // go to photo 2 if exist </li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;left&#8221;); // prev photo </li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;right&#8221;); // next photo </li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;play&#8221;); // autoplay start </li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;stop&#8221;); // autoplay stop</li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;destroy&#8221;); // destroy object, events, expando</li>
<li>jQuery(&#8220;#jbgallery&#8221;).jbgallery(&#8220;current&#8221;); // return number of current photo</li>
</ul>
<h2>CONTENTS/FURTHER ELEMENTS</h2>
<p>
    To add to the image further contents or other kind of elements you can use the following div. Otherwise you can add other divs copying the styles below.
    </p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;jbg-content&quot;&gt;
    &lt;!-- PUT HERE CONTENT --&gt;
    &lt;div id=&quot;docs&quot;&gt;
        &lt;div class=&quot;wrapper&quot;&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- /PUT HERE CONTENT --&gt;
&lt;/div&gt;
</pre>
<pre class="brush: css; title: ; notranslate">
#docs{width:500px;right:200px;top:15%;position:absolute;z-index:1000;}
#docs .wrapper{padding:10px;margin:10px;background:#fff;}
</pre>
<h2>BROWSERS TESTED</h2>
<ul>
<li>Firefox 3.5 (winxp/linux)</li>
<li>Safari 3.2, 4 (winxp)</li>
<li>Chrome/Chromium  (winxp/linux)</li>
<li>Opera 9/10/11 (winxp/linux)</li>
<li>Internet Explorer 6/7/8 (winxp)</li>
</ul>
<h2>DESIGN/GRAPHIC</h2>
<p>
    This component is published with a minimalist graphic layout.<br />
    You are free to customize css and to ask me any change to add classes to the simple menus edited by me.<br />
    If you use API or design more complex menus, or if you write plugins populating html lists via ajax by flickr<br />
    or similar services, please share with me for the next version of this plugin.
    </p>
<h2>CREDITS</h2>
<p>
        This work is inspired by <a href="http://www.ringvemedia.com/" class="blank">http://www.ringvemedia.com/</a> and <a href="http://www.chicchicken.cc/" class="blank">Chicca</a><br />
        The slider is inspired by <a href="http://www.flickr.com/search/show/?q=assisi" class="blank">http://www.flickr.com/search/show/</a><br />
        <br />
        Depends on jQuery (1.3.2/1.4.2) by <a href="http://ejohn.org/" class="blank">John Resig</a>.<br />
       <br />
        Thanks to <a href="http://www.grayhats.org/articles/34-opensource/144-intermediate-jbgallery-20-add-random-image-loading">Carlo Denaro</a>,  Simone Parato, Aaron Hutten, Alain Bourgeoa, Steffen Wenzel, krko.
    </p>
<h2>COMMENTS &amp; CONTACTS</h2>
<p>
    Post a comment on my blog. <br />
    <a href="http://maxb.net/blog/2010/03/29/jbgallery-2-0/">http://maxb.net/blog/</a>
    </p>
<h2>LICENSE</h2>
<p>
    Copyright (c) 2010 Massimiliano Balestrieri<br />
    Licensed GPL licenses:<br />
    <a href="http://www.gnu.org/licenses/gpl.html" class="blank">http://www.gnu.org/licenses/gpl.html</a>
    </p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/03/29/jbgallery-2-0/feed/</wfw:commentRss>
		<slash:comments>121</slash:comments>
		</item>
		<item>
		<title>Markerclusterer clearMarkers</title>
		<link>http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/</link>
		<comments>http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 14:23:08 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[gmaps]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[markerclusterer]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=567</guid>
		<description><![CDATA[In the last two posts, I described a bug but later I realized it was a false positive. There was no bug in the library Markerclusterer (gmaps-utility-library-dev). The false positive was mainly caused by my initial mistake. Before explaining the &#8230; <a href="http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the last <a target="_blank" href="http://maxb.net/blog/2009/12/01/markerclusterer-clearmarkers-bugfix/">two</a> <a target="_blank" href="http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/">posts</a>, I described a bug but later I realized it was a false positive.<br />
There was no bug in the library Markerclusterer (gmaps-utility-library-dev).</p>
<p>The false positive was mainly caused by my initial mistake.</p>
<p>Before explaining the initial mistake that could still be common, and lead others in &#8220;error&#8221;, I would like to clarify that both rev.1159 and rev.1214 (current) do not contain the bug I thought I had found.</p>
<p><strong>There is no need to patch the library by adding the destroy method.</strong></p>
<p>The library Markerclusterer already exposes a method to correctly destroy the clusters: <strong> clearMarkers </strong>.</p>
<h3>clearMarkers works</h3>
<p>The initial mistake I made was to isolate within a function instance</p>
<pre class="brush: jscript; title: ; notranslate">
var markerclusterer = new Markerclusterer(map, points);
</pre>
<p>Having Isolated markercluster in the function called by the form, at each form submit I wouldn&#8217;t be able to call clearMarkers methods, not having access to the previously created instances.</p>
<p><strong> map.clearOverlay() is not enough </strong>.</p>
<p>You have to remove the clusters explicitly otherwise the first trigger ZoomIn ZoomOut keys of the map would show clusters of the previous search.</p>
<p>To summarize, use the library Markerclusterer</p>
<p>1) before removing the clusters:</p>
<pre class="brush: jscript; title: ; notranslate">
markerclusterer.clearMarkers();
</pre>
<p>2) then wipe the map with</p>
<pre class="brush: jscript; title: ; notranslate">
map.clearOverlays();
</pre>
<p>For those who want to analyze the working code I release two demos that are going to overwrite the previous:</p>
<ul>
<li><a target="_blank" href="http://maxb.net/scripts/markerclusterer/bug.html">with a programming mistake not due to the library</a></li>
<li><a target="_blank" href="http://maxb.net/scripts/markerclusterer/fix.html">with a proper usage of clearMarkers</a></li>
</ul>
<p>Another thing that could lead to errors (more false positives) is that after a zoom in / out clusters might be slightly different.</p>
<ul>
<li><a target="_blank" href="http://maxb.net/scripts/markerclusterer/many.html">many clusters</a></li>
</ul>
<p>Searching &#8220;Test 2&#8243; you&#8217;ll find 3 clusters over the Western Alps</p>
<div><img class="alignnone size-full wp-image-537" title="clusterbug" src="http://maxb.net/blog/wp-content/uploads/2010/03/many1.png" alt=""  /></div>
<p>Triggering a ZoomOut and then a ZoomIn, the clusters will be slightly different than before. Increasing the number of clusters it&#8217;s clearer something went wrong.</p>
<div><img class="alignnone size-full wp-image-537" title="clusterbug" src="http://maxb.net/blog/wp-content/uploads/2010/03/many2.png" alt=""  /></div>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jbgallery 2.0 – preview</title>
		<link>http://maxb.net/blog/2010/03/25/jbgallery-2-0-preview/</link>
		<comments>http://maxb.net/blog/2010/03/25/jbgallery-2-0-preview/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 16:26:09 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jbgallery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=595</guid>
		<description><![CDATA[DEMO]]></description>
			<content:encoded><![CDATA[<p><a href="http://maxb.net/scripts/old/jbgallery-2.0/docs/menuslider.html" target="_blank">DEMO</a></p>
<p style="text-align: center;"><a href="http://maxb.net/scripts/jbgallery-2.0/docs/menuslider.html" target="_blank"><img class="aligncenter size-full " title="jbgallery2" src="http://maxb.net/blog/wp-content/uploads/2010/03/jbgallery2.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/03/25/jbgallery-2-0-preview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jbgallery – Immagini da Picasa/Flickr via YQL</title>
		<link>http://maxb.net/blog/2010/03/18/jbgallery-immagini-da-picasaflickr-via-yql/</link>
		<comments>http://maxb.net/blog/2010/03/18/jbgallery-immagini-da-picasaflickr-via-yql/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 14:40:10 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jbgallery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[yql]]></category>
		<category><![CDATA[flikr]]></category>
		<category><![CDATA[picasa]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=581</guid>
		<description><![CDATA[DEMO PICASA FLICKR Pubblico due snippets di codice, per popolare jbgallery via Flickr o Picasa. Il vantaggio è avere a &#8220;costo zero&#8221; un backoffice per la gestione della galleria. ISTRUZIONI PER L&#8217;USO Includere gli script e il markup della demo, &#8230; <a href="http://maxb.net/blog/2010/03/18/jbgallery-immagini-da-picasaflickr-via-yql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>DEMO</h3>
<ul>
<li><a href="http://maxb.net/scripts/old/jbgallery-1.0/docs/picasa.html" target="_blank">PICASA</a></li>
<li><a href="http://maxb.net/scripts/old/jbgallery-1.0/docs/flickr.html" target="_blank">FLICKR</a></li>
</ul>
<p>Pubblico due snippets di codice, per popolare  <a href="http://maxb.net/blog/2009/03/30/jbgallery-10/" target="_blank">jbgallery</a> via Flickr o Picasa.<br />
Il vantaggio è avere a &#8220;costo zero&#8221; un backoffice per la gestione della galleria.</p>
<h3>ISTRUZIONI PER L&#8217;USO</h3>
<p>Includere gli script e il markup della demo, e configurare le variabili.</p>
<h4>PICASA</h4>
<pre class="brush: jscript; title: ; notranslate">
var _n_albums = 10;
var _account = 'massimiliano.balestrieri';
var _filter_album = 'Japan2009009Persone';//false
</pre>
<p>Per Picasa configurare l&#8217;account, il numero di album da cui prendere le immagini, e l&#8217;eventuale filtro (impostato a false non ci sarà filtro) per visualizzare un solo album.</p>
<h4>FLICKR</h4>
<pre class="brush: jscript; title: ; notranslate">
var _photoset = '72157619533884851';
</pre>
<p>Per Flickr configurare il &#8220;photoset&#8221;*.</p>
<p><small>*<a href="http://www.flickr.com/photos/chiccafake/" target="_blank">Foto di Chicca Vancini</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/03/18/jbgallery-immagini-da-picasaflickr-via-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Markerclusterer clearmarkers bug demo</title>
		<link>http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/</link>
		<comments>http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 10:31:51 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[gmaps]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[markerclusterer]]></category>
		<category><![CDATA[bugfix]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=536</guid>
		<description><![CDATA[ATTENTION : This post started from a mistake. Demos are updated with the correct use of clearMarkers (which is bug free). BUG FIX PATCH Carlo and I, working together on this application have met a problem hard to isolate and &#8230; <a href="http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;font-weight:bold;border:3px dashed red;padding:5px;">
ATTENTION : This post started from a <a href="http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/">mistake</a>.<br />
Demos are updated with the correct use of clearMarkers (which is bug free).
</div>
<ul>
<li><a target="_blank" href="http://maxb.net/scripts/markerclusterer/bug.html">BUG</a></li>
<li><a target="_blank" href="http://maxb.net/scripts/markerclusterer/fix.html">FIX</a></li>
<li><a target="_blank" href="http://perassi.org/quickhacks/mkp/mk.diff">PATCH</a></li>
</ul>
<p><a target="_blank" href="http://perassi.org/2009/12/01/markerclusterer-clearmarkers-bugfix/">Carlo</a> and I, working together on <a target="_blank" href="http://www.piemonteitalia.eu/index.php?option=com_mappet">this application</a> have met a problem hard to isolate and solve.</p>
<p>Markerclusterer library (of <a target="_blank" href="http://code.google.com/p/gmaps-utility-library-dev/">gmaps-utility-library-dev</a>) has a bug.<br />
Let me try to explain the problem.</p>
<p>Each cluster has an event associated with it (in fact, the click event on the cluster triggers the &#8220;zoom in&#8221; on the map and the cluster splits itself in markers or smaller clusters).<br />
When, from the outside (for example, within a form), I clean the map &#8211; map.clearOverlays(); &#8211; and then I refill it with a new search, I&#8217;m not able anymore to destroy the clusters.<br />
It seems the clusters are disappeared but, in fact, zooming in or out, they come back.<br />
Look at the two following pictures.</p>
<h3>STEP 1</h3>
<div><img class="alignnone size-full wp-image-537" title="clusterbug" src="http://maxb.net/blog/wp-content/uploads/2010/03/bugstep1.png" alt="" /></div>
<h3>STEP 2</h3>
<div><img class="alignnone size-full wp-image-537" title="clusterbug" src="http://maxb.net/blog/wp-content/uploads/2010/03/bugstep2.png" alt=""  /></div>
<h3>ZOOM OUT</h3>
<div><img class="alignnone size-full wp-image-537" title="clusterbug" src="http://maxb.net/blog/wp-content/uploads/2010/03/bugstep3.png" alt=""  /></div>
<p>The first and second picture shows the clusters correctly.<br />
The third picture instead (<a target="_blank" href="http://maxb.net/scripts/markerclusterer/bug.html">demo bug</a>) shows the clusters of the second search <strong>AND</strong> the ones of the first (after having done &#8220;zoom out&#8221;).</p>
<p>The whole thing is due to a bug in the JavaScript garbage collection (I suppose&#8230;).<br />
The object has been &#8220;subscribed&#8221; to an event. The object is destroyed but after the first trigger of that event, the object come back.</p>
<p>To fix this strange bug (it&#8217;s even hard to reproduce it, without a form!) it&#8217;s mandatory to provide to the markerclusterer library a method to correctly destroy the clusters.<br />
The <a href="http://perassi.org/quickhacks/mkp/mk.diff" target="blank">patch</a> (the diff file has been written again the 1159 revision) adds the destroy method.<br />
Before doing a new search, it is required to call</p>
<pre class="brush: jscript; title: ; notranslate">
map.clearOverlays();
</pre>
<p>AND</p>
<pre class="brush: jscript; title: ; notranslate">
markerCluster.destroy();
</pre>
<p>where markerCluster is your instance of MarkerClusterer(map, points);</p>
<div>
The destroy() method calls:
</div>
<pre class="brush: jscript; title: ; notranslate">
this.clearMarkers();
GEvent.removeListener(mcfn_);
mcfn_ = null;
me_ = null;
</pre>
<p>I reported the <a href="http://code.google.com/p/gmaps-utility-library-dev/issues/detail?id=196" target="_blank">bug</a> to the developers with a demo of the bug itself (and a second demo with the fix). I hope my patch could help people to not get mad on it.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2010/03/15/markerclusterer-clearmarkers-bug-demo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MarkerClusterer clearMarkers bugfix</title>
		<link>http://maxb.net/blog/2009/12/01/markerclusterer-clearmarkers-bugfix/</link>
		<comments>http://maxb.net/blog/2009/12/01/markerclusterer-clearmarkers-bugfix/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 13:24:44 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[hack]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=521</guid>
		<description><![CDATA[ATTENTION : This post started from a mistake. Demos are updated with the correct use of clearMarkers (which is bug free). (This should be a crosspost written with Carlo) It seems that MarkerClusterer has a bug, fixed with this patch &#8230; <a href="http://maxb.net/blog/2009/12/01/markerclusterer-clearmarkers-bugfix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;font-weight:bold;border:3px dashed red;padding:5px;">
ATTENTION : This post started from a <a href="http://maxb.net/blog/2010/03/29/markerclusterer-clearmarkers/">mistake</a>.<br />
Demos are updated with the correct use of clearMarkers (which is bug free).
</div>
<p>(This should be a crosspost written with <a target="_blank" href="http://perassi.org/2009/12/01/markerclusterer-clearmarkers-bugfix/">Carlo</a>)</p>
<p>It seems that <a target="_blank" href="http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/1.0/docs/reference.html">MarkerClusterer</a> has a bug, fixed with <a href="http://perassi.org/quickhacks/mkp/mk.diff" target="_blank">this patch</a> (*) written by me while I was hunting with Carlo for it on <a href="http://www.piemonteitalia.eu/index.php?option=com_mappet" target="_blank" >this application</a> (now working fine): after the ajax submit and zooming out, the library was still displaying old clusters and markers, because, after destroying MarkerClusterer, the event assigned to GEvent wasn&#8217;t correctly removed.</p>
<p>(*) the patch is created against the r1159 version on <a href="http://code.google.com/p/gmaps-utility-library-dev/" target="_blank">gmaps-utility-library-dev</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2009/12/01/markerclusterer-clearmarkers-bugfix/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Un’ idea di plugin: jCropMap</title>
		<link>http://maxb.net/blog/2009/11/12/un-idea-di-plugin-jcropmap/</link>
		<comments>http://maxb.net/blog/2009/11/12/un-idea-di-plugin-jcropmap/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 18:12:52 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[jcrop]]></category>
		<category><![CDATA[jcropmap]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=481</guid>
		<description><![CDATA[SOMMARIO Per chi non avesse la pazienza di leggere, o per chi semplicemente non è italiano, o per gli autori di Jcrop, qui sotto c&#8217;è un elenco di link in cui i linguaggi sono universali:  html, javascript (jQuery) e qualche &#8230; <a href="http://maxb.net/blog/2009/11/12/un-idea-di-plugin-jcropmap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>SOMMARIO</h3>
<p>Per chi non avesse la pazienza di leggere, o per chi semplicemente non è italiano, o per gli autori di <a href="http://deepliquid.com/projects/Jcrop/demos.php" target="_blank">Jcrop</a>, qui sotto c&#8217;è un elenco di link in cui i linguaggi sono universali:  html, javascript (jQuery) e qualche proprietà di css.</p>
<ul>
<li><a href="http://maxb.net/scripts/jcropmap/demo.html" target="_blank">esempio base</a></li>
<li><a href="http://maxb.net/scripts/jcropmap/edit.html" target="_blank">inserire le aree</a></li>
<li><a href="http://maxb.net/scripts/jcropmap/show.html" target="_blank">visualizzare le aree inserite</a></li>
<li><a href="http://maxb.net/scripts/jcropmap/demo2.html" target="_blank">esempio con shapes disegnate</a></li>
<li><a href="http://maxb.net/scripts/jcropmap/release.html" target="_blank">trigger dell&#8217;evento release</a></li>
</ul>
<h3>DOWNLOAD</h3>
<p>
<a href="http://maxb.net/scripts/jcropmap/jcropmap.zip" target="_blank">DEMOS</a>
</p>
<h3>IL TAG MAP</h3>
<p>Il tag <a href="http://www.w3schools.com/TAGS/tag_map.asp" target="_blank">map</a>, e il &#8220;sottotag&#8221; <a href="http://www.w3schools.com/TAGS/tag_area.asp" target="_blank">area</a> permettono di &#8220;disegnare&#8221; link all&#8217;interno di un immagine.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;img src=&quot;planets.gif&quot; width=&quot;145&quot; height=&quot;126&quot; alt=&quot;Planets&quot; usemap=&quot;#planetmap&quot; /&gt;

&lt;map name=&quot;planetmap&quot;&gt;
  &lt;area shape=&quot;rect&quot; coords=&quot;0,0,82,126&quot; alt=&quot;Sun&quot; href=&quot;sun.htm&quot; /&gt;
  &lt;area shape=&quot;circle&quot; coords=&quot;90,58,3&quot; alt=&quot;Mercury&quot; href=&quot;mercur.htm&quot; /&gt;
  &lt;area shape=&quot;circle&quot; coords=&quot;124,58,8&quot; alt=&quot;Venus&quot; href=&quot;venus.htm&quot; /&gt;
&lt;/map&gt;
</pre>
<p><a href="http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_areamap" target="_blank">Qui</a> c&#8217;è un esempio di utilizzo.</p>
<h3>LIMITI DEL TAG MAP</h3>
<p>Il limite principale di questo tag è a mio modo di vedere l&#8217;impossibilità di applicare stili ai tag &#8220;AREA&#8221; presenti all&#8217;interno.<br />
In pratica l&#8217;<strong>unico indizio</strong> visivo del link all&#8217;interno di una certa porzione di immagine, che viene dato all&#8217;utente, <strong>è il cursore</strong>.<br />
Non è possibile anche solo applicare bordi.<br />
Tutto questo fondamentalmente perchè il tag map permette di creare aree di tipo &#8220;rect&#8221; (e non sarebbe un problema per un browser disegnarne il bordo), &#8220;circle&#8221;, &#8220;poly&#8221;.<br />
Quindi il browser dovrebbe saper disegnare (canvas).</p>
<p>Altro limite, ma non direttamente del tag, è la difficoltà di scrivere le coordinate.</p>
<h3>ALTERNATIVE AL TAG MAP</h3>
<p><a href="http://www.alistapart.com/articles/cssmaps/" target="_blank">Listapart</a> ci aveva già pensato, e suggerisce di creare qualcosa di completamente diverso. Javascript legge una lista, disegna dei punti in posizione assoluta, e al click (o al mouseover) visulizza un tooltip.</p>
<p>L&#8217;idea è quella.</p>
<p>Siccome il mio problema comunque, era di dare in mano ad un redattore uno strumento per inserire i punti, ho iniziato a fare scouting di plugins che disegnassero aree sopra un&#8217; immagine.</p>
<h3>JQUERY JCROP</h3>
<p>Ecco che arrivo a <a href="http://deepliquid.com/projects/Jcrop/demos.php" target="_blank">Jcrop</a>.</p>
<p>Jcrop è un plugin <a href="http://jquery.com/" target="_blank">jQuery</a> principalmente pensato per tagliare immagini.</p>
<p>Inizialmente non pensavo di usarlo come sostituto dei tag map/area.</p>
<p>Pensavo solo di usare le coordinate che <a href="http://deepliquid.com/projects/Jcrop/demos.php?demo=handler" target="_blank">restuitiva</a>, salvarle nel database e successivamente creare le aree lato &#8220;frontoffice&#8221; leggendo dal database le coordinate salvate dal redattore della mappa.</p>
<p>Quindi l&#8217;avevo scelto come strumento di backoffice.</p>
<p><a href="http://deepliquid.com/projects/Jcrop/demos.php?demo=handler" target="_blank">Qui</a> un semplice utilizzo di Jcrop con le coordinate restituite in campi form.</p>
<h3>JCROP COME SOSTITUTO DEL TAG MAP</h3>
<p>Alla fine anche per la presentazione ho deciso di provare ad utilizzare il plugin.</p>
<p><a href="http://maxb.net/scripts/jcropmap/demo.html" target="_blank">Questo</a> è il risultato.</p>
<p>Una serie di link presi da una lista con le coordinate passate via <a href="http://docs.jquery.com/Plugins/Metadata" target="_blank">metadata</a>.</p>
<p>L&#8217;implementazione è  semplice (anche se le coordinate non sono proprio user-frendly).</p>
<h3>L&#8217;ESEMPIO BASE</h3>
<p><strong>Il container:</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;jcropmap&quot;&gt;&lt;/div&gt;
</pre>
<p><strong>L&#8217;immagine:</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;img src=&quot;img/italia2006.jpg&quot; alt=&quot;italia2006&quot; /&gt;
</pre>
<p><strong>La lista di aree: </strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;ul&gt;
	&lt;li&gt;&lt;a class=&quot;{coords : [33,111,75,176,42,65]}&quot; href=&quot;#&quot;&gt;Gattuso&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [93,104,144,180,51,76]}&quot; href=&quot;#&quot;&gt;Pirlo&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [171,103,224,183,53,80]}&quot; href=&quot;#&quot;&gt;Zambrotta&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [245,102,318,191,73,89]}&quot; href=&quot;#&quot;&gt;Camoranesi&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [326,100,397,190,71,90]}&quot; href=&quot;#&quot;&gt;Cannavaro&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [402,98,456,174,54,76]}&quot; href=&quot;#&quot;&gt;Perrotta&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [410,14,464,90,54,76]}&quot; href=&quot;#&quot;&gt;Totti&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [345,7,399,83,54,76]}&quot; href=&quot;#&quot;&gt;Grosso&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [274,4,328,80,54,76]}&quot; href=&quot;#&quot;&gt;Toni&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [211,4,265,80,54,76]}&quot; href=&quot;#&quot;&gt;Barzagli&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;{coords : [149,2,203,78,54,76]}&quot; href=&quot;#&quot;&gt;Buffon&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p><strong>Il JS NELL&#8217;HEAD:</strong></p>
<pre class="brush: jscript; title: ; notranslate">
jQuery(window).load(function(){
	jQuery(&quot;.jcropmap&quot;).jcropmap();
});
</pre>
<p>NB:</p>
<p>non ci sono regole forti per questo plugin per la struttura html. L&#8217; importante è scegliere una classe o un id per il wrapper container e richiamarla nell&#8217;head quando si avvia il costruttore. All&#8217;interno di questo wrapper ricordarsi solo che i link vengono cercati all&#8217;interno di un ul, e l&#8217;immagine DEVE avere come classe jcropbox (sovrascrivibile da opzione).</p>
<h3>CREARE LE AREE</h3>
<p>Visto che non è proprio semplice scrivere le coordinate delle aree, ho creato una <a href="http://maxb.net/scripts/jcropmap/edit.html" target="_blank">demo</a> con una banale gestione della sessione.</p>
<p><strong>Questa demo non è un plugin</strong>.</p>
<p>E&#8217; solo uno <strong>spunto</strong> per crearsi la propria gestione dei link.</p>
<p>Sarà quindi necessario implementare un servizio che ad esempio salvi le informazioni su db.</p>
<h3>VISUALIZZARE IL RISULTATO</h3>
<p>Una volta inserite le coordinate nella <a href="http://maxb.net/scripts/jcropmap/edit.html" target="_blank">demo</a> precedente, potrete vedere il risultato dei vostri &#8220;tag&#8221; <a href="http://maxb.net/scripts/jcropmap/show.html" target="_blank">qui</a>.</p>
<h3>EXTRA : SHAPES, OPTIONS, RELEASE</h3>
<p>Ho aggiunto anche la possibilità di visualizzare le aree all&#8217;interno del &#8220;viewport&#8221; di Jcrop, e di sovrascrivere le opzioni che vengono passate. Un <a href="http://maxb.net/scripts/jcropmap/demo2.html" target="_blank">esempio</a>.</p>
<p><a href="http://maxb.net/scripts/jcropmap/release.html" target="_blank">Qui</a> invece mostro come ho agganciato il metodo release dell&#8217;oggetto costruito all&#8217;interno del plugin (click sul body).</p>
<p>Non è una tecnica pulitissima. Ma nemmeno quella di Jcrop mi sembra elegante.</p>
<h3>FEEDBACK</h3>
<p>Se ci sarà un certo riscontro a questo post, magari versionerò il plugin, esporrò meglio le opzioni, e magari anche un API pubblica di metodi.</p>
<p>Fino ad allora per maggiori informazioni o chiedete qui postando un commento, oppure guardate il <a href="http://maxb.net/scripts/jcropmap/jcropmap.js" target="_blank">codice sorgente</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2009/11/12/un-idea-di-plugin-jcropmap/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Autocomplete con jQuery</title>
		<link>http://maxb.net/blog/2009/09/14/autocomplete-con-jquery/</link>
		<comments>http://maxb.net/blog/2009/09/14/autocomplete-con-jquery/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 08:30:38 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[suggest]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=436</guid>
		<description><![CDATA[NB: ci sono novità al fondo del post Pubblico le mie 3 implementazioni del plugin jQuery Autocomplete di Jörn Zaefferer. Queste implementazioni servono ad attivare campi form con suggest automatico senza scrivere una sola riga di javascript. La prima implementazione &#8230; <a href="http://maxb.net/blog/2009/09/14/autocomplete-con-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>NB: <a href="http://maxb.net/blog/2009/09/14/autocomplete-con-jquery/#update_post_autocomplete">ci sono novità al fondo del post</a></strong></p>
<p>Pubblico le mie 3 implementazioni del plugin jQuery <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank">Autocomplete</a> di Jörn Zaefferer.</p>
<p>Queste implementazioni servono ad attivare campi form con suggest automatico <strong>senza scrivere una sola riga di javascript.</strong></p>
<p>
La prima implementazione autoattiva il plugin originale (con supporto ai metadata):
</p>
<p>
<img src="http://maxb.net/blog/wp-content/uploads/2009/09/suggest1.png" alt="" />
</p>
<p>
La seconda implementazione aggiunge &#8220;magicamente&#8221; un campo &#8220;hidden&#8221; e  in fase di invio del &#8220;form&#8221; spedisce al server anche la chiave associata al valore selezionato nel suggest.
</p>
<p>
<img src="http://maxb.net/blog/wp-content/uploads/2009/09/suggest2.png" alt="" />
</p>
<p>
La terza invece crea un suggest &#8220;tabellare&#8221;. <strong>E&#8217; stato necessario modificare lo script</strong>.
</p>
<p>
<img src="http://maxb.net/blog/wp-content/uploads/2009/09/suggest3.png" alt="" />
</p>
<p>Per le demo ho usato:</p>
<ul>
<li><a href="http://jquery.com/" target="_blank">jQuery 1.3.2</a></li>
<li><a href="http://docs.jquery.com/Plugins/Metadata" target="_blank">jQuery Metadata</a></li>
<li><a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank">jQuery Autocomplete 1.1</a></li>
</ul>
<h3>HEAD HTML</h3>
<p>Includere le librerie e i css necessari.</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;link href=&quot;lib/jquery.autocomplete.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
	&lt;script src=&quot;lib/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;lib/jquery.metadata.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;lib/jquery.autocomplete.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;autocomplete.custom.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p><a href="http://maxb.net/scripts/autocomplete/autocomplete.custom.zip">DOWNLOAD DEMO</a></p>
<h3>SUGGEST BASE</h3>
<p>Per attivare un suggest base è sufficiente</p>
<ul>
<li>assegnare al campo input la classe <strong>suggest</strong>.</li>
<li>valorizzare l&#8217;attributo alt del campo input inserendo un url <strong>relativo</strong> es: &#8220;php/mesi.php&#8221;</li>
</ul>
<p>Lo script php d&#8217;esempio che restituisce alle chiamate ajax l&#8217;elenco dei valori:</p>
<pre class="brush: php; title: ; notranslate">
$q = strtolower($_GET[&quot;q&quot;]);
if (!$q) return;
$items = array(
	'gennaio',
	'febbraio',
	'marzo',
	'aprile',
	'maggio',
	'giugno',
	'luglio',
	'agosto',
	'settembre',
	'ottobre',
	'novembre',
	'dicembre'
);

foreach ($items as $value) {
    if (strpos(strtolower($value), $q) !== false) {
        echo &quot;$value\n&quot;;
    }
}
</pre>
<p><strong>Chiaramente nelle applicazioni reali i dati non verranno presi da un array ma da un database</strong></p>
<h4>ESEMPIO 1</h4>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/1.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; name=&quot;suggest1&quot; id=&quot;suggest1&quot; class=&quot;suggest&quot; alt=&quot;php/mesi.php&quot; /&gt;
</pre>
<h4>ESEMPIO 2</h4>
<p>Grazie all&#8217;uso di jQuery metadata le opzioni dell&#8217;autocomplete possono essere settate direttamente nell&#8217;html (quindi senza scrivere codice javascript).<br />
L&#8217;elenco delle opzioni che modificano il comportamento del plugin si trova <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions" target="_blank">qui</a>.</p>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/2.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; name=&quot;suggest2&quot; id=&quot;suggest2&quot; class=&quot;suggest {multiple:true}&quot; alt=&quot;php/mesi.php&quot; /&gt;
</pre>
<h4>ESEMPIO 3</h4>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/3.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; name=&quot;suggest3&quot; id=&quot;suggest3&quot; class=&quot;suggest {minChars:3, max:3}&quot; alt=&quot;php/search.php&quot; /&gt;
</pre>
<h3>SUGGEST CHIAVE VALORE</h3>
<p>La seconda implementazione di jQuery Autocomplete crea un campo hidden per la chiave legata al valore visualizzato in suggest in modo da poter inviare al server sia la chiave sia il valore in fase di submit.</p>
<p>Per attivare un suggest chiave/valore è sufficiente</p>
<ul>
<li>assegnare al campo input la classe <strong>suggest_keys</strong>.</li>
<li>valorizzare l&#8217;attributo alt del campo input inserendo un url <strong>relativo</strong> es: &#8220;php/keys.php&#8221;</li>
</ul>
<p>Lo script php d&#8217;esempio che restituisce alle chiamate ajax l&#8217;elenco di chiavi|valori:</p>
<pre class="brush: php; title: ; notranslate">
$q = strtolower($_GET[&quot;q&quot;]);
if (!$q) return;
$items = array(
	&quot;10024&quot; =&gt; &quot;Moncalieri&quot;,
	&quot;20000&quot; =&gt; &quot;Monza&quot;,
	&quot;10100&quot;	=&gt; &quot;Torino&quot;
);

foreach ($items as $key=&gt;$value) {
    if (strpos(strtolower($value), $q) !== false) {
        echo &quot;$key|$value\n&quot;;
    }
}
</pre>
<h4>ESEMPIO 4</h4>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/4.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; name=&quot;suggest4&quot; id=&quot;suggest4&quot; class=&quot;suggest_keys&quot; alt=&quot;php/keys.php&quot; /&gt;
</pre>
<p>Se utilizzate firebug potrete vedere che viene creato un campo nascosto. Es:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;hidden&quot; value=&quot;&quot; id=&quot;suggest4_hidden&quot; name=&quot;suggest4_hidden&quot;/&gt;
</pre>
<h4>ESEMPIO 5</h4>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/4.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; name=&quot;entita[campo]&quot; id=&quot;entita_campo&quot; class=&quot;suggest_keys&quot; alt=&quot;php/keys.php&quot; /&gt;
</pre>
<p>Se utilizzate firebug potrete vedere che viene creato un campo nascosto. Es:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;hidden&quot; value=&quot;&quot; id=&quot;entita_campo_hidden&quot; name=&quot;entita[campo_hidden]&quot;/&gt;
</pre>
<h3>SUGGEST TABELLARE</h3>
<p>La terza implementazione di jQuery Autocomplete è un po&#8217; più complessa e prevede l&#8217;utilizzo di una versione modificata di jquery autocomplete.</p>
<p>Per attivare un suggest tabellare è sufficiente</p>
<ul>
<li>Includere nell&#8217;head la versione modificata di <a href="http://maxb.net/scripts/autocomplete/lib/jquery.autocomplete.mod.js" target="_blank">jQuery  Autocomplete</a></li>
<li>assegnare al campo input la classe <strong>suggest_table</strong>.</li>
<li>personalizzare le intestazioni di colonna nell&#8217;attributo class (vedi sotto l&#8217;esempio)</li>
<li>valorizzare l&#8217;attributo alt del campo input inserendo un url <strong>relativo</strong> es: &#8220;php/table.php&#8221;</li>
<li>Includere le seguenti istruzioni css personalizzando &#8220;le larghezze&#8221; che nell&#8217;esempio settano le 3 colonne della tabella</li>
</ul>
<pre class="brush: css; title: ; notranslate">
.ac_results ul li div.tbl{clear:both;}
.ac_results ul li div.tbl div{float:left;width:30%;overflow-x:hidden;}
.ac_intestazione{position:absolute;left:0px;top:-0px;z-index:1000;background:#000;color:#fff;}

/*PERSONALIZZA*/
.ac_results ul li div.tbl div.fld_1, #int_1{width:150px;}
.ac_results ul li div.tbl div.fld_2, #int_2{width:70px;}
.ac_results ul li div.tbl div.fld_3, #int_3{width:70px;}
</pre>
<p>Lo script php d&#8217;esempio che restituisce alle chiamate ajax l&#8217;elenco dei valori della tabella.</p>
<pre class="brush: php; title: ; notranslate">
$q = strtolower($_GET[&quot;q&quot;]);
if (!$q) return;
$items = array(
	&quot;10024&quot; =&gt; array(
		&quot;Moncalieri&quot;,
		&quot;Torino&quot;,
		&quot;Piemonte&quot;
	),
	&quot;20000&quot; =&gt; array(
		&quot;Conegliano&quot;,
		&quot;Treviso&quot;,
		&quot;Veneto&quot;
	),
	&quot;10100&quot;	=&gt; array(
		&quot;Alba&quot;,
		&quot;Cuneo&quot;,
		&quot;Piemonte&quot;
	)
);

foreach ($items as $key=&gt;$array) {
	$str = join($array,&quot;#&quot;);
    if (strpos(strtolower($str), $q) !== false) {
        echo &quot;$key|$str\n&quot;;
    }
}
</pre>
<h4>ESEMPIO TABELLARE</h4>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/table.html" target="_blank">DEMO</a></li>
</ul>
<pre class="brush: xml; title: ; notranslate">
&lt;input type=&quot;text&quot; id=&quot;suggest1&quot; name=&quot;suggest1&quot; class=&quot;suggest_table {th : ['città', 'provincia', 'regione']}&quot; alt=&quot;php/table.php&quot; style=&quot;width:300px;&quot; /&gt;
</pre>
<h3 id="update_post_autocomplete">AGGIORNAMENTO 13-11-2009:</h3>
<p>Ho aggiornato lo <a href="http://maxb.net/scripts/autocomplete/autocomplete.custom.zip">ZIP</a> con le demo e gli script di questo post.</p>
<p>Ho aggiornato in particolare</p>
<ul>
<li><a href="http://maxb.net/scripts/autocomplete/lib/jquery.autocomplete.mod.js" target="_blank">jQuery  Autocomplete &#8220;modificato&#8221;</a></li>
<li><a href="http://maxb.net/scripts/autocomplete/autocomplete.custom.js" target="_blank">jQuery  Autocomplete &#8220;custom&#8221;</a></li>
</ul>
<p>Ho aggiunto questa <a href="http://maxb.net/scripts/autocomplete/table_opzioni_autocomplete.html" target="_blank">DEMO</a> per il passaggio delle <strong>opzioni autocomplete</strong> al plugin base (jquery.autocomplete.mod.js).</p>
<p><strong>Le porzioni di jquery.autocomplete.js modificate sono a questo punto due</strong>, entrambe nel metodo/funzione fillList:</p>
<pre class="brush: jscript; title: ; notranslate">
var li = $(&quot;&lt;li/&gt;&quot;).html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? &quot;ac_even&quot; : &quot;ac_odd&quot;).appendTo(list)[0];
//PATCH
if(i == 0 &amp;amp;&amp;amp; $(input).is(&quot;.suggest_table&quot;)){
	$(li).addClass(&quot;ac_first&quot;);
	var _ie_sucks = typeof document.body.style.maxHeight === &quot;undefined&quot; || //IE6
					(document.all &amp;amp;&amp;amp; !window.opera &amp;amp;&amp;amp; window.XMLHttpRequest); //IE7
	if (_ie_sucks || max == 1) {
		$(li).attr(&quot;style&quot;, &quot;padding-top:20px&quot;);
	}
}
//PATCH
$.data(li, &quot;ac_data&quot;, data[i]);
</pre>
<pre class="brush: jscript; title: ; notranslate">
listItems = list.find(&quot;li&quot;);
if ( options.selectFirst ) {
	//PATCH
	//listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
	listItems.slice(1, 2).addClass(CLASSES.ACTIVE);
	//PATCH
	active = 0;
}
</pre>
<p>Per questa seconda modifica, ringrazio <strong>Mansportivo</strong> che nei commenti qui sotto mi ha segnalato l&#8217;anomalia.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2009/09/14/autocomplete-con-jquery/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Ahah &amp; unobtrusive javascript</title>
		<link>http://maxb.net/blog/2009/07/27/ahah-unobtrusive-javascript/</link>
		<comments>http://maxb.net/blog/2009/07/27/ahah-unobtrusive-javascript/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 12:59:15 +0000</pubDate>
		<dc:creator>Massimiliano Balestrieri</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[ahah]]></category>
		<category><![CDATA[ajaxstop]]></category>
		<category><![CDATA[authoring]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://maxb.net/blog/?p=410</guid>
		<description><![CDATA[DEMO il problema soluzione &#8220;manuale&#8221; (responsabilità dello sviluppatore) soluzione nel plugin (responsabilità affidata al plugin) IL PROBLEMA DEMO SORGENTE Javascript non intrusivo ha un problema di fondo. Lavorando sull&#8217;evento window.onload, i componenti javascript non intrusivi, NON si attivano nel momento &#8230; <a href="http://maxb.net/blog/2009/07/27/ahah-unobtrusive-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>DEMO</h1>
<ul>
<li><a href="http://maxb.net/scripts/ahah_issue/ahah.html" target="_blank">il problema</a></li>
<li><a href="http://maxb.net/scripts/ahah_issue/solution1.html" target="_blank">soluzione &#8220;manuale&#8221;</a> (responsabilità dello sviluppatore)</li>
<li><a href="http://maxb.net/scripts/ahah_issue/solution2.html" target="_blank">soluzione nel plugin</a> (responsabilità affidata al plugin)</li>
</ul>
<h1>IL PROBLEMA</h1>
<ul>
<li><a href="http://maxb.net/scripts/ahah_issue/ahah.html" target="_blank">DEMO</a></li>
<li><a href="http://maxb.net/scripts/ahah_issue/lib/plugins.js.html" target="_blank">SORGENTE</a></li>
</ul>
<p>Javascript non intrusivo ha un problema di fondo.<br />
Lavorando sull&#8217;evento window.onload, i componenti javascript non intrusivi,<strong> NON si attivano nel momento in cui viene fatta un&#8217; iniezione html nel DOM (<a href="http://en.wikipedia.org/wiki/AHAH" target="_blank">AHAH</a>)</strong>.</p>
<p><a href="http://maxb.net/scripts/ahah_issue/ahah.html" target="_blank">Qui</a> ho scritto un banale esempio.</p>
<p>Il <a href="http://maxb.net/scripts/ahah_issue/lib/plugin.js" target="_blank">plugin</a> aggiunge le funzionalità draggable e resizable (jQuery UI) agli elementi HTML selezionati.</p>
<p>Il plugin come &#8220;comportamento di default&#8221; agisce su tutti gli elementi con classe &#8220;box&#8221; :</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){
	$(&quot;.box&quot;).myplugin();
});
</pre>
<p>Quindi nella demo tutti gli elementi con classe &#8220;box&#8221; saranno draggabili e ridimensionabili.</p>
<p>Il link ADD, nella <a href="http://maxb.net/scripts/ahah_issue/ahah.html" target="_blank">DEMO</a>, aggiunge elementi box via ajax (<a href="http://en.wikipedia.org/wiki/AHAH" target="_blank">AHAH</a>):</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#add&quot;).click(function(){
    $.ajax({
        url     : 'box.html',
        success : function(html){
            $(&quot;body&quot;).append($(html).myplugin());
        }
    });
});
</pre>
<p>Questi elementi arrivando da un iniezione HTML non vengono &#8220;arricchiti&#8221; dal plugin (non sono quindi ridimensionabili ne trascinabili) perchè non sono presenti al window.onload (al document.ready per chi usa jquery).</p>
<p>Questo problema non si avvertirebbe se il componente fosse intrusivo (js cablato nell&#8217;html):</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;box1&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
$(&quot;#box1&quot;).myplugin();
//]]&gt;
&lt;/script&gt;
</pre>
<p>Se io iniettassi il codice qui sopra il box si attiverebbe perchè verrebbe valutato il js (almeno se iniettato via jquery) immediatamente senza eventi onload di mezzo.</p>
<p>Spesso i framework server-side sono intrusivi proprio per essere più flessibili.<br />
Il codice html generato sarà sporco (richfaces ad esempio) ma i componenti saranno sempre &#8220;funzionanti&#8221; sia al primo caricamento sia a seguito di iniezioni html.</p>
<h1>SOLUZIONE MANUALE</h1>
<ul>
<li><a href="http://maxb.net/scripts/ahah_issue/solution1.html" target="_blank">DEMO</a></li>
</ul>
<p>La soluzione &#8220;manuale&#8221; (a carico dello sviluppatore che implementa il comportamento e <strong>USA</strong> il plugin) è attivare le funzionalità js prima di appendere il nuovo pezzo di html. <a href="http://maxb.net/scripts/ahah_issue/solution1.html" target="_blank">DEMO</a></p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#add&quot;).click(function(){
    $.ajax({
        url     : 'box.html',
        success : function(html){
            $(&quot;body&quot;).append($(html).myplugin());
        }
    });
});
</pre>
<p>Questa è la soluzione che più di frequente utilizzo. </p>
<p>Se invece avessi scritto il plugin ecco come potrei fare (quindi spostando la responsabilità al plugin stesso).</p>
<h1>SOLUZIONE AUTOMATICA</h1>
<ul>
<li><a href="http://maxb.net/scripts/ahah_issue/ahah.html" target="_blank">DEMO</a></li>
<li><a href="http://maxb.net/scripts/ahah_issue/lib/solution.js.html" target="_blank">SORGENTE</a></li>
</ul>
<p>L&#8217;idea è : quello che attivo al document.ready lo attivo anche all&#8217;evento ajaxStop (quindi inizializzo il plugin sia al window.onload sia alla chiusura di ogni chiamata ajax).</p>
<pre class="brush: jscript; title: ; notranslate">
$(document)
.ready(function(){
    $(&quot;.box&quot;).myplugin();
})
.ajaxStop(function(){
    $(&quot;.box&quot;).myplugin();
});
</pre>
<p>Il problema di questa soluzione è che applicando 2 volte ad un elemento lo stesso plugin si &#8220;rischia&#8221; spesso di ottenere degli effetti indesiderati (doppi eventi al click, interfaccia che si moltiplica a mo&#8217; di matrioska, ecc&#8230;).</p>
<p>La soluzione quindi è realizzare un qualche sistema di singleton all&#8217;elemento che si arrichisce.<br />
Nel <a href="http://maxb.net/scripts/ahah_issue/solution2.html#">plugin</a> finale ho scritto un banale if che aggiunge una certa classe (flag) all&#8217;elemento arricchito.<br />
Se un evento (ajaxStop) invoca il costruttore del plugin più volte il codice non verrà eseguito.</p>
<pre class="brush: jscript; title: ; notranslate">
//singleton
if ($(that).is(&quot;.myplugin&quot;)) {
   return;
} else {
   $(that).addClass(&quot;.myplugin&quot;);
}
//plugin code...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://maxb.net/blog/2009/07/27/ahah-unobtrusive-javascript/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

