Arjunsos / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

TIMEPLOT: Better Timeplot._clearLabels function #78

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Index: timeplot.js
===================================================================
--- timeplot.js (revision 9214)
+++ timeplot.js (working copy)
@@ -394,10 +394,21 @@
     },

     _clearLabels: function() {
- var labels = this._containerDiv.firstChild;
- if (labels) this._containerDiv.removeChild(labels);
- labels = document.createElement("div");
- this._containerDiv.appendChild(labels);
+ if (this._containerDiv.hasChildNodes())
+ {
+ var children = this._containerDiv.childNodes;
+ for (var i = 0; i < children.length; i++)
+ {
+ if(children[i].id == "timeplot-labels")
+ {
+ this._containerDiv.removeChild(children[i]);
+ }
+ }
+ }
+
+ var labels = document.createElement("div");
+ labels.id = "timeplot-labels";
+ this._containerDiv.insertBefore(labels, this._containerDiv.firstChild);
     },

     _prepareCanvas: function() { 

Index: geometry.js
===================================================================
--- geometry.js (revision 9214)
+++ geometry.js (working copy)
@@ -193,11 +193,9 @@
      * Removes all the labels that were added by this geometry
      */
     _clearLabels: function() {
- for (var i = 0; i < this._labels.length; i++) {
- var l = this._labels[i];
- var parent = l.parentNode;
- if (parent) parent.removeChild(l);
- }
+ if(this._timeplot && this._timeplot._containerDiv){
+
SimileAjax.jQuery(".timeplot-grid-label",this._timeplot._containerDiv).remove();
+ }
     },

     /*

[Submitted by Jon-Carlos Rivera on simile.mit.edu]

Original issue reported on code.google.com by stefano.mazzocchi@gmail.com on 25 Mar 2009 at 5:51