diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/flightjs-example-app/app/component_data')
3 files changed, 213 insertions, 0 deletions
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); + }); + } + + } +); |