diff --git a/core/js/contactsmenu.js b/core/js/contactsmenu.js index b0f302e159..8c9b7060a7 100644 --- a/core/js/contactsmenu.js +++ b/core/js/contactsmenu.js @@ -25,67 +25,6 @@ (function(OC, $, _, Handlebars) { 'use strict'; - var MENU_TEMPLATE = '' - + '' - + '' - + '
' - + '
'; - var CONTACTS_LIST_TEMPLATE = '' - + '{{#unless contacts.length}}' - + '
' - + ' ' - + '

' + t('core', 'No contacts found') + '

' - + '
' - + '{{/unless}}' - + '
' - + '{{#if contactsAppEnabled}}{{/if}}'; - var LOADING_TEMPLATE = '' - + '
' - + '
' - + '

{{loadingText}}

' - + '
'; - var ERROR_TEMPLATE = '' - + '
' - + ' ' - + '

' + t('core', 'Could not load your contacts') + '

' - + '
'; - var CONTACT_TEMPLATE = '' - + '{{#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}}'; - /** * @class Contact */ @@ -201,10 +140,7 @@ * @returns {undefined} */ template: function(data) { - if (!this._template) { - this._template = Handlebars.compile(CONTACT_TEMPLATE); - } - return this._template(data); + return OC.ContactsMenu.Templates['contact'](data); }, /** @@ -314,10 +250,7 @@ * @returns {string} */ loadingTemplate: function(data) { - if (!this._loadingTemplate) { - this._loadingTemplate = Handlebars.compile(LOADING_TEMPLATE); - } - return this._loadingTemplate(data); + return OC.ContactsMenu.Templates['loading'](data); }, /** @@ -325,10 +258,11 @@ * @returns {string} */ errorTemplate: function(data) { - if (!this._errorTemplate) { - this._errorTemplate = Handlebars.compile(ERROR_TEMPLATE); - } - return this._errorTemplate(data); + return OC.ContactsMenu.Templates['error']( + _.extend({ + couldNotLoadText: t('core', 'Could not load your contacts') + }, data) + ); }, /** @@ -336,10 +270,11 @@ * @returns {string} */ contentTemplate: function(data) { - if (!this._contentTemplate) { - this._contentTemplate = Handlebars.compile(MENU_TEMPLATE); - } - return this._contentTemplate(data); + return OC.ContactsMenu.Templates['menu']( + _.extend({ + searchContactsText: t('core', 'Search contacts …') + }, data) + ); }, /** @@ -347,10 +282,12 @@ * @returns {string} */ contactsTemplate: function(data) { - if (!this._contactsTemplate) { - this._contactsTemplate = Handlebars.compile(CONTACTS_LIST_TEMPLATE); - } - return this._contactsTemplate(data); + return OC.ContactsMenu.Templates['list']( + _.extend({ + noContactsFoundText: t('core', 'No contacts found'), + showAllContactsText: t('core', 'Show all contacts …') + }, data) + ); }, /** diff --git a/core/js/contactsmenu/contact.handlebars b/core/js/contactsmenu/contact.handlebars new file mode 100644 index 0000000000..a30b11462c --- /dev/null +++ b/core/js/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/js/contactsmenu/error.handlebars b/core/js/contactsmenu/error.handlebars new file mode 100644 index 0000000000..5115595b4e --- /dev/null +++ b/core/js/contactsmenu/error.handlebars @@ -0,0 +1,4 @@ +
+ +

{{couldNotLoadText}}

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

{{noContactsFoundText}}

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

{{loadingText}}

+
diff --git a/core/js/contactsmenu/menu.handlebars b/core/js/contactsmenu/menu.handlebars new file mode 100644 index 0000000000..7d7697e780 --- /dev/null +++ b/core/js/contactsmenu/menu.handlebars @@ -0,0 +1,4 @@ + + +
+
diff --git a/core/js/contactsmenu_templates.js b/core/js/contactsmenu_templates.js new file mode 100644 index 0000000000..8e30b21cb2 --- /dev/null +++ b/core/js/contactsmenu_templates.js @@ -0,0 +1,117 @@ +(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 "\"\"\n"; +},"3":function(container,depth0,helpers,partials,data) { + return "
\n"; +},"5":function(container,depth0,helpers,partials,data) { + var stack1, alias1=container.lambda, alias2=container.escapeExpression; + + return "\n \""\n\n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1, alias1=container.lambda, alias2=container.escapeExpression; + + return "\n \""\n\n"; +},"9":function(container,depth0,helpers,partials,data) { + var stack1; + + return " \n
\n \n
\n"; +},"10":function(container,depth0,helpers,partials,data) { + var helper, alias1=helpers.helperMissing, alias2="function", alias3=container.escapeExpression; + + return "
  • \n \n \"\"\n " + + alias3(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"title","hash":{},"data":data}) : helper))) + + "\n \n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=container.lambda, alias2=container.escapeExpression; + + return ((stack1 = helpers["if"].call(depth0,((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 : "") + + "
    \n
    " + + alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.fullName : stack1), depth0)) + + "
    \n
    " + + alias2(alias1(((stack1 = (depth0 != null ? depth0.contact : depth0)) != null ? stack1.lastMessage : stack1), depth0)) + + "
    \n
    \n" + + ((stack1 = helpers["if"].call(depth0,((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(depth0,((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(depth0,((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 "
    \n
    \n

    " + + container.escapeExpression(((helper = (helper = helpers.couldNotLoadText || (depth0 != null ? depth0.couldNotLoadText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"couldNotLoadText","hash":{},"data":data}) : helper))) + + "

    \n
    \n"; +},"useData":true}); +templates['list'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return "
    \n
    \n

    " + + container.escapeExpression(((helper = (helper = helpers.noContactsFoundText || (depth0 != null ? depth0.noContactsFoundText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"noContactsFoundText","hash":{},"data":data}) : helper))) + + "

    \n
    \n"; +},"3":function(container,depth0,helpers,partials,data) { + var helper, alias1=helpers.helperMissing, alias2="function", alias3=container.escapeExpression; + + return "
    " + + alias3(((helper = (helper = helpers.showAllContactsText || (depth0 != null ? depth0.showAllContactsText : depth0)) != null ? helper : alias1),(typeof helper === alias2 ? helper.call(depth0,{"name":"showAllContactsText","hash":{},"data":data}) : helper))) + + "
    "; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.unless.call(depth0,((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 : "") + + "
    \n" + + ((stack1 = helpers["if"].call(depth0,(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 "
    \n
    \n

    " + + container.escapeExpression(((helper = (helper = helpers.loadingText || (depth0 != null ? depth0.loadingText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0,{"name":"loadingText","hash":{},"data":data}) : helper))) + + "

    \n
    \n"; +},"useData":true}); +templates['menu'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var helper, alias1=helpers.helperMissing, alias2="function", alias3=container.escapeExpression; + + return "\n\n
    \n
    \n"; +},"useData":true}); +})(); \ No newline at end of file diff --git a/core/js/core.json b/core/js/core.json index 2ebc2e710e..19f361d2df 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -42,6 +42,7 @@ "sharedialogshareelistview.js", "octemplate.js", "contactsmenu.js", + "contactsmenu_templates.js", "eventsource.js", "config.js", "public/appconfig.js", diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php index 1505089d56..9c7da75e5f 100644 --- a/lib/private/legacy/template.php +++ b/lib/private/legacy/template.php @@ -124,6 +124,7 @@ class OC_Template extends \OC\Template\Base { OC_Util::addScript('files/fileinfo'); OC_Util::addScript('files/client'); OC_Util::addScript('contactsmenu'); + OC_Util::addScript('contactsmenu_templates'); if (\OC::$server->getConfig()->getSystemValue('debug')) { // Add the stuff we need always