From a498b72dec99a3ef8a0e9a15caa0afe3af245176 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 3 Feb 2019 22:29:00 +0100 Subject: Move the contactsmenu handlebars templates to the bundle Signed-off-by: Roeland Jago Douma --- core/src/OC/contactsmenu.js | 19 ++++++++---- core/src/OC/contactsmenu/contact.handlebars | 34 ++++++++++++++++++++++ core/src/OC/contactsmenu/error.handlebars | 4 +++ core/src/OC/contactsmenu/list.handlebars | 8 +++++ core/src/OC/contactsmenu/loading.handlebars | 4 +++ core/src/OC/contactsmenu/menu.handlebars | 4 +++ core/src/jquery/contactsmenu.js | 6 ++-- .../jquery/contactsmenu/jquery_entry.handlebars | 6 ++++ 8 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 core/src/OC/contactsmenu/contact.handlebars create mode 100644 core/src/OC/contactsmenu/error.handlebars create mode 100644 core/src/OC/contactsmenu/list.handlebars create mode 100644 core/src/OC/contactsmenu/loading.handlebars create mode 100644 core/src/OC/contactsmenu/menu.handlebars create mode 100644 core/src/jquery/contactsmenu/jquery_entry.handlebars (limited to 'core/src') diff --git a/core/src/OC/contactsmenu.js b/core/src/OC/contactsmenu.js index 88218830337..ff3553a61ed 100644 --- a/core/src/OC/contactsmenu.js +++ b/core/src/OC/contactsmenu.js @@ -140,12 +140,14 @@ const ContactsListItemView = View.extend({ 'click .icon-more': '_onToggleActionsMenu' }, + contactTemplate: require('./contactsmenu/contact.handlebars'), + /** * @param {object} data * @returns {undefined} */ template: function (data) { - return OC.ContactsMenu.Templates['contact'](data); + return this.contactTemplate(data); }, /** @@ -236,6 +238,13 @@ const ContactsMenuView = View.extend({ 'input #contactsmenu-search': '_onSearch' }, + templates: { + loading: require('./contactsmenu/loading.handlebars'), + error: require('./contactsmenu/error.handlebars'), + menu: require('./contactsmenu/menu.handlebars'), + list: require('./contactsmenu/list.handlebars') + }, + /** * @returns {undefined} */ @@ -256,7 +265,7 @@ const ContactsMenuView = View.extend({ * @returns {string} */ loadingTemplate: function (data) { - return OC.ContactsMenu.Templates['loading'](data); + return this.templates.loading(data); }, /** @@ -264,7 +273,7 @@ const ContactsMenuView = View.extend({ * @returns {string} */ errorTemplate: function (data) { - return OC.ContactsMenu.Templates['error']( + return this.templates.error( _.extend({ couldNotLoadText: t('core', 'Could not load your contacts') }, data) @@ -276,7 +285,7 @@ const ContactsMenuView = View.extend({ * @returns {string} */ contentTemplate: function (data) { - return OC.ContactsMenu.Templates['menu']( + return this.templates.menu( _.extend({ searchContactsText: t('core', 'Search contacts …') }, data) @@ -288,7 +297,7 @@ const ContactsMenuView = View.extend({ * @returns {string} */ contactsTemplate: function (data) { - return OC.ContactsMenu.Templates['list']( + return this.templates.list( _.extend({ noContactsFoundText: t('core', 'No contacts found'), showAllContactsText: t('core', 'Show all contacts …') diff --git a/core/src/OC/contactsmenu/contact.handlebars b/core/src/OC/contactsmenu/contact.handlebars new file mode 100644 index 00000000000..a30b11462c4 --- /dev/null +++ b/core/src/OC/contactsmenu/contact.handlebars @@ -0,0 +1,34 @@ +{{#if contact.avatar}} + +{{else}} +
+{{/if}} +
+
{{contact.fullName}}
+
{{contact.lastMessage}}
+
+{{#if contact.topAction}} + + {{contact.topAction.title}} + +{{/if}} +{{#if contact.hasTwoActions}} + + {{contact.secondAction.title}} + +{{/if}} +{{#if contact.hasManyActions}} + + +{{/if}} diff --git a/core/src/OC/contactsmenu/error.handlebars b/core/src/OC/contactsmenu/error.handlebars new file mode 100644 index 00000000000..5115595b4e1 --- /dev/null +++ b/core/src/OC/contactsmenu/error.handlebars @@ -0,0 +1,4 @@ +
+ +

{{couldNotLoadText}}

+
diff --git a/core/src/OC/contactsmenu/list.handlebars b/core/src/OC/contactsmenu/list.handlebars new file mode 100644 index 00000000000..07699204db0 --- /dev/null +++ b/core/src/OC/contactsmenu/list.handlebars @@ -0,0 +1,8 @@ +{{#unless contacts.length}} +
+ +

{{noContactsFoundText}}

+
+{{/unless}} +
+{{#if contactsAppEnabled}}{{/if}} diff --git a/core/src/OC/contactsmenu/loading.handlebars b/core/src/OC/contactsmenu/loading.handlebars new file mode 100644 index 00000000000..7fb22a6ed8e --- /dev/null +++ b/core/src/OC/contactsmenu/loading.handlebars @@ -0,0 +1,4 @@ +
+
+

{{loadingText}}

+
diff --git a/core/src/OC/contactsmenu/menu.handlebars b/core/src/OC/contactsmenu/menu.handlebars new file mode 100644 index 00000000000..7d7697e780c --- /dev/null +++ b/core/src/OC/contactsmenu/menu.handlebars @@ -0,0 +1,4 @@ + + +
+
diff --git a/core/src/jquery/contactsmenu.js b/core/src/jquery/contactsmenu.js index 8ee97dd51e9..4f90640eda0 100644 --- a/core/src/jquery/contactsmenu.js +++ b/core/src/jquery/contactsmenu.js @@ -34,6 +34,8 @@ const LIST = '' + ' ' + ''; +const entryTemplate = require('./contactsmenu/jquery_entry.handlebars'); + $.fn.contactsMenu = function (shareWith, shareType, appendTo) { // 0 - user, 4 - email, 6 - remote var allowedTypes = [0, 4, 6]; @@ -80,7 +82,7 @@ $.fn.contactsMenu = function (shareWith, shareType, appendTo) { } actions.forEach(function (action) { - var template = OC.ContactsMenu.Templates['jquery_entry']; + var template = entryTemplate; $list.find('ul').append(template(action)); }); @@ -97,7 +99,7 @@ $.fn.contactsMenu = function (shareWith, shareType, appendTo) { title = t('core', 'Error fetching contact actions'); } - var template = OC.ContactsMenu.Templates['jquery_entry']; + var template = entryTemplate; $list.find('ul').append(template({ hyperlink: '#', title: title diff --git a/core/src/jquery/contactsmenu/jquery_entry.handlebars b/core/src/jquery/contactsmenu/jquery_entry.handlebars new file mode 100644 index 00000000000..cbd97056e5c --- /dev/null +++ b/core/src/jquery/contactsmenu/jquery_entry.handlebars @@ -0,0 +1,6 @@ +
  • + + {{#if icon}}{{/if}} + {{title}} + +
  • -- cgit v1.2.3