diff -r 06af20e663f2 -r 7ff24154351d web/data/cubicweb.edition.js --- a/web/data/cubicweb.edition.js Tue Apr 21 19:20:56 2009 +0200 +++ b/web/data/cubicweb.edition.js Wed Apr 22 16:50:46 2009 +0200 @@ -1,6 +1,6 @@ /* * :organization: Logilab - * :copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. + * :copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr */ @@ -22,7 +22,8 @@ function setPropValueWidget(varname, tabindex) { var key = firstSelected(document.getElementById('pkey:'+varname)); if (key) { - var args = _buildRemoteArgs('prop_widget', key, varname, tabindex); + var args = {fname: 'prop_widget', pageid: pageid, + arg: map(jQuery.toJSON, [key, varname, tabindex])}; jqNode('div:value:'+varname).loadxhtml(JSON_BASE_URL, args, 'post'); } } @@ -51,40 +52,25 @@ }); } + function showMatchingSelect(selectedValue, eid) { if (selectedValue) { divId = 'div' + selectedValue + '_' + eid; var divNode = jQuery('#' + divId); if (!divNode.length) { var args = {vid: 'unrelateddivs', relation: selectedValue, - rql: rql_for_eid(eid), pageid: pageid, - '__notemplate': 1}; - jQuery.get(JSON_BASE_URL, args, function(response) { - // append generated HTML to the cell - jQuery('#unrelatedDivs_' + eid).append(getDomFromResponse(response)); - _showMatchingSelect(eid, jQuery('#' + divId)); - }); - // deferred = doXHR(JSON_BASE_URL + queryString(args)); - // deferred.addCallback(_buildAndShowMatchingSelect, eid, divId); + rql: rql_for_eid(eid), '__notemplate': 1, + callback: function() {_showMatchingSelect(eid, jQuery('#' + divId))}}; + jQuery('#unrelatedDivs_' + eid).loadxhtml(baseuri() + 'view', args, 'post', 'append'); } else { _showMatchingSelect(eid, divNode); } - } - else { + } else { _showMatchingSelect(eid, null); } } - -// @param divStr a HTML string returned by the server -// function _buildAndShowMatchingSelect(eid, divId, req) { -// var tdNode = jQuery('#unrelatedDivs_' + eid); -// // append generated HTML to the cell -// tdNode.appendChild(getDomFromRequest(req)); -// _showMatchingSelect(eid, jQuery('#' + divId)); -// } - // @param divNode is a jQuery selection function _showMatchingSelect(eid, divNode) { // hide all divs, and then show the matching one @@ -154,7 +140,7 @@ // add hidden parameter var entityForm = jQuery('#entityForm'); var oid = optionNode.id.substring(2); // option id is prefixed by "id" - remote_exec('add_pending_insert', oid.split(':')); + remoteExec('add_pending_inserts', [oid.split(':')]); var selectNode = optionNode.parentNode; // remove option node selectNode.removeChild(optionNode); @@ -186,7 +172,7 @@ options[options.length] = OPTION({'id' : elementId, 'value' : node_id}, entityView); } } - remote_exec('remove_pending_insert', elementId.split(':')); + remoteExec('remove_pending_insert', elementId.split(':')); } // this function builds a Handle to cancel pending insertion @@ -198,7 +184,7 @@ // @param nodeId eid_from:r_type:eid_to function addPendingDelete(nodeId, eid) { - var d = async_remote_exec('add_pending_delete', nodeId.split(':')); + var d = asyncRemoteExec('add_pending_delete', nodeId.split(':')); d.addCallback(function () { // and strike entity view jqNode('span' + nodeId).addClass('pendingDelete'); @@ -209,7 +195,7 @@ // @param nodeId eid_from:r_type:eid_to function cancelPendingDelete(nodeId, eid) { - var d = async_remote_exec('remove_pending_delete', nodeId.split(':')); + var d = asyncRemoteExec('remove_pending_delete', nodeId.split(':')); d.addCallback(function () { // reset link's CSS class jqNode('span' + nodeId).removeClass('pendingDelete'); @@ -232,11 +218,11 @@ function selectForAssociation(tripletIdsString, originalEid) { var tripletlist = map(function (x) { return x.split(':'); }, tripletIdsString.split('-')); - var d = async_remote_exec('add_pending_inserts', tripletlist); + var d = asyncRemoteExec('add_pending_inserts', tripletlist); d.addCallback(function () { var args = {vid: 'edition', __mode: 'normal', rql: rql_for_eid(originalEid)}; - document.location = 'view?' + as_url(args); + document.location = 'view?' + asURL(args); }); } @@ -246,13 +232,9 @@ jQuery('#inline' + rtype + 'slot span.icounter').each(function (i) { this.innerHTML = i+1; }); - // var divnode = jQuery('#inline' + rtype + 'slot'); - // var iforms = getElementsByTagAndClassName('span', 'icounter', divnode); - // for (var i=0; i