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 | 3x 3x 3x 3x 3x 939x 939x 939x 939x 9x 930x 930x 930x 14712x 14712x 930x 930x 930x 930x 8694x 7356x 7356x 7356x 7356x 7356x 7356x 7356x 930x 3x 240x 240x 240x 771x 771x 240x 3x 480x 480x 480x 3726x 480x 3x | /* Copyright 2008-2009 University of Cambridge Copyright 2008-2009 University of Toronto Copyright 2010-2013 OCAD University Copyright 2010-2011 Lucendo Development Ltd. Copyright 2014-2016 Raising the Floor - International Copyright 2016 Dinuka De Silva 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"; fluid.registerNamespace("fluid.pagedTable"); // cf. ancient SVN-era version in bitbucket at https://bitbucket.org/fluid/infusion/src/adf319d9b279/branches/FLUID-2881/src/webapp/components/pager/js/PagedTable.js fluid.defaults("fluid.pagedTable.rangeAnnotator", { gradeNames: ["fluid.component"] }); // TODO: Get rid of this old-style kind of architecture - we should just react to model changes directly and not inject this // peculiar event up and down the place. Probably best to have new renderer first. fluid.pagedTable.rangeAnnotator.onRenderPageLinks = function (that, tree, newModel, pagerBar) { pagerBar.tooltip.close(); // Close any existing tooltips otherwise they will linger after their parent is destroyed var roots = {}; var column = that.options.annotateColumnRange || (that.options.annotateSortedColumn ? newModel.sortKey : null); if (!column) { return; } var dataModel = that.options.dataModel; var columnDefs = that.options.columnDefs; var columnDef = fluid.table.findColumnDef(columnDefs, column); function fetchValue(index) { index = that.permutation ? that.permutation[index] : index; return fluid.table.fetchValue(that.options.dataOffset, dataModel, index, columnDef.valuebinding, roots); } var tModel = {}; fluid.model.copyModel(tModel, newModel); var tooltipInfo = {}; fluid.each(tree, function (cell) { if (cell.ID === "page-link:link") { var page = cell.pageIndex; var start = page * tModel.pageSize; tModel.pageIndex = page; var limit = fluid.pager.computePageLimit(tModel); var iValue = fetchValue(start); var lValue = fetchValue(limit - 1); tooltipInfo[page] = { first: iValue, last: lValue }; } }); pagerBar.tooltipInfo = tooltipInfo; }; fluid.pagedTable.directModelFilter = function (model, pagerModel, perm) { var togo = []; var limit = fluid.pager.computePageLimit(pagerModel); for (var i = pagerModel.pageIndex * pagerModel.pageSize; i < limit; ++i) { var index = perm ? perm[i] : i; togo[togo.length] = {index: index, row: model[index]}; } return togo; }; fluid.pagedTable.configureTooltip = function (pagedTable, pagerBar, renderedPageList) { var idMap = renderedPageList.rendererOptions.idMap; var idToContent = {}; fluid.each(pagerBar.tooltipInfo, function (value, index) { idToContent[idMap["pageLink:" + index]] = fluid.stringTemplate(pagedTable.options.markup.rangeAnnotation, value); }); pagerBar.tooltip.applier.change("idToContent", idToContent); }; fluid.defaults("fluid.pagedTable", { gradeNames: ["fluid.pager", "fluid.table"], distributeOptions: [{ target: "{that renderedPageList}.options.listeners.afterRender", record: { funcName: "fluid.pagedTable.configureTooltip", args: ["{pagedTable}", "{pagerBar}", "{arguments}.0"] // NB! Use of "pagerBar" depends on FLUID-5258 - we will need a new annotation when this is fixed } }, { target: "{that renderedPageList}.options.listeners.onRenderPageLinks", record: { funcName: "fluid.pagedTable.rangeAnnotator.onRenderPageLinks", args: ["{pagedTable}", "{arguments}.0", "{arguments}.1", "{pagerBar}"] // FLUID-5258 as above } }, { target: "{that pagerBar}.options.components.tooltip", source: "{that}.options.tooltip" }], annotateSortedColumn: false, annotateColumnRange: undefined, // specify a "key" from the columnDefs markup: { rangeAnnotation: "<b> %first </b><br/>—<br/><b> %last </b>" }, tooltip: { type: "fluid.tooltip", container: "{that}.container", options: { } }, invokers: { acquireDefaultRange: { funcName: "fluid.identity", args: "{that}.dataModel.length" } }, modelFilter: fluid.pagedTable.directModelFilter, model: { pageSize: 10 } }); })(jQuery, fluid_3_0_0); |