Author: jmorliaguet Date: Fri May 26 23:40:59 2006 New Revision: 3232 Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js
Log: - cosmetic Modified: cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js ============================================================================== --- cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js (original) +++ cpsskins/branches/paris-sprint-2006/lib/cpsskins/src/cpsskins.js Fri May 26 23:40:59 2006 @@ -34,7 +34,7 @@ } var CPSSkins = { - Version: "0.8", + Version: "0.9", Controllers: $H({}), Effects: $H({}), @@ -637,7 +637,7 @@ Event.stopObserving(view.widget, "submit", this.submitEvent); }, - refreshViews: function() { + refreshViews: function() { this.views.entries().each(function(v) { CPSSkins.getViewById(v).refresh(); }); @@ -901,9 +901,9 @@ var dim = draggable.getDimensions(); var feedback = CPSSkins.Canvas.createNode({tag: 'div'}); feedback.setStyle({ - 'z-index': parseInt(draggable.getStyle('z-index') || 0) +1, - 'width': dim.width + 'px', - 'height': dim.height + 'px' + zIndex: parseInt(draggable.getStyle('z-index') || 0) +1, + width: dim.width + 'px', + height: dim.height + 'px' }); if (this.def.dragging.feedback.clone) { var clone = $(draggable.cloneNode(true)); @@ -911,10 +911,10 @@ feedback.appendChild(clone); } else { feedback.setStyle({ - 'border-color': this.def.dragging.feedback.border || '#000', - 'background-color': this.def.dragging.feedback.background || '#fc3', - 'border-style': 'solid', - 'border-width': '1px' + borderColor: this.def.dragging.feedback.border || '#000', + backgroundColor: this.def.dragging.feedback.background || '#fc3', + borderStyle: 'solid', + borderWidth: '1px' }) } feedback.setOpacity(this.def.dragging.feedback.opacity); @@ -952,21 +952,19 @@ var startDragY = this.startDragY; if (startDragX != null && startDragY != null) { - if (Math.abs(startDragX-x) < 1 || Math.abs(startDragY-y) < 1) { - Event.stop(e); + if (Math.abs(startDragX-x) < 10 && Math.abs(startDragY-y) < 10) { return false; } else { + Event.stop(e); this.startDrag(x, y); this.startDragX = null; this.startDragY = null; } } - var moved = $(this.moved); + var moved = this.moved; moved.moveTo({x: x-this.x1, y: y-this.y1, fit: true}); - Event.stop(e); - var now = new Date().getTime(); if (now < this._last_updated + 100) return; this._last_updated = now; @@ -1003,7 +1001,7 @@ if (this.target) var dim = this.target.getDimensions(); this.moved.setStyle({ - 'width': dim.width + 'px', 'height': dim.height + 'px' + width: dim.width + 'px', height: dim.height + 'px' }); } }, @@ -1012,6 +1010,10 @@ Event.stopObserving(document, "mousemove", this.moveEvent); Event.stopObserving(document, "mouseup", this.dropEvent); + if (!this.dragged) return; + + var moved = this.moved; + var dragged = this.dragged; var x = Event.pointerX(e); var y = Event.pointerY(e); @@ -1032,24 +1034,25 @@ } var dropping = this.def.dropping; - if (dropping && this.dragged) { + if (dropping && dragged) { var action_id = dropping.action; if (action_id) { var action_handler = CPSSkins.getAction(action_id); if (action_handler) action_handler({ - 'source': this.dragged, - 'target': this.droptarget || this.target, - 'context': this + source: dragged, + target: this.droptarget || this.target, + context: this }); } } if (this.def.dragging.feedback) { - if (zoomback && this.moved) { - this.moved.moveTo({ - 'x': this.x0, - 'y': this.y0, - 'duration': zoomback.duration || 400, + if (zoomback && moved) { + moved.moveTo({ + x: this.x0, + y: this.y0, + duration: zoomback.duration || 400, + onComplete: function() {moved.parentNode.removeChild(moved)} }); } } @@ -1066,26 +1069,22 @@ var zoomto = this.def.dropping.zoomto; if (zoomto) { var pos = Position.cumulativeOffset(this.target); - this.moved.moveTo({ + moved.moveTo({ x: pos[0], y: pos[1], duration: zoomto.duration || 400, - onComplete: function() { this.parentNode.removeChild(this); } + onComplete: function() { moved.parentNode.removeChild(moved); } }); } } - if (this.def.dragging.feedback && !zoomback && !zoomto && this.moved) { - var parent = this.moved.parentNode; - if (parent) { - parent.removeChild(this.moved); - } + if (this.def.dragging.feedback && !zoomback && !zoomto && moved) { + moved.parentNode.removeChild(moved); } - if (this.moved) this.moved.setStyle({cursor: ''}); - - if (this.dragged) this.dragged.setOpacity(1); - Event.stop(e); + if (moved) moved.setStyle({cursor: ''}); + if (dragged) dragged.setOpacity(1); + this.dragged = null; } }); @@ -1321,8 +1320,8 @@ new CPSSkins.Scheduler(Object.extend(options, { action: function(value) { element.setStyle({ - 'left': x0 + (x - x0) * value + 'px', - 'top': y0 + (y - y0) * value + 'px' + left: x0 + (x - x0) * value + 'px', + top: y0 + (y - y0) * value + 'px' }); }, onComplete: (options.onComplete || function() {}).bind(element) @@ -2283,11 +2282,8 @@ var icon = disabled ? "noicon.png": (item.icon || "noicon.png"); a.appendChild(createNode({ - tag: "img", - attributes: { - "src": icon, - "alt": "*" - } + tag: 'img', + attributes: {src: icon, alt: '*'} })); container.appendChild(a); @@ -2313,11 +2309,8 @@ var icon = disabled ? "noicon.png": (item.icon || "noicon.png"); a.appendChild(createNode({ - tag: "img", - attributes: { - "src": icon, - "alt": "*" - } + tag: 'img', + attributes: {src: icon, alt: '*'} })); container.appendChild(a); @@ -2328,8 +2321,8 @@ case "separator": { var node = createNode({ - tag: "div", - classes: "separator" + tag: 'div', + classes: 'separator' }); container.appendChild(node); break; @@ -2391,6 +2384,7 @@ /* Event handlers */ showEvent: function(e) { + if (Event.isLeftClick(e)) return; if (this.wait) return; var element = Event.element(e); var selected = CPSSkins.Identifiable.getIdentifiable(element); @@ -2419,6 +2413,7 @@ }, callEvent: function(e) { + Event.stop(e); var element = Event.element(e); if (element.getAttribute("disabled")) return; var action = element.getAttribute("action"); @@ -2437,7 +2432,6 @@ options: {action: action, choice: choice} } CPSSkins.notify("command", info); - Event.stop(e); this.wait = true; }, -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins