OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This is a data model representin | 6 * @fileoverview This is a data model representin |
7 */ | 7 */ |
8 | 8 |
9 cr.define('cr.ui', function() { | 9 cr.define('cr.ui', function() { |
10 const EventTarget = cr.EventTarget; | 10 const EventTarget = cr.EventTarget; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 * @param {string} field The field to set compare function. | 65 * @param {string} field The field to set compare function. |
66 * @param {function(*, *): number} Compare function to set for given field. | 66 * @param {function(*, *): number} Compare function to set for given field. |
67 */ | 67 */ |
68 setCompareFunction: function(field, compareFunction) { | 68 setCompareFunction: function(field, compareFunction) { |
69 if (!this.compareFunctions_) { | 69 if (!this.compareFunctions_) { |
70 this.compareFunctions_ = {}; | 70 this.compareFunctions_ = {}; |
71 } | 71 } |
72 this.compareFunctions_[field] = compareFunction; | 72 this.compareFunctions_[field] = compareFunction; |
73 }, | 73 }, |
74 | 74 |
| 75 isSortable: function(field) { |
| 76 return this.compareFunctions_ && field in this.compareFunctions_; |
| 77 }, |
| 78 |
75 /** | 79 /** |
76 * Returns current sort status. | 80 * Returns current sort status. |
77 * @return {!Object} Current sort status. | 81 * @return {!Object} Current sort status. |
78 */ | 82 */ |
79 get sortStatus() { | 83 get sortStatus() { |
80 if (this.sortStatus_) { | 84 if (this.sortStatus_) { |
81 return this.createSortStatus( | 85 return this.createSortStatus( |
82 this.sortStatus_.field, this.sortStatus_.direction); | 86 this.sortStatus_.field, this.sortStatus_.direction); |
83 } else { | 87 } else { |
84 return this.createSortStatus(null, null); | 88 return this.createSortStatus(null, null); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (a > b) | 358 if (a > b) |
355 return 1; | 359 return 1; |
356 return 0; | 360 return 0; |
357 } | 361 } |
358 }; | 362 }; |
359 | 363 |
360 return { | 364 return { |
361 ArrayDataModel: ArrayDataModel | 365 ArrayDataModel: ArrayDataModel |
362 }; | 366 }; |
363 }); | 367 }); |
OLD | NEW |