1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-02 14:24:11 +01:00
Commit Graph

987 Commits

Author SHA1 Message Date
Allan Jardine
6f67df2d21 New: $.fn.dataTable.render.text renderer method that can be used to help prevent against possible XSS attacks. It will basically encode HTML entities so they are shown in the rendered view rather than being written directly as HTML.
Update: `$.fn.dataTable.render.number` will now return the original value rather than NaN if the value cannot be parsed as a number.
2015-11-06 10:40:50 +00:00
Allan Jardine
06a6a0c429 Dev: Add a plugin-init event which is triggered immediately prior to init
- This is so that Buttons (and others) can listen for this event and
  create the buttons before the user init functions. Otherwise they
  would need a setTimeoutout to be able to access the Buttons methods
  immediately.
2015-11-04 16:33:00 +00:00
Allan Jardine
b36cbc745b Update: Allow a window to be passed in for CommonJS factory which gives DataTables the ability to be used in a headless environment (server-side rendering for example)
- Factory builder redesigned to pass in window and document to the
  factory method, mandating a small update to the AMD and Browser
  loaders
- Main change in is the CommonJS loader which can now optionally have a
  window object passed in - if it is not passed in `window` will be used
  (if this is the case in a CommonJS environment without a root object
  being passed in an error will occur).
- DataTables caches a reference to the jQuery instance so the plug-ins
  can easily reference jQuery while retaining their current return of
  the module they define. This basically means that DataTables core will
  include jQuery for the plug-ins.
- This does increase the core library size by ~160 bytes which is rather
  frustrating, but I think this is the correct way to go about it
- With thanks to Evan Carroll for input on this:
  https://github.com/DataTables/Plugins/issues/199
2015-11-03 16:32:39 +00:00
Allan Jardine
8fe17acf82 Update: A dt-init scrollX table is now allowed to collapse horizontally - simply don't specify style="width: 100%" or width="100%" for your table in the HTML and it will be allowed to collapse if the columns are smaller than the space required.
Fix: Force a column width if `dt-init scrollX` is specified and a column width is given. This can be overruled if the width given is too small for the content

- We already use the width attribute to determine if the table should
  resize dynamically to 100% width, so it makes sense to use that when
  scroll-x is enabled as well.
- This still isn't perfect as Chrome seems to change between a
  box-sizing calculation depending if scrolling is required or not so
  there can be a shift in column widths when changing between a
  scrolling state and not (column visibility) which is ugly, but is
  proving to be difficult to deal with.
2015-11-03 16:32:10 +00:00
Allan Jardine
ab982a537e New: dt-init language.aria.paginate options which can be used to specify ARIA label attributes for the pagination buttons. Particularly useful if you wish to use icons in place of the button text. 2015-10-28 11:38:01 +00:00
Allan Jardine
b9bdc5eb11 Fix: dt-api page.info() reported the page length as 10 when paging was disabled - should be -1 2015-10-28 09:03:41 +00:00
Allan Jardine
66893ae170 Update: Add column index information to the Requested unknown parameter error message to provide additional debug info 2015-10-28 09:03:15 +00:00
Allan Jardine
8adcf16743 Fix: Column alignment errors in IE due to sub-pixel rendering issues. Basically this came down to the width of the table not equalling the width of the cells in the table and if the column widths assigned and the table width assigned did not match perfectly, IE would ignore the column widths assigning and layout as it saw best. Now the column width calculation will remove this sub-pixel issue by rounding up and also keep a track of the table width itself rather than reading from the DOM.
Fix: ` ` in cells could cause column alignment errors as it was being counted as 6 characters rather than 1 in the find longest string method.
2015-10-27 12:05:03 +00:00
Allan Jardine
c55f460e6d Dev: Removing the Chrome workaround - this appears to be extremely hard
to reproduce the error and it is only occuring on Chrome Mac with a
combination of the CSS in the DataTables demos specifically. This is an
edge case that I'd rather not add code for at the moment.
2015-10-22 11:39:02 +01:00
Allan Jardine
40dda9c24f Fix: If dt-init scrollX is enabled for a table that doesn't need horizontal scrolling, but does have vertical scrolling, when the table is filtered to have no vertical scrolling the columns would be misaligned due to the column widths not being recalculated for the new table width.
Fix: Chrome has an odd bug whereby the max-height needs a reflow in order to be correctly calculated - otherwise a gap could appear at the bottom of the table

