1 | |
---|
2 | function InicializarObjectoPositicion(){ |
---|
3 | var container = document.getElementById('container1'), |
---|
4 | element = document.getElementsByClassName('text')[0]; |
---|
5 | |
---|
6 | // options |
---|
7 | var options = { |
---|
8 | limit: container, |
---|
9 | setCursor: true |
---|
10 | }; |
---|
11 | |
---|
12 | // initialize drag |
---|
13 | $("#texto").hide(); |
---|
14 | new Draggable(element, options); |
---|
15 | |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | function NuevoObjectoInicial(){ |
---|
20 | $("#texto").hide(); |
---|
21 | var num = 0; |
---|
22 | $( ".text" ).draggable({ |
---|
23 | containment: '#container1', |
---|
24 | scroll: false, |
---|
25 | stop: function(event, ui) |
---|
26 | { |
---|
27 | |
---|
28 | num+= 1; |
---|
29 | if (num == 1){ |
---|
30 | $("#firma_visible #Formato_Visible .text").hide(); |
---|
31 | VALOR_X = 0; |
---|
32 | VALOR_Y = 0; |
---|
33 | }else{ |
---|
34 | VALOR_X = parseInt(ui.position['left']); |
---|
35 | VALOR_Y = parseInt(ui.position['top']); |
---|
36 | console.log(VALOR_X, VALOR_Y) |
---|
37 | } |
---|
38 | $('#id_pos_x').val(VALOR_X) |
---|
39 | $('#id_pos_y').val(VALOR_Y) |
---|
40 | $('#id_pag').val(__CURRENT_PAGE) |
---|
41 | }, |
---|
42 | |
---|
43 | }); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | var transferred = false; |
---|
48 | $('.text').draggable({ |
---|
49 | connectToSortable: "div#container1", |
---|
50 | helper: 'clone', |
---|
51 | start: function(event, ui) |
---|
52 | { |
---|
53 | $(this).hide(); |
---|
54 | }, |
---|
55 | stop: function(event, ui) |
---|
56 | { |
---|
57 | |
---|
58 | if(!transferred) { |
---|
59 | $(this).show(); |
---|
60 | } |
---|
61 | else{ |
---|
62 | |
---|
63 | $(this).remove(); |
---|
64 | transferred = false; |
---|
65 | } |
---|
66 | } |
---|
67 | }); |
---|
68 | |
---|
69 | |
---|
70 | $('div#container1').sortable({ |
---|
71 | connectWith: "div#container1", |
---|
72 | receive: function(event, ui) |
---|
73 | { |
---|
74 | transferred = true; |
---|
75 | $("#firmar-documento").removeAttr('disabled'); |
---|
76 | InicializarObjectoPositicion() |
---|
77 | NuevoObjectoInicial(); |
---|
78 | } |
---|
79 | }); |
---|