diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/css/head.css | 22 | ||||
| -rw-r--r-- | public/css/menu.css | 12 | ||||
| -rw-r--r-- | public/js/Input.js (renamed from public/js/InputFile.js) | 50 | ||||
| -rw-r--r-- | public/js/InputText.js | 48 | ||||
| -rw-r--r-- | public/js/menu.js | 78 |
5 files changed, 64 insertions, 146 deletions
diff --git a/public/css/head.css b/public/css/head.css index 4206044..dab81a8 100644 --- a/public/css/head.css +++ b/public/css/head.css | |||
| @@ -49,7 +49,7 @@ header | |||
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | .site_title | 52 | .header_center_col |
| 53 | { | 53 | { |
| 54 | background-color: #ffffff7f; | 54 | background-color: #ffffff7f; |
| 55 | border-radius: 10px; | 55 | border-radius: 10px; |
| @@ -81,25 +81,15 @@ header a | |||
| 81 | color: unset; /* ne plus hériter */ | 81 | color: unset; /* ne plus hériter */ |
| 82 | text-decoration: none; | 82 | text-decoration: none; |
| 83 | } | 83 | } |
| 84 | .editing_zone > div | ||
| 85 | { | ||
| 86 | /*display: inline;*/ /* à l'ancienne */ | ||
| 87 | } | ||
| 88 | /*.header_right_col | 84 | /*.header_right_col |
| 89 | {}*/ | 85 | {}*/ |
| 90 | .social | 86 | #header_social img |
| 91 | { | ||
| 92 | /*align-self: end;*/ | ||
| 93 | /*padding: 4px;*/ | ||
| 94 | } | ||
| 95 | .social a img | ||
| 96 | { | 87 | { |
| 97 | width: 25px; | 88 | width: 28px; |
| 98 | background-color: #ffffffb3; | 89 | background-color: rgba(255, 255, 255, 0.7); |
| 99 | border-radius: 50%; | 90 | border-radius: 50%; |
| 100 | } | 91 | } |
| 101 | 92 | #header_social img:hover | |
| 102 | .social img:hover | ||
| 103 | { | 93 | { |
| 104 | background-color: yellow; | 94 | background-color: yellow; |
| 105 | } | 95 | } \ No newline at end of file |
diff --git a/public/css/menu.css b/public/css/menu.css index ac77d50..0dfb840 100644 --- a/public/css/menu.css +++ b/public/css/menu.css | |||
| @@ -58,7 +58,7 @@ | |||
| 58 | 58 | ||
| 59 | .menu button | 59 | .menu button |
| 60 | { | 60 | { |
| 61 | margin: 5px; | 61 | margin: 4px 0; |
| 62 | } | 62 | } |
| 63 | .menu_entry_checkbox | 63 | .menu_entry_checkbox |
| 64 | { | 64 | { |
| @@ -109,15 +109,11 @@ | |||
| 109 | flex-wrap: wrap; | 109 | flex-wrap: wrap; |
| 110 | align-items: center; | 110 | align-items: center; |
| 111 | } | 111 | } |
| 112 | .menu .url | 112 | .menu .url_content input |
| 113 | { | ||
| 114 | text-wrap: nowrap; | ||
| 115 | } | ||
| 116 | .menu .url input[type=url] | ||
| 117 | { | 113 | { |
| 118 | width: 50%; | 114 | width: 50%; |
| 119 | } | 115 | } |
| 120 | 116 | ||
| 121 | @media screen and (min-width: 80rem) { | 117 | /*@media screen and (min-width: 80rem) { |
| 122 | i{} | 118 | i{} |
| 123 | } \ No newline at end of file | 119 | }*/ \ No newline at end of file |
diff --git a/public/js/InputFile.js b/public/js/Input.js index e676037..0b6912b 100644 --- a/public/js/InputFile.js +++ b/public/js/Input.js | |||
| @@ -1,27 +1,36 @@ | |||
| 1 | // étendre une classe parente avec InputFile? | 1 | class Input{ |
| 2 | class InputFile{ | ||
| 3 | constructor(name){ | 2 | constructor(name){ |
| 4 | this.name = name; | 3 | this.name = name; |
| 4 | /*const name_array = name.split('_'); | ||
| 5 | this.node = name_array[0]; | ||
| 6 | this.what = name_array[1];*/ | ||
| 5 | this.parent = document.getElementById(name); | 7 | this.parent = document.getElementById(name); |
| 6 | } | 8 | } |
| 7 | open(){ | 9 | open(){ |
| 8 | this.parent.querySelector('#' + this.name + '_img').classList.add('hidden'); | 10 | this.parent.querySelector('#' + this.name + '_content').classList.add('hidden'); |
| 9 | this.parent.querySelector('#' + this.name + '_input').classList.remove('hidden'); | 11 | this.parent.querySelector('#' + this.name + '_input').classList.remove('hidden'); |
| 10 | this.parent.querySelector('#' + this.name + '_open').classList.add('hidden'); | 12 | this.parent.querySelector('#' + this.name + '_open').classList.add('hidden'); |
| 11 | this.parent.querySelector('#' + this.name + '_submit').classList.remove('hidden'); | 13 | this.parent.querySelector('#' + this.name + '_submit').classList.remove('hidden'); |
| 12 | this.parent.querySelector('#' + this.name + '_cancel').classList.remove('hidden'); | 14 | this.parent.querySelector('#' + this.name + '_cancel').classList.remove('hidden'); |
| 13 | } | 15 | } |
| 14 | close(){ | 16 | close(){ |
| 15 | this.parent.querySelector('#' + this.name + '_img').classList.remove('hidden'); | 17 | this.parent.querySelector('#' + this.name + '_content').classList.remove('hidden'); |
| 16 | this.parent.querySelector('#' + this.name + '_input').classList.add('hidden'); | 18 | this.parent.querySelector('#' + this.name + '_input').classList.add('hidden'); |
| 17 | this.parent.querySelector('#' + this.name + '_open').classList.remove('hidden'); | 19 | this.parent.querySelector('#' + this.name + '_open').classList.remove('hidden'); |
| 18 | this.parent.querySelector('#' + this.name + '_submit').classList.add('hidden'); | 20 | this.parent.querySelector('#' + this.name + '_submit').classList.add('hidden'); |
| 19 | this.parent.querySelector('#' + this.name + '_cancel').classList.add('hidden'); | 21 | this.parent.querySelector('#' + this.name + '_cancel').classList.add('hidden'); |
| 20 | } | 22 | } |
| 23 | cancel(){ | ||
| 24 | this.close(); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | class InputFile extends Input{ | ||
| 21 | submit(){ | 29 | submit(){ |
| 22 | const file = this.parent.querySelector('#' + this.name + '_input').files[0]; | 30 | const file = this.parent.querySelector('#' + this.name + '_input').files[0]; |
| 23 | if(!file){ | 31 | if(!file){ |
| 24 | console.error("Erreur: aucun fichier sélectionné."); | 32 | console.error("Erreur: aucun fichier sélectionné."); |
| 33 | toastNotify("Erreur: aucun fichier sélectionné."); | ||
| 25 | return; | 34 | return; |
| 26 | } | 35 | } |
| 27 | const form_data = new FormData(); | 36 | const form_data = new FormData(); |
| @@ -34,9 +43,7 @@ class InputFile{ | |||
| 34 | .then(response => response.json()) | 43 | .then(response => response.json()) |
| 35 | .then(data => { | 44 | .then(data => { |
| 36 | if(data.success){ | 45 | if(data.success){ |
| 37 | this.parent.querySelector('#' + this.name + '_img').src = data.location; | 46 | // cas particuliers |
| 38 | |||
| 39 | // cas particulier | ||
| 40 | if(this.name === 'head_favicon'){ | 47 | if(this.name === 'head_favicon'){ |
| 41 | const link = document.querySelector('link[rel="icon"]'); | 48 | const link = document.querySelector('link[rel="icon"]'); |
| 42 | link.type = data.mime_type; | 49 | link.type = data.mime_type; |
| @@ -46,6 +53,7 @@ class InputFile{ | |||
| 46 | document.querySelector('header').style.backgroundImage = "url('" + data.location + "')"; | 53 | document.querySelector('header').style.backgroundImage = "url('" + data.location + "')"; |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 56 | this.parent.querySelector('#' + this.name + '_content').src = data.location; | ||
| 49 | this.close(); | 57 | this.close(); |
| 50 | } | 58 | } |
| 51 | else{ | 59 | else{ |
| @@ -56,7 +64,33 @@ class InputFile{ | |||
| 56 | console.error('Erreur:', error); | 64 | console.error('Erreur:', error); |
| 57 | }); | 65 | }); |
| 58 | } | 66 | } |
| 59 | cancel(){ | 67 | } |
| 68 | |||
| 69 | class InputText extends Input{ | ||
| 70 | submit(){ | ||
| 71 | const new_text = this.parent.querySelector('#' + this.name + '_input').value; | ||
| 72 | |||
| 73 | fetch('index.php?head_foot_text=' + this.name, { | ||
| 74 | method: 'POST', | ||
| 75 | headers: { 'Content-Type': 'application/json' }, | ||
| 76 | body: JSON.stringify({new_text: new_text}) | ||
| 77 | }) | ||
| 78 | .then(response => response.json()) | ||
| 79 | .then(data => { | ||
| 80 | if(data.success){ | ||
| 81 | this.parent.querySelector('#' + this.name + '_content').innerHTML = new_text; | ||
| 82 | this.close(); | ||
| 83 | } | ||
| 84 | else{ | ||
| 85 | console.error("Erreur: le serveur n'a pas enregistré le nouveau texte."); | ||
| 86 | } | ||
| 87 | }) | ||
| 88 | .catch(error => { | ||
| 89 | console.error('Erreur:', error); | ||
| 90 | }); | ||
| 91 | } | ||
| 92 | cancel(){ // surcharge | ||
| 93 | this.parent.querySelector('#' + this.name + '_input').value = this.parent.querySelector('#' + this.name + '_content').innerHTML; | ||
| 60 | this.close(); | 94 | this.close(); |
| 61 | } | 95 | } |
| 62 | } \ No newline at end of file | 96 | } \ No newline at end of file |
diff --git a/public/js/InputText.js b/public/js/InputText.js deleted file mode 100644 index 79f0398..0000000 --- a/public/js/InputText.js +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | // s'en servir dans menu et chemin | ||
| 2 | // étendre un classe parente avec InputText? | ||
| 3 | class InputText{ | ||
| 4 | constructor(name){ | ||
| 5 | this.name = name; | ||
| 6 | this.parent = document.getElementById(name); | ||
| 7 | } | ||
| 8 | open(){ | ||
| 9 | this.parent.querySelector('#' + this.name + '_span').classList.add('hidden'); | ||
| 10 | this.parent.querySelector('#' + this.name + '_input').classList.remove('hidden'); | ||
| 11 | this.parent.querySelector('#' + this.name + '_open').classList.add('hidden'); | ||
| 12 | this.parent.querySelector('#' + this.name + '_submit').classList.remove('hidden'); | ||
| 13 | this.parent.querySelector('#' + this.name + '_cancel').classList.remove('hidden'); | ||
| 14 | } | ||
| 15 | close(){ | ||
| 16 | this.parent.querySelector('#' + this.name + '_span').classList.remove('hidden'); | ||
| 17 | this.parent.querySelector('#' + this.name + '_input').classList.add('hidden'); | ||
| 18 | this.parent.querySelector('#' + this.name + '_open').classList.remove('hidden'); | ||
| 19 | this.parent.querySelector('#' + this.name + '_submit').classList.add('hidden'); | ||
| 20 | this.parent.querySelector('#' + this.name + '_cancel').classList.add('hidden'); | ||
| 21 | } | ||
| 22 | submit(){ | ||
| 23 | const new_text = this.parent.querySelector('#' + this.name + '_input').value; | ||
| 24 | |||
| 25 | fetch('index.php?head_foot_text=' + this.name, { | ||
| 26 | method: 'POST', | ||
| 27 | headers: { 'Content-Type': 'application/json' }, | ||
| 28 | body: JSON.stringify({new_text: new_text}) | ||
| 29 | }) | ||
| 30 | .then(response => response.json()) | ||
| 31 | .then(data => { | ||
| 32 | if(data.success){ | ||
| 33 | this.parent.querySelector('#' + this.name + '_span').innerHTML = new_text; | ||
| 34 | this.close(); | ||
| 35 | } | ||
| 36 | else{ | ||
| 37 | console.error("Erreur: le serveur n'a pas enregistré le nouveau texte."); | ||
| 38 | } | ||
| 39 | }) | ||
| 40 | .catch(error => { | ||
| 41 | console.error('Erreur:', error); | ||
| 42 | }); | ||
| 43 | } | ||
| 44 | cancel(){ | ||
| 45 | this.parent.querySelector('#' + this.name + '_input').value = this.parent.querySelector('#' + this.name + '_span').innerHTML; | ||
| 46 | this.close(); | ||
| 47 | } | ||
| 48 | } \ No newline at end of file | ||
diff --git a/public/js/menu.js b/public/js/menu.js index ef58c42..5e02387 100644 --- a/public/js/menu.js +++ b/public/js/menu.js | |||
| @@ -147,22 +147,27 @@ function checkMenuEntry(page_id){ | |||
| 147 | }); | 147 | }); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | // seul la modification des URL est possible pour l'instant, les noms des entrées de menu attendront | 150 | function editUrl(page_id, selector){ |
| 151 | function editUrlEntry(page_id){ | ||
| 152 | const parent_div = document.getElementById(page_id); | 151 | const parent_div = document.getElementById(page_id); |
| 153 | const url_input = parent_div.querySelector('.url').querySelector('input').value; | 152 | const input_data = parent_div.querySelector('.' + selector).querySelector('input').value; |
| 154 | 153 | ||
| 155 | fetch('index.php?menu_edit=edit_url_entry', { | 154 | fetch('index.php?menu_edit=url_edit', { |
| 156 | method: 'POST', | 155 | method: 'POST', |
| 157 | headers: { | 156 | headers: { |
| 158 | 'Content-Type': 'application/json' | 157 | 'Content-Type': 'application/json' |
| 159 | }, | 158 | }, |
| 160 | body: JSON.stringify({ id: page_id, url_input: url_input }) | 159 | body: JSON.stringify({ id: page_id, field: selector, input_data: input_data }) |
| 161 | }) | 160 | }) |
| 162 | .then(response => response.json()) | 161 | .then(response => response.json()) |
| 163 | .then(data => { | 162 | .then(data => { |
| 164 | if(data.success){ | 163 | if(data.success){ |
| 165 | findParentByTagName(document.getElementById('m_' + page_id), 'a').href = data.url_input; // MAJ menu | 164 | // MAJ menu |
| 165 | if(selector === 'url_name'){ | ||
| 166 | document.getElementById('m_' + page_id).innerHTML = data.url_data; | ||
| 167 | } | ||
| 168 | else if(selector === 'url_content'){ | ||
| 169 | findParentByTagName(document.getElementById('m_' + page_id), 'a').href = data.url_data; | ||
| 170 | } | ||
| 166 | toastNotify("Nouvelle adresse enregistrée avec succès") | 171 | toastNotify("Nouvelle adresse enregistrée avec succès") |
| 167 | } | 172 | } |
| 168 | else{ | 173 | else{ |
| @@ -173,63 +178,4 @@ function editUrlEntry(page_id){ | |||
| 173 | .catch(error => { | 178 | .catch(error => { |
| 174 | console.error('Erreur:', error); | 179 | console.error('Erreur:', error); |
| 175 | }); | 180 | }); |
| 176 | } | 181 | } \ No newline at end of file |
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | // code à recycler pour pouvoir modifier le nom de l'entrée de menu correspondant aux liens | ||
| 181 | /*function editUrlEntry(page_id){ | ||
| 182 | const parent_div = document.getElementById(page_id); | ||
| 183 | parent_div.querySelector('i').classList.add('hidden'); | ||
| 184 | parent_div.querySelector('.url').querySelector('input').classList.remove('hidden'); | ||
| 185 | parent_div.querySelector('#edit-i' + page_id).classList.add('hidden'); | ||
| 186 | parent_div.querySelector('#delete-i' + page_id).querySelector('input[type=image]').classList.add('hidden'); | ||
| 187 | parent_div.querySelector('#cancel-i' + page_id).querySelector('button').classList.remove('hidden'); | ||
| 188 | parent_div.querySelector('#submit-i' + page_id).querySelector('input[type=submit]').classList.remove('hidden'); | ||
| 189 | } | ||
| 190 | function cancelUrlEntry(page_id){ | ||
| 191 | const parent_div = document.getElementById(page_id); | ||
| 192 | parent_div.querySelector('.url').querySelector('input').value = parent_div.querySelector('i').textContent; // textContent (contrairement à innerHTML) ne transforme pas les & en entités HTML | ||
| 193 | closeUrlEntry(page_id, parent_div); | ||
| 194 | } | ||
| 195 | function submitUrlEntry(page_id){ | ||
| 196 | const parent_div = document.getElementById(page_id); | ||
| 197 | const url_input = parent_div.querySelector('.url').querySelector('input').value; | ||
| 198 | |||
| 199 | fetch('index.php?menu_edit=edit_url_entry', { | ||
| 200 | method: 'POST', | ||
| 201 | headers: { | ||
| 202 | 'Content-Type': 'application/json' | ||
| 203 | }, | ||
| 204 | body: JSON.stringify({ id: page_id, url_input: url_input }) | ||
| 205 | }) | ||
| 206 | .then(response => response.json()) | ||
| 207 | .then(data => { | ||
| 208 | if(data.success){ | ||
| 209 | parent_div.querySelector('i').innerHTML = data.url_input; // MAJ <i> | ||
| 210 | findParentByTagName(document.getElementById('m_' + page_id), 'a').href = data.url_input; // MAJ menu | ||
| 211 | closeUrlEntry(page_id, parent_div); | ||
| 212 | } | ||
| 213 | else{ | ||
| 214 | toastNotify("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 215 | console.error("Erreur rencontrée par le serveur, changements non pris en compte"); | ||
| 216 | } | ||
| 217 | }) | ||
| 218 | .catch(error => { | ||
| 219 | console.error('Erreur:', error); | ||
| 220 | }); | ||
| 221 | } | ||
| 222 | function closeUrlEntry(page_id, parent_div){ | ||
| 223 | parent_div.querySelector('i').classList.remove('hidden'); | ||
| 224 | parent_div.querySelector('.url').querySelector('input').classList.add('hidden'); | ||
| 225 | parent_div.querySelector('#edit-i' + page_id).classList.remove('hidden'); | ||
| 226 | parent_div.querySelector('#delete-i' + page_id).querySelector('input[type=image]').classList.remove('hidden'); | ||
| 227 | parent_div.querySelector('#cancel-i' + page_id).querySelector('button').classList.add('hidden'); | ||
| 228 | parent_div.querySelector('#submit-i' + page_id).querySelector('input[type=submit]').classList.add('hidden'); | ||
| 229 | }*/ | ||
| 230 | |||
| 231 | /*function deleteUrlEntry(page_id){ | ||
| 232 | const selected_div = document.getElementById(page_id); | ||
| 233 | console.log(selected_div.id); | ||
| 234 | }*/ | ||
| 235 | |||
