"
},
_create: function() {
this._tabify( true );
},
_setOption: function( key, value ) {
if ( key == "selected" ) {
if (this.options.collapsible && value == this.options.selected ) {
return;
}
this.select( value );
} else {
this.options[ key ] = value;
this._tabify();
}
},
_tabId: function( a ) {
return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
this.options.idPrefix + getNextTabId();
},
_sanitizeSelector: function( hash ) {
// we need this because an id may contain a ":"
return hash.replace( /:/g, "\\:" );
},
_cookie: function() {
var cookie = this.cookie ||
( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
},
_ui: function( tab, panel ) {
return {
tab: tab,
panel: panel,
index: this.anchors.index( tab )
};
},
_cleanup: function() {
// restore all former loading tabs labels
this.lis.filter( ".ui-state-processing" )
.removeClass( "ui-state-processing" )
.find( "span:data(label.tabs)" )
.each(function() {
var el = $( this );
el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
});
},
_tabify: function( init ) {
var self = this,
o = this.options,
fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
this.list = this.element.find( "ol,ul" ).eq( 0 );
this.lis = $( " > li:has(a[href])", this.list );
this.anchors = this.lis.map(function() {
return $( "a", this )[ 0 ];
});
this.panels = $( [] );
this.anchors.each(function( i, a ) {
var href = $( a ).attr( "href" );
// For dynamically created HTML that contains a hash as href IE < 8 expands
// such href to the full page url with hash and then misinterprets tab as ajax.
// Same consideration applies for an added tab with a fragment identifier
// since a[href=#fragment-identifier] does unexpectedly not match.
// Thus normalize href attribute...
var hrefBase = href.split( "#" )[ 0 ],
baseEl;
if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
href = a.hash;
a.href = href;
}
// inline tab
if ( fragmentId.test( href ) ) {
self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
// remote tab
// prevent loading the page itself if href is just "#"
} else if ( href && href !== "#" ) {
// required for restore on destroy
$.data( a, "href.tabs", href );
// TODO until #3808 is fixed strip fragment identifier from url
// (IE fails to load from such url)
$.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
var id = self._tabId( a );
a.href = "#" + id;
var $panel = self.element.find( "#" + id );
if ( !$panel.length ) {
$panel = $( o.panelTemplate )
.attr( "id", id )
.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
.insertAfter( self.panels[ i - 1 ] || self.list );
$panel.data( "destroy.tabs", true );
}
self.panels = self.panels.add( $panel );
// invalid tab href
} else {
o.disabled.push( i );
}
});
// initialization from scratch
if ( init ) {
// attach necessary classes for styling
this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
this.lis.addClass( "ui-state-default ui-corner-top" );
this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
// Selected tab
// use "selected" option or try to retrieve:
// 1. from fragment identifier in url
// 2. from cookie
// 3. from selected class attribute on
if ( o.selected === undefined ) {
if ( location.hash ) {
this.anchors.each(function( i, a ) {
if ( a.hash == location.hash ) {
o.selected = i;
return false;
}
});
}
if ( typeof o.selected !== "number" && o.cookie ) {
o.selected = parseInt( self._cookie(), 10 );
}
if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
}
o.selected = o.selected || ( this.lis.length ? 0 : -1 );
} else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
o.selected = -1;
}
// sanity check - default to first tab...
o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
? o.selected
: 0;
// Take disabling tabs via class attribute from HTML
// into account and update option properly.
// A selected tab cannot become disabled.
o.disabled = $.unique( o.disabled.concat(
$.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
return self.lis.index( n );
})
) ).sort();
if ( $.inArray( o.selected, o.disabled ) != -1 ) {
o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
}
// highlight selected tab
this.panels.addClass( "ui-tabs-hide" );
this.lis.removeClass( "ui-tabs-selected ui-state-active" );
// check for length avoids error when initializing empty list
if ( o.selected >= 0 && this.anchors.length ) {
self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
// seems to be expected behavior that the show callback is fired
self.element.queue( "tabs", function() {
self._trigger( "show", null,
self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
});
this.load( o.selected );
}
// clean up to avoid memory leaks in certain versions of IE 6
// TODO: namespace this event
$( window ).bind( "unload", function() {
self.lis.add( self.anchors ).unbind( ".tabs" );
self.lis = self.anchors = self.panels = null;
});
// update selected after add/remove
} else {
o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
}
// update collapsible
// TODO: use .toggleClass()
this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
// set or update cookie after init and add/remove respectively
if ( o.cookie ) {
this._cookie( o.selected, o.cookie );
}
// disable tabs
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
$( li )[ $.inArray( i, o.disabled ) != -1 &&
// TODO: use .toggleClass()
!$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
}
// reset cache if switching from cached to not cached
if ( o.cache === false ) {
this.anchors.removeData( "cache.tabs" );
}
// remove all handlers before, tabify may run on existing tabs after add or option change
this.lis.add( this.anchors ).unbind( ".tabs" );
if ( o.event !== "mouseover" ) {
var addState = function( state, el ) {
if ( el.is( ":not(.ui-state-disabled)" ) ) {
el.addClass( "ui-state-" + state );
}
};
var removeState = function( state, el ) {
el.removeClass( "ui-state-" + state );
};
this.lis.bind( "mouseover.tabs" , function() {
addState( "hover", $( this ) );
});
this.lis.bind( "mouseout.tabs", function() {
removeState( "hover", $( this ) );
});
this.anchors.bind( "focus.tabs", function() {
addState( "focus", $( this ).closest( "li" ) );
});
this.anchors.bind( "blur.tabs", function() {
removeState( "focus", $( this ).closest( "li" ) );
});
}
// set up animations
var hideFx, showFx;
if ( o.fx ) {
if ( $.isArray( o.fx ) ) {
hideFx = o.fx[ 0 ];
showFx = o.fx[ 1 ];
} else {
hideFx = showFx = o.fx;
}
}
// Reset certain styles left over from animation
// and prevent IE's ClearType bug...
function resetStyle( $el, fx ) {
$el.css( "display", "" );
if ( !$.support.opacity && fx.opacity ) {
$el[ 0 ].style.removeAttribute( "filter" );
}
}
// Show a tab...
var showTab = showFx
? function( clicked, $show ) {
$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
$show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
.animate( showFx, showFx.duration || "normal", function() {
resetStyle( $show, showFx );
self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
});
}
: function( clicked, $show ) {
$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
$show.removeClass( "ui-tabs-hide" );
self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
};
// Hide a tab, $show is optional...
var hideTab = hideFx
? function( clicked, $hide ) {
$hide.animate( hideFx, hideFx.duration || "normal", function() {
self.lis.removeClass( "ui-tabs-selected ui-state-active" );
$hide.addClass( "ui-tabs-hide" );
resetStyle( $hide, hideFx );
self.element.dequeue( "tabs" );
});
}
: function( clicked, $hide, $show ) {
self.lis.removeClass( "ui-tabs-selected ui-state-active" );
$hide.addClass( "ui-tabs-hide" );
self.element.dequeue( "tabs" );
};
// attach tab event handler, unbind to avoid duplicates from former tabifying...
this.anchors.bind( o.event + ".tabs", function() {
var el = this,
$li = $(el).closest( "li" ),
$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
$show = self.element.find( self._sanitizeSelector( el.hash ) );
// If tab is already selected and not collapsible or tab disabled or
// or is already loading or click callback returns false stop here.
// Check if click handler returns false last so that it is not executed
// for a disabled or loading tab!
if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
$li.hasClass( "ui-state-disabled" ) ||
$li.hasClass( "ui-state-processing" ) ||
self.panels.filter( ":animated" ).length ||
self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
this.blur();
return false;
}
o.selected = self.anchors.index( this );
self.abort();
// if tab may be closed
if ( o.collapsible ) {
if ( $li.hasClass( "ui-tabs-selected" ) ) {
o.selected = -1;
if ( o.cookie ) {
self._cookie( o.selected, o.cookie );
}
self.element.queue( "tabs", function() {
hideTab( el, $hide );
}).dequeue( "tabs" );
this.blur();
return false;
} else if ( !$hide.length ) {
if ( o.cookie ) {
self._cookie( o.selected, o.cookie );
}
self.element.queue( "tabs", function() {
showTab( el, $show );
});
// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
self.load( self.anchors.index( this ) );
this.blur();
return false;
}
}
if ( o.cookie ) {
self._cookie( o.selected, o.cookie );
}
// show new tab
if ( $show.length ) {
if ( $hide.length ) {
self.element.queue( "tabs", function() {
hideTab( el, $hide );
});
}
self.element.queue( "tabs", function() {
showTab( el, $show );
});
self.load( self.anchors.index( this ) );
} else {
throw "jQuery UI Tabs: Mismatching fragment identifier.";
}
// Prevent IE from keeping other link focussed when using the back button
// and remove dotted border from clicked link. This is controlled via CSS
// in modern browsers; blur() removes focus from address bar in Firefox
// which can become a usability and annoying problem with tabs('rotate').
if ( $.browser.msie ) {
this.blur();
}
});
// disable click in any case
this.anchors.bind( "click.tabs", function(){
return false;
});
},
_getIndex: function( index ) {
// meta-function to give users option to provide a href string instead of a numerical index.
// also sanitizes numerical indexes to valid values.
if ( typeof index == "string" ) {
index = this.anchors.index( this.anchors.filter( "[href$=" + index + "]" ) );
}
return index;
},
destroy: function() {
var o = this.options;
this.abort();
this.element
.unbind( ".tabs" )
.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
.removeData( "tabs" );
this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
this.anchors.each(function() {
var href = $.data( this, "href.tabs" );
if ( href ) {
this.href = href;
}
var $this = $( this ).unbind( ".tabs" );
$.each( [ "href", "load", "cache" ], function( i, prefix ) {
$this.removeData( prefix + ".tabs" );
});
});
this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
if ( $.data( this, "destroy.tabs" ) ) {
$( this ).remove();
} else {
$( this ).removeClass([
"ui-state-default",
"ui-corner-top",
"ui-tabs-selected",
"ui-state-active",
"ui-state-hover",
"ui-state-focus",
"ui-state-disabled",
"ui-tabs-panel",
"ui-widget-content",
"ui-corner-bottom",
"ui-tabs-hide"
].join( " " ) );
}
});
if ( o.cookie ) {
this._cookie( null, o.cookie );
}
return this;
},
add: function( url, label, index ) {
if ( index === undefined ) {
index = this.anchors.length;
}
var self = this,
o = this.options,
$li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
$li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
// try to find an existing element before creating a new one
var $panel = self.element.find( "#" + id );
if ( !$panel.length ) {
$panel = $( o.panelTemplate )
.attr( "id", id )
.data( "destroy.tabs", true );
}
$panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
if ( index >= this.lis.length ) {
$li.appendTo( this.list );
$panel.appendTo( this.list[ 0 ].parentNode );
} else {
$li.insertBefore( this.lis[ index ] );
$panel.insertBefore( this.panels[ index ] );
}
o.disabled = $.map( o.disabled, function( n, i ) {
return n >= index ? ++n : n;
});
this._tabify();
if ( this.anchors.length == 1 ) {
o.selected = 0;
$li.addClass( "ui-tabs-selected ui-state-active" );
$panel.removeClass( "ui-tabs-hide" );
this.element.queue( "tabs", function() {
self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
});
this.load( 0 );
}
this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
return this;
},
remove: function( index ) {
index = this._getIndex( index );
var o = this.options,
$li = this.lis.eq( index ).remove(),
$panel = this.panels.eq( index ).remove();
// If selected tab was removed focus tab to the right or
// in case the last tab was removed the tab to the left.
if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
}
o.disabled = $.map(
$.grep( o.disabled, function(n, i) {
return n != index;
}),
function( n, i ) {
return n >= index ? --n : n;
});
this._tabify();
this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
return this;
},
enable: function( index ) {
index = this._getIndex( index );
var o = this.options;
if ( $.inArray( index, o.disabled ) == -1 ) {
return;
}
this.lis.eq( index ).removeClass( "ui-state-disabled" );
o.disabled = $.grep( o.disabled, function( n, i ) {
return n != index;
});
this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
return this;
},
disable: function( index ) {
index = this._getIndex( index );
var self = this, o = this.options;
// cannot disable already selected tab
if ( index != o.selected ) {
this.lis.eq( index ).addClass( "ui-state-disabled" );
o.disabled.push( index );
o.disabled.sort();
this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
}
return this;
},
select: function( index ) {
index = this._getIndex( index );
if ( index == -1 ) {
if ( this.options.collapsible && this.options.selected != -1 ) {
index = this.options.selected;
} else {
return this;
}
}
this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
return this;
},
load: function( index ) {
index = this._getIndex( index );
var self = this,
o = this.options,
a = this.anchors.eq( index )[ 0 ],
url = $.data( a, "load.tabs" );
this.abort();
// not remote or from cache
if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
this.element.dequeue( "tabs" );
return;
}
// load remote from here on
this.lis.eq( index ).addClass( "ui-state-processing" );
if ( o.spinner ) {
var span = $( "span", a );
span.data( "label.tabs", span.html() ).html( o.spinner );
}
this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
url: url,
success: function( r, s ) {
self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
// take care of tab labels
self._cleanup();
if ( o.cache ) {
$.data( a, "cache.tabs", true );
}
self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
try {
o.ajaxOptions.success( r, s );
}
catch ( e ) {}
},
error: function( xhr, s, e ) {
// take care of tab labels
self._cleanup();
self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
try {
// Passing index avoid a race condition when this method is
// called after the user has selected another tab.
// Pass the anchor that initiated this request allows
// loadError to manipulate the tab content panel via $(a.hash)
o.ajaxOptions.error( xhr, s, index, a );
}
catch ( e ) {}
}
} ) );
// last, so that load event is fired before show...
self.element.dequeue( "tabs" );
return this;
},
abort: function() {
// stop possibly running animations
this.element.queue( [] );
this.panels.stop( false, true );
// "tabs" queue must not contain more than two elements,
// which are the callbacks for the latest clicked tab...
this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
// terminate pending requests from other tabs
if ( this.xhr ) {
this.xhr.abort();
delete this.xhr;
}
// take care of tab labels
this._cleanup();
return this;
},
url: function( index, url ) {
this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
return this;
},
length: function() {
return this.anchors.length;
}
});
$.extend( $.ui.tabs, {
version: "1.8.16"
});
/*
* Tabs Extensions
*/
/*
* Rotate
*/
$.extend( $.ui.tabs.prototype, {
rotation: null,
rotate: function( ms, continuing ) {
var self = this,
o = this.options;
var rotate = self._rotate || ( self._rotate = function( e ) {
clearTimeout( self.rotation );
self.rotation = setTimeout(function() {
var t = o.selected;
self.select( ++t < self.anchors.length ? t : 0 );
}, ms );
if ( e ) {
e.stopPropagation();
}
});
var stop = self._unrotate || ( self._unrotate = !continuing
? function(e) {
if (e.clientX) { // in case of a true click
self.rotate(null);
}
}
: function( e ) {
t = o.selected;
rotate();
});
// start rotation
if ( ms ) {
this.element.bind( "tabsshow", rotate );
this.anchors.bind( o.event + ".tabs", stop );
rotate();
// stop rotation
} else {
clearTimeout( self.rotation );
this.element.unbind( "tabsshow", rotate );
this.anchors.unbind( o.event + ".tabs", stop );
delete this._rotate;
delete this._unrotate;
}
return this;
}
});
})( jQuery );
/*
* jQuery UI Datepicker 1.8.16
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Datepicker
*
* Depends:
* jquery.ui.core.js
*/
(function( $, undefined ) {
$.extend($.ui, { datepicker: { version: "1.8.16" } });
var PROP_NAME = 'datepicker';
var dpuuid = new Date().getTime();
var instActive;
/* Date picker manager.
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
Settings for (groups of) date pickers are maintained in an instance object,
allowing multiple different settings on the same page. */
function Datepicker() {
this.debug = false; // Change this to true to start debugging
this._curInst = null; // The current instance in use
this._keyEvent = false; // If the last event was a key event
this._disabledInputs = []; // List of date picker inputs that have been disabled
this._datepickerShowing = false; // True if the popup picker is showing , false if not
this._inDialog = false; // True if showing within a "dialog", false if not
this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
closeText: 'Done', // Display text for close link
prevText: 'Prev', // Display text for previous month link
nextText: 'Next', // Display text for next month link
currentText: 'Today', // Display text for current month link
monthNames: ['January','February','March','April','May','June',
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
weekHeader: 'Wk', // Column header for week of the year
dateFormat: 'mm/dd/yy', // See format options on parseDate
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
isRTL: false, // True if right-to-left language, false if left-to-right
showMonthAfterYear: false, // True if the year select precedes month, false for month then year
yearSuffix: '' // Additional text to append to the year in the month headers
};
this._defaults = { // Global defaults for all the date picker instances
showOn: 'focus', // 'focus' for popup on focus,
// 'button' for trigger button, or 'both' for either
showAnim: 'fadeIn', // Name of jQuery animation for popup
showOptions: {}, // Options for enhanced animations
defaultDate: null, // Used when field is blank: actual date,
// +/-number for offset from today, null for today
appendText: '', // Display text following the input box, e.g. showing the format
buttonText: '...', // Text for trigger button
buttonImage: '', // URL for trigger button image
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
hideIfNoPrevNext: false, // True to hide next/previous month links
// if not applicable, false to just disable them
navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
gotoCurrent: false, // True if today link goes back to current selection instead
changeMonth: false, // True if month can be selected directly, false if only prev/next
changeYear: false, // True if year can be selected directly, false if only prev/next
yearRange: 'c-10:c+10', // Range of years to display in drop-down,
// either relative to today's year (-nn:+nn), relative to currently displayed year
// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
showOtherMonths: false, // True to show dates in other months, false to leave blank
selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
showWeek: false, // True to show week of the year, false to not show it
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
// takes a Date and returns the number of the week for it
shortYearCutoff: '+10', // Short year values < this are in the current century,
// > this are in the previous century,
// string value starting with '+' for current year + value
minDate: null, // The earliest selectable date, or null for no limit
maxDate: null, // The latest selectable date, or null for no limit
duration: 'fast', // Duration of display/closure
beforeShowDay: null, // Function that takes a date and returns an array with
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
beforeShow: null, // Function that takes an input field and
// returns a set of custom settings for the date picker
onSelect: null, // Define a callback function when a date is selected
onChangeMonthYear: null, // Define a callback function when the month or year is changed
onClose: null, // Define a callback function when the datepicker is closed
numberOfMonths: 1, // Number of months to show at a time
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
stepMonths: 1, // Number of months to step back/forward
stepBigMonths: 12, // Number of months to step back/forward for the big links
altField: '', // Selector for an alternate field to store selected dates into
altFormat: '', // The date format to use for the alternate field
constrainInput: true, // The input is constrained by the current date format
showButtonPanel: false, // True to show button panel, false to not show it
autoSize: false, // True to size the input for the date format, false to leave as is
disabled: false // The initial disabled state
};
$.extend(this._defaults, this.regional['']);
this.dpDiv = bindHover($(''));
}
$.extend(Datepicker.prototype, {
/* Class name added to elements to indicate already configured with a date picker. */
markerClassName: 'hasDatepicker',
//Keep track of the maximum number of rows displayed (see #7043)
maxRows: 4,
/* Debug logging (if enabled). */
log: function () {
if (this.debug)
console.log.apply('', arguments);
},
// TODO rename to "widget" when switching to widget factory
_widgetDatepicker: function() {
return this.dpDiv;
},
/* Override the default settings for all instances of the date picker.
@param settings object - the new settings to use as defaults (anonymous object)
@return the manager object */
setDefaults: function(settings) {
extendRemove(this._defaults, settings || {});
return this;
},
/* Attach the date picker to a jQuery selection.
@param target element - the target input field or division or span
@param settings object - the new settings to use for this date picker instance (anonymous) */
_attachDatepicker: function(target, settings) {
// check for settings on the control itself - in namespace 'date:'
var inlineSettings = null;
for (var attrName in this._defaults) {
var attrValue = target.getAttribute('date:' + attrName);
if (attrValue) {
inlineSettings = inlineSettings || {};
try {
inlineSettings[attrName] = eval(attrValue);
} catch (err) {
inlineSettings[attrName] = attrValue;
}
}
}
var nodeName = target.nodeName.toLowerCase();
var inline = (nodeName == 'div' || nodeName == 'span');
if (!target.id) {
this.uuid += 1;
target.id = 'dp' + this.uuid;
}
var inst = this._newInst($(target), inline);
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
if (nodeName == 'input') {
this._connectDatepicker(target, inst);
} else if (inline) {
this._inlineDatepicker(target, inst);
}
},
/* Create a new instance object. */
_newInst: function(target, inline) {
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
return {id: id, input: target, // associated target
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
drawMonth: 0, drawYear: 0, // month being drawn
inline: inline, // is datepicker inline or not
dpDiv: (!inline ? this.dpDiv : // presentation div
bindHover($('')))};
},
/* Attach the date picker to an input field. */
_connectDatepicker: function(target, inst) {
var input = $(target);
inst.append = $([]);
inst.trigger = $([]);
if (input.hasClass(this.markerClassName))
return;
this._attachments(input, inst);
input.addClass(this.markerClassName).keydown(this._doKeyDown).
keypress(this._doKeyPress).keyup(this._doKeyUp).
bind("setData.datepicker", function(event, key, value) {
inst.settings[key] = value;
}).bind("getData.datepicker", function(event, key) {
return this._get(inst, key);
});
this._autoSize(inst);
$.data(target, PROP_NAME, inst);
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
if( inst.settings.disabled ) {
this._disableDatepicker( target );
}
},
/* Make attachments based on settings. */
_attachments: function(input, inst) {
var appendText = this._get(inst, 'appendText');
var isRTL = this._get(inst, 'isRTL');
if (inst.append)
inst.append.remove();
if (appendText) {
inst.append = $('' + appendText + '');
input[isRTL ? 'before' : 'after'](inst.append);
}
input.unbind('focus', this._showDatepicker);
if (inst.trigger)
inst.trigger.remove();
var showOn = this._get(inst, 'showOn');
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
input.focus(this._showDatepicker);
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
var buttonText = this._get(inst, 'buttonText');
var buttonImage = this._get(inst, 'buttonImage');
inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
$('').addClass(this._triggerClass).
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
$('').addClass(this._triggerClass).
html(buttonImage == '' ? buttonText : $('').attr(
{ src:buttonImage, alt:buttonText, title:buttonText })));
input[isRTL ? 'before' : 'after'](inst.trigger);
inst.trigger.click(function() {
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
$.datepicker._hideDatepicker();
else
$.datepicker._showDatepicker(input[0]);
return false;
});
}
},
/* Apply the maximum length for the date format. */
_autoSize: function(inst) {
if (this._get(inst, 'autoSize') && !inst.inline) {
var date = new Date(2009, 12 - 1, 20); // Ensure double digits
var dateFormat = this._get(inst, 'dateFormat');
if (dateFormat.match(/[DM]/)) {
var findMax = function(names) {
var max = 0;
var maxI = 0;
for (var i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
'monthNames' : 'monthNamesShort'))));
date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
}
inst.input.attr('size', this._formatDate(inst, date).length);
}
},
/* Attach an inline date picker to a div. */
_inlineDatepicker: function(target, inst) {
var divSpan = $(target);
if (divSpan.hasClass(this.markerClassName))
return;
divSpan.addClass(this.markerClassName).append(inst.dpDiv).
bind("setData.datepicker", function(event, key, value){
inst.settings[key] = value;
}).bind("getData.datepicker", function(event, key){
return this._get(inst, key);
});
$.data(target, PROP_NAME, inst);
this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst);
this._updateAlternate(inst);
//If disabled option is true, disable the datepicker before showing it (see ticket #5665)
if( inst.settings.disabled ) {
this._disableDatepicker( target );
}
// Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
// http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
inst.dpDiv.css( "display", "block" );
},
/* Pop-up the date picker in a "dialog" box.
@param input element - ignored
@param date string or Date - the initial date to display
@param onSelect function - the function to call when a date is selected
@param settings object - update the dialog date picker instance's settings (anonymous object)
@param pos int[2] - coordinates for the dialog's position within the screen or
event - with x/y coordinates or
leave empty for default (screen centre)
@return the manager object */
_dialogDatepicker: function(input, date, onSelect, settings, pos) {
var inst = this._dialogInst; // internal instance
if (!inst) {
this.uuid += 1;
var id = 'dp' + this.uuid;
this._dialogInput = $('');
this._dialogInput.keydown(this._doKeyDown);
$('body').append(this._dialogInput);
inst = this._dialogInst = this._newInst(this._dialogInput, false);
inst.settings = {};
$.data(this._dialogInput[0], PROP_NAME, inst);
}
extendRemove(inst.settings, settings || {});
date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
this._dialogInput.val(date);
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
if (!this._pos) {
var browserWidth = document.documentElement.clientWidth;
var browserHeight = document.documentElement.clientHeight;
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
this._pos = // should use actual width/height below
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
}
// move input on screen for focus, but hidden behind dialog
this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
inst.settings.onSelect = onSelect;
this._inDialog = true;
this.dpDiv.addClass(this._dialogClass);
this._showDatepicker(this._dialogInput[0]);
if ($.blockUI)
$.blockUI(this.dpDiv);
$.data(this._dialogInput[0], PROP_NAME, inst);
return this;
},
/* Detach a datepicker from its control.
@param target element - the target input field or division or span */
_destroyDatepicker: function(target) {
var $target = $(target);
var inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
var nodeName = target.nodeName.toLowerCase();
$.removeData(target, PROP_NAME);
if (nodeName == 'input') {
inst.append.remove();
inst.trigger.remove();
$target.removeClass(this.markerClassName).
unbind('focus', this._showDatepicker).
unbind('keydown', this._doKeyDown).
unbind('keypress', this._doKeyPress).
unbind('keyup', this._doKeyUp);
} else if (nodeName == 'div' || nodeName == 'span')
$target.removeClass(this.markerClassName).empty();
},
/* Enable the date picker to a jQuery selection.
@param target element - the target input field or division or span */
_enableDatepicker: function(target) {
var $target = $(target);
var inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
var nodeName = target.nodeName.toLowerCase();
if (nodeName == 'input') {
target.disabled = false;
inst.trigger.filter('button').
each(function() { this.disabled = false; }).end().
filter('img').css({opacity: '1.0', cursor: ''});
}
else if (nodeName == 'div' || nodeName == 'span') {
var inline = $target.children('.' + this._inlineClass);
inline.children().removeClass('ui-state-disabled');
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
removeAttr("disabled");
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
},
/* Disable the date picker to a jQuery selection.
@param target element - the target input field or division or span */
_disableDatepicker: function(target) {
var $target = $(target);
var inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
var nodeName = target.nodeName.toLowerCase();
if (nodeName == 'input') {
target.disabled = true;
inst.trigger.filter('button').
each(function() { this.disabled = true; }).end().
filter('img').css({opacity: '0.5', cursor: 'default'});
}
else if (nodeName == 'div' || nodeName == 'span') {
var inline = $target.children('.' + this._inlineClass);
inline.children().addClass('ui-state-disabled');
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
attr("disabled", "disabled");
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
this._disabledInputs[this._disabledInputs.length] = target;
},
/* Is the first field in a jQuery collection disabled as a datepicker?
@param target element - the target input field or division or span
@return boolean - true if disabled, false if enabled */
_isDisabledDatepicker: function(target) {
if (!target) {
return false;
}
for (var i = 0; i < this._disabledInputs.length; i++) {
if (this._disabledInputs[i] == target)
return true;
}
return false;
},
/* Retrieve the instance data for the target control.
@param target element - the target input field or division or span
@return object - the associated instance data
@throws error if a jQuery problem getting data */
_getInst: function(target) {
try {
return $.data(target, PROP_NAME);
}
catch (err) {
throw 'Missing instance data for this datepicker';
}
},
/* Update or retrieve the settings for a date picker attached to an input field or division.
@param target element - the target input field or division or span
@param name object - the new settings to update or
string - the name of the setting to change or retrieve,
when retrieving also 'all' for all instance settings or
'defaults' for all global defaults
@param value any - the new value for the setting
(omit if above is an object or to retrieve a value) */
_optionDatepicker: function(target, name, value) {
var inst = this._getInst(target);
if (arguments.length == 2 && typeof name == 'string') {
return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
(inst ? (name == 'all' ? $.extend({}, inst.settings) :
this._get(inst, name)) : null));
}
var settings = name || {};
if (typeof name == 'string') {
settings = {};
settings[name] = value;
}
if (inst) {
if (this._curInst == inst) {
this._hideDatepicker();
}
var date = this._getDateDatepicker(target, true);
var minDate = this._getMinMaxDate(inst, 'min');
var maxDate = this._getMinMaxDate(inst, 'max');
extendRemove(inst.settings, settings);
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
inst.settings.minDate = this._formatDate(inst, minDate);
if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
inst.settings.maxDate = this._formatDate(inst, maxDate);
this._attachments($(target), inst);
this._autoSize(inst);
this._setDate(inst, date);
this._updateAlternate(inst);
this._updateDatepicker(inst);
}
},
// change method deprecated
_changeDatepicker: function(target, name, value) {
this._optionDatepicker(target, name, value);
},
/* Redraw the date picker attached to an input field or division.
@param target element - the target input field or division or span */
_refreshDatepicker: function(target) {
var inst = this._getInst(target);
if (inst) {
this._updateDatepicker(inst);
}
},
/* Set the dates for a jQuery selection.
@param target element - the target input field or division or span
@param date Date - the new date */
_setDateDatepicker: function(target, date) {
var inst = this._getInst(target);
if (inst) {
this._setDate(inst, date);
this._updateDatepicker(inst);
this._updateAlternate(inst);
}
},
/* Get the date(s) for the first entry in a jQuery selection.
@param target element - the target input field or division or span
@param noDefault boolean - true if no default date is to be used
@return Date - the current date */
_getDateDatepicker: function(target, noDefault) {
var inst = this._getInst(target);
if (inst && !inst.inline)
this._setDateFromField(inst, noDefault);
return (inst ? this._getDate(inst) : null);
},
/* Handle keystrokes. */
_doKeyDown: function(event) {
var inst = $.datepicker._getInst(event.target);
var handled = true;
var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
inst._keyEvent = true;
if ($.datepicker._datepickerShowing)
switch (event.keyCode) {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
$.datepicker._currentClass + ')', inst.dpDiv);
if (sel[0])
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
var onSelect = $.datepicker._get(inst, 'onSelect');
if (onSelect) {
var dateStr = $.datepicker._formatDate(inst);
// trigger custom callback
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
}
else
$.datepicker._hideDatepicker();
return false; // don't submit the form
break; // select the value on enter
case 27: $.datepicker._hideDatepicker();
break; // hide on escape
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, 'stepBigMonths') :
-$.datepicker._get(inst, 'stepMonths')), 'M');
break; // previous month/year on page up/+ ctrl
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, 'stepBigMonths') :
+$.datepicker._get(inst, 'stepMonths')), 'M');
break; // next month/year on page down/+ ctrl
case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
handled = event.ctrlKey || event.metaKey;
break; // clear on ctrl or command +end
case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
handled = event.ctrlKey || event.metaKey;
break; // current on ctrl or command +home
case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
handled = event.ctrlKey || event.metaKey;
// -1 day on ctrl or command +left
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, 'stepBigMonths') :
-$.datepicker._get(inst, 'stepMonths')), 'M');
// next month/year on alt +left on Mac
break;
case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
handled = event.ctrlKey || event.metaKey;
break; // -1 week on ctrl or command +up
case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
handled = event.ctrlKey || event.metaKey;
// +1 day on ctrl or command +right
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, 'stepBigMonths') :
+$.datepicker._get(inst, 'stepMonths')), 'M');
// next month/year on alt +right
break;
case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
handled = event.ctrlKey || event.metaKey;
break; // +1 week on ctrl or command +down
default: handled = false;
}
else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
$.datepicker._showDatepicker(this);
else {
handled = false;
}
if (handled) {
event.preventDefault();
event.stopPropagation();
}
},
/* Filter entered characters - based on date format. */
_doKeyPress: function(event) {
var inst = $.datepicker._getInst(event.target);
if ($.datepicker._get(inst, 'constrainInput')) {
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
}
},
/* Synchronise manual entry and field/alternate field. */
_doKeyUp: function(event) {
var inst = $.datepicker._getInst(event.target);
if (inst.input.val() != inst.lastVal) {
try {
var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
(inst.input ? inst.input.val() : null),
$.datepicker._getFormatConfig(inst));
if (date) { // only if valid
$.datepicker._setDateFromField(inst);
$.datepicker._updateAlternate(inst);
$.datepicker._updateDatepicker(inst);
}
}
catch (event) {
$.datepicker.log(event);
}
}
return true;
},
/* Pop-up the date picker for a given input field.
If false returned from beforeShow event handler do not show.
@param input element - the input field attached to the date picker or
event - if triggered by focus */
_showDatepicker: function(input) {
input = input.target || input;
if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
input = $('input', input.parentNode)[0];
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
if ( $.datepicker._datepickerShowing ) {
$.datepicker._triggerOnClose($.datepicker._curInst);
}
$.datepicker._curInst.dpDiv.stop(true, true);
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
if(beforeShowSettings === false){
//false
return;
}
extendRemove(inst.settings, beforeShowSettings);
inst.lastVal = null;
$.datepicker._lastInput = input;
$.datepicker._setDateFromField(inst);
if ($.datepicker._inDialog) // hide cursor
input.value = '';
if (!$.datepicker._pos) { // position below input
$.datepicker._pos = $.datepicker._findPos(input);
$.datepicker._pos[1] += input.offsetHeight; // add the height
}
var isFixed = false;
$(input).parents().each(function() {
isFixed |= $(this).css('position') == 'fixed';
return !isFixed;
});
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
$.datepicker._pos[0] -= document.documentElement.scrollLeft;
$.datepicker._pos[1] -= document.documentElement.scrollTop;
}
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
$.datepicker._pos = null;
//to avoid flashes on Firefox
inst.dpDiv.empty();
// determine sizing offscreen
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
$.datepicker._updateDatepicker(inst);
// fix width for dynamic number of date pickers
// and adjust position before showing
offset = $.datepicker._checkOffset(inst, offset, isFixed);
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
left: offset.left + 'px', top: offset.top + 'px'});
if (!inst.inline) {
var showAnim = $.datepicker._get(inst, 'showAnim');
var duration = $.datepicker._get(inst, 'duration');
var postProcess = function() {
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
if( !! cover.length ){
var borders = $.datepicker._getBorders(inst.dpDiv);
cover.css({left: -borders[0], top: -borders[1],
width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
}
};
inst.dpDiv.zIndex($(input).zIndex()+1);
$.datepicker._datepickerShowing = true;
if ($.effects && $.effects[showAnim])
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
else
inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
if (!showAnim || !duration)
postProcess();
if (inst.input.is(':visible') && !inst.input.is(':disabled'))
inst.input.focus();
$.datepicker._curInst = inst;
}
},
/* Generate the date picker content. */
_updateDatepicker: function(inst) {
var self = this;
self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
var borders = $.datepicker._getBorders(inst.dpDiv);
instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst));
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
}
inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
var numMonths = this._getNumberOfMonths(inst);
var cols = numMonths[1];
var width = 17;
inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
if (cols > 1)
inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
'Class']('ui-datepicker-multi');
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
'Class']('ui-datepicker-rtl');
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
// #6694 - don't focus the input if it's already focused
// this breaks the change event in IE
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
inst.input.focus();
// deffered render of the years select (to avoid flashes on Firefox)
if( inst.yearshtml ){
var origyearshtml = inst.yearshtml;
setTimeout(function(){
//assure that inst.yearshtml didn't change.
if( origyearshtml === inst.yearshtml && inst.yearshtml ){
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
}
origyearshtml = inst.yearshtml = null;
}, 0);
}
},
/* Retrieve the size of left and top borders for an element.
@param elem (jQuery object) the element of interest
@return (number[2]) the left and top borders */
_getBorders: function(elem) {
var convert = function(value) {
return {thin: 1, medium: 2, thick: 3}[value] || value;
};
return [parseFloat(convert(elem.css('border-left-width'))),
parseFloat(convert(elem.css('border-top-width')))];
},
/* Check positioning to remain on screen. */
_checkOffset: function(inst, offset, isFixed) {
var dpWidth = inst.dpDiv.outerWidth();
var dpHeight = inst.dpDiv.outerHeight();
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
// now check if datepicker is showing outside window viewport - move to a better place if so.
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
Math.abs(offset.left + dpWidth - viewWidth) : 0);
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
Math.abs(dpHeight + inputHeight) : 0);
return offset;
},
/* Find an object's position on the screen. */
_findPos: function(obj) {
var inst = this._getInst(obj);
var isRTL = this._get(inst, 'isRTL');
while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
}
var position = $(obj).offset();
return [position.left, position.top];
},
/* Trigger custom callback of onClose. */
_triggerOnClose: function(inst) {
var onClose = this._get(inst, 'onClose');
if (onClose)
onClose.apply((inst.input ? inst.input[0] : null),
[(inst.input ? inst.input.val() : ''), inst]);
},
/* Hide the date picker from view.
@param input element - the input field attached to the date picker */
_hideDatepicker: function(input) {
var inst = this._curInst;
if (!inst || (input && inst != $.data(input, PROP_NAME)))
return;
if (this._datepickerShowing) {
var showAnim = this._get(inst, 'showAnim');
var duration = this._get(inst, 'duration');
var postProcess = function() {
$.datepicker._tidyDialog(inst);
this._curInst = null;
};
if ($.effects && $.effects[showAnim])
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
else
inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
$.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
if ($.blockUI) {
$.unblockUI();
$('body').append(this.dpDiv);
}
}
this._inDialog = false;
}
},
/* Tidy up after a dialog display. */
_tidyDialog: function(inst) {
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
},
/* Close date picker if clicked elsewhere. */
_checkExternalClick: function(event) {
if (!$.datepicker._curInst)
return;
var $target = $(event.target);
if ($target[0].id != $.datepicker._mainDivId &&
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
!$target.hasClass($.datepicker.markerClassName) &&
!$target.hasClass($.datepicker._triggerClass) &&
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
$.datepicker._hideDatepicker();
},
/* Adjust one of the date sub-fields. */
_adjustDate: function(id, offset, period) {
var target = $(id);
var inst = this._getInst(target[0]);
if (this._isDisabledDatepicker(target[0])) {
return;
}
this._adjustInstDate(inst, offset +
(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
period);
this._updateDatepicker(inst);
},
/* Action for current link. */
_gotoToday: function(id) {
var target = $(id);
var inst = this._getInst(target[0]);
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
}
else {
var date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
}
this._notifyChange(inst);
this._adjustDate(target);
},
/* Action for selecting a new month/year. */
_selectMonthYear: function(id, select, period) {
var target = $(id);
var inst = this._getInst(target[0]);
inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
parseInt(select.options[select.selectedIndex].value,10);
this._notifyChange(inst);
this._adjustDate(target);
},
/* Action for selecting a day. */
_selectDay: function(id, month, year, td) {
var target = $(id);
if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
return;
}
var inst = this._getInst(target[0]);
inst.selectedDay = inst.currentDay = $('a', td).html();
inst.selectedMonth = inst.currentMonth = month;
inst.selectedYear = inst.currentYear = year;
this._selectDate(id, this._formatDate(inst,
inst.currentDay, inst.currentMonth, inst.currentYear));
},
/* Erase the input field and hide the date picker. */
_clearDate: function(id) {
var target = $(id);
var inst = this._getInst(target[0]);
this._selectDate(target, '');
},
/* Update the input field with the selected date. */
_selectDate: function(id, dateStr) {
var target = $(id);
var inst = this._getInst(target[0]);
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
if (inst.input)
inst.input.val(dateStr);
this._updateAlternate(inst);
var onSelect = this._get(inst, 'onSelect');
if (onSelect)
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
else if (inst.input)
inst.input.trigger('change'); // fire the change event
if (inst.inline)
this._updateDatepicker(inst);
else {
this._hideDatepicker();
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) != 'object')
inst.input.focus(); // restore focus
this._lastInput = null;
}
},
/* Update any alternate field to synchronise with the main field. */
_updateAlternate: function(inst) {
var altField = this._get(inst, 'altField');
if (altField) { // update alternate field too
var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
var date = this._getDate(inst);
var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
$(altField).each(function() { $(this).val(dateStr); });
}
},
/* Set as beforeShowDay function to prevent selection of weekends.
@param date Date - the date to customise
@return [boolean, string] - is this date selectable?, what is its CSS class? */
noWeekends: function(date) {
var day = date.getDay();
return [(day > 0 && day < 6), ''];
},
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
@param date Date - the date to get the week for
@return number - the number of the week within the year that contains this date */
iso8601Week: function(date) {
var checkDate = new Date(date.getTime());
// Find Thursday of this week starting on Monday
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
checkDate.setMonth(0); // Compare with Jan 1
checkDate.setDate(1);
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
},
/* Parse a string value into a date object.
See formatDate below for the possible formats.
@param format string - the expected format of the date
@param value string - the date in the above format
@param settings Object - attributes include:
shortYearCutoff number - the cutoff year for determining the century (optional)
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
dayNames string[7] - names of the days from Sunday (optional)
monthNamesShort string[12] - abbreviated names of the months (optional)
monthNames string[12] - names of the months (optional)
@return Date - the extracted date value or null if value is blank */
parseDate: function (format, value, settings) {
if (format == null || value == null)
throw 'Invalid arguments';
value = (typeof value == 'object' ? value.toString() : value + '');
if (value == '')
return null;
var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
var year = -1;
var month = -1;
var day = -1;
var doy = -1;
var literal = false;
// Check whether a format character is doubled
var lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches)
iFormat++;
return matches;
};
// Extract a number from the string value
var getNumber = function(match) {
var isDoubled = lookAhead(match);
var size = (match == '@' ? 14 : (match == '!' ? 20 :
(match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
var digits = new RegExp('^\\d{1,' + size + '}');
var num = value.substring(iValue).match(digits);
if (!num)
throw 'Missing number at position ' + iValue;
iValue += num[0].length;
return parseInt(num[0], 10);
};
// Extract a name from the string value and convert to an index
var getName = function(match, shortNames, longNames) {
var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
return [ [k, v] ];
}).sort(function (a, b) {
return -(a[1].length - b[1].length);
});
var index = -1;
$.each(names, function (i, pair) {
var name = pair[1];
if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
index = pair[0];
iValue += name.length;
return false;
}
});
if (index != -1)
return index + 1;
else
throw 'Unknown name at position ' + iValue;
};
// Confirm that a literal character matches the string value
var checkLiteral = function() {
if (value.charAt(iValue) != format.charAt(iFormat))
throw 'Unexpected literal at position ' + iValue;
iValue++;
};
var iValue = 0;
for (var iFormat = 0; iFormat < format.length; iFormat++) {
if (literal)
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
literal = false;
else
checkLiteral();
else
switch (format.charAt(iFormat)) {
case 'd':
day = getNumber('d');
break;
case 'D':
getName('D', dayNamesShort, dayNames);
break;
case 'o':
doy = getNumber('o');
break;
case 'm':
month = getNumber('m');
break;
case 'M':
month = getName('M', monthNamesShort, monthNames);
break;
case 'y':
year = getNumber('y');
break;
case '@':
var date = new Date(getNumber('@'));
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
break;
case '!':
var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
break;
case "'":
if (lookAhead("'"))
checkLiteral();
else
literal = true;
break;
default:
checkLiteral();
}
}
if (iValue < value.length){
throw "Extra/unparsed characters found in date: " + value.substring(iValue);
}
if (year == -1)
year = new Date().getFullYear();
else if (year < 100)
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
(year <= shortYearCutoff ? 0 : -100);
if (doy > -1) {
month = 1;
day = doy;
do {
var dim = this._getDaysInMonth(year, month - 1);
if (day <= dim)
break;
month++;
day -= dim;
} while (true);
}
var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
throw 'Invalid date'; // E.g. 31/02/00
return date;
},
/* Standard date formats. */
ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
COOKIE: 'D, dd M yy',
ISO_8601: 'yy-mm-dd',
RFC_822: 'D, d M y',
RFC_850: 'DD, dd-M-y',
RFC_1036: 'D, d M y',
RFC_1123: 'D, d M yy',
RFC_2822: 'D, d M yy',
RSS: 'D, d M y', // RFC 822
TICKS: '!',
TIMESTAMP: '@',
W3C: 'yy-mm-dd', // ISO 8601
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
/* Format a date object into a string value.
The format can be combinations of the following:
d - day of month (no leading zero)
dd - day of month (two digit)
o - day of year (no leading zeros)
oo - day of year (three digit)
D - day name short
DD - day name long
m - month of year (no leading zero)
mm - month of year (two digit)
M - month name short
MM - month name long
y - year (two digit)
yy - year (four digit)
@ - Unix timestamp (ms since 01/01/1970)
! - Windows ticks (100ns since 01/01/0001)
'...' - literal text
'' - single quote
@param format string - the desired format of the date
@param date Date - the date value to format
@param settings Object - attributes include:
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
dayNames string[7] - names of the days from Sunday (optional)
monthNamesShort string[12] - abbreviated names of the months (optional)
monthNames string[12] - names of the months (optional)
@return string - the date in the above format */
formatDate: function (format, date, settings) {
if (!date)
return '';
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
// Check whether a format character is doubled
var lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches)
iFormat++;
return matches;
};
// Format a number, with leading zero if necessary
var formatNumber = function(match, value, len) {
var num = '' + value;
if (lookAhead(match))
while (num.length < len)
num = '0' + num;
return num;
};
// Format a name, short or long as requested
var formatName = function(match, value, shortNames, longNames) {
return (lookAhead(match) ? longNames[value] : shortNames[value]);
};
var output = '';
var literal = false;
if (date)
for (var iFormat = 0; iFormat < format.length; iFormat++) {
if (literal)
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
literal = false;
else
output += format.charAt(iFormat);
else
switch (format.charAt(iFormat)) {
case 'd':
output += formatNumber('d', date.getDate(), 2);
break;
case 'D':
output += formatName('D', date.getDay(), dayNamesShort, dayNames);
break;
case 'o':
output += formatNumber('o',
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
break;
case 'm':
output += formatNumber('m', date.getMonth() + 1, 2);
break;
case 'M':
output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
break;
case 'y':
output += (lookAhead('y') ? date.getFullYear() :
(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
break;
case '@':
output += date.getTime();
break;
case '!':
output += date.getTime() * 10000 + this._ticksTo1970;
break;
case "'":
if (lookAhead("'"))
output += "'";
else
literal = true;
break;
default:
output += format.charAt(iFormat);
}
}
return output;
},
/* Extract all possible characters from the date format. */
_possibleChars: function (format) {
var chars = '';
var literal = false;
// Check whether a format character is doubled
var lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
if (matches)
iFormat++;
return matches;
};
for (var iFormat = 0; iFormat < format.length; iFormat++)
if (literal)
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
literal = false;
else
chars += format.charAt(iFormat);
else
switch (format.charAt(iFormat)) {
case 'd': case 'm': case 'y': case '@':
chars += '0123456789';
break;
case 'D': case 'M':
return null; // Accept anything
case "'":
if (lookAhead("'"))
chars += "'";
else
literal = true;
break;
default:
chars += format.charAt(iFormat);
}
return chars;
},
/* Get a setting value, defaulting if necessary. */
_get: function(inst, name) {
return inst.settings[name] !== undefined ?
inst.settings[name] : this._defaults[name];
},
/* Parse existing date and initialise date picker. */
_setDateFromField: function(inst, noDefault) {
if (inst.input.val() == inst.lastVal) {
return;
}
var dateFormat = this._get(inst, 'dateFormat');
var dates = inst.lastVal = inst.input ? inst.input.val() : null;
var date, defaultDate;
date = defaultDate = this._getDefaultDate(inst);
var settings = this._getFormatConfig(inst);
try {
date = this.parseDate(dateFormat, dates, settings) || defaultDate;
} catch (event) {
this.log(event);
dates = (noDefault ? '' : dates);
}
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
inst.currentDay = (dates ? date.getDate() : 0);
inst.currentMonth = (dates ? date.getMonth() : 0);
inst.currentYear = (dates ? date.getFullYear() : 0);
this._adjustInstDate(inst);
},
/* Retrieve the default date shown on opening. */
_getDefaultDate: function(inst) {
return this._restrictMinMax(inst,
this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
},
/* A date may be specified as an exact value or a relative one. */
_determineDate: function(inst, date, defaultDate) {
var offsetNumeric = function(offset) {
var date = new Date();
date.setDate(date.getDate() + offset);
return date;
};
var offsetString = function(offset) {
try {
return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
offset, $.datepicker._getFormatConfig(inst));
}
catch (e) {
// Ignore
}
var date = (offset.toLowerCase().match(/^c/) ?
$.datepicker._getDate(inst) : null) || new Date();
var year = date.getFullYear();
var month = date.getMonth();
var day = date.getDate();
var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
var matches = pattern.exec(offset);
while (matches) {
switch (matches[2] || 'd') {
case 'd' : case 'D' :
day += parseInt(matches[1],10); break;
case 'w' : case 'W' :
day += parseInt(matches[1],10) * 7; break;
case 'm' : case 'M' :
month += parseInt(matches[1],10);
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
break;
case 'y': case 'Y' :
year += parseInt(matches[1],10);
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
break;
}
matches = pattern.exec(offset);
}
return new Date(year, month, day);
};
var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
if (newDate) {
newDate.setHours(0);
newDate.setMinutes(0);
newDate.setSeconds(0);
newDate.setMilliseconds(0);
}
return this._daylightSavingAdjust(newDate);
},
/* Handle switch to/from daylight saving.
Hours may be non-zero on daylight saving cut-over:
> 12 when midnight changeover, but then cannot generate
midnight datetime, so jump to 1AM, otherwise reset.
@param date (Date) the date to check
@return (Date) the corrected date */
_daylightSavingAdjust: function(date) {
if (!date) return null;
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
return date;
},
/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
var clear = !date;
var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear;
var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
inst.selectedDay = inst.currentDay = newDate.getDate();
inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
this._notifyChange(inst);
this._adjustInstDate(inst);
if (inst.input) {
inst.input.val(clear ? '' : this._formatDate(inst));
}
},
/* Retrieve the date(s) directly. */
_getDate: function(inst) {
var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
this._daylightSavingAdjust(new Date(
inst.currentYear, inst.currentMonth, inst.currentDay)));
return startDate;
},
/* Generate the HTML for the current state of the date picker. */
_generateHTML: function(inst) {
var today = new Date();
today = this._daylightSavingAdjust(
new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
var isRTL = this._get(inst, 'isRTL');
var showButtonPanel = this._get(inst, 'showButtonPanel');
var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
var numMonths = this._getNumberOfMonths(inst);
var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
var stepMonths = this._get(inst, 'stepMonths');
var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
var minDate = this._getMinMaxDate(inst, 'min');
var maxDate = this._getMinMaxDate(inst, 'max');
var drawMonth = inst.drawMonth - showCurrentAtPos;
var drawYear = inst.drawYear;
if (drawMonth < 0) {
drawMonth += 12;
drawYear--;
}
if (maxDate) {
var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
drawMonth--;
if (drawMonth < 0) {
drawMonth = 11;
drawYear--;
}
}
}
inst.drawMonth = drawMonth;
inst.drawYear = drawYear;
var prevText = this._get(inst, 'prevText');
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
this._getFormatConfig(inst)));
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
'' + prevText + '' :
(hideIfNoPrevNext ? '' : '' + prevText + ''));
var nextText = this._get(inst, 'nextText');
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
this._getFormatConfig(inst)));
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
'' + nextText + '' :
(hideIfNoPrevNext ? '' : '' + nextText + ''));
var currentText = this._get(inst, 'currentText');
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
currentText = (!navigationAsDateFormat ? currentText :
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
var controls = (!inst.inline ? '' : '');
var buttonPanel = (showButtonPanel) ? '
');
no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html);
};
Chosen.prototype.no_results_clear = function() {
return this.search_results.find(".no-results").remove();
};
Chosen.prototype.keydown_arrow = function() {
var first_active, next_sib;
if (!this.result_highlight) {
first_active = this.search_results.find("li.active-result").first();
if (first_active) this.result_do_highlight($(first_active));
} else if (this.results_showing) {
next_sib = this.result_highlight.nextAll("li.active-result").first();
if (next_sib) this.result_do_highlight(next_sib);
}
if (!this.results_showing) return this.results_show();
};
Chosen.prototype.keyup_arrow = function() {
var prev_sibs;
if (!this.results_showing && !this.is_multiple) {
return this.results_show();
} else if (this.result_highlight) {
prev_sibs = this.result_highlight.prevAll("li.active-result");
if (prev_sibs.length) {
return this.result_do_highlight(prev_sibs.first());
} else {
if (this.choices > 0) this.results_hide();
return this.result_clear_highlight();
}
}
};
Chosen.prototype.keydown_backstroke = function() {
if (this.pending_backstroke) {
this.choice_destroy(this.pending_backstroke.find("a").first());
return this.clear_backstroke();
} else {
this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
return this.pending_backstroke.addClass("search-choice-focus");
}
};
Chosen.prototype.clear_backstroke = function() {
if (this.pending_backstroke) {
this.pending_backstroke.removeClass("search-choice-focus");
}
return this.pending_backstroke = null;
};
Chosen.prototype.keydown_checker = function(evt) {
var stroke, _ref;
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
this.search_field_scale();
if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
switch (stroke) {
case 8:
this.backstroke_length = this.search_field.val().length;
break;
case 9:
if (this.results_showing && !this.is_multiple) this.result_select(evt);
this.mouse_on_container = false;
break;
case 13:
evt.preventDefault();
break;
case 38:
evt.preventDefault();
this.keyup_arrow();
break;
case 40:
this.keydown_arrow();
break;
}
};
Chosen.prototype.search_field_scale = function() {
var dd_top, div, h, style, style_block, styles, w, _i, _len;
if (this.is_multiple) {
h = 0;
w = 0;
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
for (_i = 0, _len = styles.length; _i < _len; _i++) {
style = styles[_i];
style_block += style + ":" + this.search_field.css(style) + ";";
}
div = $('', {
'style': style_block
});
div.text(this.search_field.val());
$('body').append(div);
w = div.width() + 25;
div.remove();
if (w > this.f_width - 10) w = this.f_width - 10;
this.search_field.css({
'width': w + 'px'
});
dd_top = this.container.height();
return this.dropdown.css({
"top": dd_top + "px"
});
}
};
Chosen.prototype.generate_random_id = function() {
var string;
string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
while ($("#" + string).length > 0) {
string += this.generate_random_char();
}
return string;
};
return Chosen;
})(AbstractChosen);
get_side_border_padding = function(elmt) {
var side_border_padding;
return side_border_padding = elmt.outerWidth() - elmt.width();
};
root.get_side_border_padding = get_side_border_padding;
}).call(this);
/*
* AutoSuggest
* Copyright 2009-2010 Drew Wilson
* www.drewwilson.com
* code.drewwilson.com/entry/autosuggest-jquery-plugin
*
* Version 1.4 - Updated: Mar. 23, 2010
*
* This Plug-In will auto-complete or auto-suggest completed search queries
* for you as you type. You can add multiple selections and remove them on
* the fly. It supports keybord navigation (UP + DOWN + RETURN), as well
* as multiple AutoSuggest fields on the same page.
*
* Inspied by the Autocomplete plugin by: J�rn Zaefferer
* and the Facelist plugin by: Ian Tearle (iantearle.com)
*
* This AutoSuggest jQuery plug-in is dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($){
$.fn.autoSuggest = function(data, options) {
var defaults = {
asHtmlID: false,
startText: "Enter Name Here",
emptyText: "No Results Found",
preFill: {},
limitText: "No More Selections Are Allowed",
selectedItemProp: "value", //name of object property
selectedValuesProp: "value", //name of object property
searchObjProps: "value", //comma separated list of object property names
queryParam: "q",
retrieveLimit: false, //number for 'limit' param on ajax request
extraParams: "",
matchCase: false,
minChars: 1,
keyDelay: 400,
resultsHighlight: true,
neverSubmit: false,
selectionLimit: false,
showResultList: true,
start: function(){},
selectionClick: function(elem){},
selectionAdded: function(elem){},
selectionRemoved: function(elem){ elem.remove(); },
formatList: false, //callback function
beforeRetrieve: function(string){ return string; },
retrieveComplete: function(data){ return data; },
resultClick: function(data){},
resultsComplete: function(){}
};
var opts = $.extend(defaults, options);
var d_type = "object";
var d_count = 0;
if(typeof data == "string") {
d_type = "string";
var req_string = data;
} else {
var org_data = data;
for (k in data) if (data.hasOwnProperty(k)) d_count++;
}
if((d_type == "object" && d_count > 0) || d_type == "string"){
return this.each(function(x){
if(!opts.asHtmlID){
x = x+""+Math.floor(Math.random()*100); //this ensures there will be unique IDs on the page if autoSuggest() is called multiple times
var x_id = "as-input-"+x;
} else {
x = opts.asHtmlID;
var x_id = x;
}
opts.start.call(this);
var input = $(this);
input.attr("autocomplete","off").addClass("as-input").attr("id",x_id).val(opts.startText);
var input_focus = false;
// Setup basic elements and render them to the DOM
input.wrap('
').wrap('');
var selections_holder = $("#as-selections-"+x);
var org_li = $("#as-original-"+x);
var results_holder = $('').hide();
var results_ul = $('
');
var values_input = $('');
var prefill_value = "";
if(typeof opts.preFill == "string"){
var vals = opts.preFill.split(",");
for(var i=0; i < vals.length; i++){
var v_data = {};
v_data[opts.selectedValuesProp] = vals[i];
if(vals[i] != ""){
add_selected_item(v_data, "000"+i);
}
}
prefill_value = opts.preFill;
} else {
prefill_value = "";
var prefill_count = 0;
for (k in opts.preFill) if (opts.preFill.hasOwnProperty(k)) prefill_count++;
if(prefill_count > 0){
for(var i=0; i < prefill_count; i++){
var new_v = opts.preFill[i][opts.selectedValuesProp];
if(new_v == undefined){ new_v = ""; }
prefill_value = prefill_value+new_v+",";
if(new_v != ""){
add_selected_item(opts.preFill[i], "000"+i);
}
}
}
}
if(prefill_value != ""){
input.val("");
var lastChar = prefill_value.substring(prefill_value.length-1);
if(lastChar != ","){ prefill_value = prefill_value+","; }
values_input.val(","+prefill_value);
$("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
}
input.after(values_input);
selections_holder.click(function(){
input_focus = true;
input.focus();
}).mousedown(function(){ input_focus = false; }).after(results_holder);
var timeout = null;
var prev = "";
var totalSelections = 0;
var tab_press = false;
// Handle input field events
input.focus(function(){
if($(this).val() == opts.startText && values_input.val() == ""){
$(this).val("");
} else if(input_focus){
$("li.as-selection-item", selections_holder).removeClass("blur");
if($(this).val() != ""){
results_ul.css("width",selections_holder.outerWidth());
results_holder.show();
}
}
input_focus = true;
return true;
}).blur(function(){
if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
$(this).val(opts.startText);
} else if(input_focus){
$("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
results_holder.hide();
}
}).keydown(function(e) {
// track last key pressed
lastKeyPressCode = e.keyCode;
first_focus = false;
switch(e.keyCode) {
case 38: // up
e.preventDefault();
moveSelection("up");
break;
case 40: // down
e.preventDefault();
moveSelection("down");
break;
case 8: // delete
if(input.val() == ""){
var last = values_input.val().split(",");
last = last[last.length - 2];
selections_holder.children().not(org_li.prev()).removeClass("selected");
if(org_li.prev().hasClass("selected")){
values_input.val(values_input.val().replace(","+last+",",","));
opts.selectionRemoved.call(this, org_li.prev());
} else {
opts.selectionClick.call(this, org_li.prev());
org_li.prev().addClass("selected");
}
}
if(input.val().length == 1){
results_holder.hide();
prev = "";
}
if($(":visible",results_holder).length > 0){
if (timeout){ clearTimeout(timeout); }
timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
}
break;
case 9: case 188: // tab or comma
tab_press = true;
var i_input = input.val().replace(/(,)/g, "");
if(i_input != "" && values_input.val().search(","+i_input+",") < 0 && i_input.length >= opts.minChars){
e.preventDefault();
var n_data = {};
n_data[opts.selectedItemProp] = i_input;
n_data[opts.selectedValuesProp] = i_input;
var lis = $("li", selections_holder).length;
add_selected_item(n_data, "00"+(lis+1));
input.val("");
}
case 13: // return
tab_press = false;
var active = $("li.active:first", results_holder);
if(active.length > 0){
active.click();
results_holder.hide();
}
if(opts.neverSubmit || active.length > 0){
e.preventDefault();
}
break;
default:
if(opts.showResultList){
if(opts.selectionLimit && $("li.as-selection-item", selections_holder).length >= opts.selectionLimit){
results_ul.html('
'+opts.limitText+'
');
results_holder.show();
} else {
if (timeout){ clearTimeout(timeout); }
timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
}
}
break;
}
});
function keyChange() {
// ignore if the following keys are pressed: [del] [shift] [capslock]
if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){ return results_holder.hide(); }
var string = input.val().replace(/[\\]+|[\/]+/g,"");
if (string == prev) return;
prev = string;
if (string.length >= opts.minChars) {
selections_holder.addClass("loading");
if(d_type == "string"){
var limit = "";
if(opts.retrieveLimit){
limit = "&limit="+encodeURIComponent(opts.retrieveLimit);
}
if(opts.beforeRetrieve){
string = opts.beforeRetrieve.call(this, string);
}
$.getJSON(req_string+"?"+opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams, function(data){
d_count = 0;
var new_data = opts.retrieveComplete.call(this, data);
for (k in new_data) if (new_data.hasOwnProperty(k)) d_count++;
processData(new_data, string);
});
} else {
if(opts.beforeRetrieve){
string = opts.beforeRetrieve.call(this, string);
}
processData(org_data, string);
}
} else {
selections_holder.removeClass("loading");
results_holder.hide();
}
}
var num_count = 0;
function processData(data, query){
if (!opts.matchCase){ query = query.toLowerCase(); }
var matchCount = 0;
results_holder.html(results_ul.html("")).hide();
for(var i=0;i
');
}
results_ul.css("width", selections_holder.outerWidth());
results_holder.show();
opts.resultsComplete.call(this);
}
function add_selected_item(data, num){
values_input.val(values_input.val()+data[opts.selectedValuesProp]+",");
var item = $('').click(function(){
opts.selectionClick.call(this, $(this));
selections_holder.children().removeClass("selected");
$(this).addClass("selected");
}).mousedown(function(){ input_focus = false; });
var close = $('×').click(function(){
values_input.val(values_input.val().replace(","+data[opts.selectedValuesProp]+",",","));
opts.selectionRemoved.call(this, item);
input_focus = true;
input.focus();
return false;
});
org_li.before(item.html(data[opts.selectedItemProp]).prepend(close));
opts.selectionAdded.call(this, org_li.prev());
}
function moveSelection(direction){
if($(":visible",results_holder).length > 0){
var lis = $("li", results_holder);
if(direction == "down"){
var start = lis.eq(0);
} else {
var start = lis.filter(":last");
}
var active = $("li.active:first", results_holder);
if(active.length > 0){
if(direction == "down"){
start = active.next();
} else {
start = active.prev();
}
}
lis.removeClass("active");
start.addClass("active");
}
}
});
}
}
})(jQuery);
(function($) {
/*
* Auto-growing textareas
*/
$.fn.autogrow = function(options) {
this.filter('textarea').each(function() {
var $this = $(this),
minHeight = $this.height(),
lineHeight = $this.css('lineHeight');
var shadow = $('').css({
position: 'absolute',
top: -10000,
left: -10000,
width: $(this).width() - parseInt($this.css('paddingLeft')) - parseInt($this.css('paddingRight')),
fontSize: $this.css('fontSize'),
fontFamily: $this.css('fontFamily'),
lineHeight: $this.css('lineHeight'),
resize: 'none'
}).appendTo(document.body);
var update = function() {
var times = function(string, number) {
var _res = '';
for(var i = 0; i < number; i ++) {
_res = _res + string;
}
return _res;
};
var val = this.value.replace(//g, '>')
.replace(/&/g, '&')
.replace(/\n$/, ' ')
.replace(/\n/g, ' ')
.replace(/ {2,}/g, function(space) { return times(' ', space.length -1) + ' ' });
shadow.html(val);
$(this).css('height', Math.max(shadow.height() + 20, minHeight));
}
$(this).change(update).keyup(update).keydown(update);
update.apply(this);
});
return this;
}
})(jQuery);
/**
* @summary DataTables
* @description Paginate, search and sort HTML tables
* @version 1.9.0
* @file jquery.dataTables.js
* @author Allan Jardine (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
*
* @copyright Copyright 2008-2012 Allan Jardine, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD style license, available at:
* http://datatables.net/license_gpl2
* http://datatables.net/license_bsd
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details please refer to: http://www.datatables.net
*/
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex*/
(/** @lends */function($, window, document, undefined) {
/**
* DataTables is a plug-in for the jQuery Javascript library. It is a
* highly flexible tool, based upon the foundations of progressive
* enhancement, which will add advanced interaction controls to any
* HTML table. For a full list of features please refer to
* DataTables.net.
*
* Note that the DataTable object is not a global variable but is
* aliased to jQuery.fn.DataTable and jQuery.fn.dataTable through which
* it may be accessed.
*
* @class
* @param {object} [oInit={}] Configuration object for DataTables. Options
* are defined by {@link DataTable.defaults}
* @requires jQuery 1.3+
*
* @example
* // Basic initialisation
* $(document).ready( function {
* $('#example').dataTable();
* } );
*
* @example
* // Initialisation with configuration options - in this case, disable
* // pagination and sorting.
* $(document).ready( function {
* $('#example').dataTable( {
* "bPaginate": false,
* "bSort": false
* } );
* } );
*/
var DataTable = function( oInit )
{
/**
* Add a column to the list used for the table with default values
* @param {object} oSettings dataTables settings object
* @param {node} nTh The th element for this column
* @memberof DataTable#oApi
*/
function _fnAddColumn( oSettings, nTh )
{
var oDefaults = DataTable.defaults.columns;
var iCol = oSettings.aoColumns.length;
var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
"sSortingClass": oSettings.oClasses.sSortable,
"sSortingClassJUI": oSettings.oClasses.sSortJUI,
"nTh": nTh ? nTh : document.createElement('th'),
"sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
"aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
"mDataProp": oDefaults.mDataProp ? oDefaults.oDefaults : iCol
} );
oSettings.aoColumns.push( oCol );
/* Add a column specific filter */
if ( oSettings.aoPreSearchCols[ iCol ] === undefined || oSettings.aoPreSearchCols[ iCol ] === null )
{
oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch );
}
else
{
var oPre = oSettings.aoPreSearchCols[ iCol ];
/* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */
if ( oPre.bRegex === undefined )
{
oPre.bRegex = true;
}
if ( oPre.bSmart === undefined )
{
oPre.bSmart = true;
}
if ( oPre.bCaseInsensitive === undefined )
{
oPre.bCaseInsensitive = true;
}
}
/* Use the column options function to initialise classes etc */
_fnColumnOptions( oSettings, iCol, null );
}
/**
* Apply options for a column
* @param {object} oSettings dataTables settings object
* @param {int} iCol column index to consider
* @param {object} oOptions object with sType, bVisible and bSearchable
* @memberof DataTable#oApi
*/
function _fnColumnOptions( oSettings, iCol, oOptions )
{
var oCol = oSettings.aoColumns[ iCol ];
/* User specified column options */
if ( oOptions !== undefined && oOptions !== null )
{
if ( oOptions.sType !== undefined )
{
oCol.sType = oOptions.sType;
oCol._bAutoType = false;
}
$.extend( oCol, oOptions );
_fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
/* iDataSort to be applied (backwards compatibility), but aDataSort will take
* priority if defined
*/
if ( oOptions.iDataSort !== undefined )
{
oCol.aDataSort = [ oOptions.iDataSort ];
}
_fnMap( oCol, oOptions, "aDataSort" );
}
/* Cache the data get and set functions for speed */
oCol.fnGetData = _fnGetObjectDataFn( oCol.mDataProp );
oCol.fnSetData = _fnSetObjectDataFn( oCol.mDataProp );
/* Feature sorting overrides column specific when off */
if ( !oSettings.oFeatures.bSort )
{
oCol.bSortable = false;
}
/* Check that the class assignment is correct for sorting */
if ( !oCol.bSortable ||
($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
{
oCol.sSortingClass = oSettings.oClasses.sSortableNone;
oCol.sSortingClassJUI = "";
}
else if ( oCol.bSortable ||
($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
{
oCol.sSortingClass = oSettings.oClasses.sSortable;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI;
}
else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 )
{
oCol.sSortingClass = oSettings.oClasses.sSortableAsc;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIAscAllowed;
}
else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) != -1 )
{
oCol.sSortingClass = oSettings.oClasses.sSortableDesc;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIDescAllowed;
}
}
/**
* Adjust the table column widths for new data. Note: you would probably want to
* do a redraw after calling this function!
* @param {object} oSettings dataTables settings object
* @memberof DataTable#oApi
*/
function _fnAdjustColumnSizing ( oSettings )
{
/* Not interested in doing column width calculation if autowidth is disabled */
if ( oSettings.oFeatures.bAutoWidth === false )
{
return false;
}
_fnCalculateColumnWidths( oSettings );
for ( var i=0 , iLen=oSettings.aoColumns.length ; i=0 ; i-- )
{
/* Each definition can target multiple columns, as it is an array */
var aTargets = aoColDefs[i].aTargets;
if ( !$.isArray( aTargets ) )
{
_fnLog( oSettings, 1, 'aTargets must be an array of targets, not a '+(typeof aTargets) );
}
for ( j=0, jLen=aTargets.length ; j= 0 )
{
/* Add columns that we don't yet know about */
while( oSettings.aoColumns.length <= aTargets[j] )
{
_fnAddColumn( oSettings );
}
/* Integer, basic index */
fn( aTargets[j], aoColDefs[i] );
}
else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
{
/* Negative integer, right to left column counting */
fn( oSettings.aoColumns.length+aTargets[j], aoColDefs[i] );
}
else if ( typeof aTargets[j] === 'string' )
{
/* Class name matching on TH element */
for ( k=0, kLen=oSettings.aoColumns.length ; k=0 if successful (index of new aoData entry), -1 if failed
* @memberof DataTable#oApi
*/
function _fnAddData ( oSettings, aDataSupplied )
{
var oCol;
/* Take an independent copy of the data source so we can bash it about as we wish */
var aDataIn = ($.isArray(aDataSupplied)) ?
aDataSupplied.slice() :
$.extend( true, {}, aDataSupplied );
/* Create the object for storing information about this new row */
var iRow = oSettings.aoData.length;
var oData = $.extend( true, {}, DataTable.models.oRow, {
"_aData": aDataIn
} );
oSettings.aoData.push( oData );
/* Create the cells */
var nTd, sThisType;
for ( var i=0, iLen=oSettings.aoColumns.length ; i iTarget )
{
a[i]--;
}
}
if ( iTargetIndex != -1 )
{
a.splice( iTargetIndex, 1 );
}
}
/**
* Call the developer defined fnRender function for a given cell (row/column) with
* the required parameters and return the result.
* @param {object} oSettings dataTables settings object
* @param {int} iRow aoData index for the row
* @param {int} iCol aoColumns index for the column
* @returns {*} Return of the developer's fnRender function
* @memberof DataTable#oApi
*/
function _fnRender( oSettings, iRow, iCol )
{
var oCol = oSettings.aoColumns[iCol];
return oCol.fnRender( {
"iDataRow": iRow,
"iDataColumn": iCol,
"oSettings": oSettings,
"aData": oSettings.aoData[iRow]._aData,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, iCol, 'display') );
}
/**
* Create a new TR element (and it's TD children) for a row
* @param {object} oSettings dataTables settings object
* @param {int} iRow Row to consider
* @memberof DataTable#oApi
*/
function _fnCreateTr ( oSettings, iRow )
{
var oData = oSettings.aoData[iRow];
var nTd;
if ( oData.nTr === null )
{
oData.nTr = document.createElement('tr');
/* Use a private property on the node to allow reserve mapping from the node
* to the aoData array for fast look up
*/
oData.nTr._DT_RowIndex = iRow;
/* Special parameters can be given by the data source to be used on the row */
if ( oData._aData.DT_RowId )
{
oData.nTr.id = oData._aData.DT_RowId;
}
if ( oData._aData.DT_RowClass )
{
$(oData.nTr).addClass( oData._aData.DT_RowClass );
}
/* Process each column */
for ( var i=0, iLen=oSettings.aoColumns.length ; i=0 ; j-- )
{
if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
{
aoLocal[i].splice( j, 1 );
}
}
/* Prep the applied array - it needs an element for each row */
aApplied.push( [] );
}
for ( i=0, iLen=aoLocal.length ; i= oSettings.fnRecordsDisplay()) ?
0 : oSettings.iInitDisplayStart;
}
oSettings.iInitDisplayStart = -1;
_fnCalculateEnd( oSettings );
}
/* Server-side processing draw intercept */
if ( oSettings.bDeferLoading )
{
oSettings.bDeferLoading = false;
oSettings.iDraw++;
}
else if ( !oSettings.oFeatures.bServerSide )
{
oSettings.iDraw++;
}
else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
{
return;
}
if ( oSettings.aiDisplay.length !== 0 )
{
var iStart = oSettings._iDisplayStart;
var iEnd = oSettings._iDisplayEnd;
if ( oSettings.oFeatures.bServerSide )
{
iStart = 0;
iEnd = oSettings.aoData.length;
}
for ( var j=iStart ; j')[0];
oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
/*
* All DataTables are wrapped in a div
*/
oSettings.nTableWrapper = $('')[0];
oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
/* Track where we want to insert the option */
var nInsertNode = oSettings.nTableWrapper;
/* Loop over the user set positioning and place the elements as needed */
var aDom = oSettings.sDom.split('');
var nTmp, iPushFeature, cOption, nNewNode, cNext, sAttr, j;
for ( var i=0 ; i')[0];
/* Check to see if we should append an id and/or a class name to the container */
cNext = aDom[i+1];
if ( cNext == "'" || cNext == '"' )
{
sAttr = "";
j = 2;
while ( aDom[i+j] != cNext )
{
sAttr += aDom[i+j];
j++;
}
/* Replace jQuery UI constants */
if ( sAttr == "H" )
{
sAttr = "fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix";
}
else if ( sAttr == "F" )
{
sAttr = "fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix";
}
/* The attribute can be in the format of "#id.class", "#id" or "class" This logic
* breaks the string into parts and applies them as needed
*/
if ( sAttr.indexOf('.') != -1 )
{
var aSplit = sAttr.split('.');
nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
nNewNode.className = aSplit[1];
}
else if ( sAttr.charAt(0) == "#" )
{
nNewNode.id = sAttr.substr(1, sAttr.length-1);
}
else
{
nNewNode.className = sAttr;
}
i += j; /* Move along the position array */
}
nInsertNode.appendChild( nNewNode );
nInsertNode = nNewNode;
}
else if ( cOption == '>' )
{
/* End container div */
nInsertNode = nInsertNode.parentNode;
}
else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
{
/* Length */
nTmp = _fnFeatureHtmlLength( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
{
/* Filter */
nTmp = _fnFeatureHtmlFilter( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
{
/* pRocessing */
nTmp = _fnFeatureHtmlProcessing( oSettings );
iPushFeature = 1;
}
else if ( cOption == 't' )
{
/* Table */
nTmp = _fnFeatureHtmlTable( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
{
/* Info */
nTmp = _fnFeatureHtmlInfo( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
{
/* Pagination */
nTmp = _fnFeatureHtmlPaginate( oSettings );
iPushFeature = 1;
}
else if ( DataTable.ext.aoFeatures.length !== 0 )
{
/* Plug-in features */
var aoFeatures = DataTable.ext.aoFeatures;
for ( var k=0, kLen=aoFeatures.length ; k') :
sSearchStr==="" ? '' : sSearchStr+' ';
var nFilter = document.createElement( 'div' );
nFilter.className = oSettings.oClasses.sFilter;
nFilter.innerHTML = '';
if ( !oSettings.aanFeatures.f )
{
nFilter.id = oSettings.sTableId+'_filter';
}
var jqFilter = $("input", nFilter);
jqFilter.val( oPreviousSearch.sSearch.replace('"','"') );
jqFilter.bind( 'keyup.DT', function(e) {
/* Update all other filter input elements for the new display */
var n = oSettings.aanFeatures.f;
for ( var i=0, iLen=n.length ; i=0 ; i-- )
{
var sData = _fnDataToSearch( _fnGetCellData( oSettings, oSettings.aiDisplay[i], iColumn, 'filter' ),
oSettings.aoColumns[iColumn].sType );
if ( ! rpSearch.test( sData ) )
{
oSettings.aiDisplay.splice( i, 1 );
iIndexCorrector++;
}
}
}
/**
* Filter the data table based on user input and draw the table
* @param {object} oSettings dataTables settings object
* @param {string} sInput string to filter on
* @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0)
* @param {bool} bRegex treat as a regular expression or not
* @param {bool} bSmart perform smart filtering or not
* @param {bool} bCaseInsensitive Do case insenstive matching or not
* @memberof DataTable#oApi
*/
function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive )
{
var i;
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
var oPrevSearch = oSettings.oPreviousSearch;
/* Check if we are forcing or not - optional parameter */
if ( !iForce )
{
iForce = 0;
}
/* Need to take account of custom filtering functions - always filter */
if ( DataTable.ext.afnFiltering.length !== 0 )
{
iForce = 1;
}
/*
* If the input is blank - we want the full data set
*/
if ( sInput.length <= 0 )
{
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
}
else
{
/*
* We are starting a new search or the new search string is smaller
* then the old one (i.e. delete). Search from the master array
*/
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
oPrevSearch.sSearch.length > sInput.length || iForce == 1 ||
sInput.indexOf(oPrevSearch.sSearch) !== 0 )
{
/* Nuke the old display array - we are going to rebuild it */
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
/* Force a rebuild of the search array */
_fnBuildSearchArray( oSettings, 1 );
/* Search through all records to populate the search array
* The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
* mapping
*/
for ( i=0 ; i tag - remove it */
sSearch = sSearch.replace(/\n/g," ").replace(/\r/g,"");
}
return sSearch;
}
/**
* Build a regular expression object suitable for searching a table
* @param {string} sSearch string to search for
* @param {bool} bRegex treat as a regular expression or not
* @param {bool} bSmart perform smart filtering or not
* @param {bool} bCaseInsensitive Do case insenstive matching or not
* @returns {RegExp} constructed object
* @memberof DataTable#oApi
*/
function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive )
{
var asSearch, sRegExpString;
if ( bSmart )
{
/* Generate the regular expression to use. Something along the lines of:
* ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
*/
asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' );
sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
}
else
{
sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch );
return new RegExp( sSearch, bCaseInsensitive ? "i" : "" );
}
}
/**
* Convert raw data into something that the user can search on
* @param {string} sData data to be modified
* @param {string} sType data type
* @returns {string} search string
* @memberof DataTable#oApi
*/
function _fnDataToSearch ( sData, sType )
{
if ( typeof DataTable.ext.ofnSearch[sType] === "function" )
{
return DataTable.ext.ofnSearch[sType]( sData );
}
else if ( sType == "html" )
{
return sData.replace(/[\r\n]/g," ").replace( /<.*?>/g, "" );
}
else if ( typeof sData === "string" )
{
return sData.replace(/[\r\n]/g," ");
}
else if ( sData === null )
{
return '';
}
return sData;
}
/**
* scape a string stuch that it can be used in a regular expression
* @param {string} sVal string to escape
* @returns {string} escaped string
* @memberof DataTable#oApi
*/
function _fnEscapeRegex ( sVal )
{
var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^' ];
var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
return sVal.replace(reReplace, '\\$1');
}
/**
* Generate the node required for the info display
* @param {object} oSettings dataTables settings object
* @returns {node} Information element
* @memberof DataTable#oApi
*/
function _fnFeatureHtmlInfo ( oSettings )
{
var nInfo = document.createElement( 'div' );
nInfo.className = oSettings.oClasses.sInfo;
/* Actions that are to be taken once only for this feature */
if ( !oSettings.aanFeatures.i )
{
/* Add draw callback */
oSettings.aoDrawCallback.push( {
"fn": _fnUpdateInfo,
"sName": "information"
} );
/* Add id */
nInfo.id = oSettings.sTableId+'_info';
}
oSettings.nTable.setAttribute( 'aria-describedby', oSettings.sTableId+'_info' );
return nInfo;
}
/**
* Update the information elements in the display
* @param {object} oSettings dataTables settings object
* @memberof DataTable#oApi
*/
function _fnUpdateInfo ( oSettings )
{
/* Show information about the table */
if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 )
{
return;
}
var
iStart = oSettings._iDisplayStart+1, iEnd = oSettings.fnDisplayEnd(),
iMax = oSettings.fnRecordsTotal(), iTotal = oSettings.fnRecordsDisplay(),
sStart = oSettings.fnFormatNumber( iStart ), sEnd = oSettings.fnFormatNumber( iEnd ),
sMax = oSettings.fnFormatNumber( iMax ), sTotal = oSettings.fnFormatNumber( iTotal ),
sOut;
/* When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
* internally
*/
if ( oSettings.oScroll.bInfinite )
{
sStart = oSettings.fnFormatNumber( 1 );
}
if ( oSettings.fnRecordsDisplay() === 0 &&
oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
{
/* Empty record set */
sOut = oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix;
}
else if ( oSettings.fnRecordsDisplay() === 0 )
{
/* Rmpty record set after filtering */
sOut = oSettings.oLanguage.sInfoEmpty +' '+
oSettings.oLanguage.sInfoFiltered.replace('_MAX_', sMax)+
oSettings.oLanguage.sInfoPostFix;
}
else if ( oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
{
/* Normal record set */
sOut = oSettings.oLanguage.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_TOTAL_', sTotal)+
oSettings.oLanguage.sInfoPostFix;
}
else
{
/* Record set after filtering */
sOut = oSettings.oLanguage.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_TOTAL_', sTotal) +' '+
oSettings.oLanguage.sInfoFiltered.replace('_MAX_',
oSettings.fnFormatNumber(oSettings.fnRecordsTotal()))+
oSettings.oLanguage.sInfoPostFix;
}
if ( oSettings.oLanguage.fnInfoCallback !== null )
{
sOut = oSettings.oLanguage.fnInfoCallback.call( oSettings.oInstance,
oSettings, iStart, iEnd, iMax, iTotal, sOut );
}
var n = oSettings.aanFeatures.i;
for ( var i=0, iLen=n.length ; i';
var i, iLen;
var aLengthMenu = oSettings.aLengthMenu;
if ( aLengthMenu.length == 2 && typeof aLengthMenu[0] === 'object' &&
typeof aLengthMenu[1] === 'object' )
{
for ( i=0, iLen=aLengthMenu[0].length ; i'+aLengthMenu[1][i]+'';
}
}
else
{
for ( i=0, iLen=aLengthMenu.length ; i'+aLengthMenu[i]+'';
}
}
sStdMenu += '';
var nLength = document.createElement( 'div' );
if ( !oSettings.aanFeatures.l )
{
nLength.id = oSettings.sTableId+'_length';
}
nLength.className = oSettings.oClasses.sLength;
nLength.innerHTML = '';
/*
* Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
* and Stefan Skopnik for fixing the fix!
*/
$('select option[value="'+oSettings._iDisplayLength+'"]', nLength).attr("selected", true);
$('select', nLength).bind( 'change.DT', function(e) {
var iVal = $(this).val();
/* Update all other length options for the new display */
var n = oSettings.aanFeatures.l;
for ( i=0, iLen=n.length ; i oSettings.aiDisplay.length ||
oSettings._iDisplayLength == -1 )
{
oSettings._iDisplayEnd = oSettings.aiDisplay.length;
}
else
{
oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
}
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Note that most of the paging logic is done in
* DataTable.ext.oPagination
*/
/**
* Generate the node required for default pagination
* @param {object} oSettings dataTables settings object
* @returns {node} Pagination feature node
* @memberof DataTable#oApi
*/
function _fnFeatureHtmlPaginate ( oSettings )
{
if ( oSettings.oScroll.bInfinite )
{
return null;
}
var nPaginate = document.createElement( 'div' );
nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType;
DataTable.ext.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate,
function( oSettings ) {
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
);
/* Add a draw callback for the pagination on first instance, to update the paging display */
if ( !oSettings.aanFeatures.p )
{
oSettings.aoDrawCallback.push( {
"fn": function( oSettings ) {
DataTable.ext.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) {
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
} );
},
"sName": "pagination"
} );
}
return nPaginate;
}
/**
* Alter the display settings to change the page
* @param {object} oSettings dataTables settings object
* @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
* or page number to jump to (integer)
* @returns {bool} true page has changed, false - no change (no effect) eg 'first' on page 1
* @memberof DataTable#oApi
*/
function _fnPageChange ( oSettings, mAction )
{
var iOldStart = oSettings._iDisplayStart;
if ( typeof mAction === "number" )
{
oSettings._iDisplayStart = mAction * oSettings._iDisplayLength;
if ( oSettings._iDisplayStart > oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart = 0;
}
}
else if ( mAction == "first" )
{
oSettings._iDisplayStart = 0;
}
else if ( mAction == "previous" )
{
oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ?
oSettings._iDisplayStart - oSettings._iDisplayLength :
0;
/* Correct for underrun */
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
else if ( mAction == "next" )
{
if ( oSettings._iDisplayLength >= 0 )
{
/* Make sure we are not over running the display array */
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart += oSettings._iDisplayLength;
}
}
else
{
oSettings._iDisplayStart = 0;
}
}
else if ( mAction == "last" )
{
if ( oSettings._iDisplayLength >= 0 )
{
var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
}
else
{
oSettings._iDisplayStart = 0;
}
}
else
{
_fnLog( oSettings, 0, "Unknown paging action: "+mAction );
}
$(oSettings.oInstance).trigger('page', oSettings);
return iOldStart != oSettings._iDisplayStart;
}
/**
* Generate the node required for the processing node
* @param {object} oSettings dataTables settings object
* @returns {node} Processing element
* @memberof DataTable#oApi
*/
function _fnFeatureHtmlProcessing ( oSettings )
{
var nProcessing = document.createElement( 'div' );
if ( !oSettings.aanFeatures.r )
{
nProcessing.id = oSettings.sTableId+'_processing';
}
nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
nProcessing.className = oSettings.oClasses.sProcessing;
oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable );
return nProcessing;
}
/**
* Display or hide the processing indicator
* @param {object} oSettings dataTables settings object
* @param {bool} bShow Show the processing indicator (true) or not (false)
* @memberof DataTable#oApi
*/
function _fnProcessingDisplay ( oSettings, bShow )
{
if ( oSettings.oFeatures.bProcessing )
{
var an = oSettings.aanFeatures.r;
for ( var i=0, iLen=an.length ; i
$(oSettings.nTable).height() - oSettings.oScroll.iLoadGap )
{
/* Only do the redraw if we have to - we might be at the end of the data */
if ( oSettings.fnDisplayEnd() < oSettings.fnRecordsDisplay() )
{
_fnPageChange( oSettings, 'next' );
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
}
}
} );
}
oSettings.nScrollHead = nScrollHead;
oSettings.nScrollFoot = nScrollFoot;
return nScroller;
}
/**
* Update the various tables for resizing. It's a bit of a pig this function, but
* basically the idea to:
* 1. Re-create the table inside the scrolling div
* 2. Take live measurements from the DOM
* 3. Apply the measurements
* 4. Clean up
* @param {object} o dataTables settings object
* @returns {node} Node to add to the DOM
* @memberof DataTable#oApi
*/
function _fnScrollDraw ( o )
{
var
nScrollHeadInner = o.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = o.nTable.parentNode,
i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis,
iWidth, aApplied=[], iSanityWidth,
nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null,
nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null,
ie67 = $.browser.msie && $.browser.version <= 7;
/*
* 1. Re-create the table inside the scrolling div
*/
/* Remove the old minimised thead and tfoot elements in the inner table */
var nTheadSize = o.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
o.nTable.removeChild( nTheadSize[0] );
}
var nTfootSize;
if ( o.nTFoot !== null )
{
/* Remove the old minimised footer element in the cloned header */
nTfootSize = o.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
o.nTable.removeChild( nTfootSize[0] );
}
}
/* Clone the current header and footer elements and then place it into the inner table */
nTheadSize = o.nTHead.cloneNode(true);
o.nTable.insertBefore( nTheadSize, o.nTable.childNodes[0] );
if ( o.nTFoot !== null )
{
nTfootSize = o.nTFoot.cloneNode(true);
o.nTable.insertBefore( nTfootSize, o.nTable.childNodes[1] );
}
/*
* 2. Take live measurements from the DOM - do not alter the DOM itself!
*/
/* Remove old sizing and apply the calculated column widths
* Get the unique column headers in the newly created (cloned) header. We want to apply the
* calclated sizes to this header
*/
if ( o.oScroll.sX === "" )
{
nScrollBody.style.width = '100%';
nScrollHeadInner.parentNode.style.width = '100%';
}
var nThs = _fnGetUniqueThs( o, nTheadSize );
for ( i=0, iLen=nThs.length ; i nScrollBody.offsetHeight ||
$(nScrollBody).css('overflow-y') == "scroll") )
{
o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth()-o.oScroll.iBarWidth );
}
}
else
{
if ( o.oScroll.sXInner !== "" )
{
/* x scroll inner has been given - use it */
o.nTable.style.width = _fnStringToCss(o.oScroll.sXInner);
}
else if ( iSanityWidth == $(nScrollBody).width() &&
$(nScrollBody).height() < $(o.nTable).height() )
{
/* There is y-scrolling - try to take account of the y scroll bar */
o.nTable.style.width = _fnStringToCss( iSanityWidth-o.oScroll.iBarWidth );
if ( $(o.nTable).outerWidth() > iSanityWidth-o.oScroll.iBarWidth )
{
/* Not possible to take account of it */
o.nTable.style.width = _fnStringToCss( iSanityWidth );
}
}
else
{
/* All else fails */
o.nTable.style.width = _fnStringToCss( iSanityWidth );
}
}
/* Recalculate the sanity width - now that we've applied the required width, before it was
* a temporary variable. This is required because the column width calculation is done
* before this table DOM is created.
*/
iSanityWidth = $(o.nTable).outerWidth();
/* We want the hidden header to have zero height, so remove padding and borders. Then
* set the width based on the real headers
*/
anHeadToSize = o.nTHead.getElementsByTagName('tr');
anHeadSizers = nTheadSize.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anHeadSizers, anHeadToSize );
$(anHeadSizers).height(0);
if ( o.nTFoot !== null )
{
/* Clone the current footer and then place it into the body table as a "hidden header" */
anFootSizers = nTfootSize.getElementsByTagName('tr');
anFootToSize = o.nTFoot.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anFootSizers, anFootToSize );
$(anFootSizers).height(0);
}
/*
* 3. Apply the measurements
*/
/* "Hide" the header and footer that we used for the sizing. We want to also fix their width
* to what they currently are
*/
_fnApplyToChildren( function(nSizer) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
}, anHeadSizers );
if ( o.nTFoot !== null )
{
_fnApplyToChildren( function(nSizer) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
}, anFootSizers );
}
/* Sanity check that the table is of a sensible width. If not then we are going to get
* misalignment - try to prevent this by not allowing the table to shrink below its min width
*/
if ( $(o.nTable).outerWidth() < iSanityWidth )
{
/* The min width depends upon if we have a vertical scrollbar visible or not */
var iCorrection = ((nScrollBody.scrollHeight > nScrollBody.offsetHeight ||
$(nScrollBody).css('overflow-y') == "scroll")) ?
iSanityWidth+o.oScroll.iBarWidth : iSanityWidth;
/* IE6/7 are a law unto themselves... */
if ( ie67 && (nScrollBody.scrollHeight >
nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") )
{
o.nTable.style.width = _fnStringToCss( iCorrection-o.oScroll.iBarWidth );
}
/* Apply the calculated minimum width to the table wrappers */
nScrollBody.style.width = _fnStringToCss( iCorrection );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( iCorrection );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( iCorrection );
}
/* And give the user a warning that we've stopped the table getting too small */
if ( o.oScroll.sX === "" )
{
_fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
" misalignment. The table has been drawn at its minimum possible width." );
}
else if ( o.oScroll.sXInner !== "" )
{
_fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
" misalignment. Increase the sScrollXInner value or remove it to allow automatic"+
" calculation" );
}
}
else
{
nScrollBody.style.width = _fnStringToCss( '100%' );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( '100%' );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( '100%' );
}
}
/*
* 4. Clean up
*/
if ( o.oScroll.sY === "" )
{
/* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
* the scrollbar height from the visible display, rather than adding it on. We need to
* set the height in order to sort this. Don't want to do it in any other browsers.
*/
if ( ie67 )
{
nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+o.oScroll.iBarWidth );
}
}
if ( o.oScroll.sY !== "" && o.oScroll.bCollapse )
{
nScrollBody.style.height = _fnStringToCss( o.oScroll.sY );
var iExtra = (o.oScroll.sX !== "" && o.nTable.offsetWidth > nScrollBody.offsetWidth) ?
o.oScroll.iBarWidth : 0;
if ( o.nTable.offsetHeight < nScrollBody.offsetHeight )
{
nScrollBody.style.height = _fnStringToCss( $(o.nTable).height()+iExtra );
}
}
/* Finally set the width's of the header and footer tables */
var iOuterWidth = $(o.nTable).outerWidth();
nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth );
nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth );
if ( o.nTFoot !== null )
{
nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth );
nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth );
}
/* If sorting or filtering has occurred, jump the scrolling back to the top */
if ( o.bSorted || o.bFiltered )
{
nScrollBody.scrollTop = 0;
}
}
/**
* Apply a given function to the display child nodes of an element array (typically
* TD children of TR rows
* @param {function} fn Method to apply to the objects
* @param array {nodes} an1 List of elements to look through for display children
* @param array {nodes} an2 Another list (identical structure to the first) - optional
* @memberof DataTable#oApi
*/
function _fnApplyToChildren( fn, an1, an2 )
{
for ( var i=0, iLen=an1.length ; itd', nCalcTmp);
}
/* Apply custom sizing to the cloned header */
var nThs = _fnGetUniqueThs( oSettings, nTheadClone );
iCorrector = 0;
for ( i=0 ; i 0 )
{
oSettings.aoColumns[i].sWidth = _fnStringToCss( iWidth );
}
iCorrector++;
}
}
var cssWidth = $(nCalcTmp).css('width');
oSettings.nTable.style.width = (cssWidth.indexOf('%') !== -1) ?
cssWidth : _fnStringToCss( $(nCalcTmp).outerWidth() );
nCalcTmp.parentNode.removeChild( nCalcTmp );
}
if ( widthAttr )
{
oSettings.nTable.style.width = _fnStringToCss( widthAttr );
}
}
/**
* Adjust a table's width to take account of scrolling
* @param {object} oSettings dataTables settings object
* @param {node} n table node
* @memberof DataTable#oApi
*/
function _fnScrollingWidthAdjust ( oSettings, n )
{
if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" )
{
/* When y-scrolling only, we want to remove the width of the scroll bar so the table
* + scroll bar will fit into the area avaialble.
*/
var iOrigWidth = $(n).width();
n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth );
}
else if ( oSettings.oScroll.sX !== "" )
{
/* When x-scrolling both ways, fix the table at it's current size, without adjusting */
n.style.width = _fnStringToCss( $(n).outerWidth() );
}
}
/**
* Get the widest node
* @param {object} oSettings dataTables settings object
* @param {int} iCol column of interest
* @returns {string} max strlens for each column
* @memberof DataTable#oApi
*/
function _fnGetWidestNode( oSettings, iCol )
{
var iMaxIndex = _fnGetMaxLenString( oSettings, iCol );
if ( iMaxIndex < 0 )
{
return null;
}
if ( oSettings.aoData[iMaxIndex].nTr === null )
{
var n = document.createElement('td');
n.innerHTML = _fnGetCellData( oSettings, iMaxIndex, iCol, '' );
return n;
}
return _fnGetTdNodes(oSettings, iMaxIndex)[iCol];
}
/**
* Get the maximum strlen for each data column
* @param {object} oSettings dataTables settings object
* @param {int} iCol column of interest
* @returns {string} max strlens for each column
* @memberof DataTable#oApi
*/
function _fnGetMaxLenString( oSettings, iCol )
{
var iMax = -1;
var iMaxIndex = -1;
for ( var i=0 ; i/g, "" );
if ( s.length > iMax )
{
iMax = s.length;
iMaxIndex = i;
}
}
return iMaxIndex;
}
/**
* Append a CSS unit (only if required) to a string
* @param {array} aArray1 first array
* @param {array} aArray2 second array
* @returns {int} 0 if match, 1 if length is different, 2 if no match
* @memberof DataTable#oApi
*/
function _fnStringToCss( s )
{
if ( s === null )
{
return "0px";
}
if ( typeof s == 'number' )
{
if ( s < 0 )
{
return "0px";
}
return s+"px";
}
/* Check if the last character is not 0-9 */
var c = s.charCodeAt( s.length-1 );
if (c < 0x30 || c > 0x39)
{
return s;
}
return s+"px";
}
/**
* Get the width of a scroll bar in this browser being used
* @returns {int} width in pixels
* @memberof DataTable#oApi
*/
function _fnScrollBarWidth ()
{
var inner = document.createElement('p');
var style = inner.style;
style.width = "100%";
style.height = "200px";
style.padding = "0px";
var outer = document.createElement('div');
style = outer.style;
style.position = "absolute";
style.top = "0px";
style.left = "0px";
style.visibility = "hidden";
style.width = "200px";
style.height = "150px";
style.padding = "0px";
style.overflow = "hidden";
outer.appendChild(inner);
document.body.appendChild(outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if ( w1 == w2 )
{
w2 = outer.clientWidth;
}
document.body.removeChild(outer);
return (w1 - w2);
}
/**
* Change the order of the table
* @param {object} oSettings dataTables settings object
* @param {bool} bApplyClasses optional - should we apply classes or not
* @memberof DataTable#oApi
*/
function _fnSort ( oSettings, bApplyClasses )
{
var
i, iLen, j, jLen, k, kLen,
sDataType, nTh,
aaSort = [],
aiOrig = [],
oSort = DataTable.ext.oSort,
aoData = oSettings.aoData,
aoColumns = oSettings.aoColumns,
oAria = oSettings.oLanguage.oAria;
/* No sorting required if server-side or no sorting array */
if ( !oSettings.oFeatures.bServerSide &&
(oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
{
if ( oSettings.aaSortingFixed !== null )
{
aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
}
else
{
aaSort = oSettings.aaSorting.slice();
}
/* If there is a sorting data type, and a fuction belonging to it, then we need to
* get the data from the developer's function and apply it for this column
*/
for ( i=0 ; i 0 && aaSort[0][0] == i )
{
nTh.setAttribute('aria-sort', aaSort[0][1]=="asc" ? "ascending" : "descending" );
var nextSort = (aoColumns[i].asSorting[ aaSort[0][2]+1 ]) ?
aoColumns[i].asSorting[ aaSort[0][2]+1 ] : aoColumns[i].asSorting[0];
nTh.setAttribute('aria-label', aoColumns[i].sTitle+
(nextSort=="asc" ? oAria.sSortAscending : oAria.sSortDescending) );
}
else
{
nTh.setAttribute('aria-label', aoColumns[i].sTitle+
(aoColumns[i].asSorting[0]=="asc" ? oAria.sSortAscending : oAria.sSortDescending) );
}
}
else
{
nTh.setAttribute('aria-label', aoColumns[i].sTitle);
}
}
/* Tell the draw function that we have sorted the data */
oSettings.bSorted = true;
$(oSettings.oInstance).trigger('sort', oSettings);
/* Copy the master data into the draw array and re-draw */
if ( oSettings.oFeatures.bFilter )
{
/* _fnFilter() will redraw the table for us */
_fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
}
else
{
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
oSettings._iDisplayStart = 0; /* reset display back to page 0 */
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
}
/**
* Attach a sort handler (click) to a node
* @param {object} oSettings dataTables settings object
* @param {node} nNode node to attach the handler to
* @param {int} iDataIndex column sorting index
* @param {function} [fnCallback] callback function
* @memberof DataTable#oApi
*/
function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
{
_fnBindAction( nNode, {}, function (e) {
/* If the column is not sortable - don't to anything */
if ( oSettings.aoColumns[iDataIndex].bSortable === false )
{
return;
}
/*
* This is a little bit odd I admit... I declare a temporary function inside the scope of
* _fnBuildHead and the click handler in order that the code presented here can be used
* twice - once for when bProcessing is enabled, and another time for when it is
* disabled, as we need to perform slightly different actions.
* Basically the issue here is that the Javascript engine in modern browsers don't
* appear to allow the rendering engine to update the display while it is still excuting
* it's thread (well - it does but only after long intervals). This means that the
* 'processing' display doesn't appear for a table sort. To break the js thread up a bit
* I force an execution break by using setTimeout - but this breaks the expected
* thread continuation for the end-developer's point of view (their code would execute
* too early), so we on;y do it when we absolutely have to.
*/
var fnInnerSorting = function () {
var iColumn, iNextSort;
/* If the shift key is pressed then we are multipe column sorting */
if ( e.shiftKey )
{
/* Are we already doing some kind of sort on this column? */
var bFound = false;
for ( var i=0 ; i= iColumns )
{
for ( i=0 ; i 4096 ) /* Magic 10 for padding */
{
var aCookies =document.cookie.split(';');
for ( var i=0, iLen=aCookies.length ; i=0 ; i-- )
{
aRet.push( aoStore[i].fn.apply( oSettings.oInstance, aArgs ) );
}
if ( sTrigger !== null )
{
$(oSettings.oInstance).trigger(sTrigger, aArgs);
}
return aRet;
}
/**
* JSON stringify. If JSON.stringify it provided by the browser, json2.js or any other
* library, then we use that as it is fast, safe and accurate. If the function isn't
* available then we need to built it ourselves - the insperation for this function comes
* from Craig Buckler ( http://www.sitepoint.com/javascript-json-serialization/ ). It is
* not perfect and absolutely should not be used as a replacement to json2.js - but it does
* do what we need, without requiring a dependency for DataTables.
* @param {object} o JSON object to be converted
* @returns {string} JSON string
* @memberof DataTable#oApi
*/
var _fnJsonString = (window.JSON) ? JSON.stringify : function( o )
{
/* Not an object or array */
var sType = typeof o;
if (sType !== "object" || o === null)
{
// simple data type
if (sType === "string")
{
o = '"'+o+'"';
}
return o+"";
}
/* If object or array, need to recurse over it */
var
sProp, mValue,
json = [],
bArr = $.isArray(o);
for (sProp in o)
{
mValue = o[sProp];
sType = typeof mValue;
if (sType === "string")
{
mValue = '"'+mValue+'"';
}
else if (sType === "object" && mValue !== null)
{
mValue = _fnJsonString(mValue);
}
json.push((bArr ? "" : '"'+sProp+'":') + mValue);
}
return (bArr ? "[" : "{") + json + (bArr ? "]" : "}");
};
/**
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
* return the resulting jQuery object.
* @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
* @param {object} [oOpts] Optional parameters for modifying the rows to be included
* @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
* criterion ("applied") or all TR elements (i.e. no filter).
* @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
* Can be either 'current', whereby the current sorting of the table is used, or
* 'original' whereby the original order the data was read into the table is used.
* @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
* ("current") or not ("all"). If 'current' is given, then order is assumed to be
* 'current' and filter is 'applied', regardless of what they might be given as.
* @returns {object} jQuery object, filtered by the given selector.
* @dtopt API
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable();
*
* // Highlight every second row
* oTable.$('tr:odd').css('backgroundColor', 'blue');
* } );
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable();
*
* // Filter to rows with 'Webkit' in them, add a background colour and then
* // remove the filter, thus highlighting the 'Webkit' rows only.
* oTable.fnFilter('Webkit');
* oTable.$('tr', {"filter": "applied"}).css('backgroundColor', 'blue');
* oTable.fnFilter('');
* } );
*/
this.$ = function ( sSelector, oOpts )
{
var i, iLen, a = [];
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
if ( !oOpts )
{
oOpts = {};
}
oOpts = $.extend( {}, {
"filter": "none", // applied
"order": "current", // "original"
"page": "all" // current
}, oOpts );
// Current page implies that order=current and fitler=applied, since it is fairly
// senseless otherwise
if ( oOpts.page == 'current' )
{
for ( i=oSettings._iDisplayStart, iLen=oSettings.fnDisplayEnd() ; i
*
1D array of data - add a single row with the data provided
*
2D array of arrays - add multiple rows in a single call
*
object - data object when using mDataProp
*
array of objects - multiple data objects when using mDataProp
*
* @param {bool} [bRedraw=true] redraw the table or not
* @returns {array} An array of integers, representing the list of indexes in
* aoData ({@link DataTable.models.oSettings}) that have been added to
* the table.
* @dtopt API
*
* @example
* // Global var for counter
* var giCount = 2;
*
* $(document).ready(function() {
* $('#example').dataTable();
* } );
*
* function fnClickAddRow() {
* $('#example').dataTable().fnAddData( [
* giCount+".1",
* giCount+".2",
* giCount+".3",
* giCount+".4" ]
* );
*
* giCount++;
* }
*/
this.fnAddData = function( mData, bRedraw )
{
if ( mData.length === 0 )
{
return [];
}
var aiReturn = [];
var iTest;
/* Find settings from table node */
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
/* Check if we want to add multiple rows or not */
if ( typeof mData[0] === "object" && mData[0] !== null )
{
for ( var i=0 ; i= oSettings.aiDisplay.length )
{
oSettings._iDisplayStart -= oSettings._iDisplayLength;
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
if ( bRedraw === undefined || bRedraw )
{
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
return oData;
};
/**
* Restore the table to it's original state in the DOM by removing all of DataTables
* enhancements, alterations to the DOM structure of the table and event listeners.
* @param {boolean} [bRemove=false] Completely remove the table from the DOM
* @dtopt API
*
* @example
* $(document).ready(function() {
* // This example is fairly pointless in reality, but shows how fnDestroy can be used
* var oTable = $('#example').dataTable();
* oTable.fnDestroy();
* } );
*/
this.fnDestroy = function ( bRemove )
{
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
var nOrig = oSettings.nTableWrapper.parentNode;
var nBody = oSettings.nTBody;
var i, iLen;
bRemove = (bRemove===undefined) ? false : true;
/* Flag to note that the table is currently being destroyed - no action should be taken */
oSettings.bDestroying = true;
/* Restore hidden columns */
for ( i=0, iLen=oSettings.aoDestroyCallback.length ; itr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove();
/* When scrolling we had to break the table up - restore it */
if ( oSettings.nTable != oSettings.nTHead.parentNode )
{
$(oSettings.nTable).children('thead').remove();
oSettings.nTable.appendChild( oSettings.nTHead );
}
if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode )
{
$(oSettings.nTable).children('tfoot').remove();
oSettings.nTable.appendChild( oSettings.nTFoot );
}
/* Remove the DataTables generated nodes, events and classes */
oSettings.nTable.parentNode.removeChild( oSettings.nTable );
$(oSettings.nTableWrapper).remove();
oSettings.aaSorting = [];
oSettings.aaSortingFixed = [];
_fnSortingClasses( oSettings );
$(_fnGetTrNodes( oSettings )).removeClass( oSettings.asStripeClasses.join(' ') );
$('th, td', oSettings.nTHead).removeClass( [
oSettings.oClasses.sSortable,
oSettings.oClasses.sSortableAsc,
oSettings.oClasses.sSortableDesc,
oSettings.oClasses.sSortableNone ].join(' ')
);
if ( oSettings.bJUI )
{
$('th span.'+oSettings.oClasses.sSortIcon
+ ', td span.'+oSettings.oClasses.sSortIcon, oSettings.nTHead).remove();
$('th, td', oSettings.nTHead).each( function () {
var jqWrapper = $('div.'+oSettings.oClasses.sSortJUIWrapper, this);
var kids = jqWrapper.contents();
$(this).append( kids );
jqWrapper.remove();
} );
}
/* Add the TR elements back into the table in their original order */
if ( !bRemove && oSettings.nTableReinsertBefore )
{
nOrig.insertBefore( oSettings.nTable, oSettings.nTableReinsertBefore );
}
else if ( !bRemove )
{
nOrig.appendChild( oSettings.nTable );
}
for ( i=0, iLen=oSettings.aoData.length ; i= _fnVisbleColumns( oSettings ));
/* Which coloumn should we be inserting before? */
if ( !bAppend )
{
for ( i=iCol ; i= oSettings.aoColumns.length )
{
oSettings.aaSorting[i][0] = 0;
}
var oColumn = oSettings.aoColumns[ oSettings.aaSorting[i][0] ];
/* Add a default sorting index */
if ( oSettings.aaSorting[i][2] === undefined )
{
oSettings.aaSorting[i][2] = 0;
}
/* If aaSorting is not defined, then we use the first indicator in asSorting */
if ( oInit.aaSorting === undefined && oSettings.saved_aaSorting === undefined )
{
oSettings.aaSorting[i][1] = oColumn.asSorting[0];
}
/* Set the current sorting index based on aoColumns.asSorting */
for ( j=0, jLen=oColumn.asSorting.length ; j 0 )
{
oSettings.nTFoot = tfoot[0];
_fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
}
/* Check if there is data passing into the constructor */
if ( bUsePassedData )
{
for ( i=0 ; iDataTable.settings object is aliased to jQuery.fn.dataTableExt
* through which it may be accessed and manipulated, or jQuery.fn.dataTable.settings.
* @member
* @type array
* @default []
* @private
*/
DataTable.settings = [];
/**
* Object models container, for the various models that DataTables has available
* to it. These models define the objects that are used to hold the active state
* and configuration of the table.
* @namespace
*/
DataTable.models = {};
/**
* DataTables extension options and plug-ins. This namespace acts as a collection "area"
* for plug-ins that can be used to extend the default DataTables behaviour - indeed many
* of the build in methods use this method to provide their own capabilities (sorting methods
* for example).
*
* Note that this namespace is aliased to jQuery.fn.dataTableExt so it can be readily accessed
* and modified by plug-ins.
* @namespace
*/
DataTable.models.ext = {
/**
* Plug-in filtering functions - this method of filtering is complimentary to the default
* type based filtering, and a lot more comprehensive as it allows you complete control
* over the filtering logic. Each element in this array is a function (parameters
* described below) that is called for every row in the table, and your logic decides if
* it should be included in the filtered data set or not.
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{array|object} Data for the row to be processed (same as the original format
* that was passed in as the data source, or an array from a DOM data source
*
{int} Row index in aoData ({@link DataTable.models.oSettings.aoData}), which can
* be useful to retrieve the TR element if you need DOM interaction.
*
*
*
* Function return:
*
*
{boolean} Include the row in the filtered result set (true) or not (false)
*
*
*
* @type array
* @default []
*
* @example
* // The following example shows custom filtering being applied to the fourth column (i.e.
* // the aData[3] index) based on two input values from the end-user, matching the data in
* // a certain range.
* $.fn.dataTableExt.afnFiltering.push(
* function( oSettings, aData, iDataIndex ) {
* var iMin = document.getElementById('min').value * 1;
* var iMax = document.getElementById('max').value * 1;
* var iVersion = aData[3] == "-" ? 0 : aData[3]*1;
* if ( iMin == "" && iMax == "" ) {
* return true;
* }
* else if ( iMin == "" && iVersion < iMax ) {
* return true;
* }
* else if ( iMin < iVersion && "" == iMax ) {
* return true;
* }
* else if ( iMin < iVersion && iVersion < iMax ) {
* return true;
* }
* return false;
* }
* );
*/
"afnFiltering": [],
/**
* Plug-in sorting functions - this method of sorting is complimentary to the default type
* based sorting that DataTables does automatically, allowing much greater control over the
* the data that is being used to sort a column. This is useful if you want to do sorting
* based on live data (for example the contents of an 'input' element) rather than just the
* static string that DataTables knows of. The way these plug-ins work is that you create
* an array of the values you wish to be sorted for the column in question and then return
* that array. Which pre-sorting function is run here depends on the sSortDataType parameter
* that is used for the column (if any). This is the corollary of ofnSearch for sort
* data.
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{int} Target column index
*
*
*
* Function return:
*
*
{array} Data for the column to be sorted upon
*
*
*
*
* Note that as of v1.9, it is typically preferable to use mDataProp to prepare data for
* the different uses that DataTables can put the data to. Specifically mDataProp when
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
* prepare the data as required for the different types. As such, this method is deprecated.
* @type array
* @default []
* @deprecated
*
* @example
* // Updating the cached sorting information with user entered values in HTML input elements
* jQuery.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
* {
* var aData = [];
* $( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
* aData.push( this.value );
* } );
* return aData;
* }
*/
"afnSortData": [],
/**
* Feature plug-ins - This is an array of objects which describe the feature plug-ins that are
* available to DataTables. These feature plug-ins are accessible through the sDom initialisation
* option. As such, each feature plug-in must describe a function that is used to initialise
* itself (fnInit), a character so the feature can be enabled by sDom (cFeature) and the name
* of the feature (sFeature). Thus the objects attached to this method must provide:
*
*
{function} fnInit Initialisation of the plug-in
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
*
*
* Function return:
*
*
{node|null} The element which contains your feature. Note that the return
* may also be void if your plug-in does not require to inject any DOM elements
* into DataTables control (sDom) - for example this might be useful when
* developing a plug-in which allows table control via keyboard entry.
*
*
*
*
*
{character} cFeature Character that will be matched in sDom - case sensitive
*
{string} sFeature Feature name
*
* @type array
* @default []
*
* @example
* // How TableTools initialises itself.
* $.fn.dataTableExt.aoFeatures.push( {
* "fnInit": function( oSettings ) {
* return new TableTools( { "oDTSettings": oSettings } );
* },
* "cFeature": "T",
* "sFeature": "TableTools"
* } );
*/
"aoFeatures": [],
/**
* Type detection plug-in functions - DataTables utilises types to define how sorting and
* filtering behave, and types can be either be defined by the developer (sType for the
* column) or they can be automatically detected by the methods in this array. The functions
* defined in the array are quite simple, taking a single parameter (the data to analyse)
* and returning the type if it is a known type, or null otherwise.
*
*
* Function input parameters:
*
*
{*} Data from the column cell to be analysed
*
*
*
* Function return:
*
*
{string|null} Data type detected, or null if unknown (and thus pass it
* on to the other type detection functions.
*
*
*
* @type array
* @default []
*
* @example
* // Currency type detection plug-in:
* jQuery.fn.dataTableExt.aTypes.push(
* function ( sData ) {
* var sValidChars = "0123456789.-";
* var Char;
*
* // Check the numeric part
* for ( i=1 ; i= parseInt(sThat, 10);
},
/**
* Index for what 'this' index API functions should use
* @type int
* @default 0
*/
"iApiIndex": 0,
/**
* Pre-processing of filtering data plug-ins - When you assign the sType for a column
* (or have it automatically detected for you by DataTables or a type detection plug-in),
* you will typically be using this for custom sorting, but it can also be used to provide
* custom filtering by allowing you to pre-processing the data and returning the data in
* the format that should be filtered upon. This is done by adding functions this object
* with a parameter name which matches the sType for that target column. This is the
* corollary of afnSortData for filtering data.
*
*
* Function input parameters:
*
*
{*} Data from the column cell to be prepared for filtering
*
*
*
* Function return:
*
*
{string|null} Formatted string that will be used for the filtering.
*
*
*
*
* Note that as of v1.9, it is typically preferable to use mDataProp to prepare data for
* the different uses that DataTables can put the data to. Specifically mDataProp when
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
* prepare the data as required for the different types. As such, this method is deprecated.
* @type object
* @default {}
* @deprecated
*
* @example
* $.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
* return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
* }
*/
"ofnSearch": {},
/**
* Container for all private functions in DataTables so they can be exposed externally
* @type object
* @default {}
*/
"oApi": {},
/**
* Storage for the various classes that DataTables uses
* @type object
* @default {}
*/
"oStdClasses": {},
/**
* Storage for the various classes that DataTables uses - jQuery UI suitable
* @type object
* @default {}
*/
"oJUIClasses": {},
/**
* Pagination plug-in methods - The style and controls of the pagination can significantly
* impact on how the end user interacts with the data in your table, and DataTables allows
* the addition of pagination controls by extending this object, which can then be enabled
* through the sPaginationType initialisation parameter. Each pagination type that
* is added is an object (the property name of which is what sPaginationType refers
* to) that has two properties, both methods that are used by DataTables to update the
* control's state.
*
*
* fnInit - Initialisation of the paging controls. Called only during initialisation
* of the table. It is expected that this function will add the required DOM elements
* to the page for the paging controls to work. The element pointer
* 'oSettings.aanFeatures.p' array is provided by DataTables to contain the paging
* controls (note that this is a 2D array to allow for multiple instances of each
* DataTables DOM element). It is suggested that you add the controls to this element
* as children
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{node} Container into which the pagination controls must be inserted
*
{function} Draw callback function - whenever the controls cause a page
* change, this method must be called to redraw the table.
*
*
*
* Function return:
*
*
No return required
*
*
*
*
*
* fnInit - This function is called whenever the paging status of the table changes and is
* typically used to update classes and/or text of the paging controls to reflex the new
* status.
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{function} Draw callback function - in case you need to redraw the table again
* or attach new event listeners
{int} Sorting match: <0 if first parameter should be sorted lower than
* the second parameter, ===0 if the two parameters are equal and >0 if
* the first parameter should be sorted height than the second parameter.
*
*
*
* @type object
* @default {}
*
* @example
* // Case-sensitive string sorting, with no pre-formatting method
* $.extend( $.fn.dataTableExt.oSort, {
* "string-case-asc": function(x,y) {
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
* },
* "string-case-desc": function(x,y) {
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
* }
* } );
*
* @example
* // Case-insensitive string sorting, with pre-formatting
* $.extend( $.fn.dataTableExt.oSort, {
* "string-pre": function(x) {
* return x.toLowerCase();
* },
* "string-asc": function(x,y) {
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
* },
* "string-desc": function(x,y) {
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
* }
* } );
*/
"oSort": {},
/**
* Version string for plug-ins to check compatibility. Allowed format is
* a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
* e are optional
* @type string
* @default Version number
*/
"sVersion": DataTable.version,
/**
* How should DataTables report an error. Can take the value 'alert' or 'throw'
* @type string
* @default alert
*/
"sErrMode": "alert",
/**
* Store information for DataTables to access globally about other instances
* @namespace
* @private
*/
"_oExternConfig": {
/* int:iNextUnique - next unique number for an instance */
"iNextUnique": 0
}
};
/**
* Template object for the way in which DataTables holds information about
* search information for the global filter and individual column filters.
* @namespace
*/
DataTable.models.oSearch = {
/**
* Flag to indicate if the filtering should be case insensitive or not
* @type boolean
* @default true
*/
"bCaseInsensitive": true,
/**
* Applied search term
* @type string
* @default Empty string
*/
"sSearch": "",
/**
* Flag to indicate if the search term should be interpreted as a
* regular expression (true) or not (false) and therefore and special
* regex characters escaped.
* @type boolean
* @default false
*/
"bRegex": false,
/**
* Flag to indicate if DataTables is to use its smart filtering or not.
* @type boolean
* @default true
*/
"bSmart": true
};
/**
* Template object for the way in which DataTables holds information about
* each individual row. This is the object format used for the settings
* aoData array.
* @namespace
*/
DataTable.models.oRow = {
/**
* TR element for the row
* @type node
* @default null
*/
"nTr": null,
/**
* Data object from the original data source for the row. This is either
* an array if using the traditional form of DataTables, or an object if
* using mDataProp options. The exact type will depend on the passed in
* data from the data source, or will be an array if using DOM a data
* source.
* @type array|object
* @default []
*/
"_aData": [],
/**
* Sorting data cache - this array is ostensibly the same length as the
* number of columns (although each index is generated only as it is
* needed), and holds the data that is used for sorting each column in the
* row. We do this cache generation at the start of the sort in order that
* the formatting of the sort data need be done only once for each cell
* per sort. This array should not be read from or written to by anything
* other than the master sorting methods.
* @type array
* @default []
* @private
*/
"_aSortData": [],
/**
* Array of TD elements that are cached for hidden rows, so they can be
* reinserted into the table if a column is made visible again (or to act
* as a store if a column is made hidden). Only hidden columns have a
* reference in the array. For non-hidden columns the value is either
* undefined or null.
* @type array nodes
* @default []
* @private
*/
"_anHidden": [],
/**
* Cache of the class name that DataTables has applied to the row, so we
* can quickly look at this variable rather than needing to do a DOM check
* on className for the nTr property.
* @type string
* @default Empty string
* @private
*/
"_sRowStripe": ""
};
/**
* Template object for the column information object in DataTables. This object
* is held in the settings aoColumns array and contains all the information that
* DataTables needs about each individual column.
*
* Note that this object is related to {@link DataTable.defaults.columns}
* but this one is the internal data store for DataTables's cache of columns.
* It should NOT be manipulated outside of DataTables. Any configuration should
* be done through the initialisation options.
* @namespace
*/
DataTable.models.oColumn = {
/**
* A list of the columns that sorting should occur on when this column
* is sorted. That this property is an array allows multi-column sorting
* to be defined for a column (for example first name / last name columns
* would benefit from this). The values are integers pointing to the
* columns to be sorted on (typically it will be a single integer pointing
* at itself, but that doesn't need to be the case).
* @type array
*/
"aDataSort": null,
/**
* Define the sorting directions that are applied to the column, in sequence
* as the column is repeatedly sorted upon - i.e. the first value is used
* as the sorting direction when the column if first sorted (clicked on).
* Sort it again (click again) and it will move on to the next index.
* Repeat until loop.
* @type array
*/
"asSorting": null,
/**
* Flag to indicate if the column is searchable, and thus should be included
* in the filtering or not.
* @type boolean
*/
"bSearchable": null,
/**
* Flag to indicate if the column is sortable or not.
* @type boolean
*/
"bSortable": null,
/**
* When using fnRender, you have two options for what to do with the data,
* and this property serves as the switch. Firstly, you can have the sorting
* and filtering use the rendered value (true - default), or you can have
* the sorting and filtering us the original value (false).
*
* *NOTE* It is it is advisable now to use mDataProp as a function and make
* use of the 'type' that it gives, allowing (potentially) different data to
* be used for sorting, filtering, display and type detection.
* @type boolean
* @deprecated
*/
"bUseRendered": null,
/**
* Flag to indicate if the column is currently visible in the table or not
* @type boolean
*/
"bVisible": null,
/**
* Flag to indicate to the type detection method if the automatic type
* detection should be used, or if a column type (sType) has been specified
* @type boolean
* @default true
* @private
*/
"_bAutoType": true,
/**
* Developer definable function that is called whenever a cell is created (Ajax source,
* etc) or processed for input (DOM source). This can be used as a compliment to fnRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available (since it is not when fnRender is called).
* @type function
* @param {element} nTd The TD node that has been created
* @param {*} sData The Data for the cell
* @param {array|object} oData The data for the whole row
* @param {int} iRow The row index for the aoData data store
* @default null
*/
"fnCreatedCell": null,
/**
* Function to get data from a cell in a column. You should never
* access data directly through _aData internally in DataTables - always use
* the method attached to this property. It allows mDataProp to function as
* required. This function is automatically assigned by the column
* initialisation method
* @type function
* @param {array|object} oData The data array/object for the array
* (i.e. aoData[]._aData)
* @param {string} sSpecific The specific data type you want to get -
* 'display', 'type' 'filter' 'sort'
* @returns {*} The data for the cell from the given row's data
* @default null
*/
"fnGetData": null,
/**
* Custom display function that will be called for the display of each cell
* in this column.
* @type function
* @param {object} o Object with the following parameters:
* @param {int} o.iDataRow The row in aoData
* @param {int} o.iDataColumn The column in question
* @param {array o.aData The data for the row in question
* @param {object} o.oSettings The settings object for this DataTables instance
* @returns {string} The string you which to use in the display
* @default null
*/
"fnRender": null,
/**
* Function to set data for a cell in the column. You should never
* set the data directly to _aData internally in DataTables - always use
* this method. It allows mDataProp to function as required. This function
* is automatically assigned by the column initialisation method
* @type function
* @param {array|object} oData The data array/object for the array
* (i.e. aoData[]._aData)
* @param {*} sValue Value to set
* @default null
*/
"fnSetData": null,
/**
* Property to read the value for the cells in the column from the data
* source array / object. If null, then the default content is used, if a
* function is given then the return from the function is used.
* @type function|int|string|null
* @default null
*/
"mDataProp": null,
/**
* Unique header TH/TD element for this column - this is what the sorting
* listener is attached to (if sorting is enabled.)
* @type node
* @default null
*/
"nTh": null,
/**
* Unique footer TH/TD element for this column (if there is one). Not used
* in DataTables as such, but can be used for plug-ins to reference the
* footer for each column.
* @type node
* @default null
*/
"nTf": null,
/**
* The class to apply to all TD elements in the table's TBODY for the column
* @type string
* @default null
*/
"sClass": null,
/**
* When DataTables calculates the column widths to assign to each column,
* it finds the longest string in each column and then constructs a
* temporary table and reads the widths from that. The problem with this
* is that "mmm" is much wider then "iiii", but the latter is a longer
* string - thus the calculation can go wrong (doing it properly and putting
* it into an DOM object and measuring that is horribly(!) slow). Thus as
* a "work around" we provide this option. It will append its value to the
* text that is found to be the longest string for the column - i.e. padding.
* @type string
*/
"sContentPadding": null,
/**
* Allows a default value to be given for a column's data, and will be used
* whenever a null data source is encountered (this can be because mDataProp
* is set to null, or because the data source itself is null).
* @type string
* @default null
*/
"sDefaultContent": null,
/**
* Name for the column, allowing reference to the column by name as well as
* by index (needs a lookup to work by name).
* @type string
*/
"sName": null,
/**
* Custom sorting data type - defines which of the available plug-ins in
* afnSortData the custom sorting will use - if any is defined.
* @type string
* @default std
*/
"sSortDataType": 'std',
/**
* Class to be applied to the header element when sorting on this column
* @type string
* @default null
*/
"sSortingClass": null,
/**
* Class to be applied to the header element when sorting on this column -
* when jQuery UI theming is used.
* @type string
* @default null
*/
"sSortingClassJUI": null,
/**
* Title of the column - what is seen in the TH element (nTh).
* @type string
*/
"sTitle": null,
/**
* Column sorting and filtering type
* @type string
* @default null
*/
"sType": null,
/**
* Width of the column
* @type string
* @default null
*/
"sWidth": null,
/**
* Width of the column when it was first "encountered"
* @type string
* @default null
*/
"sWidthOrig": null
};
/**
* Initialisation options that can be given to DataTables at initialisation
* time.
* @namespace
*/
DataTable.defaults = {
/**
* An array of data to use for the table, passed in at initialisation which
* will be used in preference to any data which is already in the DOM. This is
* particularly useful for constructing tables purely in Javascript, for
* example with a custom Ajax call.
* @type array
* @default null
* @dtopt Option
*
* @example
* // Using a 2D array data source
* $(document).ready( function () {
* $('#example').dataTable( {
* "aaData": [
* ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
* ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
* ],
* "aoColumns": [
* { "sTitle": "Engine" },
* { "sTitle": "Browser" },
* { "sTitle": "Platform" },
* { "sTitle": "Version" },
* { "sTitle": "Grade" }
* ]
* } );
* } );
*
* @example
* // Using an array of objects as a data source (mDataProp)
* $(document).ready( function () {
* $('#example').dataTable( {
* "aaData": [
* {
* "engine": "Trident",
* "browser": "Internet Explorer 4.0",
* "platform": "Win 95+",
* "version": 4,
* "grade": "X"
* },
* {
* "engine": "Trident",
* "browser": "Internet Explorer 5.0",
* "platform": "Win 95+",
* "version": 5,
* "grade": "C"
* }
* ],
* "aoColumns": [
* { "sTitle": "Engine", "mDataProp": "engine" },
* { "sTitle": "Browser", "mDataProp": "browser" },
* { "sTitle": "Platform", "mDataProp": "platform" },
* { "sTitle": "Version", "mDataProp": "version" },
* { "sTitle": "Grade", "mDataProp": "grade" }
* ]
* } );
* } );
*/
"aaData": null,
/**
* If sorting is enabled, then DataTables will perform a first pass sort on
* initialisation. You can define which column(s) the sort is performed upon,
* and the sorting direction, with this variable. The aaSorting array should
* contain an array for each column to be sorted initially containing the
* column's index and a direction string ('asc' or 'desc').
* @type array
* @default [[0,'asc']]
* @dtopt Option
*
* @example
* // Sort by 3rd column first, and then 4th column
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSorting": [[2,'asc'], [3,'desc']]
* } );
* } );
*
* // No initial sorting
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSorting": []
* } );
* } );
*/
"aaSorting": [[0,'asc']],
/**
* This parameter is basically identical to the aaSorting parameter, but
* cannot be overridden by user interaction with the table. What this means
* is that you could have a column (visible or hidden) which the sorting will
* always be forced on first - any sorting after that (from the user) will
* then be performed as required. This can be useful for grouping rows
* together.
* @type array
* @default null
* @dtopt Option
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSortingFixed": [[0,'asc']]
* } );
* } )
*/
"aaSortingFixed": null,
/**
* This parameter allows you to readily specify the entries in the length drop
* down menu that DataTables shows when pagination is enabled. It can be
* either a 1D array of options which will be used for both the displayed
* option and the value, or a 2D array which will use the array in the first
* position as the value, and the array in the second position as the
* displayed options (useful for language strings such as 'All').
* @type array
* @default [ 10, 25, 50, 100 ]
* @dtopt Option
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
* } );
* } );
*
* @example
* // Setting the default display length as well as length menu
* // This is likely to be wanted if you remove the '10' option which
* // is the iDisplayLength default.
* $(document).ready(function() {
* $('#example').dataTable( {
* "iDisplayLength": 25,
* "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
* } );
* } );
*/
"aLengthMenu": [ 10, 25, 50, 100 ],
/**
* The aoColumns option in the initialisation parameter allows you to define
* details about the way individual columns behave. For a full list of
* column options that can be set, please see
* {@link DataTable.defaults.columns}. Note that if you use aoColumns to
* define your columns, you must have an entry in the array for every single
* column that you have in your table (these can be null if you don't which
* to specify any options).
* @member
*/
"aoColumns": null,
/**
* Very similar to aoColumns, aoColumnDefs allows you to target a specific
* column, multiple columns, or all columns, using the aTargets property of
* each object in the array. This allows great flexibility when creating
* tables, as the aoColumnDefs arrays can be of any length, targeting the
* columns you specifically want. aoColumnDefs may use any of the column
* options available: {@link DataTable.defaults.columns}, but it _must_
* have aTargets defined in each object in the array. Values in the aTargets
* array may be:
*
*
a string - class name will be matched on the TH for the column
*
0 or a positive integer - column index counting from the left
*
a negative integer - column index counting from the right
*
the string "_all" - all columns (i.e. assign a default)
*
* @member
*/
"aoColumnDefs": null,
/**
* Basically the same as oSearch, this parameter defines the individual column
* filtering state at initialisation time. The array must be of the same size
* as the number of columns, and each element be an object with the parameters
* "sSearch" and "bEscapeRegex" (the latter is optional). 'null' is also
* accepted and the default will be used.
* @type array
* @default []
* @dtopt Option
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoSearchCols": [
* null,
* { "sSearch": "My filter" },
* null,
* { "sSearch": "^[0-9]", "bEscapeRegex": false }
* ]
* } );
* } )
*/
"aoSearchCols": [],
/**
* An array of CSS classes that should be applied to displayed rows. This
* array may be of any length, and DataTables will apply each class
* sequentially, looping when required.
* @type array
* @default [ 'odd', 'even' ]
* @dtopt Option
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "asStripeClasses": [ 'strip1', 'strip2', 'strip3' ]
* } );
* } )
*/
"asStripeClasses": [ 'odd', 'even' ],
/**
* Enable or disable automatic column width calculation. This can be disabled
* as an optimisation (it takes some time to calculate the widths) if the
* tables widths are passed in using aoColumns.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bAutoWidth": false
* } );
* } );
*/
"bAutoWidth": true,
/**
* Deferred rendering can provide DataTables with a huge speed boost when you
* are using an Ajax or JS data source for the table. This option, when set to
* true, will cause DataTables to defer the creation of the table elements for
* each row until they are needed for a draw - saving a significant amount of
* time.
* @type boolean
* @default false
* @dtopt Features
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/arrays.txt",
* "bDeferRender": true
* } );
* } );
*/
"bDeferRender": false,
/**
* Replace a DataTable which matches the given selector and replace it with
* one which has the properties of the new initialisation object passed. If no
* table matches the selector, then the new DataTable will be constructed as
* per normal.
* @type boolean
* @default false
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false
* } );
*
* // Some time later....
* $('#example').dataTable( {
* "bFilter": false,
* "bDestroy": true
* } );
* } );
*/
"bDestroy": false,
/**
* Enable or disable filtering of data. Filtering in DataTables is "smart" in
* that it allows the end user to input multiple words (space separated) and
* will match a row containing those words, even if not in the order that was
* specified (this allow matching across multiple columns). Note that if you
* wish to use filtering in DataTables this must remain 'true' - to remove the
* default filtering input box and retain filtering abilities, please use
* @ref{sDom}.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bFilter": false
* } );
* } );
*/
"bFilter": true,
/**
* Enable or disable the table information display. This shows information
* about the data that is currently visible on the page, including information
* about filtered data if that action is being performed.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bInfo": false
* } );
* } );
*/
"bInfo": true,
/**
* Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
* slightly different and additional mark-up from what DataTables has
* traditionally used).
* @type boolean
* @default false
* @dtopt Features
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "bJQueryUI": true
* } );
* } );
*/
"bJQueryUI": false,
/**
* Allows the end user to select the size of a formatted page from a select
* menu (sizes are 10, 25, 50 and 100). Requires pagination (bPaginate).
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bLengthChange": false
* } );
* } );
*/
"bLengthChange": true,
/**
* Enable or disable pagination.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bPaginate": false
* } );
* } );
*/
"bPaginate": true,
/**
* Enable or disable the display of a 'processing' indicator when the table is
* being processed (e.g. a sort). This is particularly useful for tables with
* large amounts of data where it can take a noticeable amount of time to sort
* the entries.
* @type boolean
* @default false
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bProcessing": true
* } );
* } );
*/
"bProcessing": false,
/**
* Retrieve the DataTables object for the given selector. Note that if the
* table has already been initialised, this parameter will cause DataTables
* to simply return the object that has already been set up - it will not take
* account of any changes you might have made to the initialisation object
* passed to DataTables (setting this parameter to true is an acknowledgement
* that you understand this). bDestroy can be used to reinitialise a table if
* you need.
* @type boolean
* @default false
* @dtopt Options
*
* @example
* $(document).ready(function() {
* initTable();
* tableActions();
* } );
*
* function initTable ()
* {
* return $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false,
* "bRetrieve": true
* } );
* }
*
* function tableActions ()
* {
* var oTable = initTable();
* // perform API operations with oTable
* }
*/
"bRetrieve": false,
/**
* Indicate if DataTables should be allowed to set the padding / margin
* etc for the scrolling header elements or not. Typically you will want
* this.
* @type boolean
* @default true
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bScrollAutoCss": false,
* "sScrollY": "200px"
* } );
* } );
*/
"bScrollAutoCss": true,
/**
* When vertical (y) scrolling is enabled, DataTables will force the height of
* the table's viewport to the given height at all times (useful for layout).
* However, this can look odd when filtering data down to a small data set,
* and the footer is left "floating" further down. This parameter (when
* enabled) will cause DataTables to collapse the table's viewport down when
* the result set will fit within the given Y height.
* @type boolean
* @default false
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200",
* "bScrollCollapse": true
* } );
* } );
*/
"bScrollCollapse": false,
/**
* Enable infinite scrolling for DataTables (to be used in combination with
* sScrollY). Infinite scrolling means that DataTables will continually load
* data as a user scrolls through a table, which is very useful for large
* dataset. This cannot be used with pagination, which is automatically
* disabled. Note - the Scroller extra for DataTables is recommended in
* in preference to this option.
* @type boolean
* @default false
* @dtopt Features
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bScrollInfinite": true,
* "bScrollCollapse": true,
* "sScrollY": "200px"
* } );
* } );
*/
"bScrollInfinite": false,
/**
* Configure DataTables to use server-side processing. Note that the
* sAjaxSource parameter must also be given in order to give DataTables a
* source to obtain the required data for each draw.
* @type boolean
* @default false
* @dtopt Features
* @dtopt Server-side
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "xhr.php"
* } );
* } );
*/
"bServerSide": false,
/**
* Enable or disable sorting of columns. Sorting of individual columns can be
* disabled by the "bSortable" option for each column.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bSort": false
* } );
* } );
*/
"bSort": true,
/**
* Allows control over whether DataTables should use the top (true) unique
* cell that is found for a single column, or the bottom (false - default).
* This is useful when using complex headers.
* @type boolean
* @default false
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bSortCellsTop": true
* } );
* } );
*/
"bSortCellsTop": false,
/**
* Enable or disable the addition of the classes 'sorting_1', 'sorting_2' and
* 'sorting_3' to the columns which are currently being sorted on. This is
* presented as a feature switch as it can increase processing time (while
* classes are removed and added) so for large data sets you might want to
* turn this off.
* @type boolean
* @default true
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bSortClasses": false
* } );
* } );
*/
"bSortClasses": true,
/**
* Enable or disable state saving. When enabled a cookie will be used to save
* table display information such as pagination information, display length,
* filtering and sorting. As such when the end user reloads the page the
* display display will match what thy had previously set up.
* @type boolean
* @default false
* @dtopt Features
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true
* } );
* } );
*/
"bStateSave": false,
/**
* Customise the cookie and / or the parameters being stored when using
* DataTables with state saving enabled. This function is called whenever
* the cookie is modified, and it expects a fully formed cookie string to be
* returned. Note that the data object passed in is a Javascript object which
* must be converted to a string (JSON.stringify for example).
* @type function
* @param {string} sName Name of the cookie defined by DataTables
* @param {object} oData Data to be stored in the cookie
* @param {string} sExpires Cookie expires string
* @param {string} sPath Path of the cookie to set
* @returns {string} Cookie formatted string (which should be encoded by
* using encodeURIComponent())
* @dtopt Callbacks
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "fnCookieCallback": function (sName, oData, sExpires, sPath) {
* // Customise oData or sName or whatever else here
* return sName + "="+JSON.stringify(oData)+"; expires=" + sExpires +"; path=" + sPath;
* }
* } );
* } );
*/
"fnCookieCallback": null,
/**
* This function is called when a TR element is created (and all TD child
* elements have been inserted), or registered if using a DOM source, allowing
* manipulation of the TR element (adding classes etc).
* @type function
* @param {node} nRow "TR" element for the current row
* @param {array} aData Raw data array for this row
* @param {int} iDataIndex The index of this row in aoData
* @dtopt Callbacks
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnCreatedRow": function( nRow, aData, iDataIndex ) {
* // Bold the grade for all 'A' grade browsers
* if ( aData[4] == "A" )
* {
* $('td:eq(4)', nRow).html( 'A' );
* }
* }
* } );
* } );
*/
"fnCreatedRow": null,
/**
* This function is called on every 'draw' event, and allows you to
* dynamically modify any aspect you want about the created DOM.
* @type function
* @param {object} oSettings DataTables settings object
* @dtopt Callbacks
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnDrawCallback": function() {
* alert( 'DataTables has redrawn the table' );
* }
* } );
* } );
*/
"fnDrawCallback": null,
/**
* Identical to fnHeaderCallback() but for the table footer this function
* allows you to modify the table footer on every 'draw' even.
* @type function
* @param {node} nFoot "TR" element for the footer
* @param {array} aData Full table data (as derived from the original HTML)
* @param {int} iStart Index for the current display starting point in the
* display array
* @param {int} iEnd Index for the current display ending point in the
* display array
* @param {array int} aiDisplay Index array to translate the visual position
* to the full data array
* @dtopt Callbacks
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) {
* nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
* }
* } );
* } )
*/
"fnFooterCallback": null,
/**
* When rendering large numbers in the information element for the table
* (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
* to have a comma separator for the 'thousands' units (e.g. 1 million is
* rendered as "1,000,000") to help readability for the end user. This
* function will override the default method DataTables uses.
* @type function
* @member
* @param {int} iIn number to be formatted
* @returns {string} formatted string for DataTables to show the number
* @dtopt Callbacks
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnFormatNumber": function ( iIn ) {
* if ( iIn < 1000 ) {
* return iIn;
* } else {
* var
* s=(iIn+""),
* a=s.split(""), out="",
* iLen=s.length;
*
* for ( var i=0 ; i<iLen ; i++ ) {
* if ( i%3 === 0 && i !== 0 ) {
* out = "'"+out;
* }
* out = a[iLen-i-1]+out;
* }
* }
* return out;
* };
* } );
* } );
*/
"fnFormatNumber": function ( iIn ) {
if ( iIn < 1000 )
{
// A small optimisation for what is likely to be the majority of use cases
return iIn;
}
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; iA' );
* }
* }
* } );
* } );
*/
"fnRowCallback": null,
/**
* This parameter allows you to override the default function which obtains
* the data from the server ($.getJSON) so something more suitable for your
* application. For example you could use POST data, or pull information from
* a Gears or AIR database.
* @type function
* @member
* @param {string} sSource HTTP source to obtain the data from (sAjaxSource)
* @param {array} aoData A key/value pair object containing the data to send
* to the server
* @param {function} fnCallback to be called on completion of the data get
* process that will draw the data on the page.
* @param {object} oSettings DataTables settings object
* @dtopt Callbacks
* @dtopt Server-side
*
* @example
* // POST data to server
* $(document).ready(function() {
* $('#example').dataTable( {
* "bProcessing": true,
* "bServerSide": true,
* "sAjaxSource": "xhr.php",
* "fnServerData": function ( sSource, aoData, fnCallback ) {
* $.ajax( {
* "dataType": 'json',
* "type": "POST",
* "url": sSource,
* "data": aoData,
* "success": fnCallback
* } );
* }
* } );
* } );
*/
"fnServerData": function ( sUrl, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"url": sUrl,
"data": aoData,
"success": function (json) {
$(oSettings.oInstance).trigger('xhr', oSettings);
fnCallback( json );
},
"dataType": "json",
"cache": false,
"type": oSettings.sServerMethod,
"error": function (xhr, error, thrown) {
if ( error == "parsererror" ) {
alert( "DataTables warning: JSON data from server could not be parsed. "+
"This is caused by a JSON formatting error." );
}
}
} );
},
/**
* It is often useful to send extra data to the server when making an Ajax
* request - for example custom filtering information, and this callback
* function makes it trivial to send extra information to the server. The
* passed in parameter is the data set that has been constructed by
* DataTables, and you can add to this or modify it as you require.
* @type function
* @param {array} aoData Data array (array of objects which are name/value
* pairs) that has been constructed by DataTables and will be sent to the
* server. In the case of Ajax sourced data with server-side processing
* this will be an empty array, for server-side processing there will be a
* significant number of parameters!
* @returns {undefined} Ensure that you modify the aoData array passed in,
* as this is passed by reference.
* @dtopt Callbacks
* @dtopt Server-side
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bProcessing": true,
* "bServerSide": true,
* "sAjaxSource": "scripts/server_processing.php",
* "fnServerParams": function ( aoData ) {
* aoData.push( { "name": "more_data", "value": "my_value" } );
* }
* } );
* } );
*/
"fnServerParams": null,
/**
* Load the table state. With this function you can define from where, and how, the
* state of a table is loaded. By default DataTables will load from its state saving
* cookie, but you might wish to use local storage (HTML5) or a server-side database.
* @type function
* @member
* @param {object} oSettings DataTables settings object
* @return {object} The DataTables state object to be loaded
* @dtopt Callbacks
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateSave": function (oSettings, oData) {
* var o;
*
* // Send an Ajax request to the server to get the data. Note that
* // this is a synchronous request.
* $.ajax( {
* "url": "/state_load",
* "async": false,
* "dataType": "json",
* "success": function (json) {
* o = json;
* }
* } );
*
* return o;
* }
* } );
* } );
*/
"fnStateLoad": function ( oSettings ) {
var sData = this.oApi._fnReadCookie( oSettings.sCookiePrefix+oSettings.sInstance );
var oData;
try {
oData = (typeof $.parseJSON === 'function') ?
$.parseJSON(sData) : eval( '('+sData+')' );
} catch (e) {
oData = null;
}
return oData;
},
/**
* Callback which allows modification of the saved state prior to loading that state.
* This callback is called when the table is loading state from the stored data, but
* prior to the settings object being modified by the saved state. Note that for
* plug-in authors, you should use the 'stateLoadParams' event to load parameters for
* a plug-in.
* @type function
* @param {object} oSettings DataTables settings object
* @param {object} oData The state object that is to be loaded
* @dtopt Callbacks
*
* @example
* // Remove a saved filter, so filtering is never loaded
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadParams": function (oSettings, oData) {
* oData.oFilter.sSearch = "";
* } );
* } );
*
* @example
* // Disallow state loading by returning false
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadParams": function (oSettings, oData) {
* return false;
* } );
* } );
*/
"fnStateLoadParams": null,
/**
* Callback that is called when the state has been loaded from the state saving method
* and the DataTables settings object has been modified as a result of the loaded state.
* @type function
* @param {object} oSettings DataTables settings object
* @param {object} oData The state object that was loaded
* @dtopt Callbacks
*
* @example
* // Show an alert with the filtering value that was saved
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoaded": function (oSettings, oData) {
* alert( 'Saved filter was: '+oData.oFilter.sSearch );
* } );
* } );
*/
"fnStateLoaded": null,
/**
* Save the table state. This function allows you to define where and how the state
* information for the table is stored - by default it will use a cookie, but you
* might want to use local storage (HTML5) or a server-side database.
* @type function
* @member
* @param {object} oSettings DataTables settings object
* @param {object} oData The state object to be saved
* @dtopt Callbacks
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateSave": function (oSettings, oData) {
* // Send an Ajax request to the server with the state object
* $.ajax( {
* "url": "/state_save",
* "data": oData,
* "dataType": "json",
* "method": "POST"
* "success": function () {}
* } );
* }
* } );
* } );
*/
"fnStateSave": function ( oSettings, oData ) {
this.oApi._fnCreateCookie(
oSettings.sCookiePrefix+oSettings.sInstance,
this.oApi._fnJsonString(oData),
oSettings.iCookieDuration,
oSettings.sCookiePrefix,
oSettings.fnCookieCallback
);
},
/**
* Callback which allows modification of the state to be saved. Called when the table
* has changed state a new state save is required. This method allows modification of
* the state saving object prior to actually doing the save, including addition or
* other state properties or modification. Note that for plug-in authors, you should
* use the 'stateSaveParams' event to save parameters for a plug-in.
* @type function
* @param {object} oSettings DataTables settings object
* @param {object} oData The state object to be saved
* @dtopt Callbacks
*
* @example
* // Remove a saved filter, so filtering is never saved
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadParams": function (oSettings, oData) {
* oData.oFilter.sSearch = "";
* } );
* } );
*/
"fnStateSaveParams": null,
/**
* Duration of the cookie which is used for storing session information. This
* value is given in seconds.
* @type int
* @default 7200 (2 hours)
* @dtopt Options
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iCookieDuration": 60*60*24 // 1 day
* } );
* } )
*/
"iCookieDuration": 7200,
/**
* When enabled DataTables will not make a request to the server for the first
* page draw - rather it will use the data already on the page (no sorting etc
* will be applied to it), thus saving on an XHR at load time. iDeferLoading
* is used to indicate that deferred loading is required, but it is also used
* to tell DataTables how many records there are in the full table (allowing
* the information element and pagination to be displayed correctly).
* @type int
* @default null
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "scripts/server_processing.php",
* "iDeferLoading": 57
* } );
* } );
*/
"iDeferLoading": null,
/**
* Number of rows to display on a single page when using pagination. If
* feature enabled (bLengthChange) then the end user will be able to override
* this to a custom setting using a pop-up menu.
* @type int
* @default 10
* @dtopt Options
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iDisplayLength": 50
* } );
* } )
*/
"iDisplayLength": 10,
/**
* Define the starting point for data display when using DataTables with
* pagination. Note that this parameter is the number of records, rather than
* the page number, so if you have 10 records per page and want to start on
* the third page, it should be "20".
* @type int
* @default 0
* @dtopt Options
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iDisplayStart": 20
* } );
* } )
*/
"iDisplayStart": 0,
/**
* The scroll gap is the amount of scrolling that is left to go before
* DataTables will load the next 'page' of data automatically. You typically
* want a gap which is big enough that the scrolling will be smooth for the
* user, while not so large that it will load more data than need.
* @type int
* @default 100
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bScrollInfinite": true,
* "bScrollCollapse": true,
* "sScrollY": "200px",
* "iScrollLoadGap": 50
* } );
* } );
*/
"iScrollLoadGap": 100,
/**
* By default DataTables allows keyboard navigation of the table (sorting, paging,
* and filtering) by adding a tabindex attribute to the required elements. This
* allows you to tab through the controls and press the enter key to activate them.
* The tabindex is default 0, meaning that the tab follows the flow of the document.
* You can overrule this using this parameter if you wish. Use a value of -1 to
* disable built-in keyboard navigation.
* @type int
* @default 0
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "iTabIndex": 1
* } );
* } );
*/
"iTabIndex": 0,
/**
* All strings that DataTables uses in the user interface that it creates
* are defined in this object, allowing you to modified them individually or
* completely replace them all as required.
* @namespace
*/
"oLanguage": {
/**
* Strings that are used for WAI-ARIA labels and controls only (these are not
* actually visible on the page, but will be read by screenreaders, and thus
* must be internationalised as well).
* @namespace
*/
"oAria": {
/**
* ARIA label that is added to the table headers when the column may be
* sorted ascending by activing the column (click or return when focused).
* Note that the column header is prefixed to this string.
* @type string
* @default : activate to sort column ascending
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oAria": {
* "sSortAscending": " - click/return to sort ascending"
* }
* }
* } );
* } );
*/
"sSortAscending": ": activate to sort column ascending",
/**
* ARIA label that is added to the table headers when the column may be
* sorted descending by activing the column (click or return when focused).
* Note that the column header is prefixed to this string.
* @type string
* @default : activate to sort column ascending
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oAria": {
* "sSortDescending": " - click/return to sort descending"
* }
* }
* } );
* } );
*/
"sSortDescending": ": activate to sort column descending"
},
/**
* Pagination string used by DataTables for the two built-in pagination
* control types ("two_button" and "full_numbers")
* @namespace
*/
"oPaginate": {
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the first page.
* @type string
* @default First
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sFirst": "First page"
* }
* }
* } );
* } );
*/
"sFirst": "First",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the last page.
* @type string
* @default Last
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sLast": "Last page"
* }
* }
* } );
* } );
*/
"sLast": "Last",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the next page.
* @type string
* @default Next
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sNext": "Next page"
* }
* }
* } );
* } );
*/
"sNext": "Next",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the previous page.
* @type string
* @default Previous
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sPrevious": "Previous page"
* }
* }
* } );
* } );
*/
"sPrevious": "Previous"
},
/**
* This string is shown in preference to sZeroRecords when the table is
* empty of data (regardless of filtering). Note that this is an optional
* parameter - if it is not given, the value of sZeroRecords will be used
* instead (either the default or given value).
* @type string
* @default No data available in table
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sEmptyTable": "No data available in table"
* }
* } );
* } );
*/
"sEmptyTable": "No data available in table",
/**
* This string gives information to the end user about the information that
* is current on display on the page. The _START_, _END_ and _TOTAL_
* variables are all dynamically replaced as the table display updates, and
* can be freely moved or removed as the language requirements change.
* @type string
* @default Showing _START_ to _END_ of _TOTAL_ entries
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfo": "Got a total of _TOTAL_ entries to show (_START_ to _END_)"
* }
* } );
* } );
*/
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
/**
* Display information string for when the table is empty. Typically the
* format of this string should match sInfo.
* @type string
* @default Showing 0 to 0 of 0 entries
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoEmpty": "No entries to show"
* }
* } );
* } );
*/
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
/**
* When a user filters the information in a table, this string is appended
* to the information (sInfo) to give an idea of how strong the filtering
* is. The variable _MAX_ is dynamically updated.
* @type string
* @default (filtered from _MAX_ total entries)
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoFiltered": " - filtering from _MAX_ records"
* }
* } );
* } );
*/
"sInfoFiltered": "(filtered from _MAX_ total entries)",
/**
* If can be useful to append extra information to the info string at times,
* and this variable does exactly that. This information will be appended to
* the sInfo (sInfoEmpty and sInfoFiltered in whatever combination they are
* being used) at all times.
* @type string
* @default Empty string
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoPostFix": "All records shown are derived from real information."
* }
* } );
* } );
*/
"sInfoPostFix": "",
/**
* DataTables has a build in number formatter (fnFormatNumber) which is used
* to format large numbers that are used in the table information. By
* default a comma is used, but this can be trivially changed to any
* character you wish with this parameter.
* @type string
* @default ,
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoThousands": "'"
* }
* } );
* } );
*/
"sInfoThousands": ",",
/**
* Detail the action that will be taken when the drop down menu for the
* pagination length option is changed. The '_MENU_' variable is replaced
* with a default select list of 10, 25, 50 and 100, and can be replaced
* with a custom select box if required.
* @type string
* @default Show _MENU_ entries
* @dtopt Language
*
* @example
* // Language change only
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLengthMenu": "Display _MENU_ records"
* }
* } );
* } );
*
* @example
* // Language and options change
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLengthMenu": 'Display records'
* }
* } );
* } );
*/
"sLengthMenu": "Show _MENU_ entries",
/**
* When using Ajax sourced data and during the first draw when DataTables is
* gathering the data, this message is shown in an empty row in the table to
* indicate to the end user the the data is being loaded. Note that this
* parameter is not used when loading data by server-side processing, just
* Ajax sourced data with client-side processing.
* @type string
* @default Loading...
* @dtopt Language
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLoadingRecords": "Please wait - loading..."
* }
* } );
* } );
*/
"sLoadingRecords": "Loading...",
/**
* Text which is displayed when the table is processing a user action
* (usually a sort command or similar).
* @type string
* @default Processing...
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sProcessing": "DataTables is currently busy"
* }
* } );
* } );
*/
"sProcessing": "Processing...",
/**
* Details the actions that will be taken when the user types into the
* filtering input text box. The variable "_INPUT_", if used in the string,
* is replaced with the HTML text box for the filtering input allowing
* control over where it appears in the string. If "_INPUT_" is not given
* then the input box is appended to the string automatically.
* @type string
* @default Search:
* @dtopt Language
*
* @example
* // Input text box will be appended at the end automatically
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sSearch": "Filter records:"
* }
* } );
* } );
*
* @example
* // Specify where the filter should appear
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sSearch": "Apply filter _INPUT_ to table"
* }
* } );
* } );
*/
"sSearch": "Search:",
/**
* All of the language information can be stored in a file on the
* server-side, which DataTables will look up if this parameter is passed.
* It must store the URL of the language file, which is in a JSON format,
* and the object has the same properties as the oLanguage object in the
* initialiser object (i.e. the above parameters). Please refer to one of
* the example language files to see how this works in action.
* @type string
* @default Empty string - i.e. disabled
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sUrl": "http://www.sprymedia.co.uk/dataTables/lang.txt"
* }
* } );
* } );
*/
"sUrl": "",
/**
* Text shown inside the table records when the is no information to be
* displayed after filtering. sEmptyTable is shown when there is simply no
* information in the table at all (regardless of filtering).
* @type string
* @default No matching records found
* @dtopt Language
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sZeroRecords": "No records to display"
* }
* } );
* } );
*/
"sZeroRecords": "No matching records found"
},
/**
* This parameter allows you to have define the global filtering state at
* initialisation time. As an object the "sSearch" parameter must be
* defined, but all other parameters are optional. When "bRegex" is true,
* the search string will be treated as a regular expression, when false
* (default) it will be treated as a straight string. When "bSmart"
* DataTables will use it's smart filtering methods (to word match at
* any point in the data), when false this will not be done.
* @namespace
* @extends DataTable.models.oSearch
* @dtopt Options
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "oSearch": {"sSearch": "Initial search"}
* } );
* } )
*/
"oSearch": $.extend( {}, DataTable.models.oSearch ),
/**
* By default DataTables will look for the property 'aaData' when obtaining
* data from an Ajax source or for server-side processing - this parameter
* allows that property to be changed. You can use Javascript dotted object
* notation to get a data source for multiple levels of nesting.
* @type string
* @default aaData
* @dtopt Options
* @dtopt Server-side
*
* @example
* // Get data from { "data": [...] }
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/data.txt",
* "sAjaxDataProp": "data"
* } );
* } );
*
* @example
* // Get data from { "data": { "inner": [...] } }
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/data.txt",
* "sAjaxDataProp": "data.inner"
* } );
* } );
*/
"sAjaxDataProp": "aaData",
/**
* You can instruct DataTables to load data from an external source using this
* parameter (use aData if you want to pass data in you already have). Simply
* provide a url a JSON object can be obtained from. This object must include
* the parameter 'aaData' which is the data source for the table.
* @type string
* @default null
* @dtopt Options
* @dtopt Server-side
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "sAjaxSource": "http://www.sprymedia.co.uk/dataTables/json.php"
* } );
* } )
*/
"sAjaxSource": null,
/**
* This parameter can be used to override the default prefix that DataTables
* assigns to a cookie when state saving is enabled.
* @type string
* @default SpryMedia_DataTables_
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sCookiePrefix": "my_datatable_",
* } );
* } );
*/
"sCookiePrefix": "SpryMedia_DataTables_",
/**
* This initialisation variable allows you to specify exactly where in the
* DOM you want DataTables to inject the various controls it adds to the page
* (for example you might want the pagination controls at the top of the
* table). DIV elements (with or without a custom class) can also be added to
* aid styling. The follow syntax is used:
*
*
* @type string
* @default lfrtip (when bJQueryUI is false)or
* <"H"lfr>t<"F"ip> (when bJQueryUI is true)
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sDom": '<"top"i>rt<"bottom"flp><"clear"&lgt;'
* } );
* } );
*/
"sDom": "lfrtip",
/**
* DataTables features two different built-in pagination interaction methods
* ('two_button' or 'full_numbers') which present different page controls to
* the end user. Further methods can be added using the API (see below).
* @type string
* @default two_button
* @dtopt Options
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "sPaginationType": "full_numbers"
* } );
* } )
*/
"sPaginationType": "two_button",
/**
* Enable horizontal scrolling. When a table is too wide to fit into a certain
* layout, or you have a large number of columns in the table, you can enable
* x-scrolling to show the table in a viewport, which can be scrolled. This
* property can by any CSS unit, or a number (in which case it will be treated
* as a pixel measurement).
* @type string
* @default blank string - i.e. disabled
* @dtopt Features
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollX": "100%",
* "bScrollCollapse": true
* } );
* } );
*/
"sScrollX": "",
/**
* This property can be used to force a DataTable to use more width than it
* might otherwise do when x-scrolling is enabled. For example if you have a
* table which requires to be well spaced, this parameter is useful for
* "over-sizing" the table, and thus forcing scrolling. This property can by
* any CSS unit, or a number (in which case it will be treated as a pixel
* measurement).
* @type string
* @default blank string - i.e. disabled
* @dtopt Options
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollX": "100%",
* "sScrollXInner": "110%"
* } );
* } );
*/
"sScrollXInner": "",
/**
* Enable vertical scrolling. Vertical scrolling will constrain the DataTable
* to the given height, an enable scrolling for any data which overflows the
* current viewport. This can be used as an alternative to paging to display
* a lot of data in a small area (although paging and scrolling can both be
* enabled at the same time). This property can by any CSS unit, or a number
* (in which case it will be treated as a pixel measurement).
* @type string
* @default blank string - i.e. disabled
* @dtopt Features
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false
* } );
* } );
*/
"sScrollY": "",
/**
* Set the HTTP method that is used to make the Ajax call for server-side
* processing or Ajax sourced data.
* @type string
* @default GET
* @dtopt Options
* @dtopt Server-side
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "scripts/post.php",
* "sServerMethod": "POST"
* } );
* } );
*/
"sServerMethod": "GET"
};
/**
* Column options that can be given to DataTables at initialisation time.
* @namespace
*/
DataTable.defaults.columns = {
/**
* Allows a column's sorting to take multiple columns into account when
* doing a sort. For example first name / last name columns make sense to
* do a multi-column sort over the two columns.
* @type array
* @default null Takes the value of the column index automatically
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "aDataSort": [ 0, 1 ], "aTargets": [ 0 ] },
* { "aDataSort": [ 1, 0 ], "aTargets": [ 1 ] },
* { "aDataSort": [ 2, 3, 4 ], "aTargets": [ 2 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "aDataSort": [ 0, 1 ] },
* { "aDataSort": [ 1, 0 ] },
* { "aDataSort": [ 2, 3, 4 ] },
* null,
* null
* ]
* } );
* } );
*/
"aDataSort": null,
/**
* You can control the default sorting direction, and even alter the behaviour
* of the sort handler (i.e. only allow ascending sorting etc) using this
* parameter.
* @type array
* @default [ 'asc', 'desc' ]
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "asSorting": [ "asc" ], "aTargets": [ 1 ] },
* { "asSorting": [ "desc", "asc", "asc" ], "aTargets": [ 2 ] },
* { "asSorting": [ "desc" ], "aTargets": [ 3 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* null,
* { "asSorting": [ "asc" ] },
* { "asSorting": [ "desc", "asc", "asc" ] },
* { "asSorting": [ "desc" ] },
* null
* ]
* } );
* } );
*/
"asSorting": [ 'asc', 'desc' ],
/**
* Enable or disable filtering on the data in this column.
* @type boolean
* @default true
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "bSearchable": false, "aTargets": [ 0 ] }
* ] } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "bSearchable": false },
* null,
* null,
* null,
* null
* ] } );
* } );
*/
"bSearchable": true,
/**
* Enable or disable sorting on this column.
* @type boolean
* @default true
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "bSortable": false, "aTargets": [ 0 ] }
* ] } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "bSortable": false },
* null,
* null,
* null,
* null
* ] } );
* } );
*/
"bSortable": true,
/**
* When using fnRender() for a column, you may wish to use the original data
* (before rendering) for sorting and filtering (the default is to used the
* rendered data that the user can see). This may be useful for dates etc.
*
* *NOTE* It is it is advisable now to use mDataProp as a function and make
* use of the 'type' that it gives, allowing (potentially) different data to
* be used for sorting, filtering, display and type detection.
* @type boolean
* @default true
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( oObj ) {
* return oObj.aData[0] +' '+ oObj.aData[3];
* },
* "bUseRendered": false,
* "aTargets": [ 0 ]
* }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* {
* "fnRender": function ( oObj ) {
* return oObj.aData[0] +' '+ oObj.aData[3];
* },
* "bUseRendered": false
* },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"bUseRendered": true,
/**
* Enable or disable the display of this column.
* @type boolean
* @default true
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "bVisible": false, "aTargets": [ 0 ] }
* ] } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "bVisible": false },
* null,
* null,
* null,
* null
* ] } );
* } );
*/
"bVisible": true,
/**
* Developer definable function that is called whenever a cell is created (Ajax source,
* etc) or processed for input (DOM source). This can be used as a compliment to fnRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available (since it is not when fnRender is called).
* @type function
* @param {element} nTd The TD node that has been created
* @param {*} sData The Data for the cell
* @param {array|object} oData The data for the whole row
* @param {int} iRow The row index for the aoData data store
* @param {int} iCol The column index for aoColumns
* @dtopt Columns
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [ {
* "aTargets": [3],
* "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
* if ( sData == "1.7" ) {
* $(nTd).css('color', 'blue')
* }
* }
* } ]
* });
* } );
*/
"fnCreatedCell": null,
/**
* Custom display function that will be called for the display of each cell in
* this column.
* @type function
* @param {object} o Object with the following parameters:
* @param {int} o.iDataRow The row in aoData
* @param {int} o.iDataColumn The column in question
* @param {array} o.aData The data for the row in question
* @param {object} o.oSettings The settings object for this DataTables instance
* @param {object} o.mDataProp The data property used for this column
* @param {*} val The current cell value
* @returns {string} The string you which to use in the display
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* },
* "aTargets": [ 0 ]
* }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* } },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"fnRender": null,
/**
* The column index (starting from 0!) that you wish a sort to be performed
* upon when this column is selected for sorting. This can be used for sorting
* on hidden columns for example.
* @type int
* @default -1 Use automatically calculated column index
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "iDataSort": 1, "aTargets": [ 0 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "iDataSort": 1 },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"iDataSort": -1,
/**
* This property can be used to read data from any JSON data source property,
* including deeply nested objects / properties. mDataProp can be given in a
* number of different ways which effect its behaviour:
*
*
integer - treated as an array index for the data source. This is the
* default that DataTables uses (incrementally increased for each column).
*
string - read an object property from the data source. Note that you can
* use Javascript dotted notation to read deep properties/arrays from the
* data source.
*
null - the sDafaultContent option will use used for the cell (empty
* string by default. This can be useful on generated columns such as
* edit / delete action columns.
*
function - the function given will be executed whenever DataTables
* needs to set or get the data for a cell in the column. The function
* takes three parameters:
*
*
{array|object} The data source for the row
*
{string} The type call data requested - this will be 'set' when
* setting data or 'filter', 'display', 'type' or 'sort' when gathering
* data.
*
{*} Data to set when the second parameter is 'set'.
*
* The return value from the function is not required when 'set' is the type
* of call, but otherwise the return is what will be used for the data
* requested.
*
* @type string|int|function|null
* @default null Use automatically calculated column index
* @dtopt Columns
*
* @example
* // Read table data from objects
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/deep.txt",
* "aoColumns": [
* { "mDataProp": "engine" },
* { "mDataProp": "browser" },
* { "mDataProp": "platform.inner" },
* { "mDataProp": "platform.details.0" },
* { "mDataProp": "platform.details.1" }
* ]
* } );
* } );
*
* @example
* // Using mDataProp as a function to provide different information for
* // sorting, filtering and display. In this case, currency (price)
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "aTargets": [ 0 ],
* "mDataProp": function ( source, type, val ) {
* if (type === 'set') {
* source.price = val;
* // Store the computed dislay and filter values for efficiency
* source.price_display = val=="" ? "" : "$"+numberFormat(val);
* source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
* return;
* }
* else if (type === 'display') {
* return source.price_display;
* }
* else if (type === 'filter') {
* return source.price_filter;
* }
* // 'sort' and 'type' both just use the integer
* return source.price;
* }
* ]
* } );
* } );
*/
"mDataProp": null,
/**
* Class to give to each cell in this column.
* @type string
* @default Empty string
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sClass": "my_class", "aTargets": [ 0 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "sClass": "my_class" },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"sClass": "",
/**
* When DataTables calculates the column widths to assign to each column,
* it finds the longest string in each column and then constructs a
* temporary table and reads the widths from that. The problem with this
* is that "mmm" is much wider then "iiii", but the latter is a longer
* string - thus the calculation can go wrong (doing it properly and putting
* it into an DOM object and measuring that is horribly(!) slow). Thus as
* a "work around" we provide this option. It will append its value to the
* text that is found to be the longest string for the column - i.e. padding.
* Generally you shouldn't need this, and it is not documented on the
* general DataTables.net documentation
* @type string
* @default Empty string
* @dtopt Columns
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* null,
* null,
* null,
* {
* "sContentPadding": "mmm"
* }
* ]
* } );
* } );
*/
"sContentPadding": "",
/**
* Allows a default value to be given for a column's data, and will be used
* whenever a null data source is encountered (this can be because mDataProp
* is set to null, or because the data source itself is null).
* @type string
* @default null
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "mDataProp": null,
* "sDefaultContent": "Edit",
* "aTargets": [ -1 ]
* }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* null,
* null,
* null,
* {
* "mDataProp": null,
* "sDefaultContent": "Edit"
* }
* ]
* } );
* } );
*/
"sDefaultContent": null,
/**
* This parameter is only used in DataTables' server-side processing. It can
* be exceptionally useful to know what columns are being displayed on the
* client side, and to map these to database fields. When defined, the names
* also allow DataTables to reorder information from the server if it comes
* back in an unexpected order (i.e. if you switch your columns around on the
* client-side, your server-side code does not also need updating).
* @type string
* @default Empty string
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sName": "engine", "aTargets": [ 0 ] },
* { "sName": "browser", "aTargets": [ 1 ] },
* { "sName": "platform", "aTargets": [ 2 ] },
* { "sName": "version", "aTargets": [ 3 ] },
* { "sName": "grade", "aTargets": [ 4 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "sName": "engine" },
* { "sName": "browser" },
* { "sName": "platform" },
* { "sName": "version" },
* { "sName": "grade" }
* ]
* } );
* } );
*/
"sName": "",
/**
* Defines a data source type for the sorting which can be used to read
* realtime information from the table (updating the internally cached
* version) prior to sorting. This allows sorting to occur on user editable
* elements such as form inputs.
* @type string
* @default std
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sSortDataType": "dom-text", "aTargets": [ 2, 3 ] },
* { "sType": "numeric", "aTargets": [ 3 ] },
* { "sSortDataType": "dom-select", "aTargets": [ 4 ] },
* { "sSortDataType": "dom-checkbox", "aTargets": [ 5 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* null,
* null,
* { "sSortDataType": "dom-text" },
* { "sSortDataType": "dom-text", "sType": "numeric" },
* { "sSortDataType": "dom-select" },
* { "sSortDataType": "dom-checkbox" }
* ]
* } );
* } );
*/
"sSortDataType": "std",
/**
* The title of this column.
* @type string
* @default null Derived from the 'TH' value for this column in the
* original HTML table.
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sTitle": "My column title", "aTargets": [ 0 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "sTitle": "My column title" },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"sTitle": null,
/**
* The type allows you to specify how the data for this column will be sorted.
* Four types (string, numeric, date and html (which will strip HTML tags
* before sorting)) are currently available. Note that only date formats
* understood by Javascript's Date() object will be accepted as type date. For
* example: "Mar 26, 2008 5:03 PM". May take the values: 'string', 'numeric',
* 'date' or 'html' (by default). Further types can be adding through
* plug-ins.
* @type string
* @default null Auto-detected from raw data
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sType": "html", "aTargets": [ 0 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "sType": "html" },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"sType": null,
/**
* Defining the width of the column, this parameter may take any CSS value
* (3em, 20px etc). DataTables applys 'smart' widths to columns which have not
* been given a specific width through this interface ensuring that the table
* remains readable.
* @type string
* @default null Automatic
* @dtopt Columns
*
* @example
* // Using aoColumnDefs
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [
* { "sWidth": "20%", "aTargets": [ 0 ] }
* ]
* } );
* } );
*
* @example
* // Using aoColumns
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "sWidth": "20%" },
* null,
* null,
* null,
* null
* ]
* } );
* } );
*/
"sWidth": null
};
/**
* DataTables settings object - this holds all the information needed for a
* given table, including configuration, data and current application of the
* table options. DataTables does not have a single instance for each DataTable
* with the settings attached to that instance, but rather instances of the
* DataTable "class" are created on-the-fly as needed (typically by a
* $().dataTable() call) and the settings object is then applied to that
* instance.
*
* Note that this object is related to {@link DataTable.defaults} but this
* one is the internal data store for DataTables's cache of columns. It should
* NOT be manipulated outside of DataTables. Any configuration should be done
* through the initialisation options.
* @namespace
* @todo Really should attach the settings object to individual instances so we
* don't need to create new instances on each $().dataTable() call (if the
* table already exists). It would also save passing oSettings around and
* into every single function. However, this is a very significant
* architecture change for DataTables and will almost certainly break
* backwards compatibility with older installations. This is something that
* will be done in 2.0.
*/
DataTable.models.oSettings = {
/**
* Primary features of DataTables and their enablement state.
* @namespace
*/
"oFeatures": {
/**
* Flag to say if DataTables should automatically try to calculate the
* optimum table and columns widths (true) or not (false).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bAutoWidth": null,
/**
* Delay the creation of TR and TD elements until they are actually
* needed by a driven page draw. This can give a significant speed
* increase for Ajax source and Javascript source data, but makes no
* difference at all fro DOM and server-side processing tables.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bDeferRender": null,
/**
* Enable filtering on the table or not. Note that if this is disabled
* then there is no filtering at all on the table, including fnFilter.
* To just remove the filtering input use sDom and remove the 'f' option.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bFilter": null,
/**
* Table information element (the 'Showing x of y records' div) enable
* flag.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bInfo": null,
/**
* Present a user control allowing the end user to change the page size
* when pagination is enabled.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bLengthChange": null,
/**
* Pagination enabled or not. Note that if this is disabled then length
* changing must also be disabled.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bPaginate": null,
/**
* Processing indicator enable flag whenever DataTables is enacting a
* user request - typically an Ajax request for server-side processing.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bProcessing": null,
/**
* Server-side processing enabled flag - when enabled DataTables will
* get all data from the server for every draw - there is no filtering,
* sorting or paging done on the client-side.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bServerSide": null,
/**
* Sorting enablement flag.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bSort": null,
/**
* Apply a class to the columns which are being sorted to provide a
* visual highlight or not. This can slow things down when enabled since
* there is a lot of DOM interaction.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bSortClasses": null,
/**
* State saving enablement flag.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bStateSave": null
},
/**
* Scrolling settings for a table.
* @namespace
*/
"oScroll": {
/**
* Indicate if DataTables should be allowed to set the padding / margin
* etc for the scrolling header elements or not. Typically you will want
* this.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bAutoCss": null,
/**
* When the table is shorter in height than sScrollY, collapse the
* table container down to the height of the table (when true).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bCollapse": null,
/**
* Infinite scrolling enablement flag. Now deprecated in favour of
* using the Scroller plug-in.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bInfinite": null,
/**
* Width of the scrollbar for the web-browser's platform. Calculated
* during table initialisation.
* @type int
* @default 0
*/
"iBarWidth": 0,
/**
* Space (in pixels) between the bottom of the scrolling container and
* the bottom of the scrolling viewport before the next page is loaded
* when using infinite scrolling.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type int
*/
"iLoadGap": null,
/**
* Viewport width for horizontal scrolling. Horizontal scrolling is
* disabled if an empty string.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
*/
"sX": null,
/**
* Width to expand the table to when using x-scrolling. Typically you
* should not need to use this.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
* @deprecated
*/
"sXInner": null,
/**
* Viewport height for vertical scrolling. Vertical scrolling is disabled
* if an empty string.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
*/
"sY": null
},
/**
* Language information for the table.
* @namespace
* @extends DataTable.defaults.oLanguage
*/
"oLanguage": {
/**
* Information callback function. See
* {@link DataTable.defaults.fnInfoCallback}
* @type function
* @default
*/
"fnInfoCallback": null
},
/**
* Array referencing the nodes which are used for the features. The
* parameters of this object match what is allowed by sDom - i.e.
*
*
'l' - Length changing
*
'f' - Filtering input
*
't' - The table!
*
'i' - Information
*
'p' - Pagination
*
'r' - pRocessing
*
* @type array
* @default []
*/
"aanFeatures": [],
/**
* Store data information - see {@link DataTable.models.oRow} for detailed
* information.
* @type array
* @default []
*/
"aoData": [],
/**
* Array of indexes which are in the current display (after filtering etc)
* @type array
* @default []
*/
"aiDisplay": [],
/**
* Array of indexes for display - no filtering
* @type array
* @default []
*/
"aiDisplayMaster": [],
/**
* Store information about each column that is in use
* @type array
* @default []
*/
"aoColumns": [],
/**
* Store information about the table's header
* @type array
* @default []
*/
"aoHeader": [],
/**
* Store information about the table's footer
* @type array
* @default []
*/
"aoFooter": [],
/**
* Search data array for regular expression searching
* @type array
* @default []
*/
"asDataSearch": [],
/**
* Store the applied global search information in case we want to force a
* research or compare the old search to a new one.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @namespace
* @extends DataTable.models.oSearch
*/
"oPreviousSearch": {},
/**
* Store the applied search for each column - see
* {@link DataTable.models.oSearch} for the format that is used for the
* filtering information for each column.
* @type array
* @default []
*/
"aoPreSearchCols": [],
/**
* Sorting that is applied to the table. Note that the inner arrays are
* used in the following manner:
*
*
Index 0 - column number
*
Index 1 - current sorting direction
*
Index 2 - index of asSorting for this column
*
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type array
* @todo These inner arrays should really be objects
*/
"aaSorting": null,
/**
* Sorting that is always applied to the table (i.e. prefixed in front of
* aaSorting).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type array|null
* @default null
*/
"aaSortingFixed": null,
/**
* Classes to use for the striping of a table.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type array
* @default []
*/
"asStripeClasses": null,
/**
* If restoring a table - we should restore its striping classes as well
* @type array
* @default []
*/
"asDestroyStripes": [],
/**
* If restoring a table - we should restore its width
* @type int
* @default 0
*/
"sDestroyWidth": 0,
/**
* Callback functions array for every time a row is inserted (i.e. on a draw).
* @type array
* @default []
*/
"aoRowCallback": [],
/**
* Callback functions for the header on each draw.
* @type array
* @default []
*/
"aoHeaderCallback": [],
/**
* Callback function for the footer on each draw.
* @type array
* @default []
*/
"aoFooterCallback": [],
/**
* Array of callback functions for draw callback functions
* @type array
* @default []
*/
"aoDrawCallback": [],
/**
* Array of callback functions for row created function
* @type array
* @default []
*/
"aoRowCreatedCallback": [],
/**
* Callback functions for just before the table is redrawn. A return of
* false will be used to cancel the draw.
* @type array
* @default []
*/
"aoPreDrawCallback": [],
/**
* Callback functions for when the table has been initialised.
* @type array
* @default []
*/
"aoInitComplete": [],
/**
* Callbacks for modifying the settings to be stored for state saving, prior to
* saving state.
* @type array
* @default []
*/
"aoStateSaveParams": [],
/**
* Callbacks for modifying the settings that have been stored for state saving
* prior to using the stored values to restore the state.
* @type array
* @default []
*/
"aoStateLoadParams": [],
/**
* Callbacks for operating on the settings object once the saved state has been
* loaded
* @type array
* @default []
*/
"aoStateLoaded": [],
/**
* Cache the table ID for quick access
* @type string
* @default Empty string
*/
"sTableId": "",
/**
* The TABLE node for the main table
* @type node
* @default null
*/
"nTable": null,
/**
* Permanent ref to the thead element
* @type node
* @default null
*/
"nTHead": null,
/**
* Permanent ref to the tfoot element - if it exists
* @type node
* @default null
*/
"nTFoot": null,
/**
* Permanent ref to the tbody element
* @type node
* @default null
*/
"nTBody": null,
/**
* Cache the wrapper node (contains all DataTables controlled elements)
* @type node
* @default null
*/
"nTableWrapper": null,
/**
* Indicate if when using server-side processing the loading of data
* should be deferred until the second draw.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
* @default false
*/
"bDeferLoading": false,
/**
* Indicate if all required information has been read in
* @type boolean
* @default false
*/
"bInitialised": false,
/**
* Information about open rows. Each object in the array has the parameters
* 'nTr' and 'nParent'
* @type array
* @default []
*/
"aoOpenRows": [],
/**
* Dictate the positioning of DataTables' control elements - see
* {@link DataTable.model.oInit.sDom}.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
* @default null
*/
"sDom": null,
/**
* Which type of pagination should be used.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
* @default two_button
*/
"sPaginationType": "two_button",
/**
* The cookie duration (for bStateSave) in seconds.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type int
* @default 0
*/
"iCookieDuration": 0,
/**
* The cookie name prefix.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
* @default Empty string
*/
"sCookiePrefix": "",
/**
* Callback function for cookie creation.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type function
* @default null
*/
"fnCookieCallback": null,
/**
* Array of callback functions for state saving. Each array element is an
* object with the following parameters:
*
*
function:fn - function to call. Takes two parameters, oSettings
* and the JSON string to save that has been thus far created. Returns
* a JSON string to be inserted into a json object
* (i.e. '"param": [ 0, 1, 2]')
*
string:sName - name of callback
*
* @type array
* @default []
*/
"aoStateSave": [],
/**
* Array of callback functions for state loading. Each array element is an
* object with the following parameters:
*
*
function:fn - function to call. Takes two parameters, oSettings
* and the object stored. May return false to cancel state loading
*
string:sName - name of callback
*
* @type array
* @default []
*/
"aoStateLoad": [],
/**
* State that was loaded from the cookie. Useful for back reference
* @type object
* @default null
*/
"oLoadedState": null,
/**
* Source url for AJAX data for the table.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
* @default null
*/
"sAjaxSource": null,
/**
* Property from a given object from which to read the table data from. This
* can be an empty string (when not server-side processing), in which case
* it is assumed an an array is given directly.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
*/
"sAjaxDataProp": null,
/**
* Note if draw should be blocked while getting data
* @type boolean
* @default true
*/
"bAjaxDataGet": true,
/**
* The last jQuery XHR object that was used for server-side data gathering.
* This can be used for working with the XHR information in one of the
* callbacks
* @type object
* @default null
*/
"jqXHR": null,
/**
* Function to get the server-side data.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type function
*/
"fnServerData": null,
/**
* Functions which are called prior to sending an Ajax request so extra
* parameters can easily be sent to the server
* @type array
* @default []
*/
"aoServerParams": [],
/**
* Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
* required).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type string
*/
"sServerMethod": null,
/**
* Format numbers for display.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type function
*/
"fnFormatNumber": null,
/**
* List of options that can be used for the user selectable length menu.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type array
* @default []
*/
"aLengthMenu": null,
/**
* Counter for the draws that the table does. Also used as a tracker for
* server-side processing
* @type int
* @default 0
*/
"iDraw": 0,
/**
* Indicate if a redraw is being done - useful for Ajax
* @type boolean
* @default false
*/
"bDrawing": false,
/**
* Draw index (iDraw) of the last error when parsing the returned data
* @type int
* @default -1
*/
"iDrawError": -1,
/**
* Paging display length
* @type int
* @default 10
*/
"_iDisplayLength": 10,
/**
* Paging start point - aiDisplay index
* @type int
* @default 0
*/
"_iDisplayStart": 0,
/**
* Paging end point - aiDisplay index. Use fnDisplayEnd rather than
* this property to get the end point
* @type int
* @default 10
* @private
*/
"_iDisplayEnd": 10,
/**
* Server-side processing - number of records in the result set
* (i.e. before filtering), Use fnRecordsTotal rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
* @type int
* @default 0
* @private
*/
"_iRecordsTotal": 0,
/**
* Server-side processing - number of records in the current display set
* (i.e. after filtering). Use fnRecordsDisplay rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
* @type boolean
* @default 0
* @private
*/
"_iRecordsDisplay": 0,
/**
* Flag to indicate if jQuery UI marking and classes should be used.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bJUI": null,
/**
* The classes to use for the table
* @type object
* @default {}
*/
"oClasses": {},
/**
* Flag attached to the settings object so you can check in the draw
* callback if filtering has been done in the draw. Deprecated in favour of
* events.
* @type boolean
* @default false
* @deprecated
*/
"bFiltered": false,
/**
* Flag attached to the settings object so you can check in the draw
* callback if sorting has been done in the draw. Deprecated in favour of
* events.
* @type boolean
* @default false
* @deprecated
*/
"bSorted": false,
/**
* Indicate that if multiple rows are in the header and there is more than
* one unique cell per column, if the top one (true) or bottom one (false)
* should be used for sorting / title by DataTables.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
* @type boolean
*/
"bSortCellsTop": null,
/**
* Initialisation object that is used for the table
* @type object
* @default null
*/
"oInit": null,
/**
* Destroy callback functions - for plug-ins to attach themselves to the
* destroy so they can clean up markup and events.
* @type array
* @default []
*/
"aoDestroyCallback": [],
/**
* Get the number of records in the current record set, before filtering
* @type function
*/
"fnRecordsTotal": function ()
{
if ( this.oFeatures.bServerSide ) {
return parseInt(this._iRecordsTotal, 10);
} else {
return this.aiDisplayMaster.length;
}
},
/**
* Get the number of records in the current record set, after filtering
* @type function
*/
"fnRecordsDisplay": function ()
{
if ( this.oFeatures.bServerSide ) {
return parseInt(this._iRecordsDisplay, 10);
} else {
return this.aiDisplay.length;
}
},
/**
* Set the display end point - aiDisplay index
* @type function
* @todo Should do away with _iDisplayEnd and calculate it on-the-fly here
*/
"fnDisplayEnd": function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
return this._iDisplayEnd;
}
},
/**
* The DataTables object for this table
* @type object
* @default null
*/
"oInstance": null,
/**
* Unique identifier for each instance of the DataTables object. If there
* is an ID on the table node, then it takes that value, otherwise an
* incrementing internal counter is used.
* @type string
* @default null
*/
"sInstance": null,
/**
* tabindex attribute value that is added to DataTables control elements, allowing
* keyboard navigation of the table and its controls.
*/
"iTabIndex": 0
};
/**
* Extension object for DataTables that is used to provide all extension options.
*
* Note that the DataTable.ext object is available through
* jQuery.fn.dataTable.ext where it may be accessed and manipulated. It is
* also aliased to jQuery.fn.dataTableExt for historic reasons.
* @namespace
* @extends DataTable.models.ext
*/
DataTable.ext = $.extend( true, {}, DataTable.models.ext );
$.extend( DataTable.ext.oStdClasses, {
"sTable": "dataTable",
/* Two buttons buttons */
"sPagePrevEnabled": "paginate_enabled_previous",
"sPagePrevDisabled": "paginate_disabled_previous",
"sPageNextEnabled": "paginate_enabled_next",
"sPageNextDisabled": "paginate_disabled_next",
"sPageJUINext": "",
"sPageJUIPrev": "",
/* Full numbers paging buttons */
"sPageButton": "paginate_button",
"sPageButtonActive": "paginate_active",
"sPageButtonStaticDisabled": "paginate_button paginate_button_disabled",
"sPageFirst": "first",
"sPagePrevious": "previous",
"sPageNext": "next",
"sPageLast": "last",
/* Striping classes */
"sStripeOdd": "odd",
"sStripeEven": "even",
/* Empty row */
"sRowEmpty": "dataTables_empty",
/* Features */
"sWrapper": "dataTables_wrapper",
"sFilter": "dataTables_filter",
"sInfo": "dataTables_info",
"sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
"sLength": "dataTables_length",
"sProcessing": "dataTables_processing",
/* Sorting */
"sSortAsc": "sorting_asc",
"sSortDesc": "sorting_desc",
"sSortable": "sorting", /* Sortable in both directions */
"sSortableAsc": "sorting_asc_disabled",
"sSortableDesc": "sorting_desc_disabled",
"sSortableNone": "sorting_disabled",
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
"sSortJUIAsc": "",
"sSortJUIDesc": "",
"sSortJUI": "",
"sSortJUIAscAllowed": "",
"sSortJUIDescAllowed": "",
"sSortJUIWrapper": "",
"sSortIcon": "",
/* Scrolling */
"sScrollWrapper": "dataTables_scroll",
"sScrollHead": "dataTables_scrollHead",
"sScrollHeadInner": "dataTables_scrollHeadInner",
"sScrollBody": "dataTables_scrollBody",
"sScrollFoot": "dataTables_scrollFoot",
"sScrollFootInner": "dataTables_scrollFootInner",
/* Misc */
"sFooterTH": ""
} );
$.extend( DataTable.ext.oJUIClasses, DataTable.ext.oStdClasses, {
/* Two buttons buttons */
"sPagePrevEnabled": "fg-button ui-button ui-state-default ui-corner-left",
"sPagePrevDisabled": "fg-button ui-button ui-state-default ui-corner-left ui-state-disabled",
"sPageNextEnabled": "fg-button ui-button ui-state-default ui-corner-right",
"sPageNextDisabled": "fg-button ui-button ui-state-default ui-corner-right ui-state-disabled",
"sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
"sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
/* Full numbers paging buttons */
"sPageButton": "fg-button ui-button ui-state-default",
"sPageButtonActive": "fg-button ui-button ui-state-default ui-state-disabled",
"sPageButtonStaticDisabled": "fg-button ui-button ui-state-default ui-state-disabled",
"sPageFirst": "first ui-corner-tl ui-corner-bl",
"sPageLast": "last ui-corner-tr ui-corner-br",
/* Features */
"sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
"ui-buttonset-multi paging_", /* Note that the type is postfixed */
/* Sorting */
"sSortAsc": "ui-state-default",
"sSortDesc": "ui-state-default",
"sSortable": "ui-state-default",
"sSortableAsc": "ui-state-default",
"sSortableDesc": "ui-state-default",
"sSortableNone": "ui-state-default",
"sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
"sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
"sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
"sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
"sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s",
"sSortJUIWrapper": "DataTables_sort_wrapper",
"sSortIcon": "DataTables_sort_icon",
/* Scrolling */
"sScrollHead": "dataTables_scrollHead ui-state-default",
"sScrollFoot": "dataTables_scrollFoot ui-state-default",
/* Misc */
"sFooterTH": "ui-state-default"
} );
/*
* Variable: oPagination
* Purpose:
* Scope: jQuery.fn.dataTableExt
*/
$.extend( DataTable.ext.oPagination, {
/*
* Variable: two_button
* Purpose: Standard two button (forward/back) pagination
* Scope: jQuery.fn.dataTableExt.oPagination
*/
"two_button": {
/*
* Function: oPagination.two_button.fnInit
* Purpose: Initialise dom elements required for pagination with forward/back buttons only
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* node:nPaging - the DIV which contains this pagination control
* function:fnCallbackDraw - draw function which must be called on update
*/
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
{
var oLang = oSettings.oLanguage.oPaginate;
var oClasses = oSettings.oClasses;
var fnClickHandler = function ( e ) {
if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
{
fnCallbackDraw( oSettings );
}
};
var sAppend = (!oSettings.bJUI) ?
''+oLang.sPrevious+''+
''+oLang.sNext+''
:
''+
'';
$(nPaging).append( sAppend );
var els = $('a', nPaging);
var nPrevious = els[0],
nNext = els[1];
oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, fnClickHandler );
oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
/* ID the first elements only */
if ( !oSettings.aanFeatures.p )
{
nPaging.id = oSettings.sTableId+'_paginate';
nPrevious.id = oSettings.sTableId+'_previous';
nNext.id = oSettings.sTableId+'_next';
nPrevious.setAttribute('aria-controls', oSettings.sTableId);
nNext.setAttribute('aria-controls', oSettings.sTableId);
}
},
/*
* Function: oPagination.two_button.fnUpdate
* Purpose: Update the two button pagination at the end of the draw
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* function:fnCallbackDraw - draw function to call on page change
*/
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.aanFeatures.p )
{
return;
}
var oClasses = oSettings.oClasses;
var an = oSettings.aanFeatures.p;
/* Loop over each instance of the pager */
for ( var i=0, iLen=an.length ; i'+oLang.sFirst+''+
''+oLang.sPrevious+''+
''+
''+oLang.sNext+''+
''+oLang.sLast+''
);
var els = $('a', nPaging);
var nFirst = els[0],
nPrev = els[1],
nNext = els[2],
nLast = els[3];
oSettings.oApi._fnBindAction( nFirst, {action: "first"}, fnClickHandler );
oSettings.oApi._fnBindAction( nPrev, {action: "previous"}, fnClickHandler );
oSettings.oApi._fnBindAction( nNext, {action: "next"}, fnClickHandler );
oSettings.oApi._fnBindAction( nLast, {action: "last"}, fnClickHandler );
/* ID the first elements only */
if ( !oSettings.aanFeatures.p )
{
nPaging.id = oSettings.sTableId+'_paginate';
nFirst.id =oSettings.sTableId+'_first';
nPrev.id =oSettings.sTableId+'_previous';
nNext.id =oSettings.sTableId+'_next';
nLast.id =oSettings.sTableId+'_last';
}
},
/*
* Function: oPagination.full_numbers.fnUpdate
* Purpose: Update the list of page buttons shows
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* function:fnCallbackDraw - draw function to call on page change
*/
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.aanFeatures.p )
{
return;
}
var iPageCount = DataTable.ext.oPagination.iFullNumbersShowPages;
var iPageCountHalf = Math.floor(iPageCount / 2);
var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
var sList = "";
var iStartButton, iEndButton, i, iLen;
var oClasses = oSettings.oClasses;
var anButtons, anStatic, nPaginateList;
var an = oSettings.aanFeatures.p;
var fnBind = function (j) {
oSettings.oApi._fnBindAction( this, {"page": j+iStartButton-1}, function(e) {
/* Use the information in the element to jump to the required page */
oSettings.oApi._fnPageChange( oSettings, e.data.page );
fnCallbackDraw( oSettings );
e.preventDefault();
} );
};
/* Pages calculation */
if (iPages < iPageCount)
{
iStartButton = 1;
iEndButton = iPages;
}
else if (iCurrentPage <= iPageCountHalf)
{
iStartButton = 1;
iEndButton = iPageCount;
}
else if (iCurrentPage >= (iPages - iPageCountHalf))
{
iStartButton = iPages - iPageCount + 1;
iEndButton = iPages;
}
else
{
iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
iEndButton = iStartButton + iPageCount - 1;
}
/* Build the dynamic list */
for ( i=iStartButton ; i<=iEndButton ; i++ )
{
sList += (iCurrentPage !== i) ?
''+oSettings.fnFormatNumber(i)+'' :
''+oSettings.fnFormatNumber(i)+'';
}
/* Loop over each instance of the pager */
for ( i=0, iLen=an.length ; i y) ? 1 : 0));
},
"string-desc": function ( x, y )
{
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* html sorting (ignore html tags)
*/
"html-pre": function ( a )
{
return a.replace( /<.*?>/g, "" ).toLowerCase();
},
"html-asc": function ( x, y )
{
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
},
"html-desc": function ( x, y )
{
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* date sorting
*/
"date-pre": function ( a )
{
var x = Date.parse( a );
if ( isNaN(x) || x==="" )
{
x = Date.parse( "01/01/1970 00:00:00" );
}
return x;
},
"date-asc": function ( x, y )
{
return x - y;
},
"date-desc": function ( x, y )
{
return y - x;
},
/*
* numerical sorting
*/
"numeric-pre": function ( a )
{
return (a=="-" || a==="") ? 0 : a*1;
},
"numeric-asc": function ( x, y )
{
return x - y;
},
"numeric-desc": function ( x, y )
{
return y - x;
}
} );
$.extend( DataTable.ext.aTypes, [
/*
* Function: -
* Purpose: Check to see if a string is numeric
* Returns: string:'numeric' or null
* Inputs: mixed:sText - string to check
*/
function ( sData )
{
/* Allow zero length strings as a number */
if ( typeof sData === 'number' )
{
return 'numeric';
}
else if ( typeof sData !== 'string' )
{
return null;
}
var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;
/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1)
{
return null;
}
/* Check all the other characters are valid */
for ( var i=1 ; i') != -1 )
{
return 'html';
}
return null;
}
] );
// jQuery aliases
$.fn.DataTable = DataTable;
$.fn.dataTable = DataTable;
$.fn.dataTableSettings = DataTable.settings;
$.fn.dataTableExt = DataTable.ext;
// Information about events fired by DataTables - for documentation.
/**
* Draw event, fired whenever the table is redrawn on the page, at the same point as
* fnDrawCallback. This may be useful for binding events or performing calculations when
* the table is altered at all.
* @name DataTable#draw
* @event
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* Filter event, fired when the filtering applied to the table (using the build in global
* global filter, or column filters) is altered.
* @name DataTable#filter
* @event
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* Page change event, fired when the paging of the table is altered.
* @name DataTable#page
* @event
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* Sort event, fired when the sorting applied to the table is altered.
* @name DataTable#sort
* @event
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* DataTables initialisation complete event, fired when the table is fully drawn,
* including Ajax data loaded, if Ajax data is required.
* @name DataTable#init
* @event
* @param {event} e jQuery event object
* @param {object} oSettings DataTables settings object
* @param {object} json The JSON object request from the server - only
* present if client-side Ajax sourced data is used
*/
/**
* State save event, fired when the table has changed state a new state save is required.
* This method allows modification of the state saving object prior to actually doing the
* save, including addition or other state properties (for plug-ins) or modification
* of a DataTables core property.
* @name DataTable#stateSaveParams
* @event
* @param {event} e jQuery event object
* @param {object} oSettings DataTables settings object
* @param {object} json The state information to be saved
*/
/**
* State load event, fired when the table is loading state from the stored data, but
* prior to the settings object being modified by the saved state - allowing modification
* of the saved state is required or loading of state for a plug-in.
* @name DataTable#stateLoadParams
* @event
* @param {event} e jQuery event object
* @param {object} oSettings DataTables settings object
* @param {object} json The saved state information
*/
/**
* State loaded event, fired when state has been loaded from stored data and the settings
* object has been modified by the loaded data.
* @name DataTable#stateLoaded
* @event
* @param {event} e jQuery event object
* @param {object} oSettings DataTables settings object
* @param {object} json The saved state information
*/
/**
* Processing event, fired when DataTables is doing some kind of processing (be it,
* sort, filter or anything else). Can be used to indicate to the end user that
* there is something happening, or that something has finished.
* @name DataTable#processing
* @event
* @param {event} e jQuery event object
* @param {object} oSettings DataTables settings object
* @param {boolean} bShow Flag for if DataTables is doing processing or not
*/
/**
* Ajax (XHR) event, fired whenever an Ajax request is completed from a request to
* made to the server for new data (note that this trigger is called in fnServerData,
* if you override fnServerData and which to use this event, you need to trigger it in
* you success function).
* @name DataTable#xhr
* @event
* @param {event} e jQuery event object
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
}(jQuery, window, document, undefined));
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
;(function($) {
var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,
selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
loadingTimer, loadingFrame = 1,
titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('')[0], { prop: 0 }),
isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
/*
* Private methods
*/
_abort = function() {
loading.hide();
imgPreloader.onerror = imgPreloader.onload = null;
if (ajaxLoader) {
ajaxLoader.abort();
}
tmp.empty();
},
_error = function() {
if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
loading.hide();
busy = false;
return;
}
selectedOpts.titleShow = false;
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
tmp.html( '
The requested content cannot be loaded. Please try again later.