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

1051 Commits

Author SHA1 Message Date
Allan Jardine
ab13fcfcfd Dev fix: Add renderer as an initialisation parameter
- The core logic was already present, it just wasn't in the defaults or
  available to be set in the init object
2013-12-27 22:43:44 +00:00
Allan Jardine
f3a7f909bb Dev fix: Background row colour was only being used if the display or
stripe class was added.
2013-12-20 12:01:27 +00:00
Allan Jardine
1fffb2f5d1 Dev fix: Fix error with stylesheet whereby the last row didn't have a
border
2013-12-20 12:00:47 +00:00
Allan Jardine
af287d50a2 Dev fix: The columning classes should be applied to the columns the user
has selected for sorting, not the data sorted columns (although they are
usually the same)

- https://datatables.net/forums/discussion/18714
2013-12-19 14:24:37 +00:00
Allan Jardine
cece4c7c18 Fix: Add jQuery to the anon wrapper function, so a different version can
be passed in if needed

- Based on the discussion in
  http://datatables.net/forums/discussion/18792
2013-12-19 14:04:25 +00:00
Allan Jardine
d7f487ad10 Update copyright license for SpryMedia Ltd 2013-12-19 14:01:19 +00:00
Allan Jardine
282f56e9bb License: Update to be MIT license 2013-12-11 17:20:42 +00:00
Allan Jardine
c95dd530b7 Dev: Add new _fnDataSource function to get the data source and simplify
some logic conditions
2013-12-11 17:20:31 +00:00
Allan Jardine
c6d8545319 Api: ajax.url().load() should also have a resetPaging option
- ajax.reload() and ajax.url().load() now have the same options
2013-12-11 10:57:25 +00:00
Allan Jardine
1daaf4e473 Dev fix: Show "Loading..." message when using ajax option not just
sAjaxSource
2013-12-11 09:32:28 +00:00
Allan Jardine
c20681668a New: no-footer class automatically added to the table when no tfoot
- It appears that ti is impossible to know in CSS if a table doesn't
  have a tfoot element reliably and cross browser, so I've added a class
  which is added to the table automatically if the table has no footer
  or the fotoer is empty to complete the styling of the table.

- Fixed error when there are no cells in an empty TR row in the footer.
2013-12-10 17:54:53 +00:00
Allan Jardine
7a171b14c2 Dev fix: row().child() checks for undefined now since an empty string
would be a valid input for a details row. Not a useful one, but
none-the-less a valid on.
2013-12-10 17:31:46 +00:00
Allan Jardine
c85bcab903 New: Add postfix fixed ordering option
- With the change to camelCase, it is easier to extend the usageof
  optiosn now, and in this case I've allowed the `orderFixed` (formally
  `aaSortingFixed` parameter to be passed in as an object as well as an
  array. As an object the `pre` and `post` parameters are used to
  specify prefix and / or postfix ordering. Useful for gouping.
2013-12-10 17:31:35 +00:00
Allan Jardine
dd1e7600ac Dev fix: Destroy wasn't working when using deferred rendering
- The _pluck() function that was being used to get the tr elements
  didn't remove nulls, while jQuery doesn't like removing a class from!

- Thanks to `RagingTroll` in the forums for spotting this:
  http://datatables.net/forums/discussion/18651
2013-12-09 13:05:30 +00:00
Allan Jardine
18c53eaed5 Dev fix: When using _fnExtend to extend with an object, need to check if
the property being expanded is an object or not. If not, then set it to
be an empty object which will be extended. Only really effected the
`ajax` property
2013-12-09 12:52:06 +00:00
Allan Jardine
7e67778c51 Dev: Change to how the init object is copied for multiple tables
Based on the discussion in the forms (
http://datatables.net/forums/discussion/18456 ) the fix from 8935b8a
wasn't good enough. What was happening was that the _save_data function
was doing a deep copy of all arrays (minus the data array) so the
default sort was stil applied.

The fix is to reinstate the _fnExtend function which does a jQuery like
deep extend on objects and a shallow extend on arrays. That is extended
slightly to allow array references to be broken on initialisation, to
resolve the issue 8935b8a attempted to (sorting array would be used for
two tables for example), by an optional parameter. This should resolve
the issue correctly this time!
2013-12-05 12:01:44 +00:00
Allan Jardine
8f356ab917 Dev fix: When no ordering was aplied to the table, the next order would
throw an error
2013-12-05 12:01:33 +00:00
Allan Jardine
703ee53c47 Dev fix: API - destroy() was giving a JS error on scrolling tables
- http://datatables.net/forums/discussion/18584
2013-12-04 17:10:59 +00:00
Allan Jardine
d0a0ef8ad1 Dev fix: $.fn.dataTable and $.fn.DataTable should both have the same properties available
- This fixes DataTables/DataTables issue #241.

- Most of the properties attached are objects, so we want the references
  to them, rather than a copy, so a simple assignment is all that is
  needed. Strings etc will continue to work as well.
2013-11-29 11:59:43 +00:00
Allan Jardine
d4a1028a1d Dev fix - Full backwards compatiblity with fnServerParams with array
syntax paraneter names

- Data added using fnServerParams with array syntax had different
  behaviour in 1.10 from 1.9. In 1.9 jQuery would create an array for
  us, but in 1.10 before we create an object first, we need to create
  that array ourselves. So the following code had different behaviour:

		"sAjaxSource": "data/arrays.txt",
		"fnServerParams": function ( d ) {
			d.push(
				{name: 'somekey[]', value: 'somevalue1'},
				{name: 'somekey[]', value: 'somevalue2'}
			);
		}

In 1.10 it would have sent `somekey[] = somevalue2` but 1.9 would have
sent both as part of an array.

To maintain full compatiblity with 1.9 we need to convert this syntax to
an array - this commit does that.

I was concerned about using parameters in the brackets, but jQuery only
searches for `[]` when performing this conversion. We could use $.param
and then decode the created query string, which would be absolutely 100%
comaptible, but would involve additional code and I think this method
provides that 100% compatiblity from reading the jQuery code), and its
shorter.
2013-11-29 11:36:03 +00:00
Allan Jardine
208b3ba6a1 CSS: Add border-spacing: 0 to the stylesheets
- This is the CSS version of the cellspacing attribute on the table in HTML. It will work in all browsers except IE6/7. IE8+ and the others are all fine. So for the moment most of my examples will continue carrying the cellspacing attribute, but this is useful to have in the core css
2013-11-25 09:23:57 +00:00
Allan Jardine
4549646891 Dev fix: Sort indicator items weren't being redrawn
- Confusion aorund the `order` and `sort` events which resulted in the
  sort icons not being updated
2013-11-21 13:46:17 +00:00
Allan Jardine
7a32f2db93 API: Column selector - add support for visible indexes counting from the right
- The ability to use negative numbers as a column selector for the
  column data index was added recently, but that didn't include the
  ability to work with negative numbers with the :visible pesudo
  selector. This commit adds that ability so you can do:
  `table.column("-1:visible")` to always get the right most visible
  column
2013-11-19 13:55:08 +00:00
Allan Jardine
32e27fcc2f Api: Column selector - jQuery selector as a string, an name selector
with :name postfix.

- Previously you could use a jQuery selector for columns by using the
  :jq postfix, and names were matched otherwise. This is reversed now
  for consistency with the rows and cells selectors which treat strings
  as jQuery selectors without the :jq postfix.
2013-11-19 13:54:53 +00:00
Allan Jardine
e82068e7b3 Dev fix - incorrect fix for the API extend method before. Was looking
its own reference
2013-11-19 13:54:41 +00:00
Allan Jardine
6740193eed Dev fix: The API chaining was a little broken if the inner function
returned undefined, null etc.

- The base issue was in the instanceof check which has a priority error,
  it was:
    ! obj instanceof _Api
  which is the same as:
   (! obj) instanceof _Api
  which is rubbish.

  We want:
    ! (obj instanceof _Api)
  but there is of course a wrapper function, so that needs ot be taken
  into account as well. The new logic does just that.
2013-11-19 13:54:14 +00:00
Allan Jardine
8919616833 Docs: row() and rows() API documentation 2013-11-19 13:54:02 +00:00
Allan Jardine
8dcdb94b15 API - invalidate() methods - add an "auto" option that can be passed
rather than jsut an empty string as auto
2013-11-19 13:53:48 +00:00
Allan Jardine
48fd750bd8 Fix: Initialisating multiple DataTables with a single call was broken
- Because of the manipulation of the initalisation object initialisation
  of multiple tables with a single jQuery call (i.e.
  `$('.dataTable').dataTable();`) was broken since the second table
  would see the modified init object. Need to take a coopy of the object
  before entering that state.

- This could probably do with a bit of a clean up sometime...
2013-11-19 13:53:36 +00:00
Allan Jardine
8a5712b7e9 Update - init options: Rename displayLength to pageLength for consistency
- The displayLength option is poorly named, particularly with the new
  API refering to it as the page length (page.len()) so, using the new
  translation option to allow backwards compatiblity while using new
  parameter names, I've updated this parameter's name and its
  documentation.
