Browse Source

Modifs du plugin jconfirmaction.jquery.js (clean).

bastien 13 years ago
parent
commit
35d7ee8338
1 changed files with 18 additions and 15 deletions
  1. 18 15
      web/js/jConfirmAction/jconfirmaction.jquery.js

+ 18 - 15
web/js/jConfirmAction/jconfirmaction.jquery.js View File

1
 /*
1
 /*
2
  * jQuery Plugin : jConfirmAction
2
  * jQuery Plugin : jConfirmAction
3
  * 
3
  * 
4
- * by Hidayat Sagita
4
+ * by Hidayat Sagita, modified by Sevajol Bastien (http://blog.bux.fr/tag/jconfirmaction/)
5
  * http://www.webstuffshare.com
5
  * http://www.webstuffshare.com
6
  * Licensed Under GPL version 2 license.
6
  * Licensed Under GPL version 2 license.
7
  *
7
  *
20
 			cancelAnswer: "Cancel",
20
 			cancelAnswer: "Cancel",
21
       onYes: function(){},
21
       onYes: function(){},
22
       onOpen: function(){},
22
       onOpen: function(){},
23
-      onClose: function(){}
23
+      onClose: function(){},
24
+      justOneAtTime: true
24
 		}, options);
25
 		}, options);
25
 					
26
 					
26
 			$(this).live('click', function(e) {
27
 			$(this).live('click', function(e) {
27
 
28
 
28
-        $('div.question').remove();
29
+        if (theOptions.justOneAtTime)
30
+        {
31
+          $('div.question').remove();
32
+        }
29
 
33
 
30
-        link = $(this);
31
-        options.onOpen(link);
34
+        theOptions.onOpen($(this));
32
 
35
 
33
 				e.preventDefault();
36
 				e.preventDefault();
34
-				thisHref	= $(this).attr('href');
35
 				
37
 				
36
 				if($(this).next('.question').length <= 0)
38
 				if($(this).next('.question').length <= 0)
37
-					$(this).after('<div class="question">'+theOptions.question
38
-          +'<br/> <span class="yes">'+theOptions.yesAnswer
39
-          +'</span><span class="cancel">'+theOptions.cancelAnswer
40
-          +'</span></div>');
39
+					$(this).after(
40
+            '<div class="question">'+theOptions.question
41
+            +'<br/> <span class="yes">'+theOptions.yesAnswer
42
+            +'</span><span class="cancel">'+theOptions.cancelAnswer
43
+            +'</span></div>'
44
+          );
41
 				
45
 				
42
 				$(this).next('.question').animate({opacity: 1}, 300);
46
 				$(this).next('.question').animate({opacity: 1}, 300);
43
 				
47
 				
44
-				$('.yes').bind('click', function(){
45
-					options.onYes(link);
48
+				$(this).next('.question').find('.yes').bind('click', function(){
49
+					theOptions.onYes($(this).parents('div.question').prev('a'));
46
 				});
50
 				});
47
 		
51
 		
48
-				$('.cancel').bind('click', function(){
52
+				$(this).next('.question').find('.cancel').bind('click', function(){
49
 					$(this).parents('.question').fadeOut(300, function() {
53
 					$(this).parents('.question').fadeOut(300, function() {
50
-            options.onClose(link);
51
-						$(this).remove();
54
+            theOptions.onClose($(this).parents('div.question').prev('a'));
52
 					});
55
 					});
53
 				});
56
 				});
54
 				
57