port-in-ports.js (2651B)
1 function VPortInPorts(vPortsParente, vPortFille, modèle) { 2 var pip = $('#vue-port-in-ports').jqote({}).toDom(); 3 var ph1 = $('#vue-port-placeholder').jqote().toDom(); 4 var ph2 = $('#vue-port-placeholder').jqote().toDom(); 5 $.extend(this, pip.add(ph1).add(ph2)); 6 this.pip = pip; 7 this.ph1 = ph1; 8 this.ph2 = ph2; 9 10 vPortsParente.vPorts.append(this.ph1).append(this.pip).append(this.ph2); 11 12 this.pip.target = this.pip.find('.port-target'); 13 this.ph1.box = ph1.find('.port.placeholder.vBox'); 14 this.ph2.box = ph2.find('.port.placeholder.vBox'); 15 this.ph1.td = ph1.find('.port.placeholder.vTd'); 16 this.ph2.td = ph2.find('.port.placeholder.vTd'); 17 18 this.pip.target.append(vPortFille); 19 this.ph1.hide(); 20 this.ph2.hide(); 21 22 var a1 = ph1.box.stepAnimateClass('active', ''); 23 var a2 = ph2.box.stepAnimateClass('active', ''); 24 //var animProxy = function() {}; 25 var targetMiddle = 0; 26 var insertBefore = false; 27 var dragProxy = null; 28 29 var that = this; 30 var upOrDown = function(e) { 31 if (e.pageY < targetMiddle) { 32 insertBefore = true; 33 // Glow when we get close 34 var h1 = that.ph1.td.height() / 2; 35 var dist1 = e.pageY - that.ph1.box.offY() + (that.ph1.box.height() / 2); 36 var factor1 = Math.min(1, Math.abs(dist1 / h1)); 37 a1(Math.sqrt(factor1)); 38 //animProxy(Math.sqrt(factor1)); 39 // Hide and seek 40 that.ph1.show(); 41 that.ph2.hide(); 42 } else { 43 insertBefore = false; 44 // Glow when we get close 45 var h2 = that.ph2.td.height() / 2; 46 var dist2 = e.pageY - that.ph2.box.offY() + (that.ph2.box.height() / 2); 47 var factor2 = Math.min(1, Math.abs(dist2 / h2)); 48 a2(Math.sqrt(factor2)); 49 //animProxy(Math.sqrt(factor2)); 50 // Hide and seek 51 that.ph1.hide(); 52 that.ph2.show(); 53 } 54 }; 55 56 this.pip.target.bind('dropstart', function(e) { 57 targetMiddle = that.pip.target.offY() 58 + (that.pip.target.height() / 2); 59 /* dragProxy = e.dragProxy; 60 * animProxy = $(dragProxy).stepAnimateClass('active', ''); */ 61 $('body').bind('mousemove', upOrDown); 62 upOrDown(e); 63 }); 64 this.pip.target.bind('drop', function(e) { 65 e.dragTarget.droppedOn(modèle, 1); // il faut mettre la vraie position (utiliser insertBefore) 66 }); 67 this.pip.target.bind('dropend', function(e) { 68 that.ph1.hide(); 69 that.ph2.hide(); 70 $('body').unbind('mousemove', upOrDown); 71 }); 72 }