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

1049 Commits

Author SHA1 Message Date
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
Allan Jardine
9f1cae4528 Internal: Refactor sort listener
- Think this code was in DataTables 1.0 and has been relatively
  untouched! A refactor allows it to be more readable and smaller when
  compressed (about 450 bytes saved)
2013-05-16 18:13:37 +01:00
Allan Jardine
682aa73d56 Internal: Refactor ARIA sorting attributes
- How the Aria sorting attributes were controlled, was ugly! Was in bad
  need of a refactor, which has now had. About 150 bytes (compressed)
  saved.
2013-05-16 17:37:34 +01:00
Allan Jardine
4913226456 Internal: Refactoring the sort functions for invalidation
- invalidation is going to play an important part in the new API, with
  the ability to invalid the cached data for sorting, filtering, display
  etc so we need to be able tos upport this in the core.

- In fairness the sorting didn't actually need invalidation because it
  would always get data on every sort, which is bad for performance -
  proper invalidation and caching will resolve this. Which is what has
  been implemented here.

- I had expected (hoped) to be able to save a bit of space in the
  refactor, but only aorund 100 bytes (compressed) saved, which will
  probably be lost when the invalidation is fully implemented in the
  API. Still, better performance, tidier code, and no extra space...

Fix: Sorting classes now show multi column sorting when a column is
defined to sort over multiple columns (sortData). Previously it would
only show the first column.
2013-05-16 17:16:04 +01:00
Allan Jardine
67d19ac9e4 Dev: Fix issue with the last commit which introduced an error witht he
classes calculated for display
2013-05-16 17:15:14 +01:00
Allan Jardine
b12ffb1dab New: row.add() and rows.add() methods for the new API
- Two new methods for the new API to allow new data (rows) to be added
  to the table.

  - row.add() - Add a single row to the table. object, array, jQuery
    object or TR node can be passed in.

  - rows.add() - Add one or more rows to the table from a source array.
    An array or jQuery object must be passed in, containing objects,
    arrays, or TR nodes (or any combination thereof).

- Should be noted that this is iterated over all tables in the current
  API context, so care should be taken when adding a node to multiple
  tables, since it will be moved between them. Equally, when adding
  data, the original object reference is retained, so changing it in one
  table will change it in all!

- These two methods effectively replace fnAddData from the old API.
  fnAddData had a few issues with distingusihing a multiple row add and
  a single row add, since arrays could be used for both (indeed, it
  simply couldn't cope with something like using a single integer as
  reference for a data object, which can now be done in 1.10). The two
  new methods sidestep this problem by providing one method for multiple
  row add, and another for single row add - the developer needs to know
  that the plural has meaning here!
2013-05-16 10:26:08 +01:00
Allan Jardine
5548d09ecd Merge branch 'patch-35' of https://github.com/timtucker/DataTables into 1_10_wip 2013-05-15 15:09:23 +01:00
Allan Jardine
89b2404511 New: columns().order() method for the new API
- I think it makes intuative sense to be able to tell the table to order
  on the columns given by the selector, which is exactly what this
  method does.
