Move the contactsmenu handlebars templates to the bundle

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-02-03 22:29:00 +01:00
parent a242ec695a
commit a498b72dec
No known key found for this signature in database
GPG Key ID: F941078878347C0C
15 changed files with 100 additions and 164 deletions

View File

@ -1,134 +0,0 @@
(function() {
var template = Handlebars.template, templates = OC.ContactsMenu.Templates = OC.ContactsMenu.Templates || {};
templates['contact'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<img src=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.avatar : stack1), depth0))
+ "&size=32\" class=\"avatar\" srcset=\""
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.avatar : stack1), depth0))
+ "&size=32 1x, "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.avatar : stack1), depth0))
+ "&size=64 2x, "
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.avatar : stack1), depth0))
+ "&size=128 4x\" alt=\"\">\n";
},"3":function(container,depth0,helpers,partials,data) {
return "<div class=\"avatar\"></div>\n";
},"5":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<a class=\"top-action\" href=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.topAction : stack1)) != null ? stack1.hyperlink : stack1), depth0))
+ "\" title=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.topAction : stack1)) != null ? stack1.title : stack1), depth0))
+ "\">\n <img src=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.topAction : stack1)) != null ? stack1.icon : stack1), depth0))
+ "\" alt=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.topAction : stack1)) != null ? stack1.title : stack1), depth0))
+ "\">\n</a>\n";
},"7":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<a class=\"second-action\" href=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.secondAction : stack1)) != null ? stack1.hyperlink : stack1), depth0))
+ "\" title=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.secondAction : stack1)) != null ? stack1.title : stack1), depth0))
+ "\">\n <img src=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.secondAction : stack1)) != null ? stack1.icon : stack1), depth0))
+ "\" alt=\""
+ alias2(alias1(((stack1 = ((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.secondAction : stack1)) != null ? stack1.title : stack1), depth0))
+ "\">\n</a>\n";
},"9":function(container,depth0,helpers,partials,data) {
var stack1;
return " <span class=\"other-actions icon-more\"></span>\n <div class=\"menu popovermenu\">\n <ul>\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.actions : stack1),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ " </ul>\n </div>\n";
},"10":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <li>\n <a href=\""
+ alias4(((helper = (helper = helpers.hyperlink || (depth0 != null ? depth0.hyperlink : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hyperlink","hash":{},"data":data}) : helper)))
+ "\">\n <img src=\""
+ alias4(((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"icon","hash":{},"data":data}) : helper)))
+ "\" alt=\"\">\n <span>"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "</span>\n </a>\n </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.lambda, alias3=container.escapeExpression;
return ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.avatar : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "")
+ "<div class=\"body\">\n <div class=\"full-name\">"
+ alias3(alias2(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.fullName : stack1), depth0))
+ "</div>\n <div class=\"last-message\">"
+ alias3(alias2(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.lastMessage : stack1), depth0))
+ "</div>\n</div>\n"
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.topAction : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.hasTwoActions : stack1),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.hasManyActions : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});
templates['error'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
return "<div class=\"emptycontent\">\n <div class=\"icon-search\"></div>\n <h2>"
+ container.escapeExpression(((helper = (helper = helpers.couldNotLoadText || (depth0 != null ? depth0.couldNotLoadText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"couldNotLoadText","hash":{},"data":data}) : helper)))
+ "</h2>\n</div>\n";
},"useData":true});
templates['jquery_entry'] = template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return "<img src=\""
+ container.escapeExpression(((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"icon","hash":{},"data":data}) : helper)))
+ "\">";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<li>\n <a href=\""
+ alias4(((helper = (helper = helpers.hyperlink || (depth0 != null ? depth0.hyperlink : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hyperlink","hash":{},"data":data}) : helper)))
+ "\">\n "
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n <span>"
+ alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper)))
+ "</span>\n </a>\n</li>\n";
},"useData":true});
templates['list'] = template({"1":function(container,depth0,helpers,partials,data) {
var helper;
return "<div class=\"emptycontent\">\n <div class=\"icon-search\"></div>\n <h2>"
+ container.escapeExpression(((helper = (helper = helpers.noContactsFoundText || (depth0 != null ? depth0.noContactsFoundText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"noContactsFoundText","hash":{},"data":data}) : helper)))
+ "</h2>\n</div>\n";
},"3":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<div class=\"footer\"><a href=\""
+ alias4(((helper = (helper = helpers.contactsAppURL || (depth0 != null ? depth0.contactsAppURL : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"contactsAppURL","hash":{},"data":data}) : helper)))
+ "\">"
+ alias4(((helper = (helper = helpers.showAllContactsText || (depth0 != null ? depth0.showAllContactsText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"showAllContactsText","hash":{},"data":data}) : helper)))
+ "</a></div>";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});
return ((stack1 = helpers.unless.call(alias1,((stack1 = (depth0 != null ? depth0.contacts : depth0)) != null ? stack1.length : stack1),{"name":"unless","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "<div id=\"contactsmenu-contacts\"></div>\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.contactsAppEnabled : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n";
},"useData":true});
templates['loading'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
return "<div class=\"emptycontent\">\n <div class=\"icon-loading\"></div>\n <h2>"
+ container.escapeExpression(((helper = (helper = helpers.loadingText || (depth0 != null ? depth0.loadingText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"loadingText","hash":{},"data":data}) : helper)))
+ "</h2>\n</div>\n";
},"useData":true});
templates['menu'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<label class=\"hidden-visually\" for=\"contactsmenu-search\">"
+ alias4(((helper = (helper = helpers.searchContactsText || (depth0 != null ? depth0.searchContactsText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"searchContactsText","hash":{},"data":data}) : helper)))
+ "</label>\n<input id=\"contactsmenu-search\" type=\"search\" placeholder=\""
+ alias4(((helper = (helper = helpers.searchContactsText || (depth0 != null ? depth0.searchContactsText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"searchContactsText","hash":{},"data":data}) : helper)))
+ "\" value=\""
+ alias4(((helper = (helper = helpers.searchTerm || (depth0 != null ? depth0.searchTerm : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"searchTerm","hash":{},"data":data}) : helper)))
+ "\">\n<div class=\"content\">\n</div>\n";
},"useData":true});
})();

61
core/js/dist/main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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 …')

View File

@ -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

View File

@ -32,6 +32,13 @@ module.exports = [
name: '[name].[ext]?[hash]',
limit: 8192
}
},
{
test: /\.handlebars/,
loader: "handlebars-loader",
query: {
extensions: '.handlebars'
}
}
]
},

View File

@ -120,7 +120,6 @@ class OC_Template extends \OC\Template\Base {
OC_Util::addScript('merged-template-prepend', null, true);
OC_Util::addScript('files/fileinfo');
OC_Util::addScript('files/client');
OC_Util::addScript('contactsmenu_templates');
OC_Util::addScript('core', 'dist/main', true);
if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {

33
package-lock.json generated
View File

@ -1282,7 +1282,7 @@
},
"async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
},
"async-each": {
@ -3383,6 +3383,37 @@
}
}
},
"handlebars-loader": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/handlebars-loader/-/handlebars-loader-1.7.1.tgz",
"integrity": "sha512-Q+Z/hDPQzU8ZTlVnAe/0T1LHABlyhL7opNcSKcQDhmUXK2ByGTqib1Z2Tfv4Ic50WqDcLFWQcOb3mhjcBRbscQ==",
"dev": true,
"requires": {
"async": "~0.2.10",
"fastparse": "^1.0.0",
"loader-utils": "1.0.x",
"object-assign": "^4.1.0"
},
"dependencies": {
"async": {
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
"integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=",
"dev": true
},
"loader-utils": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.0.4.tgz",
"integrity": "sha1-E/Vhl/FSOjBYkSSLTHJEVAhIQmw=",
"dev": true,
"requires": {
"big.js": "^3.1.3",
"emojis-list": "^2.0.0",
"json5": "^0.5.0"
}
}
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",

View File

@ -49,6 +49,7 @@
"babel-loader": "^8.0.5",
"css-loader": "^2.1.0",
"exports-loader": "^0.7.0",
"handlebars-loader": "^1.7.1",
"style-loader": "^0.23.1",
"url-loader": "^1.1.2",
"webpack": "^4.29.0",