diff options
author | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
---|---|---|
committer | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
commit | 04cf441c5ae18400c6b4865b0b37a71718dc9d46 (patch) | |
tree | dd0b0d049ec00389e2d4561b226c46eb1682b997 /web-ui/app/js/views | |
parent | 639a663a4c37020003586438fdcd7ac529a00f10 (diff) |
Add web-ui based on previous code
Diffstat (limited to 'web-ui/app/js/views')
-rw-r--r-- | web-ui/app/js/views/i18n.js | 18 | ||||
-rw-r--r-- | web-ui/app/js/views/recipientListFormatter.js | 16 | ||||
-rw-r--r-- | web-ui/app/js/views/templates.js | 46 |
3 files changed, 80 insertions, 0 deletions
diff --git a/web-ui/app/js/views/i18n.js b/web-ui/app/js/views/i18n.js new file mode 100644 index 00000000..4550e153 --- /dev/null +++ b/web-ui/app/js/views/i18n.js @@ -0,0 +1,18 @@ +/*global Handlebars */ + +define(['i18next'], function(i18n) { + 'use strict'; + + var self = function(str) { + return i18n.t(str); + }; + + self.get = self; + + self.init = function(path) { + i18n.init({detectLngQS: 'lang', fallbackLng: 'en', lowerCaseLng: true, getAsync: false, resGetPath: path + 'locales/__lng__/__ns__.json'}); + Handlebars.registerHelper('t', self.get.bind(self)); + }; + + return self; +}); diff --git a/web-ui/app/js/views/recipientListFormatter.js b/web-ui/app/js/views/recipientListFormatter.js new file mode 100644 index 00000000..c3d05858 --- /dev/null +++ b/web-ui/app/js/views/recipientListFormatter.js @@ -0,0 +1,16 @@ +/*global Handlebars */ + +define(function() { + 'use strict'; + Handlebars.registerHelper('formatRecipients', function (header) { + function wrapWith(begin, end) { + return function (x) { return begin + x + end; }; + } + + var to = _.map(header.to, wrapWith('<span class="to">', '</span>')); + var cc = _.map(header.cc, wrapWith('<span class="cc">cc: ', '</span>')); + var bcc = _.map(header.bcc, wrapWith('<span class="bcc">bcc: ', '</span>')); + + return new Handlebars.SafeString(to.concat(cc, bcc).join(', ')); + }); +}); diff --git a/web-ui/app/js/views/templates.js b/web-ui/app/js/views/templates.js new file mode 100644 index 00000000..cc120093 --- /dev/null +++ b/web-ui/app/js/views/templates.js @@ -0,0 +1,46 @@ +/*global Handlebars */ + +define(['hbs/templates'], function (templates) { + 'use strict'; + + var Templates = { + compose: { + box: window.Smail['app/templates/compose/compose_box.hbs'], + inlineBox: window.Smail['app/templates/compose/inline_box.hbs'], + replySection: window.Smail['app/templates/compose/reply_section.hbs'], + recipientInput: window.Smail['app/templates/compose/recipient_input.hbs'], + fixedRecipient: window.Smail['app/templates/compose/fixed_recipient.hbs'], + recipients: window.Smail['app/templates/compose/recipients.hbs'] + }, + tags: { + tagList: window.Smail['app/templates/tags/tag_list.hbs'], + tag: window.Smail['app/templates/tags/tag.hbs'], + tagInner: window.Smail['app/templates/tags/tag_inner.hbs'], + shortcut: window.Smail['app/templates/tags/shortcut.hbs'] + }, + userAlerts: { + message: window.Smail['app/templates/user_alerts/message.hbs'] + }, + mails: { + single: window.Smail['app/templates/mails/single.hbs'], + fullView: window.Smail['app/templates/mails/full_view.hbs'], + mailActions: window.Smail['app/templates/mails/mail_actions.hbs'], + sent: window.Smail['app/templates/mails/sent.hbs'] + }, + mailActions: { + actionsBox: window.Smail['app/templates/mail_actions/actions_box.hbs'], + composeTrigger: window.Smail['app/templates/mail_actions/compose_trigger.hbs'], + refreshTrigger: window.Smail['app/templates/mail_actions/refresh_trigger.hbs'], + paginationTrigger: window.Smail['app/templates/mail_actions/pagination_trigger.hbs'] + }, + noMessageSelected: window.Smail['app/templates/no_message_selected.hbs'], + search: { + trigger: window.Smail['app/templates/search/search_trigger.hbs'] + } + }; + + Handlebars.registerPartial('tag_inner', Templates.tags.tagInner); + Handlebars.registerPartial('recipients', Templates.compose.recipients); + + return Templates; +}); |