Merge pull request #214 from ONLYOFFICE/feature/pe-load-styles

Feature/pe load styles
This commit is contained in:
Julia Radzhabova 2019-07-23 10:24:55 +03:00 committed by GitHub
commit 202b1057a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 14 deletions

View file

@ -1960,26 +1960,51 @@ define([
me.toolbar.listTheme.menuPicker.store.reset([]); // remove all me.toolbar.listTheme.menuPicker.store.reset([]); // remove all
var themeStore = this.getCollection('SlideThemes'), var themeStore = this.getCollection('SlideThemes'),
mainController = this.getApplication().getController('Main'); mainController = this.getApplication().getController('Main'),
imageUrl = (window.devicePixelRatio > 1) ? '../../../../sdkjs/common/Images/themes_thumbnail@2x.png' : '../../../../sdkjs/common/Images/themes_thumbnail.png';
if (themeStore) { if (themeStore) {
var arr = []; var arr1 = [], arr2 = [];
_.each(defaultThemes.concat(docThemes), function(theme) { _.each(defaultThemes, function(theme, index) {
arr.push(new Common.UI.DataViewModel({ var tip = mainController.translationTable[theme.get_Name()] || theme.get_Name();
imageUrl: theme.get_Image(), arr1.push(new Common.UI.DataViewModel({
imageUrl: imageUrl,
uid : Common.UI.getId(), uid : Common.UI.getId(),
themeId : theme.get_Index(), themeId : theme.get_Index(),
tip : mainController.translationTable[theme.get_Name()] || theme.get_Name(), tip : tip,
itemWidth : 85, itemWidth : 85,
itemHeight : 38 itemHeight : 38,
offsety : index * 38
})); }));
me.toolbar.listTheme.menuPicker.store.add({ arr2.push({
imageUrl: theme.get_Image(), imageUrl: imageUrl,
uid : Common.UI.getId(), uid : Common.UI.getId(),
themeId : theme.get_Index(), themeId : theme.get_Index(),
tip : mainController.translationTable[theme.get_Name()] || theme.get_Name() tip : tip,
offsety : index * 38
}); });
}); });
themeStore.reset(arr); _.each(docThemes, function(theme) {
var image = theme.get_Image(),
tip = mainController.translationTable[theme.get_Name()] || theme.get_Name();
arr1.push(new Common.UI.DataViewModel({
imageUrl: image,
uid : Common.UI.getId(),
themeId : theme.get_Index(),
tip : tip,
itemWidth : 85,
itemHeight : 38,
offsety : 0
}));
arr2.push({
imageUrl: image,
uid : Common.UI.getId(),
themeId : theme.get_Index(),
tip : tip,
offsety : 0
});
});
themeStore.reset(arr1);
me.toolbar.listTheme.menuPicker.store.reset(arr2);
} }
if (me.toolbar.listTheme.menuPicker.store.length > 0 && me.toolbar.listTheme.rendered){ if (me.toolbar.listTheme.menuPicker.store.length > 0 && me.toolbar.listTheme.rendered){

View file

@ -2032,7 +2032,7 @@ define([
store : PE.getCollection('SlideThemes'), store : PE.getCollection('SlideThemes'),
itemTemplate: _.template([ itemTemplate: _.template([
'<div class="style" id="<%= id %>" style="width: <%= itemWidth %>px;">', '<div class="style" id="<%= id %>" style="width: <%= itemWidth %>px;">',
'<div style="background-image: url(<%= imageUrl %>); width: <%= itemWidth %>px; height: <%= itemHeight %>px;"/>', '<div style="background-image: url(<%= imageUrl %>); width: <%= itemWidth %>px; height: <%= itemHeight %>px;background-position: 0 -<%= offsety %>px;background-size: cover;"/>',
'</div>' '</div>'
].join('')) ].join(''))
}).on('item:click', function(picker, item, record, e) { }).on('item:click', function(picker, item, record, e) {

View file

@ -804,12 +804,12 @@ define([
me.listTheme.fieldPicker.itemTemplate = _.template([ me.listTheme.fieldPicker.itemTemplate = _.template([
'<div class="style" id="<%= id %>">', '<div class="style" id="<%= id %>">',
'<div style="background-image: url(<%= imageUrl %>); width: ' + me.listTheme.itemWidth + 'px; height: ' + me.listTheme.itemHeight + 'px;"/>', '<div style="background-image: url(<%= imageUrl %>); width: ' + me.listTheme.itemWidth + 'px; height: ' + me.listTheme.itemHeight + 'px; background-position: 0 -<%= offsety %>px;"/>',
'</div>' '</div>'
].join('')); ].join(''));
me.listTheme.menuPicker.itemTemplate = _.template([ me.listTheme.menuPicker.itemTemplate = _.template([
'<div class="style" id="<%= id %>">', '<div class="style" id="<%= id %>">',
'<div style="background-image: url(<%= imageUrl %>); width: ' + me.listTheme.itemWidth + 'px; height: ' + me.listTheme.itemHeight + 'px;"/>', '<div style="background-image: url(<%= imageUrl %>); width: ' + me.listTheme.itemWidth + 'px; height: ' + me.listTheme.itemHeight + 'px; background-position: 0 -<%= offsety %>px;"/>',
'</div>' '</div>'
].join('')); ].join(''));