f792d24_jconfirmaction.jquery_9.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * jQuery Plugin : jConfirmAction
  3. *
  4. * by Hidayat Sagita, modified by Sevajol Bastien (http://blog.bux.fr/tag/jconfirmaction/)
  5. * http://www.webstuffshare.com
  6. * Licensed Under GPL version 2 license.
  7. *
  8. */
  9. (function($){
  10. jQuery.fn.jConfirmAction = function (options) {
  11. // Some jConfirmAction options (limited to customize language) :
  12. // question : a text for your question.
  13. // yesAnswer : a text for Yes answer.
  14. // cancelAnswer : a text for Cancel/No answer.
  15. var theOptions = jQuery.extend ({
  16. question: "Are You Sure ?",
  17. yesAnswer: "Yes",
  18. cancelAnswer: "Cancel",
  19. onYes: function(){},
  20. onOpen: function(){},
  21. onClose: function(){},
  22. justOneAtTime: true
  23. }, options);
  24. $(this).live('click', function(e) {
  25. if (theOptions.justOneAtTime)
  26. {
  27. $('div.question').remove();
  28. }
  29. theOptions.onOpen($(this));
  30. e.preventDefault();
  31. if($(this).next('.question').length <= 0)
  32. $(this).after(
  33. '<div class="question">'+theOptions.question
  34. +'<br/> <span class="yes">'+theOptions.yesAnswer
  35. +'</span><span class="cancel">'+theOptions.cancelAnswer
  36. +'</span></div>'
  37. );
  38. $(this).next('.question').animate({opacity: 1}, 300);
  39. $(this).next('.question').find('.yes').bind('click', function(){
  40. theOptions.onYes($(this).parents('div.question').prev('a'));
  41. });
  42. $(this).next('.question').find('.cancel').bind('click', function(){
  43. $(this).parents('.question').fadeOut(300, function() {
  44. theOptions.onClose($(this).parents('div.question').prev('a'));
  45. });
  46. });
  47. });
  48. }
  49. })(jQuery);