2013-05-15 12:02:57 +01:00
Tim Tucker
aa70a483d4 Make fewer calls to $.inArray when assigning sort classes
Only call once each to check to see sort ascending / sort descending is is active.  (And only check for the descending class if we didn't find the ascending class)

Should also lead to smaller minified code.
2013-05-15 07:58:25 -03:00
Allan Jardine
d9119fc3cb New: destroy() method for the new API
- Addition of a destroy method for the new API, effectively replacing
  fnDestroy from the old API.

- The functionality is identical to fnDestroy, but it has been
  refactored to make better use of jQuery and allow for better
  compression (should be 1/4 - 1/2 KiB saved)
2013-05-15 11:34:40 +01:00
Allan Jardine
c211a74079 Dev: Tidy up new settings() method, doesn't actually need an iterator 2013-05-14 08:52:50 +01:00
Allan Jardine
d051a17926 New: $, clear, settings, on, one and off methods for new API
- $ - perform a jQuery selector on the nodes in the table (matching the
  $ method from the old API).

- clear - clear the table completely (replaces fnClearTable).

- settings - get an array of the settings objects for the tables used in
  the API instance.

- on - jQuery event listener proxy. Use for table specific events
  ('draw', 'xhr' etc).

- one - jQuery event listener proxy (single event).

- off - jQuery event unlistener proxy.
2013-05-14 08:47:06 +01:00
Allan Jardine
30c6a45067 Dev: Refector _fnGetDataMaster and _fnClearTable to be shorter and clearer 2013-05-14 08:46:21 +01:00
Allan Jardine
bd804fdcb8 New: child row API methods for showing / hiding child rows
- Showing and hiding details about a row in a child row is very useful
  and proven to be a popular part of DataTables. This commit provides
  that ability in the new API and extends it. It also fully modularises
  the child rows aspects, so it could be removed from the core without
  effecting any other aspects (it may be moved into a seperate file in
  future).

- This will effectively replace fnOpen, fnClose and fnIsOpen

- Added methods:
  - row( selector, opts ).child()
  - row( selector, opts ).child( str, class )
  - row( selector, opts ).child( str, class ).show()
  - row( selector, opts ).child( str, class ).hide()
  - row( selector, opts ).child.show()
  - row( selector, opts ).child.hide()
  - row( selector, opts ).child.isShown()

- Note that unlike the old API you need to specify the data first, and
  then use the show() method to show the child row. This allows the
  details rows to be configured before they are actually shown.

- Additionally multiple child rows can be attached to a parent (pass
  `str` (from above) as an array to use this feature. API plug-ins could
  use this ability to show fully nested tables.

- Not just a string can be passed in now, but also a TR node which will
  actually be used (rather than put into a nested row), any other type
  of node (which will be inserted into a wrapper row/cell) or a jQuery
  object.
2013-05-07 17:56:07 +01:00
Allan Jardine
ed34f7972d New: row() methods - operate on a single row.
- The rows() method allows operations on multiple rows with a single
  call, this new singualr option, `row()` performs operations on a
  single row, allowing fine grain control and easy access to certain
  aspects. For example. `rows().data()` will return an array of data
  objects, even if there is only one row as a result of the selector,
  while `row().data()` will return the data object directly.

- Impletemented thus far:

  - row()
  - row().node()
  - row().cells()
  - row().data() - get only as of yet
  - row().index()
  - row().remove()
2013-05-06 07:14:43 +01:00
Allan Jardine
955eb2cd99 Internal: Update the the filtering input control to update itself on filter
- Previously it was the domain of the filtering caller to update the
  global filtering input element (fnFilter or the keypress handler
  specifically), but in keeping with the drive towards modularity, it
  should be the control itself that updates when needed.

- This is done by listening for the `filter` event from the table and
  updating the display as needed. It is a touch less efficent since the
  same value might be written as what is already there, but it reduces
  code size and complexity.
2013-04-29 07:58:53 +01:00
Allan Jardine
d7058eb45d New: search() and columns().search() API methods
- Ability to filter the table through the new API.

- This effectively replaces the fnFilter method of the old API.

- Note that one capability which has been removed from the old API is the
  ability to not show the new filter on the filtering input elements. I
  can't see any use for that feature to be honest, so it has been
  dropped. The filtering inputs always show the global filter state now.

- Additionally, note that we've been forced to call this `search` here
  rather than `filter` since there is a `filter` method for the API
  collection instance. This might be revisted before release.
2013-04-29 07:51:41 +01:00
Allan Jardine
2b0a321dd2 New: rows().remove() API method
- Remove (delete) selected rows from the table.

- This effectively replaces the fnDeleteRow API method of the old API.
2013-04-29 07:50:43 +01:00
Allan Jardine
a767c05f1d New: column.index() API method for translating column indexes
- The fnVisibleToColumnIndex and fnColumnIndexToVisible plug-in API
  methods for the old API were very useful for transforming the visible
  column index to the actual index, and the return. This adds that
  capability to the new API.
2013-04-28 18:31:15 +01:00
Allan Jardine
7b6ebd63de New: columns.adjust() API method.
- Recalculate the "ideal" column sizes for the table. Might want this
  after a column visiblity change for example

- Replaces the fnAdjustColumnSizing method.
2013-04-28 10:23:43 +01:00
Allan Jardine
bbb423ee75 New: API method columns().visible() - get / set column visiblity
- This effectively replaces the old fnSetColumnVis method (a shim will
  be put in place along with the shim for the rest of the old API). It
  has added get abilities, and the option, like the rest of the new API
  to work on multiple tables / columns with a single call depending on
  the context and selector.
2013-04-28 10:14:04 +01:00
Allan Jardine
8e1bf972d4 New: columns().data() API method - get the data for the selected columns 2013-04-28 09:05:03 +01:00
Allan Jardine
68ea9af828 New - rows().cells(), columns.cells() API methods.
- row options for column selector

- Selectors (table, rows and columns) now held in a single file, sharing
  structure. A more unified API is used, with row options also being
  allow for columns, through the use of the second parameter for the
  columns() method, which will effect how a column function can act upon
  rows (for example, the order of the rows when getting data or nodes).

- Dev: tables() is no longer an iterator - using an `iterator()` method
  with options which are suitable for the different types of iteration
  the API needs.
2013-04-28 08:53:05 +01:00
Allan Jardine
b1b4b58a9a Internal - remove _fnGetTrNodes
- Not used anywhere outside the old API, which is going to be shimed to
  the new one, so we can simply drop it.
2013-04-23 10:21:48 +01:00
Allan Jardine
01bc1f728d Internal - store cell reference | remove _fnGetTdNodes
- We use the cell nodes form the table body in a number of places, and
  increasing with the new API, so rather than just storing a reference
  to the hidden cells, we should just store a reference to all cells and
  use them, cleaning up a number of other areas - in particular
  _fnGetTdNodes which is no longer needed

- Should do something similar for _fnGetTrNodes

- Disabled sort classes for the moment as that can be rewritten to be
  more efficient. It did use _fnGetTdNodes, but doesn't need to now.

- API fnSetColumnVis and fnUpdate will be broken at the moment, until
  merged into the new API.
2013-04-23 09:50:59 +01:00
Allan Jardine
bb75f22233 Dev fix - Inverted logic for the information string 2013-04-23 09:50:23 +01:00
Allan Jardine
a3b90fd0cc New: API methods rows().nodes(), rows().data() and columns().header()
- rows().nodes() - Get the TR nodes for the selected rows
- rows().data() - Get the data for the selected rows
- columns().header() - Get the header cells for the selected columns

- This also introduces the `iterator` method to the API instance, which
  can be used to loop over selected columns / rows, for the context
  (tables), returning a flat array / API instance.
2013-04-23 08:49:06 +01:00
Allan Jardine
fcc7d4a78d Internal - refactor of table information control 2013-04-22 18:56:20 +01:00
Allan Jardine
cdd82a9d0e Internal - refactor processing display
- Simple refactor into the more mordern 'style', only saves about 100
  bytes, but the code looks much cleaner.
2013-04-22 09:09:14 +01:00
Allan Jardine
414abff7e6 Dev - fix attributes for empty row weren't being applied 2013-04-22 09:08:49 +01:00
Allan Jardine
73e265218e Internal - Small refector of fnDraw
- Use variable aliases to allow better compression
- Replace body append code with jQuery code. Much simpiler, and only
  a very small performance hit (around 1mS for a draw of 100 records).
2013-04-22 08:58:28 +01:00
Allan Jardine
63d9f3f21e Internal - Refactor
- Remove the settings._iDisplayEnd parameter finally, using only
  fnDisplayEnd() is needed, and the end point is calculated on-the-fly
  when needed (which is not often and it is not expensive). This also
  means that the internal method `_fnCalculateEnd` can be dropped
  completely.

- Refactoring the empty cell in _fnDraw
2013-04-21 20:02:23 +01:00
Allan Jardine
09761bfdef New - Rows and Columns selectors
- columns() and rows() introduced with their selector components. They
  don't have any additional funtionality at this time other than just
  being able to selector rows and columns (returning arrays of indexes),
  but the principle is now in place, and the additional functions can be
  fleshed out.

- Moving to use a work in process branch, as some aspects of DataTables
  may break as this work continues, and certainly the files etc are all
  in flux
2013-04-21 16:37:38 +01:00
Allan Jardine
a077d24e6a Internal - Small change to the new order() method to remove redundant code 2013-04-20 12:04:18 +01:00
Allan Jardine
2e278b0285 New: Ordering functions for the new API:
- order() and order.listener() added (to replace fnSort and
  fnSortListener) from the old API.

- Note that the name `order` is selected to not conflict with the `sort`
  method of the API object, which can be used to order the sort data
  held in the collection.

- The `sort()` method is expanded over the abilities of fnSort to allow
  multiple different forms of input (column + direction, 1D array, list
  of 1D arrays or a 2D array).
2013-04-20 12:00:16 +01:00
Allan Jardine
aa76a6baf5 New: Add ability to do a static redraw to the new API
- draw() and ajax.reload() can now have `false` passed as their first
  (and currently only) parameter, which instructs DataTables to do a
  'static' redraw (i.e. not to reset the pagination).
2013-04-20 11:12:08 +01:00
Allan Jardine
edfbf7491d Internal - altering how a draw is called
- Previously the master sort and filter functions would perform a draw,
  but this was a bit redundant, complex and didn't allow multiple
  changes to be queued up before a new draw was performed. The new API
  will allow this ability, so we need to allow it in the core as well.
  You can now do a sort, and it will be performed internally, but not
  actually drawn until the redraw function is called. This makes a full
  redraw much simpiler, and has the benefit that a standing redraw is
  now relatively trivial since it is all performed in a single place.
2013-04-20 10:18:52 +01:00
Allan Jardine
e014d9272f New: ajax API methods:
- Introducing several methods which will control the ajax aspects of
  DataTables through the API:

  - ajax.json() - get the last JSON returned from the server
  - ajax.reload() - reload from JSON source
  - ajax.url( [url] ) - get / set the Ajax URL
  - ajax.url( url ).load() - load data from new URL after a set

- Note that this effectively replaces the old fnReloadAjax plug-in which
  was quite popular.

- Not yet fully tested - further work required.
2013-04-20 09:10:46 +01:00
Allan Jardine
15588d9e41 New - api methods: page(), page.info(), page.len(), draw()
- Paging control methods for the new API:
  - page() / page(n) - Get / set the current page
  - page.info() - Get information about the table's paging state
  - page.len() / page.len(n) - Get / set the page length

- Rewrite of core.page.js and core.length.js to be more space efficient.
  The functionality is identical to before, but now compresses much
  better (796 byte saving). The new paging API methods add only 614
  bytes (compressed), so overall a saving of 182 bytes, with the new
  functionality added by the new API.

- Start of draw methods for new API:
  - draw() - Draw the table. Need this to test the new paging methods
    since page() etc do not do a redraw themselves, you must call draw()
    when you are ready for the table to be redrawn now.
2013-04-18 07:49:38 +01:00
Allan Jardine
fa7122392d New: tables() and tables().nodes() methods for the new API:
- tables() is a table selector and iterator that most other API methods
  will likely use.

- tables().nodes() gets the selected HTML table nodes.

- Documentation of these functions is rather incomplete. Not yet sure
  how to fully document them. Currently thinking of having seperate
  documentation, a bit like jQuery, which can be a lot more involved,
  rather than building it fromt he doc comments which might get rather
  long (they already are!).
2013-04-17 14:35:15 +01:00
Allan Jardine
e9176bee48 New: First commit for the new Api.
- This commit introduces the new Api core, a 'class' which is a data
  helper and DataTable control interface. Methods of this class are
  designed to be chainable (although it is not manditory - some can
  return boolean values if needed).

- The core data helper functions are present in this comment, although
  not yet fully documented. That will come as the Api stablises and I'm
  happy with the structure.

- There are no table control methods yet - coming soon.
2013-04-16 16:38:53 +01:00
Allan Jardine
b1d88c1c91 Performance: Read the style.width property for the restore width and
apply that.

- This is much faster than the previous method of using $(this).width()
  since there is no longer an invalidation and getComputedStyle
  calculation. It just uses the value that is available in style.width,
  which might very well be empty (if the style attribute is used with a
  width property defined is it not empty).

- This also improves accuracy since it is the original that is restored,
  and not the calculated size.

- See http://datatables.net/forums/discussion/14811 for the discussion
  for this change.

- Thanks to `krzycho` for the discussion and suggestions.
2013-04-06 09:44:52 +01:00
Allan Jardine
ad0e08585f Performance: Width of scrollbars isn't going to change on a single page
between table's being reinitialised, so calculating the scrollbar width
every time is a real hit on performance since it needs to manipulate the
DOM. This change ensures that the calculation is performed only once.
2013-04-06 09:36:44 +01:00
Allan Jardine
182998a7c5 Fix: Remove pointer cursor from cells which cannot be sorted - 14826 2013-03-29 07:27:47 +00:00
Allan Jardine
5a0c1f5ac6 Fix #168 - fnInitComplete should give json as second parameter as well
- When server-side processing is enabled, fnInitComplete will now be
  passed a second parameter, the json returned from the server for that
  first draw, matching the Ajax data source with client-side processing
  option.
2013-03-27 09:25:55 +00:00
Allan Jardine
baa16632ec New - licensing: DataTables is now available under the MIT license
- Full license available here: http://datatables.net/license_mit

- Note that this effectively makes the BSD and GPLv2 licenses that
  DataTables is also available under redundant since the MIT is the most
  relaxed of these licenses. At some point in the not too distant
  future, it would make sense to remove these two licenses and have
  DataTables available under only the MIT license.
2013-03-15 09:56:27 +00:00
Allan Jardine
8d9e620ef2 Merge pull request #160 from zeitiger/master
Refactor filter search from input[text] to input[search]
2013-03-04 02:42:57 -08:00
David Steinkopff
c2dd657fa8 remove hacking 2013-03-04 08:43:11 +01:00
David Steinkopff
8efdd92a46 Merge branch 'master' of https://github.com/zeitiger/DataTables
Add requested changes
2013-03-04 08:38:31 +01:00
Allan Jardine
b87187fc5b Fix #162 - Flexible width is width="100%" is applied as attribute to the HTML table
- Attach an event handler to the window to resize the table. Note that
  this isn't debounced - possibly it should be in future(?), but don't
  want to add the additional code required if it isn't required. It
  seems to function perfectly well for me!

- Unbind needs to unbind by the instance unique reference since there
  might be multiple tables listening for the event.
2013-03-03 12:03:44 +00:00
Allan Jardine
25eaa86477 Dev fix: Typo in the name of _hungarianMap private parameter 2013-03-03 08:36:58 +00:00
Allan Jardine
2bd643468b New: Extend render option to use objects allowing different data to be
used for the different data types very easily.

- Until now, if you want to use different data for the different data
  types (I've called these orthogonal data in relations to DataTables)
  you had to specify a function. That's fine, but it seems a rather
  clumsy way of just pulling different data out of a source object based
  on the type. This method allows the data types to be very easily
  defined with an object, allowing the same rules as `render` normally
  does (dotted object notation, array notation etc).

- For example:

    $(document).ready(function() {
    	$('#example').dataTable( {
    		columns: [
    			{ data: null, render: {
    				_: 'a',
    				sort: 'c',
    				type: 'c',
    				filter: 'd'
    			} },
    			{ data: 'b' }
    		],
    		data: [
    			{ 'a': 1, 'b': 2, 'c': 4, 'd': '1' },
    			{ 'a': 3, 'b': 4, 'c': 3, 'd': '3' },
    			{ 'a': 5, 'b': 6, 'c': 2, 'd': '5' },
    			{ 'a': 7, 'b': 8, 'c': 1, 'd': 'allan' }
    		]
    	} );
    } );
2013-03-02 18:53:27 +00:00
Allan Jardine
079a1f2e1d Fix: remove tabindex from clone header nodes
- Tabbing through a scrolling table the tabindex on the cloned header in
  the body part of hte table meant that the browser would focus on those
  elements. Fix is to remove the tab index from the clone nodes.
2013-03-01 17:30:40 +00:00
David Steinkopff
9b003e6690 replace input[text] with HTML5 input[search] 2013-02-28 10:26:45 +01:00
David Steinkopff
4577a52056 replace input[text] with HTML5 input[search] 2013-02-28 09:41:49 +01:00
Allan Jardine
1bb4fc6896 Dev fix: Typo from a67ff2f 2013-02-26 21:33:00 +00:00
Allan Jardine
a67ff2fadb Dev: Trivial tidy up of _fnConvertToWidth
- Just 43 bytes saved, but tidier code and smaller size...
2013-02-18 08:47:47 +00:00
Allan Jardine
7c53a1824c Dev: Tidying up scrollbar width calcuation function
- Using jQuery we can make the code a bit smaller. Not much, just a 97
  byte saving, but every little helps, as they say....
2013-02-18 08:42:32 +00:00
Allan Jardine
4c4bfb04b8 Dev: Remove trailing white space
- JSHint flagging warnings on trailing whitespace, so tidying up. Boring
  commit, but these things must be done!
2013-02-17 17:59:27 +00:00
Allan Jardine
6e012c8ee1 Dev fix: Thousands separator was incorrectly applied
- This was from my old work on experimenting with removing hugraian
  notation, it slipped through to be committed.
2013-02-16 11:33:50 +00:00
Allan Jardine
f3ce2e2d44 Fix 151: Column type was being offset when columns were not searchable 2013-02-16 11:27:41 +00:00
Allan Jardine
d5fb56ff37 Update: Update to jQuery 1.9.1 2013-02-16 11:26:54 +00:00
Allan Jardine
39ad1e7004 Dev: Small size reduction in SSP parameter build
- Saving of just 269 bytes in minified file, but non-the-less welcome
2013-02-10 12:18:00 +00:00
Allan Jardine
28c60e92a6 Dev fix: Undefined variable (JSHint) 2013-02-10 12:17:39 +00:00
Allan Jardine
2b6788011f New: ajax parameter to control all aspects of Ajax that DataTables uses
- DataTables 1.9 had 5 different parameters that controlled how Ajax
  data was obtained, which with its own naming properties, often mapping
  to the jQuery.ajax methods, or otherwise extending them. To hugely
  simply and extend the Ajax functionality DataTables has, these five
  parameters have now been deprecated and the funtionality provided by
  them merged into the new `ajax` parameter.

- Deprecated properties:
   - sAjaxSource
   - fnServerData
   - sAjaxDataProp
   - sServerMethod
   - fnServerParams

- Note that these parameters are still fully supported and can be used,
  but for new projects, `ajax` should be used as they will eventually be
  removed (likely DataTables v2 whenever that is, as they are too widely
  used to be removed in v1.x).

- Added additional / missing tests for the deprecated properties to
  ensure full backwards compatiblity

- The new `ajax` property is fully documented in the doc comments, but
  as a summary it can take three forms:
   - string - the url to get the data from (i.e. this is the new
     sAjaxSource)
   - object - maps directly to jQuery.ajax, allowing full control of the
     Ajax call (provides the abilities of fnServerParams, sServerMethod,
     sAjaxDataProp)
   - function - a function so you can get the data your own way
     (provides the abilities of fnServerData)

- Added unit tests for the new `ajax` property and doc comment examples
  updated to use this property exclusively.
2013-02-10 11:58:58 +00:00
Allan Jardine
fad7536608 Fix: $().andSelf() was deprecated in jQuery 1.8
- As of jQuery 1.8 `andSelf` was deprecated in favour of `andBack`.
  `andBack` was not available in jQuery <1.8, and I don't want to make
  1.8 a requirement yet, so a small workaround requiring two unbind
  calls is used to avoid calling `andSelf` or `andBack`.
2013-02-07 08:29:51 +00:00
Allan Jardine
da2a834177 Dev: Tidying up documentation comments for main DataTables file 2013-02-05 09:36:58 +00:00
Allan Jardine
d740f0484d Update - docs: Add examples for the xhr event and clarify when it fires
- `xhr` event fires before DataTables processes the returned data, so
  you can listen for `xhr` and use it to manipulate the returned data.
2013-02-05 09:31:48 +00:00
Allan Jardine
f35801b111 Fix: jQuery migrate warning on display length initial setting
- jQuery migrate gives a warning about the use of `attr` rather than
  `prop`. However, we should really just be using `val` here - much
  easier.

- Thread: 13931
2013-02-05 06:49:59 +00:00
Allan Jardine
8045c7471e Dev: Committing recent changes into built script 2013-02-04 19:57:59 +00:00
Allan Jardine
1b6ffeaf78 Updated: data and render can now have periods escaped from dotted
object notation.

- Previously if you had an object key that contained a period, it
  wouldn't work with `data` or `render` (or rather it would need a
  function call to do it manually), since a split was being done on the
  periods to reconstruct the Javascript object property chain. Now it is
  possible to escape a period, allowing it to be included in the
  property name read / set.

- Example:

$('#example').dataTable( {
	columns: [
		{ data: 'a' },
		{ data: 'b\\.c' }
	],
	data: [
		{ 'a': 1, 'b.c': 2 },
		{ 'a': 3, 'b.c': 4 },
		{ 'a': 5, 'b.c': 6 },
		{ 'a': 7, 'b.c': 8 }
	]
} );
2013-02-04 19:44:41 +00:00
Allan Jardine
b2de50229e New: data and render options for columns support function notation
- As part of completing the planning development for reading data, I've
  added support for calling functions from the string defined in `data`
  and `render` column options. So you can now do something like:
  `render: 'name()'` rather than needing to use an anon function and
  calling name() in that. This is useful for cases where you want to
  give DataTables an array of Javascript instances, rather than objects
  or arrays (see example below). It also fully supports the continuation
  of the dotted notation DataTables supports, so you could use
  `name().first` if `name()` returns an object. Again to make it easier
  than needed to define a function.

- Documentation for `data` and `render` updated to reflect this
  abilities

- Unit tests for this still to come

- There is one backwards incompatiblity that should be noted - although
  I think this is a real edge case and I just can't see it being an
  issue. If before, you had `data:null` without `render` or
  `defaultContent` specified, DataTables would have output an empty
  cell. Now it will output the original data source object. Can't see
  this being an issue since, why would you have a column empty cells? If
  this is an issue, then you simply need to add `defaultContent:''` now.

- Example use case, using Javascript instances:

$(document).ready(function() {
  var z = function (i) {
    this.a = function (set) {
      if ( set ) {
        return this;
      }
      return i+'-0';
    };
    this.b = function (set) {
      if ( set ) {
        return this;
      }
      return i+'-1';
    };
    this.c = function (set) {
      if ( set ) {
        return this;
      }
      return i+'-2';
    };
    this.d = function (set) {
      if ( set ) {
        return this;
      }
      return i+'-3';
    };
    this.e = function (set) {
      if ( set ) {
        return this;
      }
      return {
        q: i+'-4q',
        w: i+'-4w'
      };
    };
  };

  window.dataset = [
    new z(0),
    new z(1),
    new z(2),
    new z(3),
    new z(4),
    new z(5)
  ];

  $('#example').dataTable( {
    columns: [
      { data: null, /*render: 'a()'*/ },
      { data: 'b()' },
      { data: 'c' },
      { data: 'd()' },
      { data: 'e().q' }
    ],
    data: dataset
  } );
} );
2013-02-04 11:05:40 +00:00
Allan Jardine
b4aee323bd Fix #136 - Allow bDestroy / bRetrieve to have defaults set
- Typically I think setting bDestroy or bRetrieve as default true is a
  bad idea as it could lead to more processing of tables than is needed
  by mistake, but if set the defaults should be acted upon.

- These are slightly different to the other defaults since the settings
  object hasn't been expanded by the point they are checked, so need to
  manually check the values.
2013-02-02 12:09:15 +00:00
Allan Jardine
10a0d7bd04 Dev: Update comments for browser feature detection 2013-02-01 10:29:03 +00:00
Allan Jardine
415ce622c3 New: Scrolling support for rtl language layout
- When scrolling is enabled, the scrollbar can be placed on the right or
  the left of the scrolling container by the browser for rtl layout (of
  the current browsers, only Safari appears to place it on the right) -
  when placed on the left the padding adjustment that DataTables makes
  for the scrollbar area was added to the wrong side.

- To cope with this, the browser compat method (moved to the compat
  file) will check for the position of the scrollbar and set a flag so
  the scroll draw can adjust the position as needed.
2013-02-01 10:05:45 +00:00
Allan Jardine
177400121e Fix: Documentation typo or sWidth 2013-02-01 10:04:20 +00:00
Allan Jardine
0e8e0d6793 Update: Updating to jQuery 1.9 2013-02-01 10:02:57 +00:00
Allan Jardine
076744a84c Merge branch 'master' of github.com:DataTables/DataTables 2012-12-21 09:36:10 +00:00
DukeAstar
d9bb6b63cd Fix backward compatibility with mDataProp = null 2012-12-07 22:32:41 +01:00
Tiax
a528bbb6b6 Applying proper CSS classes for sorting to columns
As discussed on the forums here: http://datatables.net/forums/discussion/12736/setting-sortable-with-aocolumndefs-glitched
2012-11-23 10:49:26 +01:00
Allan Jardine
36fc3cc92e Update: If aLengthMenu is given, but iDisplayLength is not, DataTables used to default to using the built in iDisplayLength option. However, this lead to a bit of confusion as to why the first value from aLengthMenu was not used (issue #61 and numerous forum posts). This commit changes that behaviour - the first value from aLengthMenu is used, if iDisplayLength is not given as well. 2012-11-02 09:28:06 +00:00
Allan Jardine
823e64cccb Dev: A bit of love for hte type detection functions. Tidy them up and improve the comments. 2012-11-02 08:43:37 +00:00
Allan Jardine
33d3667bbe Update: Much smaller numeric type detection method, based on isNumeric in jQuery. Also a whole lot faster. 2012-11-02 08:33:07 +00:00
Allan Jardine
a073515b20 Update: fnUpdate is now inline with the changes to how data can be added to the table. Rather than taking a copy of the data source, it will simply assign the data given to the row (if it is given for the row) and apply it. Documentation comments update as well. 2012-11-01 21:56:02 +00:00
Allan Jardine
065c2cc66b Fix: Filtering wasn't correctly applying the type adjustments needed for the global filter. For example this meant that html was not stripped from 'html' type columns, resulting in filtering being done on html tags/attributes as well as the content. 2012-11-01 21:45:48 +00:00
Allan Jardine
b56f3619cb Dev: Remove padding on code when in the syntax highlighter 2012-11-01 21:45:26 +00:00
Allan Jardine
46d483d055 Tests: With the change for the state saving into localStorage we need to update the state destroy in the unit tests 2012-10-31 18:12:22 +00:00
Allan Jardine
94f06473c6 New: DataTables now uses HTML5 localStorage by default for state saving. This has a number of advantages over cookies, the first of which is that we are no longer limited to 4KiB in size. It also makes HTTP requests faster since they aren't included in the HTTP transport. Better yet, the removal of the cookie code reduces the DataTables minified size by 1.5K (1573 bytes). It must be noted that this does mean that IE6/7 don't, by default, work with state saving in DataTables. If support for those browsers is required, then fnStateSaveCallback and fnStateLoadCallback must be used by the developer to define their own state saving methods.
Removed: fnCookieCallback (cookieCallback) - This is now irrelevant since DataTables does not state save in cookies by default.

Removed: sCookiePrefix (cookiePrefix) - This is now irrelevant since DataTables does not state save in cookies by default.

Depreciated: iCookieDuration (cookieDuration) - Since DataTables does not use cookies for state saving by default the name of this parameter is now incorrect. The new parameter `stateDuration` should be used instead, although the old parameter is still supported. It will be removed in the next major version of DataTables.
2012-10-31 18:09:41 +00:00
Allan Jardine
c883cdac54 Dev: Fix issue with the moved oInit defaults copy - couldn't get a reference to an exisiting DataTable 2012-10-31 15:42:09 +00:00
Allan Jardine
0ff0858734 Dev: Fix logic check for passing data to the updated _fnCreateTr method 2012-10-31 15:39:10 +00:00
Allan Jardine
5209e2f058 Dev: Removed the _fnGatherData method, replacing it with _fnAddTr and slightly updated _fnAddData / _fnCreateTr. This means that the new API add add existing TR element if needed, but more importantly it reduces code duplication and makes the code size smaller (almost 1K - 967 bytes exactly, minified). Must confess I was really hoping it would be more, but every little helps... 2012-10-31 14:56:34 +00:00
Allan Jardine
3ac3cedf53 Fix: When sorting numerically, '-' and '' should be treated as -Infinity rather than as 0, since negative numbers could also be used int he column and this would split the numbers. 2012-10-30 21:05:15 +00:00
Allan Jardine
ec0556b4f6 Updated: Changing the formatting that DataTables uses for the version numbers to be compatible with semver (http://semver.org/). The impact is minimal (unless you are parsing the version for the final part in dev builds). The change is to use a dash ('-') at the end of the version string for a non-release build, rather than a dot. 2012-10-28 16:39:35 +00:00
Allan Jardine
eafd70f53a Dev fix: When updating the parameters for lack of hungraian notation, I renamed 'iDeferLoading' as 'deferLoading' which broke server-side processing... 2012-10-28 16:34:11 +00:00
Allan Jardine
8eb8c90627 Dev - Build latest changes 2012-10-26 08:04:14 +01:00
Allan Jardine
e89958cb45 Fix docs: Example for mRender has a syntax error 2012-10-26 08:02:59 +01:00
Allan Jardine
cab0c534f1 Fix - core: Stripe removal was broken - it was stripping the classes from only the first row rows, rather than all of them, which was wrong. This was unfortunatly introduced in 1.9.4 and there weren't any unit tests to catch it. There are now, and I've rewritten the code that wil remove existing stripe classes. Its now much smaller and should be a little faster. Now it only checks the first row to see if it has any exisiting stripe classes, which is good enough. The smallest this could could be would be a simple removeClass, but that may result in significant overhead which really isn't needed in cases where there are no exisiting stripe classes. 2012-10-19 15:31:35 +01:00
Allan Jardine
8e1068e603 Dev fix: Fix issue highlighted by JSHint - The DataTable object is addressed in the private methods so it needs to be defined before them, but the contracturo needs to come after the priavte methods! 2012-10-07 18:13:16 +01:00
Allan Jardine
0e3a60b52f Dev fix: Variable name oSettings was incorrect 2012-10-07 18:11:54 +01:00
Allan Jardine
f7dddabfa3 Fix: Trailing comma 2012-10-07 18:11:41 +01:00
Allan Jardine
de935de4c6 Merge branch 'master' of github.com:DataTables/DataTables 2012-10-07 18:08:56 +01:00
Allan Jardine
ab454c1c33 Fix: In _fnExtend there was a bug where a variable referenced a 'locally global' (for lack of a better term) variable rather than the in function variable that it should be have. Got away with this since _fnExtend is only used for one thing at the moment, but it was wrong. Now fixed.
Update - Performance / Memory: The functions that DataTables uses are not instance based, they are locally scoped, but they were included in the DataTable constructore, which meant that every time you create a new 'instance' of DataTables ($().dataTable()) it would create these functions in that scope again and again. That's completely pointless since we only need them once, so moving them outside the constructor helps both performance and memory (not huge, but very little helps!).
2012-10-07 18:02:38 +01:00
Tim Tucker
2b35b262cb Update media/src/api/api.static.js
Variable initialization was wrong in the prior pull (should have been iThat, not sThat)
2012-10-07 09:11:10 -03:00
Allan Jardine
f420f1462b Merge pull request #117 from timtucker/patch-29
Dev: Modify how DataTables builds the filtering regular expressions to simplify.
2012-10-07 04:31:06 -07:00
Allan Jardine
ec10497217 Dev: Update generated file from the marges made recently 2012-10-07 12:23:24 +01:00
Allan Jardine
7a388a0a76 Merge branch 'master' of github.com:DataTables/DataTables 2012-10-07 12:23:07 +01:00
Allan Jardine
09a9976907 Dev: Trivial code styling change 2012-10-07 12:22:18 +01:00
Allan Jardine
7bcd2955ff Merge pull request #116 from timtucker/patch-28
Dev: Remove unused variable in _fnDraw
2012-10-07 04:15:17 -07:00
Allan Jardine
76507795ed Merge pull request #109 from timtucker/patch-22
Update media/src/core/core.ajax.js
2012-10-07 04:14:12 -07:00
Allan Jardine
be6fc4185d Merge pull request #106 from timtucker/patch-19
Dev: Simplify language handling of start number for infinite scrolling
2012-10-07 04:12:23 -07:00
Allan Jardine
8cabf6f830 Merge pull request #107 from timtucker/patch-20
Dev: Different algorithm for fnVersionCheck
2012-10-07 04:10:43 -07:00
Allan Jardine
542066100a Merge pull request #115 from timtucker/patch-27
Update media/src/core/core.draw.js
2012-10-07 04:09:27 -07:00
Allan Jardine
8b6e3fe264 Merge pull request #108 from timtucker/patch-21
Fix: Update string sorting to correctly sort undefined values.
2012-10-07 04:08:40 -07:00
Allan Jardine
a0455fa858 New: The primary public interface for DataTables' initialisation options is now camel case parameters rather than the Hungarian notation that was used before. There are a number of reasons for doing this, the primary one being that the Hungarian notation used by DataTables is actively stopping people from using the library due to their aversion to using Hungarian notation. Without doubt the Hungarian notation used was a mistake (the reason it was used was that when DataTables was originally written, the company I worked for at the time required the use of Hungarian notation, and thus I was trained in it...).
Backwards compatibility issues: The main goal here (other than to use camel-case notation!) is to preserve backwards compatibility. Unfortunately this isn't 100% possible:
	- DataTable.defaults.columns has been renamed to be DataTable.defaults.column
		- Otherwise it conflicts with aoColumns in the defaults.

Without doubt this is going to be a long process - for example the unit tests and examples need to be completely updated for this change. The JSDoc comments have been updated, so the site should take care of itself for the most part, when released.

In terms of implementation, it is important to note that I have not broken backwards compatibility here - the way it is does is that the current defaults are retained, and a camel-case to Hungarian mapping is automatically generated and then applied to the objects given by the end user. This adds around 0.5K to the size of DataTables, but writing the mapping manually would require at least 3K, and changing DataTables wholesale to camel-case would utterly break backwards compatibility. This is the least 'evil' way to accomplish this. It is important to note that this is a step along the roadmap for DataTables - come v2 Hungarian notation will likely be dropped completely.

One important note to make about this mapping is that if you use camel-case DataTables will copy the value from the camel-case properties to their Hungarian counterparts, so you will end up with additional properties on your source object. As I say, this appears to be to be the least 'evil' option, although still not perfect itself. The challenges of working with legacy software and installs...!
2012-10-07 11:50:29 +01:00
Tim Tucker
223fed5e94 Update media/src/core/core.ajax.js
simplify conditions:
!A || (A && (B || C)
really is the same as:
!A || (true && (B || C))
which simplifies to:
!A || (B || C)
which simplifies to:
!A || B || C
2012-10-05 23:50:33 -03:00
Allan Jardine
60484bc93a Dev - Remove reporting code from the Ajax draw update - don't need it after the change for 36076fc5c8 2012-10-04 14:50:47 +01:00
Tim Tucker
15a3e7b97d Update media/src/core/core.filter.js
Reorder things a little to simplify
2012-10-02 09:18:45 -03:00
Tim Tucker
bd7d70c6b3 Update media/src/core/core.draw.js
Remove unused variable
2012-10-02 08:57:42 -03:00
Tim Tucker
fc445cd374 Update media/src/core/core.draw.js
Remove check for iOpenRows !== 0, since it isn't really needed.
(the contents of the loop just won't execute)
2012-10-02 08:55:18 -03:00
Tim Tucker
a3b5706105 Update media/src/core/core.ajax.js
Remove unnecessary else(s)
2012-09-30 20:11:36 -03:00
Tim Tucker
23fc3858d9 Update media/src/ext/ext.sorting.js
handle undefined values, skip toLowerCase call for empty strings
2012-09-30 20:05:09 -03:00
Tim Tucker
7f35d4fb4d Update media/src/api/api.static.js
Slightly shorter method for checking the version (stops as soon as it reaches a version part that has a difference)
2012-09-30 11:07:24 -03:00
Tim Tucker
473e9b0088 Update media/src/core/core.info.js
Only set iStart once and only call fnFormatNumber once on iStart.
2012-09-30 10:21:09 -03:00
Allan Jardine
c14b49fca3 Remove - asStripClasses backwards compatiblity. There was a typo for asStripeClasses back when it was first introduced, now here in 1.10 the patch that was used to allow both forms is removed. 2012-09-30 09:22:06 +01:00
Allan Jardine
6b605936f7 Update: Significant update to how sorting is applied internally in DataTables - there is no difference to how the sort is actually done, with the single exception that the -asc and -desc are not depricated in favour of the -pre method only.
- With the introduction of the -pre method in DataTables 1.9, the -asc and -desc sorting functions became more or less redundant since they are simple comparisons (all of the complexity is now in the -pre formatting function). As such the call to the -asc / -desc method is overhead that really isn't needed, and this commit introduces a sort function that doesn't call the -asc / -desc methods, instead just doing the comparison itself. In tests, this relatively simple change leads to a performance improvement of around 15% in all browsers (it also has the side benefit of less operations, so IE8- will be able to sort larger tables before flagging up a slow script warning).

- We can't just remove the sorting method which will call -asc / -desc though since not all sorting plug-ins will have a -pre method. Therefore, for backwards compatiblity the old sort function (albeit updated for the changed variables) is retained. The backwards compatibality code adds around 300 bytes to the library, but this is an unaccounced change, so backwards compatiblity must be retained.

- The old sort method will be removed in v1.11. The -asc and -desc methods are now fully depricated.

- Altered the sorting method to flatten the aaSorting array since the introduction of aDataSort in v1.9 required an extra loop in several locations. The functionality is very useful, but the extra loop can be a bit messy and slightly hit performance, so it is now flattened to be a single array (with object information so it makes sense, rather htan array indexes!).

- Altered the order of sorting when building _aSortData since it was looking up the same variable smultiple times which really wasn't needed.

This is part of a small incremental changes plan for DataTables! There are still a huge number of things to improve in this area, but this is a nice clean up and a nice 15% sorting performance improvement to get us started :-).
2012-09-29 21:25:41 +01:00
Allan Jardine
6900a59e74 Fix - docs: Need to escape the underscores for markup output when we now use. 2012-09-29 21:24:56 +01:00
Allan Jardine
36076fc5c8 Removed: sName reordering on return from the server when server-side processing. This was depricated in DataTables 1.9 and is now removed. This was an inefficient way to supply data to the DataTable in an array that was out of order and the client-side would reorder the arrays into what was needed. The way to do this now is to use mData and JSON objects rather than arrays, as it provides much greater flexibility without a performance hit on the client-side.
Note: _fnColumnOrdering is left in place at the moment, although it may be updated as work progresses on 1.10 with regard to the increased use of column names.
2012-09-23 18:49:11 +01:00
Allan Jardine
8d56d0204e Starting DataTables 1.10 development :-)
Removed: fnRender - fnRender was depricated in 1.9 and is now being completely removed here. Its always been a bit messy and is now superseded by mRender. The main reason for this is that DataTables use to take an independent copy of the input data source object / array. This is a performance hit and it means we can't do any binding to external objects (for example it makes Knockout integration almost impossible).
Removed: bUseRendered - with fnRender being removed, bUseRendered is irrelevent
Updated: With fnRender being removed we no longer need to take an independent copy of the data source object / array (since DataTables itself isn't ever going to write to it now - fnRender did and the copy was included so we didn't inadvertantly change a developers data source object without them knowing about it. This is no longer a problem, and in fact having it use the same data source object is extremely useful in many cases.
2012-09-23 18:38:25 +01:00
Allan Jardine
6c41618c71 Update: jQuery 1.8.2 2012-09-23 14:18:58 +01:00
Allan Jardine
822c62d05d DataTables 1.9.4 2012-09-23 14:16:14 +01:00
Allan Jardine
26d2926390 Fix: Ie9 throws an error when document.activeElement is used inside a frame or iframe... So need to wrap the test up in a try/catch. Nasty. 2012-09-23 13:12:39 +01:00
Allan Jardine
bd6bb74967 Fix: Header TD elements need an outline of none to stop of focus flicker (matching TH elements which already have this) 2012-09-19 07:27:52 +01:00
Allan Jardine
b4cd9f11c6 Fix: A header made of only TD elements wasn't being correctly detected - 11705 2012-09-19 07:27:11 +01:00
Allan Jardine
77a8cb5946 Update: jQuery to 1.8.1 2012-09-19 07:26:21 +01:00
Allan Jardine
d1142e1450 Fix: If the user is currently focused on the filtering input element, don't overwrite the value that is already shown as this will effect the cursor position. 2012-09-16 12:00:36 +01:00
Allan Jardine
a19e1dee12 Dev: Use className for the newly created TR - slightly faster than addClass which isn't needed here 2012-09-16 11:19:53 +01:00
Allan Jardine
e25b377ee8 Fix: State saving deletion of cookies was somewhat broken. It would delete cookies out of order, which is not what we want. Rewrite how the 'overage' of cookies (4K limit) is handled 2012-09-13 18:13:32 +01:00
Allan Jardine
a43714bfba Fix - docs: sNext and sPrevious referened to full_numbers pagination type, but they can be used for any pagination control: 9192 2012-09-12 07:47:29 +01:00
Allan Jardine
66e92ab655 Fix - docs: Documentation error for fnGetPosition - missing one of the return indexes - 11708 2012-09-11 10:09:03 +01:00
Allan Jardine
ca96ed55d5 Fix: Remove irrelevent and broken bSortable check for the column options - fix issue #101 2012-09-11 07:04:41 +01:00
Allan Jardine
0a3793b4bb Dev: Tidy up the way that the header and footer elements are 'got'. Based on pull request #92. 2012-09-09 18:43:57 +01:00
Allan Jardine
df614240cf Update: Fully deprecate fnRender - it will be removed from the next major version of DataTables and it is strongly adviced that you do not use it! 2012-09-09 12:26:57 +01:00
Allan Jardine
880de42c6e Dev: Remove debug from last commit... 2012-09-09 12:05:20 +01:00
Allan Jardine
555aacfc6d Fix: mRender and mData now work in the same way for DOM sourced tables as they do for JS sourced table data. Generally we wouldn't really expect them to be used as much for DOM sourced tables (if you want your table formatted differently, you'd just create the HTML differently!), but it can sometimes be useful to use these options. This also brings mRender to full 'pace' ready to be used in complete preference to fnRender (alongside the other methods for cell rendeirng such an fnCellCreated etc). 2012-09-09 11:57:02 +01:00
Allan Jardine
898357fc84 Merge pull request #98 from timtucker/patch-14
Update media/src/core/core.sort.js
2012-09-04 09:38:03 -07:00
Allan Jardine
30f936d8ff Merge pull request #97 from timtucker/patch-13
Update media/src/core/core.info.js
2012-09-04 09:30:58 -07:00
Allan Jardine
6d11218a7f Merge pull request #96 from timtucker/patch-12
Update media/src/core/core.info.js
2012-09-04 09:30:06 -07:00
Allan Jardine
bb08308dfe Merge pull request #95 from timtucker/patch-11
Update media/src/core/core.sizing.js
2012-09-04 09:29:15 -07:00
Allan Jardine
3ffa14ea8a Merge pull request #94 from timtucker/patch-10
Update media/src/core/core.sizing.js
2012-09-04 09:28:07 -07:00
Allan Jardine
4603ad13d4 Merge pull request #93 from timtucker/patch-9
Update media/src/core/core.scrolling.js
2012-09-04 09:27:25 -07:00
Allan Jardine
95381359ed Merge pull request #91 from timtucker/patch-7
Update media/src/core/core.scrolling.js
2012-09-04 09:24:50 -07:00
Tim Tucker
a66bec8368 Update media/src/DataTables.js
Simplify by not passing in undefined to the outer closure
2012-09-04 13:03:20 -03:00
Tim Tucker
89be8f4083 Update media/src/core/core.sort.js
Speed things up by applying classes only when needed
2012-09-04 11:05:53 -03:00
Tim Tucker
cb2495b440 Update media/src/core/core.sort.js
Use var to keep track of # of classes found (length on sparse array doesn't work properly)
2012-09-03 19:36:18 -03:00
Tim Tucker
6bce847a3b Update media/src/core/core.sort.js
Further refinement - stop once all sorting classes have been seen
2012-09-03 19:12:03 -03:00
Tim Tucker
2afa5e4360 Update media/src/core/core.sort.js
Combined method for removing classes
2012-09-03 18:21:01 -03:00
Tim Tucker
e6e4205b02 Update media/src/core/core.sort.js
Forgot parameter to lastIndexOf
2012-09-03 16:54:30 -03:00
Tim Tucker
6a5c4cf261 Update media/src/core/core.sort.js
Use simpler dom-based method for deferred render
2012-09-03 16:53:00 -03:00
Tim Tucker
24fc23f63d Update media/src/core/core.sort.js
Simplify and improve performance
- Only check once for the presence of any sorting class instead of checking for the 3 individual classes
- Use lastIndexOf(str, 0) instead of indexOf

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

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

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

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