var DynamicSlideshow = []; function dynamicSlideshow(container_id, elements_classname, ssid, display_time, transition_time ) { this.slideshow_index = ssid; this.container_id = container_id; this.elements_classname = elements_classname; this.countainer = $('#'+container_id)[0]; this.selected = 0; this.elements = new Array(); this.display_time = display_time!=undefined ? display_time : 3000; this.transition_time = transition_time!=undefined ? transition_time : 2000; this.pager_id = container_id + '_pager'; this.pager_qte_displayed = 5; this.is_paged = false; this.is_working = false; this.getElements = function () { this.countainer.object = this; var alls = $('.' + this.elements_classname); //alls = document.getElementsByClassName(this.elements_classname); var _this = this; alls.each(function(){ _this.elements.push(this); }); // for(var i=0; i1) { var pager = $('#'+this.pager_id)[0]; pager.style.display = 'none'; if(pager) { this.is_paged = pager; /* var prev_img = $(''); prev_img.data('src_def', 'APP_DIRimages/accueil/dinamic_slide_prev.gif'); prev_img.data('src_rol', 'APP_DIRimages/accueil/dinamic_slide_prev-roll.gif'); prev_img.data('object', this); prev_img.bind('mouseover', function(){ this.src = $(this).data('src_rol'); }); prev_img.bind('mouseout', function(){ this.src = $(this).data('src_def'); }); prev_img.bind('click', function(){ alert('click'); //DynamicSlideshow[this.object.slideshow_index].clickPrev(); }); */ var prev_img = document.createElement('img'); prev_img.src_def = 'APP_DIRimages/accueil/dinamic_slide_prev.gif'; prev_img.src_rol = 'APP_DIRimages/accueil/dinamic_slide_prev-roll.gif'; prev_img.object = this; prev_img.src = prev_img.src_def; prev_img.onmouseover = function() { this.src = this.src_rol; } prev_img.onmouseout = function() { this.src = this.src_def; } prev_img.onclick = function() { DynamicSlideshow[this.object.slideshow_index].clickPrev(); } var next_img = document.createElement('img'); next_img.src_def = 'APP_DIRimages/accueil/dinamic_slide_next.gif'; next_img.src_rol = 'APP_DIRimages/accueil/dinamic_slide_next-roll.gif'; next_img.object = this; next_img.src = next_img.src_def; next_img.onmouseover = function() { this.src = this.src_rol; } next_img.onmouseout = function() { this.src = this.src_def; } next_img.onclick = function() { DynamicSlideshow[this.object.slideshow_index].clickNext(); } pager.appendChild(prev_img); for(var i=0; i this.pager_qte_displayed && this.is_paged) { var between = Math.floor(this.pager_qte_displayed/2); var displayed = 0; //tronqué sur la gauche ou centré if(this.selected + between >= this.elements.length) { for(var j=this.elements.length-1; j>=0; j--) { if(j>=(this.selected-between) && j<=(this.selected+between)) { this.elements[j].pager.style.display = 'block'; displayed++; } else { if(j=(this.selected-between) && j<=(this.selected+between)) { this.elements[j].pager.style.display = 'block'; displayed++; } else { if(j>this.selected && displayed < this.pager_qte_displayed) { this.elements[j].pager.style.display = 'block'; displayed++; } else { this.elements[j].pager.style.display = 'none'; } } } } } } this.appear = function (call_back_function) { this.countainer.call_back_function = call_back_function; this.displayGoodOne(); var _this = this; $(this.countainer).show(this.transition_time/2000, function(){ _this.is_working=false; }); /*new Effect.Appear(this.countainer,{ duration:(this.transition_time/2000), fps:30, from:0.0, to:1.0, afterFinish: function (obj) { eval(obj.element.call_back_function); obj.element.object.is_working = false; } });*/ } this.disappear = function (call_back_function) { this.is_working = true; $(this.countainer).hide(this.transition_time/2000, function(){ eval(call_back_function); }); /*new Effect.Appear(this.countainer,{ duration:(this.transition_time/2000), fps:30, from:1.0, to:0.0, afterFinish: function () { eval(call_back_function); } });*/ } window.setTimeout("DynamicSlideshow[" + this.slideshow_index + "].getElements()", 500); } function createDynamicSlideshow(container_id, elements_classname, display_time, transition_time) { var ssid = DynamicSlideshow.length; DynamicSlideshow[ssid] = new dynamicSlideshow(container_id, elements_classname, ssid, display_time, transition_time); }