aboutsummaryrefslogtreecommitdiff
path: root/public/js/modif_page.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/modif_page.js')
-rw-r--r--public/js/modif_page.js75
1 files changed, 60 insertions, 15 deletions
diff --git a/public/js/modif_page.js b/public/js/modif_page.js
index b307f69..615f34a 100644
--- a/public/js/modif_page.js
+++ b/public/js/modif_page.js
@@ -19,9 +19,7 @@ function changePageTitle(page_id){
19 19
20 fetch('index.php?page_edit=page_title', { 20 fetch('index.php?page_edit=page_title', {
21 method: 'POST', 21 method: 'POST',
22 headers: { 22 headers: { 'Content-Type': 'application/json' },
23 'Content-Type': 'application/json'
24 },
25 body: JSON.stringify({title: page_name.value, page_id: page_id}) 23 body: JSON.stringify({title: page_name.value, page_id: page_id})
26 }) 24 })
27 .then(response => response.json()) 25 .then(response => response.json())
@@ -49,9 +47,7 @@ function changePageTitle(page_id){
49 47
50 fetch('index.php?page_edit=page_menu_path', { 48 fetch('index.php?page_edit=page_menu_path', {
51 method: 'POST', 49 method: 'POST',
52 headers: { 50 headers: { 'Content-Type': 'application/json' },
53 'Content-Type': 'application/json'
54 },
55 body: JSON.stringify({page_menu_path: page_name_path.value, page_id: page_id}) 51 body: JSON.stringify({page_menu_path: page_name_path.value, page_id: page_id})
56 }) 52 })
57 .then(response => response.json()) 53 .then(response => response.json())
@@ -88,9 +84,7 @@ function changeDescription(node_data_id){
88 84
89 fetch('index.php?page_edit=page_description', { 85 fetch('index.php?page_edit=page_description', {
90 method: 'POST', 86 method: 'POST',
91 headers: { 87 headers: { 'Content-Type': 'application/json' },
92 'Content-Type': 'application/json'
93 },
94 body: JSON.stringify({description: textarea.value, node_data_id: node_data_id}) 88 body: JSON.stringify({description: textarea.value, node_data_id: node_data_id})
95 }) 89 })
96 .then(response => response.json()) 90 .then(response => response.json())
@@ -117,9 +111,7 @@ function renamePageBloc(bloc_id){
117 111
118 fetch('index.php?bloc_edit=rename_page_bloc', { 112 fetch('index.php?bloc_edit=rename_page_bloc', {
119 method: 'POST', 113 method: 'POST',
120 headers: { 114 headers: { 'Content-Type': 'application/json' },
121 'Content-Type': 'application/json'
122 },
123 body: JSON.stringify({bloc_title: input.value, bloc_id: bloc_id}) 115 body: JSON.stringify({bloc_title: input.value, bloc_id: bloc_id})
124 }) 116 })
125 .then(response => response.json()) 117 .then(response => response.json())
@@ -159,9 +151,7 @@ function switchBlocsPositions(bloc_id, direction, current_page) {
159 151
160 fetch('index.php?page=' + current_page + '&bloc_edit=switch_blocs_positions', { 152 fetch('index.php?page=' + current_page + '&bloc_edit=switch_blocs_positions', {
161 method: 'POST', 153 method: 'POST',
162 headers: { 154 headers: { 'Content-Type': 'application/json' },
163 'Content-Type': 'application/json'
164 },
165 body: JSON.stringify({ id1: bloc_id, id2: parseInt(other_bloc.id) }) 155 body: JSON.stringify({ id1: bloc_id, id2: parseInt(other_bloc.id) })
166 }) 156 })
167 .then(response => response.json()) 157 .then(response => response.json())
@@ -187,4 +177,59 @@ function switchBlocsPositions(bloc_id, direction, current_page) {
187 .catch(error => { 177 .catch(error => {
188 console.error('Erreur:', error); 178 console.error('Erreur:', error);
189 }); 179 });
180}
181
182function changePresentation(bloc_id){
183 const presentation = document.getElementById('presentation_select_' + bloc_id).value;
184
185 fetch('index.php?bloc_edit=change_presentation', {
186 method: 'POST',
187 headers: { 'Content-Type': 'application/json' },
188 body: JSON.stringify({ id: bloc_id, presentation: presentation })
189 })
190 .then(response => response.json())
191 .then(data => {
192 if(data.success){
193 document.getElementById(bloc_id).className = presentation;
194 document.getElementById('cols_min_width_edit_' + bloc_id).className = presentation === 'grid' ? '' : 'hidden';
195 console.log('changement de présentation');
196 }
197 else{
198 console.log('Erreur au changement de présentation côté serveur');
199 }
200 })
201 .catch(error => {
202 console.error('Erreur:', error);
203 });
204}
205
206function changeColsMinWidth(bloc_id){
207 const cols_min_width_input = document.getElementById('cols_min_width_select_' + bloc_id);
208
209 if(cols_min_width_input.value < 150){
210 cols_min_width_input.value = 150;
211 }
212 else if(cols_min_width_input.value > 500){
213 cols_min_width_input.value = 500;
214 }
215
216 fetch('index.php?bloc_edit=change_cols_min_width', {
217 method: 'POST',
218 headers: { 'Content-Type': 'application/json' },
219 body: JSON.stringify({ id: bloc_id, cols_min_width: cols_min_width_input.value })
220 })
221 .then(response => response.json())
222 .then(data => {
223 if(data.success){
224 document.getElementById(bloc_id).className = 'grid';
225 document.getElementById(bloc_id).querySelector(".section_child").style.gridTemplateColumns = 'repeat(auto-fit, minmax(' + data.cols_min_width + 'px, 1fr))';
226 console.log('changement de la largeur minimum en mode grille');
227 }
228 else{
229 console.log('Erreur au changement du nb de colonnes en mode grille côté serveur');
230 }
231 })
232 .catch(error => {
233 console.error('Erreur:', error);
234 });
190} \ No newline at end of file 235} \ No newline at end of file