|
| 1 | +import Ember from 'ember'; |
| 2 | +import FixedGrid from 'ember-collection/layouts/grid'; |
| 3 | +import MixedGrid from 'ember-collection/layouts/mixed-grid'; |
| 4 | +import PercentageColumns from 'ember-collection/layouts/percentage-columns'; |
| 5 | + |
| 6 | +export class FixedGridInterface extends FixedGrid { |
| 7 | + get length() { |
| 8 | + return this._size; |
| 9 | + } |
| 10 | + set length (num) { |
| 11 | + Ember.set(this, '_size', num); |
| 12 | + } |
| 13 | + |
| 14 | + contentSize() { |
| 15 | + let result = super.contentSize(...arguments); |
| 16 | + let [...args] = arguments; |
| 17 | + Ember.set(this, '_contentSize', {args: args, result: result}); |
| 18 | + console.log(`contentSize(${args.join(', ')}) => `, result); |
| 19 | + return result; |
| 20 | + } |
| 21 | + |
| 22 | + indexAt() { |
| 23 | + let result = super.indexAt(...arguments); |
| 24 | + let [...args] = arguments; |
| 25 | + Ember.set(this, '_indexAt', {args: args, result: result}); |
| 26 | + console.log(`indexAt(${args.join(', ')}) => `, result); |
| 27 | + return result; |
| 28 | + } |
| 29 | + |
| 30 | + count() { |
| 31 | + let result = super.count(...arguments); |
| 32 | + let [...args] = arguments; |
| 33 | + Ember.set(this, '_count', {args: args, result: result}); |
| 34 | + console.log(`count(${args.join(', ')}) => `, result); |
| 35 | + return result; |
| 36 | + } |
| 37 | + |
| 38 | + formatItemStyle() { |
| 39 | + let result = super.formatItemStyle(...arguments); |
| 40 | + let [...args] = arguments; |
| 41 | + console.log(`formatItemStyle(${args.join(', ')}) => `, result); |
| 42 | + return result; |
| 43 | + } |
| 44 | + |
| 45 | + get markdownContentSize() { |
| 46 | + return `/** |
| 47 | + * Size of all items (visible/invisible) in container |
| 48 | + * |
| 49 | + * contentSize(containerWidth, containerHeight) |
| 50 | + */ |
| 51 | + contentSize: function(${this._contentSize.args.join(', ')}) { |
| 52 | + return ${this.toString(this._contentSize.result)}; |
| 53 | + }`; |
| 54 | + } |
| 55 | + |
| 56 | + get markdownIndexAt() { |
| 57 | + return `/** |
| 58 | + * Index of the first visible item |
| 59 | + * |
| 60 | + * indexAt(offsetX, offsetY, containerWidth, containerHeight) |
| 61 | + */ |
| 62 | + indexAt: function(${this._indexAt.args.join(', ')}) { |
| 63 | + return ${this.toString(this._indexAt.result)}; |
| 64 | + }`; |
| 65 | + } |
| 66 | + |
| 67 | + get markdownCount() { |
| 68 | + return `/** |
| 69 | + * Number of items to display in container |
| 70 | + * |
| 71 | + * count(offsetX, offsetY, containerWidth, containerHeight) |
| 72 | + */ |
| 73 | + count: function(${this._count.args.join(', ')}) { |
| 74 | + return ${this.toString(this._count.result)}; |
| 75 | + }`; |
| 76 | + } |
| 77 | + |
| 78 | + toString(result) { |
| 79 | + return JSON.stringify(result).replace(/:/g, ': ').replace(/"/g, ''); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +export class MixedGridInterface extends MixedGrid { |
| 84 | + get length() { |
| 85 | + return this._size; |
| 86 | + } |
| 87 | + set length (num) { |
| 88 | + Ember.set(this, '_size', num); |
| 89 | + } |
| 90 | + |
| 91 | + contentSize() { |
| 92 | + let result = super.contentSize(...arguments); |
| 93 | + let [...args] = arguments; |
| 94 | + Ember.set(this, '_contentSize', {args: args, result: result}); |
| 95 | + console.log(`contentSize(${args.join(', ')}) => `, result); |
| 96 | + return result; |
| 97 | + } |
| 98 | + |
| 99 | + indexAt() { |
| 100 | + let result = super.indexAt(...arguments); |
| 101 | + let [...args] = arguments; |
| 102 | + Ember.set(this, '_indexAt', {args: args, result: result}); |
| 103 | + console.log(`indexAt(${args.join(', ')}) => `, result); |
| 104 | + return result; |
| 105 | + } |
| 106 | + |
| 107 | + count() { |
| 108 | + let result = super.count(...arguments); |
| 109 | + let [...args] = arguments; |
| 110 | + Ember.set(this, '_count', {args: args, result: result}); |
| 111 | + console.log(`count(${args.join(', ')}) => `, result); |
| 112 | + return result; |
| 113 | + } |
| 114 | + |
| 115 | + formatItemStyle() { |
| 116 | + let result = super.formatItemStyle(...arguments); |
| 117 | + let [...args] = arguments; |
| 118 | + console.log(`formatItemStyle(${args.join(', ')}) => `, result); |
| 119 | + return result; |
| 120 | + } |
| 121 | + |
| 122 | + get markdownContentSize() { |
| 123 | + return `/** |
| 124 | + * Size of all items (visible/invisible) in container |
| 125 | + * |
| 126 | + * contentSize(containerWidth, containerHeight) |
| 127 | + */ |
| 128 | + contentSize: function(${this._contentSize.args.join(', ')}) { |
| 129 | + return ${this.toString(this._contentSize.result)}; |
| 130 | + }`; |
| 131 | + } |
| 132 | + |
| 133 | + get markdownIndexAt() { |
| 134 | + return `/** |
| 135 | + * Index of the first visible item |
| 136 | + * |
| 137 | + * indexAt(offsetX, offsetY, containerWidth, containerHeight) |
| 138 | + */ |
| 139 | + indexAt: function(${this._indexAt.args.join(', ')}) { |
| 140 | + return ${this.toString(this._indexAt.result)}; |
| 141 | + }`; |
| 142 | + } |
| 143 | + |
| 144 | + get markdownCount() { |
| 145 | + return `/** |
| 146 | + * Number of items to display in container |
| 147 | + * |
| 148 | + * count(offsetX, offsetY, containerWidth, containerHeight) |
| 149 | + */ |
| 150 | + count: function(${this._count.args.join(', ')}) { |
| 151 | + return ${this.toString(this._count.result)}; |
| 152 | + }`; |
| 153 | + } |
| 154 | + |
| 155 | + toString(result) { |
| 156 | + return JSON.stringify(result).replace(/:/g, ': ').replace(/"/g, ''); |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +export class PercentageColumnsInterface extends PercentageColumns { |
| 161 | + get length() { |
| 162 | + return this._size; |
| 163 | + } |
| 164 | + set length (num) { |
| 165 | + Ember.set(this, '_size', num); |
| 166 | + } |
| 167 | + |
| 168 | + contentSize() { |
| 169 | + let result = super.contentSize(...arguments); |
| 170 | + let [...args] = arguments; |
| 171 | + Ember.set(this, '_contentSize', {args: args, result: result}); |
| 172 | + console.log(`contentSize(${args.join(', ')}) => `, result); |
| 173 | + return result; |
| 174 | + } |
| 175 | + |
| 176 | + indexAt() { |
| 177 | + let result = super.indexAt(...arguments); |
| 178 | + let [...args] = arguments; |
| 179 | + Ember.set(this, '_indexAt', {args: args, result: result}); |
| 180 | + console.log(`indexAt(${args.join(', ')}) => `, result); |
| 181 | + return result; |
| 182 | + } |
| 183 | + |
| 184 | + count() { |
| 185 | + let result = super.count(...arguments); |
| 186 | + let [...args] = arguments; |
| 187 | + Ember.set(this, '_count', {args: args, result: result}); |
| 188 | + console.log(`count(${args.join(', ')}) => `, result); |
| 189 | + return result; |
| 190 | + } |
| 191 | + |
| 192 | + formatItemStyle() { |
| 193 | + let result = super.formatItemStyle(...arguments); |
| 194 | + let [...args] = arguments; |
| 195 | + console.log(`formatItemStyle(${args.join(', ')}) => `, result); |
| 196 | + return result; |
| 197 | + } |
| 198 | + |
| 199 | + get markdownContentSize() { |
| 200 | + return `/** |
| 201 | + * Size of all items (visible/invisible) in container |
| 202 | + * |
| 203 | + * contentSize(containerWidth, containerHeight) |
| 204 | + */ |
| 205 | + contentSize: function(${this._contentSize.args.join(', ')}) { |
| 206 | + return ${this.toString(this._contentSize.result)}; |
| 207 | + }`; |
| 208 | + } |
| 209 | + |
| 210 | + get markdownIndexAt() { |
| 211 | + return `/** |
| 212 | + * Index of the first visible item |
| 213 | + * |
| 214 | + * indexAt(offsetX, offsetY, containerWidth, containerHeight) |
| 215 | + */ |
| 216 | + indexAt: function(${this._indexAt.args.join(', ')}) { |
| 217 | + return ${this.toString(this._indexAt.result)}; |
| 218 | + }`; |
| 219 | + } |
| 220 | + |
| 221 | + get markdownCount() { |
| 222 | + return `/** |
| 223 | + * Number of items to display in container |
| 224 | + * |
| 225 | + * count(offsetX, offsetY, containerWidth, containerHeight) |
| 226 | + */ |
| 227 | + count: function(${this._count.args.join(', ')}) { |
| 228 | + return ${this.toString(this._count.result)}; |
| 229 | + }`; |
| 230 | + } |
| 231 | + |
| 232 | + toString(result) { |
| 233 | + return JSON.stringify(result).replace(/:/g, ': ').replace(/"/g, ''); |
| 234 | + } |
| 235 | +} |
0 commit comments