From a498b72dec99a3ef8a0e9a15caa0afe3af245176 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Sun, 3 Feb 2019 22:29:00 +0100
Subject: Move the contactsmenu handlebars templates to the bundle

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 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}}
+<img src="{{contact.avatar}}&size=32" class="avatar" srcset="{{contact.avatar}}&size=32 1x, {{contact.avatar}}&size=64 2x, {{contact.avatar}}&size=128 4x" alt="">
+{{else}}
+<div class="avatar"></div>
+{{/if}}
+<div class="body">
+	<div class="full-name">{{contact.fullName}}</div>
+	<div class="last-message">{{contact.lastMessage}}</div>
+</div>
+{{#if contact.topAction}}
+<a class="top-action" href="{{contact.topAction.hyperlink}}" title="{{contact.topAction.title}}">
+	<img src="{{contact.topAction.icon}}" alt="{{contact.topAction.title}}">
+</a>
+{{/if}}
+{{#if contact.hasTwoActions}}
+<a class="second-action" href="{{contact.secondAction.hyperlink}}" title="{{contact.secondAction.title}}">
+	<img src="{{contact.secondAction.icon}}" alt="{{contact.secondAction.title}}">
+</a>
+{{/if}}
+{{#if contact.hasManyActions}}
+	<span class="other-actions icon-more"></span>
+	<div class="menu popovermenu">
+		<ul>
+			{{#each contact.actions}}
+			<li>
+				<a href="{{hyperlink}}">
+					<img src="{{icon}}" alt="">
+					<span>{{title}}</span>
+				</a>
+			</li>
+			{{/each}}
+		</ul>
+	</div>
+{{/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 @@
+<div class="emptycontent">
+	<div class="icon-search"></div>
+	<h2>{{couldNotLoadText}}</h2>
+</div>
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}}
+<div class="emptycontent">
+	<div class="icon-search"></div>
+	<h2>{{noContactsFoundText}}</h2>
+</div>
+{{/unless}}
+<div id="contactsmenu-contacts"></div>
+{{#if contactsAppEnabled}}<div class="footer"><a href="{{contactsAppURL}}">{{showAllContactsText}}</a></div>{{/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 @@
+<div class="emptycontent">
+	<div class="icon-loading"></div>
+	<h2>{{loadingText}}</h2>
+</div>
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 @@
+<label class="hidden-visually" for="contactsmenu-search">{{searchContactsText}}</label>
+<input id="contactsmenu-search" type="search" placeholder="{{searchContactsText}}" value="{{searchTerm}}">
+<div class="content">
+</div>
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 = ''
 	+ '    </ul>'
 	+ '</div>';
 
+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 @@
+<li>
+	<a href="{{hyperlink}}">
+		{{#if icon}}<img src="{{icon}}">{{/if}}
+		<span>{{title}}</span>
+	</a>
+</li>
-- 
cgit v1.2.3