- Haven't been able to reproduce the Chrome issue in a simple test case
  - its something to do with the scrollbars being shown while the scroll
  column calculations / updates are being done and then no longer
  being needed ater that point.
2015-10-22 11:18:39 +01:00
Allan Jardine
727937c836 Dev: Fix whitespace issues from #57 - looks like a merge diff error
Dev: Code style updated to match DataTables (unwritten!) standard
Dev: Removed some of the protection on the cell index update on row
  delete - it is safe to assume that since we have a cell node, we've
  assigned an index to it.
2015-10-13 15:31:07 +01:00
Allan Jardine
00100f5afe Merge pull request #57 from strang91/master
Updated: Performance improvement by caching cell indexes for use with cell selectors
2015-10-13 15:30:38 +01:00
Allan Jardine
3b867f209c New: Pass the recalculation parameter through to the dt-event column-visibility event allowing listeners to optimise for it 2015-10-13 15:30:18 +01:00
Allan Jardine
08d61efa63 Dev: Naming for AMD and CommonJS loaders set to a unique value that will be useable on bower and npm due to no conflicts.
- Using just `datatables` would be difficult since I and others already
  publish packages with that name. Anyone using those packages already
  would run into real issues if I were to change their meaning and
  contents!
2015-10-13 15:28:14 +01:00
Allan Jardine
954a3b080b Update cell node indexes when removing a row 2015-10-13 15:26:36 +01:00
Allan Jardine
d481e0d441 Update: Updating the AMD and CommonJS loaders
- Cannot pass in a `dt` instance - will always use the one from the
  jQuery instance given
- Don't check for reinitialisation or for jQuery when working in the
  browser - will throw an error if in browser and no jQuery, which is
  correct, DataTables needs jQuery
2015-10-06 12:06:06 +01:00
Allan Jardine
dd5ddd46a0 Fix: Performance improvement for the every() methods. Rather than a new API instance being excplicitly created for every item, use the exisiting instance as the basis for the selector.
- The item selector returns a new instance, so there is no impact upon
  compatiblity
2015-10-06 12:05:19 +01:00
Allan Jardine
c0cb3db92f New: DataTables no longer defines itself as a named AMD module
New: CommonJS will load jQuery if it wasn't passed in
Fix: Bootstrap, Foundation and jQuery UI integration Javascript files use module.exports correctly
Dev: Change the file include "function" name to not conflict with `require`

- AMD / RequireJS - The Require documentation strongly discorages using
  a named module, but I've used this in the past as the plug-ins need a
  name to depend upon themselves. This is still `datatables` but if the
  developer is using Require and it resolves automatically to a
  different name (which it may depending upon their configuration) they
  can use a map option to map their name to `datatables`. See
  https://github.com/moment/moment/issues/1095

- CommonJS - Based on the disscussion in
  https://github.com/DataTables/Plugins/issues/199 it seems that some
  developers like to pass a certain version of jQuery in. This
  modification allows them to do so while retaining backwards
  compatiblity.

- Integration files - The UMD wrapper for these files have been
  restructured to be easier to follow. Also, based on the discussion in
  the Plugins issue noted above you can now pass in a jQuery instance or
  not and likewise a DataTables object or not.

- To avoid direct conflict with `require()` the build scripts have been
  updated to use a "function" called `_buildInclude`. Ultimatily this
  should really be updated to use grunt or similar.
2015-10-06 12:03:36 +01:00
Allan Jardine
9fe4110826 Fix: Improve integration for NPM / CommonJS - jQuery object to augment can now be passed in. This applies to DataTables core as well as the integration files for Bootstrap, Foundation and jQuery UI 2015-10-06 12:02:51 +01:00
Allan Jardine
5e34369a56 Fix: Column width calculation could be incorrect when not using any user defined widths or hidden columns
- All credit to @montrothstein for finding and fixing this -
  DataTables/DataTables #681
2015-10-06 12:02:08 +01:00
Allan Jardine
ea9e926b53 Dev: Output a warning if html tidy is not installed
- I just updated my PHP and HTML Tidy was not installed which resulted
  in the examples in the dist repo all being rewritten unfortunately.
  This should stop that happening again.
