1 |
// DATA_TEMPLATE: dom_data |
2 |
oTest.fnStart( "oLanguage.sLengthMenu" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
var oTable = $('#example').dataTable(); |
7 |
var oSettings = oTable.fnSettings(); |
8 |
|
9 |
oTest.fnTest( |
10 |
"Menu language is 'Show _MENU_ entries' by default", |
11 |
null, |
12 |
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; } |
13 |
); |
14 |
|
15 |
oTest.fnTest( |
16 |
"_MENU_ macro is replaced by select menu in DOM", |
17 |
null, |
18 |
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 } |
19 |
); |
20 |
|
21 |
oTest.fnTest( |
22 |
"A label input is used", |
23 |
null, |
24 |
function () { return $('label', oSettings.aanFeatures.l[0]).length == 1 } |
25 |
); |
26 |
|
27 |
oTest.fnTest( |
28 |
"Default is put into DOM", |
29 |
null, |
30 |
function () { |
31 |
var anChildren = $('label',oSettings.aanFeatures.l[0])[0].childNodes; |
32 |
var bReturn = |
33 |
anChildren[0].nodeValue == "Show " && |
34 |
anChildren[2].nodeValue == " entries"; |
35 |
return bReturn; |
36 |
} |
37 |
); |
38 |
|
39 |
|
40 |
oTest.fnTest( |
41 |
"Menu length language can be defined - no _MENU_ macro", |
42 |
function () { |
43 |
oSession.fnRestore(); |
44 |
oTable = $('#example').dataTable( { |
45 |
"oLanguage": { |
46 |
"sLengthMenu": "unit test" |
47 |
} |
48 |
} ); |
49 |
oSettings = oTable.fnSettings(); |
50 |
}, |
51 |
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; } |
52 |
); |
53 |
|
54 |
oTest.fnTest( |
55 |
"Menu length language definition is in the DOM", |
56 |
null, |
57 |
function () { |
58 |
return $('label', oSettings.aanFeatures.l[0]).text() == "unit test"; |
59 |
} |
60 |
); |
61 |
|
62 |
|
63 |
oTest.fnTest( |
64 |
"Menu length language can be defined - with _MENU_ macro", |
65 |
function () { |
66 |
oSession.fnRestore(); |
67 |
oTable = $('#example').dataTable( { |
68 |
"oLanguage": { |
69 |
"sLengthMenu": "unit _MENU_ test" |
70 |
} |
71 |
} ); |
72 |
oSettings = oTable.fnSettings(); |
73 |
}, |
74 |
function () { |
75 |
var anChildren = $('label',oSettings.aanFeatures.l[0])[0].childNodes; |
76 |
var bReturn = |
77 |
anChildren[0].nodeValue == "unit " && |
78 |
anChildren[2].nodeValue == " test"; |
79 |
return bReturn; |
80 |
} |
81 |
); |
82 |
|
83 |
|
84 |
oTest.fnTest( |
85 |
"Only the _MENU_ macro", |
86 |
function () { |
87 |
oSession.fnRestore(); |
88 |
oTable = $('#example').dataTable( { |
89 |
"oLanguage": { |
90 |
"sLengthMenu": "_MENU_" |
91 |
} |
92 |
} ); |
93 |
oSettings = oTable.fnSettings(); |
94 |
}, |
95 |
function () { |
96 |
var anChildren = oSettings.aanFeatures.l[0].childNodes; |
97 |
var bReturn = |
98 |
anChildren.length == 1 && |
99 |
$('select', oSettings.aanFeatures.l[0]).length == 1; |
100 |
return bReturn; |
101 |
} |
102 |
); |
103 |
|
104 |
|
105 |
oTest.fnComplete(); |
106 |
} ); |