1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
/**
####################
#v 1.2
#01/09/2011
<a class='goXhrLink' href='' data-divdest='' data-godiv='' data-notymsg=''></a>
####################
**/
$('.goXhrLink').live("click", function ()
{
if (typeof ($(this).data('confirm')) != 'undefined' && !confirm($(this).data('confirm'))) return false;
var data_type = (typeof ($(this).data('datatype')) == 'undefined') ? 'text' : $(this).data('datatype');
//writeInConsole("Lien XHR JQ : lien => " + $(this).attr('href') + " div => " + div);
//------------------
var objTXT = {
godiv: $(this).data('godiv'),
divdest: $(this).data('divdest'),
deldiv: $(this).data('deldiv'),
reload: $(this).data('reload'),
closebox: $(this).data('closebox'),
notymsg: $(this).data('notymsg'),
notytype: $(this).data('notytype'),
lienxhr: $(this).data('lienxhr'),
lienxhrdiv: $(this).data('lienxhrdiv'),
insertappend: $(this).data('insertappend'),
}
$.ajax(
{
type: (typeof ($(this).data('methode')) != 'undefined') ? $(this).data('methode') : 'GET',
url: $(this).attr('href'),
cache: false,
success: function (objJSON)
{
obj = (data_type == 'text') ? objTXT : objJSON;
if (data_type == 'text')
{
if (typeof (objTXT.insertappend) != 'undefined')
{
$("#" + obj.divdest).append(objJSON);
}
else
{
$("#" + obj.divdest).html(objJSON);
}
}
$(document).ready(function ()
{
if (typeof (objTXT.godiv) != 'undefined' && document.getElementById(objTXT.godiv))
{
$('html,body').animate(
{
scrollTop: $("#" + objTXT.godiv).offset().top
}, 'fast');
}
if (typeof (obj.notymsg) != 'undefined' && obj.notymsg != '')
{
noty(
{
'text': obj.notymsg,
'layout': (typeof (obj.notylayout) != 'undefined') ? 'top' : obj.notylayout,
'type': (typeof (obj.notytype) != 'undefined') ? 'info' : obj.notytype,
'animateOpen': {
'height': 'toggle'
},
'animateClose': {
'height': 'toggle'
},
'speed': (typeof (obj.notyspeed) != 'undefined') ? 250 : obj.notyspeed,
'timeout': (typeof (obj.notytimeout) != 'undefined') ? 2000 : obj.notytimeout,
'closeButton': true,
'closeOnSelfClick': true,
'closeOnSelfOver': false,
'modal': false,
'buttons': false,
'onClose': function ()
{}
});
}
if (typeof (obj.lienxhr) != 'undefined' && typeof (obj.lienxhrdiv) != 'undefined') lienXHR(obj.lienxhr, obj.lienxhrdiv);
if (typeof (obj.closebox) != 'undefined')(parent.window['jQueryACB'] || parent.window['jQuery']).colorbox.close();
if (typeof (obj.reload) != 'undefined') document.location.reload(true);
if (typeof (obj.deldiv) != 'undefined') document.getElementById(obj.deldiv).innerHTML = '';
});
},
error: function (XMLHttpRequest, textStatus, errorThrows)
{ // erreur durant la requete
},
dataType: data_type
});
//--------------
return false;
}) |