js/datetime/timesheet/timesheet.js in rsence-pre-2.2.0.22 vs js/datetime/timesheet/timesheet.js in rsence-pre-2.2.0.23

- old
+ new

@@ -44,10 +44,12 @@ itemOffsetLeft: 64, // Theme settings; don't enter in options itemOffsetRight: 0, // Theme settings; don't enter in options itemOffsetTop: 20, // Theme settings; don't enter in options itemOffsetBottom: 0, // Theme settings; don't enter in options itemDisplayTime: true, + allowClickCreate: false, + minDragSize: 5, // minimum amount of pixels dragged required for accepting a drag hourOffsetTop: -4, // Theme settings; don't enter in options constructor: function( _ctrl ){ if( this.defaultLabel === undefined ){ this.defaultLabel = _ctrl.localeStrings.newItemLabel; } @@ -290,10 +292,11 @@ this.dragPreview.refreshValue(); }, // drag & drop event listeners, used for dragging new timesheet items startDrag: function( x, y, b ){ + this._startDragY = y; this.startDragTime = this.pxToTime( y-this.pageY() ); this.refreshDragPreview( this.startDragTime, this.startDragTime + this.minDuration ); this.dragPreview.bringToFront(); this.dragPreview.show(); return true; @@ -316,20 +319,24 @@ return true; }, endDrag: function( x, y, b ){ var - _dragTime = this.pxToTime( y-this.pageY() ); - if( _dragTime !== this.startDragTime ){ + _dragTime = this.pxToTime( y-this.pageY() ), + _minDistanceSatisfied = Math.abs( this._startDragY - y ) >= this.options.minDragSize; + if( this.options.allowClickCreate ){ + _minDistanceSatisfied = true; + } + this.dragPreview.hide(); + if( _dragTime !== this.startDragTime && _minDistanceSatisfied ){ if( this.activateEditor( this.dragPreview ) ){ this.editor.createItem( HVM.clone( this.dragPreview.value ) ); return true; } + this.clickCreated = false; + this.startDragTime = false; + this.click( x, y, b ); } - this.clickCreated = false; - this.dragPreview.hide(); - this.startDragTime = false; - this.click( x, y, b ); return false; }, // a resize triggers refresh, of which the important part is refreshValue, which triggers redraw of the time sheet items resize: function(){