source: extensions/EasyCaptcha/template/drag.js @ 26025

Last change on this file since 26025 was 26025, checked in by mistic100, 10 years ago

update for 2.6

File size: 1.5 KB
Line 
1(function($){
2
3$.drop({ mode:true });
4Math.bounds = function(a, b, c) { return Math.max(a, Math.min(b, c)); }
5
6var $easycaptcha = $('#easycaptcha').show();
7
8$easycaptcha.find('.drag_item')
9  .each(function() {
10      $(this).data({
11          origTop: $(this).css('top'),
12          origLeft: $(this).css('left'),
13      });
14  })
15  .drag('start', function(e, dd) {
16      $(this).addClass('active');
17
18      dd.limit = {
19          top: 0,
20          left: 0,
21          bottom: $easycaptcha.outerHeight() - $(this).outerHeight(),
22          right: $easycaptcha.outerWidth() - $(this).outerWidth()
23      };
24
25      $('.drag_item').not(this).each(function() {
26          $(this).animate({
27              top: $(this).data('origTop'),
28              left: $(this).data('origLeft')
29          });
30      });
31
32      $('input[name="easycaptcha"]').val('');
33      $easycaptcha.find('.drop_zone').removeClass('valid');
34  })
35  .drag(function(e, dd) {
36      $(this).css({
37          top: Math.bounds(dd.limit.top, dd.offsetY - $easycaptcha.offset().top, dd.limit.bottom),
38          left: Math.bounds(dd.limit.left, dd.offsetX - $easycaptcha.offset().left, dd.limit.right)
39      });
40  })
41  .drag('end', function() {
42      $(this).removeClass('active');
43  });
44
45$easycaptcha.find('.drop_zone')
46  .drop('start', function() {
47      $(this).addClass('active');
48  })
49  .drop(function(e, dd) {
50      $('input[name="easycaptcha"]').val($(dd.drag).data('id'));
51      $(this).addClass('valid');
52  })
53  .drop('end', function() {
54      $(this).removeClass('active');
55  });
56
57}(jQuery));
Note: See TracBrowser for help on using the repository browser.