(settings, selector, opts)
| 7817 | } |
| 7818 | |
| 7819 | var __column_selector = function (settings, selector, opts) { |
| 7820 | var columns = settings.aoColumns, |
| 7821 | names = _pluck(columns, "sName"), |
| 7822 | titles = _pluck(columns, "sTitle"), |
| 7823 | cells = DataTable.util.get("[].[].cell")(settings.aoHeader), |
| 7824 | nodes = _unique(_flatten([], cells)) |
| 7825 | |
| 7826 | var run = function (s) { |
| 7827 | var selInt = _intVal(s) |
| 7828 | |
| 7829 | // Selector - all |
| 7830 | if (s === "") { |
| 7831 | return _range(columns.length) |
| 7832 | } |
| 7833 | |
| 7834 | // Selector - index |
| 7835 | if (selInt !== null) { |
| 7836 | return [ |
| 7837 | selInt >= 0 |
| 7838 | ? selInt // Count from left |
| 7839 | : columns.length + selInt // Count from right (+ because its a negative value) |
| 7840 | ] |
| 7841 | } |
| 7842 | |
| 7843 | // Selector = function |
| 7844 | if (typeof s === "function") { |
| 7845 | var rows = _selector_row_indexes(settings, opts) |
| 7846 | |
| 7847 | return columns.map(function (col, idx) { |
| 7848 | return s(idx, __columnData(settings, idx, 0, 0, rows), __column_header(settings, idx)) ? idx : null |
| 7849 | }) |
| 7850 | } |
| 7851 | |
| 7852 | // jQuery or string selector |
| 7853 | var match = typeof s === "string" ? s.match(__re_column_selector) : "" |
| 7854 | |
| 7855 | if (match) { |
| 7856 | switch (match[2]) { |
| 7857 | case "visIdx": |
| 7858 | case "visible": |
| 7859 | // Selector is a column index |
| 7860 | if (match[1] && match[1].match(/^\d+$/)) { |
| 7861 | var idx = parseInt(match[1], 10) |
| 7862 | |
| 7863 | // Visible index given, convert to column index |
| 7864 | if (idx < 0) { |
| 7865 | // Counting from the right |
| 7866 | var visColumns = columns.map(function (col, i) { |
| 7867 | return col.bVisible ? i : null |
| 7868 | }) |
| 7869 | return [visColumns[visColumns.length + idx]] |
| 7870 | } |
| 7871 | // Counting from the left |
| 7872 | return [_fnVisibleToColumnIndex(settings, idx)] |
| 7873 | } |
| 7874 | |
| 7875 | return columns.map(function (col, idx) { |
| 7876 | // Not visible, can't match |
no test coverage detected