Compare commits

..

85 Commits

Author SHA1 Message Date
Allan Jardine
ca12924904 Merge pull request #265 from TonyaSolaris/1_9
Updated dependencies to work with jQuery 2
2014-01-22 00:57:10 -08:00
TonyaSolaris
79238d337b Updated dependencies to work with jQuery 2 2014-01-21 16:04:36 -08:00
Allan Jardine
36ba2549ad Fix: JSON error in component.json 2012-10-26 08:11:00 +01:00
Allan Jardine
6c41618c71 Update: jQuery 1.8.2 2012-09-23 14:18:58 +01:00
Allan Jardine
822c62d05d DataTables 1.9.4 2012-09-23 14:16:14 +01:00
Allan Jardine
26d2926390 Fix: Ie9 throws an error when document.activeElement is used inside a frame or iframe... So need to wrap the test up in a try/catch. Nasty. 2012-09-23 13:12:39 +01:00
Allan Jardine
bd6bb74967 Fix: Header TD elements need an outline of none to stop of focus flicker (matching TH elements which already have this) 2012-09-19 07:27:52 +01:00
Allan Jardine
b4cd9f11c6 Fix: A header made of only TD elements wasn't being correctly detected - 11705 2012-09-19 07:27:11 +01:00
Allan Jardine
77a8cb5946 Update: jQuery to 1.8.1 2012-09-19 07:26:21 +01:00
Allan Jardine
d1142e1450 Fix: If the user is currently focused on the filtering input element, don't overwrite the value that is already shown as this will effect the cursor position. 2012-09-16 12:00:36 +01:00
Allan Jardine
a19e1dee12 Dev: Use className for the newly created TR - slightly faster than addClass which isn't needed here 2012-09-16 11:19:53 +01:00
Allan Jardine
55adb2f3d5 New: component.json file for Bower ( http://twitter.github.com/bower/ ) support. Both component.json and package.json are generated with the correct version number in them. 2012-09-15 10:52:19 +01:00
Allan Jardine
e25b377ee8 Fix: State saving deletion of cookies was somewhat broken. It would delete cookies out of order, which is not what we want. Rewrite how the 'overage' of cookies (4K limit) is handled 2012-09-13 18:13:32 +01:00
Allan Jardine
a43714bfba Fix - docs: sNext and sPrevious referened to full_numbers pagination type, but they can be used for any pagination control: 9192 2012-09-12 07:47:29 +01:00
Allan Jardine
66e92ab655 Fix - docs: Documentation error for fnGetPosition - missing one of the return indexes - 11708 2012-09-11 10:09:03 +01:00
Allan Jardine
ca96ed55d5 Fix: Remove irrelevent and broken bSortable check for the column options - fix issue #101 2012-09-11 07:04:41 +01:00
Allan Jardine
0a3793b4bb Dev: Tidy up the way that the header and footer elements are 'got'. Based on pull request #92. 2012-09-09 18:43:57 +01:00
Allan Jardine
df614240cf Update: Fully deprecate fnRender - it will be removed from the next major version of DataTables and it is strongly adviced that you do not use it! 2012-09-09 12:26:57 +01:00
Allan Jardine
f6401f062a Update: Examples - remove all reference of fnRender, instead granting preference to mRender. 2012-09-09 12:05:37 +01:00
Allan Jardine
880de42c6e Dev: Remove debug from last commit... 2012-09-09 12:05:20 +01:00
Allan Jardine
555aacfc6d Fix: mRender and mData now work in the same way for DOM sourced tables as they do for JS sourced table data. Generally we wouldn't really expect them to be used as much for DOM sourced tables (if you want your table formatted differently, you'd just create the HTML differently!), but it can sometimes be useful to use these options. This also brings mRender to full 'pace' ready to be used in complete preference to fnRender (alongside the other methods for cell rendeirng such an fnCellCreated etc). 2012-09-09 11:57:02 +01:00
Allan Jardine
898357fc84 Merge pull request #98 from timtucker/patch-14
Update media/src/core/core.sort.js
2012-09-04 09:38:03 -07:00
Allan Jardine
30f936d8ff Merge pull request #97 from timtucker/patch-13
Update media/src/core/core.info.js
2012-09-04 09:30:58 -07:00
Allan Jardine
6d11218a7f Merge pull request #96 from timtucker/patch-12
Update media/src/core/core.info.js
2012-09-04 09:30:06 -07:00
Allan Jardine
bb08308dfe Merge pull request #95 from timtucker/patch-11
Update media/src/core/core.sizing.js
2012-09-04 09:29:15 -07:00
Allan Jardine
3ffa14ea8a Merge pull request #94 from timtucker/patch-10
Update media/src/core/core.sizing.js
2012-09-04 09:28:07 -07:00
Allan Jardine
4603ad13d4 Merge pull request #93 from timtucker/patch-9
Update media/src/core/core.scrolling.js
2012-09-04 09:27:25 -07:00
Allan Jardine
95381359ed Merge pull request #91 from timtucker/patch-7
Update media/src/core/core.scrolling.js
2012-09-04 09:24:50 -07:00
Allan Jardine
fcf49ef66e Merge pull request #99 from timtucker/patch-15
Update media/src/DataTables.js
2012-09-04 09:19:57 -07:00
Tim Tucker
a66bec8368 Update media/src/DataTables.js
Simplify by not passing in undefined to the outer closure
2012-09-04 13:03:20 -03:00
Tim Tucker
89be8f4083 Update media/src/core/core.sort.js
Speed things up by applying classes only when needed
2012-09-04 11:05:53 -03:00
Tim Tucker
cb2495b440 Update media/src/core/core.sort.js
Use var to keep track of # of classes found (length on sparse array doesn't work properly)
2012-09-03 19:36:18 -03:00
Tim Tucker
6bce847a3b Update media/src/core/core.sort.js
Further refinement - stop once all sorting classes have been seen
2012-09-03 19:12:03 -03:00
Tim Tucker
2afa5e4360 Update media/src/core/core.sort.js
Combined method for removing classes
2012-09-03 18:21:01 -03:00
Tim Tucker
e6e4205b02 Update media/src/core/core.sort.js
Forgot parameter to lastIndexOf
2012-09-03 16:54:30 -03:00
Tim Tucker
6a5c4cf261 Update media/src/core/core.sort.js
Use simpler dom-based method for deferred render
2012-09-03 16:53:00 -03:00
Tim Tucker
24fc23f63d Update media/src/core/core.sort.js
Simplify and improve performance
- Only check once for the presence of any sorting class instead of checking for the 3 individual classes
- Use lastIndexOf(str, 0) instead of indexOf

http://jsperf.com/rep-reg-string/4
2012-09-03 16:29:28 -03:00
Tim Tucker
af5c3d8178 Update media/src/core/core.info.js
Simplify check for filtering / empty record set
2012-09-03 14:02:38 -03:00
Tim Tucker
3485f6530a Update media/src/core/core.info.js
Use greedy match regex for replacements

Otherwise, you could have:
"_START_ of _TOTAL_, showing _START_ to _END_"
replaced as:
"1 of 5, showing _START_ to 3"
2012-09-03 13:52:30 -03:00
Tim Tucker
ef1c0890df Update media/src/core/core.sizing.js
Use document.body rather than document.getElementsByTagName
(Makes things consistent with the rest of the codebase and should be faster)