2015-09-25 10:08:52 +01:00
Allan Jardine
b84cc6063e Fix: The every() method did not have the selector options applied to it - this was particularly noticable with the dt-api columns().every() method
- See DataTables/DataTables #679 and https://jsfiddle.net/7mgny9gb/2/
- Thanks @mpryvkin for noting this bug and the test cases
2015-09-25 09:50:54 +01:00
Allan Jardine
52b30868a1 New: dt-api order.fixed() to get / set the fixed ordering of the table 2015-09-16 15:55:05 +01:00
Allan Jardine
898cdca4ff Fix: If x-scrolling is enabled using $.fn.dataTable.defaults.scrollX=true; an error would occur
- Fixes thread 30084
- Error introduced by commit 67ed583159419cec6fee14c5ecaafc5f75e7cf5c
2015-09-10 10:00:00 +01:00
Allan Jardine
561b88551e Fix: Adding a default builder string into the ext object to allow builder sourced files to work with require.js
- This comes about from thread 29819 which highlights that inserting the
  buidler string as a variable into the static file causes issues.
- This will only take effect once 1.10.10 has been released
2015-09-09 14:02:25 +01:00
Allan Jardine
a75f0a7057 Fix: Row ids were not being automatically picked up from DOM sourced tables 2015-09-07 15:54:36 +01:00
Allan Jardine
c40604d2c1 Moving on to 1.10.10 development 2015-09-07 15:54:09 +01:00
Allan Jardine
b1bca78111 DataTables 1.10.9 release 2015-09-01 09:51:29 +01:00
Allan Jardine
648726b19e Fix: When using a cell selector, if the element doesn't have a parent node (caused by it being hidden and a jQuery selector being used) an error would be thrown.
- The fix is to loop over the data array to find the cell. Slower, but
  for an edge case I think this is an approriate fix.
- This fixes DataTables/DataTables #653
2015-09-01 08:38:38 +01:00
Allan Jardine
119a355970 Fix: It was possible to select an item multiple times using redundant selectors.
- Example: table.rows( ['', '', '', ''] ) would have selected all rows 4
  times!
2015-09-01 08:38:09 +01:00
Allan Jardine
8a4dc8a9d7 Fix: Using Array.prototype.push.apply can fail on larger tables / queries due to limits on the number of arguments that can be passed to a function, imposed by the various Javascript engines.
- The fix is to replace with more approriate options. The jquery
 `$.merge` function in particular is useful and array concat when we
 don't need to maintain a refernce.
- This fixes DataTables/DataTables #651
2015-08-31 14:26:04 +01:00
Allan Jardine
e48efdf316 Fix: Setting non-array data when DataTables has been told to expect an array results in a Javascript error. Although this is somewhat unexpected input, it is reasonable to expect DataTables to handle null values here, even although an empty array is much prefered.
- THis fixes DataTables/DataTablesSrc #55
2015-08-31 14:25:09 +01:00
Allan Jardine
4f27154fe4 Fix: Clear cache of row ids when the table is cleared. This is particularly important when server-side processing since the rows should no longer exist on the client-side when paging between records. 2015-08-28 12:20:41 +01:00
Allan Jardine
726bfe5ebb Fix: Rows could still be selected by id after they had been removed from the table. This could result in a memory leak as well as rows being selectable when they shouldn't be. 2015-08-28 12:20:11 +01:00
Allan Jardine
3a43de4224 Fix: Column data setter function would be called twice for the first row in the table
- This was caused by using `_fnGetRowElements` to get the cells. While
  it was good for performance with large number or rows to do so, it
  isn't needed for a single row and a single line of jQuery is simpliler
  and doesn't trigger the set function
- Fixes DataTables/DataTables #638
2015-08-27 10:54:28 +01:00
Allan Jardine
03dc5a31ac Fix: When using a DOM data source, the cell's data function, as a setter, would be called twice
- The issue was effectively duplicate code - for 1.9- compatiblity when
  I introduced 1.10 I had the set function run specifically if a DOM
  node was given. But later in the 1.10 series when it became possible
  to have the data written to an object rather than an array, that code
  would itself call the setter, thus leading to two calls when there is
  a DOM node present for the row.
- The first is simply to remove the code that was running the setter for
  the DOM specific case.
- This fixes DataTables/DataTables #638 and thread 25846. Thanks to
  @Jamaur and @strang91 for following up on this.
2015-08-25 15:10:06 +01:00
Allan Jardine
17d0ce4cce Fix: Columns could be set to 0 width in IE6/7 when there are hidden columns in the table
- This fix also comes out of DataTables/DataTables #633. Thanks again to
  @nddery and @epitaphmike.
