1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "Sanity checks for DataTables with data from JS - Object / sub-array data source" );
5 "jQuery.dataTable function",
7 function () { return typeof jQuery().dataTable == "function"; }
11 "jQuery.dataTableSettings storage array",
13 function () { return typeof jQuery().dataTableSettings == "object"; }
17 "jQuery.dataTableExt plugin object",
19 function () { return typeof jQuery().dataTableExt == "object"; }
22 $(document).ready( function () {
25 { "mData": "engine" },
26 { "mData": "browser" },
27 { "mData": "platform" },
28 { "mData": "details.0" },
29 { "mData": "details.1" }
34 "browser": "Internet Explorer 4.0",
35 "platform": "Win 95+",
43 "browser": "Internet Explorer 5.0",
44 "platform": "Win 95+",
52 "browser": "Internet Explorer 5.5",
53 "platform": "Win 95+",
61 "browser": "Internet Explorer 6",
62 "platform": "Win 98+",
70 "browser": "Internet Explorer 7",
71 "platform": "Win XP SP2+",
79 "browser": "AOL browser (AOL desktop)",
88 "browser": "Firefox 1.0",
89 "platform": "Win 98+ / OSX.2+",
97 "browser": "Firefox 1.5",
98 "platform": "Win 98+ / OSX.2+",
106 "browser": "Firefox 2.0",
107 "platform": "Win 98+ / OSX.2+",
115 "browser": "Firefox 3.0",
116 "platform": "Win 2k+ / OSX.3+",
124 "browser": "Camino 1.0",
125 "platform": "OSX.2+",
133 "browser": "Camino 1.5",
134 "platform": "OSX.3+",
142 "browser": "Netscape 7.2",
143 "platform": "Win 95+ / Mac OS 8.6-9.2",
151 "browser": "Netscape Browser 8",
152 "platform": "Win 98SE+",
160 "browser": "Netscape Navigator 9",
161 "platform": "Win 98+ / OSX.2+",
169 "browser": "Mozilla 1.0",
170 "platform": "Win 95+ / OSX.1+",
178 "browser": "Mozilla 1.1",
179 "platform": "Win 95+ / OSX.1+",
187 "browser": "Mozilla 1.2",
188 "platform": "Win 95+ / OSX.1+",
196 "browser": "Mozilla 1.3",
197 "platform": "Win 95+ / OSX.1+",
205 "browser": "Mozilla 1.4",
206 "platform": "Win 95+ / OSX.1+",
214 "browser": "Mozilla 1.5",
215 "platform": "Win 95+ / OSX.1+",
223 "browser": "Mozilla 1.6",
224 "platform": "Win 95+ / OSX.1+",
232 "browser": "Mozilla 1.7",
233 "platform": "Win 98+ / OSX.1+",
241 "browser": "Mozilla 1.8",
242 "platform": "Win 98+ / OSX.1+",
250 "browser": "Seamonkey 1.1",
251 "platform": "Win 98+ / OSX.2+",
259 "browser": "Epiphany 2.20",
268 "browser": "Safari 1.2",
277 "browser": "Safari 1.3",
286 "browser": "Safari 2.0",
287 "platform": "OSX.4+",
295 "browser": "Safari 3.0",
296 "platform": "OSX.4+",
304 "browser": "OmniWeb 5.5",
305 "platform": "OSX.4+",
313 "browser": "iPod Touch / iPhone",
331 "browser": "Opera 7.0",
332 "platform": "Win 95+ / OSX.1+",
340 "browser": "Opera 7.5",
341 "platform": "Win 95+ / OSX.2+",
349 "browser": "Opera 8.0",
350 "platform": "Win 95+ / OSX.2+",
358 "browser": "Opera 8.5",
359 "platform": "Win 95+ / OSX.2+",
367 "browser": "Opera 9.0",
368 "platform": "Win 95+ / OSX.3+",
376 "browser": "Opera 9.2",
377 "platform": "Win 88+ / OSX.3+",
385 "browser": "Opera 9.5",
386 "platform": "Win 88+ / OSX.3+",
394 "browser": "Opera for Wii",
403 "browser": "Nokia N800",
412 "browser": "Nintendo DS browser",
413 "platform": "Nintendo DS",
421 "browser": "Konqureror 3.1",
422 "platform": "KDE 3.1",
430 "browser": "Konqureror 3.3",
431 "platform": "KDE 3.3",
439 "browser": "Konqureror 3.5",
440 "platform": "KDE 3.5",
448 "browser": "Internet Explorer 4.5",
449 "platform": "Mac OS 8-9",
457 "browser": "Internet Explorer 5.1",
458 "platform": "Mac OS 7.6-9",
466 "browser": "Internet Explorer 5.2",
467 "platform": "Mac OS 8-X",
475 "browser": "NetFront 3.1",
476 "platform": "Embedded devices",
484 "browser": "NetFront 3.4",
485 "platform": "Embedded devices",
493 "browser": "Dillo 0.8",
494 "platform": "Embedded devices",
503 "platform": "Text only",
512 "platform": "Text only",
520 "browser": "IE Mobile",
521 "platform": "Windows Mobile 6",
529 "browser": "PSP browser",
537 "engine": "Other browsers",
538 "browser": "All others",
547 $('#example').dataTable( oInit );
551 "Length changing div exists",
553 function () { return document.getElementById('example_length') != null; }
557 "Filtering div exists",
559 function () { return document.getElementById('example_filter') != null; }
563 "Information div exists",
565 function () { return document.getElementById('example_info') != null; }
569 "Pagination div exists",
571 function () { return document.getElementById('example_paginate') != null; }
575 "Processing div is off by default",
577 function () { return document.getElementById('example_processing') == null; }
581 "10 rows shown on the first page",
583 function () { return $('#example tbody tr').length == 10; }
587 "Initial sort occured",
589 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
592 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
594 "Sorting (first click) on second column",
595 function () { $('#example thead th:eq(1)').click(); },
596 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
600 "Sorting (second click) on second column",
601 function () { $('#example thead th:eq(1)').click(); },
602 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
606 "Sorting (third click) on second column",
607 function () { $('#example thead th:eq(1)').click(); },
608 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
612 "Sorting (first click) on numeric column",
613 function () { $('#example thead th:eq(3)').click(); },
614 function () { return $('#example tbody td:eq(3)').html() == "-"; }
618 "Sorting (second click) on numeric column",
619 function () { $('#example thead th:eq(3)').click(); },
620 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
624 "Sorting multi-column (first click)",
626 $('#example thead th:eq(0)').click();
627 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
628 function () { var b =
629 $('#example tbody td:eq(0)').html() == "Gecko" &&
630 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
634 "Sorting multi-column - sorting second column only",
636 $('#example thead th:eq(1)').click(); },
637 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
642 "Paging to second page",
643 function () { $('#example_next').click(); },
644 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
648 "Paging to first page",
649 function () { $('#example_previous').click(); },
650 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
654 "Attempting to page back beyond the first page",
655 function () { $('#example_previous').click(); },
656 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
659 /* Changing length */
661 "Changing table length to 25 records",
662 function () { $("select[name=example_length]").val('25').change(); },
663 function () { return $('#example tbody tr').length == 25; }
667 "Changing table length to 50 records",
668 function () { $("select[name=example_length]").val('50').change(); },
669 function () { return $('#example tbody tr').length == 50; }
673 "Changing table length to 100 records",
674 function () { $("select[name=example_length]").val('100').change(); },
675 function () { return $('#example tbody tr').length == 57; }
679 "Changing table length to 10 records",
680 function () { $("select[name=example_length]").val('10').change(); },
681 function () { return $('#example tbody tr').length == 10; }
685 * Information element
688 "Information on zero config",
690 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
694 "Information on second page",
695 function () { $('#example_next').click(); },
696 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
700 "Information on third page",
701 function () { $('#example_next').click(); },
702 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
706 "Information on last page",
708 $('#example_next').click();
709 $('#example_next').click();
710 $('#example_next').click();
712 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
716 "Information back on first page",
718 $('#example_previous').click();
719 $('#example_previous').click();
720 $('#example_previous').click();
721 $('#example_previous').click();
722 $('#example_previous').click();
724 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
728 "Information with 25 records",
729 function () { $("select[name=example_length]").val('25').change(); },
730 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
734 "Information with 25 records - second page",
735 function () { $('#example_next').click(); },
736 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
740 "Information with 100 records - first page",
742 $('#example_previous').click();
743 $("select[name=example_length]").val('100').change();
745 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
749 "Information back to 10 records",
751 $('#example_previous').click();
752 $("select[name=example_length]").val('10').change();
754 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
758 "Information with filter 'Win'",
759 function () { $('#example_filter input').val("Win").keyup(); },
760 function () { return document.getElementById('example_info').innerHTML ==
761 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
765 "Information with filter 'Win' second page",
766 function () { $('#example_next').click(); },
767 function () { return document.getElementById('example_info').innerHTML ==
768 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
772 "Information with filter 'Win' last page",
774 $('#example_next').click();
775 $('#example_next').click();
777 function () { return document.getElementById('example_info').innerHTML ==
778 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
782 "Information with filter 'Win' back to first page",
784 $('#example_previous').click();
785 $('#example_previous').click();
786 $('#example_previous').click();
788 function () { return document.getElementById('example_info').innerHTML ==
789 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
793 "Information with filter 'Win' second page - second time",
795 $('#example_next').click();
797 function () { return document.getElementById('example_info').innerHTML ==
798 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
802 "Information with filter increased to 'Win 98'",
803 function () { $('#example_filter input').val("Win 98").keyup(); },
804 function () { return document.getElementById('example_info').innerHTML ==
805 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
809 "Information with filter decreased to 'Win'",
810 function () { $('#example_filter input').val("Win").keyup(); },
811 function () { return document.getElementById('example_info').innerHTML ==
812 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
816 "Information with filter 'Win' second page - third time",
818 $('#example_next').click();
820 function () { return document.getElementById('example_info').innerHTML ==
821 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
825 "Information with filter removed",
826 function () { $('#example_filter input').val("").keyup(); },
827 function () { return document.getElementById('example_info').innerHTML ==
828 "Showing 1 to 10 of 57 entries"; }
838 /* Reset the table such that the old sorting doesn't mess things up */
839 oSession.fnRestore();
840 $('#example').dataTable( oInit );
841 $('#example_filter input').val("W").keyup(); },
842 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
848 function () { return document.getElementById('example_info').innerHTML ==
849 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
854 function () { $('#example_filter input').val("Wi").keyup(); },
855 function () { return document.getElementById('example_info').innerHTML ==
856 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
861 function () { $('#example_filter input').val("Win").keyup(); },
862 function () { return document.getElementById('example_info').innerHTML ==
863 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
867 "Filter 'Win' - sorting column 1",
868 function () { $('#example thead th:eq(1)').click(); },
869 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
873 "Filter 'Win' - sorting column 1 info",
875 function () { return document.getElementById('example_info').innerHTML ==
876 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
880 "Filter 'Win' - sorting column 1 reverse",
881 function () { $('#example thead th:eq(1)').click(); },
882 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
886 "Filter 'Win XP' - maintaing reverse sorting col 1",
887 function () { $('#example_filter input').val("Win XP").keyup(); },
888 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
892 "Filter 'Win XP' - sorting col 3",
893 function () { $('#example thead th:eq(3)').click(); },
894 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
898 "Filter 'Win XP' - sorting col 3 - reversed",
899 function () { $('#example thead th:eq(3)').click(); },
900 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
904 "Filter 'Win' - sorting col 3 - reversed info",
906 function () { return document.getElementById('example_info').innerHTML ==
907 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
911 "Filter 'nothinghere'",
912 function () { $('#example_filter input').val("nothinghere").keyup(); },
913 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
914 "No matching records found"; }
918 "Filter 'nothinghere' - info",
920 function () { return document.getElementById('example_info').innerHTML ==
921 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
925 "Filter back to blank and 1st column sorting",
927 $('#example_filter input').val("").keyup();
928 $('#example thead th:eq(0)').click();
930 function () { return document.getElementById('example_info').innerHTML ==
931 "Showing 1 to 10 of 57 entries"; }
935 "Prefixing a filter entry",
937 $('#example_filter input').val("Win").keyup();
938 $('#example_filter input').val("GeckoWin").keyup();
940 function () { return document.getElementById('example_info').innerHTML ==
941 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
945 "Prefixing a filter entry with space",
947 $('#example_filter input').val("Gecko Win").keyup();
949 function () { return document.getElementById('example_info').innerHTML ==
950 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }