Advertisement
Guest User

Untitled

a guest
May 13th, 2010
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * jQuery Plugin : jConfirmAction
  3. *
  4. * by Hidayat Sagita
  5. * http://www.webstuffshare.com
  6. * Licensed Under GPL version 2 license.
  7. *
  8. * callback added by Manuel Joao Silva
  9. *
  10. */
  11. (function($){
  12.  
  13.     jQuery.fn.jConfirmAction = function (options, callback) {
  14.  
  15.         // Some jConfirmAction options (limited to customize language) :
  16.         // question : a text for your question.
  17.         // yesAnswer : a text for Yes answer.
  18.         // cancelAnswer : a text for Cancel/No answer.
  19.         var theOptions = jQuery.extend ({
  20.             question: "Are You Sure ?",
  21.             yesAnswer: "Yes",
  22.             cancelAnswer: "Cancel"
  23.         }, options);
  24.  
  25.        
  26.         return this.each (function () {
  27.  
  28.             $(this).bind('click', function(e) {
  29.                
  30.                 e.preventDefault();
  31.  
  32.                 if($(this).next('.question').length <= 0)
  33.                 {
  34.                     $(this).after('<div class="jConfirmAction_question">'+theOptions.question+'<br/> <span class="jConfirmAction_yes">'+theOptions.yesAnswer+'</span><span class="jConfirmAction_cancel">'+theOptions.cancelAnswer+'</span></div>');
  35.                 }
  36.  
  37.                 $(this).next('.jConfirmAction_question').animate({opacity: 1}, 300);
  38.  
  39.                 $('.jConfirmAction_yes').bind('click', jQuery.proxy(callback, this));
  40.                
  41.                 $('.jConfirmAction_yes').bind('click',function(){
  42.                     $(this).parents('.jConfirmAction_question').fadeOut(300, function() {
  43.                         $(this).remove();
  44.                     });
  45.                 });
  46.                
  47.                 $('.jConfirmAction_cancel').bind('click', function(){
  48.                     $(this).parents('.jConfirmAction_question').fadeOut(300, function() {
  49.                         $(this).remove();
  50.                     });
  51.                 });
  52.  
  53.             });
  54.  
  55.         });
  56.     }
  57.  
  58. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement