Before you start reading... You should know that there are many questions below... I will appreciate any help to understand any part of the MIT code(jFlip plugin for jQuery v0.4) which I find very hard to understand
You can find the code if you like at http://plugins.jquery.com/project/jFlip
And see it working at http://www.jquery.info/scripts/jFlip/demo.html
< script type="text/javascript>
(function($){
$(function(){
$("#g1").jFlip(800,800,{background:"green",cornersTop:false}).
bind("flip.jflip",function(event,index,total){
$("#l1").html("Image "+(index+1)+" of "+total);
});
});
})(jQuery);
< /script>
- the function gets a $ and than uses the $ before another function?! and than it looks like it becomes a function $("g1") ... it feels like a delegate (is it? how does it work)
- How does the bind work...it's a js function right? (I mean part of the language)
- what is the "g1" role? I would expect something like "select case" somewhere in the code, but can't find one...
Another peace of code that I find hard is:
; (function($) {
var Flip = function(canvas, width, height, images, opts) {
//private vars
opts = $.extend({ background: "green", cornersTop: true, scale: "noresize" }, opts);
var obj = this,
el = canvas.prev(),
- why is the ";" needed before he function
- there is a var within a var - what does it mean- it's a class, struct or what?
- el = canvas.prev() ... el is not defined anywhere is it a saved word for something?
and last is the one that is important for me:
.click(function(){
if(onCorner && !flipping) {
el.trigger("flip.jflip",[index,images.length]);
}
return false;
})
- what is the dot syntax : .click(... some function definition...)
- I need to make the code in the click to execute every 5 seconds ...like onPageLoad(while(true) set timeout=5000; call click;)
That's a good time to thank Trufa for the those links: http://stackoverflow.com/questions/3953228/how-to-get-the-bookflip-effect-with-java-script
Thank you so much for your time Asaf