X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-ui-debug.js;h=88b86114a5b961c4520389bea6dee6d4254cabd7;hb=refs%2Fheads%2Fgithub.com.roojs1.master;hp=080b7d96ac1795e8c0af8cc9aca858e16410c7db;hpb=335c8c4c7d1493021efef08f6d2a8004ef17735a;p=roojs1 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index 080b7d96ac..88b86114a5 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -26,6 +26,7 @@ var Dom=Roo.lib.Dom; /** * @class Roo.dd.DragDrop + * @extends Roo.util.Observable * Defines the interface and base operation of items that that can be * dragged or can be drop targets. It was designed to be extended, overriding * the event handlers for startDrag, onDrag, onDragOver and onDragOut. @@ -72,9 +73,10 @@ Roo.dd.DragDrop = function(id, sGroup, config) { if (id) { this.init(id, sGroup, config); } + }; -Roo.dd.DragDrop.prototype = { +Roo.extend(Roo.dd.DragDrop, Roo.util.Observable , { /** * The id of the element associated with this object. This is what we @@ -1157,7 +1159,7 @@ Roo.dd.DragDrop.prototype = { return ("DragDrop " + this.id); } -}; +}); })(); /* @@ -3000,6 +3002,12 @@ Roo.dd.DDTarget = function(id, sGroup, config) { if (id) { this.initTarget(id, sGroup, config); } + if (config.listeners || config.events) { + Roo.dd.DragDrop.superclass.constructor.call(this, { + listeners : config.listeners || {}, + events : config.events || {} + }); + } }; // Roo.dd.DDTarget.prototype = new Roo.dd.DragDrop(); @@ -3884,14 +3892,87 @@ Roo.extend(Roo.dd.DragSource, Roo.dd.DDProxy, { Roo.dd.DropTarget = function(el, config){ this.el = Roo.get(el); + var listeners = false; ; + if (config && config.listeners) { + listeners= config.listeners; + delete config.listeners; + } Roo.apply(this, config); if(this.containerScroll){ Roo.dd.ScrollManager.register(this.el); } - - Roo.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group, - {isTarget: true}); + this.addEvents( { + /** + * @scope Roo.dd.DropTarget + */ + + /** + * @event enter + * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the + * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element + * and returns the dropAllowed config value. This method should be overridden if drop validation is required. + * + * IMPORTANT : it should set this.overClass and this.dropAllowed + * + * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target + * @param {Event} e The event + * @param {Object} data An object containing arbitrary data supplied by the drag source + */ + "enter" : true, + + /** + * @event over + * The function a {@link Roo.dd.DragSource} calls continuously while it is being dragged over the target. + * This method will be called on every mouse movement while the drag source is over the drop target. + * This default implementation simply returns the dropAllowed config value. + * + * IMPORTANT : it should set this.dropAllowed + * + * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target + * @param {Event} e The event + * @param {Object} data An object containing arbitrary data supplied by the drag source + + */ + "over" : true, + /** + * @event out + * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source has been dragged + * out of the target without dropping. This default implementation simply removes the CSS class specified by + * overClass (if any) from the drop element. + * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target + * @param {Event} e The event + * @param {Object} data An object containing arbitrary data supplied by the drag source + */ + "out" : true, + + /** + * @event drop + * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the dragged item has + * been dropped on it. This method has no default implementation and returns false, so you must provide an + * implementation that does something to process the drop event and returns true so that the drag source's + * repair action does not run. + * + * IMPORTANT : it should set this.success + * + * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target + * @param {Event} e The event + * @param {Object} data An object containing arbitrary data supplied by the drag source + */ + "drop" : true + }); + + + Roo.dd.DropTarget.superclass.constructor.call( this, + this.el.dom, + this.ddGroup || this.group, + { + isTarget: true, + listeners : listeners || {} + + + } + ); }; @@ -3900,6 +3981,11 @@ Roo.extend(Roo.dd.DropTarget, Roo.dd.DDTarget, { * @cfg {String} overClass * The CSS class applied to the drop target element while the drag source is over it (defaults to ""). */ + /** + * @cfg {String} ddGroup + * The drag drop group to handle drop events for + */ + /** * @cfg {String} dropAllowed * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok"). @@ -3910,70 +3996,68 @@ Roo.extend(Roo.dd.DropTarget, Roo.dd.DDTarget, { * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop"). */ dropNotAllowed : "x-dd-drop-nodrop", - + /** + * @cfg {boolean} success + * set this after drop listener.. + */ + success : false, + /** + * @cfg {boolean|String} valid true/false or string (ok-add/ok-sub/ok/nodrop) + * if the drop point is valid for over/enter.. + */ + valid : false, // private isTarget : true, // private isNotifyTarget : true, - + /** - * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the - * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element - * and returns the dropAllowed config value. This method should be overridden if drop validation is required. - * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target - * @param {Event} e The event - * @param {Object} data An object containing arbitrary data supplied by the drag source - * @return {String} status The CSS class that communicates the drop status back to the source so that the - * underlying {@link Roo.dd.StatusProxy} can be updated + * @hide */ - notifyEnter : function(dd, e, data){ + notifyEnter : function(dd, e, data) + { + this.valid = true; + this.fireEvent('enter', dd, e, data); if(this.overClass){ this.el.addClass(this.overClass); } - return this.dropAllowed; + return typeof(this.valid) == 'string' ? 'x-dd-drop-' + this.valid : ( + this.valid ? this.dropAllowed : this.dropNotAllowed + ); }, /** - * The function a {@link Roo.dd.DragSource} calls continuously while it is being dragged over the target. - * This method will be called on every mouse movement while the drag source is over the drop target. - * This default implementation simply returns the dropAllowed config value. - * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target - * @param {Event} e The event - * @param {Object} data An object containing arbitrary data supplied by the drag source - * @return {String} status The CSS class that communicates the drop status back to the source so that the - * underlying {@link Roo.dd.StatusProxy} can be updated + * @hide */ - notifyOver : function(dd, e, data){ - return this.dropAllowed; + notifyOver : function(dd, e, data) + { + this.valid = true; + this.fireEvent('over', dd, e, data); + return typeof(this.valid) == 'string' ? 'x-dd-drop-' + this.valid : ( + this.valid ? this.dropAllowed : this.dropNotAllowed + ); }, /** - * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source has been dragged - * out of the target without dropping. This default implementation simply removes the CSS class specified by - * overClass (if any) from the drop element. - * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target - * @param {Event} e The event - * @param {Object} data An object containing arbitrary data supplied by the drag source + * @hide */ - notifyOut : function(dd, e, data){ + notifyOut : function(dd, e, data) + { + this.fireEvent('out', dd, e, data); if(this.overClass){ this.el.removeClass(this.overClass); } }, /** - * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the dragged item has - * been dropped on it. This method has no default implementation and returns false, so you must provide an - * implementation that does something to process the drop event and returns true so that the drag source's - * repair action does not run. - * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target - * @param {Event} e The event - * @param {Object} data An object containing arbitrary data supplied by the drag source - * @return {Boolean} True if the drop was valid, else false + * @hide */ - notifyDrop : function(dd, e, data){ - return false; + notifyDrop : function(dd, e, data) + { + this.success = false; + this.fireEvent('drop', dd, e, data); + return this.success; } });/* * Based on: @@ -13836,16 +13920,24 @@ Roo.extend(Roo.Editor, Roo.Component, { } }, - onSpecialKey : function(field, e){ + onSpecialKey : function(field, e) + { //Roo.log('editor onSpecialKey'); if(this.completeOnEnter && e.getKey() == e.ENTER){ e.stopEvent(); this.completeEdit(); - }else if(this.cancelOnEsc && e.getKey() == e.ESC){ - this.cancelEdit(); - }else{ - this.fireEvent('specialkey', field, e); + return; + } + // do not fire special key otherwise it might hide close the editor... + if(e.getKey() == e.ENTER){ + return; } + if(this.cancelOnEsc && e.getKey() == e.ESC){ + this.cancelEdit(); + return; + } + this.fireEvent('specialkey', field, e); + }, /** @@ -15195,7 +15287,8 @@ Roo.LayoutDialog = function(el, cfg){ config = Roo.apply({}, el); // not sure why we use documentElement here.. - it should always be body. // IE7 borks horribly if we use documentElement. - el = Roo.get( Roo.isIE ? (document.body || document.documentElement) : (document.documentElement || document.body) ).createChild(); + // webkit also does not like documentElement - it creates a body element... + el = Roo.get( document.body || document.documentElement ).createChild(); //config.autoCreate = true; } @@ -21868,4 +21961,15529 @@ Roo.form.TwinTriggerField = Roo.extend(Roo.form.TriggerField, { onTrigger1Click : Roo.emptyFn, onTrigger2Click : Roo.emptyFn -}); \ No newline at end of file +});/* + * Based on: + * Ext JS Library 1.1.1 + * Copyright(c) 2006-2007, Ext JS, LLC. + * + * Originally Released Under LGPL - original licence link has changed is not relivant. + * + * Fork - LGPL + *