|
@ -2,7 +2,7 @@ var Hammer = require('../../../module/hammer'); |
|
|
var Item = require('./Item'); |
|
|
var Item = require('./Item'); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @constructor ItemRange |
|
|
|
|
|
|
|
|
* @constructor RangeItem |
|
|
* @extends Item |
|
|
* @extends Item |
|
|
* @param {Object} data Object containing parameters start, end |
|
|
* @param {Object} data Object containing parameters start, end |
|
|
* content, className. |
|
|
* content, className. |
|
@ -11,7 +11,7 @@ var Item = require('./Item'); |
|
|
* @param {Object} [options] Configuration options |
|
|
* @param {Object} [options] Configuration options |
|
|
* // TODO: describe options
|
|
|
* // TODO: describe options
|
|
|
*/ |
|
|
*/ |
|
|
function ItemRange (data, conversion, options) { |
|
|
|
|
|
|
|
|
function RangeItem (data, conversion, options) { |
|
|
this.props = { |
|
|
this.props = { |
|
|
content: { |
|
|
content: { |
|
|
width: 0 |
|
|
width: 0 |
|
@ -32,16 +32,16 @@ function ItemRange (data, conversion, options) { |
|
|
Item.call(this, data, conversion, options); |
|
|
Item.call(this, data, conversion, options); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ItemRange.prototype = new Item (null, null, null); |
|
|
|
|
|
|
|
|
RangeItem.prototype = new Item (null, null, null); |
|
|
|
|
|
|
|
|
ItemRange.prototype.baseClassName = 'item range'; |
|
|
|
|
|
|
|
|
RangeItem.prototype.baseClassName = 'item range'; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Check whether this item is visible inside given range |
|
|
* Check whether this item is visible inside given range |
|
|
* @returns {{start: Number, end: Number}} range with a timestamp for start and end |
|
|
* @returns {{start: Number, end: Number}} range with a timestamp for start and end |
|
|
* @returns {boolean} True if visible |
|
|
* @returns {boolean} True if visible |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.isVisible = function(range) { |
|
|
|
|
|
|
|
|
RangeItem.prototype.isVisible = function(range) { |
|
|
// determine visibility
|
|
|
// determine visibility
|
|
|
return (this.data.start < range.end) && (this.data.end > range.start); |
|
|
return (this.data.start < range.end) && (this.data.end > range.start); |
|
|
}; |
|
|
}; |
|
@ -49,7 +49,7 @@ ItemRange.prototype.isVisible = function(range) { |
|
|
/** |
|
|
/** |
|
|
* Repaint the item |
|
|
* Repaint the item |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.redraw = function() { |
|
|
|
|
|
|
|
|
RangeItem.prototype.redraw = function() { |
|
|
var dom = this.dom; |
|
|
var dom = this.dom; |
|
|
if (!dom) { |
|
|
if (!dom) { |
|
|
// create DOM
|
|
|
// create DOM
|
|
@ -117,7 +117,7 @@ ItemRange.prototype.redraw = function() { |
|
|
* Show the item in the DOM (when not already visible). The items DOM will |
|
|
* Show the item in the DOM (when not already visible). The items DOM will |
|
|
* be created when needed. |
|
|
* be created when needed. |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.show = function() { |
|
|
|
|
|
|
|
|
RangeItem.prototype.show = function() { |
|
|
if (!this.displayed) { |
|
|
if (!this.displayed) { |
|
|
this.redraw(); |
|
|
this.redraw(); |
|
|
} |
|
|
} |
|
@ -127,7 +127,7 @@ ItemRange.prototype.show = function() { |
|
|
* Hide the item from the DOM (when visible) |
|
|
* Hide the item from the DOM (when visible) |
|
|
* @return {Boolean} changed |
|
|
* @return {Boolean} changed |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.hide = function() { |
|
|
|
|
|
|
|
|
RangeItem.prototype.hide = function() { |
|
|
if (this.displayed) { |
|
|
if (this.displayed) { |
|
|
var box = this.dom.box; |
|
|
var box = this.dom.box; |
|
|
|
|
|
|
|
@ -146,7 +146,7 @@ ItemRange.prototype.hide = function() { |
|
|
* Reposition the item horizontally |
|
|
* Reposition the item horizontally |
|
|
* @Override |
|
|
* @Override |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.repositionX = function() { |
|
|
|
|
|
|
|
|
RangeItem.prototype.repositionX = function() { |
|
|
var parentWidth = this.parent.width; |
|
|
var parentWidth = this.parent.width; |
|
|
var start = this.conversion.toScreen(this.data.start); |
|
|
var start = this.conversion.toScreen(this.data.start); |
|
|
var end = this.conversion.toScreen(this.data.end); |
|
|
var end = this.conversion.toScreen(this.data.end); |
|
@ -217,7 +217,7 @@ ItemRange.prototype.repositionX = function() { |
|
|
* Reposition the item vertically |
|
|
* Reposition the item vertically |
|
|
* @Override |
|
|
* @Override |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype.repositionY = function() { |
|
|
|
|
|
|
|
|
RangeItem.prototype.repositionY = function() { |
|
|
var orientation = this.options.orientation, |
|
|
var orientation = this.options.orientation, |
|
|
box = this.dom.box; |
|
|
box = this.dom.box; |
|
|
|
|
|
|
|
@ -233,7 +233,7 @@ ItemRange.prototype.repositionY = function() { |
|
|
* Repaint a drag area on the left side of the range when the range is selected |
|
|
* Repaint a drag area on the left side of the range when the range is selected |
|
|
* @protected |
|
|
* @protected |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype._repaintDragLeft = function () { |
|
|
|
|
|
|
|
|
RangeItem.prototype._repaintDragLeft = function () { |
|
|
if (this.selected && this.options.editable.updateTime && !this.dom.dragLeft) { |
|
|
if (this.selected && this.options.editable.updateTime && !this.dom.dragLeft) { |
|
|
// create and show drag area
|
|
|
// create and show drag area
|
|
|
var dragLeft = document.createElement('div'); |
|
|
var dragLeft = document.createElement('div'); |
|
@ -263,7 +263,7 @@ ItemRange.prototype._repaintDragLeft = function () { |
|
|
* Repaint a drag area on the right side of the range when the range is selected |
|
|
* Repaint a drag area on the right side of the range when the range is selected |
|
|
* @protected |
|
|
* @protected |
|
|
*/ |
|
|
*/ |
|
|
ItemRange.prototype._repaintDragRight = function () { |
|
|
|
|
|
|
|
|
RangeItem.prototype._repaintDragRight = function () { |
|
|
if (this.selected && this.options.editable.updateTime && !this.dom.dragRight) { |
|
|
if (this.selected && this.options.editable.updateTime && !this.dom.dragRight) { |
|
|
// create and show drag area
|
|
|
// create and show drag area
|
|
|
var dragRight = document.createElement('div'); |
|
|
var dragRight = document.createElement('div'); |
|
@ -289,4 +289,4 @@ ItemRange.prototype._repaintDragRight = function () { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = ItemRange; |
|
|
|
|
|
|
|
|
module.exports = RangeItem; |