2013-11-18 13:43:58 +00:00
Allan Jardine
7119dfa50c API: Selectors - 'filter' selector modifier renamed to be 'search'
- Renaming in keeping with the new terminology
- Updating example which uses it (main documentation still to be
  written)
- Backwards compatible with a bit of logic to check if the old version
  is being passed in
2013-11-18 13:43:46 +00:00
Allan Jardine
d47da33826 Old API: Mark $ method as deprecated 2013-11-18 13:43:34 +00:00
Allan Jardine
a423c0f457 API - dev: Remove the plugin() methods from the new API
- Decided that it would be better to provide the new API by having
  plug-ins extend it directly, rather than providing their own API.
  Using the plugin() method it was possible to get a plug-in insta,ce
  for example TableTools, but the way it should work is that TableTools
  would provide a tabletools() API method, registering it as an
  extension to the DataTables API objects. Further more, TableTools
  should provide methods such as row().select() etc, extending the
  current API rather than doing its own thing which the plugin() methods
  prompted.

- No backwards compatiblity issues here as the plugin() code hasn't
  shipped as a release.
2013-11-18 11:46:39 +00:00
Allan Jardine
635a027057 Dev: Remove the static construct method that had been added as part of 1.10
- I added a static DataTable.on() method previously in the 1.10
  development for a single event called `construct` which would tell us
  when a table was constructed. But I've realise that since the events
  that DataTables' triggers bubble up through the document, that effect
  can already be achieved:

- Use:
  - $(document).on( 'init.dt', function ( e, settings ) { } );

- Rather than:
  - $.fn.dataTable.on( 'construct', function ( settings ) { } );

- No backwards compatiblity issues as the DataTable.on code was never
  shipped, its dev code only
2013-11-18 11:46:15 +00:00
Allan Jardine
0f18491cf1 New: Warning on generic Ajax error (404 etc)
- Previously DataTables would only show an error message if there was a
  JSON parsing error. However, if there was any other kind of error,
  such as a 404, it would just silently swallow the error. THink its
  best to show an error and a tech note.
2013-11-18 11:46:04 +00:00
Allan Jardine
6dcc69ee54 New: DataTables events are now all bound to the .dt namespace
- This is a breaking backwards incompatible change - please be aware of
  this!

- DataTables fires custom events such as `draw` etc, but these events
  were in no way identifyable as eminating from DataTables rather than
  some other component, which can cause confusion and difficulty
  resolving bugs.

- As such, all DataTables events are now fired with the `dt` namespace -
  this means if you are currently using events, you must update your
  code to also use the .dt namespace. If you are already using
  namespaces, that's great, you can continue to do so as jQuery allows
  multiple namespaces, but you must still use the .dt namespace.

- This is a breaking change because the old behaviour was incorrect -
  i.e. this was a bug to be fixed, hence why we haven't gone through a
  deprecation cycle. The old events weren't well documented (only in the
  JSDoc generated docs and a few of my forum posts), whereas in 1.10
  they will form a key part of the documentation. As such, now is the
  time to get this right. This will be documented clearly in the upgrade
  notes.

- Discussion on this topic here:
  https://github.com/DataTables/DataTables/issues/245
2013-11-18 11:45:41 +00:00
Allan Jardine
ed4afe6178 Api: Column selector - add the ability to select columns counting from
the right by passing in a negative number
2013-11-14 17:21:48 +00:00
Allan Jardine
48931bbb18 Api - columns: Corrections found durating documentation:
- columns().cache() should check for the parameter 'search' for naming
  consistency

- Plural error on column().nodes()

- Change column.index() fromIndex/toIndex to fromData/toData - its an
  index be it data or visible, so the old method was meaningless
2013-11-14 17:08:24 +00:00
Allan Jardine
debea960c6 Api fix - cache() method should look for 'search' as the passed in
parameter
2013-11-14 17:08:10 +00:00
Allan Jardine
5c9d54e6f5 Api: table().header() and table().footer() methods for naming consistency
- The columns() methods have header() and footer() children to get the
  header and footer cells for the columns. For naming consistency the
  table() methods should be named likewise
2013-11-14 17:07:57 +00:00
Allan Jardine
b956a69271 Fix - API: Errors in plurals and signular forms of method naming 2013-11-13 16:22:04 +00:00
Allan Jardine
7cf5f904d8 New: Api methods - to$, toJQuery and join
- to$ - Convert the result set to a jQuery object. Compliment to the
  toArray method. This is mainly useful when working with the node() and
  nodes() methods.

- toJQuery - Alias of to$

- join - Array join method
2013-11-13 16:21:52 +00:00
Allan Jardine
da8358ce48 Updated: Update examples and documentation for the change in committed
in cdc6399 to make naming more consistent
2013-11-12 19:18:51 +00:00
Allan Jardine
e1f0fd2dee Updated: Naming consistency for searching and ordering
- With the new API the filter() and sort() methods already have meaning
  (the array methods built into Javascript) so the methods for filtering
  and sorting in the API are called search() and order() respectively.
  However, the intialisation parameters and events in DataTables use a
  mix of filter, search, sort and order in their terminology so this
  commit harmonises on just search and order, updating where
  appropriate.

- There are a number of incompatible changes if you are already using
  the new options in 1.10, but no incompatible changes to the latest
  release (1.9.4). 1.10 changes:
    - Server-side processing, the new parameters sent have been updated
      to refelect the new terminology
    - The Ext object likewise has been updated

- Default with the old options and padding int he old options will still
  work as before, compatiblity functions have been added to provide
  mapping. If both are provided the new parameter value will take
  president.

- The change is primarily around `sort` since that was reasonably
  consistent in its terminology for the initlaisation parameters before.
2013-11-12 19:18:40 +00:00
Allan Jardine
c8d2ebedc1 Merge branch '1_10_wip' of github.com:DataTables/DataTablesSrc into 1_10_wip 2013-11-12 19:18:18 +00:00
Allan Jardine
8c2c65c9dd New: Cached footer cells can now have colspan properties, allowing
column index referencing of the cells.

- Previously a colspan in a footer cell would cause index misalignment -
  for example if you had a table of 6 columns with two in the footer
  (one colspan=5) the fotoer cells would be assigned to the first two
  columns in the table, breaking column index order. Now a cell can be
  used over multiple columns. This allows column().footer() to always
  reflect the cell that belongs to that column (possibly sharing it with
  other columns).

- Note that the footer will only use cells from the first row in the
  footer. If there is more than one row, use table().foot() to access
  the TFoot element and then manipulate it as needed.
2013-11-12 19:18:06 +00:00
Allan Jardine
ad973fec36 Fix - docs: Error in examples for xhr event 2013-11-12 19:17:54 +00:00
Allan Jardine
d389c6d348 Docs: Event docs in the new XML format for the web-site 2013-11-12 19:17:31 +00:00
Allan Jardine
a287b560b8 New: Add built-in support for percentage numbers 2013-11-12 19:17:18 +00:00
Allan Jardine
45f9be18ed Docs: Complete the XML docs for the top level DataTables options 2013-11-12 19:16:40 +00:00
Allan Jardine
87832058d4 Docs: More documentation of the options 2013-11-12 19:16:28 +00:00
Allan Jardine
90599e45a6 Docs: Further documentation of the options DataTables has available 2013-11-12 19:16:15 +00:00
Allan Jardine
9eb7164152 Fix: On pages which use *{box-sizing:border-box} scrolling would break
- The fix here is to set the box sizing for the table and its cells to
  be content-box sizing to allow the column width calculations to occur
  correctly - 17932
2013-10-24 13:20:13 +01:00
Allan Jardine
fd550de897 Update file header to use minifier friendly copyright header
- JSDoc comments still exist, but the information is to some degree
  duplicated.

- Copyright header matches what is used in the minified script now
2013-10-19 19:01:34 +01:00
Allan Jardine
62aef83013 Examples - Add initialisation code, HTML and other information to
display

- In the examples we want to show the following information to help
  developers to get to grips with DataTables more readily:
    - Init javascript code
    - HTML used for the table
    - Additional CSS used
    - Ajax loaded data
    - List of the libraries files loaded in the example

- All but the last point is complete, a bit of styling and information
  text.
2013-10-16 12:03:14 +01:00
Allan Jardine
6c10109119 Dev: Update JShint file for JShint 2.1 and apply fixes from errirs it
spotted
2013-10-15 15:31:45 +01:00
Allan Jardine
c916bb05fe New: search() and column[s]().search() API methods now have a 'get'
option

- By passing in no parameters to the search API methods we can get the
  current search value - for example:
      $('#example').DataTable().search();

- This is to round of the API as the order() method already has a get
  option as to the paging information
2013-10-15 15:31:35 +01:00
Allan Jardine
ecd36146e9 Examples - update server-side processing examples for new data
New: Server-side processing scripts rewritten to use PDO and use a class
with static functions for code sharing between all examples.
2013-10-15 14:40:19 +01:00
Allan Jardine
c9c8e65708 Updated - server-side processing support for camelCase variables
- As part of the 1.10 move to camelCase the server-side processing
  return now accepts camelCase variables as well as the old 1.9
  hungarian notation.
