Bonjour,
mon probleme est le suivant,
je travaille sur les infobulles, et je voudrais realiser une pagination sur mes infobulles.
donc le contenu de mon infobulle c est une div qui a comme enfant une UL et cette Ul a des denfants qui sont des LI.
et ma fonction pajinate prend en parametre l'identifiant du Div le parcour recuper l'ul et cre pour chaque Li une page,
comme teste j'ai inserrer dans mon Body un div qui respecte ce schema et il me donne des resulatas satisfaisant, c'est à dire ma pagination fonctionne belle bien
mais alors le Div de mon infobulle n'est pas prise en compte,
j'ai donc procedé par plusieurs testes, et je me suis rendu compte que ma fonction pajinate ne voit pas le div de mon infobulle,
comment peut on faire pour realiser une pagination sur une infobulle??
qu est ce qui pose problme sur mon code??,
ma fonction Jquery mais trop longue, avec des alertes pour le test
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
;(function($){
alert('ok-start paginate');
$.fn.pajinate = function(options){
// Set some state information
var current_page = 'current_page';
var items_per_page = 'items_per_page';
var meta;
// Setup default option values
var defaults = {
item_container_id : '.content',
items_per_page : 1,
nav_panel_id : '.page_navigation',
num_page_links_to_display : 20,
start_page : 0,
nav_label_first : 'Debut',
nav_label_prev : 'Precedent',
nav_label_next : 'Suivant',
nav_label_last : 'Fin'
};
var options = $.extend(defaults,options);
var $item_container;
var $page_container;
var $items;
var $nav_panels;
alert('ok all var1');
return this.each(function(){
alert('ok-info chargees2');
$page_container = $(this);
alert('ok-info chargees3');
$item_container = $(this).find(options.item_container_id);
alert('ok-info chargees4');
$items = $page_container.find(options.item_container_id).children();
alert('ok-info chargees');
meta = $page_container;
// Initialise meta data
meta.data(current_page,0);
meta.data(items_per_page, options.items_per_page);
// Get the total number of items
var total_items = $item_container.children().size();
// Calculate the number of pages needed
var number_of_pages = Math.ceil(total_items/options.items_per_page);
alert('ok-calculs effectues');
// Construct the nav bar
var more = '<span class="ellipse more">...</span>';
var less = '<span class="ellipse less">...</span>';
var navigation_html = '<a class="first_link" href="">'+ options.nav_label_first +'</a>';
navigation_html += '<a class="previous_link" href="">'+ options.nav_label_prev +'</a>'+ less;
var current_link = 0;
while(number_of_pages > current_link){
navigation_html += '<a class="page_link" href="" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
current_link++;
}
navigation_html += more + '<a class="next_link" href="">'+ options.nav_label_next +'</a>';
navigation_html += '<a class="last_link" href="">'+ options.nav_label_last +'</a>';
// And add it to the appropriate area of the DOM
$nav_panels = $page_container.find(options.nav_panel_id);
$nav_panels.html(navigation_html).each(function(){
$(this).find('.page_link:first').addClass('first');
$(this).find('.page_link:last').addClass('last');
});
// Hide the more/less indicators
$nav_panels.children('.ellipse').hide();
// Set the active page link styling
$nav_panels.find('.previous_link').next().next().addClass('active_page');
/* Setup Page Display */
// And hide all pages
$items.hide();
// Show the first page
$items.slice(0, meta.data(items_per_page)).show();
/* Setup Nav Menu Display */
// Page number slices
var total_page_no_links = $page_container.children(options.nav_panel_id+':first').children('.page_link').size();
options.num_page_links_to_display = Math.min(options.num_page_links_to_display,total_page_no_links);
$nav_panels.children('.page_link').hide(); // Hide all the page links
// And only show the number we should be seeing
$nav_panels.each(function(){
$(this).children('.page_link').slice(0, options.num_page_links_to_display).show();
});
/* Bind the actions to their respective links */
// Event handler for 'First' link
$page_container.find('.first_link').click(function(e){
e.preventDefault();
movePageNumbersRight($(this),0);
goto(0);
});
// Event handler for 'Last' link
$page_container.find('.last_link').click(function(e){
e.preventDefault();
var lastPage = total_page_no_links - 1;
movePageNumbersLeft($(this),lastPage);
goto(lastPage);
});
// Event handler for 'Prev' link
$page_container.find('.previous_link').click(function(e){
e.preventDefault();
showPrevPage($(this));
});
// Event handler for 'Next' link
$page_container.find('.next_link').click(function(e){
e.preventDefault();
showNextPage($(this));
});
// Event handler for each 'Page' link
$page_container.find('.page_link').click(function(e){
e.preventDefault();
goto($(this).attr('longdesc'));
});
// Goto the required page
goto(parseInt(options.start_page));
toggleMoreLess();
});
function showPrevPage(e){
new_page = parseInt(meta.data(current_page)) - 1;
// Check that we aren't on a boundary link
if($(e).siblings('.active_page').prev('.page_link').length==true){
movePageNumbersRight(e,new_page);
goto(new_page);
}
};
function showNextPage(e){
new_page = parseInt(meta.data(current_page)) + 1;
// Check that we aren't on a boundary link
if($(e).siblings('.active_page').next('.page_link').length==true){
movePageNumbersLeft(e,new_page);
goto(new_page);
}
};
function goto(page_num){
var ipp = meta.data(items_per_page);
var isLastPage = false;
// Find the start of the next slice
start_from = page_num * ipp;
// Find the end of the next slice
end_on = start_from + ipp;
// Hide the current page
$items.hide()
.slice(start_from, end_on)
.show();
// Reassign the active class
$page_container.find(options.nav_panel_id).children('.page_link[longdesc=' + page_num +']').addClass('active_page')
.siblings('.active_page')
.removeClass('active_page');
// Set the current page meta data
meta.data(current_page,page_num);
// Hide the more and/or less indicators
toggleMoreLess();
};
// Methods to shift the diplayed index of page numbers to the left or right
function movePageNumbersLeft(e, new_p){
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if($current_active_link.siblings('.page_link[longdesc=' + new_page +']').css('display') == 'none'){
$nav_panels.each(function(){
$(this).children('.page_link')
.hide() // Hide all the page links
.slice(parseInt(new_page - options.num_page_links_to_display + 1) , new_page + 1)
.show();
});
}
}
function movePageNumbersRight(e, new_p){
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if($current_active_link.siblings('.page_link[longdesc=' + new_page +']').css('display') == 'none'){
$nav_panels.each(function(){
$(this).children('.page_link')
.hide() // Hide all the page links
.slice( new_page , new_page + parseInt(options.num_page_links_to_display))
.show();
});
}
}
// Show or remove the ellipses that indicate that more page numbers exist in the page index than are currently shown
function toggleMoreLess(){
if(!$nav_panels.children('.page_link:visible').hasClass('last')){
$nav_panels.children('.more').show();
}else {
$nav_panels.children('.more').hide();
}
if(!$nav_panels.children('.page_link:visible').hasClass('first')){
$nav_panels.children('.less').show();
}else {
$nav_panels.children('.less').hide();
}
}
};
})(jQuery); |
l'en-tête:
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<LINK rel="stylesheet" type="text/css" media="all" href="stylesPagination.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.pajinate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#paging_container1').pajinate();
});
$(document).ready(function(){
$('#paging_container2').pajinate();
});
</script> |
ma fonction javascript avec la declartion de l'infobulle
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
function initialiser(ville)
{
CreationCarte(table[0][0],table[0][1]);
tablatlong (tab);
tab_point_trie(tableau_point);
for( i=0;i<tab_point_tri.length;i++)
{ var obj=tab_point_tri[i];
if (obj.nombre==1)
{
var point = new google.maps.LatLng(obj.latitude, obj.longitude);
optionsMarqueur =
{
position: point,
map: carte,
//ajouter un attibut(chaine de caractere contenant l'url de l'icone) pour l'icone? et le titre? aux objet en bas
icon: obj.iconeUrl, //objet.iconUrl
title: obj.title
};
marqueur = new google.maps.Marker(optionsMarqueur);
markers.push(marqueur);
var infowindow = new google.maps.InfoWindow ({
content: obj.contenu,
position: point,
});
marqueur._infowindow = infowindow;
google.maps.event.addListener(marqueur, 'click', function ()
{
if(marqueur_courant)
{
marqueur_courant._infowindow.close();
}
marqueur_courant = this;
// ! IMPORTANT on utilise this et non pas marqueur
this._infowindow.open( carte, this);
});
}
else
{
var point = new google.maps.LatLng(obj.latitude, obj.longitude);
optionsMarqueur =
{
position: point,
map: carte,
//ajouter un attibut(chaine de caractere contenant l'url de l'icone) pour l'icone? et le titre? aux objet en bas
icon: obj.iconeUrl, //objet.iconUrl
title: 'j suis doublé'
};
marqueur = new google.maps.Marker(optionsMarqueur);
markers.push(marqueur);
var contenuFinal =obj.contenu;
var contenuFinals ='<div id="paging_container2" class="container" > <div class="page_navigation"></div><ul class ="content" > <li> jjjjjjj</li><li>jjjjjjjj</li></ul> </div>';
var infowindow = new google.maps.InfoWindow ({
content: contenuFinals,
position: point,
});
marqueur._infowindow = infowindow;
google.maps.event.addListener(marqueur, 'click', function ()
{
if(marqueur_courant)
{
marqueur_courant._infowindow.close();
}
marqueur_courant = this;
// ! IMPORTANT on utilise this et non pas marqueur
this._infowindow.open( carte, this);
}); alert('ok-listener-click');
// $('#paging_container2').pajinate();
}
}
alert('listerner terminer');
var markerCluster = new MarkerClusterer(carte, markers);
google.maps.event.addListener(markerCluster, 'clusterclick',
function(cluster) {
('creationmarker');
var clickedMakrers = cluster.getMarkers();
// alert(cluster.getMarkers().length);
});
showVille(1,ville);
} |
ici le DIv dans le body qui marche:
Code :
1 2 3 4 5 6 7 8 9 10 11
|
<div id="paging_container1" class="container"style="width:200px; height:100px">
<div class="page_navigation">
</div>
<ul class="content">
<li> ouuuu</li>
<li>bbbbbbb</li>
<li>9</li>
<li>b5</li>
</ul>
</div> |