Author: jmorliaguet Date: Sat Mar 25 22:19:00 2006 New Revision: 2728 Modified: cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/screens/editor.pt cpsskins/branches/jmo-perspectives/ui/screens/layoutdesigner/filters/portlet.pt cpsskins/branches/jmo-perspectives/ui/screens/pagedesigner/filters/portlet.pt Log:
- optimisations (moveEvent has a resolution of 1/10s) - elements can be moved on the canvas Modified: cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py (original) +++ cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py Sat Mar 25 22:19:00 2006 @@ -200,7 +200,7 @@ 'model': 'page-designer', 'perspectives': ['page-designer'], 'controllers': ['main-editor-perspectives', 'theme-switcher', - 'portlet-factory'], + 'portlet-factory', 'element-mover'], }, 'layout-designer': { @@ -211,7 +211,7 @@ 'model': 'layout-designer', 'perspectives': ['layout-designer'], 'controllers': ['main-editor-perspectives', 'theme-switcher', - 'portlet-factory'], + 'portlet-factory', 'element-mover'], }, 'interaction-designer': { @@ -231,7 +231,8 @@ }, 'model': 'content-author', 'perspectives': ['content-author'], - 'controllers': ['main-editor-perspectives', 'portlet-factory'], + 'controllers': ['main-editor-perspectives', 'portlet-factory', + 'element-mover'], }, # screen @@ -404,6 +405,28 @@ 'action': 'insert_portlet', }, }, + 'element-mover': { + 'id': 'element-mover', + 'type': 'drag-and-drop', + 'dragging': { + 'sources': ['.elementMovable'], + 'feedback': { + 'opacity': 0.8, + }, + 'zoomback': { + 'duration': 300, + } + }, + 'shifting': { + 'element': '.elementShiftable', + }, + 'dropping': { + 'highlight': { + 'duration': 800, + }, + 'action': 'move_element', + }, + }, 'menu-actions': { 'id': 'menu-actions', 'type': 'command', Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sat Mar 25 22:19:00 2006 @@ -30,7 +30,7 @@ } catch(e) { msg = e; } - $("message").innerHTML += msg + '<br/>'; + $("message").innerHTML += msg + '</br>'; } var CPSSkins = { @@ -702,6 +702,8 @@ // cancel text selection document.onmousedown = this.cancelEvent; document.onselectstart = this.cancelEvent; + + this._last_updated = 0; }, register: function(view) { @@ -734,13 +736,18 @@ }); }); - if (this.def.shifting) { - $$(this.def.shifting.element).each(function(el) { - if (el.childOf(widget)) shiftablezones.push(el); - }); - $$(this.def.shifting.container).each(function(el) { - if (el.childOf(widget)) containerzones.push(el); - }); + var shifting = this.def.shifting; + if (shifting) { + if (shifting.element) { + $$(shifting.element).each(function(el) { + if (el.childOf(widget)) shiftablezones.push(el); + }); + } + if (shifting.container) { + $$(shifting.container).each(function(el) { + if (el.childOf(widget)) containerzones.push(el); + }); + } } if (this.def.dropping) { (this.def.dropping.targets || []).each(function(d) { @@ -768,12 +775,13 @@ return speed; }, - _findNext: function(el, cls) { + _findNext: function(el) { + var shiftablezones = this._shiftablezones; while (el) { el = el.nextSibling; if (!el) return null; if (el.nodeType == 1) { - if (el.hasClassName(cls)) { + if (shiftablezones.indexOf(el) >= 0) { return el; } } @@ -859,29 +867,37 @@ var x = Event.pointerX(e); var y = Event.pointerY(e); this.moved.moveTo({'x': x-this.x1, 'y': y-this.y1}); + Event.stop(e); + + var now = new Date().getTime(); + if (now < this._last_updated + 100) return; + this._last_updated = now; var shifting = this.def.shifting; if (shifting) { + var shifted = false; + var speed = this._getVerticalSpeed(y); this._shiftablezones.each(function(s) { if (Position.within(s, x, y)) { - var speed = this._getVerticalSpeed(y); - if (Math.abs(speed) < 1) return; if (speed > 0) { - var target = this._findNext(s, shifting.element); + var target = this._findNext(s); } else { var target = s; } s.parentNode.insertBefore(this.dragged, target); + shifted = true; return; }; }.bind(this)); - this._containerzones.each(function(s) { - if (Position.within(s, x, y)) { - s.appendChild(this.dragged); - return; - }; - }.bind(this)); + if (!shifted) { + this._containerzones.each(function(s) { + if (Position.within(s, x, y)) { + s.appendChild(this.dragged); + return; + }; + }.bind(this)); + } } if (this.def.dragging.feedback) { @@ -891,7 +907,6 @@ 'width': dim.width + 'px', 'height': dim.height + 'px' }); } - Event.stop(e); }, dropEvent: function(e) { Modified: cpsskins/branches/jmo-perspectives/ui/screens/editor.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/editor.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/editor.pt Sat Mar 25 22:19:00 2006 @@ -49,6 +49,7 @@ <ins class="view" cite="@@getView?id=layout-designer"></ins> <ins class="model" cite="@@getModel?id=content-author"></ins> <ins class="view" cite="@@getView?id=content-author"></ins> + <ins class="controller" cite="@@getController?id=element-mover"></ins> </div> <!-- Contextual menu --> Modified: cpsskins/branches/jmo-perspectives/ui/screens/layoutdesigner/filters/portlet.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/layoutdesigner/filters/portlet.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/layoutdesigner/filters/portlet.pt Sat Mar 25 22:19:00 2006 @@ -1,4 +1,5 @@ -<div class="editable draggable hover" grip="1" destination="cellcontained" +<div class="editable draggable hover elementMovable elementShiftable" + grip="1" destination="cellcontained" tal:define=" info options/info; globals info/globals; Modified: cpsskins/branches/jmo-perspectives/ui/screens/pagedesigner/filters/portlet.pt ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/screens/pagedesigner/filters/portlet.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/screens/pagedesigner/filters/portlet.pt Sat Mar 25 22:19:00 2006 @@ -1,4 +1,5 @@ -<div class="editable draggable hover" grip="1" destination="cellcontained" +<div class="editable draggable hover elementMovable elementShiftable" + grip="1" destination="cellcontained" tal:define=" info options/info; globals info/globals; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins