92 |
92 |
93 //============= utility function handling remote calls responses. ==============// |
93 //============= utility function handling remote calls responses. ==============// |
94 function _loadAjaxHtmlHead($node, $head, tag, srcattr) { |
94 function _loadAjaxHtmlHead($node, $head, tag, srcattr) { |
95 var jqtagfilter = tag + '[' + srcattr + ']'; |
95 var jqtagfilter = tag + '[' + srcattr + ']'; |
96 if (cw['loaded_'+srcattr] === undefined) { |
96 if (cw['loaded_'+srcattr] === undefined) { |
97 cw['loaded_'+srcattr] = []; |
97 cw['loaded_'+srcattr] = []; |
98 var loaded = cw['loaded_'+srcattr]; |
98 var loaded = cw['loaded_'+srcattr]; |
99 jQuery('head ' + jqtagfilter).each(function(i) { |
99 jQuery('head ' + jqtagfilter).each(function(i) { |
100 loaded.push(this.getAttribute(srcattr)); |
100 loaded.push(this.getAttribute(srcattr)); |
101 }); |
101 }); |
102 } else { |
102 } else { |
103 var loaded = cw['loaded_'+srcattr]; |
103 var loaded = cw['loaded_'+srcattr]; |
104 } |
104 } |
105 $node.find(tag).each(function(i) { |
105 $node.find(tag).each(function(i) { |
106 var url = this.getAttribute(srcattr); |
106 var url = this.getAttribute(srcattr); |
107 if (url) { |
107 if (url) { |
108 if (jQuery.inArray(url, loaded) == -1) { |
108 if (jQuery.inArray(url, loaded) == -1) { |
109 // take care to <script> tags: jQuery append method script nodes |
109 // take care to <script> tags: jQuery append method script nodes |
110 // don't appears in the DOM (See comments on |
110 // don't appears in the DOM (See comments on |
111 // http://api.jquery.com/append/), which cause undesired |
111 // http://api.jquery.com/append/), which cause undesired |
112 // duplicated load in our case. After trying to use bare DOM api |
112 // duplicated load in our case. After trying to use bare DOM api |
113 // to avoid this, we switched to handle a list of already loaded |
113 // to avoid this, we switched to handle a list of already loaded |
114 // stuff ourselves, since bare DOM api gives bug with the |
114 // stuff ourselves, since bare DOM api gives bug with the |
115 // server-response event, since we loose control on when the |
115 // server-response event, since we loose control on when the |
116 // script is loaded (jQuery load it immediatly). |
116 // script is loaded (jQuery load it immediatly). |
117 loaded.push(url); |
117 loaded.push(url); |
118 jQuery(this).appendTo($head); |
118 jQuery(this).appendTo($head); |
119 } |
119 } |
120 } else { |
120 } else { |
121 jQuery(this).appendTo($head); |
121 jQuery(this).appendTo($head); |
122 } |
122 } |
123 }); |
123 }); |
439 |
439 |
440 function userCallbackThenUpdateUI(cbname, compid, rql, msg, registry, nodeid) { |
440 function userCallbackThenUpdateUI(cbname, compid, rql, msg, registry, nodeid) { |
441 var d = userCallback(cbname); |
441 var d = userCallback(cbname); |
442 d.addCallback(function() { |
442 d.addCallback(function() { |
443 $('#' + nodeid).loadxhtml('json', ajaxFuncArgs('render', {'rql': rql}, |
443 $('#' + nodeid).loadxhtml('json', ajaxFuncArgs('render', {'rql': rql}, |
444 registry, compid)); |
444 registry, compid)); |
445 if (msg) { |
445 if (msg) { |
446 updateMessage(msg); |
446 updateMessage(msg); |
447 } |
447 } |
448 }); |
448 }); |
449 } |
449 } |
558 // only one child => return it |
558 // only one child => return it |
559 return jQuery(children[0]).clone().context; |
559 return jQuery(children[0]).clone().context; |
560 } |
560 } |
561 // several children => wrap them in a single node and return the wrap |
561 // several children => wrap them in a single node and return the wrap |
562 return DIV({'cubicweb:type': "cwResponseWrapper"}, |
562 return DIV({'cubicweb:type': "cwResponseWrapper"}, |
563 $.map(children, function(node) { |
563 $.map(children, function(node) { |
564 return jQuery(node).clone().context;}) |
564 return jQuery(node).clone().context;}) |
565 ); |
565 ); |
566 } |
566 } |
567 |
567 |
568 /* DEPRECATED *****************************************************************/ |
568 /* DEPRECATED *****************************************************************/ |
569 |
569 |
570 preprocessAjaxLoad = cw.utils.deprecatedFunction( |
570 preprocessAjaxLoad = cw.utils.deprecatedFunction( |