First Initial
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
|
||||
$.extend( DataTable.ext.oStdClasses, {
|
||||
"sTable": "dataTable",
|
||||
|
||||
/* Two buttons buttons */
|
||||
"sPagePrevEnabled": "paginate_enabled_previous",
|
||||
"sPagePrevDisabled": "paginate_disabled_previous",
|
||||
"sPageNextEnabled": "paginate_enabled_next",
|
||||
"sPageNextDisabled": "paginate_disabled_next",
|
||||
"sPageJUINext": "",
|
||||
"sPageJUIPrev": "",
|
||||
|
||||
/* Full numbers paging buttons */
|
||||
"sPageButton": "paginate_button",
|
||||
"sPageButtonActive": "paginate_active",
|
||||
"sPageButtonStaticDisabled": "paginate_button paginate_button_disabled",
|
||||
"sPageFirst": "first",
|
||||
"sPagePrevious": "previous",
|
||||
"sPageNext": "next",
|
||||
"sPageLast": "last",
|
||||
|
||||
/* Striping classes */
|
||||
"sStripeOdd": "odd",
|
||||
"sStripeEven": "even",
|
||||
|
||||
/* Empty row */
|
||||
"sRowEmpty": "dataTables_empty",
|
||||
|
||||
/* Features */
|
||||
"sWrapper": "dataTables_wrapper",
|
||||
"sFilter": "dataTables_filter",
|
||||
"sInfo": "dataTables_info",
|
||||
"sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
|
||||
"sLength": "dataTables_length",
|
||||
"sProcessing": "dataTables_processing",
|
||||
|
||||
/* Sorting */
|
||||
"sSortAsc": "sorting_asc",
|
||||
"sSortDesc": "sorting_desc",
|
||||
"sSortable": "sorting", /* Sortable in both directions */
|
||||
"sSortableAsc": "sorting_asc_disabled",
|
||||
"sSortableDesc": "sorting_desc_disabled",
|
||||
"sSortableNone": "sorting_disabled",
|
||||
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
|
||||
"sSortJUIAsc": "",
|
||||
"sSortJUIDesc": "",
|
||||
"sSortJUI": "",
|
||||
"sSortJUIAscAllowed": "",
|
||||
"sSortJUIDescAllowed": "",
|
||||
"sSortJUIWrapper": "",
|
||||
"sSortIcon": "",
|
||||
|
||||
/* Scrolling */
|
||||
"sScrollWrapper": "dataTables_scroll",
|
||||
"sScrollHead": "dataTables_scrollHead",
|
||||
"sScrollHeadInner": "dataTables_scrollHeadInner",
|
||||
"sScrollBody": "dataTables_scrollBody",
|
||||
"sScrollFoot": "dataTables_scrollFoot",
|
||||
"sScrollFootInner": "dataTables_scrollFootInner",
|
||||
|
||||
/* Misc */
|
||||
"sFooterTH": "",
|
||||
"sJUIHeader": "",
|
||||
"sJUIFooter": ""
|
||||
} );
|
||||
|
||||
|
||||
$.extend( DataTable.ext.oJUIClasses, DataTable.ext.oStdClasses, {
|
||||
/* Two buttons buttons */
|
||||
"sPagePrevEnabled": "fg-button ui-button ui-state-default ui-corner-left",
|
||||
"sPagePrevDisabled": "fg-button ui-button ui-state-default ui-corner-left ui-state-disabled",
|
||||
"sPageNextEnabled": "fg-button ui-button ui-state-default ui-corner-right",
|
||||
"sPageNextDisabled": "fg-button ui-button ui-state-default ui-corner-right ui-state-disabled",
|
||||
"sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
|
||||
"sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
|
||||
|
||||
/* Full numbers paging buttons */
|
||||
"sPageButton": "fg-button ui-button ui-state-default",
|
||||
"sPageButtonActive": "fg-button ui-button ui-state-default ui-state-disabled",
|
||||
"sPageButtonStaticDisabled": "fg-button ui-button ui-state-default ui-state-disabled",
|
||||
"sPageFirst": "first ui-corner-tl ui-corner-bl",
|
||||
"sPageLast": "last ui-corner-tr ui-corner-br",
|
||||
|
||||
/* Features */
|
||||
"sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
|
||||
"ui-buttonset-multi paging_", /* Note that the type is postfixed */
|
||||
|
||||
/* Sorting */
|
||||
"sSortAsc": "ui-state-default",
|
||||
"sSortDesc": "ui-state-default",
|
||||
"sSortable": "ui-state-default",
|
||||
"sSortableAsc": "ui-state-default",
|
||||
"sSortableDesc": "ui-state-default",
|
||||
"sSortableNone": "ui-state-default",
|
||||
"sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
|
||||
"sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
|
||||
"sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
|
||||
"sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
|
||||
"sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s",
|
||||
"sSortJUIWrapper": "DataTables_sort_wrapper",
|
||||
"sSortIcon": "DataTables_sort_icon",
|
||||
|
||||
/* Scrolling */
|
||||
"sScrollHead": "dataTables_scrollHead ui-state-default",
|
||||
"sScrollFoot": "dataTables_scrollFoot ui-state-default",
|
||||
|
||||
/* Misc */
|
||||
"sFooterTH": "ui-state-default",
|
||||
"sJUIHeader": "fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix",
|
||||
"sJUIFooter": "fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"
|
||||
} );
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Variable: oPagination
|
||||
* Purpose:
|
||||
* Scope: jQuery.fn.dataTableExt
|
||||
*/
|
||||
$.extend( DataTable.ext.oPagination, {
|
||||
/*
|
||||
* Variable: two_button
|
||||
* Purpose: Standard two button (forward/back) pagination
|
||||
* Scope: jQuery.fn.dataTableExt.oPagination
|
||||
*/
|
||||
"two_button": {
|
||||
/*
|
||||
* Function: oPagination.two_button.fnInit
|
||||
* Purpose: Initialise dom elements required for pagination with forward/back buttons only
|
||||
* Returns: -
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
* node:nPaging - the DIV which contains this pagination control
|
||||
* function:fnCallbackDraw - draw function which must be called on update
|
||||
*/
|
||||
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
|
||||
{
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var oClasses = oSettings.oClasses;
|
||||
var fnClickHandler = function ( e ) {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
var sAppend = (!oSettings.bJUI) ?
|
||||
'<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
|
||||
'<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
|
||||
:
|
||||
'<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
|
||||
'<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
|
||||
$(nPaging).append( sAppend );
|
||||
|
||||
var els = $('a', nPaging);
|
||||
var nPrevious = els[0],
|
||||
nNext = els[1];
|
||||
|
||||
oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, fnClickHandler );
|
||||
oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
|
||||
|
||||
/* ID the first elements only */
|
||||
if ( !oSettings.aanFeatures.p )
|
||||
{
|
||||
nPaging.id = oSettings.sTableId+'_paginate';
|
||||
nPrevious.id = oSettings.sTableId+'_previous';
|
||||
nNext.id = oSettings.sTableId+'_next';
|
||||
|
||||
nPrevious.setAttribute('aria-controls', oSettings.sTableId);
|
||||
nNext.setAttribute('aria-controls', oSettings.sTableId);
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Function: oPagination.two_button.fnUpdate
|
||||
* Purpose: Update the two button pagination at the end of the draw
|
||||
* Returns: -
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
* function:fnCallbackDraw - draw function to call on page change
|
||||
*/
|
||||
"fnUpdate": function ( oSettings, fnCallbackDraw )
|
||||
{
|
||||
if ( !oSettings.aanFeatures.p )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oClasses = oSettings.oClasses;
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var nNode;
|
||||
|
||||
/* Loop over each instance of the pager */
|
||||
for ( var i=0, iLen=an.length ; i<iLen ; i++ )
|
||||
{
|
||||
nNode = an[i].firstChild;
|
||||
if ( nNode )
|
||||
{
|
||||
/* Previous page */
|
||||
nNode.className = ( oSettings._iDisplayStart === 0 ) ?
|
||||
oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
|
||||
|
||||
/* Next page */
|
||||
nNode = nNode.nextSibling;
|
||||
nNode.className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
|
||||
oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* Variable: iFullNumbersShowPages
|
||||
* Purpose: Change the number of pages which can be seen
|
||||
* Scope: jQuery.fn.dataTableExt.oPagination
|
||||
*/
|
||||
"iFullNumbersShowPages": 5,
|
||||
|
||||
/*
|
||||
* Variable: full_numbers
|
||||
* Purpose: Full numbers pagination
|
||||
* Scope: jQuery.fn.dataTableExt.oPagination
|
||||
*/
|
||||
"full_numbers": {
|
||||
/*
|
||||
* Function: oPagination.full_numbers.fnInit
|
||||
* Purpose: Initialise dom elements required for pagination with a list of the pages
|
||||
* Returns: -
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
* node:nPaging - the DIV which contains this pagination control
|
||||
* function:fnCallbackDraw - draw function which must be called on update
|
||||
*/
|
||||
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
|
||||
{
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var oClasses = oSettings.oClasses;
|
||||
var fnClickHandler = function ( e ) {
|
||||
if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
|
||||
{
|
||||
fnCallbackDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).append(
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageFirst+'">'+oLang.sFirst+'</a>'+
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPagePrevious+'">'+oLang.sPrevious+'</a>'+
|
||||
'<span></span>'+
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageNext+'">'+oLang.sNext+'</a>'+
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+" "+oClasses.sPageLast+'">'+oLang.sLast+'</a>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
var nFirst = els[0],
|
||||
nPrev = els[1],
|
||||
nNext = els[2],
|
||||
nLast = els[3];
|
||||
|
||||
oSettings.oApi._fnBindAction( nFirst, {action: "first"}, fnClickHandler );
|
||||
oSettings.oApi._fnBindAction( nPrev, {action: "previous"}, fnClickHandler );
|
||||
oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
|
||||
oSettings.oApi._fnBindAction( nLast, {action: "last"}, fnClickHandler );
|
||||
|
||||
/* ID the first elements only */
|
||||
if ( !oSettings.aanFeatures.p )
|
||||
{
|
||||
nPaging.id = oSettings.sTableId+'_paginate';
|
||||
nFirst.id =oSettings.sTableId+'_first';
|
||||
nPrev.id =oSettings.sTableId+'_previous';
|
||||
nNext.id =oSettings.sTableId+'_next';
|
||||
nLast.id =oSettings.sTableId+'_last';
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Function: oPagination.full_numbers.fnUpdate
|
||||
* Purpose: Update the list of page buttons shows
|
||||
* Returns: -
|
||||
* Inputs: object:oSettings - dataTables settings object
|
||||
* function:fnCallbackDraw - draw function to call on page change
|
||||
*/
|
||||
"fnUpdate": function ( oSettings, fnCallbackDraw )
|
||||
{
|
||||
if ( !oSettings.aanFeatures.p )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var iPageCount = DataTable.ext.oPagination.iFullNumbersShowPages;
|
||||
var iPageCountHalf = Math.floor(iPageCount / 2);
|
||||
var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
|
||||
var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
|
||||
var sList = "";
|
||||
var iStartButton, iEndButton, i, iLen;
|
||||
var oClasses = oSettings.oClasses;
|
||||
var anButtons, anStatic, nPaginateList, nNode;
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var fnBind = function (j) {
|
||||
oSettings.oApi._fnBindAction( this, {"page": j+iStartButton-1}, function(e) {
|
||||
/* Use the information in the element to jump to the required page */
|
||||
oSettings.oApi._fnPageChange( oSettings, e.data.page );
|
||||
fnCallbackDraw( oSettings );
|
||||
e.preventDefault();
|
||||
} );
|
||||
};
|
||||
|
||||
/* Pages calculation */
|
||||
if ( oSettings._iDisplayLength === -1 )
|
||||
{
|
||||
iStartButton = 1;
|
||||
iEndButton = 1;
|
||||
iCurrentPage = 1;
|
||||
}
|
||||
else if (iPages < iPageCount)
|
||||
{
|
||||
iStartButton = 1;
|
||||
iEndButton = iPages;
|
||||
}
|
||||
else if (iCurrentPage <= iPageCountHalf)
|
||||
{
|
||||
iStartButton = 1;
|
||||
iEndButton = iPageCount;
|
||||
}
|
||||
else if (iCurrentPage >= (iPages - iPageCountHalf))
|
||||
{
|
||||
iStartButton = iPages - iPageCount + 1;
|
||||
iEndButton = iPages;
|
||||
}
|
||||
else
|
||||
{
|
||||
iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
|
||||
iEndButton = iStartButton + iPageCount - 1;
|
||||
}
|
||||
|
||||
|
||||
/* Build the dynamic list */
|
||||
for ( i=iStartButton ; i<=iEndButton ; i++ )
|
||||
{
|
||||
sList += (iCurrentPage !== i) ?
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButton+'">'+oSettings.fnFormatNumber(i)+'</a>' :
|
||||
'<a tabindex="'+oSettings.iTabIndex+'" class="'+oClasses.sPageButtonActive+'">'+oSettings.fnFormatNumber(i)+'</a>';
|
||||
}
|
||||
|
||||
/* Loop over each instance of the pager */
|
||||
for ( i=0, iLen=an.length ; i<iLen ; i++ )
|
||||
{
|
||||
nNode = an[i];
|
||||
if ( !nNode.hasChildNodes() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Build up the dynamic list first - html and listeners */
|
||||
$('span:eq(0)', nNode)
|
||||
.html( sList )
|
||||
.children('a').each( fnBind );
|
||||
|
||||
/* Update the permanent button's classes */
|
||||
anButtons = nNode.getElementsByTagName('a');
|
||||
anStatic = [
|
||||
anButtons[0], anButtons[1],
|
||||
anButtons[anButtons.length-2], anButtons[anButtons.length-1]
|
||||
];
|
||||
|
||||
$(anStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive+" "+oClasses.sPageButtonStaticDisabled );
|
||||
$([anStatic[0], anStatic[1]]).addClass(
|
||||
(iCurrentPage==1) ?
|
||||
oClasses.sPageButtonStaticDisabled :
|
||||
oClasses.sPageButton
|
||||
);
|
||||
$([anStatic[2], anStatic[3]]).addClass(
|
||||
(iPages===0 || iCurrentPage===iPages || oSettings._iDisplayLength===-1) ?
|
||||
oClasses.sPageButtonStaticDisabled :
|
||||
oClasses.sPageButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
$.extend( DataTable.ext.oSort, {
|
||||
/*
|
||||
* text sorting
|
||||
*/
|
||||
"string-pre": function ( a )
|
||||
{
|
||||
if ( typeof a != 'string' ) {
|
||||
a = (a !== null && a.toString) ? a.toString() : '';
|
||||
}
|
||||
return a.toLowerCase();
|
||||
},
|
||||
|
||||
"string-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
},
|
||||
|
||||
"string-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* html sorting (ignore html tags)
|
||||
*/
|
||||
"html-pre": function ( a )
|
||||
{
|
||||
return a.replace( /<.*?>/g, "" ).toLowerCase();
|
||||
},
|
||||
|
||||
"html-asc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
},
|
||||
|
||||
"html-desc": function ( x, y )
|
||||
{
|
||||
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* date sorting
|
||||
*/
|
||||
"date-pre": function ( a )
|
||||
{
|
||||
var x = Date.parse( a );
|
||||
|
||||
if ( isNaN(x) || x==="" )
|
||||
{
|
||||
x = Date.parse( "01/01/1970 00:00:00" );
|
||||
}
|
||||
return x;
|
||||
},
|
||||
|
||||
"date-asc": function ( x, y )
|
||||
{
|
||||
return x - y;
|
||||
},
|
||||
|
||||
"date-desc": function ( x, y )
|
||||
{
|
||||
return y - x;
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* numerical sorting
|
||||
*/
|
||||
"numeric-pre": function ( a )
|
||||
{
|
||||
return (a=="-" || a==="") ? 0 : a*1;
|
||||
},
|
||||
|
||||
"numeric-asc": function ( x, y )
|
||||
{
|
||||
return x - y;
|
||||
},
|
||||
|
||||
"numeric-desc": function ( x, y )
|
||||
{
|
||||
return y - x;
|
||||
}
|
||||
} );
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
|
||||
$.extend( DataTable.ext.aTypes, [
|
||||
/*
|
||||
* Function: -
|
||||
* Purpose: Check to see if a string is numeric
|
||||
* Returns: string:'numeric' or null
|
||||
* Inputs: mixed:sText - string to check
|
||||
*/
|
||||
function ( sData )
|
||||
{
|
||||
/* Allow zero length strings as a number */
|
||||
if ( typeof sData === 'number' )
|
||||
{
|
||||
return 'numeric';
|
||||
}
|
||||
else if ( typeof sData !== 'string' )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var sValidFirstChars = "0123456789-";
|
||||
var sValidChars = "0123456789.";
|
||||
var Char;
|
||||
var bDecimal = false;
|
||||
|
||||
/* Check for a valid first char (no period and allow negatives) */
|
||||
Char = sData.charAt(0);
|
||||
if (sValidFirstChars.indexOf(Char) == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Check all the other characters are valid */
|
||||
for ( var i=1 ; i<sData.length ; i++ )
|
||||
{
|
||||
Char = sData.charAt(i);
|
||||
if (sValidChars.indexOf(Char) == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Only allowed one decimal place... */
|
||||
if ( Char == "." )
|
||||
{
|
||||
if ( bDecimal )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
bDecimal = true;
|
||||
}
|
||||
}
|
||||
|
||||
return 'numeric';
|
||||
},
|
||||
|
||||
/*
|
||||
* Function: -
|
||||
* Purpose: Check to see if a string is actually a formatted date
|
||||
* Returns: string:'date' or null
|
||||
* Inputs: string:sText - string to check
|
||||
*/
|
||||
function ( sData )
|
||||
{
|
||||
var iParse = Date.parse(sData);
|
||||
if ( (iParse !== null && !isNaN(iParse)) || (typeof sData === 'string' && sData.length === 0) )
|
||||
{
|
||||
return 'date';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/*
|
||||
* Function: -
|
||||
* Purpose: Check to see if a string should be treated as an HTML string
|
||||
* Returns: string:'html' or null
|
||||
* Inputs: string:sText - string to check
|
||||
*/
|
||||
function ( sData )
|
||||
{
|
||||
if ( typeof sData === 'string' && sData.indexOf('<') != -1 && sData.indexOf('>') != -1 )
|
||||
{
|
||||
return 'html';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
] );
|
||||
|
||||
Reference in New Issue
Block a user