http://jsperf.com/document-body-vs-document-getelementsbytagname-body-0
2012-09-03 13:34:10 -03:00
Tim Tucker
4cbb9f3196 Update media/src/core/core.sizing.js
Define nWrapper earlier to avoid calling dom to get the parentNode multiple times in the initial loop
2012-09-03 13:11:11 -03:00
Tim Tucker
f5a772c594 Update media/src/core/core.scrolling.js
Use o.nScrollHead / o.nScrollFoot rather than traversing through the dom again to get the parentNodes for nScrollHeadInner / nScroolFootInner
2012-09-03 13:02:05 -03:00
Tim Tucker
70cea14422 Update media/src/core/core.scrolling.js
Only pass in what's needed to _fnApplyToChildren (don't need to be passing in both the sizer and node to size in most cases).
2012-09-03 12:38:09 -03:00
Allan Jardine
59dc2aed9c Dev: Fix a couple of issues that were introduced in pull request #85 - 1. Mix of spaces and tabs :-). 2. documentation generation was broken due to the use of another closure, 3. minification was broken as window, document, undefined were been aliased and 4. jshint was throwing errors. This addresses those issues, primarily by shifting the closures around. 2012-09-02 10:33:49 +01:00
Allan Jardine
e69e3c6c1c Dev update: Commit built changes from Tim Tucker from last few merges 2012-09-02 09:49:17 +01:00
Allan Jardine
93b0c9ede7 Examples: update - bind the 'xhr' event to the table without calling DataTables - no need for that call to be made. 2012-09-02 09:48:45 +01:00
Allan Jardine
9c82abe79d Merge pull request #89 from timtucker/patch-6
Use hasChildNodes() rather than childNodes.length
2012-09-02 01:40:10 -07:00
Allan Jardine
a950fb0642 Merge pull request #88 from timtucker/patch-5
Update media/src/core/core.data.js
2012-09-02 01:38:58 -07:00
Allan Jardine
1fdfb65457 Merge pull request #87 from timtucker/patch-4
Allow adding / removing an arbitrary number of stripes
2012-09-02 01:37:58 -07:00
Allan Jardine
dd2f084794 Merge pull request #86 from timtucker/patch-3
Improve dom iteration performance in _fnApplyToChildren
2012-09-02 01:34:13 -07:00
Tim Tucker
30eb6f0426 Update media/src/ext/ext.paging.js
Cache node
2012-08-31 18:48:15 -03:00
Tim Tucker
55b8e6fd04 Update media/src/ext/ext.paging.js
Use a different approach that caches nodes
(may actually minify better as well)
2012-08-31 18:43:38 -03:00
Tim Tucker
0c0fef65c1 Update media/src/ext/ext.paging.js
Replace childNodes.length check with hasChildNodes() in one more place
2012-08-31 18:35:00 -03:00
Tim Tucker
d8d7759613 Update media/src/ext/ext.paging.js
Use hasChildNodes() rather than childNodes.length

See the following jsperf test for the difference in performance:
http://jsperf.com/haschildnodes-vs-childnodes-length
2012-08-31 18:32:01 -03:00
Tim Tucker
dd616424b9 Update media/src/core/core.support.js
Use firstChild / nextSibling rather than childNodes
2012-08-31 18:25:23 -03:00
Tim Tucker
1001a332fb Update media/src/core/core.data.js
_fnGatherData: Use firstChild / nextSibling to iterate rather than childNodes
2012-08-31 18:12:39 -03:00
Tim Tucker
845eaaab67 Update media/src/api/api.methods.js
Properly select every nth row for adding classes
2012-08-31 17:45:15 -03:00
Tim Tucker
82fad5ca50 Update media/src/api/api.methods.js
Allow for adding / removing an arbitrary number of stripe rows
2012-08-31 17:37:11 -03:00
Tim Tucker
75ce320838 Update media/src/core/core.constructor.js
Allow for adding / removing an arbitrary number of stripe rows
2012-08-31 17:31:00 -03:00
Tim Tucker
ce59c7403f Update media/src/core/core.scrolling.js
Tweaks to improve performance
Cache nodes
Restructure to use nextSibling rather than childNodes
(small increase in file size, but may be a slight decrease in minified size)
2012-08-31 16:25:35 -03:00
Allan Jardine
0d47107906 Merge pull request #84 from timtucker/master
Update to docs
2012-08-31 09:46:34 -07:00
Tim Tucker
3cc96cf58f Update media/src/core/core.draw.js
Cache row
Avoid array access to childNodes
Move unique calculation outside of loop
Declare all vars at head of function
Cache a[i] in fnShiftCol
2012-08-31 13:38:51 -03:00
Allan Jardine
25f4602b3c Merge pull request #85 from timtucker/patch-2
Update media/src/DataTables.js
2012-08-31 09:30:07 -07:00
Tim Tucker
37485da480 Update media/src/DataTables.js
Combine closures
2012-08-31 13:08:09 -03:00
Tim Tucker
66de941632 Update media/src/DataTables.js
Wrap with globals to ease minification
Fix check for preventing multiple instantiation
Change formatting
2012-08-31 12:39:28 -03:00
Tim Tucker
87b4055b7a Update media/src/DataTables.js
Add support for AMD-based module loaders (such as requirejs).
Should have no effect when loading normally.
2012-08-31 11:15:19 -03:00
Tim Tucker
6fa5559dc3 Update media/src/core/core.sizing.js
Doc update -- getWidestNode returns node, not string
2012-08-31 11:00:48 -03:00
Tim Tucker
08619a3a21 Update media/js/jquery.dataTables.js
Update doc to reflect that _fnGetWidestNode returns a node, not a string.
2012-08-31 10:48:55 -03:00
Allan Jardine
6855be79f5 Examples: Add <code> CSS markup for examples. 2012-08-30 19:32:31 +01:00
Allan Jardine
c2af41140b Performance: Large improvement in scrolling performance due to rearranging the way that column widths are read and applied to the target table. Rather than merging reading and writing together, we now seperate the reading and writing phases, allowing the browser's rendering engine to optimise the reflow. Props to jlabanca for this modification - 11541 2012-08-30 07:29:50 +01:00
Allan Jardine
9f8d2a632b Moving on to 1.9.4 development 2012-08-22 16:41:52 +01:00
Allan Jardine
34096537c2 Fix: Firefox Windows (not Mac) had an error when calculating if scrolling oversizing was needed or not (_fnBrowserDetect). The result was that the table did not fill the space when y-scrolling was enabled and Firefox Windows was used. Fix is to remove the height on the DT_BrowserTest parent as suggested by randomuser - 11406 2012-08-22 16:39:36 +01:00
Allan Jardine
93774f4d7d Merge branch 'master' of github.com:DataTables/DataTables 2012-08-22 16:39:25 +01:00
Allan Jardine
3c358417e0 Update: Updating to jQuery 1.8.0 2012-08-22 16:38:36 +01:00
Allan Jardine
e83488ab56 Merge pull request #83 from kycook/patch2
Only restore hidden columns if table is not being removed from DOM
2012-08-22 00:58:20 -07:00
Patrick Cook
05201c21c4 Modified destroy method to only restore hidden columns if the table is not
being removed from DOM
2012-08-21 12:43:13 -07:00
Allan Jardine
d62ac092a6 Merge pull request #82 from kycook/patch1
Added fix for memory leak because of potential circular reference
2012-08-16 00:27:29 -07:00
Patrick Cook
854612a399 Added fix for memory leak because of potential circular reference 2012-08-15 23:31:14 -07:00
Allan Jardine
bec8dc3651 Merge pull request #81 from kycook/master
Fixed memory leak
2012-08-15 07:17:03 -07:00
Patrick Cook
f6ffbc7e28 Memory clean up of _that variable 2012-08-15 07:08:48 -07:00
Allan Jardine
6a8ca62b07 Merge pull request #79 from iBiryukov/patch-2
Small Typo Fix
2012-08-10 10:53:47 -07:00
iBiryukov
e15342225c Small Typo Fix 2012-08-10 19:46:06 +02:00
Allan Jardine
0585beb0c9 Merge pull request #76 from nnguyen/false_args_in_fnDestroy
Update to use false value in bRemove arg in fnDestroy
2012-08-09 23:47:44 -07:00
Nguyen Nguyen
5ac94e2512 Move to the right place (src, not the generated file) 2012-08-10 01:36:55 -05:00
Nguyen Nguyen
f29bd9ffbf Update to use false value in bRemove arg in fnDestroy 2012-08-09 18:10:07 -05:00
28 changed files with 809 additions and 723 deletions

