Created
January 9, 2013 13:27
-
-
Save charlycoste/4493101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( $ ) { | |
$.fn.show_hide = function(bloc1, bloc2, text1, text2, text3, u1, u2, u3, nodeId) { | |
return this.each(function(){ | |
var bouton = $(this); | |
var parent = $(bloc1); | |
var bloc = parent.find(bloc2); | |
// Cas où les details sont déjà affichés | |
if (bloc.length > 0) { | |
bouton.toggle(function(e){ | |
bloc.slideUp(); | |
jQuery.ez.setPreference( u1, u2 ); | |
bouton.text(text1); | |
e.preventDefault() | |
}, | |
function(e){ | |
bloc.slideDown(); | |
jQuery.ez.setPreference( u1, u3 ); | |
bouton.text(text2); | |
e.preventDefault() | |
}) | |
} else { // si les détails ne sont pas encore affichés | |
bouton.toggle(function(e){ | |
$(this).text(text3); | |
jQuery.get(jQuery.ez.url + 'run/content/view/details/'+ nodeId, function(data){bloc = $('<div />').appendTo(parent).hide().html(data).slideDown();bouton.text(text2);}); | |
jQuery.ez.setPreference( u1, u3 );e.preventDefault(); | |
}, | |
function(e){ | |
bloc.slideUp(); | |
jQuery.ez.setPreference( u1, u2 ); | |
bouton.text(text1); | |
e.preventDefault()}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment