summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/dd/DragSource.js
authorGiulio Cesare Solaroli <giulio.cesare@solaroli.it>2011-10-03 16:04:12 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@solaroli.it>2011-10-03 16:04:12 (UTC)
commit541bb378ddece2eab135a8066a16994e94436dea (patch) (side-by-side diff)
treeff160ea3e26f7fe07fcfd401387c5a0232ca715e /frontend/beta/js/YUI-extensions/dd/DragSource.js
parent1bf431fd3d45cbdf4afa3e12afefe5d24f4d3bc7 (diff)
parentecad5e895831337216544e81f1a467e0c68c4a6a (diff)
downloadclipperz-541bb378ddece2eab135a8066a16994e94436dea.zip
clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.gz
clipperz-541bb378ddece2eab135a8066a16994e94436dea.tar.bz2
Merge pull request #1 from gcsolaroli/master
First version of the restructured repository
Diffstat (limited to 'frontend/beta/js/YUI-extensions/dd/DragSource.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/YUI-extensions/dd/DragSource.js218
1 files changed, 218 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/dd/DragSource.js b/frontend/beta/js/YUI-extensions/dd/DragSource.js
new file mode 100644
index 0000000..efee2d6
--- a/dev/null
+++ b/frontend/beta/js/YUI-extensions/dd/DragSource.js
@@ -0,0 +1,218 @@
+// kill drag drop dependency
+if(YAHOO.util.DragDrop){
+
+YAHOO.ext.dd.DragSource = function(el, config){
+ this.el = getEl(el);
+ this.dragData = {};
+
+ YAHOO.ext.util.Config.apply(this, config);
+
+ if(!this.proxy){
+ this.proxy = new YAHOO.ext.dd.StatusProxy();
+ }
+ this.el.on('mouseup', this.handleMouseUp);
+ YAHOO.ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
+ {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
+
+ this.dragging = false;
+};
+
+YAHOO.extendX(YAHOO.ext.dd.DragSource, YAHOO.util.DDProxy, {
+ dropAllowed : 'ydd-drop-ok',
+ dropNotAllowed : 'ydd-drop-nodrop',
+
+ getDragData : function(e){
+ return this.dragData;
+ },
+
+ onDragEnter : function(e, id){
+ var target = YAHOO.util.DragDropMgr.getDDById(id);
+ this.cachedTarget = target;
+ if(this.beforeDragEnter(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ var status = target.notifyEnter(this, e, this.dragData);
+ this.proxy.setStatus(status);
+ }else{
+ this.proxy.setStatus(this.dropAllowed);
+ }
+
+ if(this.afterDragEnter){
+ this.afterDragEnter(target, e, id);
+ }
+ }
+ },
+
+ beforeDragEnter : function(target, e, id){
+ return true;
+ },
+
+ alignElWithMouse: function() {
+ YAHOO.ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
+ this.proxy.sync();
+ },
+
+ onDragOver : function(e, id){
+ var target = this.cachedTarget || YAHOO.util.DragDropMgr.getDDById(id);
+ if(this.beforeDragOver(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ var status = target.notifyOver(this, e, this.dragData);
+ this.proxy.setStatus(status);
+ }
+
+ if(this.afterDragOver){
+ this.afterDragOver(target, e, id);
+ }
+ }
+ },
+
+ beforeDragOver : function(target, e, id){
+ return true;
+ },
+
+ onDragOut : function(e, id){
+ var target = this.cachedTarget || YAHOO.util.DragDropMgr.getDDById(id);
+ if(this.beforeDragOut(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ target.notifyOut(this, e, this.dragData);
+ }
+ this.proxy.reset();
+ if(this.afterDragOut){
+ this.afterDragOut(target, e, id);
+ }
+ }
+ this.cachedTarget = null;
+ },
+
+ beforeDragOut : function(target, e, id){
+ return true;
+ },
+
+
+ onDragDrop : function(e, id){
+ var target = this.cachedTarget || YAHOO.util.DragDropMgr.getDDById(id);
+ if(this.beforeDragDrop(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ if(target.notifyDrop(this, e, this.dragData)){ // valid drop?
+ this.onValidDrop(target, e, id);
+ }else{
+ this.onInvalidDrop(target, e, id);
+ }
+ }else{
+ this.onValidDrop(target, e, id);
+ }
+
+ if(this.afterDragDrop){
+ this.afterDragDrop(target, e, id);
+ }
+ }
+ },
+
+ beforeDragDrop : function(target, e, id){
+ return true;
+ },
+
+ onValidDrop : function(target, e, id){
+ this.hideProxy();
+ },
+
+ getRepairXY : function(e, data){
+ return this.el.getXY();
+ },
+
+ onInvalidDrop : function(target, e, id){
+ this.beforeInvalidDrop(target, e, id);
+ if(this.cachedTarget){
+ if(this.cachedTarget.isNotifyTarget){
+ this.cachedTarget.notifyOut(this, e, this.dragData);
+ }
+ this.cacheTarget = null;
+ }
+ this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
+ if(this.afterInvalidDrop){
+ this.afterInvalidDrop(e, id);
+ }
+ },
+
+ afterRepair : function(){
+ this.el.highlight(this.hlColor || 'c3daf9');
+ this.dragging = false;
+ },
+
+ beforeInvalidDrop : function(target, e, id){
+ return true;
+ },
+
+ handleMouseDown : function(e){
+ if(this.dragging) {
+ return;
+ }
+ if(YAHOO.ext.QuickTips){
+ YAHOO.ext.QuickTips.disable();
+ }
+ var data = this.getDragData(e);
+ if(data && this.onBeforeDrag(data, e) !== false){
+ this.dragData = data;
+ this.proxy.stop();
+ YAHOO.ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
+ }
+ },
+
+ handleMouseUp : function(e){
+ if(YAHOO.ext.QuickTips){
+ YAHOO.ext.QuickTips.enable();
+ }
+ },
+
+ onBeforeDrag : function(data, e){
+ return true;
+ },
+
+ startDrag : function(e){
+ this.proxy.reset();
+ this.dragging = true;
+ this.proxy.update('');
+ this.onInitDrag(e);
+ this.proxy.show();
+ },
+
+ onInitDrag : function(e){
+ var clone = this.el.dom.cloneNode(true);
+ clone.id = YAHOO.util.Dom.generateId(); // prevent duplicate ids
+ this.proxy.update(clone);
+ return true;
+ },
+
+
+ getProxy : function(){
+ return this.proxy;
+ },
+
+ hideProxy : function(){
+ this.proxy.hide();
+ this.proxy.reset(true);
+ this.dragging = false;
+ },
+
+ triggerCacheRefresh : function(){
+ YAHOO.util.DDM.refreshCache(this.groups);
+ },
+
+ // override to prevent hiding
+ b4EndDrag: function(e) {
+ },
+
+ // override to prevent moving
+ endDrag : function(e){
+ this.onEndDrag(this.dragData, e);
+ },
+
+ onEndDrag : function(data, e){
+
+ },
+
+ // pin to cursor
+ autoOffset : function(x, y) {
+ this.setDelta(-12, -20);
+ }
+});
+}