11
component.json Executable file
View File

@@ -0,0 +1,11 @@
{
"name": "DataTables",
"version": "1.9.4",
"main": [
"./media/js/jquery.dataTables.js",
"./media/css/jquery.dataTables.css"
],
"dependencies": {
"jquery": ">=1.7.0"
}
}

View File

@@ -16,8 +16,11 @@
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function ( oObj, sVal ) {
return sVal +' '+ oObj.aData[3];
// `data` refers to the data for the cell (defined by `mData`, which
// defaults to the column being worked with, in this case is the first
// Using `row[0]` is equivalent.
"mRender": function ( data, type, row ) {
return data +' '+ row[3];
},
"aTargets": [ 0 ]
},
@@ -35,7 +38,8 @@
</div>
<h1>Preamble</h1>
<p>You may specify a function for each column to render the available data in a specific manner which will be called when the table is drawn. In this example I've appended the rendering engine version to the rendering engine name in the first column, and hidden the version column.</p>
<p>Each column has an optional rendering control called <a href="http://datatables.net/ref#mRender">mRender</a> which can be used to process the content of each cell before the data is used. <code>mRender</code> has a wide array of options available to it for rendering different types of data (sorting, filtering, display etc), but it can be used very simply to manipulate the content of a cell, as shown here.</p>
<p>This example shows the rendering engine version combined with the rendering engine name in the first column, hiding the version column. This technique can be useful for adding links, assigning colours based on content rules and any other form of text manipulation you require.</p>
<h1>Live example</h1>
<div id="demo">
@@ -469,8 +473,11 @@
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function ( oObj, sVal ) {
return sVal +' '+ oObj.aData[3];
// `data` refers to the data for the cell (defined by `mData`, which
// defaults to the column being worked with, in this case is the first
// Using `row[0]` is equivalent.
"mRender": function ( data, type, row ) {
return data +' '+ row[3];
},
"aTargets": [ 0 ]
},

View File

@@ -36,7 +36,7 @@
</div>
<h1>Preamble</h1>
<p>The following example shows how a callback function can be used to format a particular row at draw time. For each row that is generated for display, the <b>fnRowCallback()</b> function is called. It is passed the row node which can then be modified. In this case a trivial example of making the 'grade' column bold if the grade is 'A' is shown (note that this could also be performed using the <b>fnRender()</b> function, but this is just for example).</p>
<p>The following example shows how a callback function can be used to format a particular row at draw time. For each row that is generated for display, the <b>fnRowCallback()</b> function is called. It is passed the row node which can then be modified. In this case a trivial example of making the 'grade' column bold if the grade is 'A' is shown (note that this could also be performed using <a href="http://datatables.net/ref#mData">mData</a> as a function, but this is just for example of fnRowCallback!).</p>
<h1>Live example</h1>
<div id="demo">

View File

@@ -82,17 +82,7 @@
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{
"sTitle": "Grade",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = obj.aData[ obj.iDataColumn ];
if ( sReturn == "A" ) {
sReturn = "<b>A</b>";
}
return sReturn;
}
}
{ "sTitle": "Grade", "sClass": "center" }
]
} );
} );
@@ -136,17 +126,7 @@
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{
"sTitle": "Grade",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = obj.aData[ obj.iDataColumn ];
if ( sReturn == "A" ) {
sReturn = "&lt;b&gt;A&lt;/b&gt;";
}
return sReturn;
}
}
{ "sTitle": "Grade", "sClass": "center" }
]
} );
} );</pre>

View File

