[ajax] use AJAX_BASE_URL instead of JSON_BASE_URL
JSON_BASE_URL / 'json' should be replaced by AJAX_BASE_URL / 'ajax'
--- a/web/data/cubicweb.ajax.box.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.ajax.box.js Thu Feb 23 12:15:52 2012 +0100
@@ -13,11 +13,11 @@
if (separator) {
value = $.map(value.split(separator), jQuery.trim);
}
- var d = loadRemote('json', ajaxFuncArgs(fname, null, eid, value));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(fname, null, eid, value));
d.addCallback(function() {
$('#' + holderid).empty();
var formparams = ajaxFuncArgs('render', null, 'ctxcomponents', boxid, eid);
- $('#' + cw.utils.domid(boxid) + eid).loadxhtml('json', formparams);
+ $('#' + cw.utils.domid(boxid) + eid).loadxhtml(AJAX_BASE_URL, formparams);
if (msg) {
document.location.hash = '#header';
updateMessage(msg);
@@ -26,10 +26,10 @@
}
function ajaxBoxRemoveLinkedEntity(boxid, eid, relatedeid, delfname, msg) {
- var d = loadRemote('json', ajaxFuncArgs(delfname, null, eid, relatedeid));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(delfname, null, eid, relatedeid));
d.addCallback(function() {
var formparams = ajaxFuncArgs('render', null, 'ctxcomponents', boxid, eid);
- $('#' + cw.utils.domid(boxid) + eid).loadxhtml('json', formparams);
+ $('#' + cw.utils.domid(boxid) + eid).loadxhtml(AJAX_BASE_URL, formparams);
if (msg) {
document.location.hash = '#header';
updateMessage(msg);
@@ -69,7 +69,7 @@
}
else {
var inputid = holderid + 'Input';
- var deferred = loadRemote('json', ajaxFuncArgs(unrelfname, null, eid));
+ var deferred = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(unrelfname, null, eid));
deferred.addCallback(function (unrelated) {
var input = INPUT({'type': 'text', 'id': inputid, 'size': 20});
holder.append(input).show();
--- a/web/data/cubicweb.ajax.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.ajax.js Thu Feb 23 12:15:52 2012 +0100
@@ -86,8 +86,9 @@
});
-
+var AJAX_PREFIX_URL = 'ajax';
var JSON_BASE_URL = baseuri() + 'json?';
+var AJAX_BASE_URL = baseuri() + AJAX_PREFIX_URL + '?';
jQuery.extend(cw.ajax, {
@@ -439,7 +440,7 @@
* emulation of gettext's _ shortcut
*/
function _(message) {
- return loadRemote('json', ajaxFuncArgs('i18n', null, [message]), 'GET', true)[0];
+ return loadRemote(AJAX_BASE_URL, ajaxFuncArgs('i18n', null, [message]), 'GET', true)[0];
}
/**
@@ -495,19 +496,19 @@
}
extraparams['rql'] = rql;
extraparams['vid'] = vid;
- $fragment.loadxhtml('json', ajaxFuncArgs('view', extraparams));
+ $fragment.loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('view', extraparams));
}
}
function unloadPageData() {
// NOTE: do not make async calls on unload if you want to avoid
// strange bugs
- loadRemote('json', ajaxFuncArgs('unload_page_data'), 'GET', true);
+ loadRemote(AJAX_BASE_URL, ajaxFuncArgs('unload_page_data'), 'GET', true);
}
function removeBookmark(beid) {
- var d = loadRemote('json', ajaxFuncArgs('delete_bookmark', null, beid));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('delete_bookmark', null, beid));
d.addCallback(function(boxcontent) {
- $('#bookmarks_box').loadxhtml('json',
+ $('#bookmarks_box').loadxhtml(AJAX_BASE_URL,
ajaxFuncArgs('render', null, 'ctxcomponents',
'bookmarks_box'));
document.location.hash = '#header';
@@ -517,7 +518,7 @@
function userCallback(cbname) {
setProgressCursor();
- var d = loadRemote('json', ajaxFuncArgs('user_callback', null, cbname));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('user_callback', null, cbname));
d.addCallback(resetCursor);
d.addErrback(resetCursor);
d.addErrback(remoteCallFailed);
@@ -527,7 +528,7 @@
function userCallbackThenUpdateUI(cbname, compid, rql, msg, registry, nodeid) {
var d = userCallback(cbname);
d.addCallback(function() {
- $('#' + nodeid).loadxhtml('json', ajaxFuncArgs('render', {'rql': rql},
+ $('#' + nodeid).loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('render', {'rql': rql},
registry, compid));
if (msg) {
updateMessage(msg);
@@ -553,7 +554,7 @@
*/
function unregisterUserCallback(cbname) {
setProgressCursor();
- var d = loadRemote('json', ajaxFuncArgs('unregister_user_callback',
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('unregister_user_callback',
null, cbname));
d.addCallback(resetCursor);
d.addErrback(resetCursor);
@@ -679,7 +680,7 @@
var compid = this.id.replace("_", ".").rstrip(creationEid);
var params = ajaxFuncArgs('render', null, 'ctxcomponents',
compid, actualEid);
- $(this).loadxhtml('json', params, null, 'swap', true);
+ $(this).loadxhtml(AJAX_BASE_URL, params, null, 'swap', true);
});
$compsholder.attr('id', context + actualEid);
}
@@ -694,7 +695,7 @@
var ajaxArgs = ['render', formparams, registry, compid];
ajaxArgs = ajaxArgs.concat(cw.utils.sliceList(arguments, 4));
var params = ajaxFuncArgs.apply(null, ajaxArgs);
- return $('#'+domid).loadxhtml('json', params, null, 'swap');
+ return $('#'+domid).loadxhtml(AJAX_BASE_URL, params, null, 'swap');
}
/* ajax tabs ******************************************************************/
@@ -738,8 +739,8 @@
nodeid = nodeid || (compid + 'Component');
extraargs = extraargs || {};
var node = cw.jqNode(nodeid);
- return node.loadxhtml('json', ajaxFuncArgs('component', null, compid,
- rql, registry, extraargs));
+ return node.loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('component', null, compid,
+ rql, registry, extraargs));
}
);
@@ -775,7 +776,7 @@
// passing `props` directly to loadxml because replacePageChunk
// is sometimes called (abusively) with some extra parameters in `vid`
var mode = swap ? 'swap': 'replace';
- var url = JSON_BASE_URL + asURL(props);
+ var url = AJAX_BASE_URL + asURL(props);
jQuery(node).loadxhtml(url, params, 'get', mode);
} else {
cw.log('Node', nodeId, 'not found');
@@ -798,7 +799,7 @@
arg: $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON)
};
var result = jQuery.ajax({
- url: JSON_BASE_URL,
+ url: AJAX_BASE_URL,
data: props,
async: false,
traditional: true
@@ -818,7 +819,7 @@
arg: $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON)
};
// XXX we should inline the content of loadRemote here
- var deferred = loadRemote(JSON_BASE_URL, props, 'POST');
+ var deferred = loadRemote(AJAX_BASE_URL, props, 'POST');
deferred = deferred.addErrback(remoteCallFailed);
deferred = deferred.addErrback(resetCursor);
deferred = deferred.addCallback(resetCursor);
--- a/web/data/cubicweb.edition.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.edition.js Thu Feb 23 12:15:52 2012 +0100
@@ -28,7 +28,7 @@
pageid: pageid,
arg: $.map([key, varname, tabindex], jQuery.toJSON)
};
- cw.jqNode('div:value:' + varname).loadxhtml(JSON_BASE_URL, args, 'post');
+ cw.jqNode('div:value:' + varname).loadxhtml(AJAX_BASE_URL, args, 'post');
}
}
@@ -170,8 +170,8 @@
// add hidden parameter
var entityForm = jQuery('#entityForm');
var oid = optionNode.id.substring(2); // option id is prefixed by "id"
- loadRemote('json', ajaxFuncArgs('add_pending_inserts', null,
- [oid.split(':')]), 'GET', true);
+ loadRemote(AJAX_BASE_URL, ajaxFuncArgs('add_pending_inserts', null,
+ [oid.split(':')]), 'GET', true);
var selectNode = optionNode.parentNode;
// remove option node
selectNode.removeChild(optionNode);
@@ -209,8 +209,8 @@
}
}
elementId = elementId.substring(2, elementId.length);
- loadRemote('json', ajaxFuncArgs('remove_pending_insert', null,
- elementId.split(':')), 'GET', true);
+ loadRemote(AJAX_BASE_URL, ajaxFuncArgs('remove_pending_insert', null,
+ elementId.split(':')), 'GET', true);
}
/**
@@ -234,7 +234,7 @@
* * `nodeId`, eid_from:r_type:eid_to
*/
function addPendingDelete(nodeId, eid) {
- var d = loadRemote('json', ajaxFuncArgs('add_pending_delete', null, nodeId.split(':')));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('add_pending_delete', null, nodeId.split(':')));
d.addCallback(function() {
// and strike entity view
cw.jqNode('span' + nodeId).addClass('pendingDelete');
@@ -249,7 +249,7 @@
* * `nodeId`, eid_from:r_type:eid_to
*/
function cancelPendingDelete(nodeId, eid) {
- var d = loadRemote('json', ajaxFuncArgs('remove_pending_delete', null, nodeId.split(':')));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('remove_pending_delete', null, nodeId.split(':')));
d.addCallback(function() {
// reset link's CSS class
cw.jqNode('span' + nodeId).removeClass('pendingDelete');
@@ -275,7 +275,7 @@
function selectForAssociation(tripletIdsString, originalEid) {
var tripletlist = $.map(tripletIdsString.split('-'),
function(x) { return [x.split(':')] ;});
- var d = loadRemote('json', ajaxFuncArgs('add_pending_inserts', null, tripletlist));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('add_pending_inserts', null, tripletlist));
d.addCallback(function() {
var args = {
vid: 'edition',
@@ -308,7 +308,7 @@
function addInlineCreationForm(peid, petype, ttype, rtype, role, i18nctx, insertBefore) {
insertBefore = insertBefore || cw.getNode('add' + rtype + ':' + peid + 'link').parentNode;
var args = ajaxFuncArgs('inline_creation_form', null, peid, petype, ttype, rtype, role, i18nctx);
- var d = loadRemote('json', args);
+ var d = loadRemote(AJAX_BASE_URL, args);
d.addCallback(function(response) {
var dom = getDomFromResponse(response);
loadAjaxHtmlHead(dom);
@@ -587,7 +587,7 @@
try {
var zipped = cw.utils.formContents(formid);
var args = ajaxFuncArgs('validate_form', null, action, zipped[0], zipped[1]);
- var d = loadRemote('json', args, 'POST');
+ var d = loadRemote(AJAX_BASE_URL, args, 'POST');
} catch(ex) {
cw.log('got exception', ex);
return false;
--- a/web/data/cubicweb.facets.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.facets.js Thu Feb 23 12:15:52 2012 +0100
@@ -56,7 +56,7 @@
var zipped = facetFormContent($form);
zipped[0].push('facetargs');
zipped[1].push(vidargs);
- var d = loadRemote('json', ajaxFuncArgs('filter_build_rql', null, zipped[0], zipped[1]));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('filter_build_rql', null, zipped[0], zipped[1]));
d.addCallback(function(result) {
var rql = result[0];
var $bkLink = jQuery('#facetBkLink');
@@ -87,7 +87,7 @@
if (vid) { // XXX see copyParam above. Need cleanup
extraparams['vid'] = vid;
}
- d = $('#' + divid).loadxhtml('json', ajaxFuncArgs('view', extraparams),
+ d = $('#' + divid).loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('view', extraparams),
null, 'swap');
d.addCallback(function() {
// XXX rql/vid in extraparams
@@ -99,14 +99,14 @@
// now
var $node = jQuery('#edit_box');
if ($node.length) {
- $node.loadxhtml('json', ajaxFuncArgs('render', {
+ $node.loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('render', {
'rql': rql
},
'ctxcomponents', 'edit_box'));
}
$node = jQuery('#breadcrumbs');
if ($node.length) {
- $node.loadxhtml('json', ajaxFuncArgs('render', {
+ $node.loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('render', {
'rql': rql
},
'ctxcomponents', 'breadcrumbs'));
@@ -118,7 +118,7 @@
mainvar = zipped[1][index];
}
- var d = loadRemote('json', ajaxFuncArgs('filter_select_content', null, toupdate, rql, mainvar));
+ var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('filter_select_content', null, toupdate, rql, mainvar));
d.addCallback(function(updateMap) {
for (facetName in updateMap) {
var values = updateMap[facetName];
--- a/web/data/cubicweb.reledit.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.reledit.js Thu Feb 23 12:15:52 2012 +0100
@@ -53,7 +53,7 @@
return;
}
}
- jQuery('#'+params.divid+'-reledit').loadxhtml(JSON_BASE_URL, params, 'post');
+ jQuery('#'+params.divid+'-reledit').loadxhtml(AJAX_BASE_URL, params, 'post');
jQuery(cw).trigger('reledit-reloaded', params);
},
@@ -69,7 +69,7 @@
pageid: pageid, action: action,
eid: eid, divid: divid, formid: formid,
reload: reload, vid: vid};
- var d = jQuery('#'+divid+'-reledit').loadxhtml(JSON_BASE_URL, args, 'post');
+ var d = jQuery('#'+divid+'-reledit').loadxhtml(AJAX_BASE_URL, args, 'post');
d.addCallback(function () {cw.reledit.showInlineEditionForm(divid);});
}
});
--- a/web/data/cubicweb.widgets.js Tue Feb 21 16:58:43 2012 +0100
+++ b/web/data/cubicweb.widgets.js Thu Feb 23 12:15:52 2012 +0100
@@ -45,11 +45,11 @@
});
function postJSON(url, data, callback) {
- return jQuery.post(url, data, callback, 'json');
+ return jQuery.post(url, data, callback, AJAX_BASE_URL);
}
function getJSON(url, data, callback) {
- return jQuery.get(url, data, callback, 'json');
+ return jQuery.get(url, data, callback, AJAX_BASE_URL);
}