2015-08-25 14:18:58 +01:00
Allan Jardine
7d3c5cc276 Fix: Browsers on Macs with zero width scrollbars would be incorrected treated the same way as IE6/7 causing column width calculations to be incorrect.
- The issue was caused by the check for the `bScrollOversize` option
  which looks for the container being the same width as its inner
  content area. Obviously that happens to be true if there is no
  scrollbar. Adding a check for the clientWidth not being 100 as well
  resolves this.
- I've also combined the scrollbar width detection with the other
  browser detect functions. The two functions were performing very
  similar operations and so easily combined
- The browser detect DOM creation will only run once, rather than for
  every table initialisation, optimising multi-table loading
- Fixes DataTables/DataTables #633 - Thanks to @nddery and @epitaphmike
  for the input
2015-08-25 14:18:30 +01:00
Allan Jardine
e7e439dd0a Fix: Cell invalidation would fail due to incorrect logic
- If d or objectRead were truthful then the row's data object would be
  replaced with an empty object. This was one shortcut in code too many!

- Relates to thread 29530 with thanks to idleog.
2015-08-19 14:40:22 +01:00
Allan Jardine
9ef7f1ad20 Fix: Compatibility with jQuery 2's isPlainObject. API instances were returning as plain objects
- This appears to be caused by setting the prototype chain as an object
  directly. For example:

  var test = function () {};
  test.prototype = {};
  $.isPlainObject( new test() );

  will return `true` with jQuery 2.1.4 (and `false` for 1.11.3).

  If an item is added to the prototype object then it will return
  `false`, although for some reason that wasn't the case with
  DataTables' API prototype.

  More investigation required, but for full compatiblity with exisiting
  jQuery releases, the correct thing to do here is to build on the
  exisiting prototype, which we can do with `$.extend`.
2015-08-19 12:25:28 +01:00
Allan Jardine
3950e119e2 Fix - docs: Add note to dt-api draw() that the string options require 1.10.8 or newer 2015-08-19 09:54:48 +01:00
Allan Jardine
a6e75123eb Update rows().ids().xml
Spell mistake
2015-08-19 09:54:19 +01:00
Allan Jardine
7898f4e585 Merge branch 'master' of github.com:DataTables/DataTablesSrc 2015-08-19 09:53:47 +01:00
Allan Jardine
52531db870 Update selector-modifier.xml
Just a small spell mistake
2015-08-19 09:52:44 +01:00
Allan Jardine
085d7f3137 Fix: Row invalidation would throw an error when reading from a DOM row
- Fixes DataTables/DataTables #623
2015-08-17 09:34:39 +01:00
Allan Jardine
44b1402fa6 DataTables 1.10.9 development starts 2015-08-17 09:34:10 +01:00
Allan Jardine
f91373337b DataTables 1.10.8 release 2015-08-12 19:49:47 +01:00
Allan Jardine
60273a0a75 Dev: Update the new rowId option to be able to read the id from the DOM 2015-08-12 19:49:29 +01:00
Allan Jardine
9cc3be030f Fix: Calculation for horizontal scroll bar adjustment when the dt-init scrollCollapse parameter is set could be incorrect when the standard height exceeds the window height.
- This is an interesting one, and I suspect a bit of an edge case in the
  browsers - what is happening is that the window is going from having a
  scrollbar to not having a scrollbar when the scrolling viewport is
  collapsed. This causes the browser to show the scrollbars in the
  viewport for an instant, even although they aren't actually required.
  If the height of the viewport is 53px and you up it to 80 so there are
  no scrollbars and reduce it back to 53 the scrollbars are gone! The
  browser must be stopping a race condition once the scrollbars are
  shown.

- The fix is to use `max-height` for the scrolling container if the
  scroll collapse is set and `height` otherwise. The browser native
  methods makes the code _much_ easier to work with, more performant and
  easier to understand.
2015-08-10 17:47:34 +01:00
Allan Jardine
07c04c69f8 Dev fix: Commit f2df0716 removed a check for IE6/7 to disable the smart
column width for these tables. However, that was in error - it is in
fact required still as the smart width calculations cause the browser to
crash (APPCRASH). There is no indication as to why this is, not is it as
simple as just disabling one or two pieces of code to stop the crash.
This leads me to suspect that it is the number of operations being
performed - particularly to do with the cloning of the elements. If this
is the case, then its just never going to work. Also IE6/7 are such a
small market now (thank goodness) this is just a feature that won't be
available in those browsers.

If anyone is interested in working on fixing it, or paying me to do so,
I'm happy to hear from you :-)
2015-08-10 17:47:12 +01:00