(function() {

// MAXB.NET LABS

})();

javascript, jbgallery, jquery, plugins

jbgallery 3.0

Posted on by Massimiliano Balestrieri | Comments (143)

DEMO SITE(UPDATED 2011-05-16)

WHAT’S NEW

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 a site’s background, in a “dialog” mode or as a common pop-up.

jbgallery has two basic menus: the first one has music player buttons while the other one links directly to single images.
I added a “complex” menu on the 2.0 version, which is inspired by the flickr slider-equipped slideshow that allows to scroll the thumbnail previews.
jbgallery provides a pubblic API to remote control the component, so it would be easier to bind also with a more complex menu.

Examples:

Installation

Download and extract

jbgallery-3.0.beta.zip

Download single files :

Extra files :

  • jbpicasa.js : source – new version.
  • jbpicasa.js : source – test adapter that you can use building an html structure, getting data from an external rss feed.

Usage

js and css (include in head tag)

<link href="jbgallery-3.0.css" rel="stylesheet" media="screen" />
<script type="text/javascript" src="jquery.1.4.2.min.js"></script>
<script type="text/javascript" src="jbgallery-3.0.js"></script>

HTML structure (minimal menu)

<div class="jbgallery">
 <ul>
  <li><a href="1.jpg" >1</a></li>
  <li><a href="2.jpg" >2</a></li>
  <!-- etc -->
 </ul>
</div>

HTML structure (thumbnails – menu with slider)

<div class="jbgallery">
 <ul>
  <li><a href="big1.jpg"><img src="small1.jpg" alt="" /></a></li>
  <li><a href="big2.jpg"><img src="small2.jpg" alt="" /></a></li>
  <!-- etc -->
 </ul>
</div>

HTML structure (caption)

[/html]
<div class="jbgallery">
 <ul>
  <li>
   <a href="big.jpg" title="Caption title" rel="Caption title link"><img src="small.jpg" alt="" /></a>
   <div class="caption">Long long long text</div>
  </li>
  <!-- etc -->
 </ul>
</div>

1

JS

<script type="text/javascript">
jQuery(document).ready(function(){
  jQuery(".jbgallery").jbgallery();
});
</script>

OPTIONS & DEFAULTS

Write options HERE :

    jQuery('.jbgallery').jbgallery({HERE});
{
  //option   : default value     //see docs/demo for usage - PLEASE FIX MY ENGLISH IF YOU CAN &amp; SEND ME  (thanks!)
    style    : "centered",       //"centered"|"zoom"|"original" - image style
    menu     : "slider",         //false|"numbers"|"simple"|"slider" - 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; traditional popup hack to display multiple gallery (3.0 : fullscreen:false)
    randomize: 0,                //0|1|2 - randomize first image (1) or randomize "slideshow" (2) - blackout: http://www.grayhats.org
    caption  : true,             //true|false - show/disable internal caption system
    autohide : false,            //true|false - auto hide menu &amp; caption
    clickable: false,            //true|false - "image click &amp; go"
    current  : 1,                //number     - set initial photo (modal "hack" - see demo. don't use "hash". jbgallery use "location.hash" 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; 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 : "play",
        next : "next",
        prev : "prev",
        stop : "stop",
        close: "close",
        info : "info"
    },
    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 "stay in a box" 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
}

API (developers/designers)

