Update js/rus/rus.js
Browse files- js/rus/rus.js +28 -17
js/rus/rus.js
CHANGED
@@ -1020,7 +1020,7 @@ editor.CssComposer.addRules(`
|
|
1020 |
editor.BlockManager.add('custom-widget', {
|
1021 |
label: `
|
1022 |
<div style="display: flex; flex-direction: column; align-items: center;">
|
1023 |
-
|
1024 |
<span style="margin-top: 8px;">Widget</span>
|
1025 |
</div>`,
|
1026 |
content: `
|
@@ -1031,28 +1031,38 @@ editor.BlockManager.add('custom-widget', {
|
|
1031 |
attributes: {
|
1032 |
class: ''
|
1033 |
},
|
1034 |
-
//
|
1035 |
-
|
1036 |
-
|
1037 |
type: 'text',
|
1038 |
label: 'Script URL',
|
1039 |
-
|
|
|
1040 |
},
|
1041 |
-
|
1042 |
type: 'text',
|
1043 |
label: 'Widget ID',
|
1044 |
-
|
1045 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1046 |
},
|
1047 |
-
// Функция для обновления скрипта при изменении полей ввода
|
1048 |
-
onUpdate: function(component) {
|
1049 |
-
const scriptUrl = component.get('scriptUrl');
|
1050 |
-
const widgetId = component.get('widgetId');
|
1051 |
-
const scriptElement = document.getElementById('custom-widget-script');
|
1052 |
-
if (scriptElement) {
|
1053 |
-
scriptElement.src = `${scriptUrl}?id=${widgetId}`;
|
1054 |
-
}
|
1055 |
-
}
|
1056 |
});
|
1057 |
|
1058 |
editor.CssComposer.addRules(`
|
@@ -1069,3 +1079,4 @@ editor.CssComposer.addRules(`
|
|
1069 |
|
1070 |
|
1071 |
|
|
|
|
1020 |
editor.BlockManager.add('custom-widget', {
|
1021 |
label: `
|
1022 |
<div style="display: flex; flex-direction: column; align-items: center;">
|
1023 |
+
<svg id="Layer_1" enable-background="new 0 0 48 48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" width="36" height="36"><path d="m38 8h-28c-2.2 0-4 1.8-4 4v24c0 2.2 1.8 4 4 4h8v-4h-8v-20h28v20h-8v4h8c2.2 0 4-1.8 4-4v-24c0-2.2-1.8-4-4-4zm-14 12-8 8h6v12h4v-12h6z" fill="#000000" style="fill: rgb(237, 237, 237);"></path></svg>
|
1024 |
<span style="margin-top: 8px;">Widget</span>
|
1025 |
</div>`,
|
1026 |
content: `
|
|
|
1031 |
attributes: {
|
1032 |
class: ''
|
1033 |
},
|
1034 |
+
// Add traits for input fields to modify Script URL and Widget ID
|
1035 |
+
traits: [
|
1036 |
+
{
|
1037 |
type: 'text',
|
1038 |
label: 'Script URL',
|
1039 |
+
name: 'scriptUrl',
|
1040 |
+
value: 'https://school.riverpsy.com/pl/lite/widget/script',
|
1041 |
},
|
1042 |
+
{
|
1043 |
type: 'text',
|
1044 |
label: 'Widget ID',
|
1045 |
+
name: 'widgetId',
|
1046 |
+
value: '731982',
|
1047 |
+
},
|
1048 |
+
],
|
1049 |
+
// Update script src when the traits change
|
1050 |
+
script: function() {
|
1051 |
+
const updateScript = () => {
|
1052 |
+
const scriptUrl = this.getAttribute('scriptUrl') || 'https://school.riverpsy.com/pl/lite/widget/script';
|
1053 |
+
const widgetId = this.getAttribute('widgetId') || '731982';
|
1054 |
+
const scriptElement = document.getElementById('custom-widget-script');
|
1055 |
+
if (scriptElement) {
|
1056 |
+
scriptElement.src = `${scriptUrl}?id=${widgetId}`;
|
1057 |
+
}
|
1058 |
+
};
|
1059 |
+
|
1060 |
+
updateScript();
|
1061 |
+
|
1062 |
+
// Watch for trait changes and update the script dynamically
|
1063 |
+
this.addEventListener('change:scriptUrl', updateScript);
|
1064 |
+
this.addEventListener('change:widgetId', updateScript);
|
1065 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1066 |
});
|
1067 |
|
1068 |
editor.CssComposer.addRules(`
|
|
|
1079 |
|
1080 |
|
1081 |
|
1082 |
+
|