/** * General notice: * There is no intialization processus of the pre-checked boxes. * If checkbox should be checked and display their child on start, the children attribute of the checkbox must be filled * * Currently known limitation: * - Inside popin it don't display outside popin * - If the pseudo select tag is all on the right of the screen, the option list will be displayed outside of the screen */ /** * Display the list options when a user click on the pseudo-select tag * * @param String Integer The ID that identify the advanced list */ function show_adv_list( id) { // if a list if currently opened, close this list before if( document.current_list_container) hide_list(); var list_container = document.getElementById( 'list_container_'+ id ); var current_list_head = document.getElementById( 'list_head_'+ id ); // position the option list that should appears list_container.style.top= ( current_list_head.offsetTop + current_list_head.offsetHeight -1 )+"px"; list_container.style.left= current_list_head.offsetLeft+"px"; list_container.style.display= 'block'; list_container.shown = true; current_list_head.default_onmousedown = current_list_head.onmousedown; // store references for the currently opened list document.current_list_container = list_container; document.current_list_head = current_list_head; // the event initialisation is putted in a timeout in order to avoid interaction between thoses declaration and the current event setTimeout('document.onmousedown= verif_click_list', 0); setTimeout('document.current_list_head.onmousedown = ""', 0); } /** * A click has been made somewhere in the window. If it's outside the list, the list should close itself */ function verif_click_list(e ) { if( !e ) e= event; // get the target element of the click var node= (e.target || e.srcElement); while( node.parentNode ) { // the event has been fired inside the displayed list, we stop here if( node == document.current_list_container ) { return false; } node= node.parentNode; } // the click has not been fired insed the displayed list so we hide the opened list hide_list(); return true; } /** * Hide the opened list and cleanup events */ function hide_list( ) { if( document.current_list_container ) { document.current_list_container.style.display = "none"; document.onmousedown = ''; document.current_list_head.onmousedown = document.current_list_head.default_onmousedown; document.current_list_container = false; } } /** * Called when a click is made over a link or a checkbox * * @param String id The ID that identify the checkbox */ function adv_list_click_input( id ) { var input = document.getElementById( 'site_partner_link_site_partner_link_area_list_'+ id ); var children_container = document.getElementById( 'adv_list_child_'+ id ); // change the checked option of the input input.checked = !input.checked; // if the checkbox is now checked, we execute the oncheck process and allow to show the child list if( input.checked ) { children_container.style.display= "block"; eval( input.getAttribute('_oncheck') ); } // otherwise we hiddenthe child list and execute the onuncheck process else { children_container.style.display= "none"; eval( input.getAttribute('_onuncheck') ); } } /** * Ajax call for loading child list * * @param String url The URL of the ajax call * @param String list_id The ID that identify the advance list * @param String check_id The ID that identify the checkbox * @param Boolean do_cache Indicate if the ajax query result must be cached for later calls */ function adv_list_ajax_load( url, list_id, check_id, do_cache) { input = document.getElementById( 'site_partner_link_site_partner_link_area_list_'+ check_id ); var post_params = 'name='+ input.name +'&value='+ input.value +'&destination=adv_list_child_'+ check_id +'&list_id='+ list_id; // Creation of a new Ajax object instance var ajax= new PFW_AJAX(url); ajax.setParametres( post_params ); // Cache activation if( do_cache ) ajax.setCacheMode('auto'); ajax.HTTPrequest(); }