# HG changeset patch # User Adrien Di Mascio # Date 1261474971 -3600 # Node ID 92a10d2a09af897c1efb25cc6720feeccc0a2a05 # Parent 860f622a31aaadf9abf05028747b48f02730fab7 [javascript] cleanup, remove tabs diff -r 860f622a31aa -r 92a10d2a09af web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Tue Dec 22 10:42:39 2009 +0100 +++ b/web/data/cubicweb.ajax.js Tue Dec 22 10:42:51 2009 +0100 @@ -13,16 +13,16 @@ var loaded = []; var jqtagfilter = tag + '[' + srcattr + ']'; jQuery('head ' + jqtagfilter).each(function(i) { - loaded.push(this.getAttribute(srcattr)); + loaded.push(this.getAttribute(srcattr)); }); node.find(tag).each(function(i) { - if (this.getAttribute(srcattr)) { - if (!loaded.contains(this.getAttribute(srcattr))) { - jQuery(this).appendTo(head); - } - } else { - jQuery(this).appendTo(head); - } + if (this.getAttribute(srcattr)) { + if (!loaded.contains(this.getAttribute(srcattr))) { + jQuery(this).appendTo(head); + } + } else { + jQuery(this).appendTo(head); + } }); node.find(jqtagfilter).remove(); } @@ -73,20 +73,20 @@ function postAjaxLoad(node) { // find sortable tables if there are some if (typeof(Sortable) != 'undefined') { - Sortable.sortTables(node); + Sortable.sortTables(node); } // find textareas and wrap them if there are some if (typeof(FCKeditor) != 'undefined') { - buildWysiwygEditors(); + buildWysiwygEditors(); } if (typeof initFacetBoxEvents != 'undefined') { - initFacetBoxEvents(node); + initFacetBoxEvents(node); } if (typeof buildWidgets != 'undefined') { - buildWidgets(node); + buildWidgets(node); } if (typeof roundedCorners != 'undefined') { - roundedCorners(node); + roundedCorners(node); } if (typeof setFormsTarget != 'undefined') { setFormsTarget(node); @@ -97,7 +97,7 @@ // we probably need to unbind the fired events // When this is done, jquery.treeview.js (for instance) // can be unpatched. - jQuery(CubicWeb).trigger('ajax-loaded'); + jQuery(CubicWeb).trigger('ajax-loaded'); } /* cubicweb loadxhtml plugin to make jquery handle xhtml response @@ -113,19 +113,19 @@ jQuery.fn.loadxhtml = function(url, data, reqtype, mode) { var ajax = null; if (reqtype == 'post') { - ajax = jQuery.post; + ajax = jQuery.post; } else { - ajax = jQuery.get; + ajax = jQuery.get; } if (this.size() > 1) { - log('loadxhtml was called with more than one element'); + log('loadxhtml was called with more than one element'); } var node = this.get(0); // only consider the first element mode = mode || 'replace'; var callback = null; if (data && data.callback) { - callback = data.callback; - delete data.callback; + callback = data.callback; + delete data.callback; } ajax(url, data, function(response) { var domnode = getDomFromResponse(response); @@ -155,43 +155,43 @@ */ function loadDynamicFragments(node) { if (node) { - var fragments = jQuery(node).find('div.dynamicFragment'); + var fragments = jQuery(node).find('div.dynamicFragment'); } else { - var fragments = jQuery('div.dynamicFragment'); + var fragments = jQuery('div.dynamicFragment'); } if (fragments.length == 0) { - return; + return; } if (typeof LOADING_MSG == 'undefined') { - LOADING_MSG = 'loading'; // this is only a safety belt, it should not happen + LOADING_MSG = 'loading'; // this is only a safety belt, it should not happen } for(var i=0; i'; - // if cubicweb:loadurl is set, just pick the url et send it to loadxhtml - var url = getNodeAttribute(fragment, 'cubicweb:loadurl'); - if (url) { - jQuery(fragment).loadxhtml(url); - continue; - } - // else: rebuild full url by fetching cubicweb:rql, cubicweb:vid, etc. - var rql = getNodeAttribute(fragment, 'cubicweb:rql'); - var items = getNodeAttribute(fragment, 'cubicweb:vid').split('&'); - var vid = items[0]; + var fragment = fragments[i]; + fragment.innerHTML = '

' + LOADING_MSG + ' ...

'; + // if cubicweb:loadurl is set, just pick the url et send it to loadxhtml + var url = getNodeAttribute(fragment, 'cubicweb:loadurl'); + if (url) { + jQuery(fragment).loadxhtml(url); + continue; + } + // else: rebuild full url by fetching cubicweb:rql, cubicweb:vid, etc. + var rql = getNodeAttribute(fragment, 'cubicweb:rql'); + var items = getNodeAttribute(fragment, 'cubicweb:vid').split('&'); + var vid = items[0]; var extraparams = {}; - // case where vid='myvid¶m1=val1¶m2=val2': this is a deprecated abuse-case - if (items.length > 1) { - console.log("[3.5] you're using extraargs in cubicweb:vid attribute, this is deprecated, consider using loadurl instead"); - for (var j=1; j 1) { + console.log("[3.5] you're using extraargs in cubicweb:vid attribute, this is deprecated, consider using loadurl instead"); + for (var j=1; j return the whole document - return jQuery(doc).clone().context; + // no child (error cases) => return the whole document + return jQuery(doc).clone().context; } children = stripEmptyTextNodes(children); if (children.length == 1) { - // only one child => return it - return jQuery(children[0]).clone().context; + // only one child => return it + return jQuery(children[0]).clone().context; } // several children => wrap them in a single node and return the wrap return DIV({'cubicweb:type': "cwResponseWrapper"},