[AI] Fix styles for models list window

This commit is contained in:
Alexey Koshelev
2025-04-09 19:03:32 +03:00
parent acb59382e1
commit 8e092319b6
3 changed files with 33 additions and 3 deletions

View File

@ -23,6 +23,7 @@
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
<script type="text/javascript" src="./components/ListView/script.js"></script>
<script src="vendor/jquery/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
<link rel="stylesheet" href="./resources/styles/common.css">
<link rel="stylesheet" href="./components/ListView/style.css">

View File

@ -4,15 +4,14 @@ body {
}
#ai-models-list .item {
padding: 6px;
border-bottom: 1px solid;
border-bottom: none;
}
#ai-models-list .item .content {
display: -webkit-inline-box;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-line-clamp: 1;
}
#buttons-block {

View File

@ -61,6 +61,10 @@ window.Asc.plugin.onTranslate = function () {
});
};
window.addEventListener("resize", onResize);
onResize();
function onThemeChanged(theme) {
window.Asc.plugin.onThemeChangedBase(theme);
themeType = theme.type || 'light';
@ -81,4 +85,30 @@ function onThemeChanged(theme) {
let newSrc = src.replace(/(icons\/)([^\/]+)(\/)/, '$1' + themeType + '$3');
icon.setAttribute('src', newSrc);
}
}
function getZoomSuffixForImage() {
var ratio = Math.round(window.devicePixelRatio / 0.25) * 0.25;
ratio = Math.max(ratio, 1);
ratio = Math.min(ratio, 2);
if(ratio == 1) return ''
else {
return '@' + ratio + 'x';
}
}
function onResize () {
$('img').each(function() {
var el = $(this);
var src = $(el).attr('src');
if(!src.includes('resources/icons/')) return;
var srcParts = src.split('/');
var fileNameWithRatio = srcParts.pop();
var clearFileName = fileNameWithRatio.replace(/@\d+(\.\d+)?x/, '');
var newFileName = clearFileName;
newFileName = clearFileName.replace(/(\.[^/.]+)$/, getZoomSuffixForImage() + '$1');
srcParts.push(newFileName);
el.attr('src', srcParts.join('/'));
});
}