X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo%2Fbootstrap%2FDropTarget.js;fp=Roo%2Fbootstrap%2FDropTarget.js;h=5d85006fbf1c8a887b96773e30e60b567e1810fd;hp=0000000000000000000000000000000000000000;hb=267f6bc0ecf0897515863c3c91a8eea23388e273;hpb=4806a3a6a72a6fc861a138965a6b1b5df60d0c87 diff --git a/Roo/bootstrap/DropTarget.js b/Roo/bootstrap/DropTarget.js new file mode 100644 index 0000000000..5d85006fbf --- /dev/null +++ b/Roo/bootstrap/DropTarget.js @@ -0,0 +1,95 @@ +/* + * - LGPL + * + * dropable area + * + */ + +/** + * @class Roo.bootstrap.DropTarget + * @extends Roo.bootstrap.Element + * Bootstrap DropTarget class + + * @cfg {string} name dropable name + * + * @constructor + * Create a new Dropable Area + * @param {Object} config The config object + */ + +Roo.bootstrap.DropTarget = function(config){ + Roo.bootstrap.DropTarget.superclass.constructor.call(this, config); + + this.addEvents({ + // raw events + /** + * @event click + * When a element is chick + * @param {Roo.bootstrap.Element} this + * @param {Roo.EventObject} e + */ + "drop" : true + }); +}; + +Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, { + + + getAutoCreate : function(){ + + + }, + + initEvents: function() + { + Roo.bootstrap.DropTarget.superclass.initEvents.call(this); + this.dropZone = new Roo.dd.DropTarget(this.getEl(), { + ddGroup: this.name, + listeners : { + drop : this.dragDrop.createDelegate(this), + enter : this.dragEnter.createDelegate(this), + out : this.dragOut.createDelegate(this), + over : this.dragOver.createDelegate(this) + } + + }); + this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff + }, + + dragDrop : function(source,e,data) + { + // user has to decide how to impliment this. + Roo.log('drop'); + Roo.log(this); + //this.fireEvent('drop', this, source, e ,data); + return false; + }, + + dragEnter : function(n, dd, e, data) + { + // probably want to resize the element to match the dropped element.. + Roo.log("enter"); + this.originalSize = this.el.getSize(); + this.el.setSize( n.el.getSize()); + this.dropZone.DDM.refreshCache(this.name); + Roo.log([n, dd, e, data]); + }, + + dragOut : function(value) + { + // resize back to normal + Roo.log("out"); + this.el.setSize(this.originalSize); + this.dropZone.resetConstraints(); + }, + + dragOver : function() + { + // ??? do nothing? + } + +}); + + + + \ No newline at end of file