From ea6af98bab40a13e0b2bc33e455e7a56e50269c4 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 11 Aug 2020 15:54:07 +0300 Subject: [PATCH] [DE] set off changin of underscore's templates to Mustache --- apps/common/main/lib/component/Button.js | 182 +++++++++++++----- .../main/app/template/Viewport.handlebars | 19 ++ .../template/compiled/Viewport.template.js | 6 + apps/documenteditor/main/app/view/Viewport.js | 4 +- apps/documenteditor/main/index.html | 5 + 5 files changed, 172 insertions(+), 44 deletions(-) create mode 100644 apps/documenteditor/main/app/template/Viewport.handlebars create mode 100644 apps/documenteditor/main/app/template/compiled/Viewport.template.js diff --git a/apps/common/main/lib/component/Button.js b/apps/common/main/lib/component/Button.js index 50c2c4020..8814b42cc 100644 --- a/apps/common/main/lib/component/Button.js +++ b/apps/common/main/lib/component/Button.js @@ -193,44 +193,108 @@ define([ 'print(\' \'); %>' + '<% } %>'; + // var templateHugeCaption = + // ''; + + // var templateHugeMenuCaption = + // '
' + + // '' + + // '
'; + + // var templateHugeSplitCaption = + // '
' + + // '' + + // '' + + // '
'; + + + Handlebars.registerHelper('check_if_svg', function (iconcls) { + return /svgicon/.test(iconcls); + }); + + var templateBtnIcon_hbrs = + '{{#if (iconImg)}}' + + '' + + '{{else if (check_if_svg iconCls)}}' + + 'print(\'' + + '\');' + + '{{else}}' + + ' ' + + '{{/if}}'; + var templateHugeCaption = - ''; var templateHugeMenuCaption = - '
' + - '' + '
'; var templateHugeSplitCaption = - '
' + - '' + - '' + '
'; + Handlebars.registerPartial('applyicon', + '{{#if (iconImg)}}' + + '' + + '{{else if (check_if_svg iconCls)}}' + + '' + + '' + + '' + + '{{else if iconCls}}' + + ' ' + + '{{/if}}'); + Common.UI.Button = Common.UI.BaseView.extend({ options : { id : null, @@ -248,45 +312,74 @@ define([ visible : true }, - template: _.template([ - '<% var applyicon = function() { %>', - '<% if (iconImg) { print(\'\'); } else { %>', - // '<% if (iconCls != "") { print(\' \'); }} %>', - '<% if (iconCls != "") { ' + - ' if (/svgicon/.test(iconCls)) {' + - 'print(\'' + - '\');' + - '} else ' + - 'print(\' \'); ' + - '}} %>', - '<% } %>', - '<% if ( !menu ) { %>', - '', + // '<% } else if (split == false) {%>', + // '
', + // '', + // '
', + // '<% } else { %>', + // '
', + // '', + // '', + // '
', + // '<% } %>' + // ].join('')), + template: Handlebars.compile([ + '{{#unless menu}}', + '', - '<% } else if (split == false) {%>', - '
', - '', '
', - '<% } else { %>', - '
', - '', - '', '
', - '<% } %>' + '{{/unless}}' ].join('')), initialize : function(options) { @@ -331,12 +424,15 @@ define([ if ( /icon-top/.test(me.cls) && !!me.caption && /huge/.test(me.cls) ) { if ( me.split === true ) { !!me.cls && (me.cls = me.cls.replace(/\s?(?:x-huge|icon-top)/g, '')); - this.template = _.template(templateHugeSplitCaption); + // this.template = _.template(templateHugeSplitCaption); + this.template = Handlebars.compile(templateHugeSplitCaption); } else if ( !!me.menu ) { - this.template = _.template(templateHugeMenuCaption); + // this.template = _.template(templateHugeMenuCaption); + this.template = Handlebars.compile(templateHugeMenuCaption); } else { - this.template = _.template(templateHugeCaption); + // this.template = _.template(templateHugeCaption); + this.template = Handlebars.compile(templateHugeCaption); } } diff --git a/apps/documenteditor/main/app/template/Viewport.handlebars b/apps/documenteditor/main/app/template/Viewport.handlebars new file mode 100644 index 000000000..41582b203 --- /dev/null +++ b/apps/documenteditor/main/app/template/Viewport.handlebars @@ -0,0 +1,19 @@ +
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
diff --git a/apps/documenteditor/main/app/template/compiled/Viewport.template.js b/apps/documenteditor/main/app/template/compiled/Viewport.template.js new file mode 100644 index 000000000..a05fc6f75 --- /dev/null +++ b/apps/documenteditor/main/app/template/compiled/Viewport.template.js @@ -0,0 +1,6 @@ +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +templates['Viewport'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { + return "
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n"; +},"useData":true}); +})(); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/Viewport.js b/apps/documenteditor/main/app/view/Viewport.js index a90ad6f6b..fc9705019 100644 --- a/apps/documenteditor/main/app/view/Viewport.js +++ b/apps/documenteditor/main/app/view/Viewport.js @@ -45,6 +45,7 @@ define([ 'jquery', 'underscore', 'backbone', + 'documenteditor/main/app/template/compiled/Viewport.template', 'common/main/lib/component/Layout' ], function (viewportTemplate, $, _, Backbone) { 'use strict'; @@ -53,7 +54,8 @@ define([ el: '#viewport', // Compile our stats template - template: _.template(viewportTemplate), + // template: _.template(viewportTemplate), + template: Handlebars.templates.Viewport, // Delegated events for creating new items, and clearing completed ones. events: { diff --git a/apps/documenteditor/main/index.html b/apps/documenteditor/main/index.html index 81e239298..3b133cbcc 100644 --- a/apps/documenteditor/main/index.html +++ b/apps/documenteditor/main/index.html @@ -5,6 +5,9 @@ + + + @@ -285,6 +288,8 @@ + +