Fix datateble pagination

This commit is contained in:
Daniel Molina committed 2013-04-05 17:43:14 +02:00
1 parent edd5ab1756
commit 3769cb4b1f
16 files changed
+41 -89

No files matched your search

+2 -2
View File
@@ -36,8 +36,8 @@ function showTab(tabname,highlight_tab){
//we no longer expect #tab_id here, but simply tab_id
//So safety check - remove # from #tab_id if present to ensure compatibility
$('tbody input.check_item:checked').click();
$('td').removeClass('markrowchecked markrowselected');
//$('tbody input.check_item:checked').click();
//$('td').removeClass('markrowchecked markrowselected');
last_select_row = null;
if (tabname.indexOf('#') == 0)
+1 -6
View File
@@ -614,7 +614,6 @@ function setAclAutorefresh(){
$(document).ready(function(){
//if we are not oneadmin, our tab will not even be in the DOM.
dataTable_acls = $("#datatable_acls",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
@@ -622,11 +621,7 @@ $(document).ready(function(){
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [6]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
@@ -1811,18 +1811,13 @@ $(document).ready(function(){
//prepare host datatable
dataTable_clusters = $("#datatable_clusters",main_tabs_context).dataTable({
"sDom" :"<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] },
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#cluster_search').keyup(function(){
@@ -986,18 +986,13 @@ function setDatastoreAutorefresh(){
$(document).ready(function(){
dataTable_datastores = $("#datatable_datastores",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [6,7,8,9] }
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#datastore_search').keyup(function(){
+1 -6
View File
@@ -1042,7 +1042,6 @@ function popUpFileCloneDialog(){
$(document).ready(function(){
dataTable_files = $("#datatable_files",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
@@ -1053,11 +1052,7 @@ $(document).ready(function(){
{ "sWidth": "100px", "aTargets": [5,7] },
{ "sWidth": "150px", "aTargets": [8] },
{ "bVisible": false, "aTargets": [6,8,9,11,12]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#file_search').keyup(function(){
+1 -6
View File
@@ -795,15 +795,10 @@ function setGroupAutorefresh(){
$(document).ready(function(){
dataTable_groups = $("#datatable_groups",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] }
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
//addElement([
+1 -6
View File
@@ -1038,7 +1038,6 @@ $(document).ready(function(){
//prepare host datatable
dataTable_hosts = $("#datatable_hosts",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": { //exclude checkbox column
"aiExclude": [ 0 ]
},
@@ -1046,11 +1045,7 @@ $(document).ready(function(){
//{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1,4,9] }, //check, ID, RVMS, Status
{ "bVisible": false, "aTargets": [5,7,10,11,12]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#hosts_search').keyup(function(){
+1 -6
View File
@@ -1253,7 +1253,6 @@ function popUpImageCloneDialog(){
$(document).ready(function(){
dataTable_images = $("#datatable_images",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
@@ -1264,11 +1263,7 @@ $(document).ready(function(){
{ "sWidth": "100px", "aTargets": [5,7] },
{ "sWidth": "150px", "aTargets": [8] },
{ "bVisible": false, "aTargets": [6,8,12]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#image_search').keyup(function(){
@@ -285,7 +285,6 @@ function onlyOneCheckboxListener(dataTable) {
$(document).ready(function(){
dataTable_marketplace = $("#datatable_marketplace", main_tabs_context).dataTable({
"bSortClasses": true,
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"aoColumns": [
{ "bSortable": false,
"mData": function ( o, val, data ) {
@@ -304,11 +303,7 @@ $(document).ready(function(){
{ "mDataProp": "files.0.os-arch", "sWidth" : "100px"},
{ "mDataProp": "files.0.format", "sWidth" : "100px"},
{ "mDataProp": "tags", "bVisible": false}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
@@ -4153,7 +4153,6 @@ $(document).ready(function(){
"oColVis": {
"aiExclude": [ 0 ]
},
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] },
+1 -6
View File
@@ -1168,7 +1168,6 @@ function setUserAutorefresh(){
$(document).ready(function(){
//if we are not oneadmin, our tab will not even be in the DOM.
dataTable_users = $("#datatable_users",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
@@ -1176,11 +1175,7 @@ $(document).ready(function(){
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [8]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#user_search').keyup(function(){
+3 -6
View File
@@ -2981,7 +2981,6 @@ function vmMonitorError(req,error_json){
$(document).ready(function(){
dataTable_vMachines = $("#datatable_vmachines",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
@@ -2989,17 +2988,15 @@ $(document).ready(function(){
{ "bSortable": false, "aTargets": ["check"] },
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [6,7,10]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#vms_search').keyup(function(){
dataTable_vMachines.fnFilter( $(this).val() );
})
//addElement([
// spinner,
// '','','','','','','','','','',''],dataTable_vMachines);
+1 -6
View File
@@ -1320,18 +1320,13 @@ function setVNetAutorefresh() {
$(document).ready(function(){
dataTable_vNetworks = $("#datatable_vnetworks",main_tabs_context).dataTable({
"sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>",
"oColVis": {
"aiExclude": [ 0 ]
},
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [7]}
],
"oLanguage": (datatable_lang != "") ?
{
sUrl: "locale/"+lang+"/"+datatable_lang
} : ""
]
});
$('#vnet_search').keyup(function(){
+4 -4
View File
@@ -341,9 +341,9 @@ function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_to
function initCheckAllBoxes(datatable){
//small css hack
$('input.check_all',datatable).css({"border":"2px"});
$('input.check_all',datatable).live("change",function(){
var table = $(this).parents('table');
$('input.check_all').css({"border":"2px"});
$('input.check_all').live("change",function(){
var table = $(this).closest('.dataTables_wrapper');
var checked = $(this).attr('checked');
if (checked) { //check all
$('tbody input.check_item',table).attr('checked','checked');
@@ -443,7 +443,7 @@ function onError(request,error_json) {
//Used when refreshing elements of a datatable.
function waitingNodes(dataTable){
$('tr input.check_item:visible',dataTable).replaceWith(spinner);
recountCheckboxes(dataTable);
//recountCheckboxes(dataTable);
}
+2 -1
View File
@@ -828,4 +828,5 @@ form {
.dataTables_scrollBody {
margin-top: -3px;
}
}
@@ -1,12 +1,13 @@
/* Set the defaults for DataTables initialisation */
$.extend( true, $.fn.dataTable.defaults, {
"sDom": "<'row'<'six columns'l><'six columns'f>r><'row'<'twelve columns't>><'row'<'six columns'i><'six columns'p>>",
"sDom": "<'H'>t<'row'<'four columns'l><'six columns'p>>",
"sPaginationType": "foundation",
"oLanguage": {
"sLengthMenu": 'Show <form class="custom dataTables"><select><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select></form> entries'
"sLengthMenu": '<select><option value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option></select> rows'
}
} );
/* API method to get paging information */
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
{
@@ -34,14 +35,18 @@ $.extend( $.fn.dataTableExt.oPagination, {
};
$(nPaging).addClass('pagination').append(
'<ul class="pagination">'+
'<li class="arrow unavailable"><a href="#">&laquo; '+oLang.sPrevious+'</a></li>'+
'<li class="arrow unavailable"><a href="#">'+oLang.sNext+' &raquo; </a></li>'+
'<ul class="pagination">' +
'<li class="prev unavailable"><a href="#"><i class="icon-double-angle-left"/></a></li>' +
'<li class="prev unavailable"><a href="#"><i class="icon-angle-left"/></a></li>'+
'<li class="next unavailable"><a href="#"><i class="icon-angle-right"/></a></li>' +
'<li class="next unavailable"><a href="#"><i class="icon-double-angle-right"/></a></li>' +
'</ul>'
);
var els = $('a', nPaging);
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
$(els[0]).bind('click.DT', { action: "first" }, fnClickHandler);
$(els[1]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
$(els[2]).bind('click.DT', { action: "next" }, fnClickHandler);
$(els[3]).bind('click.DT', { action: "last" }, fnClickHandler);
},
"fnUpdate": function ( oSettings, fnDraw ) {
@@ -67,31 +72,31 @@ $.extend( $.fn.dataTableExt.oPagination, {
for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
// Remove the middle elements
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
$('li:gt(1)', an[i]).filter(':not(.next)').remove();
// Add the new list items and their event handlers
for ( j=iStart ; j<=iEnd ; j++ ) {
sClass = (j==oPaging.iPage+1) ? 'class="current"' : '';
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
.insertBefore( $('li:last', an[i])[0] )
.insertBefore( $('li.next:first', an[i])[0] )
.bind('click', function (e) {
e.preventDefault();
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
fnDraw( oSettings );
});
}
// Add / remove disabled classes from the static elements
if ( oPaging.iPage === 0 ) {
$('li:first', an[i]).addClass('unavailable');
$('li.prev', an[i]).addClass('unavailable');
} else {
$('li:first', an[i]).removeClass('unavailable');
$('li.prev', an[i]).removeClass('unavailable');
}
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
$('li:last', an[i]).addClass('unavailable');
$('li.next', an[i]).addClass('unavailable');
} else {
$('li:last', an[i]).removeClass('unavailable');
$('li.next', an[i]).removeClass('unavailable');
}
}
}