var obj = jQuery("#jbg").jbgallery({menu : "slider"}, 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();

EXAMPLE

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("#jbgallery-api").jbgallery({menu : "slider"}, true);//GET API
jQuery("#mm-empty").click(function(){
    obj.empty();
});
jQuery("#mm-push").click(function(){
    obj.push(images.single);
});
jQuery("#mm-pushmany").click(function(){
    obj.push(images.aobj);
});
jQuery("#mm-shift").click(function(){
    obj.shift();
});
jQuery("#mm-pop").click(function(){
    obj.pop();
});
jQuery("#mm-unshift").click(function(){
    obj.unshift(images.obj);
});
jQuery("#mm-unshiftmany").click(function(){
    obj.unshift(images.arr);
});

NOTES

BROWSERS TESTED

  • Firefox 3.6
  • Chrome 8,9
  • IE6,7,8,9
  • Opera
  • Safari

DESIGN

This component is published with two graphic layout.

You are free to customize css and to ask me any change to add classes to the menus edited by me.
If you use API or design more complex menus, or if you write plugins populating html lists pushing images
(see picasa 3.0 adapter) via ajax by flickr
or similar services, please share with me for the next version of this plugin.

CREDITS

This work is inspired by http://www.ringvemedia.com/ and Chicca
The slider is inspired by http://www.flickr.com/search/show/

Depends on jQuery (1.4.4) by John Resig.

Thanks to Carlo Denaro, Simone Parato, Aaron Hutten, Alain Bourgeoa, Steffen Wenzel

CONTACTS

Post a comment on this post.

LICENSE

Copyright (c) 2010 Massimiliano Balestrieri

Licensed GPL licenses:
http://www.gnu.org/licenses/gpl.html

javascript, jbgallery, jquery, plugins

jbgallery 2.0

Posted on by Massimiliano Balestrieri | Comments (121)
ATTENTION : jbgallery 3.0 BETA

DEMO SITE(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 a site’s background, in a “dialog” mode or as a common pop-up.
jbgallery has two basic menus: the first one has music player buttons while the other one links directly to single images.
I added a “complex” menu on the 2.0 version, which in inspired by the flickr slider-equipped slideshow that allows to scroll the thumbnail previews.
jbgallery provides a pubblic API to remote control the component, so it would be easier to bind also with a more complex menu.

Examples:

Installation

Download and extract

jbgallery-2.0.zip (update: 2010-12-20)

Download single files :

Extra files :

  • jbpicasa.js : source – test adapter that you can use building an html structure, getting data from an external rss feed.

js and css (include in head tag)

<link href="jbgallery-2.0.css" rel="stylesheet" media="screen" />
<script type="text/javascript" src="jquery.1.4.2.min.js"></script>
<script type="text/javascript" src="jbgallery-2.0.js"></script>

HTML structure (minimal menu)

<div class="jbgallery">
 <ul>
  <li><a href="1.jpg" >1</a></li>
  <li><a href="2.jpg" >2</a></li>
  <!-- etc -->
 </ul>
</div>

HTML structure (thumbnails – menu with slider)

<div class="jbgallery">
 <ul>
  <li><a href="big1.jpg"><img src="small1.jpg" alt="" /></a></li>
  <li><a href="big2.jpg"><img src="small2.jpg" alt="" /></a></li>
  <!-- etc -->
 </ul>
</div>

HTML structure (caption)

<div class="jbgallery">
 <ul>
  <li>
   <a href="big.jpg" title="Caption title"><img src="small.jpg" alt="" /></a>
   <div class="caption">Long long long text</div>
  </li>
  <!-- etc -->
 </ul>
</div>

JS

<script type="text/javascript">
jQuery(document).ready(function(){
  jQuery(".jbgallery").jbgallery();
});
</script>

OPTIONS & DEFAULTS

Write options HERE :

 jQuery(".jbgallery").jbgallery({HERE});
jQuery(“.jbgallery”).jbgallery({HERE});

DEFAULTS

{
  style     : "centered",//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 : "play",
    next : "next",
    prev : "prev",
    stop : "stop",
    close: "close",
    info : "info"
  },
  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(){}
}

OPTIONS

  • style : string (‘zoom’/'centered’/'original’)
  • slideshow : boolean (true/false)
  • menu : string/boolean (‘slider’/'simple’/'numbers’/false)
  • caption : boolean (show info button in menu – NEW)
  • autohide: boolean (autohide interface – NEW)
  • clickable: boolean (NEW)
  • current: number (set the initial photo NEW)
  • randomize : numeric (0/1/2 – NEW – 0 default | 1 randomize first image | 2 randomize slidshow/prev/next – thanks to Carlo Denaro – blackout: http://www.grayhats.org)
  • fade : boolean (false/true)
  • shortcuts : array (keycodes for trigger events left/right via keyboard)
  • before: function (callback)
  • load : function(ev) (callback – native image load event)
  • after : function (callback)
  • ready : function (callback – interface ready)
  • popup : boolean (show close button)
  • close : function(ev) (callback after click close button. i.e. window.close())
  • labels: object – default:
    {
       play : "play",
       next : "next",
       prev : "prev",
       stop : "stop",
       close: "close",
       info : "info"
    }
    
  • timers: object – default:
    {
      fade      : 400,  //fadeIn-Out timer
      interval  : 7000, //slideshow timer
      autohide  : 7000  //autohide timer
    }
    
  • delays: object – default:
    {
      mousemove : 200,
      resize    : 500,
      mouseover : 800
    }
    

API (developers/designers)

  • jQuery(“#jbgallery”).jbgallery(); // build object FIRST
  • jQuery(“#jbgallery”).jbgallery(“go” , 2); // go to photo 2 if exist
  • jQuery(“#jbgallery”).jbgallery(“left”); // prev photo
  • jQuery(“#jbgallery”).jbgallery(“right”); // next photo
  • jQuery(“#jbgallery”).jbgallery(“play”); // autoplay start
  • jQuery(“#jbgallery”).jbgallery(“stop”); // autoplay stop
  • jQuery(“#jbgallery”).jbgallery(“destroy”); // destroy object, events, expando
  • jQuery(“#jbgallery”).jbgallery(“current”); // return number of current photo

CONTENTS/FURTHER ELEMENTS

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.

<div id="jbg-content">
    <!-- PUT HERE CONTENT -->
    <div id="docs">
        <div class="wrapper">
        </div>
    </div>
    <!-- /PUT HERE CONTENT -->
</div>
#docs{width:500px;right:200px;top:15%;position:absolute;z-index:1000;}
#docs .wrapper{padding:10px;margin:10px;background:#fff;}

BROWSERS TESTED

  • Firefox 3.5 (winxp/linux)
  • Safari 3.2, 4 (winxp)
  • Chrome/Chromium (winxp/linux)
  • Opera 9/10/11 (winxp/linux)
  • Internet Explorer 6/7/8 (winxp)

DESIGN/GRAPHIC

This component is published with a minimalist graphic layout.
You are free to customize css and to ask me any change to add classes to the simple menus edited by me.
If you use API or design more complex menus, or if you write plugins populating html lists via ajax by flickr
or similar services, please share with me for the next version of this plugin.

CREDITS

This work is inspired by http://www.ringvemedia.com/ and Chicca
The slider is inspired by http://www.flickr.com/search/show/

Depends on jQuery (1.3.2/1.4.2) by John Resig.

Thanks to Carlo Denaro, Simone Parato, Aaron Hutten, Alain Bourgeoa, Steffen Wenzel, krko.

COMMENTS & CONTACTS

Post a comment on my blog.
http://maxb.net/blog/

LICENSE

Copyright (c) 2010 Massimiliano Balestrieri
Licensed GPL licenses:
http://www.gnu.org/licenses/gpl.html

gmaps, javascript, markerclusterer

Markerclusterer clearMarkers

Posted on by Massimiliano Balestrieri | Comments (2)

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 initial mistake that could still be common, and lead others in “error”, I would like to clarify that both rev.1159 and rev.1214 (current) do not contain the bug I thought I had found.

There is no need to patch the library by adding the destroy method.

The library Markerclusterer already exposes a method to correctly destroy the clusters: clearMarkers .

clearMarkers works

The initial mistake I made was to isolate within a function instance

var markerclusterer = new Markerclusterer(map, points);

Having Isolated markercluster in the function called by the form, at each form submit I wouldn’t be able to call clearMarkers methods, not having access to the previously created instances.

map.clearOverlay() is not enough .

You have to remove the clusters explicitly otherwise the first trigger ZoomIn ZoomOut keys of the map would show clusters of the previous search.

To summarize, use the library Markerclusterer

1) before removing the clusters:

markerclusterer.clearMarkers();

2) then wipe the map with

map.clearOverlays();

For those who want to analyze the working code I release two demos that are going to overwrite the previous:

Another thing that could lead to errors (more false positives) is that after a zoom in / out clusters might be slightly different.

Searching “Test 2″ you’ll find 3 clusters over the Western Alps

Triggering a ZoomOut and then a ZoomIn, the clusters will be slightly different than before. Increasing the number of clusters it’s clearer something went wrong.

javascript, jbgallery, jquery, plugins, yql

jbgallery – Immagini da Picasa/Flickr via YQL

Posted on by Massimiliano Balestrieri | Comments Off

DEMO

Pubblico due snippets di codice, per popolare jbgallery via Flickr o Picasa.
Il vantaggio è avere a “costo zero” un backoffice per la gestione della galleria.

ISTRUZIONI PER L’USO

Includere gli script e il markup della demo, e configurare le variabili.

PICASA

var _n_albums = 10;
var _account = 'massimiliano.balestrieri';
var _filter_album = 'Japan2009009Persone';//false

Per Picasa configurare l’account, il numero di album da cui prendere le immagini, e l’eventuale filtro (impostato a false non ci sarà filtro) per visualizzare un solo album.

FLICKR

var _photoset = '72157619533884851';

Per Flickr configurare il “photoset”*.

*Foto di Chicca Vancini