generic-skin 2.5.3 → 2.9.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Vue.component('panel-control', {
2
- props: ['dataElements'],
3
- data: function () {
2
+ props: ['elements'],
3
+ data() {
4
4
  return {
5
5
  userId: _userdata.user_id,
6
6
  state: {
@@ -13,10 +13,10 @@ Vue.component('panel-control', {
13
13
  }
14
14
  },
15
15
  computed: {
16
- validationPanel: function () {
16
+ validationPanel() {
17
17
  return FNR.utility.genValidation(this.content.current)
18
18
  },
19
- toSave: function () {
19
+ toSave() {
20
20
  let final = [];
21
21
 
22
22
  [].forEach.call(this.content.current, (item, index) => {
@@ -33,7 +33,11 @@ Vue.component('panel-control', {
33
33
  }
34
34
  },
35
35
  methods: {
36
- updateProfile: function () {
36
+ updateProfile() {
37
+ if (!this.toSave.length || this.validationPanel !== '') {
38
+ return;
39
+ }
40
+
37
41
  this.state.page = 2;
38
42
 
39
43
  FNR.user.profile.setData(this.toSave).then((r) => {
@@ -62,7 +66,7 @@ Vue.component('panel-control', {
62
66
  }
63
67
  },
64
68
  created() {
65
- FNR.user.profile.getData(JSON.parse(this.dataElements.replace(/'/g, '"'))).then((r) => {
69
+ FNR.user.profile.getData(JSON.parse(this.elements.replace(/'/g, '"'))).then((r) => {
66
70
  this.content.original = JSON.parse(JSON.stringify(r));
67
71
  this.content.current = r;
68
72
  this.state.page = 1;
@@ -74,11 +78,11 @@ Vue.component('panel-control', {
74
78
  <h2>Editar perfil</h2>
75
79
  <hr />
76
80
  <p>En esta página podrás editar tu perfil de usuario. En caso de que quieras editar tu contraseña, por favor dirígete a <a target="_blank" title="Ir a «Cambiar contraseña»" :href="'/profile?change_password=Cambiar+tu+contraseña&mode=editprofile&page_profil=informations&user_id=' + userId">este enlace</a>.</p>
77
- <p>Si estás experimentando problemas con el foro, pulsa <a title="Reiniciar cache" onclick="localStorage.clear(); window.location.replace('/')">este otro</a>. Puede que los solucione.</p>
81
+ <p>Ante cualquier duda o problema, contacta con la administración.</p>
78
82
  </div>
79
83
  <separador-foro />
80
84
  <template v-if="state.page === 0">
81
- <cargando-foro data-text="Cargando utilidad…"></cargando-foro>
85
+ <cargando-foro text="Cargando utilidad…"></cargando-foro>
82
86
  </template>
83
87
  <template v-else-if="state.page === 1">
84
88
  <aviso-foro v-show="validationPanel !== ''">
@@ -86,7 +90,7 @@ Vue.component('panel-control', {
86
90
  </aviso-foro>
87
91
  <ul class="forum-fieldlist no-style">
88
92
  <li v-for="item in content.current">
89
- <campo-foro :data-name="item.name">
93
+ <campo-foro :name="item.name">
90
94
  <input v-model="item.value" v-if="item.type === 'input' || item.type === 'avatar'" type="text"/>
91
95
  <textarea v-model="item.value" v-else-if="item.type === 'textarea'"></textarea>
92
96
  <div v-else-if="item.type === 'select'" class="select-container">
@@ -97,75 +101,384 @@ Vue.component('panel-control', {
97
101
  </campo-foro>
98
102
  </li>
99
103
  </ul>
100
- <div id="usereply-comand" v-if="toSave.length && validationPanel === ''">
101
- <button class="button1 btn-main" v-on:click="updateProfile()" title="Actualizar perfil">Actualizar</button>
104
+ <div id="usereply-comand">
105
+ <button class="button1 btn-main" @click="updateProfile()" title="Actualizar perfil">Actualizar</button>
102
106
  </div>
103
107
  </template>
104
108
  <template v-if="state.page === 2">
105
- <cargando-foro data-text="Actualizando información…"></cargando-foro>
109
+ <cargando-foro text="Actualizando información…"></cargando-foro>
106
110
  </template>
107
111
  </section>
108
112
  `
109
113
  });
110
114
 
111
115
  Vue.component('lista-bosquejos', {
112
- data: function () {
116
+ data() {
113
117
  return {
114
118
  state: {
115
- page: 0
119
+ page: 0,
116
120
  },
117
- content: {
118
- drafts: []
121
+ drafts: {
122
+ messages: {
123
+ page: 0,
124
+ loading: 0,
125
+ pages: [],
126
+ content: []
127
+ },
128
+ topics: {
129
+ page: 0,
130
+ loading: 0,
131
+ pages: [],
132
+ content: []
133
+ }
119
134
  }
120
135
  }
121
136
  },
137
+ computed: {
138
+ sortedMessagesPages() {
139
+ return FNR.behaviour.genPagelist(this.drafts.messages.pages, this.drafts.messages.page);
140
+ },
141
+ sortedTopicsPages() {
142
+ return FNR.behaviour.genPagelist(this.drafts.topics.pages, this.drafts.topics.page);
143
+ }
144
+ },
145
+ methods: {
146
+ getPageMessages(id) {
147
+ this.drafts.messages.loading = 0;
148
+
149
+ FNR.user.drafts.messages.getDrafts(id).then((r) => {
150
+ this.drafts.messages.content = r;
151
+ this.drafts.messages.loading = 1;
152
+ this.state.page = 1;
153
+ });
154
+ },
155
+ getPageTopics(id) {
156
+ this.drafts.topics.loading = 0;
157
+
158
+ FNR.user.drafts.topics.getDrafts(id).then((r) => {
159
+ this.drafts.topics.content = r;
160
+ this.drafts.topics.loading = 1;
161
+ this.state.page = 1;
162
+ });
163
+ },
164
+ setPageMessages(id) {
165
+ this.drafts.messages.page = id;
166
+ this.getPageMessages(this.drafts.messages.pages[this.drafts.messages.page]);
167
+ },
168
+ setPageTopics(id) {
169
+ this.drafts.topics.page = id;
170
+ this.getPageMessages(this.drafts.topics.pages[this.drafts.topics.page]);
171
+ },
172
+ },
122
173
  created() {
123
- FNR.user.profile.getDrafts().then((r) => {
124
- this.state.page = 1;
125
- this.content.drafts = r;
174
+ Promise.all([FNR.user.drafts.messages.getPages(), FNR.user.drafts.topics.getPages()]).then((r) => {
175
+ if (r[0].items !== 0) {
176
+ this.drafts.messages.pages = r[0].pages;
177
+ this.getPageMessages(this.drafts.messages.pages[this.drafts.messages.page]);
178
+ }
179
+
180
+ if (r[1].items !== 0) {
181
+ this.drafts.topics.pages = r[1].pages;
182
+ this.getPageTopics(this.drafts.topics.pages[this.drafts.topics.page]);
183
+ }
184
+
185
+ if (r[0].items + r[1].items === 0) {
186
+ this.state.page = 1;
187
+ }
188
+ });
189
+ },
190
+ updated() {
191
+ FNR.behaviour.genControls();
192
+ },
193
+ template: `
194
+ <section class="wiki-content is-dramatic">
195
+ <div class="is-content">
196
+ <h2>Lista de Bosquejos</h2>
197
+ <hr />
198
+ <p>En esta página tienes tu lista de Bosquejos dividida entre mensajes y temas.</p>
199
+ <p>Ante cualquier duda o problema, contacta con la administración.</p>
200
+ </div>
201
+ <separador-foro />
202
+ <template v-if="state.page === 0">
203
+ <cargando-foro text="Cargando utilidad…"></cargando-foro>
204
+ </template>
205
+ <template v-else-if="state.page === 1">
206
+ <div class="is-content mb-4">
207
+ <h4>Mensajes</h4>
208
+ </div>
209
+ <mando-foro id="upper-controls" app="true">
210
+ <template slot="pagination" v-if="drafts.messages.pages.length > 1">
211
+ <a class="page-action" title="Ir a la página anterior" v-if="drafts.messages.page > 0" @click="setPageMessages(drafts.messages.page -= 1)">
212
+ <i class="fas fa-chevron-left"></i>
213
+ </a>
214
+ <template v-for="page in sortedMessagesPages">
215
+ <strong v-if="drafts.messages.pages.indexOf(page) === drafts.messages.page">{{ drafts.messages.pages.indexOf(page) + 1 }}</strong>
216
+ <a class="page-link" :title="'Ir a la página «' + (drafts.messages.pages.indexOf(page) + 1) + '»'" v-else @click="setPageMessages(drafts.messages.pages.indexOf(page))">{{ drafts.messages.pages.indexOf(page) + 1 }}</a>
217
+ </template>
218
+ <a class="page-action" title="Ir a la página siguiente" v-if="(drafts.messages.page + 1) < drafts.messages.pages.length" @click="setPageMessages(drafts.messages.page += 1)">
219
+ <i class="fas fa-chevron-right"></i>
220
+ </a>
221
+ </template>
222
+ </mando-foro>
223
+ <section id="forum-drafts-messages" class="forum-topiclist">
224
+ <lista-temas-cabecera elements="['Tema', 'Información']"></lista-temas-cabecera>
225
+ <ul :class="'topiclist-topics no-style' + (!drafts.messages.content.length || drafts.messages.loading === 0 ? ' no-results': '')">
226
+ <template v-if="!drafts.messages.content.length">
227
+ <li class="is-not-topic is-not-lastpost">
228
+ <h6>No tienes bosquejos</h6>
229
+ </li>
230
+ </template>
231
+ <template v-else-if="drafts.messages.loading === 0">
232
+ <li class="is-not-topic is-not-lastpost">
233
+ <cargando-foro text="Cargando temas…"></cargando-foro>
234
+ </li>
235
+ </template>
236
+ <template v-else>
237
+ <li class="row is-not-topic is-not-lastpost" v-for="draft in drafts.messages.content">
238
+ <temas-foro type="draft" mode="" :url="draft.topic.url" :replies="draft.info.location" :views="draft.info.date" :quick="draft.modify">
239
+ <template slot="title">{{ draft.topic.name }}</template>
240
+ </temas-foro>
241
+ </li>
242
+ </template>
243
+ </ul>
244
+ </section>
245
+ <mando-foro id="lower-controls" app="true">
246
+ <template slot="pagination" v-if="drafts.messages.pages.length > 1">
247
+ <a class="page-action" title="Ir a la página anterior" v-if="drafts.messages.page > 0" @click="setPageMessages(drafts.messages.page -= 1)">
248
+ <i class="fas fa-chevron-left"></i>
249
+ </a>
250
+ <template v-for="page in sortedMessagesPages">
251
+ <strong v-if="drafts.messages.pages.indexOf(page) === drafts.messages.page">{{ drafts.messages.pages.indexOf(page) + 1 }}</strong>
252
+ <a class="page-link" :title="'Ir a la página «' + (drafts.messages.pages.indexOf(page) + 1) + '»'" v-else @click="setPageMessages(drafts.messages.pages.indexOf(page))">{{ drafts.messages.pages.indexOf(page) + 1 }}</a>
253
+ </template>
254
+ <a class="page-action" title="Ir a la página siguiente" v-if="(drafts.messages.page + 1) < drafts.messages.pages.length" @click="setPageMessages(drafts.messages.page += 1)">
255
+ <i class="fas fa-chevron-right"></i>
256
+ </a>
257
+ </template>
258
+ </mando-foro>
259
+ <separador-foro></separador-foro>
260
+ <div class="is-content mb-4">
261
+ <h4>Temas</h4>
262
+ </div>
263
+ <mando-foro id="upper-controls" app="true">
264
+ <template slot="pagination" v-if="drafts.topics.pages.length > 1">
265
+ <a class="page-action" title="Ir a la página anterior" v-if="drafts.topics.page > 0" @click="setPageTopics(drafts.topics.page -= 1)">
266
+ <i class="fas fa-chevron-left"></i>
267
+ </a>
268
+ <template v-for="page in sortedTopicsPages">
269
+ <strong v-if="drafts.topics.pages.indexOf(page) === drafts.topics.page">{{ drafts.topics.pages.indexOf(page) + 1 }}</strong>
270
+ <a class="page-link" :title="'Ir a la página «' + (drafts.topics.pages.indexOf(page) + 1) + '»'" v-else @click="setPageTopics(drafts.topics.pages.indexOf(page))">{{ drafts.topics.pages.indexOf(page) + 1 }}</a>
271
+ </template>
272
+ <a class="page-action" title="Ir a la página siguiente" v-if="(drafts.topics.page + 1) < drafts.topics.pages.length" @click="setPageTopics(drafts.topics.page += 1)">
273
+ <i class="fas fa-chevron-right"></i>
274
+ </a>
275
+ </template>
276
+ </mando-foro>
277
+ <section id="forum-drafts-messages" class="forum-topiclist">
278
+ <lista-temas-cabecera elements="['Tema', 'Información']"></lista-temas-cabecera>
279
+ <ul :class="'topiclist-topics no-style' + (!drafts.topics.content.length || drafts.topics.loading === 0 ? ' no-results': '')">
280
+ <template v-if="!drafts.topics.content.length">
281
+ <li class="is-not-topic is-not-lastpost">
282
+ <h6>No tienes bosquejos</h6>
283
+ </li>
284
+ </template>
285
+ <template v-else-if="drafts.topics.loading === 0">
286
+ <li class="is-not-topic is-not-lastpost">
287
+ <cargando-foro text="Cargando temas…"></cargando-foro>
288
+ </li>
289
+ </template>
290
+ <template v-else>
291
+ <li class="row is-not-topic is-not-lastpost" v-for="draft in drafts.topics.content">
292
+ <temas-foro type="draft" mode="" :url="draft.topic.url" :replies="draft.info.location" :views="draft.info.date" :quick="draft.modify">
293
+ <template slot="title">{{ draft.topic.name }}</template>
294
+ </temas-foro>
295
+ </li>
296
+ </template>
297
+ </ul>
298
+ </section>
299
+ <mando-foro id="lower-controls" app="true">
300
+ <template slot="pagination" v-if="drafts.topics.pages.length > 1">
301
+ <a class="page-action" title="Ir a la página anterior" v-if="drafts.topics.page > 0" @click="setPageTopics(drafts.topics.page -= 1)">
302
+ <i class="fas fa-chevron-left"></i>
303
+ </a>
304
+ <template v-for="page in sortedTopicsPages">
305
+ <strong v-if="drafts.topics.pages.indexOf(page) === drafts.topics.page">{{ drafts.topics.pages.indexOf(page) + 1 }}</strong>
306
+ <a class="page-link" :title="'Ir a la página «' + (drafts.topics.pages.indexOf(page) + 1) + '»'" v-else @click="setPageTopics(drafts.topics.pages.indexOf(page))">{{ drafts.topics.pages.indexOf(page) + 1 }}</a>
307
+ </template>
308
+ <a class="page-action" title="Ir a la página siguiente" v-if="(drafts.topics.page + 1) < drafts.topics.pages.length" @click="setPageTopics(drafts.topics.page += 1)">
309
+ <i class="fas fa-chevron-right"></i>
310
+ </a>
311
+ </template>
312
+ </mando-foro>
313
+ </template>
314
+ </section>
315
+ `
316
+ });
317
+
318
+ Vue.component('lista-seguidos', {
319
+ data() {
320
+ return {
321
+ state: {
322
+ page: 0,
323
+ selected: [],
324
+ },
325
+ followed: {
326
+ page: 0,
327
+ loading: 0,
328
+ pages: [],
329
+ content: []
330
+ }
331
+ }
332
+ },
333
+ computed: {
334
+ sortedPages() {
335
+ return FNR.behaviour.genPagelist(this.followed.pages, this.followed.page);
336
+ }
337
+ },
338
+ methods: {
339
+ getPage(id) {
340
+ this.followed.loading = 0;
341
+
342
+ FNR.user.followed.getFollowed(id).then((r) => {
343
+ this.followed.content = r;
344
+ this.followed.loading = 1;
345
+ this.state.page = 1;
346
+ });
347
+ },
348
+ setPage(id) {
349
+ this.followed.page = id;
350
+ this.getPage(this.followed.pages[this.followed.page]);
351
+ },
352
+ setTopic(id) {
353
+ const positionId = this.state.selected.indexOf(id);
354
+
355
+ if (positionId === -1) {
356
+ this.state.selected.push(id);
357
+ } else {
358
+ this.state.selected.splice(positionId, 1);
359
+ }
360
+ },
361
+ delTopics() {
362
+ FNR.user.followed.delFollowed(this.state.selected).then((r) => {
363
+ if (r) {
364
+ window.location.reload();
365
+ } else {
366
+ FNR.html.genNotification('Atención', 'Hubo un problema al retirar. Inténtalo de nuevo.', 'fas fa-exclamation');
367
+ }
368
+ });
369
+ }
370
+ },
371
+ created() {
372
+ FNR.user.followed.getPages().then((r) => {
373
+ if (r.items === 0) {
374
+ this.state.page = 1;
375
+ return;
376
+ }
377
+
378
+ this.followed.pages = r.pages;
379
+ this.getPage(this.followed.pages[this.followed.page]);
126
380
  });
127
381
  },
382
+ updated() {
383
+ FNR.behaviour.genControls();
384
+ },
128
385
  template: `
129
386
  <section class="wiki-content is-dramatic">
130
387
  <div class="is-content">
131
- <h2>Lista de bosquejos</h2>
388
+ <h2>Lista de Temas Supervisados</h2>
132
389
  <hr />
133
- <p>En esta página tienes tu lista de tus bosquejos. No es una lista completa, tan solo muestra la primera página. Si deseas ver más bosquejos, aligera la lista publicándolos.</p>
390
+ <p>En esta página tienes tu lista de Temas Supervisados.</p>
391
+ <p>Ante cualquier duda o problema, contacta con la administración.</p>
134
392
  </div>
135
393
  <separador-foro />
136
394
  <template v-if="state.page === 0">
137
- <cargando-foro data-text="Cargando utilidad…"></cargando-foro>
395
+ <cargando-foro text="Cargando utilidad…"></cargando-foro>
138
396
  </template>
139
397
  <template v-else-if="state.page === 1">
140
- <section id="forum-drafts" class="forum-topiclist">
141
- <lista-temas-cabecera data-elements="['Tema', 'Información']"></lista-temas-cabecera>
142
- <ul class="topiclist-topics no-style">
143
- <template v-if="content.drafts === false">
144
- <li class="is-not-lastpost not-status">
145
- <h6>No tienes bosquejos guardados</h6>
398
+ <mando-foro id="upper-controls" app="true">
399
+ <template slot="pagination" v-if="followed.pages.length > 1">
400
+ <a class="page-action" title="Ir a la página anterior" v-if="followed.page > 0" @click="setPage(followed.page -= 1)">
401
+ <i class="fas fa-chevron-left"></i>
402
+ </a>
403
+ <template v-for="page in sortedPages">
404
+ <strong v-if="followed.pages.indexOf(page) === followed.page">{{ followed.pages.indexOf(page) + 1 }}</strong>
405
+ <a class="page-link" :title="'Ir a la página «' + (followed.pages.indexOf(page) + 1) + '»'" v-else @click="setPage(followed.pages.indexOf(page))">{{ followed.pages.indexOf(page) + 1 }}</a>
406
+ </template>
407
+ <a class="page-action" title="Ir a la página siguiente" v-if="(followed.page + 1) < followed.pages.length" @click="setPage(followed.page += 1)">
408
+ <i class="fas fa-chevron-right"></i>
409
+ </a>
410
+ </template>
411
+ <template slot="controls">
412
+ <li v-if="followed.content.length" @click="delTopics()">
413
+ <boton-foro url="javascript:{}" name="Retirar" icon="fas fa-minus"></boton-foro>
414
+ </li>
415
+ </template>
416
+ </mando-foro>
417
+ <section id="forum-followed" class="forum-topiclist">
418
+ <lista-temas-cabecera elements="['Tema', 'Información']"></lista-temas-cabecera>
419
+ <ul :class="'topiclist-topics no-style' + (!followed.content.length || followed.loading === 0 ? ' no-results': '')">
420
+ <template v-if="!followed.content.length">
421
+ <li class="is-not-topic is-not-lastpost">
422
+ <h6>No tienes temas supervisados</h6>
423
+ </li>
424
+ </template>
425
+ <template v-else-if="followed.loading === 0">
426
+ <li class="is-not-topic is-not-lastpost">
427
+ <cargando-foro text="Cargando temas…"></cargando-foro>
146
428
  </li>
147
429
  </template>
148
430
  <template v-else>
149
- <li class="row is-not-lastpost not-status" v-for="draft in content.drafts">
150
- <temas-foro data-type="draft" data-mode="" :data-url="draft.topic.url" :data-title="draft.topic.name" :data-replies="draft.info.location" :data-views="draft.info.date" :data-quick="draft.modify" />
431
+ <li :class="'row is-not-topic is-not-lastpost ' + topic.type" v-for="topic in followed.content" :key="topic.id">
432
+ <temas-foro type="followed" mode="" :url="topic.url" :replies="topic.replies + ' respuestas'" :views="topic.views + ' visitas'">
433
+ <template slot="title">{{ topic.name }}</template>
434
+ <template slot="radio">
435
+ <div :class="'forum-checkbox' + (state.selected.indexOf(topic.id) === -1 ? '' : ' is-active')">
436
+ <div class="checkbox-content" @click="setTopic(topic.id)">
437
+ <div class="checkbox-click">
438
+ <i class="fas fa-check"></i>
439
+ </div>
440
+ </div>
441
+ </div>
442
+ </template>
443
+ </temas-foro>
151
444
  </li>
152
445
  </template>
153
446
  </ul>
154
447
  </section>
448
+ <mando-foro id="lower-controls" app="true">
449
+ <template slot="pagination" v-if="followed.pages.length > 1">
450
+ <a class="page-action" title="Ir a la página anterior" v-if="followed.page > 0" @click="setPage(followed.page -= 1)">
451
+ <i class="fas fa-chevron-left"></i>
452
+ </a>
453
+ <template v-for="page in sortedPages">
454
+ <strong v-if="followed.pages.indexOf(page) === followed.page">{{ followed.pages.indexOf(page) + 1 }}</strong>
455
+ <a class="page-link" :title="'Ir a la página «' + (followed.pages.indexOf(page) + 1) + '»'" v-else @click="setPage(followed.pages.indexOf(page))">{{ followed.pages.indexOf(page) + 1 }}</a>
456
+ </template>
457
+ <a class="page-action" title="Ir a la página siguiente" v-if="(followed.page + 1) < followed.pages.length" @click="setPage(followed.page += 1)">
458
+ <i class="fas fa-chevron-right"></i>
459
+ </a>
460
+ </template>
461
+ <template slot="controls">
462
+ <li v-if="followed.content.length" @click="delTopics()">
463
+ <boton-foro url="javascript:{}" name="Retirar" icon="fas fa-minus"></boton-foro>
464
+ </li>
465
+ </template>
466
+ </mando-foro>
155
467
  </template>
156
468
  </section>
157
469
  `
158
470
  });
159
471
 
160
472
  Vue.component('editor-foro', {
161
- data: function () {
473
+ data() {
162
474
  return {
163
475
  state: {
164
476
  page: 0,
165
477
  editor: 'none',
166
478
  admin: (_userdata.user_level === 1),
167
479
  guest: (_userdata.session_logged_in === 0),
168
- dice: document.querySelectorAll('#list_dice').length
480
+ dice: document.querySelectorAll('#list_dice').length,
481
+ draft: document.querySelectorAll('input[name="draft"]').length
169
482
  },
170
483
  colors: FNR.forum.getColors(),
171
484
  content: {
@@ -192,11 +505,11 @@ Vue.component('editor-foro', {
192
505
  }
193
506
  },
194
507
  computed: {
195
- msgCheck: function () {
508
+ msgCheck() {
196
509
  let final = '';
197
510
 
198
511
  if (this.state.guest) {
199
- if (this.content.username.trim().length < 4 || this.content.username.trim().length > 60) {
512
+ if (this.content.username.trim().length < 1 || this.content.username.trim().length > 60) {
200
513
  final += '<li>Escribe un nombre de usuario de tamaño adecuado.</li>';
201
514
  }
202
515
  }
@@ -215,9 +528,9 @@ Vue.component('editor-foro', {
215
528
  }
216
529
  }
217
530
 
218
- if (this.state.editor === 'newtopic' || this.state.editor === 'post') {
219
- if (this.content.subject.trim().length < 4 || this.content.subject.trim().length > 60) {
220
- final += '<li>Escribe un titulo de tamaño adecuado.</li>';
531
+ if (this.state.editor === 'newtopic' || this.state.editor === 'post' || this.state.editor === 'edittopicdraft') {
532
+ if (this.content.subject.trim().length < 4 || this.content.subject.trim().length > 100) {
533
+ final += '<li>Escribe un titulo de tamaño adecuado (4 a 100 carácteres).</li>';
221
534
  }
222
535
  }
223
536
 
@@ -227,7 +540,7 @@ Vue.component('editor-foro', {
227
540
 
228
541
  return final;
229
542
  },
230
- sortedCharacters: function () {
543
+ sortedCharacters() {
231
544
  if (!Object.keys(this.users.options).length) return [];
232
545
  else return this.users.options.map((item) => {
233
546
  return item.user;
@@ -241,7 +554,7 @@ Vue.component('editor-foro', {
241
554
  return 0;
242
555
  });
243
556
  },
244
- sortedEditCharacters: function () {
557
+ sortedEditCharacters() {
245
558
  return this.users.selected.sort((a, b) => {
246
559
  if (a < b) return -1;
247
560
  else if (a > b) return 1;
@@ -250,7 +563,7 @@ Vue.component('editor-foro', {
250
563
  }
251
564
  },
252
565
  methods: {
253
- insertSomething: function (insertBefore, insertAfter) {
566
+ insertSomething(insertBefore, insertAfter) {
254
567
  const myField = document.getElementById('usereply-editor');
255
568
  const pre = insertBefore.replace(/-jump-/g, '\n');
256
569
  const post = insertAfter.replace(/-jump-/g, '\n');
@@ -260,8 +573,8 @@ Vue.component('editor-foro', {
260
573
  document.selection.createRange().text = pre + document.selection.createRange().text + post;
261
574
  } else if (myField.selectionStart || myField.selectionStart == '0') {
262
575
  const startPos = myField.selectionStart;
263
- const endPos = myField.selectionEnd;
264
- const cursorPos = endPos + pre.length + post.length;
576
+ const endPos = myField.selectionEnd
577
+ const cursorPos = endPos + pre.length;
265
578
 
266
579
  myField.value = myField.value.substring(0, startPos) + pre + myField.value.substring(startPos, endPos) + post + myField.value.substring(endPos, myField.value.length);
267
580
  myField.setSelectionRange(cursorPos, cursorPos);
@@ -269,13 +582,13 @@ Vue.component('editor-foro', {
269
582
 
270
583
  this.content.msg = myField.value;
271
584
  },
272
- newDice: function () {
585
+ newDice() {
273
586
  this.dice.current.push({
274
587
  dice: -1,
275
588
  number: 0
276
589
  });
277
590
  },
278
- addCharacter: function (character) {
591
+ addCharacter(character) {
279
592
  this.users.selected.push(character);
280
593
  this.users.selector = false;
281
594
  this.users.current = '';
@@ -284,15 +597,15 @@ Vue.component('editor-foro', {
284
597
  this.users.selector = true;
285
598
  }, 250);
286
599
  },
287
- deleteCharacter: function (index) {
600
+ deleteCharacter(index) {
288
601
  this.users.current = '';
289
602
  this.users.selected.splice(index, 1);
290
603
  },
291
- changeGroup: function () {
604
+ changeGroup() {
292
605
  this.users.selected = [];
293
606
  this.users.current = '';
294
607
  },
295
- insertUrl: function () {
608
+ insertUrl() {
296
609
  const myField = document.getElementById('usereply-editor');
297
610
  const startPos = myField.selectionStart;
298
611
  const endPos = myField.selectionEnd;
@@ -305,7 +618,7 @@ Vue.component('editor-foro', {
305
618
  }
306
619
  });
307
620
  },
308
- insertImg: function () {
621
+ insertImg() {
309
622
  FNR.html.genPrompt('Insertar imagen', 'Introduce las medidas de la imagen en píxeles pero sin la medida (por ejemplo 100x100). <u>En caso de dejarlo en blanco, se insertará con la medida inicial</u>.', 'Medidas de la imagen', '').then((result) => {
310
623
  if (result !== false) {
311
624
  this.insertSomething('[img=' + result + ']', '[/img]');
@@ -314,7 +627,7 @@ Vue.component('editor-foro', {
314
627
  }
315
628
  });
316
629
  },
317
- insertSpoiler: function () {
630
+ insertSpoiler() {
318
631
  FNR.html.genPrompt('Insertar spoiler', 'Introduce el título del spoiler. <u>En caso de dejarlo en blanco, se insertará sin él.</u>.', 'Título del spoiler', '').then((result) => {
319
632
  if (result !== false) {
320
633
  this.insertSomething('[spoiler=' + result + ']', '[/spoiler]');
@@ -323,7 +636,7 @@ Vue.component('editor-foro', {
323
636
  }
324
637
  });
325
638
  },
326
- insertQuote: function () {
639
+ insertQuote() {
327
640
  FNR.html.genPrompt('Insertar cita', 'Introduce el destinatario de la cita. <u>En caso de dejarlo en blanco, se insertará sin él.</u>.', 'Destinatario de la cita', '').then((result) => {
328
641
  if (result !== false) {
329
642
  this.insertSomething('[quote=' + result + ']', '[/quote]');
@@ -332,7 +645,7 @@ Vue.component('editor-foro', {
332
645
  }
333
646
  });
334
647
  },
335
- parseMsg: function () {
648
+ parseMsg() {
336
649
  window.forumParsing = true;
337
650
 
338
651
  if (document.querySelector('#forum-realreply > form .sceditor-container > textarea')) {
@@ -341,32 +654,6 @@ Vue.component('editor-foro', {
341
654
  document.querySelector('#forum-realreply > form textarea#text_editor_textarea').value = this.content.msg.replace(/#per/g, this.colors[this.colors.length - 1].hex);
342
655
  }
343
656
 
344
- if (this.state.editor === 'reply') {
345
- if (FNR.content.isAutosave()) {
346
- if (FNR.cache.getData('post' + document.post.t.value + '-' + _userdata.user_id) !== false && _userdata.user_id !== -1) {
347
- FNR.cache.delData('post' + document.post.t.value + '-' + _userdata.user_id);
348
- }
349
- }
350
-
351
- if (this.state.dice) {
352
- [].forEach.call(document.querySelectorAll('#forum-realreply > form #list_dice tr'), (item, index) => {
353
- if (index !== 0) {
354
- item.remove();
355
- }
356
- });
357
-
358
- document.querySelector('#forum-realreply > form #list_dice tr td').insertAdjacentHTML('beforeend', '<span id="dice_to_del"></span>');
359
-
360
- this.dice.current.filter((item) => {
361
- return item.dice !== -1;
362
- }).filter((item) => {
363
- return parseFloat(item.number) !== 0 && !isNaN(parseFloat(item.number));
364
- }).forEach((item) => {
365
- add_dice(document.querySelectorAll('#list_dice tr').length, item.dice, item.number);
366
- });
367
- }
368
- }
369
-
370
657
  if (this.state.guest) {
371
658
  if (this.content.subject.trim().length > 4 || this.content.subject.trim().length < 60) {
372
659
  document.querySelector('#forum-realreply > form input[name="username"]').value = this.content.username;
@@ -392,23 +679,80 @@ Vue.component('editor-foro', {
392
679
  }
393
680
  }
394
681
 
395
- if (this.state.editor === 'newtopic' || this.state.editor === 'post') {
396
- if (this.content.subject.trim().length > 4 || this.content.subject.trim().length < 60) {
682
+ if (this.state.editor === 'newtopic' || this.state.editor === 'post' || this.state.editor === 'edittopicdraft') {
683
+ if (this.content.subject.trim().length > 4 || this.content.subject.trim().length < 100) {
397
684
  document.querySelector('#forum-realreply > form input[name="subject"]').value = this.content.subject.trim();
398
685
  }
399
686
  }
687
+
688
+ if (this.state.editor === 'reply') {
689
+ if (FNR.content.isAutosave()) {
690
+ if (FNR.cache.getData('post' + document.post.t.value + '-' + _userdata.user_id) !== false && _userdata.user_id !== -1) {
691
+ FNR.cache.delData('post' + document.post.t.value + '-' + _userdata.user_id);
692
+ }
693
+ }
694
+ }
695
+
696
+ if (this.state.dice && (this.state.editor === 'reply' || this.state.editor === 'newtopic' || this.state.editor === 'editpostdraft' || this.state.editor === 'edittopicdraft')) {
697
+ [].forEach.call(document.querySelectorAll('#forum-realreply > form #list_dice tr'), (item, index) => {
698
+ if (index !== 0) {
699
+ item.remove();
700
+ }
701
+ });
702
+
703
+ document.querySelector('#forum-realreply > form #list_dice tr td').insertAdjacentHTML('beforeend', '<span id="dice_to_del"></span>');
704
+
705
+ this.dice.current.filter((item) => {
706
+ return item.dice !== -1;
707
+ }).filter((item) => {
708
+ return parseFloat(item.number) !== 0 && !isNaN(parseFloat(item.number));
709
+ }).forEach((item) => {
710
+ add_dice(document.querySelectorAll('#list_dice tr').length, item.dice, item.number);
711
+ });
712
+ }
400
713
  },
401
- draftMsg: function () {
714
+ draftMsg() {
715
+ if (this.msgCheck.length) {
716
+ return;
717
+ }
718
+
402
719
  this.parseMsg();
403
720
 
404
- document.querySelector('#forum-realreply > form input[value="Bosquejo"], #forum-realreply input[value="Modificar"]').click();
721
+ document.querySelector('#forum-realreply > form input[value="Bosquejo"], #forum-realreply input[value="Modificar"], #forum-realreply input[value="Registrar"]').click();
405
722
  },
406
- sendMsg: function () {
723
+ delMsg() {
724
+ const urlParams = new URLSearchParams(window.location.search);
725
+
726
+ let type = 'topicdraft';
727
+ let param = 't';
728
+
729
+ if (urlParams.get('mode') === 'editpostdraft') {
730
+ type = 'draft';
731
+ param = 'p';
732
+ }
733
+
734
+ FNR.user.drafts.delDrafts(type, [urlParams.get(param)]).then((r) => {
735
+ if (r) {
736
+ window.location.replace(`${window.location.protocol}//${window.location.host}${forumConfig.usableDirections.ucp}#/bosquejos`)
737
+ } else {
738
+ FNR.html.genNotification('Atención', 'Hubo un problema al eliminar. Inténtalo de nuevo.', 'fas fa-exclamation');
739
+ }
740
+ });
741
+ },
742
+ sendMsg() {
743
+ if (this.msgCheck.length) {
744
+ return;
745
+ }
746
+
407
747
  this.parseMsg();
408
748
 
409
749
  document.querySelector('#forum-realreply > form input[value="Enviar"], #forum-realreply input[value="Publicar"]').click();
410
750
  },
411
- prevMsg: function () {
751
+ prevMsg() {
752
+ if (this.msgCheck.length) {
753
+ return;
754
+ }
755
+
412
756
  this.parseMsg();
413
757
 
414
758
  document.querySelector('#forum-realreply > form input[value="Previsualización"], #forum-realreply input[value="Previsualizar"]').click();
@@ -802,7 +1146,7 @@ Vue.component('editor-foro', {
802
1146
  template: `
803
1147
  <div id="forum-usereply">
804
1148
  <template v-if="state.page === 0">
805
- <cargando-foro data-text="Cargando utilidad…"></cargando-foro>
1149
+ <cargando-foro text="Cargando utilidad…"></cargando-foro>
806
1150
  </template>
807
1151
  <template v-else-if="state.page === 1">
808
1152
  <aviso-foro v-show="msgCheck.length">
@@ -811,22 +1155,22 @@ Vue.component('editor-foro', {
811
1155
  <ul id="usereply-extra" class="forum-fieldlist no-style" v-if="state.editor !== 'reply'">
812
1156
  <template v-if="state.guest">
813
1157
  <li>
814
- <campo-foro data-name="Nombre de usuario">
1158
+ <campo-foro name="Nombre de usuario">
815
1159
  <input type="text" v-model="content.username" placeholder="Escribe tu nombre de usuario." />
816
1160
  </campo-foro>
817
1161
  </li>
818
1162
  </template>
819
1163
  <template v-if="state.editor === 'post'">
820
1164
  <li>
821
- <campo-foro data-name="Usuarios">
1165
+ <campo-foro name="Usuarios">
822
1166
  <div class="character-selector">
823
1167
  <input type="text" v-model="users.current" placeholder="Escribe el nombre de un usuario." :disabled="groups.type !== -1" />
824
1168
  <ul class="no-style selector-list" v-if="users.selector && sortedCharacters.length > 0">
825
- <li v-for="(character, index) in sortedCharacters" v-on:click="addCharacter(character)" :title="'Seleccionar ' + character">{{ character }}<i class="fas fa-plus"></i></li>
1169
+ <li v-for="(character, index) in sortedCharacters" @click="addCharacter(character)" :title="'Seleccionar ' + character">{{ character }}<i class="fas fa-plus"></i></li>
826
1170
  </ul>
827
1171
  </div>
828
1172
  <ul v-if="sortedEditCharacters.length" class="no-style character-list">
829
- <li v-for="(character, index) in sortedEditCharacters" v-on:click="deleteCharacter(index)" :title="'Quitar ' + character"><i class="fas fa-times"></i> {{ character }}</li>
1173
+ <li v-for="(character, index) in sortedEditCharacters" @click="deleteCharacter(index)" :title="'Quitar ' + character"><i class="fas fa-times"></i> {{ character }}</li>
830
1174
  </ul>
831
1175
  </campo-foro>
832
1176
  </li>
@@ -834,9 +1178,9 @@ Vue.component('editor-foro', {
834
1178
  <template v-if="state.admin">
835
1179
  <template v-if="state.editor === 'post'">
836
1180
  <li>
837
- <campo-foro data-name="Grupo">
1181
+ <campo-foro name="Grupo">
838
1182
  <div class="select-container">
839
- <select v-model="groups.type" v-on:change="changeGroup()" :disabled="users.selected.length !== 0">
1183
+ <select v-model="groups.type" @change="changeGroup()" :disabled="users.selected.length !== 0">
840
1184
  <option value="-1" hidden>Selecciona un grupo.</option>
841
1185
  <option v-for="option in groups.options" :value="option.value">{{ option.name }}</option>
842
1186
  </select>
@@ -844,9 +1188,9 @@ Vue.component('editor-foro', {
844
1188
  </campo-foro>
845
1189
  </li>
846
1190
  </template>
847
- <template v-else-if="state.editor === 'newtopic' && content.type !== -1">
1191
+ <template v-else-if="content.type !== -1 && (state.editor === 'newtopic' || state.editor === 'edittopicdraft')">
848
1192
  <li>
849
- <campo-foro data-name="Tipo de tema">
1193
+ <campo-foro name="Tipo de tema">
850
1194
  <div class="select-container">
851
1195
  <select v-model="content.type">
852
1196
  <option value="-1" hidden>Selecciona una opción.</option>
@@ -857,9 +1201,9 @@ Vue.component('editor-foro', {
857
1201
  </li>
858
1202
  </template>
859
1203
  </template>
860
- <template v-if="state.editor === 'newtopic' || state.editor === 'post'">
1204
+ <template v-if="state.editor === 'newtopic' || state.editor === 'post' || state.editor === 'edittopicdraft'">
861
1205
  <li>
862
- <campo-foro data-name="Título">
1206
+ <campo-foro name="Título">
863
1207
  <input type="text" v-model="content.subject" placeholder="Escribe el título." />
864
1208
  </campo-foro>
865
1209
  </li>
@@ -870,22 +1214,22 @@ Vue.component('editor-foro', {
870
1214
  <div id="usereply-buttons">
871
1215
  <ul class="is-hidden-mobile">
872
1216
  <li id="bold-button">
873
- <button class="usereply-button" v-on:click="insertSomething('[b]', '[/b]')" title="Negrita">
1217
+ <button class="usereply-button" @click="insertSomething('[b]', '[/b]')" title="Negrita">
874
1218
  <i class="fas fa-bold"></i>
875
1219
  </button>
876
1220
  </li>
877
1221
  <li id="italic-button">
878
- <button class="usereply-button" v-on:click="insertSomething('[i]', '[/i]')" title="Cursiva">
1222
+ <button class="usereply-button" @click="insertSomething('[i]', '[/i]')" title="Cursiva">
879
1223
  <i class="fas fa-italic"></i>
880
1224
  </button>
881
1225
  </li>
882
1226
  <li id="underline-button">
883
- <button class="usereply-button" v-on:click="insertSomething('[u]', '[/u]')" title="Subrayado">
1227
+ <button class="usereply-button" @click="insertSomething('[u]', '[/u]')" title="Subrayado">
884
1228
  <i class="fas fa-underline"></i>
885
1229
  </button>
886
1230
  </li>
887
1231
  <li id="strike-button">
888
- <button class="usereply-button" v-on:click="insertSomething('[strike]', '[/strike]')" title="Tachado">
1232
+ <button class="usereply-button" @click="insertSomething('[strike]', '[/strike]')" title="Tachado">
889
1233
  <i class="fas fa-strikethrough"></i>
890
1234
  </button>
891
1235
  </li>
@@ -900,7 +1244,7 @@ Vue.component('editor-foro', {
900
1244
  </div>
901
1245
  <div class="dropdown-menu" role="menu">
902
1246
  <div id="colour-list" class="dropdown-content">
903
- <div v-for="color in colors" class="usereply-option" :style="'color:' + color.hex" v-on:click="insertSomething('[color=' + color.hex + ']', '[/color]')">{{ color.name }}</div>
1247
+ <div v-for="color in colors" class="usereply-option" :style="'color:' + color.hex" @click="insertSomething('[color=' + color.hex + ']', '[/color]')">{{ color.name }}</div>
904
1248
  </div>
905
1249
  </div>
906
1250
  </div>
@@ -928,9 +1272,9 @@ Vue.component('editor-foro', {
928
1272
  </div>
929
1273
  <div class="dropdown-menu" role="menu">
930
1274
  <div id="align-list" class="dropdown-content">
931
- <div class="usereply-option" v-on:click="insertSomething('[left]', '[/left]')">Izquierda</div>
932
- <div class="usereply-option" v-on:click="insertSomething('[center]', '[/center]')">Centro</div>
933
- <div class="usereply-option" v-on:click="insertSomething('[right]', '[/right]')">Derecha</div>
1275
+ <div class="usereply-option" @click="insertSomething('[left]', '[/left]')">Izquierda</div>
1276
+ <div class="usereply-option" @click="insertSomething('[center]', '[/center]')">Centro</div>
1277
+ <div class="usereply-option" @click="insertSomething('[right]', '[/right]')">Derecha</div>
934
1278
  </div>
935
1279
  </div>
936
1280
  </div>
@@ -944,13 +1288,13 @@ Vue.component('editor-foro', {
944
1288
  </div>
945
1289
  <div class="dropdown-menu" role="menu">
946
1290
  <div id="toolbox-list" class="dropdown-content">
947
- <div class="usereply-option" v-on:click="insertUrl()">Enlace</div>
948
- <div class="usereply-option" v-on:click="insertImg()">Imagen</div>
949
- <div class="usereply-option" v-on:click="insertSpoiler()">Spoiler</div>
950
- <div class="usereply-option" v-on:click="insertSomething('[code]', '[/code]')">Code</div>
951
- <div class="usereply-option" v-on:click="insertQuote()">Cita</div>
952
- <div class="usereply-option" v-on:click="insertSomething('[hide]', '[/hide]')">Ocultar</div>
953
- <div class="usereply-option" v-on:click="insertSomething('[youtube]', '[/youtube]')">Youtube</div>
1291
+ <div class="usereply-option" @click="insertUrl()">Enlace</div>
1292
+ <div class="usereply-option" @click="insertImg()">Imagen</div>
1293
+ <div class="usereply-option" @click="insertSpoiler()">Spoiler</div>
1294
+ <div class="usereply-option" @click="insertSomething('[code]', '[/code]')">Code</div>
1295
+ <div class="usereply-option" @click="insertQuote()">Cita</div>
1296
+ <div class="usereply-option" @click="insertSomething('[hide]', '[/hide]')">Ocultar</div>
1297
+ <div class="usereply-option" @click="insertSomething('[youtube]', '[/youtube]')">Youtube</div>
954
1298
  </div>
955
1299
  </div>
956
1300
  </div>
@@ -959,26 +1303,27 @@ Vue.component('editor-foro', {
959
1303
  </div>
960
1304
  </div>
961
1305
  <textarea id="usereply-editor" contenteditable="true" v-model="content.msg"></textarea>
962
- <div id="usereply-comand" v-if="!msgCheck.length">
963
- <button class="button1 btn-main" v-on:click="sendMsg()">Enviar</button>
964
- <button class="button1" v-on:click="draftMsg()" v-if="state.editor === 'editpostdraft'">Modificar</button>
965
- <button class="button1" v-on:click="draftMsg()" v-else-if="state.editor === 'reply' && state.dice">Bosquejo</button>
966
- <button class="button1" v-on:click="prevMsg()">Previsualizar</button>
1306
+ <div id="usereply-comand">
1307
+ <button class="button1 btn-main" @click="sendMsg()">Enviar</button>
1308
+ <button class="button1" @click="draftMsg()" v-if="state.editor === 'editpostdraft' || state.editor === 'edittopicdraft'">Modificar</button>
1309
+ <button class="button1" @click="draftMsg()" v-else-if="state.draft && (state.editor === 'reply' || state.editor === 'newtopic')">Bosquejo</button>
1310
+ <button class="button1" @click="prevMsg()">Previsualizar</button>
1311
+ <button class="button1" @click="delMsg()" v-if="state.editor === 'editpostdraft' || state.editor === 'edittopicdraft'">Eliminar</button>
967
1312
  </div>
968
- <div v-if="state.editor === 'reply' && state.dice" id="usereply-dice">
1313
+ <div v-if="state.dice && (state.editor === 'reply' || state.editor === 'newtopic' || state.editor === 'editpostdraft' || state.editor === 'edittopicdraft')" id="usereply-dice">
969
1314
  <div class="usereply-header">
970
1315
  <h3>Tirar dados</h3>
971
1316
  </div>
972
1317
  <ul>
973
1318
  <li v-for="(item, index) in dice.current">
974
1319
  <div class="select-container">
975
- <select v-model="item.dice">
1320
+ <select v-model="item.dice" @change="item.number = 1">
976
1321
  <option value="-1" selected hidden>Selec. un dado</option>
977
1322
  <option v-for="option in dice.options" :value="option.value">{{ option.content }}</option>
978
1323
  </select>
979
1324
  </div>
980
1325
  <input type="number" v-model="item.number" />
981
- <button v-on:click="newDice()" v-if="(index + 1) === dice.current.length" class="dice-more">
1326
+ <button @click="newDice()" v-if="(index + 1) === dice.current.length" class="dice-more">
982
1327
  <i class="fas fa-plus"></i>
983
1328
  </button>
984
1329
  <div v-else class="dice-more"></div>