Skip to content

Commit 859f74a

Browse files
committed
refactor
1 parent 6f4b675 commit 859f74a

File tree

7 files changed

+25
-51
lines changed

7 files changed

+25
-51
lines changed

services/static-webserver/client/source/class/osparc/conversation/AddMessage.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,7 @@ qx.Class.define("osparc.conversation.AddMessage", {
7878
break;
7979
}
8080
case "thumbnail": {
81-
control = new qx.ui.basic.Image().set({
82-
alignY: "middle",
83-
scale: true,
84-
allowGrowX: true,
85-
allowGrowY: true,
86-
allowShrinkX: true,
87-
allowShrinkY: true,
88-
maxWidth: 32,
89-
maxHeight: 32,
90-
decorator: "rounded",
91-
});
81+
control = osparc.utils.Utils.createThumbnail(32);
9282
const authData = osparc.auth.Data.getInstance();
9383
const myUsername = authData.getUsername();
9484
const myEmail = authData.getEmail();

services/static-webserver/client/source/class/osparc/conversation/MessageUI.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ qx.Class.define("osparc.conversation.MessageUI", {
6464
let control;
6565
switch (id) {
6666
case "thumbnail":
67-
control = new qx.ui.basic.Image().set({
68-
scale: true,
69-
maxWidth: 32,
70-
maxHeight: 32,
71-
decorator: "rounded",
67+
control = osparc.utils.Utils.createThumbnail(32).set({
7268
marginTop: 4,
7369
});
7470
this._add(control, {

services/static-webserver/client/source/class/osparc/dashboard/GroupedCardContainer.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,7 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
100100
paddingBottom: 5,
101101
allowGrowX: false
102102
});
103-
control.getChildControl("icon").set({
104-
scale: true,
105-
allowGrowX: true,
106-
allowGrowY: true,
107-
allowShrinkX: true,
108-
allowShrinkY: true,
109-
maxWidth: 32,
110-
maxHeight: 32
111-
});
103+
control.getChildControl("icon").set(this.getThumbnailProps(32));
112104
control.getChildControl("label").set({
113105
rich: true,
114106
wrap: true

services/static-webserver/client/source/class/osparc/ui/list/ListItem.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,7 @@ qx.Class.define("osparc.ui.list.ListItem", {
142142
let control;
143143
switch (id) {
144144
case "thumbnail":
145-
control = new qx.ui.basic.Image().set({
146-
alignY: "middle",
147-
scale: true,
148-
allowGrowX: true,
149-
allowGrowY: true,
150-
allowShrinkX: true,
151-
allowShrinkY: true,
152-
maxWidth: 32,
153-
maxHeight: 32
154-
});
145+
control = osparc.utils.Utils.createThumbnail(32);
155146
this._add(control, {
156147
row: 0,
157148
column: 0,

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ qx.Class.define("osparc.utils.Utils", {
130130
}
131131
},
132132

133+
getThumbnailProps: function(size = 32) {
134+
return {
135+
alignX: "center",
136+
alignY: "middle",
137+
scale: true,
138+
allowGrowX: true,
139+
allowGrowY: true,
140+
allowShrinkX: true,
141+
allowShrinkY: true,
142+
decorator: "rounded",
143+
maxWidth: size,
144+
maxHeight: size,
145+
};
146+
},
147+
148+
createThumbnail: function(size = 32) {
149+
return new qx.ui.basic.Image().set(this.getThumbnailProps(size));
150+
},
151+
133152
disableAutocomplete: function(control) {
134153
if (control && control.getContentElement()) {
135154
control.getContentElement().setAttribute("autocomplete", "off");

services/static-webserver/client/source/class/osparc/vipMarket/LicensedItemDetails.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,7 @@ qx.Class.define("osparc.vipMarket.LicensedItemDetails", {
195195
iconPosition: "right",
196196
cursor: "pointer",
197197
});
198-
manufacturerLink.getChildControl("icon").set({
199-
maxWidth: 32,
200-
maxHeight: 32,
201-
scale: true,
202-
decorator: "rounded",
203-
});
198+
manufacturerLink.getChildControl("icon").set(osparc.utils.Utils.getThumbnailProps(32));
204199
manufacturerLink.addListener("tap", () => window.open(licensedResource.getManufacturerLink()));
205200
headerLayout.add(manufacturerLink, {
206201
column: 1,

services/static-webserver/client/source/class/osparc/vipMarket/LicensedItemListItem.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,7 @@ qx.Class.define("osparc.vipMarket.LicensedItemListItem", {
127127
let control;
128128
switch (id) {
129129
case "thumbnail":
130-
control = new qx.ui.basic.Image().set({
131-
alignY: "middle",
132-
scale: true,
133-
allowGrowX: true,
134-
allowGrowY: true,
135-
allowShrinkX: true,
136-
allowShrinkY: true,
137-
maxWidth: 32,
138-
maxHeight: 32
139-
});
130+
control = osparc.utils.Utils.createThumbnail(32);
140131
this._add(control, {
141132
row: 0,
142133
column: 0,

0 commit comments

Comments
 (0)