Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | 1x 1x 1x 1x 340x 370x 1x 5233x 5233x 1x 5409x 5409x 1x 4976x 4976x 4976x 1x 12x 126x 1x 12x 12x 12x 12x 72x 12x 12x 1x 433x 433x 433x 433x 433x 1x 83x 83x 83x 75x 8x 8x 16x 8x 1x 82x 82x 82x 82x 6x 6x 1x 240x 240x 1x 80x 80x 80x 1x 93x 6x 6x 6x 6x 6x 6x 3x 3x 3x 3x 2x 3x 3x 6x 6x 6x 1x 93x 1x 80x 80x 3x 77x 3x 80x 80x 93x 1x 1x 1x 256x 340x 340x 340x 340x 256x 1x 87x 1x 80x 80x 80x 80x 257x 257x 257x 256x 80x 80x 80x 80x 80x 1x 160x 160x 160x 1x 80x 80x 80x 1x 1x 7x 1x | /* Copyright 2008-2009 University of Cambridge Copyright 2008-2009 University of Toronto Copyright 2010-2014 OCAD University Copyright 2010-2011 Lucendo Development Ltd. Copyright 2013 Raising the Floor - US Copyright 2015-2016 Raising the Floor - International Licensed under the Educational Community License (ECL), Version 2.0 or the New BSD license. You may not use this file except in compliance with one these Licenses. You may obtain a copy of the ECL 2.0 License and BSD License at https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt */ var fluid_3_0_0 = fluid_3_0_0 || {}; (function ($, fluid) { "use strict"; // cf. ancient SVN-era version in bitbucket at https://bitbucket.org/fluid/infusion/src/adf319d9b279/branches/FLUID-2881/src/webapp/components/pager/js/Table.js fluid.registerNamespace("fluid.table"); fluid.table.findColumnDef = function (columnDefs, key) { return fluid.find_if(columnDefs, function (def) { return def.key === key; }); }; fluid.table.getRoots = function (target, dataOffset, index) { target.shortRoot = index; target.longRoot = fluid.pathUtil.composePath(dataOffset, target.shortRoot); }; // TODO: This crazed variable expansion system was a sketch for what eventually became the "protoComponent expansion system" delivered in 1.x versions of // Infusion. It in turn should be abolished when FLUID-4260 is implemented, allowing users to code with standard Fluid components and standard IoC references fluid.table.expandPath = function (EL, shortRoot, longRoot) { Eif (EL.charAt(0) === "*") { return longRoot + EL.substring(1); } else { return EL.replace("*", shortRoot); } }; fluid.table.fetchValue = function (dataOffset, dataModel, index, valuebinding, roots) { fluid.table.getRoots(roots, dataOffset, index); var path = fluid.table.expandPath(valuebinding, roots.shortRoot, roots.longRoot); return fluid.get(dataModel, path); }; fluid.table.rowComparator = function (sortDir) { return function (arec, brec) { return (arec.value > brec.value ? 1 : (arec.value < brec.value ? -1 : 0)) * sortDir; }; }; fluid.table.basicSorter = function (columnDefs, dataModel, dataOffset, model) { var roots = {}; var columnDef = fluid.table.findColumnDef(columnDefs, model.sortKey); var sortrecs = []; for (var i = 0; i < model.totalRange; ++i) { sortrecs[i] = { index: i, value: fluid.table.fetchValue(dataOffset, dataModel, i, columnDef.valuebinding, roots) }; } sortrecs.sort(fluid.table.rowComparator(model.sortDir)); return fluid.getMembers(sortrecs, "index"); }; fluid.table.IDforColumn = function (columnDef, keyPrefix, roots) { var EL = columnDef.valuebinding; var key = columnDef.key; Iif (!EL) { fluid.fail("Error in definition for column with key " + key + ": valuebinding is not set"); } Iif (!key) { var segs = fluid.model.parseEL(EL); key = segs[segs.length - 1]; } return { ID: (keyPrefix || "") + key, EL: fluid.table.expandPath(EL, roots.shortRoot, roots.longRoot) }; }; fluid.table.bigHeaderForKey = function (key, options) { // TODO: ensure this is shared properly var id = options.rendererOptions.idMap["header:" + key]; var smallHeader = fluid.jById(id); if (smallHeader.length === 0) { return null; } var headerSortStylisticOffset = options.selectors.headerSortStylisticOffset; var bigHeader = fluid.findAncestor(smallHeader, function (element) { return $(element).is(headerSortStylisticOffset); }); return bigHeader; }; fluid.table.setSortHeaderClass = function (styles, element, sort) { element = $(element); element.removeClass(styles.ascendingHeader); element.removeClass(styles.descendingHeader); if (sort !== 0) { element.addClass(sort === 1 ? styles.ascendingHeader : styles.descendingHeader); // aria-sort property are specified in the W3C WAI spec, ascending, descending, none, other. // since pager currently uses ascending and descending, we do not support the others. // http://www.w3.org/WAI/PF/aria/states_and_properties#aria-sort element.attr("aria-sort", sort === 1 ? "ascending" : "descending"); } }; fluid.table.isCurrentColumnSortable = function (columnDefs, model) { var columnDef = model.sortKey ? fluid.table.findColumnDef(columnDefs, model.sortKey) : null; return columnDef ? columnDef.sortable : false; }; fluid.table.setModelSortHeaderClass = function (columnDefs, newModel, options) { var styles = options.styles; var sort = fluid.table.isCurrentColumnSortable(columnDefs, newModel) ? newModel.sortDir : 0; fluid.table.setSortHeaderClass(styles, fluid.table.bigHeaderForKey(newModel.sortKey, options), sort); }; fluid.table.generateColumnClick = function (tableThat, options, model, columnDef) { return function () { Eif (columnDef.sortable === true) { var model = tableThat.model; var newModel = fluid.copy(model); var styles = tableThat.options.styles; var oldKey = model.sortKey; if (columnDef.key !== model.sortKey) { newModel.sortKey = columnDef.key; newModel.sortDir = 1; var oldBig = fluid.table.bigHeaderForKey(oldKey, options); if (oldBig) { fluid.table.setSortHeaderClass(styles, oldBig, 0); } } else Eif (newModel.sortKey === columnDef.key) { newModel.sortDir = -1 * newModel.sortDir; } else { return false; } newModel.pageIndex = 0; tableThat.applier.change("", newModel); // fluid.table.setModelSortHeaderClass(newModel, options); - done during rerender, surely } return false; }; }; fluid.table.fetchHeaderDecorators = function (decorators, columnDef) { return decorators[columnDef.sortable ? "sortableHeader" : "unsortableHeader"]; }; fluid.table.generateHeader = function (tableThat, options, newModel) { // arg 2 is renderThat.options var sortableColumnTxt = options.strings.sortableColumnText; if (newModel.sortDir === 1) { sortableColumnTxt = options.strings.sortableColumnTextAsc; } else if (newModel.sortDir === -1) { sortableColumnTxt = options.strings.sortableColumnTextDesc; } var columnDefs = tableThat.options.columnDefs; return { children: fluid.transform(columnDefs, function (columnDef) { return { ID: fluid.table.IDforColumn(columnDef, options.keyPrefix, {}).ID, value: columnDef.label, decorators: [ {"jQuery": ["click", fluid.table.generateColumnClick(tableThat, options, newModel, columnDef)]}, {identify: "header:" + columnDef.key}, {type: "attrs", attributes: { title: (columnDef.key === newModel.sortKey) ? sortableColumnTxt : options.strings.sortableColumnText}} ].concat(fluid.table.fetchHeaderDecorators(options.decorators, columnDef)) }; }) }; }; fluid.table.expandVariables = function (value, opts) { var togo = ""; var index = 0; while (true) { var nextindex = value.indexOf("${", index); if (nextindex === -1) { togo += value.substring(index); break; } else { togo += value.substring(index, nextindex); var endi = value.indexOf("}", nextindex + 2); var EL = value.substring(nextindex + 2, endi); if (EL === "VALUE") { EL = opts.EL; } else { EL = fluid.table.expandPath(EL, opts.shortRoot, opts.longRoot); } var val = fluid.get(opts.dataModel, EL); togo += val; index = endi + 1; } } return togo; }; fluid.table.expandPaths = function (target, tree, opts) { for (var i in tree) { var val = tree[i]; if (fluid.isMarker(val, fluid.VALUE)) { // TODO, in theory, we could prevent copying of columnDefs if (i === "valuebinding") { target[i] = opts.EL; } else { target[i] = {"valuebinding" : opts.EL}; } } else if (i === "valuebinding") { target[i] = fluid.table.expandPath(tree[i], opts); } else if (typeof (val) === "object") { target[i] = val.length !== undefined ? [] : {}; fluid.table.expandPaths(target[i], val, opts); } else if (typeof (val) === "string") { target[i] = fluid.table.expandVariables(val, opts); } else { target[i] = tree[i]; } } return target; }; fluid.table.expandColumnDefs = function (columnDefs, keyPrefix, dataModel, filteredRow, roots) { var tree = fluid.transform(columnDefs, function (columnDef) { var record = fluid.table.IDforColumn(columnDef, keyPrefix, roots); var opts = $.extend({ dataModel: dataModel }, roots, record); var togo; Eif (!columnDef.components) { return { ID: record.ID, valuebinding: record.EL }; } else if (typeof columnDef.components === "function") { togo = columnDef.components(filteredRow.row, filteredRow.index); } else { togo = columnDef.components; } togo = fluid.table.expandPaths({}, togo, opts); togo.ID = record.ID; return togo; }); return tree; }; fluid.table.fetchDataModel = function (dataModel, dataOffset) { return fluid.get(dataModel, dataOffset); }; fluid.table.produceTree = function (tableThat, renderThat) { var options = renderThat.options; var columnDefs = tableThat.options.columnDefs; var roots = {}; var tree = fluid.transform(tableThat.filtered, function (filteredRow) { fluid.table.getRoots(roots, tableThat.options.dataOffset, filteredRow.index); Iif (columnDefs === "explode") { return fluid.explode(filteredRow.row, roots.longRoot); } else if (columnDefs.length) { return fluid.table.expandColumnDefs(columnDefs, renderThat.options.keyPrefix, tableThat.dataModel, filteredRow, roots); } }); var fullTree = {}; fullTree[options.row] = tree; Eif (typeof (columnDefs) === "object") { fullTree[options.header] = fluid.table.generateHeader(tableThat, renderThat.options, tableThat.model); } return fullTree; }; fluid.table.sortInvoker = function (tableThat, newModel) { var columnDefs = tableThat.options.columnDefs; var sorted = fluid.table.isCurrentColumnSortable(columnDefs, newModel) ? tableThat.options.sorter(columnDefs, tableThat.options.dataModel, tableThat.options.dataOffset, newModel) : null; tableThat.permutation = sorted; }; fluid.table.onModelChange = function (tableThat, renderThat, newModel) { renderThat.sortInvoker(newModel); tableThat.dataModel = tableThat.fetchDataModel(); tableThat.filtered = tableThat.options.modelFilter(tableThat.dataModel, newModel, tableThat.permutation); }; /** A body renderer implementation which uses the Fluid renderer to render a table section **/ fluid.defaults("fluid.table.selfRender", { gradeNames: ["fluid.rendererComponent"], listeners: { onCreate: [{ "this": "{that}.root", method: "addClass", args: "{that}.options.styles.root" }], onIndexModelChange: [{ funcName: "fluid.table.onModelChange", namespace: "onModelChange", args: ["{fluid.table}", "{fluid.table.selfRender}", "{arguments}.0", "{arguments}.1"] // newModel, oldModel }, { func: "{that}.sortInvoker", namespace: "sortInvoker", args: "{arguments}.0" }, { priority: "last", namespace: "refreshView", func: "{that}.refreshView" }], afterRender: { // TODO, should this not be actually renderable? funcName: "fluid.table.setModelSortHeaderClass", args: ["{that}.options.columnDefs", "{fluid.table}.model", "{that}.options"] } }, modelListeners: { "{fluid.table}.model": "{that}.events.onIndexModelChange.fire({change}.value, {change}.oldValue)" }, events: { onIndexModelChange: null }, invokers: { sortInvoker: { funcName: "fluid.table.sortInvoker", args: ["{fluid.table}", "{arguments}.0"] // newModel }, produceTree: { funcName: "fluid.table.produceTree", args: ["{fluid.table}", "{fluid.table.selfRender}"] } }, selectors: { root: ".flc-pager-body-template", headerSortStylisticOffset: "{table}.options.selectors.headerSortStylisticOffset", header: ".flc-table-header", row: ".flc-table-row" }, repeatingSelectors: ["header", "row"], selectorsToIgnore: ["root", "headerSortStylisticOffset"], styles: { root: "fl-pager", ascendingHeader: "{table}.options.styles.ascendingHeader", descendingHeader: "{table}.options.styles.descendingHeader" }, members: { root: "{that}.dom.root" }, decorators: { sortableHeader: [], unsortableHeader: [] }, keyStrategy: "id", keyPrefix: "", row: "row:", // should match selector name, deprecated after v1.5 header: "header:", // should match selector name, deprecated after v1.5 strings: "{table}.options.strings", columnDefs: "{table}.options.columnDefs", // Options passed upstream to the renderer rendererFnOptions: { templateSource: {node: "{that}.dom.root"}, renderTarget: "{that}.dom.root", noexpand: true }, rendererOptions: { model: "{table}.options.dataModel", idMap: {} } }); fluid.table.checkTotalRange = function (totalRange, pagerBar) { Iif (totalRange === undefined && !pagerBar) { fluid.fail("Error in Pager configuration - cannot determine total range, " + " since not configured in model.totalRange and no PagerBar is configured"); } }; fluid.defaults("fluid.table", { gradeNames: ["fluid.viewComponent"], mergePolicy: { dataModel: "preserve", columnDefs: "noexpand" }, components: { bodyRenderer: { type: "fluid.table.selfRender", container: "{table}.container" } }, listeners: { onCreate: { funcName: "fluid.table.checkTotalRange", namespace: "checkTotalRange", args: ["{that}.model.totalRange", "{that}.pagerBar"] } }, modelFilter: fluid.table.directModelFilter, // TODO: no implementation for this yet sorter: fluid.table.basicSorter, members: { dataModel: { expander: { func: "{that}.fetchDataModel" } } }, invokers: { fetchDataModel: { funcName: "fluid.table.fetchDataModel", args: ["{that}.options.dataModel", "{that}.options.dataOffset"] } }, styles: { ascendingHeader: "fl-pager-asc", descendingHeader: "fl-pager-desc" }, selectors: { headerSortStylisticOffset: ".flc-pager-sort-header" }, strings: { sortableColumnText: "Select to sort", sortableColumnTextDesc: "Select to sort in ascending, currently in descending order.", sortableColumnTextAsc: "Select to sort in descending, currently in ascending order." }, // Offset of the tree's "main" data from the overall dataModel root dataOffset: "", // strategy for generating a tree row, either "explode" or an array of columnDef objects columnDefs: [] // [{key: "columnName", valuebinding: "*.valuePath", sortable: true/false}] }); })(jQuery, fluid_3_0_0); |