|
1 | 1 | /*! |
2 | | - * jQuery Bootgrid v0.9.6-rc1 - 05/28/2014 |
| 2 | + * jQuery Bootgrid v0.9.6-rc2 - 05/28/2014 |
3 | 3 | * Copyright (c) 2014 Rafael Staib (http://www.jquery-bootgrid.com) |
4 | 4 | * Licensed under MIT http://www.opensource.org/licenses/MIT |
5 | 5 | */ |
|
52 | 52 | { |
53 | 53 | var request = { |
54 | 54 | current: context.current, |
55 | | - rowCount: options.rowCount, |
| 55 | + rowCount: context.rowCount, |
56 | 56 | sort: context.sort |
57 | 57 | }, |
58 | 58 | post = options.post; |
|
167 | 167 | tpl = options.templates; |
168 | 168 |
|
169 | 169 | instance.loading = $(options.templates.loading.resolve(getParams(context))); |
170 | | - instance.header = $(tpl.header.resolve(getParams(context, { id: element._bgId() + "-header" }))); |
171 | | - instance.footer = $(tpl.footer.resolve(getParams(context, { id: element._bgId() + "-footer" }))); |
172 | | - element.addClass(css.table).before(instance.header).after(instance.footer).after(instance.loading); |
| 170 | + element.addClass(css.table).after(instance.loading); |
| 171 | + if (options.navigation & 1) |
| 172 | + { |
| 173 | + instance.header = $(tpl.header.resolve(getParams(context, { id: element._bgId() + "-header" }))); |
| 174 | + element.before(instance.header); |
| 175 | + } |
| 176 | + if (options.navigation & 2) |
| 177 | + { |
| 178 | + instance.footer = $(tpl.footer.resolve(getParams(context, { id: element._bgId() + "-footer" }))); |
| 179 | + element.after(instance.footer); |
| 180 | + } |
173 | 181 |
|
174 | 182 | renderTableHeader(element, options, context); |
175 | 183 | } |
|
210 | 218 | var $this = $(this); |
211 | 219 | if ($this.text() !== currentKey) |
212 | 220 | { |
213 | | - // todo: sophisticated solution needed for figuring out which page is selected and if applicable to reset the current page |
214 | | - context.current = 1; |
| 221 | + // todo: sophisticated solution needed for calculating which page is selected |
| 222 | + context.current = 1; // context.rowCount === -1 ---> All |
215 | 223 | context.rowCount = +$this.attr("href").substr(1); |
216 | 224 | loadData(element, options, context); |
217 | 225 | } |
|
267 | 275 | if (options.navigation !== 0) |
268 | 276 | { |
269 | 277 | var instance = getInstance(element), |
270 | | - end = (context.current * context.rowCount), |
| 278 | + selector = getSelector(options.css.infos), |
| 279 | + header = instance.header.find(selector)._bgShowAria(context.rowCount !== -1), |
| 280 | + footer = instance.footer.find(selector)._bgShowAria(context.rowCount !== -1); |
| 281 | + |
| 282 | + if (context.rowCount === -1) |
| 283 | + { |
| 284 | + return; |
| 285 | + } |
| 286 | + |
| 287 | + var end = (context.current * context.rowCount), |
271 | 288 | infos = $(options.templates.infos.resolve(getParams(context, |
272 | | - { end: end, start: (end - context.rowCount + 1), total: context.total }))), |
273 | | - selector = getSelector(options.css.infos); |
| 289 | + { end: (end > context.total) ? context.total : end, |
| 290 | + start: (end - context.rowCount + 1), total: context.total }))); |
274 | 291 |
|
275 | | - replacePlaceHolder(options, instance.header.find(selector), infos, 1); |
276 | | - replacePlaceHolder(options, instance.footer.find(selector), infos, 2); |
| 292 | + replacePlaceHolder(options, header, infos, 1); |
| 293 | + replacePlaceHolder(options, footer, infos, 2); |
277 | 294 | } |
278 | 295 | } |
279 | 296 |
|
|
282 | 299 | if (options.navigation !== 0) |
283 | 300 | { |
284 | 301 | var instance = getInstance(element), |
285 | | - tpl = options.templates, |
| 302 | + selector = getSelector(options.css.pagination), |
| 303 | + header = instance.header.find(selector)._bgShowAria(context.rowCount !== -1), |
| 304 | + footer = instance.footer.find(selector)._bgShowAria(context.rowCount !== -1); |
| 305 | + |
| 306 | + if (context.rowCount === -1) |
| 307 | + { |
| 308 | + return; |
| 309 | + } |
| 310 | + |
| 311 | + var tpl = options.templates, |
286 | 312 | current = context.current, |
287 | 313 | totalPages = context.totalPages, |
288 | 314 | pagination = $(tpl.pagination.resolve(getParams(context))), |
|
292 | 318 | Math.max(offsetLeft, 1) : |
293 | 319 | Math.max((offsetLeft - options.padding + offsetRight), 1)), |
294 | 320 | maxCount = options.padding * 2 + 1, |
295 | | - count = (totalPages >= maxCount) ? maxCount : totalPages, |
296 | | - selector = getSelector(options.css.pagination); |
| 321 | + count = (totalPages >= maxCount) ? maxCount : totalPages; |
297 | 322 |
|
298 | 323 | renderPaginationItem(element, options, context, pagination, "first", "«", "first") |
299 | 324 | ._bgEnableAria(current > 1); |
|
307 | 332 | ._bgEnableAria()._bgSelectAria(pos === current); |
308 | 333 | } |
309 | 334 |
|
| 335 | + if (count === 0) |
| 336 | + { |
| 337 | + renderPaginationItem(element, options, context, pagination, 1, 1, "page-" + 1) |
| 338 | + ._bgEnableAria(false)._bgSelectAria(); |
| 339 | + } |
| 340 | + |
310 | 341 | renderPaginationItem(element, options, context, pagination, "next", ">", "next") |
311 | 342 | ._bgEnableAria(totalPages > current); |
312 | 343 | renderPaginationItem(element, options, context, pagination, "last", "»", "last") |
313 | 344 | ._bgEnableAria(totalPages > current); |
314 | 345 |
|
315 | | - replacePlaceHolder(options, instance.header.find(selector), pagination, 1); |
316 | | - replacePlaceHolder(options, instance.footer.find(selector), pagination, 2); |
| 346 | + replacePlaceHolder(options, header, pagination, 1); |
| 347 | + replacePlaceHolder(options, footer, pagination, 2); |
317 | 348 | } |
318 | 349 | } |
319 | 350 |
|
|
0 commit comments