| |
200 |
200 |
|
| |
201 |
201 |
|
| |
202 |
202 |
|
| |
203 |
203 |
var data = JSON.parse(data_repeat_attribute); |
| |
204 |
204 |
|
| |
205 |
205 |
var compareLength = from.length; |
| |
206 |
206 |
if (data.name.substring(0,compareLength) == from) { |
| |
207 |
207 |
var new_name = to + data.name.substring(compareLength,data.name.length); |
| |
208 |
208 |
data.name = new_name; |
| |
209 |
209 |
e.setAttribute('data-repeat',JSON.stringify(data)); |
| |
210 |
210 |
} |
| |
211 |
211 |
} |
| |
212 |
212 |
for (var j = 0; j < items.length; j++) { |
| |
213 |
213 |
this.renameItem(top, items[j], from, to); |
| |
214 |
214 |
} |
| |
215 |
215 |
} else { |
| |
216 |
216 |
console.log('rename ignores ' + e); |
| |
217 |
217 |
} |
| |
218 |
218 |
} |
| |
219 |
219 |
|
| |
|
220 |
if (typeof window.tinyMCE !== 'undefined') { |
| |
|
221 |
|
| |
|
222 |
|
| |
|
223 |
|
| |
|
224 |
|
| |
|
225 |
|
| |
|
226 |
|
| |
|
227 |
xowiki.tinyMCE = {}; |
| |
|
228 |
xowiki.tinyMCE.removeEditor = function (selector) { |
| |
|
229 |
for (const el of document.querySelectorAll(selector)) { |
| |
|
230 |
const editor = window.tinyMCE.get(el.id); |
| |
|
231 |
|
| |
|
232 |
if (!editor) {continue;} |
| |
|
233 |
el.innerHTML = editor.getContent(); |
| |
|
234 |
editor.remove(); |
| |
|
235 |
} |
| |
|
236 |
}; |
| |
|
237 |
} |
| |
|
238 |
|
| |
220 |
239 |
|
| |
221 |
240 |
|
| |
222 |
241 |
|
| |
223 |
242 |
|
| |
224 |
243 |
|
| |
225 |
244 |
|
| |
226 |
245 |
|
| |
227 |
246 |
xowiki.repeat.delItem = function(e, json) { |
| |
228 |
247 |
|
| |
229 |
248 |
var data = JSON.parse(json); |
| |
230 |
249 |
var item = e.parentNode; |
| |
231 |
250 |
var stats = this.itemStats(item); |
| |
232 |
251 |
|
| |
233 |
252 |
console.info(stats); |
| |
234 |
253 |
|
| |
235 |
254 |
|
| |
236 |
255 |
var current = stats['current']; |
| |
237 |
256 |
var last = stats['visible']; |
| |
238 |
257 |
var items = item.parentNode.children; |
| |
239 |
258 |
var divs = stats['divs']; |
| |
240 |
259 |
|
| |
241 |
260 |
var display = 'none'; |
| |
242 |
261 |
|
| |
243 |
262 |
if (stats['visible'] < data['min']+1) { |
| |
244 |
263 |
|
| |
245 |
264 |
|
| |
246 |
265 |
|
| |
247 |
266 |
last = current; |
| |
248 |
267 |
display = 'block'; |
| |
249 |
268 |
} |
| |
250 |
269 |
|
| |
251 |
270 |
console.log('delete ' + current); |
| |
252 |
271 |
|
| |
253 |
272 |
if (current == last) { |
| |
254 |
273 |
|
| |
|
274 |
xowiki.tinyMCE?.removeEditor(`[id^='${item.parentNode.id}.${current}']`); |
| |
255 |
275 |
} else { |
| |
256 |
276 |
for (var j = current; j < last; j++) { |
| |
257 |
277 |
var k = j + 1; |
| |
258 |
278 |
|
| |
259 |
279 |
|
| |
260 |
280 |
|
| |
261 |
281 |
|
| |
262 |
282 |
|
| |
263 |
283 |
$(divs[k]).find(':input[type=text]').each(function() { |
| |
264 |
284 |
$(this).attr('value',$(this).val()); |
| |
265 |
285 |
}); |
| |
266 |
286 |
|
| |
267 |
287 |
|
| |
268 |
288 |
|
| |
269 |
289 |
$(divs[k]).find(':input[type=radio]').each(function() { |
| |
270 |
290 |
|
| |
271 |
291 |
if($(this).prop('checked')) { |
| |
272 |
292 |
$(this).attr('checked', 'checked'); |
| |
273 |
293 |
} |
| |
274 |
294 |
}); |
|
| |
296 |
316 |
|
| |
297 |
317 |
if (typeof CKEDITOR != "undefined") { |
| |
298 |
318 |
|
| |
299 |
319 |
for (var l in CKEDITOR.instances) { |
| |
300 |
320 |
|
| |
301 |
321 |
var searchString = item.parentNode.id + k; |
| |
302 |
322 |
|
| |
303 |
323 |
searchString = searchString.replace(/[.:-]/g,''); |
| |
304 |
324 |
|
| |
305 |
325 |
|
| |
306 |
326 |
if (CKEDITOR.instances[l].name.search(searchString) == 0) { |
| |
307 |
327 |
|
| |
308 |
328 |
|
| |
309 |
329 |
CKEDITOR.instances[l].updateElement(); |
| |
310 |
330 |
document.getElementById(CKEDITOR.instances[l].name).innerHTML=CKEDITOR.instances[l].getData(); |
| |
311 |
331 |
|
| |
312 |
332 |
CKEDITOR.instances[l].destroy(true); |
| |
313 |
333 |
} |
| |
314 |
334 |
} |
| |
315 |
335 |
} |
| |
316 |
|
|
| |
317 |
|
|
| |
318 |
|
|
| |
319 |
|
|
| |
320 |
|
|
| |
321 |
|
|
| |
322 |
|
|
| |
323 |
|
if (typeof window.tinyMCE != "undefined") { |
| |
324 |
|
for (const el of document.querySelectorAll(`[id^='${oldid}'], [id^='${newid}']`)) { |
| |
325 |
|
const editor = window.tinyMCE.get(el.id); |
| |
326 |
|
|
| |
327 |
|
if (!editor) {continue;} |
| |
328 |
|
el.innerHTML = editor.getContent(); |
| |
329 |
|
editor.remove(); |
| |
330 |
|
} |
| |
331 |
|
} |
| |
|
336 |
|
| |
|
337 |
xowiki.tinyMCE?.removeEditor(`[id^='${oldid}'], [id^='${newid}']`); |
| |
|
338 |
|
| |
332 |
339 |
|
| |
333 |
340 |
divs[j].innerHTML = divs[k].innerHTML; |
| |
334 |
341 |
|
| |
335 |
342 |
|
| |
336 |
343 |
|
| |
337 |
344 |
|
| |
338 |
345 |
this.renameIds(divs[j], oldid, newid); |
| |
339 |
346 |
|
| |
340 |
347 |
this.renameItem(divs[j], divs[j], |
| |
341 |
348 |
data['name'] + '.' + (k), data['name'] + '.' + (j)); |
| |
342 |
349 |
|
| |
343 |
350 |
this.registerAddDeleteAction(divs[j]); |
| |
344 |
351 |
} |
| |
345 |
352 |
}; |
| |
346 |
353 |
|
| |
347 |
354 |
|
| |
348 |
355 |
$(item.parentNode).children(".repeat-add-link").show(); |
| |
349 |
356 |
|
| |
350 |
357 |
|
| |
351 |
358 |
if (stats['visible'] > data['min']) { |