2013-10-14 17:33:54 +01:00
Allan Jardine
a70f109ac4 Dev - code regoranisation for new methods
- Variables and functions which are to be private in DataTables, but
  available across all files have a single leading underscore.

- Variables and functions which are to be private in a single file have
  two underscores (but no self executing function to restrict scope as
  that will just take extra space).

- Externally exposed functions and JSHint globals list updated
2013-10-14 14:06:09 +01:00
Allan Jardine
fa5b99a586 Update exposed functions list 2013-10-14 14:06:00 +01:00
Allan Jardine
686b9c9b72 Size: Refactor _fnBrowserDetect slightly to reduce size a small amount 2013-10-11 17:31:33 +01:00
Allan Jardine
a9035942d0 New - API: plugin(), plugin.register() and plugin.deregister() methods
- When working with plug-ins such as TableTools, there is no clearly
  defined way at the moment to get at the plug-in instance, with each
  doing it its own way (TableTools as a static function, while Scroller
  attaches itself to the settings object and KeyTable is its own
  intialiser, amoung others...) so I'm introducing these methods to
  unify this.

- plugin() is used by DataTables users to get their plugin instance, for
  example `table.plugin('tabletools')` would get the TableTools
  instance allowing full access to its API.

- plugin.register() and plugin.deregister() are called by the plug-ins
  when they attach themselves to a DataTable. The 'extras' will all need
  to be updated to use this new method.
2013-10-11 17:19:10 +01:00
Allan Jardine
846c4d9c60 New - API: Static on() method, which listens for static events from DataTables
- Some plug-ins would benefit from be able to automatically initialise
  when a DataTables is constructed, to this end, a construct for static
  events is added here, with the static function $.fn.dataTable.on()
  listening for events. Currently only the `construct` method is
  available, although others could potentially be added in future if
  they are useful. As such, the code driving it is intentionally simple
  for this cas,e but the API abstract enough to allow future expansion.

- There is no `off()` method, as I'm not sure it would be that useful.
  Could be added in future if needed!
2013-10-11 16:09:30 +01:00
Allan Jardine
4e05760b20 New: Add callback function to the ajax.url().load() and ajax.reload()
methods
2013-10-11 16:09:19 +01:00
Allan Jardine
8f975060d8 New: Server-side processing parameters update
- The server-side processing parameters used by DataTables 1.9 are very
  ugly, and rather arkward to work with, so in keeping with the
  camcelCase approach of 1.10 and its general monderisation, when using
  the `ajax` option to set the ajax url for data, DataTables server-side
  processing will now use a much more modern method of telling the
  server what data is required - specifically using arrays and objects
  in neatly formatted data.

- The old 1.9 method is invoked if sAjaxSource is used to set the ajax
  url, or if $.fn.dataTable.ext.legacy.ajax is set to true. As such,
  this change should be fully backwards compatible since `ajax` is a new
  option in 1.10.

- This new ability adds 334 bytes to the min file, primarily, because
  the old method is retained (using just the new method would actually
  reduce the size slightly).
2013-10-11 15:39:54 +01:00
Allan Jardine
9d642814cc Size - refactor Ajax server-side processing parameter builder 2013-10-11 14:22:10 +01:00
Allan Jardine
3e0637f910 Dev: Fix type in last commit 2013-10-11 14:22:00 +01:00
Allan Jardine
c3a2ad6f40 ize - refactor _fnInitialise for size. Only about 60 bytes saved 2013-10-11 14:21:49 +01:00
Allan Jardine
5c0cdd86cd Size - refactor sizing functions to reduce file size and modernise code
- The _fnCalculateColumnWidths is probably the oldest function in
  DataTables which has mostly reamined as it was 5 years ago! However,
  its time to trim it down a bit and optimise now. This rewrite has all
  the same actions, but results in a minified file which is about 700
  bytes smaller than before.
2013-10-11 14:21:38 +01:00
Allan Jardine
920b7671fb Dev fix - Broke non-scrolling tables with the scrolling refactor 2013-10-11 09:48:22 +01:00
Allan Jardine
70a3f88d8d Dev - tidy up changes 2013-10-10 17:47:11 +01:00
Allan Jardine
b178ab69a2 Removed - bAutoCss and refactor scrolling functions for size
- The bAutoCss parameter is not one that I've ever actually seen used,
  so I've dropped it out here to reduce complexity. It was only useful
  for making the scrollbars always visible on the table, which can just
  as easily be done with `div.dataTables_scrollBody { overflow: scroll
  !important }` since that will take a heigher priority that the
  DataTables appled style.

- The moster _fnFeatureHtmlTable and _fnScrollDraw functions have been
  refactors, saving around 1.5K in size (in the minified file)
2013-10-10 17:46:59 +01:00
Allan Jardine
fb2f40a455 Removed: bScrollInfinite and iScrollLoadGap
- The infinite scrolling feature of DataTables is inadequate as a
  solution for the problem it is trying to solve as it introduces a
  number of compatiblity issues with the rest of the API parimarily
  due to the fact that it "tricks" the rest of DataTables into drawing
  just a small proportion of the table, leaving the elements which are
  currently in place. This means that DataTables doesn't realise that
  the table has additional rows at the top of the table, thus breaking
  numerous interactions with the API and confusing developers. As such,
  its a poor feature that is just taking up space and could be done much
  better externally.

- I will write an infinite loading feature for DataTables in future for
  users that do what to use this ability - there is nothing stopping a
  simple scroll event being attached to the scrolling element and
  calling the rows.add() function. This is exactly what the new plug-in
  will do.

- Scroller is a much better solution for defined length tables.
2013-10-10 17:46:48 +01:00
Allan Jardine
c31d3a1447 Dev: Refactor the filtering HTML creation function - save 138 bytes on
file size
2013-10-10 17:46:36 +01:00
Allan Jardine
3795134856 New: Default Ajax source property updated to be data
- In keeping with the camelCase name changes for DataTables 1.10, the
  default Ajax data source object property name has been updated from
  `aaData` to just `data`. Note that this is a fulyl backwards
  compatible change - if aaData is present in the data, it will be used.
2013-10-10 17:46:26 +01:00
Allan Jardine
fe1a5a630a Dev examples - Update ajax examples for new data and improved
descriptions
2013-10-10 17:46:15 +01:00
Allan Jardine
c470d7bfda New: sFilterInput and sLengthSelect class options for the <select> and
<input> controls used by DataTables for length change and filtering
respectively.

- Bootstrap 3 requires a styling class be set directly on the element,
  so in order to correctly support Bootstrap 3, which we want to do, we
  need to have the ability to set these classes. This commit adds that
  ability
2013-10-09 14:57:45 +01:00
Allan Jardine
bef8374eed Dev fix: Sorting a filtered table was broken
- Because of the decoupling of the filtering and sorting, the filtering
  was missing that the indexes of the displayed data will have changed
  after a sort. So need to do a full filter when just sorted
2013-10-09 14:57:34 +01:00
Allan Jardine
8debb87477 Dev examples - update bootstrap and foundation examples for example
styling

- Note that I've included the bootstrap and Foundation integration files
  in the resources folder. In future these files will be on the CDN, but
  that isn't up and running yet...
2013-10-09 14:57:23 +01:00
Allan Jardine
a11eb6d696 Dev fix: Error in full pagination type - missing first and last
buttons
2013-10-09 14:56:24 +01:00
Allan Jardine
6bd699b537 Dev fix: iDataSort and aDataSort conflicting on camelCase
- Simple fix is to check if it is a number or not
2013-10-09 14:56:12 +01:00
Allan Jardine
8573d5955c Update - init: scrollX can be set as true
- scrollX was often the source of frustration when setting it to
  anything other than "100%", which is was in the demos and
  documentation but it makes it easy to see that you could set it to be
  50% or anything else. That usually broke the developer's layout. So
  now you can just use scrollX: true, to enable horizontal scrolling.
  The demos have been updated for this.
2013-10-09 14:56:01 +01:00
Allan Jardine
888c4374e8 CSS: Automatically clear the DataTable wrapper element
- A numebr of support requests are about why the layout immediately
  after a DataTable looks wrong, and its usually because of the floats
  used by info / paging, so we self clear the wrapper around the
  DataTable controls
2013-10-09 14:55:24 +01:00
Allan Jardine
cdae9014de Dev - build process - examples
- Updating the build process to introduce the example builder to convert
  the XML example files into HTML files. This process is performed for a
  number of reasons:

  - Much more maintainable - links automatically updated
  - Add / remove examples easier
  - Modify page styling easier
  - Examples can be directly integrated into web-site since they are
    transformed by template
  - Common data sharing

- Note that the work on the new example build process is not complete in
  this commit, there are still a few things to do! css, media paths and
  completing the templates.
2013-10-09 14:55:01 +01:00
Allan Jardine
76ae8661c8 Dev: JSON API - store and return the original JSON object
- Rather than creating a new JSON object from the XHR, use the one that
  was returned by the server. This is useful if you manipulate the data
  since you want to just keep using the same object.
2013-09-23 11:45:23 +01:00
Allan Jardine
7c1d27ae5f Dev fix: HTML-5 attr detection could provide undefined functions
- The HTML5 attribute detection for sorting, filtering etc was breaking
  if you didn't provide a filtering _and_ sorting attributes since they
  created an undefined get data function, which causes DataTables to
  complain. Fix is to just check for a null value.
2013-09-23 11:45:14 +01:00
Allan Jardine
5a3401ee5b Fix: Add support for the input, paste and cut events in the filter input
- IE10 has a little `x` to clear text boxes which fires the `input`
  event, so we need to monitor for that in the filtering input.

- While I'm here, I've also added support for the paste and cut events
  to change the filtering when they fire. Via keyboard the fire on
  keyup, but not if you use the mouse. They do now.

- Not that it us possible to have multiple events fire (keyup + paste
  for example). The logic of checking for a change of input counters
  this.

- Thhis fixes DataTables/DataTables issue #227.
2013-09-23 11:45:06 +01:00
Allan Jardine
4e5cad9640 Size: The default formatNumber method has been reduced in size.
- Exactly the same functionality, but now uses a regex to perform the
  same operation
2013-09-23 11:44:58 +01:00
Allan Jardine
e61e402e37 Performance: On destroy, don't select tbody elements for event removal
- Based on thread 17024 - if you have a large table with a lot of
  elements in the tbody, the find('*') selector was of course selecting
  them all. That results in poor performance. DataTables doesn't add any
  events to the children in the tbody, so we can filter out those
  elemetns and keep the element list ot  a sensible size.
2013-08-23 10:11:42 +01:00
Allan Jardine
4d6081c3d2 Performance - HTML decode uses DOM directly rather than jQuery to speed things up
- Based on the discussion in forum thread 16961 and the results from
  http://jsperf.com/html-decode I've updated how the HTML decode for
  filtering is done to bypass jQuery and use DOM methods directly. It is
  more code but it is also much faster.
2013-08-22 09:30:02 +01:00
Allan Jardine
74a78b2010 Accessibility: Add live region attribute to table info, remove from table
- Based on feedback from Rich Caloggero in forum thread 13421 the ARIA
  live region DataTables was adding to the TBODY element of the table
  have been moved to the table information element, so screen readers
  don't go mad announcing the new informaiton in the table on every
  change, but rather just read the summary.
2013-08-20 15:58:38 +01:00
Allan Jardine
5ca931c23b Fix: null handling for type detection and filtering methods
- The built in filtering formatters and type detection need to be able
  to handle just about any data being passed into them. They were
  tripping up with null data being passed in before.
2013-08-20 15:01:51 +01:00
Allan Jardine
a798d53d17 Merge branch '1_10_wip' of github.com:DataTables/DataTablesSrc into 1_10_wip 2013-08-20 15:01:34 +01:00
Allan Jardine
e6840bd2cf New: Pagination language options (i18n) have _PAGE_ and _PAGES_ options
- Based on the discussion in forum thread 16938 DataTables now has the
  ability to use _PAGE_ and _PAGES_ in addition to the exisiting
  _START_, _END_, _MAX_ and _TOTAL_ options in the information language
  strings. This allows the developer to show paging information rather
  than record based information in the information element.
2013-08-20 15:01:25 +01:00
Allan Jardine
425eb38c5b Dev fix: API page.info().page should use 0 as the start index not 1
- Math.floor should be used to have page indexes starting at 0 rather
  than 1, since page(n) uses 0 based indexing.
