/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/src/core/core.info.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/src/core/core.info.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 2529 byte(s)
initial import
1
2 /**
3 * Generate the node required for the info display
4 * @param {object} oSettings dataTables settings object
5 * @returns {node} Information element
6 * @memberof DataTable#oApi
7 */
8 function _fnFeatureHtmlInfo ( oSettings )
9 {
10 var nInfo = document.createElement( 'div' );
11 nInfo.className = oSettings.oClasses.sInfo;
12
13 /* Actions that are to be taken once only for this feature */
14 if ( !oSettings.aanFeatures.i )
15 {
16 /* Add draw callback */
17 oSettings.aoDrawCallback.push( {
18 "fn": _fnUpdateInfo,
19 "sName": "information"
20 } );
21
22 /* Add id */
23 nInfo.id = oSettings.sTableId+'_info';
24 }
25 oSettings.nTable.setAttribute( 'aria-describedby', oSettings.sTableId+'_info' );
26
27 return nInfo;
28 }
29
30
31 /**
32 * Update the information elements in the display
33 * @param {object} oSettings dataTables settings object
34 * @memberof DataTable#oApi
35 */
36 function _fnUpdateInfo ( oSettings )
37 {
38 /* Show information about the table */
39 if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 )
40 {
41 return;
42 }
43
44 var
45 oLang = oSettings.oLanguage,
46 iStart = oSettings._iDisplayStart+1,
47 iEnd = oSettings.fnDisplayEnd(),
48 iMax = oSettings.fnRecordsTotal(),
49 iTotal = oSettings.fnRecordsDisplay(),
50 sOut;
51
52 if ( iTotal === 0 )
53 {
54 /* Empty record set */
55 sOut = oLang.sInfoEmpty;
56 }
57 else {
58 /* Normal record set */
59 sOut = oLang.sInfo;
60 }
61
62 if ( iTotal != iMax )
63 {
64 /* Record set after filtering */
65 sOut += ' ' + oLang.sInfoFiltered;
66 }
67
68 // Convert the macros
69 sOut += oLang.sInfoPostFix;
70 sOut = _fnInfoMacros( oSettings, sOut );
71
72 if ( oLang.fnInfoCallback !== null )
73 {
74 sOut = oLang.fnInfoCallback.call( oSettings.oInstance,
75 oSettings, iStart, iEnd, iMax, iTotal, sOut );
76 }
77
78 var n = oSettings.aanFeatures.i;
79 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
80 {
81 $(n[i]).html( sOut );
82 }
83 }
84
85
86 function _fnInfoMacros ( oSettings, str )
87 {
88 var
89 iStart = oSettings._iDisplayStart+1,
90 sStart = oSettings.fnFormatNumber( iStart ),
91 iEnd = oSettings.fnDisplayEnd(),
92 sEnd = oSettings.fnFormatNumber( iEnd ),
93 iTotal = oSettings.fnRecordsDisplay(),
94 sTotal = oSettings.fnFormatNumber( iTotal ),
95 iMax = oSettings.fnRecordsTotal(),
96 sMax = oSettings.fnFormatNumber( iMax );
97
98 // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
99 // internally
100 if ( oSettings.oScroll.bInfinite )
101 {
102 sStart = oSettings.fnFormatNumber( 1 );
103 }
104
105 return str.
106 replace(/_START_/g, sStart).
107 replace(/_END_/g, sEnd).
108 replace(/_TOTAL_/g, sTotal).
109 replace(/_MAX_/g, sMax);
110 }

  ViewVC Help
Powered by ViewVC 1.1.20