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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { | 75 isSortable: function(field) { |
76 return this.compareFunctions_ && field in this.compareFunctions_; | 76 return this.compareFunctions_ && field in this.compareFunctions_; |
77 }, | 77 }, |
78 | 78 |
79 /** | 79 /** |
| 80 * Returns true if the field has a compare function. |
| 81 * @param {string} field The field to check. |
| 82 * @return {boolean} True if the field is sortable. |
| 83 */ |
| 84 isSortable: function(field) { |
| 85 return this.compareFunctions_ && field in this.compareFunctions_; |
| 86 }, |
| 87 |
| 88 /** |
80 * Returns current sort status. | 89 * Returns current sort status. |
81 * @return {!Object} Current sort status. | 90 * @return {!Object} Current sort status. |
82 */ | 91 */ |
83 get sortStatus() { | 92 get sortStatus() { |
84 if (this.sortStatus_) { | 93 if (this.sortStatus_) { |
85 return this.createSortStatus( | 94 return this.createSortStatus( |
86 this.sortStatus_.field, this.sortStatus_.direction); | 95 this.sortStatus_.field, this.sortStatus_.direction); |
87 } else { | 96 } else { |
88 return this.createSortStatus(null, null); | 97 return this.createSortStatus(null, null); |
89 } | 98 } |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if (a > b) | 367 if (a > b) |
359 return 1; | 368 return 1; |
360 return 0; | 369 return 0; |
361 } | 370 } |
362 }; | 371 }; |
363 | 372 |
364 return { | 373 return { |
365 ArrayDataModel: ArrayDataModel | 374 ArrayDataModel: ArrayDataModel |
366 }; | 375 }; |
367 }); | 376 }); |
OLD | NEW |