web/data/cubicweb.ajax.js
changeset 540 e5c97f6f119d
parent 492 cd792cfda071
child 642 2cf7b79d8e77
child 955 3017a858bbc2
equal deleted inserted replaced
539:6ed63265764e 540:e5c97f6f119d
     6 
     6 
     7 CubicWeb.require('python.js');
     7 CubicWeb.require('python.js');
     8 CubicWeb.require('htmlhelpers.js');
     8 CubicWeb.require('htmlhelpers.js');
     9 
     9 
    10 var JSON_BASE_URL = baseuri() + 'json?';
    10 var JSON_BASE_URL = baseuri() + 'json?';
       
    11 
       
    12 function postAjaxLoad(node) {
       
    13     // find sortable tables if there are some
       
    14     if (typeof(Sortable) != 'undefined') {
       
    15 	Sortable.sortTables(node);
       
    16     }
       
    17     // find textareas and wrap them if there are some
       
    18     if (typeof(FCKeditor) != 'undefined') {
       
    19 	buildWysiwygEditors(node);
       
    20     }
       
    21     if (typeof initFacetBoxEvents != 'undefined') {
       
    22 	initFacetBoxEvents(node);
       
    23     }
       
    24     if (typeof buildWidgets != 'undefined') {
       
    25 	buildWidgets(node);
       
    26     }
       
    27 }
    11 
    28 
    12 // cubicweb loadxhtml plugin to make jquery handle xhtml response
    29 // cubicweb loadxhtml plugin to make jquery handle xhtml response
    13 jQuery.fn.loadxhtml = function(url, data, reqtype, mode) {
    30 jQuery.fn.loadxhtml = function(url, data, reqtype, mode) {
    14     var ajax = null;
    31     var ajax = null;
    15     if (reqtype == 'post') {
    32     if (reqtype == 'post') {
    38 	} else if (mode == 'replace') {
    55 	} else if (mode == 'replace') {
    39 	    jQuery(node).empty().append(domnode);
    56 	    jQuery(node).empty().append(domnode);
    40 	} else if (mode == 'append') {
    57 	} else if (mode == 'append') {
    41 	    jQuery(node).append(domnode);
    58 	    jQuery(node).append(domnode);
    42 	}
    59 	}
    43 	// find sortable tables if there are some
    60 	postAjaxLoad(node);
    44 	if (typeof(Sortable) != 'undefined') {
       
    45 	    Sortable.sortTables(node);
       
    46 	}
       
    47 	// find textareas and wrap them if there are some
       
    48 	if (typeof(FCKeditor) != 'undefined') {
       
    49 	    buildWysiwygEditors(node);
       
    50 	}
       
    51 
       
    52 	if (typeof initFacetBoxEvents != 'undefined') {
       
    53 	    initFacetBoxEvents(node);
       
    54 	}
       
    55 
       
    56 	if (typeof buildWidgets != 'undefined') {
       
    57 	    buildWidgets(node);
       
    58 	}
       
    59 
       
    60 	while (jQuery.isFunction(callback)) {
    61 	while (jQuery.isFunction(callback)) {
    61 	    callback = callback.apply(this, [domnode]);
    62 	    callback = callback.apply(this, [domnode]);
    62 	}
    63 	}
    63     });
    64     });
    64 }
    65 };
    65 
    66 
    66 
    67 
    67 
    68 
    68 /* finds each dynamic fragment in the page and executes the
    69 /* finds each dynamic fragment in the page and executes the
    69  * the associated RQL to build them (Async call)
    70  * the associated RQL to build them (Async call)