mas01mj@640: /* mas01mj@640: * File: jquery.dataTables.js mas01mj@640: * Version: 1.5.2 mas01mj@640: * CVS: $Id$ mas01mj@640: * Description: Paginate, search and sort HTML tables mas01mj@640: * Author: Allan Jardine (www.sprymedia.co.uk) mas01mj@640: * Created: 28/3/2008 mas01mj@640: * Modified: $Date$ by $Author$ mas01mj@640: * Language: Javascript mas01mj@640: * License: GPL v2 or BSD 3 point style mas01mj@640: * Project: Mtaala mas01mj@640: * Contact: allan.jardine@sprymedia.co.uk mas01mj@640: * mas01mj@640: * Copyright 2008-2009 Allan Jardine, all rights reserved. mas01mj@640: * mas01mj@640: * This source file is free software, under either the GPL v2 license or a mas01mj@640: * BSD style license, as supplied with this software. mas01mj@640: * mas01mj@640: * This source file is distributed in the hope that it will be useful, but mas01mj@640: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY mas01mj@640: * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. mas01mj@640: * mas01mj@640: * For details pleease refer to: http://www.datatables.net mas01mj@640: */ mas01mj@640: mas01mj@640: /* mas01mj@640: * When considering jsLint, we need to allow eval() as it it is used for reading cookies and mas01mj@640: * building the dynamic multi-column sort functions. mas01mj@640: */ mas01mj@640: /*jslint evil: true, undef: true, browser: true */ mas01mj@640: /*globals $, jQuery,_fnReadCookie,_fnProcessingDisplay,_fnDraw,_fnSort,_fnReDraw,_fnDetectType,_fnSortingClasses,_fnSettingsFromNode,_fnBuildSearchArray,_fnCalculateEnd,_fnFeatureHtmlProcessing,_fnFeatureHtmlPaginate,_fnFeatureHtmlInfo,_fnFeatureHtmlFilter,_fnFilter,_fnSaveState,_fnFilterColumn,_fnEscapeRegex,_fnFilterComplete,_fnFeatureHtmlLength,_fnGetDataMaster,_fnVisibleToColumnIndex,_fnDrawHead,_fnAddData,_fnGetTrNodes,_fnColumnIndexToVisible,_fnCreateCookie,_fnAddOptionsHtml,_fnMap,_fnClearTable,_fnDataToSearch,_fnReOrderIndex,_fnFilterCustom,_fnVisbleColumns,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnColumnOrdering,fnGetMaxLenString*/ mas01mj@640: mas01mj@640: (function($) { mas01mj@640: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * mas01mj@640: * DataTables variables mas01mj@640: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: dataTableSettings mas01mj@640: * Purpose: Store the settings for each dataTables instance mas01mj@640: * Scope: jQuery.fn mas01mj@640: */ mas01mj@640: $.fn.dataTableSettings = []; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: dataTableExt mas01mj@640: * Purpose: Container for customisable parts of DataTables mas01mj@640: * Scope: jQuery.fn mas01mj@640: */ mas01mj@640: $.fn.dataTableExt = {}; mas01mj@640: var _oExt = $.fn.dataTableExt; /* Short reference for fast internal lookup */ mas01mj@640: mas01mj@640: mas01mj@640: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * mas01mj@640: * DataTables extensible objects mas01mj@640: * mas01mj@640: * The _oExt object is used to provide an area where user dfined plugins can be mas01mj@640: * added to DataTables. The following properties of the object are used: mas01mj@640: * oApi - Plug-in API functions mas01mj@640: * aTypes - Auto-detection of types mas01mj@640: * oSort - Sorting functions used by DataTables (based on the type) mas01mj@640: * oPagination - Pagination functions for different input styles mas01mj@640: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: sVersion mas01mj@640: * Purpose: Version string for plug-ins to check compatibility mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.sVersion = "1.5.2"; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: iApiIndex mas01mj@640: * Purpose: Index for what 'this' index API functions should use mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.iApiIndex = 0; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: oApi mas01mj@640: * Purpose: Container for plugin API functions mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.oApi = { }; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: aFiltering mas01mj@640: * Purpose: Container for plugin filtering functions mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.afnFiltering = [ ]; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: aoFeatures mas01mj@640: * Purpose: Container for plugin function functions mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: * Notes: Array of objects with the following parameters: mas01mj@640: * fnInit: Function for initialisation of Feature. Takes oSettings and returns node mas01mj@640: * cFeature: Character that will be matched in sDom - case sensitive mas01mj@640: * sFeature: Feature name - just for completeness :-) mas01mj@640: */ mas01mj@640: _oExt.aoFeatures = [ ]; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: ofnSearch mas01mj@640: * Purpose: Container for custom filtering functions mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: * Notes: This is an object (the name should match the type) for custom filtering function, mas01mj@640: * which can be used for live DOM checking or formatted text filtering mas01mj@640: */ mas01mj@640: _oExt.ofnSearch = { }; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: oStdClasses mas01mj@640: * Purpose: Storage for the various classes that DataTables uses mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.oStdClasses = { mas01mj@640: /* Two buttons buttons */ mas01mj@640: "sPagePrevEnabled": "paginate_enabled_previous", mas01mj@640: "sPagePrevDisabled": "paginate_disabled_previous", mas01mj@640: "sPageNextEnabled": "paginate_enabled_next", mas01mj@640: "sPageNextDisabled": "paginate_disabled_next", mas01mj@640: "sPageJUINext": "", mas01mj@640: "sPageJUIPrev": "", mas01mj@640: mas01mj@640: /* Full numbers paging buttons */ mas01mj@640: "sPageButton": "paginate_button", mas01mj@640: "sPageButtonActive": "paginate_active", mas01mj@640: "sPageButtonStaticActive": "paginate_button", mas01mj@640: "sPageFirst": "first", mas01mj@640: "sPagePrevious": "previous", mas01mj@640: "sPageNext": "next", mas01mj@640: "sPageLast": "last", mas01mj@640: mas01mj@640: /* Stripping classes */ mas01mj@640: "sStripOdd": "odd", mas01mj@640: "sStripEven": "even", mas01mj@640: mas01mj@640: /* Empty row */ mas01mj@640: "sRowEmpty": "dataTables_empty", mas01mj@640: mas01mj@640: /* Features */ mas01mj@640: "sWrapper": "dataTables_wrapper", mas01mj@640: "sFilter": "dataTables_filter", mas01mj@640: "sInfo": "dataTables_info", mas01mj@640: "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */ mas01mj@640: "sLength": "dataTables_length", mas01mj@640: "sProcessing": "dataTables_processing", mas01mj@640: mas01mj@640: /* Sorting */ mas01mj@640: "sSortAsc": "sorting_asc", mas01mj@640: "sSortDesc": "sorting_desc", mas01mj@640: "sSortable": "sorting", mas01mj@640: "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */ mas01mj@640: "sSortJUIAsc": "", mas01mj@640: "sSortJUIDesc": "", mas01mj@640: "sSortJUI": "" mas01mj@640: }; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: oJUIClasses mas01mj@640: * Purpose: Storage for the various classes that DataTables uses - jQuery UI suitable mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.oJUIClasses = { mas01mj@640: /* Two buttons buttons */ mas01mj@640: "sPagePrevEnabled": "fg-button ui-state-default ui-corner-left", mas01mj@640: "sPagePrevDisabled": "fg-button ui-state-default ui-corner-left ui-state-disabled", mas01mj@640: "sPageNextEnabled": "fg-button ui-state-default ui-corner-right", mas01mj@640: "sPageNextDisabled": "fg-button ui-state-default ui-corner-right ui-state-disabled", mas01mj@640: "sPageJUINext": "ui-icon ui-icon-circle-arrow-e", mas01mj@640: "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w", mas01mj@640: mas01mj@640: /* Full numbers paging buttons */ mas01mj@640: "sPageButton": "fg-button ui-state-default", mas01mj@640: "sPageButtonActive": "fg-button ui-state-default ui-state-disabled", mas01mj@640: "sPageButtonStaticActive": "fg-button ui-state-default ui-state-disabled", mas01mj@640: "sPageFirst": "first ui-corner-tl ui-corner-bl", mas01mj@640: "sPagePrevious": "previous", mas01mj@640: "sPageNext": "next", mas01mj@640: "sPageLast": "last ui-corner-tr ui-corner-br", mas01mj@640: mas01mj@640: /* Stripping classes */ mas01mj@640: "sStripOdd": "odd", mas01mj@640: "sStripEven": "even", mas01mj@640: mas01mj@640: /* Empty row */ mas01mj@640: "sRowEmpty": "dataTables_empty", mas01mj@640: mas01mj@640: /* Features */ mas01mj@640: "sWrapper": "dataTables_wrapper", mas01mj@640: "sFilter": "dataTables_filter", mas01mj@640: "sInfo": "dataTables_info", mas01mj@640: "sPaging": "dataTables_paginate fg-buttonset fg-buttonset-multi paging_", /* Note that the type is postfixed */ mas01mj@640: "sLength": "dataTables_length", mas01mj@640: "sProcessing": "dataTables_processing", mas01mj@640: mas01mj@640: /* Sorting */ mas01mj@640: "sSortAsc": "ui-state-default", mas01mj@640: "sSortDesc": "ui-state-default", mas01mj@640: "sSortable": "ui-state-default", mas01mj@640: "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */ mas01mj@640: "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n", mas01mj@640: "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s", mas01mj@640: "sSortJUI": "css_right ui-icon ui-icon-triangle-2-n-s" mas01mj@640: }; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: oPagination mas01mj@640: * Purpose: Container for the various type of pagination that dataTables supports mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: */ mas01mj@640: _oExt.oPagination = { mas01mj@640: /* mas01mj@640: * Variable: two_button mas01mj@640: * Purpose: Standard two button (forward/back) pagination mas01mj@640: * Scope: jQuery.fn.dataTableExt.oPagination mas01mj@640: */ mas01mj@640: "two_button": { mas01mj@640: /* mas01mj@640: * Function: oPagination.two_button.fnInit mas01mj@640: * Purpose: Initalise dom elements required for pagination with forward/back buttons only mas01mj@640: * Returns: - mas01mj@640: * Inputs: object:oSettings - dataTables settings object mas01mj@640: * function:fnCallbackDraw - draw function which must be called on update mas01mj@640: */ mas01mj@640: "fnInit": function ( oSettings, fnCallbackDraw ) mas01mj@640: { mas01mj@640: var nPaging = oSettings.anFeatures.p; mas01mj@640: mas01mj@640: /* Store the next and previous elements in the oSettings object as they can be very mas01mj@640: * usful for automation - particularly testing mas01mj@640: */ mas01mj@640: if ( !oSettings.bJUI ) mas01mj@640: { mas01mj@640: oSettings.nPrevious = document.createElement( 'div' ); mas01mj@640: oSettings.nNext = document.createElement( 'div' ); mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: oSettings.nPrevious = document.createElement( 'a' ); mas01mj@640: oSettings.nNext = document.createElement( 'a' ); mas01mj@640: mas01mj@640: var nNextInner = document.createElement('span'); mas01mj@640: nNextInner.className = oSettings.oClasses.sPageJUINext; mas01mj@640: oSettings.nNext.appendChild( nNextInner ); mas01mj@640: mas01mj@640: var nPreviousInner = document.createElement('span'); mas01mj@640: nPreviousInner.className = oSettings.oClasses.sPageJUIPrev; mas01mj@640: oSettings.nPrevious.appendChild( nPreviousInner ); mas01mj@640: } mas01mj@640: mas01mj@640: if ( oSettings.sTableId !== '' ) mas01mj@640: { mas01mj@640: nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' ); mas01mj@640: oSettings.nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' ); mas01mj@640: oSettings.nNext.setAttribute( 'id', oSettings.sTableId+'_next' ); mas01mj@640: } mas01mj@640: mas01mj@640: oSettings.nPrevious.className = oSettings.oClasses.sPagePrevDisabled; mas01mj@640: oSettings.nNext.className = oSettings.oClasses.sPageNextDisabled; mas01mj@640: mas01mj@640: oSettings.nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious; mas01mj@640: oSettings.nNext.title = oSettings.oLanguage.oPaginate.sNext; mas01mj@640: mas01mj@640: nPaging.appendChild( oSettings.nPrevious ); mas01mj@640: nPaging.appendChild( oSettings.nNext ); mas01mj@640: $(nPaging).insertAfter( oSettings.nTable ); mas01mj@640: mas01mj@640: $(oSettings.nPrevious).click( function() { mas01mj@640: oSettings._iDisplayStart -= oSettings._iDisplayLength; mas01mj@640: mas01mj@640: /* Correct for underrun */ mas01mj@640: if ( oSettings._iDisplayStart < 0 ) mas01mj@640: { mas01mj@640: oSettings._iDisplayStart = 0; mas01mj@640: } mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: $(oSettings.nNext).click( function() { mas01mj@640: /* Make sure we are not over running the display array */ mas01mj@640: if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) mas01mj@640: { mas01mj@640: oSettings._iDisplayStart += oSettings._iDisplayLength; mas01mj@640: } mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: /* Take the brutal approach to cancelling text selection */ mas01mj@640: $(oSettings.nPrevious).bind( 'selectstart', function () { return false; } ); mas01mj@640: $(oSettings.nNext).bind( 'selectstart', function () { return false; } ); mas01mj@640: }, mas01mj@640: mas01mj@640: /* mas01mj@640: * Function: oPagination.two_button.fnUpdate mas01mj@640: * Purpose: Update the two button pagination at the end of the draw mas01mj@640: * Returns: - mas01mj@640: * Inputs: object:oSettings - dataTables settings object mas01mj@640: * function:fnCallbackDraw - draw function which must be called on update mas01mj@640: */ mas01mj@640: "fnUpdate": function ( oSettings, fnCallbackDraw ) mas01mj@640: { mas01mj@640: if ( !oSettings.anFeatures.p ) mas01mj@640: { mas01mj@640: return; mas01mj@640: } mas01mj@640: mas01mj@640: oSettings.nPrevious.className = mas01mj@640: ( oSettings._iDisplayStart === 0 ) ? mas01mj@640: oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled; mas01mj@640: mas01mj@640: oSettings.nNext.className = mas01mj@640: ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ? mas01mj@640: oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled; mas01mj@640: } mas01mj@640: }, mas01mj@640: mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: iFullNumbersShowPages mas01mj@640: * Purpose: Change the number of pages which can be seen mas01mj@640: * Scope: jQuery.fn.dataTableExt.oPagination mas01mj@640: */ mas01mj@640: "iFullNumbersShowPages": 5, mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: full_numbers mas01mj@640: * Purpose: Full numbers pagination mas01mj@640: * Scope: jQuery.fn.dataTableExt.oPagination mas01mj@640: */ mas01mj@640: "full_numbers": { mas01mj@640: /* mas01mj@640: * Function: oPagination.full_numbers.fnInit mas01mj@640: * Purpose: Initalise dom elements required for pagination with a list of the pages mas01mj@640: * Returns: - mas01mj@640: * Inputs: object:oSettings - dataTables settings object mas01mj@640: * function:fnCallbackDraw - draw function which must be called on update mas01mj@640: */ mas01mj@640: "fnInit": function ( oSettings, fnCallbackDraw ) mas01mj@640: { mas01mj@640: var nPaging = oSettings.anFeatures.p; mas01mj@640: var nFirst = document.createElement( 'span' ); mas01mj@640: var nPrevious = document.createElement( 'span' ); mas01mj@640: var nList = document.createElement( 'span' ); mas01mj@640: var nNext = document.createElement( 'span' ); mas01mj@640: var nLast = document.createElement( 'span' ); mas01mj@640: mas01mj@640: nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst; mas01mj@640: nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious; mas01mj@640: nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext; mas01mj@640: nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast; mas01mj@640: mas01mj@640: var oClasses = oSettings.oClasses; mas01mj@640: nFirst.className = oClasses.sPageButton+" "+oClasses.sPageFirst; mas01mj@640: nPrevious.className = oClasses.sPageButton+" "+oClasses.sPagePrevious; mas01mj@640: nNext.className= oClasses.sPageButton+" "+oClasses.sPageNext; mas01mj@640: nLast.className = oClasses.sPageButton+" "+oClasses.sPageLast; mas01mj@640: mas01mj@640: if ( oSettings.sTableId !== '' ) mas01mj@640: { mas01mj@640: nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' ); mas01mj@640: nFirst.setAttribute( 'id', oSettings.sTableId+'_first' ); mas01mj@640: nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' ); mas01mj@640: nNext.setAttribute( 'id', oSettings.sTableId+'_next' ); mas01mj@640: nLast.setAttribute( 'id', oSettings.sTableId+'_last' ); mas01mj@640: } mas01mj@640: mas01mj@640: nPaging.appendChild( nFirst ); mas01mj@640: nPaging.appendChild( nPrevious ); mas01mj@640: nPaging.appendChild( nList ); mas01mj@640: nPaging.appendChild( nNext ); mas01mj@640: nPaging.appendChild( nLast ); mas01mj@640: mas01mj@640: $(nFirst).click( function () { mas01mj@640: oSettings._iDisplayStart = 0; mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: $(nPrevious).click( function() { mas01mj@640: oSettings._iDisplayStart -= oSettings._iDisplayLength; mas01mj@640: mas01mj@640: /* Correct for underrun */ mas01mj@640: if ( oSettings._iDisplayStart < 0 ) mas01mj@640: { mas01mj@640: oSettings._iDisplayStart = 0; mas01mj@640: } mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: $(nNext).click( function() { mas01mj@640: /* Make sure we are not over running the display array */ mas01mj@640: if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) mas01mj@640: { mas01mj@640: oSettings._iDisplayStart += oSettings._iDisplayLength; mas01mj@640: } mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: $(nLast).click( function() { mas01mj@640: var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1; mas01mj@640: oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength; mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: } ); mas01mj@640: mas01mj@640: /* Take the brutal approach to cancelling text selection */ mas01mj@640: $('span', nPaging).bind( 'mousedown', function () { return false; } ); mas01mj@640: $('span', nPaging).bind( 'selectstart', function () { return false; } ); mas01mj@640: mas01mj@640: oSettings.nPaginateList = nList; mas01mj@640: }, mas01mj@640: mas01mj@640: /* mas01mj@640: * Function: oPagination.full_numbers.fnUpdate mas01mj@640: * Purpose: Update the list of page buttons shows mas01mj@640: * Returns: - mas01mj@640: * Inputs: object:oSettings - dataTables settings object mas01mj@640: * function:fnCallbackDraw - draw function which must be called on update mas01mj@640: */ mas01mj@640: "fnUpdate": function ( oSettings, fnCallbackDraw ) mas01mj@640: { mas01mj@640: if ( !oSettings.anFeatures.p ) mas01mj@640: { mas01mj@640: return; mas01mj@640: } mas01mj@640: mas01mj@640: var iPageCount = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages; mas01mj@640: var iPageCountHalf = Math.floor(iPageCount / 2); mas01mj@640: var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength); mas01mj@640: var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1; mas01mj@640: var sList = ""; mas01mj@640: var iStartButton; mas01mj@640: var iEndButton; mas01mj@640: var oClasses = oSettings.oClasses; mas01mj@640: mas01mj@640: if (iPages < iPageCount) mas01mj@640: { mas01mj@640: iStartButton = 1; mas01mj@640: iEndButton = iPages; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: if (iCurrentPage <= iPageCountHalf) mas01mj@640: { mas01mj@640: iStartButton = 1; mas01mj@640: iEndButton = iPageCount; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: if (iCurrentPage >= (iPages - iPageCountHalf)) mas01mj@640: { mas01mj@640: iStartButton = iPages - iPageCount + 1; mas01mj@640: iEndButton = iPages; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1; mas01mj@640: iEndButton = iStartButton + iPageCount - 1; mas01mj@640: } mas01mj@640: } mas01mj@640: } mas01mj@640: mas01mj@640: for ( var i=iStartButton ; i<=iEndButton ; i++ ) mas01mj@640: { mas01mj@640: if ( iCurrentPage != i ) mas01mj@640: { mas01mj@640: sList += ''+i+''; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: sList += ''+i+''; mas01mj@640: } mas01mj@640: } mas01mj@640: mas01mj@640: oSettings.nPaginateList.innerHTML = sList; mas01mj@640: mas01mj@640: /* Take the brutal approach to cancelling text selection */ mas01mj@640: $('span', oSettings.nPaginateList).bind( 'mousedown', function () { return false; } ); mas01mj@640: $('span', oSettings.nPaginateList).bind( 'selectstart', function () { return false; } ); mas01mj@640: mas01mj@640: $('span', oSettings.nPaginateList).click( function() { mas01mj@640: var iTarget = (this.innerHTML * 1) - 1; mas01mj@640: oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength; mas01mj@640: mas01mj@640: fnCallbackDraw( oSettings ); mas01mj@640: return false; mas01mj@640: } ); mas01mj@640: mas01mj@640: /* Update the 'premanent botton's classes */ mas01mj@640: var nButtons = $('span', oSettings.anFeatures.p); mas01mj@640: var nStatic = [ nButtons[0], nButtons[1], nButtons[nButtons.length-2], nButtons[nButtons.length-1] ]; mas01mj@640: $(nStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive ); mas01mj@640: if ( iCurrentPage == 1 ) mas01mj@640: { mas01mj@640: nStatic[0].className += " "+oClasses.sPageButtonStaticActive; mas01mj@640: nStatic[1].className += " "+oClasses.sPageButtonStaticActive; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: nStatic[0].className += " "+oClasses.sPageButton; mas01mj@640: nStatic[1].className += " "+oClasses.sPageButton; mas01mj@640: } mas01mj@640: mas01mj@640: if ( iCurrentPage == iPages ) mas01mj@640: { mas01mj@640: nStatic[2].className += " "+oClasses.sPageButtonStaticActive; mas01mj@640: nStatic[3].className += " "+oClasses.sPageButtonStaticActive; mas01mj@640: } mas01mj@640: else mas01mj@640: { mas01mj@640: nStatic[2].className += " "+oClasses.sPageButton; mas01mj@640: nStatic[3].className += " "+oClasses.sPageButton; mas01mj@640: } mas01mj@640: } mas01mj@640: } mas01mj@640: }; mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: oSort mas01mj@640: * Purpose: Wrapper for the sorting functions that can be used in DataTables mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: * Notes: The functions provided in this object are basically standard javascript sort mas01mj@640: * functions - they expect two inputs which they then compare and then return a priority mas01mj@640: * result. For each sort method added, two functions need to be defined, an ascending sort and mas01mj@640: * a descending sort. mas01mj@640: */ mas01mj@640: _oExt.oSort = { mas01mj@640: /* mas01mj@640: * text sorting mas01mj@640: */ mas01mj@640: "string-asc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a.toLowerCase(); mas01mj@640: var y = b.toLowerCase(); mas01mj@640: return ((x < y) ? -1 : ((x > y) ? 1 : 0)); mas01mj@640: }, mas01mj@640: mas01mj@640: "string-desc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a.toLowerCase(); mas01mj@640: var y = b.toLowerCase(); mas01mj@640: return ((x < y) ? 1 : ((x > y) ? -1 : 0)); mas01mj@640: }, mas01mj@640: mas01mj@640: mas01mj@640: /* mas01mj@640: * html sorting (ignore html tags) mas01mj@640: */ mas01mj@640: "html-asc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a.replace( /<.*?>/g, "" ).toLowerCase(); mas01mj@640: var y = b.replace( /<.*?>/g, "" ).toLowerCase(); mas01mj@640: return ((x < y) ? -1 : ((x > y) ? 1 : 0)); mas01mj@640: }, mas01mj@640: mas01mj@640: "html-desc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a.replace( /<.*?>/g, "" ).toLowerCase(); mas01mj@640: var y = b.replace( /<.*?>/g, "" ).toLowerCase(); mas01mj@640: return ((x < y) ? 1 : ((x > y) ? -1 : 0)); mas01mj@640: }, mas01mj@640: mas01mj@640: mas01mj@640: /* mas01mj@640: * date sorting mas01mj@640: */ mas01mj@640: "date-asc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = Date.parse( a ); mas01mj@640: var y = Date.parse( b ); mas01mj@640: mas01mj@640: if ( isNaN( x ) ) mas01mj@640: { mas01mj@640: x = Date.parse( "01/01/1970 00:00:00" ); mas01mj@640: } mas01mj@640: if ( isNaN( y ) ) mas01mj@640: { mas01mj@640: y = Date.parse( "01/01/1970 00:00:00" ); mas01mj@640: } mas01mj@640: mas01mj@640: return x - y; mas01mj@640: }, mas01mj@640: mas01mj@640: "date-desc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = Date.parse( a ); mas01mj@640: var y = Date.parse( b ); mas01mj@640: mas01mj@640: if ( isNaN( x ) ) mas01mj@640: { mas01mj@640: x = Date.parse( "01/01/1970 00:00:00" ); mas01mj@640: } mas01mj@640: if ( isNaN( y ) ) mas01mj@640: { mas01mj@640: y = Date.parse( "01/01/1970 00:00:00" ); mas01mj@640: } mas01mj@640: mas01mj@640: return y - x; mas01mj@640: }, mas01mj@640: mas01mj@640: mas01mj@640: /* mas01mj@640: * numerical sorting mas01mj@640: */ mas01mj@640: "numeric-asc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a == "-" ? 0 : a; mas01mj@640: var y = b == "-" ? 0 : b; mas01mj@640: return x - y; mas01mj@640: }, mas01mj@640: mas01mj@640: "numeric-desc": function ( a, b ) mas01mj@640: { mas01mj@640: var x = a == "-" ? 0 : a; mas01mj@640: var y = b == "-" ? 0 : b; mas01mj@640: return y - x; mas01mj@640: } mas01mj@640: }; mas01mj@640: mas01mj@640: mas01mj@640: /* mas01mj@640: * Variable: aTypes mas01mj@640: * Purpose: Container for the various type of type detection that dataTables supports mas01mj@640: * Scope: jQuery.fn.dataTableExt mas01mj@640: * Notes: The functions in this array are expected to parse a string to see if it is a data mas01mj@640: * type that it recognises. If so then the function should return the name of the type (a mas01mj@640: * corresponding sort function should be defined!), if the type is not recognised then the mas01mj@640: * function should return null such that the parser and move on to check the next type. mas01mj@640: * Note that ordering is important in this array - the functions are processed linearly, mas01mj@640: * starting at index 0. mas01mj@640: */ mas01mj@640: _oExt.aTypes = [ mas01mj@640: /* mas01mj@640: * Function: - mas01mj@640: * Purpose: Check to see if a string is numeric mas01mj@640: * Returns: string:'numeric' or null mas01mj@640: * Inputs: string:sText - string to check mas01mj@640: */ mas01mj@640: function ( sData ) mas01mj@640: { mas01mj@640: /* Snaity check that we are dealing with a string or quick return for a number */ mas01mj@640: if ( typeof sData == 'number' ) mas01mj@640: { mas01mj@640: return 'numeric'; mas01mj@640: } mas01mj@640: else if ( typeof sData.charAt != 'function' ) mas01mj@640: { mas01mj@640: return null; mas01mj@640: } mas01mj@640: mas01mj@640: var sValidFirstChars = "0123456789-"; mas01mj@640: var sValidChars = "0123456789."; mas01mj@640: var Char; mas01mj@640: var bDecimal = false; mas01mj@640: mas01mj@640: /* Check for a valid first char (no period and allow negatives) */ mas01mj@640: Char = sData.charAt(0); mas01mj@640: if (sValidFirstChars.indexOf(Char) == -1) mas01mj@640: { mas01mj@640: return null; mas01mj@640: } mas01mj@640: mas01mj@640: /* Check all the other characters are valid */ mas01mj@640: for ( var i=1 ; i