summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js')
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js
new file mode 100644
index 0000000000..959f554502
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js
@@ -0,0 +1,67 @@
+'use strict';
+
+define(
+ [
+ 'flight/lib/component'
+ ],
+
+ function(defineComponent) {
+
+ return defineComponent(mailControls);
+
+ function mailControls() {
+ this.defaultAttrs({
+ //selectors
+ actionControlsSelector: 'button.mail-action',
+ deleteControlSelector: '#delete_mail',
+ moveControlSelector: '#move_mail',
+ forwardControlSelector: '#forward',
+ replyControlSelector: '#reply',
+ singleItemActionSelector: 'button.single-item'
+ });
+
+ this.disableAll = function() {
+ this.select('actionControlsSelector').attr('disabled', 'disabled');
+ };
+
+ this.restyleOnSelectionChange = function(ev, data) {
+ if (data.selectedIds.length > 1) {
+ this.select('actionControlsSelector').not('button.single-item').removeAttr('disabled');
+ this.select('singleItemActionSelector').attr('disabled', 'disabled');
+ } else if (data.selectedIds.length == 1) {
+ this.select('actionControlsSelector').removeAttr('disabled');
+ } else {
+ this.disableAll();
+ }
+ };
+
+ this.deleteMail = function(ev, data) {
+ this.trigger('uiDeleteMail');
+ };
+
+ this.moveMail = function(ev, data) {
+ this.trigger('uiMoveMail');
+ };
+
+ this.forwardMail = function(ev, data) {
+ this.trigger('uiForwardMail');
+ };
+
+ this.replyToMail = function(ev, data) {
+ this.trigger('uiReplyToMail');
+ };
+
+ this.after('initialize', function() {
+ this.on('.mail-action', 'click', {
+ 'deleteControlSelector': this.deleteMail,
+ 'moveControlSelector': this.moveMail,
+ 'forwardControlSelector': this.forwardMail,
+ 'replyControlSelector': this.replyToMail
+ });
+ this.on(document, 'uiMailItemSelectionChanged', this.restyleOnSelectionChange);
+ this.on(document, 'uiFolderSelectionChanged', this.disableAll);
+ });
+ }
+ }
+);
+