function tplace-item droppable accept photo-item hoverClass report-hov

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$(function() {
$('.tplace-item').droppable({
accept: ".photo-item",
hoverClass: "report-hover",
tolerance: "pointer",
drop: function(ev, ui) {
var tplace = $(this);
var photo = $(ui.draggable);
var tplace_id = parseId(tplace.attr('class'));
var photo_id = parseId(photo.attr('class'));
args = {tplace_id: tplace_id, image_id: photo_id}
tplace.removeClass('no');
tplace.addClass('load');
var num_box = $('.num', tplace);
var number = num_box.text() ? parseInt(num_box.text()) : 0;
num_box.text(number + 1);
$.post('{% url image_to_deadline task.id dl.id %}', args, function(data) {
tplace.removeClass('load');
if (data.success) {
ui.draggable.hide();
tplace.addClass('photo-num');
$('.pdf-button').removeClass('b-gray').addClass('b-green');
$('.view-button').removeClass('b-gray').addClass('b-green');
} else {
alert(data.error);
}
});
}
});
$('.photo-item').draggable(draggable_config);
});
var draggable_config = {
helper: function(ev) {
var obj = $(ev.currentTarget);
var img = $('.image img', obj);
return $('<img width="50" height="50" src="' + img.attr('src') + '" />');
},
zIndex: 20,
cursorAt: {top: 0, left: 0}
/*
start: function(ev, ui) {
$('.review-photo').css('overflow-y', 'hidden');
//$(this).fadeTo(0, 0.5);
},
stop: function(ev, ui) {
$('.review-photo').css('overflow-y', 'auto');
//$(this).fadeTo(0, 1);
}
*/
}