Improve the Widget.prototype.removeChildDomNodes() method so that most subclasses won't need to override it

print-window-tiddler
Jermolene 2013-11-09 16:55:14 +00:00
rodzic e2d7c7aea5
commit 6f1c9d88cc
19 zmienionych plików z 12 dodań i 183 usunięć

Wyświetl plik

@ -63,16 +63,6 @@ BrowseWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget or its children
*/
BrowseWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.browse = BrowseWidget;
})();

Wyświetl plik

@ -136,16 +136,6 @@ ButtonWidget.prototype.refresh = function(changedTiddlers) {
return this.refreshChildren(changedTiddlers);
};
/*
Remove any DOM nodes created by this widget or its children
*/
ButtonWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.button = ButtonWidget;
})();

Wyświetl plik

@ -103,16 +103,6 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Remove any DOM nodes created by this widget or its children
*/
CheckboxWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.checkbox = CheckboxWidget;
})();

Wyświetl plik

@ -66,16 +66,6 @@ CountWidget.prototype.refresh = function(changedTiddlers) {
};
/*
Remove any DOM nodes created by this widget
*/
CountWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.count = CountWidget;
})();

Wyświetl plik

@ -175,16 +175,6 @@ DropZoneWidget.prototype.refresh = function(changedTiddlers) {
return this.refreshChildren(changedTiddlers);
};
/*
Remove any DOM nodes created by this widget or its children
*/
DropZoneWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.dropzone = DropZoneWidget;
})();

Wyświetl plik

@ -94,16 +94,6 @@ EditBitmapWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget or its children
*/
EditBitmapWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
EditBitmapWidget.prototype.loadCanvas = function() {
var tiddler = this.wiki.getTiddler(this.editTitle),
currImage = new Image();

Wyświetl plik

@ -247,16 +247,6 @@ EditTextWidget.prototype.saveChanges = function(text) {
}
};
/*
Remove any DOM nodes created by this widget or its children
*/
EditTextWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports["edit-text"] = EditTextWidget;
})();

Wyświetl plik

@ -70,16 +70,6 @@ ElementWidget.prototype.refresh = function(changedTiddlers) {
return this.refreshChildren(changedTiddlers) || hasChangedAttributes;
};
/*
Remove any DOM nodes created by this widget or its children
*/
ElementWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.element = ElementWidget;
})();

Wyświetl plik

@ -70,16 +70,6 @@ EncryptWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Remove any DOM nodes created by this widget
*/
EncryptWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.encrypt = EncryptWidget;
})();

Wyświetl plik

@ -47,16 +47,6 @@ EntityWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget
*/
EntityWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.entity = EntityWidget;
})();

Wyświetl plik

@ -98,16 +98,6 @@ FieldsWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Remove any DOM nodes created by this widget
*/
FieldsWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.fields = FieldsWidget;
})();

Wyświetl plik

@ -169,16 +169,6 @@ LinkWidget.prototype.refresh = function(changedTiddlers) {
return this.refreshChildren(changedTiddlers);
};
/*
Remove any DOM nodes created by this widget or its children
*/
LinkWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.link = LinkWidget;
})();

Wyświetl plik

@ -77,16 +77,6 @@ PasswordWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Remove any DOM nodes created by this widget or its children
*/
PasswordWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.password = PasswordWidget;
})();

Wyświetl plik

@ -190,16 +190,6 @@ RevealWidget.prototype.updateState = function() {
}
};
/*
Remove any DOM nodes created by this widget or its children
*/
RevealWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.reveal = RevealWidget;
})();

Wyświetl plik

@ -48,16 +48,6 @@ TextNodeWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget
*/
TextNodeWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.text = TextNodeWidget;
})();

Wyświetl plik

@ -170,16 +170,6 @@ ViewWidget.prototype.refresh = function(changedTiddlers) {
}
};
/*
Remove any DOM nodes created by this widget
*/
ViewWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.view = ViewWidget;
})();

Wyświetl plik

@ -450,9 +450,18 @@ Widget.prototype.findFirstDomNode = function() {
Remove any DOM nodes created by this widget or its children
*/
Widget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.children,function(childWidget) {
childWidget.removeChildDomNodes();
});
// If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case
if(this.domNodes.length > 0) {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
} else {
// Otherwise, ask the child widgets to delete their DOM nodes
$tw.utils.each(this.children,function(childWidget) {
childWidget.removeChildDomNodes();
});
}
};
exports.widget = Widget;

Wyświetl plik

@ -199,16 +199,6 @@ BarWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget or its children
*/
BarWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.d3bar = BarWidget;
})();

Wyświetl plik

@ -128,16 +128,6 @@ CloudWidget.prototype.refresh = function(changedTiddlers) {
return false;
};
/*
Remove any DOM nodes created by this widget or its children
*/
CloudWidget.prototype.removeChildDomNodes = function() {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
};
exports.d3cloud = CloudWidget;
})();