Archives FluxBB.fr

Les archives de FluxBB.fr

Vous n'êtes pas identifié(e).

#1 22-04-2011 15:45:43

barbuslex
Membre

[Résolu] Ajax quick post pour v1.4.5

Salut,

Je viens de mettre a jour mon forum vers la v1.4.5 et aussi le mod AJAX QUICK POST :
http://fluxbb.org/resources/mods/ajax-quick-post/

Seulement dans le viewtopic.php la v1.4.5 fait qu'il y est rajouté le bouton "Prévisualisation" pour les réponses rapides.

Lorsque l'on clique sur "Prévisualisation" le bouton ne fonctionne pas car le mod envoi le message comme si on appuyé sur le bouton "Envoyer".

Voici le code en question :

function aqp_post(the_form)
{
        $('#aqp-icon').show();
        $('#quickpost form input').attr('disabled', 'disabled');
    
        var values = {
            form_sent: 1,
            form_user: the_form.form_user.value,
            req_message: the_form.req_message.value
        };
    
        $.post('post.php?tid=' + aqp_tid + '&lpid=' + aqp_last_post_id + '&pcount=' + aqp_post_count + '&ajax=1', values, function(data) 
            {
                if (data.indexOf('<div id="p') != -1)
                {
                    data = data.substring(data.indexOf('<div id="p')); // trim top crumbs
                    data = data.substring(0, data.indexOf('<div id="aqp">')); // posts end
                
                    $('#aqp').html(data);
                    document.getElementsByName('req_message')[0].value = '';
                }
                else
                    alert(data);
    
                
                $('#aqp-icon').hide();
                $('#quickpost form input').removeAttr('disabled');
            }
        );
        
        return false;
    }
}

J'ai essayé de bidouiller sa comme ceci :

function aqp_post(the_form)
{
    if($('#quickpost form input').attr('name') == 'submit')
    {
        $('#aqp-icon').show();
        $('#quickpost form input').attr('disabled', 'disabled');
    
        var values = {
            form_sent: 1,
            form_user: the_form.form_user.value,
            req_message: the_form.req_message.value
        };
    
        $.post('post.php?tid=' + aqp_tid + '&lpid=' + aqp_last_post_id + '&pcount=' + aqp_post_count + '&ajax=1', values, function(data) 
            {
                if (data.indexOf('<div id="p') != -1)
                {
                    data = data.substring(data.indexOf('<div id="p')); // trim top crumbs
                    data = data.substring(0, data.indexOf('<div id="aqp">')); // posts end
                
                    $('#aqp').html(data);
                    document.getElementsByName('req_message')[0].value = '';
                }
                else
                    alert(data);
    
                
                $('#aqp-icon').hide();
                $('#quickpost form input').removeAttr('disabled');
            }
        );
        
        return false;
    }
    else
        return true;
}

Mais cela ne fonctionne pas....
Quelqu'un peut il m'aider ?

Dans l'attente,
++

Dernière modification par barbuslex (26-04-2011 10:28:55)

Hors ligne

#2 26-04-2011 10:28:13

barbuslex
Membre

Re : [Résolu] Ajax quick post pour v1.4.5

C'est bon j'ai réussi.
Voici la solution pour ceux qui ont le même problème:

Dans header.php
Remplacer :

if (basename($_SERVER['PHP_SELF']) == 'viewtopic.php')
{
    $page_head['jquery'] = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>'."\n";
    echo = '<script type="text/javascript" src="'.$pun_config['o_base_url'].'/include/ajax_quick_post/aqp.js"></script>'."\n";
}

Par:

if (basename($_SERVER['PHP_SELF']) == 'viewtopic.php')
{
    $page_head['jquery'] = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>'."\n";
    $page_head['Quick post'] = '<script type="text/javascript" src="'.$pun_config['o_base_url'].'/include/ajax_quick_post/aqp.js"></script>'."\n";
}

Ensuite dans include/ajax_quick_post/aqp.js :
Remplacez tout par :

function aqp_post(the_form)
{
    if(nomBouton == "submit")
    {
        nomBouton = '';
        $('#aqp-icon').show();
        $('#quickpost form input').attr('disabled', 'disabled');
    
        var values = {};
        for (var i = 0; i < the_form.elements.length; i++)
        {
            var el = the_form.elements[i];
            if (el.name != 'undefined' && el.value != 'undefined' && el.name != 'preview')
                values[el.name] = el.value;
        }
    
        $.post('post.php?tid=' + aqp_tid + '&lpid=' + aqp_last_post_id + '&pcount=' + aqp_post_count + '&ajax=1', values, function(data) 
        {
            if (data.indexOf('<div id="p') != -1)
            {
                data = data.substring(data.indexOf('<div id="p')); // trim top crumbs
                data = data.substring(0, data.indexOf('<div id="aqp">')); // posts end
            
                $('#aqp').html(data);
                the_form['req_message'].value = '';
                if (the_form['req_username']) the_form['req_username'].value = '';
                if (the_form['req_email']) the_form['req_email'].value = '';
                if (the_form['email']) the_form['email'].value = '';
            }
            else
                alert(data);

            $('#aqp-icon').hide();
            $('#quickpost form input').removeAttr('disabled');
        });

        return false;
    }
    else
        return true;
}

$(function() {
    $("#quickpost form input").click(function() {
        nomBouton = $(this).attr("name");
    });
});

Désormais le bouton "Prévisualisation" de la réponse rapide fonctionne et affiche la prévisualisation (et ne post plus le message) et le ajax quick post fonctionne aussi lorsque l'on clique sur le bouton "Envoyer" dans la v1.4.5.

Voilou,

Hors ligne

Pied de page des forums