summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app')
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/boot/page.js47
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/compose_box.js93
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/mail_items.js68
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/move_to.js52
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/compose_box.js113
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/folders.js34
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_controls.js67
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/mail_items.js61
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/move_to_selector.js79
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/with_select.js64
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/css/custom.css102
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/data.js110
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/templates.js62
13 files changed, 952 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/boot/page.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/boot/page.js
new file mode 100644
index 0000000000..f561f8e2c6
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/boot/page.js
@@ -0,0 +1,47 @@
+'use strict';
+
+define(
+
+ [
+ 'app/component_data/mail_items',
+ 'app/component_data/compose_box',
+ 'app/component_data/move_to',
+ 'app/component_ui/mail_items',
+ 'app/component_ui/mail_controls',
+ 'app/component_ui/compose_box',
+ 'app/component_ui/folders',
+ 'app/component_ui/move_to_selector'
+ ],
+
+ function(
+ MailItemsData,
+ ComposeBoxData,
+ MoveToData,
+ MailItemsUI,
+ MailControlsUI,
+ ComposeBoxUI,
+ FoldersUI,
+ MoveToSelectorUI) {
+
+ function initialize() {
+ MailItemsData.attachTo(document);
+ ComposeBoxData.attachTo(document, {
+ selectedFolders: ['inbox']
+ });
+ MoveToData.attachTo(document);
+ MailItemsUI.attachTo('#mail_items', {
+ itemContainerSelector: '#mail_items_TB',
+ selectedFolders: ['inbox']
+ });
+ MailControlsUI.attachTo('#mail_controls');
+ ComposeBoxUI.attachTo('#compose_box');
+ FoldersUI.attachTo('#folders');
+ MoveToSelectorUI.attachTo('#move_to_selector', {
+ moveActionSelector: '#move_mail',
+ selectedFolders: ['inbox']
+ });
+ }
+
+ return initialize;
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/compose_box.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/compose_box.js
new file mode 100644
index 0000000000..e728086f02
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/compose_box.js
@@ -0,0 +1,93 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ 'components/mustache/mustache',
+ 'app/data',
+ 'app/templates'
+ ],
+
+ function(defineComponent, Mustache, dataStore, templates) {
+ return defineComponent(composeBox);
+
+ function composeBox() {
+
+ this.defaultAttrs({
+ dataStore: dataStore,
+ recipientHintId: 'recipient_hint',
+ subjectHint: 'Subject',
+ messageHint: 'Message',
+ toHint: 'To',
+ forwardPrefix: 'Fw',
+ replyPrefix: 'Re'
+ });
+
+ this.serveComposeBox = function(ev, data) {
+ this.trigger("dataComposeBoxServed", {
+ markup: this.renderComposeBox(data.type, data.relatedMailId),
+ type: data.type});
+ };
+
+ this.getSubject = function(type, relatedMailId) {
+ var relatedMail = this.attr.dataStore.mail.filter(function(each) {
+ return each.id == relatedMailId;
+ })[0];
+
+ var subject = relatedMail && relatedMail.subject;
+
+ var subjectLookup = {
+ newMail: this.attr.subjectHint,
+ forward: this.attr.forwardPrefix + ": " + subject,
+ reply: this.attr.replyPrefix + ": " + subject
+ }
+
+ return subjectLookup[type];
+ };
+
+ this.renderComposeBox = function(type, relatedMailId) {
+ var recipientId = this.getRecipientId(type, relatedMailId);
+ var contacts = this.attr.dataStore.contacts.map(function(contact) {
+ contact.recipient = (contact.id == recipientId);
+ return contact;
+ });
+
+ return Mustache.render(templates.composeBox, {
+ newMail: type == 'newMail',
+ reply: type == 'reply',
+ subject: this.getSubject(type, relatedMailId),
+ message: this.attr.messageHint,
+ contacts: contacts
+ });
+ };
+
+ this.getRecipientId = function(type, relatedMailId) {
+ var relatedMail = (type == 'reply') && this.attr.dataStore.mail.filter(function(each) {
+ return each.id == relatedMailId;
+ })[0];
+
+ return relatedMail && relatedMail.contact_id || this.attr.recipientHintId;
+ };
+
+
+ this.send = function(ev, data) {
+ this.attr.dataStore.mail.push({
+ id: String(Date.now()),
+ contact_id: data.to_id,
+ folders: ["sent"],
+ time: Date.now(),
+ subject: data.subject,
+ message: data.message
+ });
+ this.trigger('dataMailItemsRefreshRequested', {folder: data.currentFolder});
+ };
+
+ this.after("initialize", function() {
+ this.on("uiComposeBoxRequested", this.serveComposeBox);
+ this.on("uiSendRequested", this.send);
+ });
+ }
+
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/mail_items.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/mail_items.js
new file mode 100644
index 0000000000..380ff9a0e8
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/mail_items.js
@@ -0,0 +1,68 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ 'components/mustache/mustache',
+ 'app/data',
+ 'app/templates'
+ ],
+
+ function(defineComponent, Mustache, dataStore, templates) {
+ return defineComponent(mailItems);
+
+ function mailItems() {
+
+ this.defaultAttrs({
+ folder: 'inbox',
+ dataStore: dataStore
+ });
+
+ this.serveMailItems = function(ev, data) {
+ var folder = (data && data.folder) || this.attr.folder;
+ this.trigger("dataMailItemsServed", {markup: this.renderItems(this.assembleItems(folder))})
+ };
+
+ this.renderItems = function(items) {
+ return Mustache.render(templates.mailItem, {mailItems: items});
+ };
+
+ this.assembleItems = function(folder) {
+ var items = [];
+
+ this.attr.dataStore.mail.forEach(function(each) {
+ if (each.folders && each.folders.indexOf(folder) > -1) {
+ items.push(this.getItemForView(each));
+ }
+ }, this);
+
+ return items;
+ };
+
+ this.getItemForView = function(itemData) {
+ var thisItem, thisContact, msg
+
+ thisItem = {id: itemData.id, important: itemData.important};
+
+ thisContact = this.attr.dataStore.contacts.filter(function(contact) {
+ return contact.id == itemData.contact_id
+ })[0];
+ thisItem.name = [thisContact.firstName, thisContact.lastName].join(' ');
+
+ var subj = itemData.subject;
+ thisItem.formattedSubject = subj.length > 70 ? subj.slice(0, 70) + "..." : subj;
+
+ var msg = itemData.message;
+ thisItem.formattedMessage = msg.length > 70 ? msg.slice(0, 70) + "..." : msg;
+
+ return thisItem;
+ };
+
+ this.after("initialize", function() {
+ this.on("uiMailItemsRequested", this.serveMailItems);
+ this.on("dataMailItemsRefreshRequested", this.serveMailItems);
+ });
+ }
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/move_to.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/move_to.js
new file mode 100644
index 0000000000..46f248540b
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data/move_to.js
@@ -0,0 +1,52 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ 'components/mustache/mustache',
+ 'app/data',
+ 'app/templates'
+ ],
+
+ function(defineComponent, Mustache, dataStore, templates) {
+ return defineComponent(moveTo);
+
+ function moveTo() {
+
+ this.defaultAttrs({
+ dataStore: dataStore
+ });
+
+ this.serveAvailableFolders = function(ev, data) {
+ this.trigger("dataMoveToItemsServed", {
+ markup: this.renderFolderSelector(this.getOtherFolders(data.folder))
+ })
+ };
+
+ this.renderFolderSelector = function(items) {
+ return Mustache.render(templates.moveToSelector, {moveToItems: items});
+ };
+
+ this.moveItems = function(ev, data) {
+ var itemsToMoveIds = data.itemIds
+ this.attr.dataStore.mail.forEach(function(item) {
+ if (itemsToMoveIds.indexOf(item.id) > -1) {
+ item.folders = [data.toFolder];
+ }
+ });
+ this.trigger('dataMailItemsRefreshRequested', {folder: data.fromFolder});
+ };
+
+ this.getOtherFolders = function(folder) {
+ return this.attr.dataStore.folders.filter(function(e) {return e != folder});
+ };
+
+ this.after("initialize", function() {
+ this.on("uiAvailableFoldersRequested", this.serveAvailableFolders);
+ this.on("uiMoveItemsRequested", this.moveItems);
+ });
+ }
+
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/compose_box.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/compose_box.js
new file mode 100644
index 0000000000..feb14040be
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/compose_box.js
@@ -0,0 +1,113 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component'
+ ],
+
+ function(defineComponent) {
+
+ return defineComponent(composeBox);
+
+ function composeBox() {
+
+ this.defaultAttrs({
+ newMailType: 'newMail',
+ forwardMailType: 'forward',
+ replyMailType: 'reply',
+ hintClass: 'hint',
+ selectedFolders: [],
+ selectedMailItems: [],
+
+ //selectors
+ composeControl: '.compose',
+ newControlSelector: '#new_mail',
+ cancelSelector: '#cancel_composed',
+ sendSelector: '#send_composed',
+ toSelector: '#compose_to',
+ subjectSelector: '#compose_subject',
+ messageSelector: '#compose_message',
+ recipientSelector: '#recipient_select',
+ recipientHintSelector: '#recipient_hint',
+ selectedRecipientSelector: '#recipient_select :selected',
+ hintSelector: 'div.hint'
+ });
+
+ this.newMail = function() {
+ this.requestComposeBox(this.attr.newMailType);
+ };
+
+ this.forward = function() {
+ this.requestComposeBox(this.attr.forwardMailType, this.attr.selectedMailItems);
+ };
+
+ this.reply = function() {
+ this.requestComposeBox(this.attr.replyMailType, this.attr.selectedMailItems);
+ };
+
+ this.requestComposeBox = function(type, relatedMailId) {
+ this.trigger('uiComposeBoxRequested', {type: type, relatedMailId: relatedMailId});
+ };
+
+ this.launchComposeBox = function(ev, data) {
+ var focusSelector = (data.type == this.attr.replyMailType) ? 'messageSelector' : 'toSelector';
+ this.$node.html(data.markup).show();
+ this.select(focusSelector).focus();
+ };
+
+ this.cancel = function() {
+ this.$node.html('').hide();
+ };
+
+ this.requestSend = function() {
+ var data = {
+ to_id: this.select('selectedRecipientSelector').attr('id'),
+ subject: this.select('subjectSelector').text(),
+ message: this.select('messageSelector').text(),
+ currentFolder: this.attr.selectedFolders[0]
+ };
+ this.trigger('uiSendRequested', data);
+ this.$node.hide();
+ };
+
+ this.enableSend = function() {
+ this.select('recipientHintSelector').attr('disabled', 'disabled');
+ this.select('sendSelector').removeAttr('disabled');
+ };
+
+ this.removeHint = function(ev, data) {
+ $(ev.target).html('').removeClass(this.attr.hintClass);
+ };
+
+ this.updateMailItemSelections = function(ev, data) {
+ this.attr.selectedMailItems = data.selectedIds;
+ }
+
+ this.updateFolderSelections = function(ev, data) {
+ this.attr.selectedFolders = data.selectedIds;
+ }
+
+ this.after('initialize', function() {
+ this.on(document, 'dataComposeBoxServed', this.launchComposeBox);
+ this.on(document, 'uiForwardMail', this.forward);
+ this.on(document, 'uiReplyToMail', this.reply);
+ this.on(document, 'uiMailItemSelectionChanged', this.updateMailItemSelections);
+ this.on(document, 'uiFolderSelectionChanged', this.updateFolderSelections);
+
+ //the following bindings use delegation so that the event target is read at event time
+ this.on(document, "click", {
+ 'cancelSelector': this.cancel,
+ 'sendSelector': this.requestSend,
+ 'newControlSelector': this.newMail
+ });
+ this.on('change', {
+ 'recipientSelector': this.enableSend
+ });
+ this.on('keydown', {
+ 'hintSelector': this.removeHint
+ });
+ });
+ }
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/folders.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/folders.js
new file mode 100644
index 0000000000..f8504939eb
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/folders.js
@@ -0,0 +1,34 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ './with_select'
+ ],
+
+ function(defineComponent, withSelect) {
+
+ return defineComponent(folders, withSelect);
+
+ function folders() {
+
+ this.defaultAttrs({
+ selectedClass: 'selected',
+ selectionChangedEvent: 'uiFolderSelectionChanged',
+
+ //selectors
+ itemSelector: 'li.folder-item',
+ selectedItemSelector: 'li.folder-item.selected'
+ });
+
+ this.fetchMailItems = function(ev, data) {
+ this.trigger('uiMailItemsRequested', {folder: data.selectedIds[0]});
+ }
+
+ this.after('initialize', function() {
+ this.on('uiFolderSelectionChanged', this.fetchMailItems);
+ });
+ }
+ }
+);
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);
+ });
+ }
+ }
+);
+
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');
+ });
+ }
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/move_to_selector.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/move_to_selector.js
new file mode 100644
index 0000000000..e077e6aff3
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/move_to_selector.js
@@ -0,0 +1,79 @@
+'use strict';
+
+define(
+
+ [
+ 'flight/lib/component',
+ './with_select'
+ ],
+
+ function(defineComponent, withSelect) {
+
+ return defineComponent(moveToSelector, withSelect);
+
+ function moveToSelector() {
+
+ this.defaultAttrs({
+ selectionChangedEvent: 'uiMoveToSelectionChanged',
+ selectedMailItems: [],
+ selectedFolders: [],
+ //selectors
+ itemSelector: 'li.move-to-item',
+ selectedItemSelector: 'li.move-to-item.selected'
+ });
+
+ this.requestSelectorWidget = function(ev, data) {
+ this.trigger('uiAvailableFoldersRequested', {
+ folder: this.attr.selectedFolders[0]
+ })
+ };
+
+ this.launchSelector = function(ev, data) {
+ var controlPosition = $(this.attr.moveActionSelector).offset();
+ this.$node.html(data.markup).show().css({
+ left: controlPosition.left,
+ top: controlPosition.top + $(this.attr.moveActionSelector).outerHeight(),
+ width: $(this.attr.moveActionSelector).outerWidth()
+ });
+ window.setTimeout(
+ (function() {
+ this.on(document, 'click', this.hideSelector)
+ }).bind(this), 0);
+ };
+
+ this.hideSelector = function() {
+ this.off(document, 'click', this.hideSelector);
+ this.$node.hide();
+ }
+
+ this.updateMailItemSelections = function(ev, data) {
+ this.attr.selectedMailItems = data.selectedIds;
+ }
+
+ this.updateFolderSelections = function(ev, data) {
+ this.attr.selectedFolders = data.selectedIds;
+ }
+
+ this.requestMoveTo = function(ev, data) {
+ this.trigger('uiMoveItemsRequested', {
+ itemIds: this.attr.selectedMailItems,
+ fromFolder: this.attr.selectedFolders[0],
+ toFolder: data.selectedIds[0]
+ });
+ this.$node.hide();
+ };
+
+ this.after('initialize', function() {
+ //show selector widget
+ this.on(document, 'uiMoveMail', this.requestSelectorWidget);
+ this.on(document, 'dataMoveToItemsServed', this.launchSelector);
+ //listen for other selections
+ this.on(document, 'uiMailItemSelectionChanged', this.updateMailItemSelections);
+ this.on(document, 'uiFolderSelectionChanged', this.updateFolderSelections);
+ //move items
+ this.on('uiMoveToSelectionChanged', this.requestMoveTo);
+
+ });
+ }
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/with_select.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/with_select.js
new file mode 100644
index 0000000000..2a99feaadf
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_ui/with_select.js
@@ -0,0 +1,64 @@
+'use strict';
+
+define(
+
+ function() {
+
+ return withSelect;
+
+ function withSelect() {
+
+ this.defaultAttrs({
+ selectedIds: []
+ });
+
+ this.initializeSelections = function() {
+ this.select('selectedItemSelector').toArray().forEach(function(el) {
+ this.attr.selectedIds.push(el.getAttribute('id'));
+ }, this);
+ };
+
+ this.getSelectedIds = function() {
+ return this.attr.selectedIds;
+ };
+
+ this.toggleItemSelect = function(ev, data) {
+ var $item = $(data.el), append;
+
+ if ($item.hasClass(this.attr.selectedClass)) {
+ this.unselectItem($item);
+ } else {
+ append = this.attr.allowMultiSelect && (ev.metaKey || ev.ctrlKey || ev.shiftKey);
+ this.selectItem($item, append);
+ }
+ };
+
+ this.selectItem = function($item, append) {
+ if (!append) {
+ this.select('selectedItemSelector').removeClass(this.attr.selectedClass);
+ this.attr.selectedIds = [];
+ }
+ $item.addClass(this.attr.selectedClass);
+
+ this.attr.selectedIds.push($item.attr('id'));
+ this.trigger(this.attr.selectionChangedEvent, {selectedIds: this.attr.selectedIds});
+ };
+
+ this.unselectItem = function($item) {
+ $item.removeClass(this.attr.selectedClass);
+
+ var thisIdIndex = this.attr.selectedIds.indexOf($item.attr('id'));
+ this.attr.selectedIds.splice(thisIdIndex, 1);
+ this.trigger(this.attr.selectionChangedEvent, {selectedIds: this.attr.selectedIds});
+ };
+
+ this.after("initialize", function() {
+ this.on('click', {
+ 'itemSelector': this.toggleItemSelect
+ });
+
+ this.initializeSelections();
+ });
+ }
+ }
+);
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/css/custom.css b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/css/custom.css
new file mode 100644
index 0000000000..697197a075
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/css/custom.css
@@ -0,0 +1,102 @@
+.modal.fade.in {
+ left: 5%;
+ top: 10%;
+ margin: auto auto auto auto;
+}
+
+table {
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+td.mailContact,
+span.mailSubject,
+span.mailMessage {
+ font-size: 15px;
+}
+
+td.mailContact,
+span.mailSubject {
+ font-weight: bold;
+}
+
+tr.mail-item.selected td,
+li.folder-item.selected,
+li.move-to-item.selected {
+ background-color: #D9EDF7;
+}
+
+tr.mail-item.selected:hover td,
+li.folder-item.selected:hover,
+li.move-to-item.selected:hover {
+ background-color: #C1E1FF;
+}
+
+li.folder-item:hover,
+li.move-to-item:hover {
+ background-color: #EDEDED;
+}
+
+li.folder-item,
+li.move-to-item {
+ padding: 3px 0;
+ margin-left: -15px;
+ font-size: 15px;
+ cursor:pointer;
+}
+
+li.move-to-item {
+ text-align: center;
+ margin-right: -15px;
+}
+
+#new_mail {
+ width: 100px;
+}
+
+div.compose-box {
+ position: absolute;
+ z-index: 10;
+ background-color: #FFFFFF;
+ width: 350px;
+ border: 1px solid;
+}
+
+div.compose-body {
+ padding: 0;
+}
+
+div.compose-header {
+ font-size: 15px;
+}
+
+#recipient_select {
+ width: 90%;
+ margin-bottom: 0;
+ font-weight: bold;
+}
+
+div.hint {
+ border: 1px solid #EAEAEA;
+ color:#CACACA;
+}
+
+#compose_message {
+ height: 180px;
+}
+
+#compose_subject,
+#compose_message {
+ font-size: 15px;
+ padding: 15px;
+}
+
+#move_to_selector {
+ position: absolute;
+ z-index: 10;
+ background-color: #FFFFFF;
+ border: 1px solid;
+} \ No newline at end of file
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/data.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/data.js
new file mode 100644
index 0000000000..3a567c2264
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/data.js
@@ -0,0 +1,110 @@
+'use strict';
+
+define(
+ function() {
+ return {
+ folders: ["inbox", "later", "sent", "trash"],
+ contacts: [
+ {
+ "id": "contact_342",
+ "firstName": "Michael",
+ "lastName": "Smith",
+ "email": "ms@proxyweb.com"
+ },
+ {
+ "id": "contact_377",
+ "firstName": "Mary",
+ "lastName": "Jones",
+ "email": "mary@jones.net"
+ },
+ {
+ "id": "contact_398",
+ "firstName": "Billy",
+ "lastName": "Idiot",
+ "email": "william_idiot@gmail.com"
+ }
+ ],
+ mail: [
+ {
+ "id": "mail_2139",
+ "contact_id": "contact_342",
+ "folders": ["inbox"],
+ "time": 1334891976104,
+ "subject": "Consectetur adipiscing elit",
+ "message": "Vestibulum vestibulum varius diam in iaculis. Praesent ultrices dui vitae nibh malesuada non iaculis ante vulputate. Suspendisse feugiat ultricies egestas. Aenean a odio libero. Quisque mollis leo et est euismod sit amet dignissim sapien venenatis. Morbi interdum adipiscing massa"
+ },
+ {
+ "id": "mail_2143",
+ "contact_id": "contact_377",
+ "folders": ["inbox", "later"],
+ "important": "true",
+ "time": 1334884976104,
+ "subject": "Neque porro quisquam velit!!",
+ "message": "Curabitur sollicitudin mi eget sapien posuere semper. Fusce at neque et lacus luctus vulputate vehicula ac enim"
+ },
+ {
+ "id": "mail_2154",
+ "contact_id": "contact_398",
+ "folders": ["inbox"],
+ "important": "true",
+ "unread": "true",
+ "time": 1334874976199,
+ "subject": "Proin egestas aliquam :)",
+ "message": "Aenean nec erat id ipsum faucibus tristique. Nam blandit est lacinia turpis consectetur elementum. Nulla in risus ut sapien dignissim feugiat. Proin ultrices sodales imperdiet. Vestibulum vehicula blandit tincidunt. Vivamus posuere rhoncus orci, porta commodo mauris aliquam nec"
+ },
+ {
+ "id": "mail_2176",
+ "contact_id": "contact_377",
+ "folders": ["inbox"],
+ "time": 1334884976104,
+ "subject": "Sed ut perspiciatis unde omnis?",
+ "message": "laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem."
+ },
+ {
+ "id": "mail_2191",
+ "contact_id": "contact_398",
+ "folders": ["inbox"],
+ "unread": "true",
+ "time": 1334874976199,
+ "subject": "At vero eos et accusamus!",
+ "message": "Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat"
+ },
+ {
+ "id": "mail_2203",
+ "contact_id": "contact_377",
+ "folders": ["later"],
+ "important": "true",
+ "time": 1334874576199,
+ "subject": "Mi netus convallis",
+ "message": "Egestas morbi at. Curabitur aliquet et commodo nonummy, aliquam quis arcu, sed pellentesque vitae molestie mattis magna, in eget, risus nulla vivamus vulputate"
+ },
+ {
+ "id": "mail_2212",
+ "contact_id": "contact_398",
+ "folders": ["sent"],
+ "time": 1334874579867,
+ "subject": "Fusce tristique pretium eros a gravida",
+ "message": "Proin malesuada"
+ },
+ {
+ "id": "mail_2021",
+ "contact_id": "contact_342",
+ "folders": ["trash"],
+ "time": 1134874579824,
+ "subject": "Phasellus vitae interdum nulla.",
+ "message": "Pellentesque quam eros, mollis quis vulputate eget, pellentesque nec ipsum. Cras dignissim fringilla ligula, ac ullamcorper dui convallis blandit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam id nunc ac orci hendrerit faucibus vel in ante. Mauris nec est turpis, ut fringilla mi. Suspendisse vel tortor at nulla facilisis venenatis in sit amet ligula."
+ },
+ {
+ "id": "mail_1976",
+ "contact_id": "contact_377",
+ "folders": ["trash"],
+ "time": 1034874579813,
+ "subject": "Fusce tristique pretium :(",
+ "message": "aliquam quis arcu."
+ }
+ ]
+ };
+ return data;
+ }
+);
+
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/templates.js b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/templates.js
new file mode 100644
index 0000000000..99625bd830
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/templates.js
@@ -0,0 +1,62 @@
+'use strict';
+
+define(
+ function() {
+ var mailItem =
+ '{{#mailItems}}\
+ <tr id="{{id}}" class="mail-item">\
+ {{#important}}\
+ <td class="span1"><span class="label label-important">Important</span></td>\
+ {{/important}}\
+ {{^important}}\
+ <td class="span1"><span>&nbsp;</span></td>\
+ {{/important}}\
+ <td class="span2 mailContact">{{name}}</td>\
+ <td class="span8">\
+ <span class="mailSubject">\
+ {{formattedSubject}}\
+ </span>\
+ <span class="mailMessage">\
+ - <a href="#">{{formattedMessage}}</a>\
+ </span>\
+ </td>\
+ </tr>\
+ {{/mailItems}}';
+
+ var composeBox =
+ '<div id="compose_to" class="modal-header compose-header">\
+ To: <select id="recipient_select">\
+ {{^reply}}<option id="recipient_hint" class="hint" style="color:#CACACA" >[Select Recipient]</option>{{/reply}}\
+ {{#contacts}}\
+ <option id="{{id}}"{{#recipient}} selected{{/recipient}}>{{firstName}} {{lastName}}</option>\
+ {{/contacts}}\
+ </select>\
+ </div>\
+ <div class="modal-body compose-body">\
+ <div id="compose_subject" class="{{#newMail}}hint{{/newMail}}{{^newMail}}compose-header{{/newMail}}" contentEditable="true">\
+ {{subject}}\
+ </div>\
+ <div id="compose_message" class="hint" contentEditable="true">\
+ {{message}}\
+ </div>\
+ </div>\
+ <div class="modal-footer">\
+ <button id="send_composed" {{^reply}}disabled="disabled"{{/reply}} class="btn btn-primary">Send</button>\
+ <button id="cancel_composed" class="btn">Cancel</button>\
+ </div>';
+
+ var moveToSelector =
+ '<ul class="nav nav-list">\
+ {{#moveToItems}}\
+ <li id="{{.}}" class="move-to-item">{{.}}</li>\
+ {{/moveToItems}}\
+ </ul>';
+
+ return {
+ mailItem: mailItem,
+ composeBox: composeBox,
+ moveToSelector: moveToSelector
+ }
+ }
+
+);