Skip to content

Commit

Permalink
fix: some icons don't render
Browse files Browse the repository at this point in the history
  • Loading branch information
sekiju committed Nov 10, 2024
1 parent 7ef37db commit 91a4c32
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
24 changes: 13 additions & 11 deletions apps/common/main/lib/component/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ define([
'</svg>' +
'<% } else if (/svgicon/.test(iconCls)) { %>' +
'<svg class="icon permanent-icon <%= (iconCls ? iconCls.indexOf("icon-rtl") : -1) > -1 ? "icon-rtl" : "" %>"><use class="zoom-int" href="#<%= /svgicon\\s(\\S+)/.exec(iconCls)[1] %>"></use></svg>' +
'<% } else { %>' +
'<i class="icon <% iconCls %>"></i>' +
'<% } %>';
'<% } else { ' +
'print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); ' +
' } %>';

var templateBtnCaption =
'<%= caption %>' +
Expand Down Expand Up @@ -293,9 +293,9 @@ define([
'<svg class="icon <%= (iconCls ? iconCls.indexOf("icon-rtl") : -1) > -1 ? "icon-rtl" : "" %>"><use class="zoom-int" href="#<%= /btn-[^\\s]+/.exec(iconCls)[0] %>"></use></svg>',
'<% } else if (/svgicon/.test(iconCls)) { %>',
'<svg class="icon permanent-icon <%= (iconCls ? iconCls.indexOf("icon-rtl") : -1) > -1 ? "icon-rtl" : "" %>"><use class="zoom-int" href="#<%= /svgicon\\s(\\S+)/.exec(iconCls)[1] %>"></use></svg>',
'<% } else { %>',
'<i class="icon <% iconCls %>"></i>',
'<% } %>',
'<% } else { ',
'print(\'<i class=\"icon \' + iconCls + \'\">&nbsp;</i>\'); ',
' } %>',
'<% } %>',
'<% } %>',
'<% if ( !menu && onlyIcon ) { %>',
Expand Down Expand Up @@ -474,7 +474,6 @@ define([
}

parentEl.html(me.cmpEl);
me.$icon = me.$el.find('.icon');
}
} else {
if (me.options.el || me.cmpEl) {
Expand Down Expand Up @@ -791,8 +790,7 @@ define([
},

changeIcon: function(opts) {
let btnIconEl = $(this.el).find('i.icon');
let svgIcon = $(this.el).find('.icon use.zoom-int');
const svgIcon = $(this.el).find('.icon use.zoom-int'), btnIconEl = $(this.el).find('i.icon');

if (opts && (opts.curr || opts.next)) {
if (opts.curr) {
Expand All @@ -816,7 +814,8 @@ define([
},

hasIcon: function(iconcls) {
return this.$icon.hasClass(iconcls);
const iconHref = this.$el.find('use.zoom-int').attr('href');
return iconHref.includes(iconcls);
},

setVisible: function(visible) {
Expand Down Expand Up @@ -1083,7 +1082,10 @@ define([
},

updateIcon: function() {
this.$icon && this.$icon.css({'background-image': 'url('+ (this.cmpButtonFirst && (this.cmpButtonFirst.hasClass('active') || this.cmpButtonFirst.is(':active')) ? this.iconActiveImg : this.iconNormalImg) +')'});
this.$el.find('i.icon').css({
'background-image': 'url('+ (this.cmpButtonFirst && (this.cmpButtonFirst.hasClass('active') || this.cmpButtonFirst.is(':active')) ? this.iconActiveImg : this.iconNormalImg) +')',
'display': 'inline-block'
});
},

applyScaling: function (ratio) {
Expand Down
6 changes: 3 additions & 3 deletions apps/common/main/lib/component/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ define([
template: _.template([
'<a id="<%= id %>" class="menu-item" <% if (_.isEmpty(iconCls)) { %> data-no-icon <% } %> style="<%= style %>" <% if(options.canFocused) { %> tabindex="-1" type="menuitem" <% }; if(!_.isUndefined(options.stopPropagation)) { %> data-stopPropagation="true" <% }; if(!_.isUndefined(options.dataHint)) { %> data-hint="<%= options.dataHint %>" <% }; if(!_.isUndefined(options.dataHintDirection)) { %> data-hint-direction="<%= options.dataHintDirection %>" <% }; if(!_.isUndefined(options.dataHintOffset)) { %> data-hint-offset="<%= options.dataHintOffset %>" <% }; if(options.dataHintTitle) { %> data-hint-title="<%= options.dataHintTitle %>" <% }; %> >',
'<% if (!_.isEmpty(iconCls)) { %>',
'<svg class="menu-item-icon <%= (iconCls ? iconCls.indexOf("icon-rtl") : -1) > -1 ? "icon-rtl" : "" %>">',
'<use class="zoom-int" href="#<%= /btn-[^\\s]+/.exec(iconCls)[0] %>"></use>',
'</svg>',
'<% if (/btn-[^\\s]+/.test(iconCls)) { %>',
'<svg class="menu-item-icon"><use class="zoom-int" href="#<%= /btn-[^\\s]+/.exec(iconCls)[0] %>"></use></svg>',
'<% } %>',
'<% } else if (!_.isEmpty(iconImg)) { %>',
'<img src="<%= iconImg %>" class="menu-item-icon">',
'<% } %>',
Expand Down
3 changes: 3 additions & 0 deletions apps/common/main/lib/view/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ define([
var menuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" class="menu-item"><div>' +
'<% if (!_.isEmpty(iconCls)) { %>' +
'<span class="menu-item-icon <%= iconCls %>"></span>' +
'<% if (/btn-[^\\s]+/.test(iconCls)) { %>' +
'<svg class="menu-item-icon"><use class="zoom-int" href="#<%= /btn-[^\\s]+/.exec(iconCls)[0] %>"></use></svg>' +
'<% } %>' +
'<% } %>' +
'<b><%= caption %></b></div>' +
'<% if (options.description !== null) { %><label class="margin-left-10 description"><%= options.description %></label>' +
Expand Down
7 changes: 5 additions & 2 deletions apps/common/main/resources/less/bigscaling.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@

.dropdown-menu {
.menu-item {
span.menu-item-icon {
display: none;
body:not(.pixel-ratio__1_25, .pixel-ratio__1_5, .pixel-ratio__1_75) & {
span.menu-item-icon {
display: none;
}
}

svg.menu-item-icon {
fill: @icon-normal-ie;
fill: @icon-normal;
Expand Down
28 changes: 16 additions & 12 deletions apps/presentationeditor/main/app/view/DocumentPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ define([
'<div id="presentation-preview" style="width:100%; height:100%"></div>',
'<div id="preview-controls-panel" class="preview-controls"">',
'<div class="preview-group" style="">',
!Common.UI.isRTL() ? '<button id="btn-preview-prev" type="button" class="btn small btn-toolbar"><i class="icon toolbar__icon btn-previtem">&nbsp;</i></button>' : '<button id="btn-preview-next" type="button" class="btn small btn-toolbar"><span class="icon toolbar__icon btn-nextitem">&nbsp;</span></button>',
'<button id="btn-preview-play" type="button" class="btn small btn-toolbar"><i class="icon toolbar__icon btn-play">&nbsp;</i></button>',
!Common.UI.isRTL() ? '<button id="btn-preview-next" type="button" class="btn small btn-toolbar"><i class="icon toolbar__icon btn-nextitem">&nbsp;</i></button>' : '<button id="btn-preview-prev" type="button" class="btn small btn-toolbar"><span class="icon toolbar__icon btn-previtem">&nbsp;</span></button>',
!Common.UI.isRTL() ? '<button id="btn-preview-prev" type="button" class="btn small btn-toolbar"></button>' : '<button id="btn-preview-next" type="button" class="btn small btn-toolbar"></button>',
'<button id="btn-preview-play" type="button" class="btn small btn-toolbar"></button>',
!Common.UI.isRTL() ? '<button id="btn-preview-next" type="button" class="btn small btn-toolbar"></button>' : '<button id="btn-preview-prev" type="button" class="btn small btn-toolbar"></button>',
'<div class="separator"></div>',
'</div>',
'<div class="preview-group dropup">',
Expand All @@ -87,9 +87,9 @@ define([
'</div>',
'<div class="preview-group" style="">',
'<div class="separator"></div>',
'<button id="btn-preview-fullscreen" type="button" class="btn small btn-toolbar"><i class="icon toolbar__icon btn-fullscreen">&nbsp;</i></button>',
'<button id="btn-preview-fullscreen" type="button" class="btn small btn-toolbar"></button>',
'<div class="separator fullscreen"></div>',
'<button id="btn-preview-close" type="button" class="btn small btn-toolbar"><i class="icon toolbar__icon btn-close">&nbsp;</i></button>',
'<button id="btn-preview-close" type="button" class="btn small btn-toolbar"></button>',
'</div>',
'</div>'
].join('');
Expand All @@ -109,7 +109,8 @@ define([
el: $('#btn-preview-prev',this.el),
hint: this.txtPrev,
hintAnchor: 'top',
hintContainer: '#pe-preview'
hintContainer: '#pe-preview',
iconCls: 'toolbar__icon btn-previtem'
});
this.btnPrev.on('click', _.bind(function() {
if (this.api) this.api.DemonstrationPrevSlide();
Expand All @@ -119,7 +120,8 @@ define([
el: $('#btn-preview-next',this.el),
hint: this.txtNext,
hintAnchor: 'top',
hintContainer: '#pe-preview'
hintContainer: '#pe-preview',
iconCls: 'toolbar__icon btn-nextitem'
});
this.btnNext.on('click', _.bind(function() {
if (this.api) this.api.DemonstrationNextSlide();
Expand All @@ -129,11 +131,11 @@ define([
el: $('#btn-preview-play',this.el),
hint: this.txtPlay,
hintAnchor: 'top',
hintContainer: '#pe-preview'
hintContainer: '#pe-preview',
iconCls: 'toolbar__icon btn-play'
});
this.btnPlay.on('click', _.bind(function(btn) {
var iconEl = $('.icon', this.btnPlay.cmpEl);
if (iconEl.hasClass('btn-preview-pause')) {
if (btn.hasIcon('btn-preview-pause')) {
this.btnPlay.changeIcon({curr: 'btn-preview-pause', next: 'btn-play'});
this.btnPlay.updateHint(this.txtPlay);
if (this.api)
Expand All @@ -150,7 +152,8 @@ define([
el: $('#btn-preview-close',this.el),
hint: this.txtClose,
hintAnchor: 'top',
hintContainer: '#pe-preview'
hintContainer: '#pe-preview',
iconCls: 'toolbar__icon btn-close'
});
this.btnClose.on('click', _.bind(function() {
if (this.api) this.api.EndDemonstration();
Expand All @@ -160,7 +163,8 @@ define([
el: $('#btn-preview-fullscreen',this.el),
hint: this.txtFullScreen,
hintAnchor: 'top',
hintContainer: '#pe-preview'
hintContainer: '#pe-preview',
iconCls: 'toolbar__icon btn-fullscreen'
});
this.btnFullScreen.on('click', _.bind(function(btn) {
this.toggleFullScreen();
Expand Down

0 comments on commit 91a4c32

Please sign in to comment.