43 var form = cw.getNode(formid || 'entityForm'); |
43 var form = cw.getNode(formid || 'entityForm'); |
44 var inputTypes = ['INPUT', 'SELECT', 'TEXTAREA']; |
44 var inputTypes = ['INPUT', 'SELECT', 'TEXTAREA']; |
45 var tabindex = (start == null) ? 15: start; |
45 var tabindex = (start == null) ? 15: start; |
46 cw.utils.nodeWalkDepthFirst(form, function(elem) { |
46 cw.utils.nodeWalkDepthFirst(form, function(elem) { |
47 var tagName = elem.tagName.toUpperCase(); |
47 var tagName = elem.tagName.toUpperCase(); |
48 if (inputTypes.contains(tagName)) { |
48 if ($.inArray(tagName, inputTypes)) { |
49 if (jQuery(elem).attr('tabindex') != null) { |
49 if (jQuery(elem).attr('tabindex') != null) { |
50 tabindex += 1; |
50 tabindex += 1; |
51 jQuery(elem).attr('tabindex', tabindex); |
51 jQuery(elem).attr('tabindex', tabindex); |
52 } |
52 } |
53 return null; |
53 return null; |
307 insertBefore = insertBefore || cw.getNode('add' + rtype + ':' + peid + 'link').parentNode; |
307 insertBefore = insertBefore || cw.getNode('add' + rtype + ':' + peid + 'link').parentNode; |
308 var args = ajaxFuncArgs('inline_creation_form', null, peid, petype, ttype, rtype, role, i18nctx); |
308 var args = ajaxFuncArgs('inline_creation_form', null, peid, petype, ttype, rtype, role, i18nctx); |
309 var d = loadRemote('json', args); |
309 var d = loadRemote('json', args); |
310 d.addCallback(function(response) { |
310 d.addCallback(function(response) { |
311 var dom = getDomFromResponse(response); |
311 var dom = getDomFromResponse(response); |
312 preprocessAjaxLoad(null, dom); |
312 loadAjaxHtmlHead(dom); |
313 var form = jQuery(dom); |
313 var form = jQuery(dom); |
314 form.css('display', 'none'); |
314 form.css('display', 'none'); |
315 form.insertBefore(insertBefore).slideDown('fast'); |
315 form.insertBefore(insertBefore).slideDown('fast'); |
316 updateInlinedEntitiesCounters(rtype, role); |
316 updateInlinedEntitiesCounters(rtype, role); |
317 reorderTabindex(null, $(insertBefore).closest('form')[0]); |
317 reorderTabindex(null, $(insertBefore).closest('form')[0]); |
321 if (form.find('input:file').length) { |
321 if (form.find('input:file').length) { |
322 // NOTE: IE doesn't support dynamic enctype modification, we have |
322 // NOTE: IE doesn't support dynamic enctype modification, we have |
323 // to set encoding too. |
323 // to set encoding too. |
324 form.closest('form').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data'); |
324 form.closest('form').attr('enctype', 'multipart/form-data').attr('encoding', 'multipart/form-data'); |
325 } |
325 } |
326 postAjaxLoad(dom); |
326 _postAjaxLoad(dom); |
327 }); |
327 }); |
328 d.addErrback(function(xxx) { |
328 d.addErrback(function(xxx) { |
329 log('xxx =', xxx); |
329 log('xxx =', xxx); |
330 }); |
330 }); |
331 } |
331 } |