Index: openacs-4/packages/xowiki/tcl/repeat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/repeat-procs.tcl,v diff -u -r1.14.2.14 -r1.14.2.15 --- openacs-4/packages/xowiki/tcl/repeat-procs.tcl 19 Apr 2023 17:31:26 -0000 1.14.2.14 +++ openacs-4/packages/xowiki/tcl/repeat-procs.tcl 30 Apr 2024 07:14:16 -0000 1.14.2.15 @@ -100,22 +100,12 @@ set componentItemSpecs [list [list 0 $itemSpec]] # - # Add max content items (1 .. max) and build form fields + # We use dynamic repeat fields. The number of fields generated on + # the server side is the minimum, while the rest will be created + # on demand via javascript. # - set formAction [${:object} form_parameter __form_action:graph {}] - # TODO: we use for the time being the code for dynamic repeat field - if {0 && $formAction eq ""} { - # - # The form field is in input mode; as long there is no js - # support do incrementally add form fields in js, we have to - # generate it here. - # - set max [:max] - } else { - #set max [:max] - set max [:min] ;# use dynamic repeat fields: if set to min, repeat fields will be created on demand - } - #ns_log notice "dynamic repeat MAX=$max FORMACTION <$formAction>" + set max [:min] + for {set i 1} {$i <= $max} {incr i} { set componentItemSpec [:component_item_spec $i $itemSpec $isRequired] #ns_log notice "dynamic repeat componentItemSpec $componentItemSpec" Index: openacs-4/packages/xowiki/www/resources/repeat.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/repeat.js,v diff -u -r1.4.2.3 -r1.4.2.4 --- openacs-4/packages/xowiki/www/resources/repeat.js 14 Aug 2019 07:36:40 -0000 1.4.2.3 +++ openacs-4/packages/xowiki/www/resources/repeat.js 30 Apr 2024 07:14:16 -0000 1.4.2.4 @@ -1,66 +1,7 @@ var xowiki = xowiki || {}; xowiki.repeat = {}; var data_repeat = new Array(); -/* - * addItem - * - * Add an item to the container if nrItems is below maximum. Actually, - * this function just invisible items visible. - */ -xowiki.repeat.addItem = function(e, json) { - //var data = eval("(" + json + ')'); - var data = JSON.parse(json); - var items = $(e.parentNode).children(".repeatable:hidden"); - var currentItem = ''; - // the loop starts with 1 because items[0] is the template - for (var j = 1; j < items.length; j++) { - currentItem = items[j]; - if (currentItem.nodeName != 'DIV') { continue; } - if (currentItem.style.display == 'none') { - if (j == (items.length)-1) { - // this is the final item: hide add item button - $(e.parentNode).children(".repeat-add-link").hide(); - } - // Make an existing but invisible item visible. - currentItem.style.display = 'block'; - /* - // IPAD HACK START - // for ipad we have to set the contenteditiable to true for the ckeditor inline if it is false - var ck_editors = $(currentItem).find('.xowiki-ckeditor.cke_editable.cke_editable_inline.cke_contents_ltr'); - for (var k = 0; k < ck_editors.length; k++) { - if ($(ck_editors[k]).attr('contenteditable') == 'false') { - console.log('we have to set the contenteditable to true'); - $(ck_editors[k]).attr('contenteditable','true'); - } - } - // IPAD HACK END - */ - break; - } - } - - $(".xowiki-ckeditor, .datetimepicker", currentItem).each(function (i,e) { - //console.debug('load ckeditor' +e.id); - if ($(e).is(':visible')) { - var functionname = 'load_' + e.id; - try { - window[functionname](); - } catch(err) { - //console.log('function: ' + functionname + ' not found'); - } - } - }); - - // We could add another item here by adding a copy of the template - // and renaming the field like in delItems. We have to care as - // well in RepeatContainer.initialize() to check, how many - // subcomponents must be generated in advance (not max as now). - //console.log('could add one more, j ' + j); - //console.info(data); - return false; -}; - /* * newItem *