2013-08-20 15:01:17 +01:00
Allan Jardine
e1f4a8fa9e Use named module for AMD include
Based on DataTables/DataTables/issues/214 this commit uses the optional id parameter for the AMD define function to give DataTables a 'name' for easy referencing.
2013-08-20 15:01:10 +01:00
Allan Jardine
d5eb393df9 New: DataTables tables resize automatically with window (and width="100%" attr)
- DataTables tables previously did not automatically adjust their sizing
  when the window width was changed, which let to a lot of additional
  calls to fnAdjustColumnSizing in peoples code (and support questions
  in the forums). This commit add adjustment to the sizing automatically
  for tables width have width="100%" as an attribute (we can't use CSS
  since we can't know if it is relative or absolute sizing) - extending
  what went before. This has full compatiblity with scrolling and
  non-scrolling tables. A throttle is used to not bring IE to its
  knees...
2013-08-14 12:15:18 +01:00
Allan Jardine
b00180b71e Dev fix: fnAdjustColumnSizing was reseting paging
- The shim layer call to api.draw() was telling the API to reset the
  paging, but it should have been holding it static (as it now does by
  passing false in to draw()).
2013-08-14 09:07:15 +01:00
Allan Jardine
c05d26fcb9 Dev fix: Spell _unique correctly in ext! 2013-08-09 12:06:43 +01:00
Allan Jardine
cbeaadcba8 Dev fix: Additional to the content-box fix form the other day - use
jQuery since browser specific styles can override the W3C option. jQuery
deals with it for us.
2013-08-08 14:51:51 +01:00
Allan Jardine
dd805f6623 New: CSS - Add .selected option to CSS for selected rows
- It is quite common to have a row selection styling in DataTables, so
  it makes sense to built this ability directly into the core CSS. It
  doesn't add too much extra weight, but it would be a huge pain for
  developers to do themselves and also it means I can reuse it in
  TableTools / Editor.
2013-08-06 17:18:56 +01:00
Allan Jardine
4c317c910a New - event - column-sizing - fired when the column sizing chages
- This event allows plug-ins (specifically FixedColumns in this this
  case is what I'm thinking of, but others such as FixedHeader could
  also benefit) to alter their layout when the column sizing is changed
  (for example by a window resize).
2013-08-06 10:26:05 +01:00
Allan Jardine
ac7fb22620 New: New event - column-sizing - fired when 2013-08-06 10:25:57 +01:00
Allan Jardine
f817e9a0be Dev fix: State saving was breaking on sort
- My fix a while back for detecting if a column was no longer available
  in a table was duff, since it used $.map which flattens its array
  return, but sorting needs a 2D array.

- Fixed by doing our own itteration
2013-08-06 09:08:10 +01:00
Allan Jardine
6447373eb6 Dev fix: Update filter formatters to deal with null / undefined data 2013-08-05 15:40:50 +01:00
Allan Jardine
38e12beac9 Fix: Arrays in settings object shared between instances
- Because of the way _fnExtend() was deep copying objects, but shallow
  copying (i.e. references) arrays, the arrays used in the settings
  object were actually being shared between all instances of DataTables
  on a page.

- This is most noticable in the column filtering, whereby if you apply
  a filter to the column of one table, it is applied to all tables!

- The fix is to dump _fnExtend and replace it with a typical jQuery
  extend. However, one special consideration is made for the data being
  passed it - we absolutely do want that reference to be retained (that
  + the fact that extend is slow on large arrays/objects) so it is
  dumped into a temp variable which is then assigned back to the cloned
  object.

- This fixed DataTables/DataTables issue #213
2013-08-05 09:04:23 +01:00
Allan Jardine
a242a848d5 Fix: Individual column sorting was not distinct for multiple tables
- The `settings.aoPreSearchCols` array was being shared between every
  table on the table (test using a simple:
    $.fn.dataTableSettings[0].aoColumns ===
    $.fn.dataTableSettings[1].aoColumns
  ) which meant that a column filter aplpied to one table would be
  applied to all others.

- Fix is to deep copy the search model when adding a columns

- Fixes DataTables/DataTables issue #213
2013-08-04 10:16:28 +01:00
Allan Jardine
3f79e6cce4 Fix: box-sizing: border-box would cause column misalignment when scrolling
- It is far from uncommon to do `* { box-sizing: border-box; }` at the
  top of your CSS these days, including in frameworks, but this could
  cause DataTables a little bit of a problem when scrolling both
  horizontally and vertically since the padding it adds to the header
  linear element to allow it to scroll over the vertical scrollbar would
  be folded into the width of the div linear, rather than added to it.

- Fix is to simply set the box-sizing for the linear. I've decided to do
  this in Javascript rather than CSS since it is going to be needed
  regardless of the CSS being used.
2013-08-04 09:26:02 +01:00
Allan Jardine
f9ac4c64e2 New: Currency, formatted numbers and HTML numbers sort types built in
- This commit sees the number of built in type detection and sorting
  functions increase to cover the most common cases of use of plug-ins
  for DataTables (witht he exception of dates, for which a new first
  class plug-in will be created). Specifically, DataTables now has built
  in support for:
  - Dates (Date.parse())
  - Numeric sorting
  - Formatted numbers sorting (including currency and thousands
    seperators)
  - Numbers wrapped in HTML (link tags for example)
  - Formatted numbers in HTML
  - HTML

Although the numeric sorting plug-ins could have been collapsed down to
just two plug-ins (rather than 4) I decided to do it this way to allow
type based filter formatters to be used with the formatted number types
to allow search for "100,000" or "100000" to match the same data. This
is not built in, but it is possible (and might be in future).

- The goal with these additional functions is to enhance the abilities
  of DataTables out of the box to cover the most common cases for data
  usage - DataTables is all about making data in tables more accessable
  after all! The size cost is ~300 bytes for these additional functions
2013-08-03 08:08:38 +01:00
Allan Jardine
59c6b530f3 Fix: A default for mData would not have been applied
- Fix for DataTables/DataTables issue #212
2013-08-03 08:06:54 +01:00
Allan Jardine
382482f8e9 Update: If there is no sorting methods for the column type, use string
- In the case of filtering, if there is no filtering extension for the
  column type, then the basic string based filter formatting is
  performed (i.e. string is always the fallback - there can't be an
  error because a function isn't there).

- This commit matches that behaviour in sorting. If you define a column
  type as something for which there is no column sorting function, then
  the string type will be used rather than resulting in a javascript
  error.
2013-07-30 19:06:44 +01:00
Allan Jardine
42170f6498 Dev styling - darken the paging button border slightly 2013-07-30 19:06:38 +01:00
Allan Jardine
c95f8c88d6 Size: Remove _fnColumnOrdering and replace with a _pluck call 2013-07-30 19:06:32 +01:00
Allan Jardine
16dea34d8c Update: Rewrite of column type detection
- Automatic column type detection was a real weak point of v1.9- - it
  did basically work, but if you then updated a row that didn't match
  the current data type it would always end up as a string. A good
  example of this is the ambiguous date "06-06-13" (is it dd-mm-yy or
  mm-dd-yy?). If it was detected as dd-mm-yy and then you add '05-20-13'
  to the column (or update an exisiting cell), the type would not match
  the exisiting value that thus failover to a string.

- Type detection is now more rigorous, but still optimised (since it
  has the potential to take up a significant amount of time). When a row
  is added or updated, or a cell is updated, the exisiting type is
  removed from the target column(s) and then, before sorting or
  filtering, the _fnColumnTypes function checks to see if any column
  needs to be type detected and do so if needed. This approach allows
  multiple rows to be added (for example) before the draw is performed and
  the type actually needs to be calculated.

- In future I'd like to have a 'data-ready' type event which will tell
  DataTables, and any of its components that something wants to work with
  the data in the table and it should prep the data. The counterpart would be
  a 'data-invalid' flag which would be set on update, add etc so it knows
  when an update is needed.
2013-07-30 19:06:25 +01:00
Allan Jardine
d9ce185f35 Dev fix: oApi backwards compatiblity issue
- The oApi option wasn't being attached correctly to either the settings
  object or the instance, so plug-ins were breaking. This adds the alias
  back in.
2013-07-26 15:55:40 +01:00
Allan Jardine
5e0e5ea5e4 Dev fix: Single column sort when not shift clicking the column
- If you were multi-column sorting, and didn't have shift depressed and
  click on the first column in the sorting priority, the multi-column
  sort would be retained. Non-shift click on any of the other columns
  would reduce to a single column sort, so match here
2013-07-24 15:09:37 +01:00
Allan Jardine
b7c6c98031 API: Update to extension API for camelCase support and tidy up
- This is a fairly far reaching commit in that the DataTables.ext object
  is updated to primarily use camelCase, just like the rest of the 1.10
  API. The old notation is still available for compatiblity, but
  deprecated.

- While working in this area, I've made a number of updates:

  - .model.ext has been removed - that was redundant and not useful.
    DataTables.ext is where the plug-ins for DataTables will live and
    will be correctly publically documented as such.

  - Type based actions (detection, sorting and filter) now live in a
    `type` namespace to make it clear that they are type based.

  - Internal references to .ext updated to use the new parameters. We
    could use the old ones since they are fully backwards compatible,
    but I'd rather set the standard by using the modern ones.

  - JSDoc comments for .ext updated

  - Extension examples updated
2013-07-24 14:51:01 +01:00
Allan Jardine
379a746034 Dev styling: Lighten selected paging button colour
- Reversed the hover and active paging colours as the black was rather
  heavy by default
2013-07-24 14:50:51 +01:00
Allan Jardine
36f720ca60 Dev fix: Volumne visiblity with scrolling enabled would misalign columns
- When creating the new visiblity methods, I forgot to have the table do
  a scroll draw to have the columns align correctly for the header and
  body. This commit fixes that.

- Also update the column visiblity example to use jQuery events rather
  than DOM0 events.
2013-07-23 10:47:54 +01:00
Allan Jardine
c822eefc4e Update: When Ajax loading data, now automatically ajust column sizing
- Previously you'd need to use initComplete and columns.adjust() to take
  account of the data that was loaded by Ajax. Now this will be done
  automatically. It does mean a few more clock cycles, but I think
  that's a tradeoff that is worth it.
2013-07-23 10:17:43 +01:00
Allan Jardine
c750514e98 API: Static methods updated for DataTables 1.10 camelCase
- Alias the static methods to camelCase and hungarian varients:
  - versionCheck()
  - tables()
  - isDataTable()

- Small updates in styling of the static functions
2013-07-23 10:17:32 +01:00
Allan Jardine
78e4d32e30 New: cache() methods for rows and cells.
- I'd previously added columns().cache() which gets the cached
  information about filtering or sorting, but this rounds the API off,
  extending that also to rows and cells:

  - rows().cache()
  - row().cache()
  - cells().cache()
  - cell().cache()
2013-07-22 17:58:08 +01:00
Allan Jardine
de1ec231cd Dev: Fix issue whereby you couldn't order with a click on a column after using order() API
Fix: I've removed the third entry in the aaSorting array, as the issue
was that after using order() that entry wasn't present. It was a bit
confusing as well, so it is now replaced with a property (_idx on the
aaSorting entries) which indicates the current sorting index (in
asSorting) - and this property is optional. If not given, it is looked
up or 0.
2013-07-22 16:04:01 +01:00
Allan Jardine
572e0ca9b9 Build: Usage for the make script 2013-07-22 15:28:06 +01:00
Allan Jardine
182eadf213 API: Column selector now allows {integer}:visible
- This is an alias of `{integer}:visIdx` which should be a little easier
  to remember.
2013-07-20 10:50:35 +01:00
Allan Jardine
2023aafd99 Dev: Update CSS file with the updated formatted used in the source repo 2013-07-20 10:46:30 +01:00
Allan Jardine
e8c3a0b96a Dev: New .datatables-commit-sync which is going to be used by the
build and commit scripts to keep the src and build repos in sync.

Dev: Update the dataTables main file to the latest build which was
accedentally committed. Just a couple of little dev fixes - no API
changes.
2013-07-19 15:17:26 +01:00
Allan Jardine
3ed88a9c87 Repo: Starting the split of the src and build repos.
- DataTables/DataTables is now going to be a build mirror of
  DataTables/DataTableSrc which will host the source core. Scripts will
  be used to build the generated files as there will be a number of
  these now (examples, JS, CSS, web-site documentation etc).
2013-06-27 21:22:56 +01:00
Allan Jardine
e84b102815 Dev: Fix error in fnDeleteRow shim 2013-06-25 11:39:47 +01:00
Allan Jardine
07f0a51ca8 Dev: Fix error in the mapping update 2013-06-25 11:39:31 +01:00
Allan Jardine
b7bbe0e1ff Merge branch '1_10_wip' of github.com:DataTables/DataTables into 1_10_wip 2013-06-25 10:09:33 +01:00
Allan Jardine
338b5e81cf New: columns().nodes() and column().nodes() methods
- Previously there was columns().cells() and column().cells(), but these
  were removed in f0a73ce due to the changes for the new top level
  cell() and cells() selector methods.

- This commit effectively re-instates those functions but under the
  `nodes()` name, matching the row and cell selection options. This is
  for completeness in the API.
2013-06-25 08:27:49 +01:00
Allan Jardine
4e04d1e977 Build latest changes 2013-06-24 22:15:42 +01:00
Allan Jardine
85a845aed2 Dev: Remove asDataSearch - its gone now 2013-06-24 22:02:27 +01:00
Allan Jardine
c1eeed8e1a Dev - refactoring _fnMap to improve compression. Saves about 500 bytes 2013-06-24 11:32:50 +01:00
Allan Jardine
cddcafc92d Dev fix: Wasn't correctly creating the element to insert a header row 2013-06-22 15:58:58 +01:00
Allan Jardine
fd10532f94 Dev: Altering how sort classes are applied to be a draw callback
- Previously the sort classes were being applied at the end of the
  _fnSort function, with a callback for when using deferred rendering
  and server-side processing (that was a performance hit for deferred
  rendering thinging about it, since it hapened twice).

- Now a single callback is used so sorting classes are applied only
  after the draw is done.
2013-06-22 14:08:53 +01:00
Allan Jardine
01444af1a6 New: Header renderers
- Rendering functions can now be provided for the header cells in the
  table, which will format HTML in the cells (note only the cells that
  are identified as the 'control' cell for the column have the renderer
  applied) and apply any classes needed (thus the renderers should
  listen for the 'sort' event).

- This is done to provide integration options for other frameworks and
  advanced styling controls. For example, FontAwesome could now easily
  be used to style a header with sorting icons sourced from the font.

- jQuery UI header rendering has been seperated out into its own
  renderer which is activated by the bJQueryUI initialisation option.
  This, along with the whole of DataTables' jQuery UI ThemeRoller
  support will be moved into a plug-in in 1.11 (it is very tempting make
  that change now, but one major version for the decprecated option is
  correct I think). This is the last part of the jQuery UI integration
  that needed to be decoupled from the DataTables core - it can now all
  be provided by plug-ins.

- This fixed issue #153

- Renderers still be to documented.
2013-06-22 11:12:40 +01:00
Allan Jardine
81a76059ae Dev: Refactor _fnBuildHead to be a good deal tidier and smaller
- Saves about ~300 bytes on the min file.
2013-06-21 11:37:20 +01:00
Allan Jardine
95be4568eb New: Support for box-sizing: border-box;
- Setting `box-sizing: border-box;` for table cells would cause
  DataTables to incorrectly calculate the size of the element when
  applying the scrolling draw. This is because jQuery's $().width()
  always returns the content width (taking into account box-sizing).

- One possible fix was to detect the box model used and switch between
  width() and outerWidth(), but a much better fix is to use
  $().css('width') as this does take into account the box-model and
  allows DataTables to draw the scrolling table columns correctly,
  regardless of the box model. It should actually also improve
  performance, since jQuery doesn't need to look the box model up
  itself.

- This fixes issue #157
2013-06-21 09:45:29 +01:00
Allan Jardine
370a1e7f7a New / update: The data option, when used as a function, is given and
can return only objects now.

- The new `ajax` option for 1.10 did previously allow both arrays of
  objects with name value pairs and objects, however, this change
  removes the option of using arrays of objects to try and simplify
  things. One of the most common questions in the forums is about name
  value pair objects, so this sidesteps that.

- The big benefit of doing this is that the data passed into `data()` is
  now very easy to manipulate. Rather than needing to loop over the
  array, you can just modify the parameter you want.

- It also allows an object to be passed back from the function,
  manipulated as desired. For example it is now super easy to nest the
  DataTables parameters in a sub-object:

	$('#example').dataTable( {
		'processing': true,
		'serverSide': true,
		'ajax': {
			'url': '../server_side/scripts/server_processing.php',
			'data': function ( data ) {
				return { 'myprop': data };
			}
		}
	} );

  This fixed issue #124.

- The parameters submitted to the server and those expected back are
  currently left as is. They will be updated to be camelCase at some
  point, but not yet sure if that will be for 1.10 or 1.11.
2013-06-21 09:26:51 +01:00
Allan Jardine
76e572985d Build latest changes 2013-06-21 07:38:46 +01:00
Allan Jardine
a194116c42 Dev: Fix display class for the sort column.
- Styles weren't being correctly applied becuase the selector was
  `table.dataTable.display.stripe` rather than just
  `table.dataTable.display` for the "correction" styles when multiple
  styles are enabled.
2013-06-20 10:08:40 +01:00
Allan Jardine
bda2d25b5f Internal: Change the application of global filtering methodology
- Reducing the complexity of how the global filter is applied in
  DataTables by removing the `asDataSearch` internal settings array
  which held information about each row's filtering data. This is now
  held on a per row basis in `_sFilterRow` which is built only when the
  data is invalidated. This should result in a small performance
  improvement as well as simplifying and reducing the code.

- Filtering is now implemented by simply checking the built regex
  against the `_sFilterRow` parameter for the display array (with a
  reset to master, as there was before, if needed)

- This also fixes an indexing issue that was present in the filtering in
  1.10.dev only
2013-06-20 08:52:52 +01:00
Allan Jardine
1a880b9f46 Dev: All the latest changes now built 2013-06-19 17:34:49 +01:00
Allan Jardine
3827b96b7d New: jQuery UI integration now has the sorting_* classes applied to it
for the header cells (matching the standard case, in addition to the
ui-state-default class for styling).

- This allows the developer to add styling information based on the
  sorting state of the cell.

- This fixed issue #17
2013-06-19 17:32:24 +01:00
Allan Jardine
3d8a0d2f30 New: Add sHeaderTH class option to the classes to match the sFooterTH
option

- This fixes issue 175
2013-06-19 17:11:21 +01:00
Allan Jardine
3d1d64bc4e Dev fix: Call number formatter in the correct scope 2013-06-19 16:46:22 +01:00
Allan Jardine
0d8282c61a Dev fix: _pluck should check that what is is accessing exists
- When using _pluck with deferred rendering, there were a number of
  errors due to the nTr element being undefined (that's what deferred
  rendering is all about of course). So the logic to check that pluck
  can pluck from a source object needs ot be added.
2013-06-19 16:44:38 +01:00
Allan Jardine
0142172027 Dev fix: The sort classes were being applied regardless of sort and
`sortClasses`
2013-06-19 16:43:12 +01:00
Allan Jardine
d2755c4037 New - init option: classes option can be used to modify the classes
object

- Previously to modify the class names that DataTables uses for its
  components you has to use $.fn.dataTable.ext.oStdClasses. Now you can
  use the `classes` initialisation option which will extend the classes
  object of the DataTable.

- This fixes issue #180.
2013-06-17 12:05:07 +01:00
Allan Jardine
5cecbb5528 New: Automatic detection of HTML5 data-* attributes for orthogonal data
- Building on the new ability of DataTables to work with element
  attributes as data sources for sorting and filtering, this commit adds
  auto-detection of the attributes 'data-sort' and 'data-filter' in DOM
  sourced tables.

- The first row in the table is used for this auto-detection and the
  built mData object assigned only when it is found to be the default
  for the column (i.e. the column index). So any custom value is
  retained and thus if you want to use a custom value you need to build
  the attribute querying object manually (I think the majority of uses
  will not need this!).
2013-06-17 11:35:06 +01:00
Allan Jardine
0f2cc15217 New: HTML5 data attribute support. data-* attributes can now be used to
source orthogonal data for filtering, sorting and type detection data.

- In HTML5 the data-* attributes can be used to add semantic data to an
  HTML page, which a user will not see, but the scripts on the page can
  interact with. DataTables now has the ability to use these attributes
  (actually any attribute can be used) as a data source. Previously DOM
  sourced tables always used just the content of the cells for all data
  interaction, but this can provide advanced controls in just the same
  way that Javascript / Ajax sourced data can do orthogonal data in
  DataTables.

- A typical use case is to provide numeric sorting information for
  complex formatted dates that the browser doesn't understand with
  Date.prase().
2013-06-16 09:49:18 +01:00
Allan Jardine
b353431cbe Dev: Documentation update to indicate more clearly that dataSrc can be
used as a transform function
2013-06-16 09:48:48 +01:00
Allan Jardine
3edd19ed9d Dev: Reduce code footprint for the Ajax get function 2013-06-15 09:53:39 +01:00
Allan Jardine
11591f4894 New - CSS: Add 'display' class to the options list.
- 'display' is a short cut for using the classes: 'hover stripe
  row-border sort-column'
2013-06-15 09:22:16 +01:00
Allan Jardine
fe390220cf Dev: Completing the work on the new SCSS stylesheet for DataTables
- The SCSS stylesheet is now feature complete, and the
  jquery.dataTables.css file found in the repo is now directly generated
  from that SCSS file. The SCSS online compiler will run the stylesheet:
  http://sass-lang.com/try.html .
2013-06-15 08:27:18 +01:00
Allan Jardine
3cabe9a6db New: Styling features can be added by CSS class.
New: SCSS base stylesheet with variables for colours
New: Pagination styling

- DataTables now has the ability to selectively enable different style
  types by applying different class names to the host table. The options
  supported are:
    - hover - show a hover effect over rows
    - stripe - show odd/even row stripes
    - row-border - show a vertical border between rows
    - cell-border - show a border around all four sides of a row (only
      one of row-border or cell-border should be used)
    - sort-column - highlighting of the sorting column.

 I will be adding another class along the lines of `display` which will
 enable 'hover, stripe, row-border and sort-column' (although this is
 not yet implemented).

 The reason for doing this is to encorage developers to style their
 DataTables more their own way, but making it easier to enable the
 features they want.

- To that end, the DataTables stylesheet will be generated from a SCSS
  template in future. The SCSS template is included in this comment
  (although the generated stylesheet is not yet committed). This allows
  colours to be changed which a trivial amount of effort, while still
  being able to get row highlighting etc, thanks to SCSS's colour
  functions.

- Pagination styles have been updated to fit in with the new styling of
  the DataTable.
2013-06-14 12:25:35 +01:00
Allan Jardine
0fb58706d1 Update to jQuery 1.10.x 2013-06-14 09:22:16 +01:00
Allan Jardine
3ab5af5ff5 New: Rewrite of how pagination is handled to make it hugely more
flexible and simple to actually use.

New: Two additional built-in pagination types: 'simple_numbers' and
'full'.

Update: 'two_buttons' type pagination (previous default) renamed to
'simple'.

New: Default pagination type is now 'simple_numbers'.

New: Introducing renderers to DataTables (something that will play an
important part moving forward).

New: Simplified pagination button classes to simply:
 * "sPageButton": "paginate_button"
 * "sPageButtonActive": "current"
 * "sPageButtonDisabled": "disabled"

- The basis for this commit is a restructuring of how pagination
  plug-ins work in DataTables, whereby the pagination plug-in simply
  returns an array of button types which should be shown. These are then
  actually displayed by the renderer. This seperates the logic for which
  buttons to show from the display logic, making it much easier, both to
  customise which buttons will be shown, and for integration plug-ins to
  customise the display of the buttons (since they don't need to
  replicate the button calculation logic). This change allows us to
  introduce two new built-in pagination types to DataTables with minimal
  size cost. Indeed, this change as a whole reduces the compressed
  DataTables size by 2.5K (additional functionality, simpler and smaller
  - what's not to like!?).

- Pagination button classes in DataTables were a mess before, with
  different classes used for the two built in types, with the additional
  complexity of only one of the defined class options being used, rather
  than concatinating the classes based on the type. This was bonkers and
  a barrier to new users styling the form as they wanted. Reducing to
  just three class options, and having the active and disabled options
  added to the base class makes it MUCH simpiler. This could hit
  backwards compatiblity for those who had styled the mad old style, but
  it would have been crazy to keep it while writing the rest.
2013-06-09 20:16:50 +01:00
Allan Jardine
e36609713c Fix issue #200 - images: sort_asc_disabled image was the wrong colour 2013-06-01 10:07:30 +01:00
Allan Jardine
a070ccc2b3 Build - latest changes 2013-05-29 09:13:49 +01:00
Allan Jardine
16bb9b0516 Dev fix #190 - When rows have been invalidated, a full filter is required
- If a row has been invalidated, then we need to perform a full
  re-filter, so we need to pass this invalidation information back up
  from the invalidation checker to the filtering functions.
2013-05-29 09:12:27 +01:00
Allan Jardine
748f8634cd Dev: All the latest changes built into the main file 2013-05-26 19:52:23 +01:00
Allan Jardine
86fd198fdd Fix - thread #14114: State saved table breaks if columns reduced
- If the number of columns in the table were reduced, then the column
  filter state that was saved would be incorrect since it would define
  more columns that there were. Equally sorting could potentially be
  done on a column that no longer exists.

- There were a few work around in the code already to try and address
  this a bit, bit not satisfactorily as seen by thread 14114. The real
  issue was that the columns were being detected after the state was
  being loaded - ideally we want to load state after the columns had
  been detected and throw away the state saved if the columns did not
  match since the table might be entirly different.

- This is done by a little bit of reordering in the constructor, and
  actually simplifies the code a bit.
2013-05-26 19:48:11 +01:00
Allan Jardine
ab7e797965 Dev fix: Loading from an initial draw position was broken
- I had inadvertantly broken the ability to set an initial draw position
  using `displayStart` or state saving with the small refactoring of
  _fnDraw and fnDisplayEnd. fnDisplayEnd must be called with
  settings._iDisplayStart set, which is now done simply by changing the
  order of calling a little.
2013-05-26 19:44:21 +01:00
Allan Jardine
b7915d7cf6 New: Initialisation option - sortMulti. Allow / disallow multi-coloumn sorting
- Multi-coloumn sorting might not be a feature that everyone wants, so
  the ability to disable it is added in this commit.

- This fixes issue #13.
2013-05-26 10:55:07 +01:00
Allan Jardine
20949ae51a New: HTML5 data-* attributes for the TR can be set using DT_RowData
property

- Extending the funtionality of DT_RowId and DT_RowClass, this commit
  adds DT_RowData which utalises jQuery's `$().data()` method to set
  HTML5 data-* attributes, which can be useful for additional meta data.

- This is some what complimentary to using objects as the data source
  where you could just use row().data() to get the data, but this is
  effectively an orthogonal way of getting the data and might be useful
  for existing Javascript libraries.

- It should be noted that the data-sort and data-filter work I'll be
  doing for v1.10 shortly will not interact with this method, that will
  be DOM sourced data only, while this is Ajax / Javascript based only.
  However, if you do want to use data from this source for filtering /
  sorting, its easy to do with `data` - `data: 'DT_RowData.sort'` for
  example.

- This fixes issue #45.
2013-05-26 10:40:29 +01:00
Allan Jardine
2be56a63fc Dev: Include row details API file
- Had split the row details out into its own file a little while back,
  since it is 100% self contained now, but hadn't committed the file!
  Here is it now.
2013-05-26 09:59:15 +01:00
Allan Jardine
4f1d05b65f Dev: Removing trailing white-space
- Non-functional change - just to tidy up the code styling a bit
2013-05-26 09:58:32 +01:00
Allan Jardine
cb3174c29e Fix: Remove dataTable class from the host table on destroy
- Fixes issue #188
2013-05-26 09:25:53 +01:00
Allan Jardine
7f1dfc2b38 Update: Provide link to technical note explaining errors for DT logged
errors

- A lot of posts in the forum are questions such as "what does the
  invalid JSON response" error mean, or "how to fix the unknown
  requested parameter error". To address these, rather than having them
  answered individually in the forum, I'm going to write a series of
  technical notes for DataTables (getting started, how to use columns
  etc) and as part of those, each error that DataTables can fire off
  will have a technical note explaining in deatil what the error means.

- Example:
   DataTables warning: table id=example - Invalid JSON response. For
   more information about this error, please see
   http://datatables.net/tn/1

- This commit puts the required logic in place. The technical notes
  don't exist yet, but they will soon. They will be:

1 - Invalid JSON response
2 - Non-table node initialisation ({this.nodeName})
3 - Cannot reinitialise DataTable
4 - Requested unknown parameter {param} for row {idx}
5 - Unknown paging action: {action}
6 - Possible column misalignment
		- The table cannot fit into the current element which
		  will cause column

- This also has the advantage that the errors in the DataTables code can
  be a little smaller. Around 500 bytes saved.

- This fixes issue #173
2013-05-26 09:15:21 +01:00
Allan Jardine
1b8f4608ac Update: Allow targets (aTargets as it was formally known) to be a
non-array element

- If found to be something other than an array, it will treat it as if
  it were an array with a single element in it, of the value given.
2013-05-26 09:05:35 +01:00
Allan Jardine
34f86db782 Build update - all the latest changes, compiled into the source file. 2013-05-25 08:21:55 +01:00
Allan Jardine
f9179058df Update: Deprecate old API. update api() method.
- With the new API that is being introduced in v1.10, the old API
  (fnUpdate, fnAddData etc) is being deprecated and retired. It is now a
  shim layer calling through the new API, rather than duplicating the
  logic of the calls, but is still provided for backwards compatiblity.

- It is _strongly_ recommended that you start to use the new API from
  this point in - very certainly for new projects.

- The api() method, is not deprecated, it is new in 1.10 and provides a
  way to get access to a DataTables API instance from the jQuery host
  object, if the table is initlaised with `dataTable()` (rather than
  `DataTable()` which does give you the API instance. It has a single
  option which is used by the old API's shim layer to allow it to use
  the iApiIndex option to get the context to be used.
2013-05-25 08:17:13 +01:00
Allan Jardine
22f350becd Dev fix: Fix name conflict and adding of TR elements
- There were two functions called _fnGetRowData, which were conflicting

- The $().map doesn't execute with the scope of the element, need to
  pass the element through to the get data function correctly.
2013-05-25 08:15:35 +01:00
Allan Jardine
f7c92e1270 Dev fix: rows.add() API was trying to get the row index from the wrong
parameter.

- Simple fix, just had the array index in the wrong location.
2013-05-25 08:14:21 +01:00
Allan Jardine
0b0fc5fe04 Dev fix: Fix new filtering API which was incorrectly assinging undefined
values to the filtering operators
2013-05-25 08:13:11 +01:00
Allan Jardine
73d36854e3 Dev fix: Fix flatten, which was returning an array rather than an API
instance
2013-05-25 08:12:44 +01:00
Allan Jardine
dd36646723 Dev fix: Fix case where trying to select row index 0
- row(0) was failing due to a logic error in the selector, which was
  ignoring the 0, or rather, treating it like an empty selector.
2013-05-25 08:11:46 +01:00
Allan Jardine
bea47e6470 New: columns and cell index() API methods
- The row()/rows() methods have index methods, so it makes sense that
  the column(s) and cell(s) methods also have index methods to get the
  raw information out of the table. Rather than shying away from the
  indexes in 1.10, as has been done with the pervious versions of
  DataTables, 1.10 will embrase them as first class citizens.

- New methods:
  - columns().index()
  - column().index()
  - cells().index()
  - cell().index()
2013-05-24 07:57:41 +01:00
Allan Jardine
01cc744b00 New: new data() method
- It is possible at the moment to use rows().data() to get the data for
  the table, you can use rows().data( { order: 'index' } ); to get the
  data in index order - I suspect a reasonably common use when working
  with the data set (at least, I use it that way!) and its a but clumsy
  to write that way, particularly compared to the old fnGetData method.
  So the new data() method is a short cut for `rows().data( { order:
  'index' } ).flatten()` to get the data set for the host table(s).
2013-05-23 21:58:44 +01:00
Allan Jardine
8e583a51b3 New: cells() and cell() API methods now accept a cell selector and options
- For consistency and completeness, the cell() and cells() methods now
  accept their own cell selector option (rather than just rows and
  columns) which is a jQuery selector, or no selector at all for all
  cells. Additionally it allows an options object to be passed in, to
  allow configuraiton of the order of data etc.

- The cells() method now has these calling options:
  - cells() - all cells
  - cells( opts ) - option configuration
  - cells( selector ) - cell selector
  - cells( selector, opts ) - cell selector + options
  - cells( rowSelector, columnSelector ) - row + column selector
  - cells( rowSelector, columnSelector, opts ) - row + column selector +
    opttions

- The cell() method as the same signature.
2013-05-23 19:07:30 +01:00
Allan Jardine
a30468a1f4 API: rows.add() and row.add() return a rows() (or row()) extended object
with newly added rows

- Looking at fnAddData, and about to replace it, I realised that
  fnAddData returned the indexes of the newly added row while the new
  methods didn't. It makes sense for row.add() to return a row()
  extended object with the newly added rows so row().node() etc can be
  used. Also the indexes are in the inst, so that information is also
  available. Likewise is done for its plural counterpart.

- Did consider creating an `augment` static method for the API, and
  might yet do this, but this is the only place to use it at the moment.
  Possibly it might be useful for plug-ins, but before adding, lets see
  how the new API is used.
2013-05-22 12:16:19 +01:00
Allan Jardine
fddc869390 API: Promote row().index() to work for plurals as well
- With the new plural option for registering API methods, there is no
  harm in adding rows().index() to get the indexes of the selected rows.
2013-05-20 08:55:42 +01:00
Allan Jardine
0ab8eb7ed0 Internal: Small enhancement to registerPlural to correctly deal with
same instance returns.
2013-05-20 08:45:12 +01:00
Allan Jardine
f5286dc130 Internal: Create registerPlural method to provide an easy way of working
with plurality

- There are four groupings of plural / singular methods in the new API:
  table(s), row(s), column(s) and cell(s). We need to provide similar
  methods for each, often leading to code duplication. To help reduce
  this code duplication I've created a new `registerPlural` method which
  allows both the singular and plural to be derived from a single
  function automatically. The plural form is given and wrapped up by a
  container function which extracts a singular return.

- Note that not all singular methods can use this approach, for example
  row().data() provides extra functionality over rows().data() in that
  it can be used as a setter as well as getter.
2013-05-20 08:37:19 +01:00
Allan Jardine
103e997db8 New: column() API methods for working with a single column
- To round off the API, this commit adds a column() method, for working
  with a single column, as with row/rows, cell/cells and table/tables.

- New methods:
  - column() - Column selector
  - column().data() - Get column data
  - column().header() - Get the column header cell
  - column().visible( set ) - Get / set the column visiblity
  - column().order( dir ) - Order the table by this column

- Note that I haven't implemented column().search() yet as I'm sure
  there must be a better way of dealing with the singular functions...
  Need to look at the four groups a bit more before this (and then the
  API :-) ) is finalised
2013-05-19 15:53:54 +01:00
Allan Jardine
1b4688cdf3 API: Consistency of data return for columns().data()
- The columns().data() method was flattening the returned array. While
  possibly okay on its own, that doesn't match the behaviour of how
  rows().data() works, where each row is an entry in the array, rather
  than the array being flattened. As such I've changed columns().data()
  to work work in the say way, for each column you select, you get an
  entry in the api instance - an array with the data for the that
  column.

- To allow for hte fact that some may want to work with the flattened
  data, I've added a `flatten()` method to the instance base, which is
  basically a shortcut call to `reduce`.
2013-05-19 09:54:46 +01:00
Allan Jardine
f0a73ce595 Dev: Removing row and column .cells() methods
- Now that we have the cells() / cell() methods, with the ability to
  select based on column and row, and the ability to get the whole row
  or column cells, the TD get methods on row / rows / columns were
  redundant and I think should be removed for berevity. It could also
  get confusing with the chaining since there are nested and top level
  methods with the same name.

- Removed:
  - rows().cells()
  - row().cells()
  - columns().cells()
2013-05-19 08:49:43 +01:00
Allan Jardine
1894b96a42 New: cell set data API method
- New API call:
  - cell().data( set ) - Ability to set data for a single cell. Will
    invalidate the whole row.
2013-05-19 08:47:33 +01:00
Allan Jardine
1590f41525 New: cell invalidation methods
- New API methods:
  - cell().invalidate() - Invalidate a single cell
  - cells().invalidate() - Invalidate multiple cells

- Note that the invalidation is actually row based, rather than cell
  based - i.e. the whole row is invalidated. This may change in future
  versions of DataTables, but I'm concerned that it would add a lot of
  code for little enhancement.
2013-05-19 08:43:45 +01:00
Allan Jardine
643930c33d Merge pull request #196 from timtucker/patch-38
Remove index from map call in pluck
2013-05-18 11:00:12 -07:00
Allan Jardine
623b24329a New: New cell based API methods
- New API methods:
  - cells( rowSelector, columnSelector, opts ) - Cell selector
  - cells( ... ).nodes() - Get the nodes for the selected cells
  - cells( ... ).data() - Get the data for the selected cells
  - cell( rowSelector, columnSelector, opts ) - Single cell selector
  - cell( ... ).node() - Get the cell node
  - cell( ... ).data() - Get the cell data

- There was a bug in `_selector_first` whereby it wasn't correctly
  reducing the set - was gatting away with it before, because it was
  reducing to a single element array, which has a toString() method
  which allowed it to appear to work for integers.
2013-05-18 18:56:04 +01:00
Allan Jardine
903d1219f3 New: table() API methods
- New API methods:
  - table() - select a single table
  - table().node() - get the table node for the table

- To be honest, these methods are not likely to be used particuarly
  often, so I think they are fairly low priority, but they could provide
  useful, and it is a public way to get the table node.
2013-05-18 17:39:03 +01:00
Tim Tucker
a74348f56a Remove index from map call in pluck
Pluck isn't using the index, so it's safe to remove the ", i" from the function call passed to map.  Not much, but at least a few fewer bytes.
2013-05-18 09:19:34 -03:00
Allan Jardine
d7b12bd83b New: Invalidation and data set methods.
- New API methods:
  - rows().invalidate() - Invalidate the matched rows
  - row().invalidate() - Invalidate the matched row
  - row().data( set ) - Set the data to use for the matched row

- This involves building upon the invalidation work done in the last few
  commits and creating an invalidation function. This new function will
  mark the cached data as invalid for re-reading by the sort and
  filtering methods (this will need to be abstracted into modules in
  1.11, but there is no infrastructure for that yet - that's what 1.11
  is all about). Additionally the invalidation method will update either
  the data held by DataTables (read from the DOM), or update the DOM if
  the data source was not the DOM. A flag allows an override to state
  the direction, although I think that generally speaking you might not
  want to use the override (you might nuke parts of your data source
  object if you read from the dom for example).
2013-05-18 11:49:48 +01:00
Allan Jardine
fbc28624ac Internal: Filtering invalidation
- Like sorting, for the new API we need to be able to invalidate data
  held for filtering in a fairly simple manner (it could be done before,
  but it was messy, see fnUpdate - you need to call the methods in the
  parent function, rather than just invalidating). This commit adds that
  ability to DataTables.

- Performance improvements:
  - The big one is that filtering data is only obtained and formatted
    when invalidated, rather than every full filter now.

  - Regular expressions for newline and HTML matching are variables,
    rather than redefined on every call.

  - DIV for reading text version of an HTML formatted string is a
    variable, rather than being recreated on every call.

- Type based formatters have been moved into the extension API ('string'
  and 'html'). They can be overridden there if wanted. Allows
  simplication of the call for the formatter.

- Fixes issue #158 as part of the refactoring.

- Smaller by 22 bytes (compressed)... Likely once invalidation is fully
  implemented that will be swallowed up...
2013-05-17 12:00:19 +01:00
Allan Jardine
6a6eed2db3 Internal: Refactor sorting classes for size and efficiency
- Refactoring _fnSortingClasses to be more efficient in how it operates
  and to compress better. This is done by looping first over the
  elements to have their classes removed, and then looping over only
  those to have them added. Previous all columns were operated upon.
  Also using _pluck and that fact that all cells fromt he tbody are
  stored makes the code much smaller, more readable and compressable.
  Only 0.5KiB saved in the refactor, but every little helps...

- Restored column sorting classes functionality that had been disabled
  earlier in the 1.10 development sequence.
2013-05-17 09:48:21 +01:00