Browse Source

Renamed all functions `repaint` to `redraw`

css_transitions
jos 10 years ago
parent
commit
a5025b9673
13 changed files with 56 additions and 56 deletions
  1. +5
    -5
      src/timeline/Timeline.js
  2. +2
    -2
      src/timeline/component/Component.js
  3. +2
    -2
      src/timeline/component/CurrentTime.js
  4. +2
    -2
      src/timeline/component/CustomTime.js
  5. +2
    -2
      src/timeline/component/Group.js
  6. +11
    -11
      src/timeline/component/ItemSet.js
  7. +4
    -4
      src/timeline/component/Panel.js
  8. +7
    -7
      src/timeline/component/RootPanel.js
  9. +2
    -2
      src/timeline/component/TimeAxis.js
  10. +3
    -3
      src/timeline/component/item/Item.js
  11. +6
    -6
      src/timeline/component/item/ItemBox.js
  12. +5
    -5
      src/timeline/component/item/ItemPoint.js
  13. +5
    -5
      src/timeline/component/item/ItemRange.js

+ 5
- 5
src/timeline/Timeline.js View File

@ -191,11 +191,11 @@ function Timeline (container, items, options) {
now.clone().add('days', 4).valueOf() now.clone().add('days', 4).valueOf()
); );
this.range.on('rangechange', function (properties) { this.range.on('rangechange', function (properties) {
me.rootPanel.repaint();
me.rootPanel.redraw();
me.emit('rangechange', properties); me.emit('rangechange', properties);
}); });
this.range.on('rangechanged', function (properties) { this.range.on('rangechanged', function (properties) {
me.rootPanel.repaint();
me.rootPanel.redraw();
me.emit('rangechanged', properties); me.emit('rangechanged', properties);
}); });
@ -306,7 +306,7 @@ function Timeline (container, items, options) {
}); });
this.itemSet = new ItemSet(this.backgroundPanel, this.axisPanel, this.sideContentPanel, itemOptions); this.itemSet = new ItemSet(this.backgroundPanel, this.axisPanel, this.sideContentPanel, itemOptions);
this.itemSet.setRange(this.range); this.itemSet.setRange(this.range);
this.itemSet.on('change', me.rootPanel.repaint.bind(me.rootPanel));
this.itemSet.on('change', me.rootPanel.redraw.bind(me.rootPanel));
this.contentPanel.appendChild(this.itemSet); this.contentPanel.appendChild(this.itemSet);
*/ */
this.itemsData = null; // DataSet this.itemsData = null; // DataSet
@ -837,9 +837,9 @@ Timeline.prototype.redraw = function() {
dom.foregroundVertical.style.left = props.left.width + 'px'; dom.foregroundVertical.style.left = props.left.width + 'px';
dom.foregroundVertical.style.top = '0'; dom.foregroundVertical.style.top = '0';
// repaint all components
// redraw all components
this.components.forEach(function (component) { this.components.forEach(function (component) {
resized = component.repaint() || resized;
resized = component.redraw() || resized;
}); });
if (resized) { if (resized) {
// keep repainting until all sizes are settled // keep repainting until all sizes are settled

+ 2
- 2
src/timeline/component/Component.js View File

@ -20,7 +20,7 @@ Component.prototype.setOptions = function setOptions(options) {
if (options) { if (options) {
util.extend(this.options, options); util.extend(this.options, options);
this.repaint();
this.redraw();
} }
}; };
@ -46,7 +46,7 @@ Component.prototype.getOption = function getOption(name) {
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
Component.prototype.repaint = function repaint() {
Component.prototype.redraw = function redraw() {
// should be implemented by the component // should be implemented by the component
return false; return false;
}; };

+ 2
- 2
src/timeline/component/CurrentTime.js View File

@ -35,7 +35,7 @@ CurrentTime.prototype._create = function _create () {
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
CurrentTime.prototype.repaint = function repaint() {
CurrentTime.prototype.redraw = function redraw() {
if (this.options.showCurrentTime) { if (this.options.showCurrentTime) {
var parent = this.timeline.dom.foregroundVertical; var parent = this.timeline.dom.foregroundVertical;
if (this.bar.parentNode != parent) { if (this.bar.parentNode != parent) {
@ -80,7 +80,7 @@ CurrentTime.prototype.start = function start() {
if (interval < 30) interval = 30; if (interval < 30) interval = 30;
if (interval > 1000) interval = 1000; if (interval > 1000) interval = 1000;
me.repaint();
me.redraw();
// start a timer to adjust for the new time // start a timer to adjust for the new time
me.currentTimeTimer = setTimeout(update, interval); me.currentTimeTimer = setTimeout(update, interval);

+ 2
- 2
src/timeline/component/CustomTime.js View File

@ -53,7 +53,7 @@ CustomTime.prototype._create = function _create () {
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
CustomTime.prototype.repaint = function () {
CustomTime.prototype.redraw = function () {
if (this.options.showCustomTime) { if (this.options.showCustomTime) {
var parent = this.timeline.dom.foregroundVertical; var parent = this.timeline.dom.foregroundVertical;
if (this.bar.parentNode != parent) { if (this.bar.parentNode != parent) {
@ -85,7 +85,7 @@ CustomTime.prototype.repaint = function () {
*/ */
CustomTime.prototype.setCustomTime = function(time) { CustomTime.prototype.setCustomTime = function(time) {
this.customTime = new Date(time.valueOf()); this.customTime = new Date(time.valueOf());
this.repaint();
this.redraw();
}; };
/** /**

+ 2
- 2
src/timeline/component/Group.js View File

@ -108,7 +108,7 @@ Group.prototype.getLabelWidth = function getLabelWidth() {
* @param {boolean} [restack=false] Force restacking of all items * @param {boolean} [restack=false] Force restacking of all items
* @return {boolean} Returns true if the group is resized * @return {boolean} Returns true if the group is resized
*/ */
Group.prototype.repaint = function repaint(range, margin, restack) {
Group.prototype.redraw = function redraw(range, margin, restack) {
var resized = false; var resized = false;
this.visibleItems = this._updateVisibleItems(this.orderedItems, this.visibleItems, range); this.visibleItems = this._updateVisibleItems(this.orderedItems, this.visibleItems, range);
@ -121,7 +121,7 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
util.forEach(this.items, function (item) { util.forEach(this.items, function (item) {
item.dirty = true; item.dirty = true;
if (item.displayed) item.repaint();
if (item.displayed) item.redraw();
}); });
restack = true; restack = true;

+ 11
- 11
src/timeline/component/ItemSet.js View File

@ -54,7 +54,7 @@ function ItemSet(timeline, options) {
this.groupIds = []; this.groupIds = [];
this.selection = []; // list with the ids of all selected nodes this.selection = []; // list with the ids of all selected nodes
this.stackDirty = true; // if true, all items will be restacked on next repaint
this.stackDirty = true; // if true, all items will be restacked on next redraw
this.touchParams = {}; // stores properties while dragging this.touchParams = {}; // stores properties while dragging
// create the HTML DOM // create the HTML DOM
@ -148,7 +148,7 @@ ItemSet.prototype._create = function _create(){
ItemSet.prototype.setOptions = Component.prototype.setOptions; ItemSet.prototype.setOptions = Component.prototype.setOptions;
/** /**
* Mark the ItemSet dirty so it will refresh everything with next repaint
* Mark the ItemSet dirty so it will refresh everything with next redraw
*/ */
ItemSet.prototype.markDirty = function markDirty() { ItemSet.prototype.markDirty = function markDirty() {
this.groupIds = []; this.groupIds = [];
@ -258,7 +258,7 @@ ItemSet.prototype._deselect = function _deselect(id) {
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
ItemSet.prototype.repaint = function repaint() {
ItemSet.prototype.redraw = function redraw() {
var margin = this.options.margin, var margin = this.options.margin,
range = this.timeline.range, range = this.timeline.range,
asSize = util.option.asSize, asSize = util.option.asSize,
@ -286,7 +286,7 @@ ItemSet.prototype.repaint = function repaint() {
this.lastVisibleInterval = visibleInterval; this.lastVisibleInterval = visibleInterval;
this.props.lastWidth = this.props.width; this.props.lastWidth = this.props.width;
// repaint all groups
// redraw all groups
var restack = this.stackDirty, var restack = this.stackDirty,
firstGroup = this._firstGroup(), firstGroup = this._firstGroup(),
firstMargin = { firstMargin = {
@ -301,7 +301,7 @@ ItemSet.prototype.repaint = function repaint() {
minHeight = margin.axis + margin.item; minHeight = margin.axis + margin.item;
util.forEach(this.groups, function (group) { util.forEach(this.groups, function (group) {
var groupMargin = (group == firstGroup) ? firstMargin : nonFirstMargin; var groupMargin = (group == firstGroup) ? firstMargin : nonFirstMargin;
resized = group.repaint(range, groupMargin, restack) || resized;
resized = group.redraw(range, groupMargin, restack) || resized;
height += group.height; height += group.height;
}); });
height = Math.max(height, minHeight); height = Math.max(height, minHeight);
@ -462,7 +462,7 @@ ItemSet.prototype.setGroups = function setGroups(groups) {
// remove all drawn groups // remove all drawn groups
ids = this.groupsData.getIds(); ids = this.groupsData.getIds();
this.groupsData = null; this.groupsData = null;
this._onRemoveGroups(ids); // note: this will cause a repaint
this._onRemoveGroups(ids); // note: this will cause a redraw
} }
// replace the dataset // replace the dataset
@ -571,7 +571,7 @@ ItemSet.prototype._onUpdate = function _onUpdate(ids) {
}); });
this._order(); this._order();
this.stackDirty = true; // force re-stacking of all items next repaint
this.stackDirty = true; // force re-stacking of all items next redraw
this.timeline.emitter.emit('change'); this.timeline.emitter.emit('change');
}; };
@ -601,7 +601,7 @@ ItemSet.prototype._onRemove = function _onRemove(ids) {
if (count) { if (count) {
// update order // update order
this._order(); this._order();
this.stackDirty = true; // force re-stacking of all items next repaint
this.stackDirty = true; // force re-stacking of all items next redraw
this.timeline.emitter.emit('change'); this.timeline.emitter.emit('change');
} }
}; };
@ -756,7 +756,7 @@ ItemSet.prototype._updateItem = function _updateItem(item, itemData) {
item.data = itemData; item.data = itemData;
if (item.displayed) { if (item.displayed) {
item.repaint();
item.redraw();
} }
// update group // update group
@ -936,7 +936,7 @@ ItemSet.prototype._onDrag = function (event) {
// TODO: implement onMoving handler // TODO: implement onMoving handler
this.stackDirty = true; // force re-stacking of all items next repaint
this.stackDirty = true; // force re-stacking of all items next redraw
this.timeline.emitter.emit('change'); this.timeline.emitter.emit('change');
event.stopPropagation(); event.stopPropagation();
@ -986,7 +986,7 @@ ItemSet.prototype._onDragEnd = function (event) {
if ('start' in props) props.item.data.start = props.start; if ('start' in props) props.item.data.start = props.start;
if ('end' in props) props.item.data.end = props.end; if ('end' in props) props.item.data.end = props.end;
me.stackDirty = true; // force re-stacking of all items next repaint
me.stackDirty = true; // force re-stacking of all items next redraw
me.timeline.emitter.emit('change'); me.timeline.emitter.emit('change');
} }
}); });

+ 4
- 4
src/timeline/component/Panel.js View File

@ -117,9 +117,9 @@ Panel.prototype.hasChild = function (child) {
/** /**
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component was resized since previous repaint
* @return {boolean} Returns true if the component was resized since previous redraw
*/ */
Panel.prototype.repaint = function () {
Panel.prototype.redraw = function () {
var asString = util.option.asString, var asString = util.option.asString,
options = this.options, options = this.options,
frame = this.getFrame(); frame = this.getFrame();
@ -127,7 +127,7 @@ Panel.prototype.repaint = function () {
// update className // update className
frame.className = 'vpanel' + (options.className ? (' ' + asString(options.className)) : ''); frame.className = 'vpanel' + (options.className ? (' ' + asString(options.className)) : '');
// repaint the child components
// redraw the child components
var childsResized = this._repaintChilds(); var childsResized = this._repaintChilds();
// update frame size // update frame size
@ -144,7 +144,7 @@ Panel.prototype.repaint = function () {
Panel.prototype._repaintChilds = function () { Panel.prototype._repaintChilds = function () {
var resized = false; var resized = false;
for (var i = 0, ii = this.childs.length; i < ii; i++) { for (var i = 0, ii = this.childs.length; i < ii; i++) {
resized = this.childs[i].repaint() || resized;
resized = this.childs[i].redraw() || resized;
} }
return resized; return resized;
}; };

+ 7
- 7
src/timeline/component/RootPanel.js View File

@ -19,7 +19,7 @@ function RootPanel(container, options) {
this._create(); this._create();
// attach the root panel to the provided container // attach the root panel to the provided container
if (!this.container) throw new Error('Cannot repaint root panel: no container attached');
if (!this.container) throw new Error('Cannot redraw root panel: no container attached');
this.container.appendChild(this.getFrame()); this.container.appendChild(this.getFrame());
@ -72,7 +72,7 @@ RootPanel.prototype.setOptions = function setOptions(options) {
if (options) { if (options) {
util.extend(this.options, options); util.extend(this.options, options);
this.repaint();
this.redraw();
this._initWatch(); this._initWatch();
} }
@ -88,7 +88,7 @@ RootPanel.prototype.getFrame = function getFrame() {
/** /**
* Repaint the root panel * Repaint the root panel
*/ */
RootPanel.prototype.repaint = function repaint() {
RootPanel.prototype.redraw = function redraw() {
// update class name // update class name
var options = this.options; var options = this.options;
var editable = options.editable.updateTime || options.editable.updateGroup; var editable = options.editable.updateTime || options.editable.updateGroup;
@ -96,7 +96,7 @@ RootPanel.prototype.repaint = function repaint() {
if (options.className) className += ' ' + util.option.asString(className); if (options.className) className += ' ' + util.option.asString(className);
this.frame.className = className; this.frame.className = className;
// repaint the child components
// redraw the child components
var childsResized = this._repaintChilds(); var childsResized = this._repaintChilds();
// update frame size // update frame size
@ -104,11 +104,11 @@ RootPanel.prototype.repaint = function repaint() {
this.frame.style.minHeight = util.option.asSize(this.options.minHeight, ''); this.frame.style.minHeight = util.option.asSize(this.options.minHeight, '');
this._updateSize(); this._updateSize();
// if the root panel or any of its childs is resized, repaint again,
// if the root panel or any of its childs is resized, redraw again,
// as other components may need to be resized accordingly // as other components may need to be resized accordingly
var resized = this._isResized() || childsResized; var resized = this._isResized() || childsResized;
if (resized) { if (resized) {
setTimeout(this.repaint.bind(this), 0);
setTimeout(this.redraw.bind(this), 0);
} }
}; };
@ -150,7 +150,7 @@ RootPanel.prototype._watch = function _watch() {
(me.frame.clientHeight != me.lastHeight)) { (me.frame.clientHeight != me.lastHeight)) {
me.lastWidth = me.frame.clientWidth; me.lastWidth = me.frame.clientWidth;
me.lastHeight = me.frame.clientHeight; me.lastHeight = me.frame.clientHeight;
me.repaint();
me.redraw();
// TODO: emit a resize event instead? // TODO: emit a resize event instead?
} }
} }

+ 2
- 2
src/timeline/component/TimeAxis.js View File

@ -70,7 +70,7 @@ TimeAxis.prototype._create = function _create() {
* Repaint the component * Repaint the component
* @return {boolean} Returns true if the component is resized * @return {boolean} Returns true if the component is resized
*/ */
TimeAxis.prototype.repaint = function () {
TimeAxis.prototype.redraw = function () {
var options = this.options, var options = this.options,
props = this.props, props = this.props,
foreground = this.dom.foreground, foreground = this.dom.foreground,
@ -342,7 +342,7 @@ TimeAxis.prototype._repaintMajorLine = function (x, orientation) {
* @private * @private
*/ */
TimeAxis.prototype._calculateCharSize = function () { TimeAxis.prototype._calculateCharSize = function () {
// Note: We calculate char size with every repaint. Size may change, for
// Note: We calculate char size with every redraw. Size may change, for
// example when any of the timelines parents had display:none for example. // example when any of the timelines parents had display:none for example.
// determine the char width and height on the minor axis // determine the char width and height on the minor axis

+ 3
- 3
src/timeline/component/item/Item.js View File

@ -29,7 +29,7 @@ function Item (data, options, defaultOptions) {
*/ */
Item.prototype.select = function select() { Item.prototype.select = function select() {
this.selected = true; this.selected = true;
if (this.displayed) this.repaint();
if (this.displayed) this.redraw();
}; };
/** /**
@ -37,7 +37,7 @@ Item.prototype.select = function select() {
*/ */
Item.prototype.unselect = function unselect() { Item.prototype.unselect = function unselect() {
this.selected = false; this.selected = false;
if (this.displayed) this.repaint();
if (this.displayed) this.redraw();
}; };
/** /**
@ -86,7 +86,7 @@ Item.prototype.hide = function hide() {
/** /**
* Repaint the item * Repaint the item
*/ */
Item.prototype.repaint = function repaint() {
Item.prototype.redraw = function redraw() {
// should be implemented by the item // should be implemented by the item
}; };

+ 6
- 6
src/timeline/component/item/ItemBox.js View File

@ -46,7 +46,7 @@ ItemBox.prototype.isVisible = function isVisible (range) {
/** /**
* Repaint the item * Repaint the item
*/ */
ItemBox.prototype.repaint = function repaint() {
ItemBox.prototype.redraw = function redraw() {
var dom = this.dom; var dom = this.dom;
if (!dom) { if (!dom) {
// create DOM // create DOM
@ -75,21 +75,21 @@ ItemBox.prototype.repaint = function repaint() {
// append DOM to parent DOM // append DOM to parent DOM
if (!this.parent) { if (!this.parent) {
throw new Error('Cannot repaint item: no parent attached');
throw new Error('Cannot redraw item: no parent attached');
} }
if (!dom.box.parentNode) { if (!dom.box.parentNode) {
var foreground = this.parent.dom.foreground; var foreground = this.parent.dom.foreground;
if (!foreground) throw new Error('Cannot repaint time axis: parent has no foreground container element');
if (!foreground) throw new Error('Cannot redraw time axis: parent has no foreground container element');
foreground.appendChild(dom.box); foreground.appendChild(dom.box);
} }
if (!dom.line.parentNode) { if (!dom.line.parentNode) {
var background = this.parent.dom.background; var background = this.parent.dom.background;
if (!background) throw new Error('Cannot repaint time axis: parent has no background container element');
if (!background) throw new Error('Cannot redraw time axis: parent has no background container element');
background.appendChild(dom.line); background.appendChild(dom.line);
} }
if (!dom.dot.parentNode) { if (!dom.dot.parentNode) {
var axis = this.parent.dom.axis; var axis = this.parent.dom.axis;
if (!background) throw new Error('Cannot repaint time axis: parent has no axis container element');
if (!background) throw new Error('Cannot redraw time axis: parent has no axis container element');
axis.appendChild(dom.dot); axis.appendChild(dom.dot);
} }
this.displayed = true; this.displayed = true;
@ -143,7 +143,7 @@ ItemBox.prototype.repaint = function repaint() {
*/ */
ItemBox.prototype.show = function show() { ItemBox.prototype.show = function show() {
if (!this.displayed) { if (!this.displayed) {
this.repaint();
this.redraw();
} }
}; };

+ 5
- 5
src/timeline/component/item/ItemPoint.js View File

@ -47,7 +47,7 @@ ItemPoint.prototype.isVisible = function isVisible (range) {
/** /**
* Repaint the item * Repaint the item
*/ */
ItemPoint.prototype.repaint = function repaint() {
ItemPoint.prototype.redraw = function redraw() {
var dom = this.dom; var dom = this.dom;
if (!dom) { if (!dom) {
// create DOM // create DOM
@ -56,7 +56,7 @@ ItemPoint.prototype.repaint = function repaint() {
// background box // background box
dom.point = document.createElement('div'); dom.point = document.createElement('div');
// className is updated in repaint()
// className is updated in redraw()
// contents box, right from the dot // contents box, right from the dot
dom.content = document.createElement('div'); dom.content = document.createElement('div');
@ -73,12 +73,12 @@ ItemPoint.prototype.repaint = function repaint() {
// append DOM to parent DOM // append DOM to parent DOM
if (!this.parent) { if (!this.parent) {
throw new Error('Cannot repaint item: no parent attached');
throw new Error('Cannot redraw item: no parent attached');
} }
if (!dom.point.parentNode) { if (!dom.point.parentNode) {
var foreground = this.parent.dom.foreground; var foreground = this.parent.dom.foreground;
if (!foreground) { if (!foreground) {
throw new Error('Cannot repaint time axis: parent has no foreground container element');
throw new Error('Cannot redraw time axis: parent has no foreground container element');
} }
foreground.appendChild(dom.point); foreground.appendChild(dom.point);
} }
@ -139,7 +139,7 @@ ItemPoint.prototype.repaint = function repaint() {
*/ */
ItemPoint.prototype.show = function show() { ItemPoint.prototype.show = function show() {
if (!this.displayed) { if (!this.displayed) {
this.repaint();
this.redraw();
} }
}; };

+ 5
- 5
src/timeline/component/item/ItemRange.js View File

@ -44,7 +44,7 @@ ItemRange.prototype.isVisible = function isVisible (range) {
/** /**
* Repaint the item * Repaint the item
*/ */
ItemRange.prototype.repaint = function repaint() {
ItemRange.prototype.redraw = function redraw() {
var dom = this.dom; var dom = this.dom;
if (!dom) { if (!dom) {
// create DOM // create DOM
@ -53,7 +53,7 @@ ItemRange.prototype.repaint = function repaint() {
// background box // background box
dom.box = document.createElement('div'); dom.box = document.createElement('div');
// className is updated in repaint()
// className is updated in redraw()
// contents box // contents box
dom.content = document.createElement('div'); dom.content = document.createElement('div');
@ -66,12 +66,12 @@ ItemRange.prototype.repaint = function repaint() {
// append DOM to parent DOM // append DOM to parent DOM
if (!this.parent) { if (!this.parent) {
throw new Error('Cannot repaint item: no parent attached');
throw new Error('Cannot redraw item: no parent attached');
} }
if (!dom.box.parentNode) { if (!dom.box.parentNode) {
var foreground = this.parent.dom.foreground; var foreground = this.parent.dom.foreground;
if (!foreground) { if (!foreground) {
throw new Error('Cannot repaint time axis: parent has no foreground container element');
throw new Error('Cannot redraw time axis: parent has no foreground container element');
} }
foreground.appendChild(dom.box); foreground.appendChild(dom.box);
} }
@ -123,7 +123,7 @@ ItemRange.prototype.repaint = function repaint() {
*/ */
ItemRange.prototype.show = function show() { ItemRange.prototype.show = function show() {
if (!this.displayed) { if (!this.displayed) {
this.repaint();
this.redraw();
} }
}; };

Loading…
Cancel
Save