# HG changeset patch # User Sylvain Thénault # Date 1278586465 -7200 # Node ID 82cac9383dd8d7e29de244d9f59cdafcff5ac6ed # Parent 98ac4000e820143c7735815a96d8471da05dc34a [javascript] more cleanups and deprecation warnings removal diff -r 98ac4000e820 -r 82cac9383dd8 web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Thu Jul 08 12:54:14 2010 +0200 +++ b/web/data/cubicweb.ajax.js Thu Jul 08 12:54:25 2010 +0200 @@ -241,7 +241,7 @@ $(node).removeClass("hidden"); if (mode == 'swap') { var origId = node.id; - node = swapDOM(node, domnode); + node = cw.swapDOM(node, domnode); if (!node.id) { node.id = origId; } @@ -255,16 +255,16 @@ callback = callback.apply(this, [domnode]); } }); + d.addErrback(remoteCallFailed); if (cursor) { d.addCallback(resetCursor); d.addErrback(resetCursor); - d.addErrback(remoteCallFailed); } return d; } /** - * .. function:: loadRemote(url, form, reqtype='GET', async=true) + * .. function:: loadRemote(url, form, reqtype='GET', sync=false) * * Asynchronously (unless `async` argument is set to false) load an url or path * and return a deferred whose callbacks args are decoded according to the diff -r 98ac4000e820 -r 82cac9383dd8 web/data/cubicweb.edition.js --- a/web/data/cubicweb.edition.js Thu Jul 08 12:54:14 2010 +0200 +++ b/web/data/cubicweb.edition.js Thu Jul 08 12:54:25 2010 +0200 @@ -48,7 +48,7 @@ if ($.inArray(tagName, inputTypes)) { if (jQuery(elem).attr('tabindex') != null) { tabindex += 1; - jQuery(elem).attr('tabindex', tabindex); + jQuery(elem).attr('tabindex', tabindex); } return null; } @@ -170,7 +170,8 @@ // add hidden parameter var entityForm = jQuery('#entityForm'); var oid = optionNode.id.substring(2); // option id is prefixed by "id" - remoteExec('add_pending_inserts', [oid.split(':')]); + loadRemote('json', ajaxFuncArgs('add_pending_inserts', null, + [oid.split(':')]), 'GET', true); var selectNode = optionNode.parentNode; // remove option node selectNode.removeChild(optionNode); @@ -208,7 +209,8 @@ } } elementId = elementId.substring(2, elementId.length); - remoteExec('remove_pending_insert', elementId.split(':')); + loadRemote('json', ajaxFuncArgs('remove_pending_inserts', null, + elementId.split(':')), 'GET', true); } /** @@ -337,8 +339,8 @@ */ function removeInlineForm(peid, rtype, role, eid, showaddnewlink) { cw.jqNode(['div', peid, rtype, eid].join('-')).slideUp('fast', function() { - $(this).remove(); - updateInlinedEntitiesCounters(rtype, role); + $(this).remove(); + updateInlinedEntitiesCounters(rtype, role); }); if (showaddnewlink) { toggleVisibility(showaddnewlink); @@ -469,10 +471,10 @@ var errmsg; // Unknown structure if ( !cw.utils.isArrayLike(descr) || descr.length != 2 ) { - errmsg = descr; + errmsg = descr; } else { - _displayValidationerrors(formid, descr[0], descr[1]); - errmsg = _('please correct errors below'); + _displayValidationerrors(formid, descr[0], descr[1]); + errmsg = _('please correct errors below'); } updateMessage(errmsg); // ensure the browser does not scroll down diff -r 98ac4000e820 -r 82cac9383dd8 web/data/cubicweb.facets.js --- a/web/data/cubicweb.facets.js Thu Jul 08 12:54:14 2010 +0200 +++ b/web/data/cubicweb.facets.js Thu Jul 08 12:54:25 2010 +0200 @@ -1,10 +1,15 @@ -/** +/** filter form, aka facets, javascript functions + * * :organization: Logilab * :copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. * :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr */ -//============= filter form functions ========================================// +var SELECTED_IMG = baseuri() + "data/black-check.png"; +var UNSELECTED_IMG = baseuri() + "data/no-check-no-border.png"; +var UNSELECTED_BORDER_IMG = baseuri() + "data/black-uncheck.png"; + + function copyParam(origparams, newparams, param) { var index = jQuery.inArray(param, origparams[0]); if (index > - 1) { @@ -12,31 +17,33 @@ } } -function facetFormContent(form) { + +function facetFormContent($form) { var names = []; var values = []; - jQuery(form).find('.facet').each(function() { + $form.find('.facet').each(function() { var facetName = jQuery(this).find('.facetTitle').attr('cubicweb:facetName'); var facetValues = jQuery(this).find('.facetValueSelected').each(function(x) { names.push(facetName); values.push(this.getAttribute('cubicweb:value')); }); }); - jQuery(form).find('input').each(function() { + $form.find('input').each(function() { names.push(this.name); values.push(this.value); }); - jQuery(form).find('select option[selected]').each(function() { + $form.find('select option[selected]').each(function() { names.push(this.parentNode.name); values.push(this.value); }); return [names, values]; } + function buildRQL(divid, vid, paginate, vidargs) { jQuery(CubicWeb).trigger('facets-content-loading', [divid, vid, paginate, vidargs]); - var form = getNode(divid + 'Form'); - var zipped = facetFormContent(form); + var $form = $('#' + divid + 'Form'); + 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])); @@ -78,8 +85,8 @@ }); if (paginate) { // FIXME the edit box might not be displayed in which case we don't - // know where to put the potential new one, just skip this case - // for now + // know where to put the potential new one, just skip this case for + // now var $node = jQuery('#edit_box'); if ($node.length) { $node.loadxhtml('json', ajaxFuncArgs('render', { @@ -116,9 +123,6 @@ }); } -var SELECTED_IMG = baseuri() + "data/black-check.png"; -var UNSELECTED_IMG = baseuri() + "data/no-check-no-border.png"; -var UNSELECTED_BORDER_IMG = baseuri() + "data/black-uncheck.png"; function initFacetBoxEvents(root) { // facetargs : (divid, vid, paginate, extraargs) @@ -206,6 +210,7 @@ }); } + // trigger this function on document ready event if you provide some kind of // persistent search (eg crih) function reorderFacetsItems(root) { @@ -233,10 +238,11 @@ }); } -// we need to differenciate cases where initFacetBoxEvents is called -// with one argument or without any argument. If we use `initFacetBoxEvents` -// as the direct callback on the jQuery.ready event, jQuery will pass some argument -// of his, so we use this small anonymous function instead. + +// we need to differenciate cases where initFacetBoxEvents is called with one +// argument or without any argument. If we use `initFacetBoxEvents` as the +// direct callback on the jQuery.ready event, jQuery will pass some argument of +// his, so we use this small anonymous function instead. jQuery(document).ready(function() { initFacetBoxEvents(); });