Compare commits

...

3 commits

Author SHA1 Message Date
Maxim Kadushkin 856f260667 [component] button's refactoring 2019-09-24 14:00:01 +03:00
Julia Radzhabova f07418e832 [DE] Fix callback 2019-09-18 18:16:21 +03:00
Julia Radzhabova c0507f7749 [DE] Refactoring for localization 2019-09-18 18:12:50 +03:00
4 changed files with 81 additions and 79 deletions

View file

@ -56,8 +56,8 @@ Common.Locale = new(function() {
obj = obj[p[i]]; obj = obj[p[i]];
} }
if (obj) { if (obj && obj.prototype) {
obj[p[p.length - 1]] = l10n[prop]; obj.prototype[p[p.length - 1]] = l10n[prop];
} }
} }
} }

View file

@ -183,48 +183,48 @@ define([
}; };
var templateBtnIcon = var templateBtnIcon =
'<% if ( iconImg ) { %>' + '<% if ( opts.iconImg ) { %>' +
'<img src="<%= iconImg %>">' + '<img src="<%= opts.iconImg %>">' +
'<% } else { %>' + '<% } else { %>' +
'<% if (/svgicon/.test(iconCls)) {' + '<% if (/svgicon/.test(opts.iconCls)) {' +
'print(\'<svg width="26" height="26" class=\"icon\"><use href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'\"></use></svg>\');' + 'print(\'<svg width="26" height="26" class=\"icon\"><use href=\"#\' + /svgicon\\s(\\S+)/.exec(opts.iconCls)[1] + \'\"></use></svg>\');' +
'} else ' + '} else ' +
'print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); %>' + 'print(\'<i class=\"icon \' + opts.iconCls + \'\">&nbsp;</i>\'); %>' +
'<% } %>'; '<% } %>';
var templateHugeCaption = var templateHugeCaption =
'<button type="button" class="btn <%= cls %>" id="<%= id %>" > ' + '<button type="button" class="btn <%= opts.cls %>" id="<%= opts.id %>" > ' +
'<div class="inner-box-icon">' + '<div class="inner-box-icon">' +
templateBtnIcon + templateBtnIcon +
'</div>' + '</div>' +
'<div class="inner-box-caption">' + '<div class="inner-box-caption">' +
'<span class="caption"><%= caption %></span>' + '<span class="caption"><%= opts.caption %></span>' +
'</div>' + '</div>' +
'</button>'; '</button>';
var templateHugeMenuCaption = var templateHugeMenuCaption =
'<div class="btn-group icon-top" id="<%= id %>" style="<%= style %>">' + '<div class="btn-group icon-top" id="<%= opts.id %>" style="<%= opts.style %>">' +
'<button type="button" class="btn dropdown-toggle <%= cls %>" data-toggle="dropdown">' + '<button type="button" class="btn dropdown-toggle <%= opts.cls %>" data-toggle="dropdown">' +
'<div class="inner-box-icon">' + '<div class="inner-box-icon">' +
templateBtnIcon + templateBtnIcon +
'</div>' + '</div>' +
'<div class="inner-box-caption">' + '<div class="inner-box-caption">' +
'<span class="caption"><%= caption %></span>' + '<span class="caption"><%= opts.caption %></span>' +
'<i class="caret img-commonctrl"></i>' + '<i class="caret img-commonctrl"></i>' +
'</div>' + '</div>' +
'</button>' + '</button>' +
'</div>'; '</div>';
var templateHugeSplitCaption = var templateHugeSplitCaption =
'<div class="btn-group x-huge split icon-top" id="<%= id %>" style="<%= style %>">' + '<div class="btn-group x-huge split icon-top" id="<%= opts.id %>" style="<%= opts.style %>">' +
'<button type="button" class="btn <%= cls %> inner-box-icon">' + '<button type="button" class="btn <%= opts.cls %> inner-box-icon">' +
'<span class="btn-fixflex-hcenter">' + '<span class="btn-fixflex-hcenter">' +
templateBtnIcon + templateBtnIcon +
'</span>' + '</span>' +
'</button>' + '</button>' +
'<button type="button" class="btn <%= cls %> inner-box-caption dropdown-toggle" data-toggle="dropdown">' + '<button type="button" class="btn <%= opts.cls %> inner-box-caption dropdown-toggle" data-toggle="dropdown">' +
'<span class="btn-fixflex-vcenter">' + '<span class="btn-fixflex-vcenter">' +
'<span class="caption"><%= caption %></span>' + '<span class="caption"><%= opts.caption %></span>' +
'<i class="caret img-commonctrl"></i>' + '<i class="caret img-commonctrl"></i>' +
'</span>' + '</span>' +
'</button>' + '</button>' +
@ -249,43 +249,49 @@ define([
template: _.template([ template: _.template([
'<% var applyicon = function() { %>', '<% var applyicon = function() { %>',
'<% if (iconImg) { print(\'<img src=\"\' + iconImg + \'\">\'); } else { %>', '<% if (opts.iconImg) { print(\'<img src=\"\' + opts.iconImg + \'\">\'); } else { %>',
// '<% if (iconCls != "") { print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); }} %>', // '<% if (iconCls != "") { print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); }} %>',
'<% if (iconCls != "") { ' + '<% if (opts.iconCls != "") { ' +
' if (/svgicon/.test(iconCls)) {' + ' if (/svgicon/.test(opts.iconCls)) {' +
'print(\'<svg class=\"icon\"><use xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'\"></use></svg>\');' + 'print(\'<svg class=\"icon\"><use xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(opts.iconCls)[1] + \'\"></use></svg>\');' +
'} else ' + '} else ' +
'print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); ' + 'print(\'<i class=\"icon \' + opts.iconCls + \'\">&nbsp;</i>\'); ' +
'}} %>', '}} %>',
'<% } %>', '<% } %>',
'<% if ( !menu ) { %>', '<% if ( !opts.menu ) { %>',
'<button type="button" class="btn <%= cls %>" id="<%= id %>" style="<%= style %>">', '<button type="button" class="btn <%= opts.cls %>" id="<%= opts.id %>" style="<%= opts.style %>">',
'<% applyicon() %>', '<% applyicon() %>',
'<span class="caption"><%= caption %></span>', '<span class="caption"><%= opts.caption %></span>',
'</button>', '</button>',
'<% } else if (split == false) {%>', '<% } else if (opts.split == false) {%>',
'<div class="btn-group" id="<%= id %>" style="<%= style %>">', '<div class="btn-group" id="<%= opts.id %>" style="<%= opts.style %>">',
'<button type="button" class="btn dropdown-toggle <%= cls %>" data-toggle="dropdown">', '<button type="button" class="btn dropdown-toggle <%= opts.cls %>" data-toggle="dropdown">',
'<% applyicon() %>', '<% applyicon() %>',
'<span class="caption"><%= caption %></span>', '<span class="caption"><%= opts.caption %></span>',
'<span class="inner-box-caret">' + '<span class="inner-box-caret">' +
'<i class="caret img-commonctrl"></i>' + '<i class="caret img-commonctrl"></i>' +
'</span>', '</span>',
'</button>', '</button>',
'</div>', '</div>',
'<% } else { %>', '<% } else { %>',
'<div class="btn-group split" id="<%= id %>" style="<%= style %>">', '<div class="btn-group split" id="<%= opts.id %>" style="<%= opts.style %>">',
'<button type="button" class="btn <%= cls %>">', '<button type="button" class="btn <%= opts.cls %>">',
'<% applyicon() %>', '<% applyicon() %>',
'<span class="caption"><%= caption %></span>', '<span class="caption"><%= opts.caption %></span>',
'</button>', '</button>',
'<button type="button" class="btn <%= cls %> dropdown-toggle" data-toggle="dropdown">', '<button type="button" class="btn <%= opts.cls %> dropdown-toggle" data-toggle="dropdown">',
'<i class="caret img-commonctrl"></i>', '<i class="caret img-commonctrl"></i>',
'<span class="sr-only"></span>', '<span class="sr-only"></span>',
'</button>', '</button>',
'</div>', '</div>',
'<% } %>' '<% } %>'
].join('')), ].join(''), null, {variable:'opts'}),
templates: {
hugesplitted : _.template(templateHugeSplitCaption, null, {variable:'opts'}),
hugewithmenu : _.template(templateHugeMenuCaption, null, {variable:'opts'}),
hugesimple : _.template(templateHugeCaption, null, {variable:'opts'})
},
initialize : function(options) { initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options); Common.UI.BaseView.prototype.initialize.call(this, options);
@ -328,12 +334,12 @@ define([
if ( /icon-top/.test(me.cls) && !!me.caption && /huge/.test(me.cls) ) { if ( /icon-top/.test(me.cls) && !!me.caption && /huge/.test(me.cls) ) {
if ( me.split === true ) { if ( me.split === true ) {
!!me.cls && (me.cls = me.cls.replace(/\s?(?:x-huge|icon-top)/g, '')); !!me.cls && (me.cls = me.cls.replace(/\s?(?:x-huge|icon-top)/g, ''));
this.template = _.template(templateHugeSplitCaption); this.template = this.templates.hugesplitted;
} else } else
if ( !!me.menu ) { if ( !!me.menu ) {
this.template = _.template(templateHugeMenuCaption); this.template = this.templates.hugewithmenu;
} else { } else {
this.template = _.template(templateHugeCaption); this.template = this.templates.hugesimple;
} }
} }

View file

@ -62,7 +62,7 @@ define([
], function ($, _, Backbone, template, template_view) { ], function ($, _, Backbone, template, template_view) {
'use strict'; 'use strict';
DE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend((function(){ DE.Views.Toolbar = Common.UI.Mixtbar.extend((function(){
return { return {
el: '#toolbar', el: '#toolbar',
@ -2326,5 +2326,5 @@ define([
textRemWatermark: 'Remove Watermark', textRemWatermark: 'Remove Watermark',
tipWatermark: 'Edit watermark' tipWatermark: 'Edit watermark'
} }
})(), DE.Views.Toolbar || {})); })());
}); });

View file

@ -159,8 +159,6 @@ require([
] ]
}); });
Common.Locale.apply(
function() {
require([ require([
'documenteditor/main/app/controller/Viewport', 'documenteditor/main/app/controller/Viewport',
'documenteditor/main/app/controller/DocumentHolder', 'documenteditor/main/app/controller/DocumentHolder',
@ -196,10 +194,8 @@ require([
,'common/main/lib/controller/Desktop' ,'common/main/lib/controller/Desktop'
], function() { ], function() {
window.compareVersions = true; window.compareVersions = true;
app.start(); Common.Locale.apply(app.start.bind(app));
}); });
}
);
}, function(err) { }, function(err) {
if (err.requireType == 'timeout' && !reqerr && window.requireTimeourError) { if (err.requireType == 'timeout' && !reqerr && window.requireTimeourError) {
reqerr = window.requireTimeourError(); reqerr = window.requireTimeourError();