* Get the width for a given set of columns * * @param {*} settings DataTables settings object * @param {*} targets Columns - comma separated string or array of numbers * @param {*} original Use the original width (true) or calculated (false) * @param {*} incVisible Include visible columns
(settings, targets, original, incVisible)
| 2368 | * @returns Combined CSS value |
| 2369 | */ |
| 2370 | function _fnColumnsSumWidth(settings, targets, original, incVisible) { |
| 2371 | if (!Array.isArray(targets)) { |
| 2372 | targets = _fnColumnsFromHeader(targets) |
| 2373 | } |
| 2374 | |
| 2375 | var sum = 0 |
| 2376 | var unit |
| 2377 | var columns = settings.aoColumns |
| 2378 | |
| 2379 | for (var i = 0, ien = targets.length; i < ien; i++) { |
| 2380 | var column = columns[targets[i]] |
| 2381 | var definedWidth = original ? column.sWidthOrig : column.sWidth |
| 2382 | |
| 2383 | if (!incVisible && column.bVisible === false) { |
| 2384 | continue |
| 2385 | } |
| 2386 | |
| 2387 | if (definedWidth === null || definedWidth === undefined) { |
| 2388 | return null // can't determine a defined width - browser defined |
| 2389 | } else if (typeof definedWidth === "number") { |
| 2390 | unit = "px" |
| 2391 | sum += definedWidth |
| 2392 | } else { |
| 2393 | var matched = definedWidth.match(/([\d\.]+)([^\d]*)/) |
| 2394 | |
| 2395 | if (matched) { |
| 2396 | sum += matched[1] * 1 |
| 2397 | unit = matched.length === 3 ? matched[2] : "px" |
| 2398 | } |
| 2399 | } |
| 2400 | } |
| 2401 | |
| 2402 | return sum + unit |
| 2403 | } |
| 2404 | |
| 2405 | function _fnColumnsFromHeader(cell) { |
| 2406 | var attr = $(cell).closest("[data-dt-column]").attr("data-dt-column") |
no test coverage detected