@@ -2698,7 +2698,7 @@ var dtLinks = [
/* Show and syntax highlight XHR returns from the server */
$(document).ready( function () {
if ( $.fn.dataTableSettings.length >= 1 ) {
$('#example').dataTable().bind('xhr', function ( e, oSettings, json ) {
$('#example').bind('xhr', function ( e, oSettings, json ) {
var n = document.getElementById('latest_xhr');
if ( n ) {
n.innerHTML = JSON.stringify( json, null, 2 );

View File

@@ -104,4 +104,19 @@
height: 100px;
width: 100%;
overflow: auto;
}
}
#dt_example code {
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
padding: 2px 4px !important;
white-space: nowrap;
font-size: 0.9em;
color: #D14;
background-color: #F7F7F9;
border: 1px solid #E1E1E8;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

View File

@@ -201,7 +201,8 @@ table.display td.center {
background: url('../images/sort_desc_disabled.png') no-repeat center right;
}
th:active {
table.display thead th:active,
table.display thead td:active {
outline: none;
}

View File

@@ -201,7 +201,8 @@ table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; }
.sorting_asc_disabled { background: url('../images/sort_asc_disabled.png') no-repeat center right; }
.sorting_desc_disabled { background: url('../images/sort_desc_disabled.png') no-repeat center right; }
table.dataTable th:active {
table.dataTable thead th:active,
table.dataTable thead td:active {
outline: none;
}

File diff suppressed because it is too large Load Diff

6
media/js/jquery.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
/**
* @summary DataTables
* @description Paginate, search and sort HTML tables
* @version 1.9.3
* @version 1.9.4
* @file jquery.dataTables.js
* @author Allan Jardine (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
@@ -21,9 +21,28 @@
*/
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/
/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/
(/** @lends <global> */function($, window, document, undefined) {
(/** @lends <global> */function( window, document, undefined ) {
(function( factory ) {
"use strict";
// Define as an AMD module if possible
if ( typeof define === 'function' && define.amd )
{
define( ['jquery'], factory );
}
/* Define using browser globals otherwise
* Prevent multiple instantiations if the script is loaded twice
*/
else if ( jQuery && !jQuery.fn.dataTable )
{
factory( jQuery );
}
}
(/** @lends <global> */function( $ ) {
"use strict";
/**
* DataTables is a plug-in for the jQuery Javascript library. It is a
* highly flexible tool, based upon the foundations of progressive
@@ -78,9 +97,11 @@
require('api.internal.js');
var _that = this;
return this.each(function() {
this.each(function() {
require('core.constructor.js');
} );
_that = null;
return this;
};
require('api.static.js');
@@ -93,7 +114,7 @@
* @type string
* @default Version number
*/
DataTable.version = "1.9.3";
DataTable.version = "1.9.4";
/**
* Private data store, containing all of the settings objects that are created for the
@@ -257,4 +278,7 @@
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
}(jQuery, window, document, undefined));
}));
}(window, document));

View File

@@ -1,5 +1,3 @@
/**
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
* return the resulting jQuery object.
@@ -474,20 +472,23 @@ this.fnDestroy = function ( bRemove )
var nBody = oSettings.nTBody;
var i, iLen;
bRemove = (bRemove===undefined) ? false : true;
bRemove = (bRemove===undefined) ? false : bRemove;
/* Flag to note that the table is currently being destroyed - no action should be taken */
oSettings.bDestroying = true;
/* Fire off the destroy callbacks for plug-ins etc */
_fnCallbackFire( oSettings, "aoDestroyCallback", "destroy", [oSettings] );
/* Restore hidden columns */
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
/* If the table is not being removed, restore the hidden columns */
if ( !bRemove )
{
if ( oSettings.aoColumns[i].bVisible === false )
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
{
this.fnSetColumnVis( i, true );
if ( oSettings.aoColumns[i].bVisible === false )
{
this.fnSetColumnVis( i, true );
}
}
}
@@ -563,12 +564,19 @@ this.fnDestroy = function ( bRemove )
oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
}
/* If the were originally odd/even type classes - then we add them back here. Note
* this is not fool proof (for example if not all rows as odd/even classes - but
/* If the were originally stripe classes - then we add them back here. Note
* this is not fool proof (for example if not all rows had stripe classes - but
* it's a good effort without getting carried away
*/
$(nBody).children('tr:even').addClass( oSettings.asDestroyStripes[0] );
$(nBody).children('tr:odd').addClass( oSettings.asDestroyStripes[1] );
iLen = oSettings.asDestroyStripes.length;
if (iLen)
{
var anRows = $(nBody).children('tr');
for ( i=0 ; i<iLen ; i++ )
{
anRows.filter(':nth-child(' + iLen + 'n + ' + i + ')').addClass( oSettings.asDestroyStripes[i] );
}
}
/* Remove the settings object from the settings array */
for ( i=0, iLen=DataTable.settings.length ; i<iLen ; i++ )
@@ -581,6 +589,7 @@ this.fnDestroy = function ( bRemove )
/* End it all */
oSettings = null;
oInit = null;
};
@@ -674,7 +683,17 @@ this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseIns
var n = oSettings.aanFeatures.f;
for ( var i=0, iLen=n.length ; i<iLen ; i++ )
{
$(n[i]._DT_Input).val( sInput );
// IE9 throws an 'unknown error' if document.activeElement is used
// inside an iframe or frame...
try {
if ( n[i]._DT_Input != document.activeElement )
{
$(n[i]._DT_Input).val( sInput );
}
}
catch ( e ) {
$(n[i]._DT_Input).val( sInput );
}
}
}
}
@@ -794,7 +813,8 @@ this.fnGetNodes = function( iRow )
* and column index including hidden columns
* @param {node} nNode this can either be a TR, TD or TH in the table's body
* @returns {int} If nNode is given as a TR, then a single index is returned, or
* if given as a cell, an array of [row index, column index (visible)] is given.
* if given as a cell, an array of [row index, column index (visible),
* column index (all)] is given.
* @dtopt API
*
* @example

View File

@@ -118,11 +118,10 @@ function _fnColumnOptions( oSettings, iCol, oOptions )
oCol.sSortingClass = oSettings.oClasses.sSortableNone;
oCol.sSortingClassJUI = "";
}
else if ( oCol.bSortable ||
($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1 )
{
oCol.sSortingClass = oSettings.oClasses.sSortable;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI;
oCol.sSortingClass = oSettings.oClasses.sSortable;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI;
}
else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 )
{

View File

@@ -1,4 +1,3 @@
var i=0, iLen, j, jLen, k, kLen;
var sId = this.getAttribute( 'id' );
var bInitHandedOff = false;
@@ -240,42 +239,29 @@ if ( oInit.asStripeClasses === null )
}
/* Remove row stripe classes if they are already on the table row */
var bStripeRemove = false;
var anRows = $(this).children('tbody').children('tr');
for ( i=0, iLen=oSettings.asStripeClasses.length ; i<iLen ; i++ )
iLen=oSettings.asStripeClasses.length;
oSettings.asDestroyStripes = [];
if (iLen)
{
if ( anRows.filter(":lt(2)").hasClass( oSettings.asStripeClasses[i]) )
var bStripeRemove = false;
var anRows = $(this).children('tbody').children('tr:lt(' + iLen + ')');
for ( i=0 ; i<iLen ; i++ )
{
bStripeRemove = true;
break;
}
}
if ( bStripeRemove )
{
/* Store the classes which we are about to remove so they can be re-added on destroy */
oSettings.asDestroyStripes = [ '', '' ];
if ( $(anRows[0]).hasClass(oSettings.oClasses.sStripeOdd) )
{
oSettings.asDestroyStripes[0] += oSettings.oClasses.sStripeOdd+" ";
}
if ( $(anRows[0]).hasClass(oSettings.oClasses.sStripeEven) )
{
oSettings.asDestroyStripes[0] += oSettings.oClasses.sStripeEven;
}
if ( $(anRows[1]).hasClass(oSettings.oClasses.sStripeOdd) )
{
oSettings.asDestroyStripes[1] += oSettings.oClasses.sStripeOdd+" ";
}
if ( $(anRows[1]).hasClass(oSettings.oClasses.sStripeEven) )
{
oSettings.asDestroyStripes[1] += oSettings.oClasses.sStripeEven;
if ( anRows.hasClass( oSettings.asStripeClasses[i] ) )
{
bStripeRemove = true;
/* Store the classes which we are about to remove so they can be re-added on destroy */
oSettings.asDestroyStripes.push( oSettings.asStripeClasses[i] );
}
}
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
if ( bStripeRemove )
{
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
}
}
/*
* Columns
* See if we should load columns automatically or use defined ones

View File

@@ -1,5 +1,3 @@
/**
* Add a data array to the table, creating DOM node etc. This is the parallel to
* _fnGatherData, but for adding rows from a Javascript source, rather than a
@@ -64,7 +62,7 @@ function _fnAddData ( oSettings, aDataSupplied )
/* Add to the display array */
oSettings.aiDisplayMaster.push( iRow );
/* Create the DOM imformation */
/* Create the DOM information */
if ( !oSettings.oFeatures.bDeferRender )
{
_fnCreateTr( oSettings, iRow );
@@ -82,7 +80,7 @@ function _fnAddData ( oSettings, aDataSupplied )
function _fnGatherData( oSettings )
{
var iLoop, i, iLen, j, jLen, jInner,
nTds, nTrs, nTd, aLocalData, iThisIndex,
nTds, nTrs, nTd, nTr, aLocalData, iThisIndex,
iRow, iRows, iColumn, iColumns, sNodeName,
oCol, oData;
@@ -93,31 +91,32 @@ function _fnGatherData( oSettings )
*/
if ( oSettings.bDeferLoading || oSettings.sAjaxSource === null )
{
nTrs = oSettings.nTBody.childNodes;
for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
nTr = oSettings.nTBody.firstChild;
while ( nTr )
{
if ( nTrs[i].nodeName.toUpperCase() == "TR" )
if ( nTr.nodeName.toUpperCase() == "TR" )
{
iThisIndex = oSettings.aoData.length;
nTrs[i]._DT_RowIndex = iThisIndex;
nTr._DT_RowIndex = iThisIndex;
oSettings.aoData.push( $.extend( true, {}, DataTable.models.oRow, {
"nTr": nTrs[i]
"nTr": nTr
} ) );
oSettings.aiDisplayMaster.push( iThisIndex );
nTds = nTrs[i].childNodes;
nTd = nTr.firstChild;
jInner = 0;
for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
while ( nTd )
{
sNodeName = nTds[j].nodeName.toUpperCase();
sNodeName = nTd.nodeName.toUpperCase();
if ( sNodeName == "TD" || sNodeName == "TH" )
{
_fnSetCellData( oSettings, iThisIndex, jInner, $.trim(nTds[j].innerHTML) );
_fnSetCellData( oSettings, iThisIndex, jInner, $.trim(nTd.innerHTML) );
jInner++;
}
nTd = nTd.nextSibling;
}
}
nTr = nTr.nextSibling;
}
}
@@ -129,14 +128,15 @@ function _fnGatherData( oSettings )
nTds = [];
for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
{
for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
nTd = nTrs[i].firstChild;
while ( nTd )
{
nTd = nTrs[i].childNodes[j];
sNodeName = nTd.nodeName.toUpperCase();
if ( sNodeName == "TD" || sNodeName == "TH" )
{
nTds.push( nTd );
}
nTd = nTd.nextSibling;
}
}
@@ -186,8 +186,16 @@ function _fnGatherData( oSettings )
}
}
if ( typeof oCol.mData === 'function' )
if ( oCol.mRender )
{
// mRender has been defined, so we need to get the value and set it
nCell.innerHTML = _fnGetCellData( oSettings, iRow, iColumn, 'display' );
}
else if ( oCol.mData !== iColumn )
{
// If mData is not the same as the column number, then we need to
// get the dev set value. If it is the column, no point in wasting
// time setting the value that is already there!
nCell.innerHTML = _fnGetCellData( oSettings, iRow, iColumn, 'display' );
}

View File

@@ -1,4 +1,3 @@
/**
* Create a new TR element (and it's TD children) for a row
* @param {object} oSettings dataTables settings object
@@ -27,7 +26,7 @@ function _fnCreateTr ( oSettings, iRow )
if ( oData._aData.DT_RowClass )
{
$(oData.nTr).addClass( oData._aData.DT_RowClass );
oData.nTr.className = oData._aData.DT_RowClass;
}
/* Process each column */
@@ -80,7 +79,7 @@ function _fnCreateTr ( oSettings, iRow )
function _fnBuildHead( oSettings )
{
var i, nTh, iLen, j, jLen;
var iThs = oSettings.nTHead.getElementsByTagName('th').length;
var iThs = $('th, td', oSettings.nTHead).length;
var iCorrector = 0;
var jqChildren;
@@ -691,10 +690,12 @@ function _fnAddOptionsHtml ( oSettings )
function _fnDetectHeader ( aLayout, nThead )
{
var nTrs = $(nThead).children('tr');
var nCell;
var i, j, k, l, iLen, jLen, iColShifted;
var nTr, nCell;
var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
var bUnique;
var fnShiftCol = function ( a, i, j ) {
while ( a[i][j] ) {
var k = a[i];
while ( k[j] ) {
j++;
}
return j;
@@ -711,19 +712,18 @@ function _fnDetectHeader ( aLayout, nThead )
/* Calculate a layout array */
for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
{
var iColumn = 0;
nTr = nTrs[i];
iColumn = 0;
/* For every cell in the row... */
for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
{
nCell = nTrs[i].childNodes[j];
nCell = nTr.firstChild;
while ( nCell ) {
if ( nCell.nodeName.toUpperCase() == "TD" ||
nCell.nodeName.toUpperCase() == "TH" )
{
/* Get the col and rowspan attributes from the DOM and sanitise them */
var iColspan = nCell.getAttribute('colspan') * 1;
var iRowspan = nCell.getAttribute('rowspan') * 1;
iColspan = nCell.getAttribute('colspan') * 1;
iRowspan = nCell.getAttribute('rowspan') * 1;
iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
@@ -732,6 +732,9 @@ function _fnDetectHeader ( aLayout, nThead )
*/
iColShifted = fnShiftCol( aLayout, i, iColumn );
/* Cache calculation for unique columns */
bUnique = iColspan === 1 ? true : false;
/* If there is col / rowspan, copy the information into the layout grid */
for ( l=0 ; l<iColspan ; l++ )
{
@@ -739,12 +742,13 @@ function _fnDetectHeader ( aLayout, nThead )
{
aLayout[i+k][iColShifted+l] = {
"cell": nCell,
"unique": iColspan == 1 ? true : false
"unique": bUnique
};
aLayout[i+k].nTr = nTrs[i];
aLayout[i+k].nTr = nTr;
}
}
}
nCell = nCell.nextSibling;
}
}
}

View File

@@ -1,5 +1,4 @@
/**
* Generate the node required for the info display
* @param {object} oSettings dataTables settings object
@@ -50,25 +49,20 @@ function _fnUpdateInfo ( oSettings )
iTotal = oSettings.fnRecordsDisplay(),
sOut;
if ( iTotal === 0 && iTotal == iMax )
if ( iTotal === 0 )
{
/* Empty record set */
sOut = oLang.sInfoEmpty;
}
else if ( iTotal === 0 )
{
/* Empty record set after filtering */
sOut = oLang.sInfoEmpty +' '+ oLang.sInfoFiltered;
}
else if ( iTotal == iMax )
{
else {
/* Normal record set */
sOut = oLang.sInfo;
}
else
if ( iTotal != iMax )
{
/* Record set after filtering */
sOut = oLang.sInfo +' '+ oLang.sInfoFiltered;
sOut += ' ' + oLang.sInfoFiltered;
}
// Convert the macros
@@ -109,9 +103,9 @@ function _fnInfoMacros ( oSettings, str )
}
return str.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_TOTAL_', sTotal).
replace('_MAX_', sMax);
replace(/_START_/g, sStart).
replace(/_END_/g, sEnd).
replace(/_TOTAL_/g, sTotal).
replace(/_MAX_/g, sMax);
}

View File

@@ -1,5 +1,3 @@
/**
* Add any control elements for the table - specifically scrolling
* @param {object} oSettings dataTables settings object
@@ -191,10 +189,18 @@ function _fnScrollDraw ( o )
nScrollBody = o.nTable.parentNode,
i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis,
nTheadSize, nTfootSize,
iWidth, aApplied=[], iSanityWidth,
iWidth, aApplied=[], aAppliedFooter=[], iSanityWidth,
nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null,
nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null,
ie67 = o.oBrowser.bScrollOversize;
ie67 = o.oBrowser.bScrollOversize,
zeroOut = function(nSizer) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
};
/*
* 1. Re-create the table inside the scrolling div
@@ -206,11 +212,15 @@ function _fnScrollDraw ( o )
/* Clone the current header and footer elements and then place it into the inner table */
nTheadSize = $(o.nTHead).clone()[0];
o.nTable.insertBefore( nTheadSize, o.nTable.childNodes[0] );
anHeadToSize = o.nTHead.getElementsByTagName('tr');
anHeadSizers = nTheadSize.getElementsByTagName('tr');
if ( o.nTFoot !== null )
{
nTfootSize = $(o.nTFoot).clone()[0];
o.nTable.insertBefore( nTfootSize, o.nTable.childNodes[1] );
anFootToSize = o.nTFoot.getElementsByTagName('tr');
anFootSizers = nTfootSize.getElementsByTagName('tr');
}
/*
@@ -238,7 +248,7 @@ function _fnScrollDraw ( o )
{
_fnApplyToChildren( function(n) {
n.style.width = "";
}, nTfootSize.getElementsByTagName('tr') );
}, anFootSizers );
}
// If scroll collapse is enabled, when we put the headers back into the body for sizing, we
@@ -300,41 +310,38 @@ function _fnScrollDraw ( o )
/* We want the hidden header to have zero height, so remove padding and borders. Then
* set the width based on the real headers
*/
anHeadToSize = o.nTHead.getElementsByTagName('tr');
anHeadSizers = nTheadSize.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anHeadSizers, anHeadToSize );
// Apply all styles in one pass. Invalidates layout only once because we don't read any
// DOM properties.
_fnApplyToChildren( zeroOut, anHeadSizers );
// Read all widths in next pass. Forces layout only once because we do not change
// any DOM properties.
_fnApplyToChildren( function(nSizer) {
aApplied.push( _fnStringToCss( $(nSizer).width() ) );
}, anHeadSizers );
// Apply all widths in final pass. Invalidates layout only once because we do not
// read any DOM properties.
_fnApplyToChildren( function(nToSize, i) {
nToSize.style.width = aApplied[i];
}, anHeadToSize );
$(anHeadSizers).height(0);
/* Same again with the footer if we have one */
if ( o.nTFoot !== null )
{
/* Clone the current footer and then place it into the body table as a "hidden header" */
anFootSizers = nTfootSize.getElementsByTagName('tr');
anFootToSize = o.nTFoot.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anFootSizers, anFootToSize );
_fnApplyToChildren( zeroOut, anFootSizers );
_fnApplyToChildren( function(nSizer) {
aAppliedFooter.push( _fnStringToCss( $(nSizer).width() ) );
}, anFootSizers );
_fnApplyToChildren( function(nToSize, i) {
nToSize.style.width = aAppliedFooter[i];
}, anFootToSize );
$(anFootSizers).height(0);
}
@@ -345,16 +352,16 @@ function _fnScrollDraw ( o )
/* "Hide" the header and footer that we used for the sizing. We want to also fix their width
* to what they currently are
*/
_fnApplyToChildren( function(nSizer) {
_fnApplyToChildren( function(nSizer, i) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
nSizer.style.width = aApplied[i];
}, anHeadSizers );
if ( o.nTFoot !== null )
{
_fnApplyToChildren( function(nSizer) {
_fnApplyToChildren( function(nSizer, i) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
nSizer.style.width = aAppliedFooter[i];
}, anFootSizers );
}
@@ -377,11 +384,11 @@ function _fnScrollDraw ( o )
/* Apply the calculated minimum width to the table wrappers */
nScrollBody.style.width = _fnStringToCss( iCorrection );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( iCorrection );
o.nScrollHead.style.width = _fnStringToCss( iCorrection );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( iCorrection );
o.nScrollFoot.style.width = _fnStringToCss( iCorrection );
}
/* And give the user a warning that we've stopped the table getting too small */
@@ -400,11 +407,11 @@ function _fnScrollDraw ( o )
else
{
nScrollBody.style.width = _fnStringToCss( '100%' );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( '100%' );
o.nScrollHead.style.width = _fnStringToCss( '100%' );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( '100%' );
o.nScrollFoot.style.width = _fnStringToCss( '100%' );
}
}
@@ -474,22 +481,31 @@ function _fnScrollDraw ( o )
*/
function _fnApplyToChildren( fn, an1, an2 )
{
for ( var i=0, iLen=an1.length ; i<iLen ; i++ )
var index=0, i=0, iLen=an1.length;
var nNode1, nNode2;
while ( i < iLen )
{
for ( var j=0, jLen=an1[i].childNodes.length ; j<jLen ; j++ )
nNode1 = an1[i].firstChild;
nNode2 = an2 ? an2[i].firstChild : null;
while ( nNode1 )
{
if ( an1[i].childNodes[j].nodeType == 1 )
if ( nNode1.nodeType === 1 )
{
if ( an2 )
{
fn( an1[i].childNodes[j], an2[i].childNodes[j] );
fn( nNode1, nNode2, index );
}
else
{
fn( an1[i].childNodes[j] );
fn( nNode1, index );
}
index++;
}
nNode1 = nNode1.nextSibling;
nNode2 = an2 ? nNode2.nextSibling : null;
}
i++;
}
}

View File

@@ -1,5 +1,3 @@
/**
* Convert a CSS unit width to pixels (e.g. 2em)
* @param {string} sWidth width to be converted
@@ -16,7 +14,7 @@ function _fnConvertToWidth ( sWidth, nParent )
if ( !nParent )
{
nParent = document.getElementsByTagName('body')[0];
nParent = document.body;
}
var iWidth;
@@ -46,6 +44,7 @@ function _fnCalculateColumnWidths ( oSettings )
var i, iIndex, iCorrector, iWidth;
var oHeaders = $('th', oSettings.nTHead);
var widthAttr = oSettings.nTable.getAttribute('width');
var nWrapper = oSettings.nTable.parentNode;
/* Convert any user input sizes into pixel sizes */
for ( i=0 ; i<iColums ; i++ )
@@ -57,7 +56,7 @@ function _fnCalculateColumnWidths ( oSettings )
if ( oSettings.aoColumns[i].sWidth !== null )
{
iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidthOrig,
oSettings.nTable.parentNode );
nWrapper );
if ( iTmpWidth !== null )
{
oSettings.aoColumns[i].sWidth = _fnStringToCss( iTmpWidth );
@@ -157,7 +156,6 @@ function _fnCalculateColumnWidths ( oSettings )
}
/* Build the table and 'display' it */
var nWrapper = oSettings.nTable.parentNode;
nWrapper.appendChild( nCalcTmp );
/* When scrolling (X or Y) we want to set the width of the table as appropriate. However,
@@ -284,7 +282,7 @@ function _fnScrollingWidthAdjust ( oSettings, n )
* Get the widest node
* @param {object} oSettings dataTables settings object
* @param {int} iCol column of interest
* @returns {string} max string length for each column
* @returns {node} widest table node
* @memberof DataTable#oApi
*/
function _fnGetWidestNode( oSettings, iCol )

View File

@@ -1,5 +1,3 @@
/**
* Change the order of the table
* @param {object} oSettings dataTables settings object
@@ -403,58 +401,51 @@ function _fnSortingClasses( oSettings )
if ( oSettings.oFeatures.bSort && oSettings.oFeatures.bSortClasses )
{
var nTds = _fnGetTdNodes( oSettings );
/* Remove the old classes */
if ( oSettings.oFeatures.bDeferRender )
{
$(nTds).removeClass(sClass+'1 '+sClass+'2 '+sClass+'3');
}
else if ( nTds.length >= iColumns )
{
for ( i=0 ; i<iColumns ; i++ )
{
if ( nTds[i].className.indexOf(sClass+"1") != -1 )
{
for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
{
nTds[(iColumns*j)+i].className =
$.trim( nTds[(iColumns*j)+i].className.replace( sClass+"1", "" ) );
}
}
else if ( nTds[i].className.indexOf(sClass+"2") != -1 )
{
for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
{
nTds[(iColumns*j)+i].className =
$.trim( nTds[(iColumns*j)+i].className.replace( sClass+"2", "" ) );
}
}
else if ( nTds[i].className.indexOf(sClass+"3") != -1 )
{
for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
{
nTds[(iColumns*j)+i].className =
$.trim( nTds[(iColumns*j)+i].className.replace( " "+sClass+"3", "" ) );
}
}
}
}
/* Add the new classes to the table */
var iClass = 1, iTargetCol;
for ( i=0 ; i<aaSort.length ; i++ )
/* Determine what the sorting class for each column should be */
var iClass, iTargetCol;
var asClasses = [];
for (i = 0; i < iColumns; i++)
{
asClasses.push("");
}
for (i = 0, iClass = 1; i < aaSort.length; i++)
{
iTargetCol = parseInt( aaSort[i][0], 10 );
for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
{
nTds[(iColumns*j)+iTargetCol].className += " "+sClass+iClass;
}
asClasses[iTargetCol] = sClass + iClass;
if ( iClass < 3 )
{
iClass++;
}
}
/* Make changes to the classes for each cell as needed */
var reClass = new RegExp(sClass + "[123]");
var sTmpClass, sCurrentClass, sNewClass;
for ( i=0, iLen=nTds.length; i<iLen; i++ )
{
/* Determine which column we're looking at */
iTargetCol = i % iColumns;
/* What is the full list of classes now */
sCurrentClass = nTds[i].className;
/* What sorting class should be applied? */
sNewClass = asClasses[iTargetCol];
/* What would the new full list be if we did a replacement? */
sTmpClass = sCurrentClass.replace(reClass, sNewClass);
if ( sTmpClass != sCurrentClass )
{
/* We changed something */
nTds[i].className = $.trim( sTmpClass );
}
else if ( sNewClass.length > 0 && sCurrentClass.indexOf(sNewClass) == -1 )
{
/* We need to add a class */
nTds[i].className = sCurrentClass + " " + sNewClass;
}
}
}
}

View File

@@ -132,35 +132,50 @@ function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
}
/* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies
* belonging to DataTables. This is FAR from bullet proof
* belonging to DataTables.
*/
var sOldName="", iOldTime=9999999999999;
var iLength = _fnReadCookie( sNameFile )!==null ? document.cookie.length :
sFullCookie.length + document.cookie.length;
var
aCookies =document.cookie.split(';'),
iNewCookieLen = sFullCookie.split(';')[0].length,
aOldCookies = [];
if ( iLength+10 > 4096 ) /* Magic 10 for padding */
if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */
{
var aCookies =document.cookie.split(';');
for ( var i=0, iLen=aCookies.length ; i<iLen ; i++ )
{
if ( aCookies[i].indexOf( sBaseName ) != -1 )
{
/* It's a DataTables cookie, so eval it and check the time stamp */
var aSplitCookie = aCookies[i].split('=');
try { oData = eval( '('+decodeURIComponent(aSplitCookie[1])+')' ); }
catch( e ) { continue; }
if ( oData.iCreate && oData.iCreate < iOldTime )
{
sOldName = aSplitCookie[0];
iOldTime = oData.iCreate;
try {
oData = eval( '('+decodeURIComponent(aSplitCookie[1])+')' );
if ( oData && oData.iCreate )
{
aOldCookies.push( {
"name": aSplitCookie[0],
"time": oData.iCreate
} );
}
}
catch( e ) {}
}
}
if ( sOldName !== "" )
{
document.cookie = sOldName+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+
// Make sure we delete the oldest ones first
aOldCookies.sort( function (a, b) {
return b.time - a.time;
} );
// Eliminate as many old DataTables cookies as we need to
while ( iNewCookieLen + document.cookie.length + 10 > 4096 ) {
if ( aOldCookies.length === 0 ) {
// Deleted all DT cookies and still not enough space. Can't state save
return;
}
var old = aOldCookies.pop();
document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+
aParts.join('/') + "/";
}
}

View File

@@ -1,5 +1,4 @@
/**
* Return the settings object for a particular table
* @param {node} nTable table we are using as a dataTable
@@ -53,7 +52,7 @@ function _fnGetTdNodes ( oSettings, iIndividualRow )
{
var anReturn = [];
var iCorrector;
var anTds;
var anTds, nTd;
var iRow, iRows=oSettings.aoData.length,
iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;
@@ -71,13 +70,15 @@ function _fnGetTdNodes ( oSettings, iIndividualRow )
{
/* get the TD child nodes - taking into account text etc nodes */
anTds = [];
for ( iColumn=0, iColumns=oData.nTr.childNodes.length ; iColumn<iColumns ; iColumn++ )
nTd = oData.nTr.firstChild;
while ( nTd )
{
sNodeName = oData.nTr.childNodes[iColumn].nodeName.toLowerCase();
sNodeName = nTd.nodeName.toLowerCase();
if ( sNodeName == 'td' || sNodeName == 'th' )
{
anTds.push( oData.nTr.childNodes[iColumn] );
anTds.push( nTd );
}
nTd = nTd.nextSibling;
}
iCorrector = 0;
@@ -333,7 +334,7 @@ function _fnBrowserDetect( oSettings )
*/
var n = $(
'<div style="position:absolute; top:0; left:0; height:1px; width:1px; overflow:hidden">'+
'<div style="position:absolute; top:1px; left:1px; width:100px; height:50px; overflow:scroll;">'+
'<div style="position:absolute; top:1px; left:1px; width:100px; overflow:scroll;">'+
'<div id="DT_BrowserTest" style="width:100%; height:10px;"></div>'+
'</div>'+
'</div>')[0];

View File

@@ -1,4 +1,3 @@
/*
* Variable: oPagination
* Purpose:
@@ -73,17 +72,22 @@ $.extend( DataTable.ext.oPagination, {
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++ )
{
if ( an[i].childNodes.length !== 0 )
nNode = an[i].firstChild;
if ( nNode )
{
an[i].childNodes[0].className = ( oSettings._iDisplayStart === 0 ) ?
oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
an[i].childNodes[1].className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
/* 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;
}
}
}
@@ -172,7 +176,7 @@ $.extend( DataTable.ext.oPagination, {
var sList = "";
var iStartButton, iEndButton, i, iLen;
var oClasses = oSettings.oClasses;
var anButtons, anStatic, nPaginateList;
var anButtons, anStatic, nPaginateList, nNode;
var an = oSettings.aanFeatures.p;
var fnBind = function (j) {
oSettings.oApi._fnBindAction( this, {"page": j+iStartButton-1}, function(e) {
@@ -223,18 +227,19 @@ $.extend( DataTable.ext.oPagination, {
/* Loop over each instance of the pager */
for ( i=0, iLen=an.length ; i<iLen ; i++ )
{
if ( an[i].childNodes.length === 0 )
nNode = an[i];
if ( !nNode.hasChildNodes() )
{
continue;
}
/* Build up the dynamic list first - html and listeners */
$('span:eq(0)', an[i])
$('span:eq(0)', nNode)
.html( sList )
.children('a').each( fnBind );
/* Update the permanent button's classes */
anButtons = an[i].getElementsByTagName('a');
anButtons = nNode.getElementsByTagName('a');
anStatic = [
anButtons[0], anButtons[1],
anButtons[anButtons.length-2], anButtons[anButtons.length-1]

View File

@@ -48,14 +48,14 @@ DataTable.models.oColumn = {
"bSortable": null,
/**
* When using fnRender, you have two options for what to do with the data,
* and this property serves as the switch. Firstly, you can have the sorting
* and filtering use the rendered value (true - default), or you can have
* the sorting and filtering us the original value (false).
*
* *NOTE* It is it is advisable now to use mData as a function and make
* use of the 'type' that it gives, allowing (potentially) different data to
* be used for sorting, filtering, display and type detection.
* <code>Deprecated</code> When using fnRender, you have two options for what
* to do with the data, and this property serves as the switch. Firstly, you
* can have the sorting and filtering use the rendered value (true - default),
* or you can have the sorting and filtering us the original value (false).
*
* Please note that this option has now been deprecated and will be removed
* in the next version of DataTables. Please use mRender / mData rather than
* fnRender.
* @type boolean
* @deprecated
*/
@@ -78,9 +78,9 @@ DataTable.models.oColumn = {
/**
* Developer definable function that is called whenever a cell is created (Ajax source,
* etc) or processed for input (DOM source). This can be used as a compliment to fnRender
* etc) or processed for input (DOM source). This can be used as a compliment to mRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available (since it is not when fnRender is called).
* element is available.
* @type function
* @param {element} nTd The TD node that has been created
* @param {*} sData The Data for the cell
@@ -107,8 +107,12 @@ DataTable.models.oColumn = {
"fnGetData": null,
/**
* Custom display function that will be called for the display of each cell
* in this column.
* <code>Deprecated</code> Custom display function that will be called for the
* display of each cell in this column.
*
* Please note that this option has now been deprecated and will be removed
* in the next version of DataTables. Please use mRender / mData rather than
* fnRender.
* @type function
* @param {object} o Object with the following parameters:
* @param {int} o.iDataRow The row in aoData
@@ -117,6 +121,7 @@ DataTable.models.oColumn = {
* @param {object} o.oSettings The settings object for this DataTables instance
* @returns {string} The string you which to use in the display
* @default null
* @deprecated
*/
"fnRender": null,

View File

@@ -142,51 +142,18 @@ DataTable.defaults.columns = {
/**
* When using fnRender() for a column, you may wish to use the original data
* (before rendering) for sorting and filtering (the default is to used the
* rendered data that the user can see). This may be useful for dates etc.
* <code>Deprecated</code> When using fnRender() for a column, you may wish
* to use the original data (before rendering) for sorting and filtering
* (the default is to used the rendered data that the user can see). This
* may be useful for dates etc.
*
* *NOTE* This property is now deprecated, and it is suggested that you use
* mData and / or mRender to render data for the DataTable.
* Please note that this option has now been deprecated and will be removed
* in the next version of DataTables. Please use mRender / mData rather than
* fnRender.
* @type boolean
* @default true
* @dtopt Columns
* @deprecated
*
* @example
* // Using aoColumnDefs
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( oObj ) {
* return oObj.aData[0] +' '+ oObj.aData[3];
* },
* "bUseRendered": false,
* "aTargets": [ 0 ]
* }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoColumns": [
* {
* "fnRender": function ( oObj ) {
* return oObj.aData[0] +' '+ oObj.aData[3];
* },
* "bUseRendered": false
* },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"bUseRendered": true,
@@ -224,9 +191,9 @@ DataTable.defaults.columns = {
/**
* Developer definable function that is called whenever a cell is created (Ajax source,
* etc) or processed for input (DOM source). This can be used as a compliment to fnRender
* etc) or processed for input (DOM source). This can be used as a compliment to mRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available (since it is not when fnRender is called).
* element is available.
* @type function
* @param {element} nTd The TD node that has been created
* @param {*} sData The Data for the cell
@@ -253,8 +220,12 @@ DataTable.defaults.columns = {
/**
* Custom display function that will be called for the display of each cell in
* this column.
* <code>Deprecated</code> Custom display function that will be called for the
* display of each cell in this column.
*
* Please note that this option has now been deprecated and will be removed
* in the next version of DataTables. Please use mRender / mData rather than
* fnRender.
* @type function
* @param {object} o Object with the following parameters:
* @param {int} o.iDataRow The row in aoData
@@ -265,37 +236,7 @@ DataTable.defaults.columns = {
* @param {*} val The current cell value
* @returns {string} The string you which to use in the display
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* },
* "aTargets": [ 0 ]
* }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* } },
* null,
* null,
* null,
* null
* ]
* } );
* } );
* @deprecated
*/
"fnRender": null,

View File

@@ -1384,8 +1384,8 @@ DataTable.defaults = {
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the next page.
* Text to use for the 'next' pagination button (to take the user to the
* next page).
* @type string
* @default Next
* @dtopt Language
@@ -1405,8 +1405,8 @@ DataTable.defaults = {
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the previous page.
* Text to use for the 'previous' pagination button (to take the user to
* the previous page).
* @type string
* @default Previous
* @dtopt Language

66
package.json Normal file → Executable file
View File

@@ -1,34 +1,34 @@
{
"name": "DataTables",
"version": "1.9.2",
"title": "DataTables",
"author": {
"name": "Allan Jardine",
"url": "http://sprymedia.co.uk"
},
"licenses": [
{
"type": "BSD",
"url": "http://datatables.net/license_bsd"
},
{
"type": "GPLv2",
"url": "http://datatables.net/license_gpl2"
}
],
"dependencies": {
"jquery": "1.3 - 1.7"
},
"description": "DataTables enhances HTML tables with the ability to sort, filter and page the data in the table very easily. It provides a comprehensive API and set of configuration options, allowing you to consume data from virtually any data source.",
"keywords": [
"DataTables",
"DataTable",
"table",
"grid",
"filter",
"sort",
"page",
"internationalisable"
],
"homepage": "http://datatables.net"
}
"name": "DataTables",
"version": "1.9.4",
"title": "DataTables",
"author": {
"name": "Allan Jardine",
"url": "http://sprymedia.co.uk"
},
"licenses": [
{
"type": "BSD",
"url": "http://datatables.net/license_bsd"
},
{
"type": "GPLv2",
"url": "http://datatables.net/license_gpl2"
}
],
"dependencies": {
"jquery": ">=1.7"
},
"description": "DataTables enhances HTML tables with the ability to sort, filter and page the data in the table very easily. It provides a comprehensive API and set of configuration options, allowing you to consume data from virtually any data source.",
"keywords": [
"DataTables",
"DataTable",
"table",
"grid",
"filter",
"sort",
"page",
"internationalisable"
],
"homepage": "http://datatables.net"
}

View File

@@ -99,6 +99,65 @@ if [ "$CMD" != "debug" ]; then
fi
fi
# Back to DataTables root dir
cd ../..
#
# Packaging files
#
cat <<EOF > package.json
{
"name": "DataTables",
"version": "${VERSION}",
"title": "DataTables",
"author": {
"name": "Allan Jardine",
"url": "http://sprymedia.co.uk"
},
"licenses": [
{
"type": "BSD",
"url": "http://datatables.net/license_bsd"
},
{
"type": "GPLv2",
"url": "http://datatables.net/license_gpl2"
}
],
"dependencies": {
"jquery": "1.4 - 1.8"
},
"description": "DataTables enhances HTML tables with the ability to sort, filter and page the data in the table very easily. It provides a comprehensive API and set of configuration options, allowing you to consume data from virtually any data source.",
"keywords": [
"DataTables",
"DataTable",
"table",
"grid",
"filter",
"sort",
"page",
"internationalisable"
],
"homepage": "http://datatables.net"
}
EOF
cat <<EOF > component.json
{
"name": "DataTables",
"version": "${VERSION}",
"main": [
"./media/js/jquery.dataTables.js",
"./media/css/jquery.dataTables.css",
],
"dependencies": {
"jquery": "~1.8.0"
}
}
EOF
echo " Done\n"