From a5025b96737ec83bb90ef656c35543e51c9134c5 Mon Sep 17 00:00:00 2001 From: jos Date: Tue, 10 Jun 2014 10:56:40 +0200 Subject: [PATCH] Renamed all functions `repaint` to `redraw` --- src/timeline/Timeline.js | 10 +++++----- src/timeline/component/Component.js | 4 ++-- src/timeline/component/CurrentTime.js | 4 ++-- src/timeline/component/CustomTime.js | 4 ++-- src/timeline/component/Group.js | 4 ++-- src/timeline/component/ItemSet.js | 22 +++++++++++----------- src/timeline/component/Panel.js | 8 ++++---- src/timeline/component/RootPanel.js | 14 +++++++------- src/timeline/component/TimeAxis.js | 4 ++-- src/timeline/component/item/Item.js | 6 +++--- src/timeline/component/item/ItemBox.js | 12 ++++++------ src/timeline/component/item/ItemPoint.js | 10 +++++----- src/timeline/component/item/ItemRange.js | 10 +++++----- 13 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js index bdfc66ed..d646e632 100644 --- a/src/timeline/Timeline.js +++ b/src/timeline/Timeline.js @@ -191,11 +191,11 @@ function Timeline (container, items, options) { now.clone().add('days', 4).valueOf() ); this.range.on('rangechange', function (properties) { - me.rootPanel.repaint(); + me.rootPanel.redraw(); me.emit('rangechange', properties); }); this.range.on('rangechanged', function (properties) { - me.rootPanel.repaint(); + me.rootPanel.redraw(); 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.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.itemsData = null; // DataSet @@ -837,9 +837,9 @@ Timeline.prototype.redraw = function() { dom.foregroundVertical.style.left = props.left.width + 'px'; dom.foregroundVertical.style.top = '0'; - // repaint all components + // redraw all components this.components.forEach(function (component) { - resized = component.repaint() || resized; + resized = component.redraw() || resized; }); if (resized) { // keep repainting until all sizes are settled diff --git a/src/timeline/component/Component.js b/src/timeline/component/Component.js index 3d91b28a..61ce3290 100644 --- a/src/timeline/component/Component.js +++ b/src/timeline/component/Component.js @@ -20,7 +20,7 @@ Component.prototype.setOptions = function setOptions(options) { if (options) { util.extend(this.options, options); - this.repaint(); + this.redraw(); } }; @@ -46,7 +46,7 @@ Component.prototype.getOption = function getOption(name) { * Repaint the component * @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 return false; }; diff --git a/src/timeline/component/CurrentTime.js b/src/timeline/component/CurrentTime.js index 25210ee1..ac824cb7 100644 --- a/src/timeline/component/CurrentTime.js +++ b/src/timeline/component/CurrentTime.js @@ -35,7 +35,7 @@ CurrentTime.prototype._create = function _create () { * Repaint the component * @return {boolean} Returns true if the component is resized */ -CurrentTime.prototype.repaint = function repaint() { +CurrentTime.prototype.redraw = function redraw() { if (this.options.showCurrentTime) { var parent = this.timeline.dom.foregroundVertical; if (this.bar.parentNode != parent) { @@ -80,7 +80,7 @@ CurrentTime.prototype.start = function start() { if (interval < 30) interval = 30; if (interval > 1000) interval = 1000; - me.repaint(); + me.redraw(); // start a timer to adjust for the new time me.currentTimeTimer = setTimeout(update, interval); diff --git a/src/timeline/component/CustomTime.js b/src/timeline/component/CustomTime.js index 2012bcf9..b95079cd 100644 --- a/src/timeline/component/CustomTime.js +++ b/src/timeline/component/CustomTime.js @@ -53,7 +53,7 @@ CustomTime.prototype._create = function _create () { * Repaint the component * @return {boolean} Returns true if the component is resized */ -CustomTime.prototype.repaint = function () { +CustomTime.prototype.redraw = function () { if (this.options.showCustomTime) { var parent = this.timeline.dom.foregroundVertical; if (this.bar.parentNode != parent) { @@ -85,7 +85,7 @@ CustomTime.prototype.repaint = function () { */ CustomTime.prototype.setCustomTime = function(time) { this.customTime = new Date(time.valueOf()); - this.repaint(); + this.redraw(); }; /** diff --git a/src/timeline/component/Group.js b/src/timeline/component/Group.js index 928d1b69..ec9e4377 100644 --- a/src/timeline/component/Group.js +++ b/src/timeline/component/Group.js @@ -108,7 +108,7 @@ Group.prototype.getLabelWidth = function getLabelWidth() { * @param {boolean} [restack=false] Force restacking of all items * @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; 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) { item.dirty = true; - if (item.displayed) item.repaint(); + if (item.displayed) item.redraw(); }); restack = true; diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index 24159659..4126ef15 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -54,7 +54,7 @@ function ItemSet(timeline, options) { this.groupIds = []; 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 // create the HTML DOM @@ -148,7 +148,7 @@ ItemSet.prototype._create = function _create(){ 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() { this.groupIds = []; @@ -258,7 +258,7 @@ ItemSet.prototype._deselect = function _deselect(id) { * Repaint the component * @return {boolean} Returns true if the component is resized */ -ItemSet.prototype.repaint = function repaint() { +ItemSet.prototype.redraw = function redraw() { var margin = this.options.margin, range = this.timeline.range, asSize = util.option.asSize, @@ -286,7 +286,7 @@ ItemSet.prototype.repaint = function repaint() { this.lastVisibleInterval = visibleInterval; this.props.lastWidth = this.props.width; - // repaint all groups + // redraw all groups var restack = this.stackDirty, firstGroup = this._firstGroup(), firstMargin = { @@ -301,7 +301,7 @@ ItemSet.prototype.repaint = function repaint() { minHeight = margin.axis + margin.item; util.forEach(this.groups, function (group) { var groupMargin = (group == firstGroup) ? firstMargin : nonFirstMargin; - resized = group.repaint(range, groupMargin, restack) || resized; + resized = group.redraw(range, groupMargin, restack) || resized; height += group.height; }); height = Math.max(height, minHeight); @@ -462,7 +462,7 @@ ItemSet.prototype.setGroups = function setGroups(groups) { // remove all drawn groups ids = this.groupsData.getIds(); this.groupsData = null; - this._onRemoveGroups(ids); // note: this will cause a repaint + this._onRemoveGroups(ids); // note: this will cause a redraw } // replace the dataset @@ -571,7 +571,7 @@ ItemSet.prototype._onUpdate = function _onUpdate(ids) { }); 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'); }; @@ -601,7 +601,7 @@ ItemSet.prototype._onRemove = function _onRemove(ids) { if (count) { // update 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'); } }; @@ -756,7 +756,7 @@ ItemSet.prototype._updateItem = function _updateItem(item, itemData) { item.data = itemData; if (item.displayed) { - item.repaint(); + item.redraw(); } // update group @@ -936,7 +936,7 @@ ItemSet.prototype._onDrag = function (event) { // 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'); event.stopPropagation(); @@ -986,7 +986,7 @@ ItemSet.prototype._onDragEnd = function (event) { if ('start' in props) props.item.data.start = props.start; 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'); } }); diff --git a/src/timeline/component/Panel.js b/src/timeline/component/Panel.js index 615636e3..f8c1a284 100644 --- a/src/timeline/component/Panel.js +++ b/src/timeline/component/Panel.js @@ -117,9 +117,9 @@ Panel.prototype.hasChild = function (child) { /** * 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, options = this.options, frame = this.getFrame(); @@ -127,7 +127,7 @@ Panel.prototype.repaint = function () { // update className frame.className = 'vpanel' + (options.className ? (' ' + asString(options.className)) : ''); - // repaint the child components + // redraw the child components var childsResized = this._repaintChilds(); // update frame size @@ -144,7 +144,7 @@ Panel.prototype.repaint = function () { Panel.prototype._repaintChilds = function () { var resized = false; 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; }; diff --git a/src/timeline/component/RootPanel.js b/src/timeline/component/RootPanel.js index 0386461d..1da83a71 100644 --- a/src/timeline/component/RootPanel.js +++ b/src/timeline/component/RootPanel.js @@ -19,7 +19,7 @@ function RootPanel(container, options) { this._create(); // 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()); @@ -72,7 +72,7 @@ RootPanel.prototype.setOptions = function setOptions(options) { if (options) { util.extend(this.options, options); - this.repaint(); + this.redraw(); this._initWatch(); } @@ -88,7 +88,7 @@ RootPanel.prototype.getFrame = function getFrame() { /** * Repaint the root panel */ -RootPanel.prototype.repaint = function repaint() { +RootPanel.prototype.redraw = function redraw() { // update class name var options = this.options; 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); this.frame.className = className; - // repaint the child components + // redraw the child components var childsResized = this._repaintChilds(); // update frame size @@ -104,11 +104,11 @@ RootPanel.prototype.repaint = function repaint() { this.frame.style.minHeight = util.option.asSize(this.options.minHeight, ''); 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 var resized = this._isResized() || childsResized; 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.lastWidth = me.frame.clientWidth; me.lastHeight = me.frame.clientHeight; - me.repaint(); + me.redraw(); // TODO: emit a resize event instead? } } diff --git a/src/timeline/component/TimeAxis.js b/src/timeline/component/TimeAxis.js index 76f9bba5..1c991a23 100644 --- a/src/timeline/component/TimeAxis.js +++ b/src/timeline/component/TimeAxis.js @@ -70,7 +70,7 @@ TimeAxis.prototype._create = function _create() { * Repaint the component * @return {boolean} Returns true if the component is resized */ -TimeAxis.prototype.repaint = function () { +TimeAxis.prototype.redraw = function () { var options = this.options, props = this.props, foreground = this.dom.foreground, @@ -342,7 +342,7 @@ TimeAxis.prototype._repaintMajorLine = function (x, orientation) { * @private */ 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. // determine the char width and height on the minor axis diff --git a/src/timeline/component/item/Item.js b/src/timeline/component/item/Item.js index 15b4d272..8c5b8f97 100644 --- a/src/timeline/component/item/Item.js +++ b/src/timeline/component/item/Item.js @@ -29,7 +29,7 @@ function Item (data, options, defaultOptions) { */ Item.prototype.select = function select() { 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() { 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 */ -Item.prototype.repaint = function repaint() { +Item.prototype.redraw = function redraw() { // should be implemented by the item }; diff --git a/src/timeline/component/item/ItemBox.js b/src/timeline/component/item/ItemBox.js index 1e7ecb75..2258878b 100644 --- a/src/timeline/component/item/ItemBox.js +++ b/src/timeline/component/item/ItemBox.js @@ -46,7 +46,7 @@ ItemBox.prototype.isVisible = function isVisible (range) { /** * Repaint the item */ -ItemBox.prototype.repaint = function repaint() { +ItemBox.prototype.redraw = function redraw() { var dom = this.dom; if (!dom) { // create DOM @@ -75,21 +75,21 @@ ItemBox.prototype.repaint = function repaint() { // append DOM to parent DOM 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) { 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); } if (!dom.line.parentNode) { 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); } if (!dom.dot.parentNode) { 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); } this.displayed = true; @@ -143,7 +143,7 @@ ItemBox.prototype.repaint = function repaint() { */ ItemBox.prototype.show = function show() { if (!this.displayed) { - this.repaint(); + this.redraw(); } }; diff --git a/src/timeline/component/item/ItemPoint.js b/src/timeline/component/item/ItemPoint.js index ba7d1a5b..6a6d39ff 100644 --- a/src/timeline/component/item/ItemPoint.js +++ b/src/timeline/component/item/ItemPoint.js @@ -47,7 +47,7 @@ ItemPoint.prototype.isVisible = function isVisible (range) { /** * Repaint the item */ -ItemPoint.prototype.repaint = function repaint() { +ItemPoint.prototype.redraw = function redraw() { var dom = this.dom; if (!dom) { // create DOM @@ -56,7 +56,7 @@ ItemPoint.prototype.repaint = function repaint() { // background box dom.point = document.createElement('div'); - // className is updated in repaint() + // className is updated in redraw() // contents box, right from the dot dom.content = document.createElement('div'); @@ -73,12 +73,12 @@ ItemPoint.prototype.repaint = function repaint() { // append DOM to parent DOM 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) { var foreground = this.parent.dom.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); } @@ -139,7 +139,7 @@ ItemPoint.prototype.repaint = function repaint() { */ ItemPoint.prototype.show = function show() { if (!this.displayed) { - this.repaint(); + this.redraw(); } }; diff --git a/src/timeline/component/item/ItemRange.js b/src/timeline/component/item/ItemRange.js index 3ef554bd..bf57bf2e 100644 --- a/src/timeline/component/item/ItemRange.js +++ b/src/timeline/component/item/ItemRange.js @@ -44,7 +44,7 @@ ItemRange.prototype.isVisible = function isVisible (range) { /** * Repaint the item */ -ItemRange.prototype.repaint = function repaint() { +ItemRange.prototype.redraw = function redraw() { var dom = this.dom; if (!dom) { // create DOM @@ -53,7 +53,7 @@ ItemRange.prototype.repaint = function repaint() { // background box dom.box = document.createElement('div'); - // className is updated in repaint() + // className is updated in redraw() // contents box dom.content = document.createElement('div'); @@ -66,12 +66,12 @@ ItemRange.prototype.repaint = function repaint() { // append DOM to parent DOM 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) { var foreground = this.parent.dom.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); } @@ -123,7 +123,7 @@ ItemRange.prototype.repaint = function repaint() { */ ItemRange.prototype.show = function show() { if (!this.displayed) { - this.repaint(); + this.redraw(); } };