summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js')
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js
new file mode 100644
index 0000000000..29b5cfd665
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js
@@ -0,0 +1,61 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ './with_select'
+ ],
+
+ function(defineComponent, withSelect) {
+
+ return defineComponent(mailItems, withSelect);
+
+ function mailItems() {
+
+ this.defaultAttrs({
+ deleteFolder: 'trash',
+ selectedClass: 'selected',
+ allowMultiSelect: true,
+ selectionChangedEvent: 'uiMailItemSelectionChanged',
+ selectedMailItems: [],
+ selectedFolders: [],
+ //selectors
+ itemSelector: 'tr.mail-item',
+ selectedItemSelector: 'tr.mail-item.selected'
+ });
+
+ this.renderItems = function(ev, data) {
+ this.select('itemContainerSelector').html(data.markup);
+ //new items, so no selections
+ this.trigger('uiMailItemSelectionChanged', {selectedIds: []});
+ }
+
+ this.updateMailItemSelections = function(ev, data) {
+ this.attr.selectedMailItems = data.selectedIds;
+ }
+
+ this.updateFolderSelections = function(ev, data) {
+ this.attr.selectedFolders = data.selectedIds;
+ }
+
+ this.requestDeletion = function() {
+ this.trigger('uiMoveItemsRequested', {
+ itemIds: this.attr.selectedMailItems,
+ fromFolder: this.attr.selectedFolders[0],
+ toFolder: this.attr.deleteFolder
+ });
+ };
+
+ this.after('initialize', function() {
+ this.on(document, 'dataMailItemsServed', this.renderItems);
+ this.on(document, 'uiDeleteMail', this.requestDeletion);
+
+ this.on('uiMailItemSelectionChanged', this.updateMailItemSelections);
+ this.on(document, 'uiFolderSelectionChanged', this.updateFolderSelections);
+
+ this.trigger('uiMailItemsRequested');
+ });
+ }
+ }
+);