Commit 0ee4d6fc authored by rniwa@webkit.org's avatar rniwa@webkit.org

DoYouEvenBench: Add a test case for FlightJS

https://bugs.webkit.org/show_bug.cgi?id=121926

Reviewed by Antti Koivisto.

Add a FlightJS test case.

* DoYouEvenBench/benchmark.html:
* DoYouEvenBench/benchmark.js:
* DoYouEvenBench/flightjs-example-app: Added.
* DoYouEvenBench/flightjs-example-app/LICENSE.md: Added.
* DoYouEvenBench/flightjs-example-app/README.md: Added.
* DoYouEvenBench/flightjs-example-app/app: Added.
* DoYouEvenBench/flightjs-example-app/app/boot: Added.
* DoYouEvenBench/flightjs-example-app/app/boot/page.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/compose_box.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/mail_items.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/move_to.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/compose_box.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/folders.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/mail_controls.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/mail_items.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/move_to_selector.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/with_select.js: Added.
* DoYouEvenBench/flightjs-example-app/app/css: Added.
* DoYouEvenBench/flightjs-example-app/app/css/custom.css: Added.
* DoYouEvenBench/flightjs-example-app/app/data.js: Added.
* DoYouEvenBench/flightjs-example-app/app/templates.js: Added.
* DoYouEvenBench/flightjs-example-app/components: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap-responsive.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap-responsive.min.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap.min.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img/glyphicons-halflings-white.png: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img/glyphicons-halflings.png: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js/bootstrap.js: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js/bootstrap.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/.gitignore: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/CHANGES: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/CONTRIBUTORS.md: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/LICENSE: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/README.md: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/component.json: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-sham.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-sham.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-shim.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-shim.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/package.json: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h-kill.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h-matchers.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/index.html: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine-html.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine.css: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine_favicon.png: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/json2.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-array.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-date.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-function.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-object.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-string.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/.travis.yml: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/advice.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/component.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/compose.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/index.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/logger.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/registry.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/utils.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools/debug: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools/debug/debug.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/LICENSE.md: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/README.md: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/bower.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/lib/jasmine-flight.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery/lib/jasmine-jquery.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/component.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/composer.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/jquery.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/jquery.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/mustache: Added.
* DoYouEvenBench/flightjs-example-app/components/mustache/mustache.js: Added.
* DoYouEvenBench/flightjs-example-app/components/requirejs: Added.
* DoYouEvenBench/flightjs-example-app/components/requirejs/require.js: Added.
* DoYouEvenBench/flightjs-example-app/index.html: Added.
* DoYouEvenBench/flightjs-example-app/karma.conf.js: Added.
* DoYouEvenBench/flightjs-example-app/package.json: Added.
* DoYouEvenBench/flightjs-example-app/requireMain.js: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156425 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 234e0122
2013-09-25 Ryosuke Niwa <rniwa@webkit.org>
DoYouEvenBench: Add a test case for FlightJS
https://bugs.webkit.org/show_bug.cgi?id=121926
Reviewed by Antti Koivisto.
Add a FlightJS test case.
* DoYouEvenBench/benchmark.html:
* DoYouEvenBench/benchmark.js:
* DoYouEvenBench/flightjs-example-app: Added.
* DoYouEvenBench/flightjs-example-app/LICENSE.md: Added.
* DoYouEvenBench/flightjs-example-app/README.md: Added.
* DoYouEvenBench/flightjs-example-app/app: Added.
* DoYouEvenBench/flightjs-example-app/app/boot: Added.
* DoYouEvenBench/flightjs-example-app/app/boot/page.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/compose_box.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/mail_items.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_data/move_to.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/compose_box.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/folders.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/mail_controls.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/mail_items.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/move_to_selector.js: Added.
* DoYouEvenBench/flightjs-example-app/app/component_ui/with_select.js: Added.
* DoYouEvenBench/flightjs-example-app/app/css: Added.
* DoYouEvenBench/flightjs-example-app/app/css/custom.css: Added.
* DoYouEvenBench/flightjs-example-app/app/data.js: Added.
* DoYouEvenBench/flightjs-example-app/app/templates.js: Added.
* DoYouEvenBench/flightjs-example-app/components: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap-responsive.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap-responsive.min.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/css/bootstrap.min.css: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img/glyphicons-halflings-white.png: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/img/glyphicons-halflings.png: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js/bootstrap.js: Added.
* DoYouEvenBench/flightjs-example-app/components/bootstrap/js/bootstrap.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/.gitignore: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/CHANGES: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/CONTRIBUTORS.md: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/LICENSE: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/README.md: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/component.json: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-sham.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-sham.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-shim.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/es5-shim.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/package.json: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h-kill.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h-matchers.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/helpers/h.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/index.html: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine-html.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine.css: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/jasmine_favicon.png: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/lib/json2.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-array.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-date.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-function.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-object.js: Added.
* DoYouEvenBench/flightjs-example-app/components/es5-shim/tests/spec/s-string.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/.travis.yml: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/advice.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/component.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/compose.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/index.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/logger.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/registry.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/lib/utils.js: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools/debug: Added.
* DoYouEvenBench/flightjs-example-app/components/flight/tools/debug/debug.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/LICENSE.md: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/README.md: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/bower.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-flight/lib/jasmine-flight.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery/lib: Added.
* DoYouEvenBench/flightjs-example-app/components/jasmine-jquery/lib/jasmine-jquery.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/component.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/composer.json: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/jquery.js: Added.
* DoYouEvenBench/flightjs-example-app/components/jquery/jquery.min.js: Added.
* DoYouEvenBench/flightjs-example-app/components/mustache: Added.
* DoYouEvenBench/flightjs-example-app/components/mustache/mustache.js: Added.
* DoYouEvenBench/flightjs-example-app/components/requirejs: Added.
* DoYouEvenBench/flightjs-example-app/components/requirejs/require.js: Added.
* DoYouEvenBench/flightjs-example-app/index.html: Added.
* DoYouEvenBench/flightjs-example-app/karma.conf.js: Added.
* DoYouEvenBench/flightjs-example-app/package.json: Added.
* DoYouEvenBench/flightjs-example-app/requireMain.js: Added.
2013-09-19 Ryosuke Niwa <rniwa@webkit.org>
DoYouEvenBench: Indentations in benchmark.js and benchmark.html are all messed up
......
......@@ -113,7 +113,6 @@ BenchmarkRunner.suite({
name: 'jQuery/TodoMVC',
url: 'todomvc/architecture-examples/jquery/index.html',
prepare: function (contentWindow, contentDocument) {
var storage = [];
return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
element.focus();
return element;
......@@ -147,7 +146,6 @@ BenchmarkRunner.suite({
name: 'AngularJS/TodoMVC',
url: 'todomvc/architecture-examples/angularjs/index.html',
prepare: function (contentWindow, contentDocument) {
var storage = [];
return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
element.focus();
return element;
......@@ -179,9 +177,62 @@ BenchmarkRunner.suite({
]
});
var actionCount = 50;
BenchmarkRunner.suite({
name: 'FlightJS/MailClient',
url: 'flightjs-example-app/index.html',
prepare: function (contentWindow, contentDocument) {
return BenchmarkRunner.waitForElement('.span8').then(function (element) {
element.focus();
return element;
});
},
tests: [
['OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
contentDocument.getElementById('inbox').click();
for (var i = 0; i < actionCount; i++) {
contentDocument.getElementById('later').click();
contentDocument.getElementById('sent').click();
contentDocument.getElementById('trash').click();
contentDocument.getElementById('inbox').click();
}
}],
['MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
contentDocument.getElementById('inbox').click();
for (var i = 0; i < actionCount; i++) {
contentDocument.getElementById('mail_2139').click();
contentDocument.getElementById('move_mail').click();
contentDocument.querySelector('#move_to_selector #later').click();
contentDocument.getElementById('later').click();
contentDocument.getElementById('mail_2139').click();
contentDocument.getElementById('move_mail').click();
contentDocument.querySelector('#move_to_selector #trash').click();
contentDocument.getElementById('trash').click();
contentDocument.getElementById('mail_2139').click();
contentDocument.getElementById('move_mail').click();
contentDocument.querySelector('#move_to_selector #inbox').click();
contentDocument.getElementById('inbox').click();
}
}],
['Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
for (var i = 0; i < actionCount; i++) {
contentDocument.getElementById('new_mail').click();
var subject = contentDocument.getElementById('compose_subject');
var message = contentDocument.getElementById('compose_message');
subject.focus();
contentWindow.$(subject).trigger('keydown');
contentDocument.execCommand('InsertText', false, 'Hello');
message.focus();
contentWindow.$(message).trigger('keydown');
contentDocument.execCommand('InsertText', false, 'Hello,\n\nThis is a test message.\n\n- WebKitten');
contentDocument.getElementById('send_composed').click();
}
}],
]
});
</script>
</head>
<body>
<p></p>
</body>
</html>
......@@ -319,7 +319,7 @@ window.addEventListener('load', function () { BenchmarkRunner.listSuites(); });
(function () {
var style = document.createElement('style');
style.appendChild(document.createTextNode('iframe { width: 700px; height: 500px; border: 2px solid black; }'
style.appendChild(document.createTextNode('iframe { width: 1000px; height: 500px; border: 2px solid black; }'
+ 'ol { list-style: none; margin: 0; padding: 0; }'
+ 'ol ol { margin-left: 2em; list-position: outside; }'
+ '.running { text-decoration: underline; }'
......
Copyright (c) Twitter Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# Flight example app
[![Build Status](https://travis-ci.org/flightjs/example-app.png?branch=master)](http://travis-ci.org/flightjs/example-app)
An example Flight application.
'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;
}
);
'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);
});
}
}
);
'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);
});
}
}
);
'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);
});
}
}
);
'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]