Cleaned up elementPlace legacy code, no longer relys on elementCreate
This commit is contained in:
parent
006f6e5ade
commit
cfc60ebd1d
@ -60,24 +60,21 @@ function elementMake (ID,Class,element) { //new and improved, I can use more tha
|
||||
}
|
||||
|
||||
function elementPlace (parentID, ID, Class, element, position) {
|
||||
parentID = "string" == typeof parentID ? parentID.replace(/ /g,"_") : parentID;
|
||||
var newObject = document.createElement(element);
|
||||
if ("string" == typeof Class) { newObject.setAttribute("class",Class); }
|
||||
if ("string" == typeof ID) {
|
||||
ID = "string" == typeof ID ? ID.replace(/ /g,"_") : ID;
|
||||
var newElement = elementMake(ID,Class,element);
|
||||
if ( (typeof document.querySelector(parentID).append && typeof document.querySelector(parentID).prepend) !== "undefined") { // Are we compliant?
|
||||
if ("before" == position) {
|
||||
document.querySelector(parentID).prepend(newElement);
|
||||
} else {
|
||||
document.querySelector(parentID).append(newElement);
|
||||
newObject.id = ID;
|
||||
}
|
||||
} else { //No? Ok we will use the old way.
|
||||
if ("before" == position) {
|
||||
parentID = "string" == typeof parentID ? parentID.replace(/ /g,"_") : parentID;
|
||||
var p = document.querySelector(parentID);
|
||||
p.insertBefore(newElement,p.firstChild);
|
||||
var compliant = ( (typeof document.querySelector(parentID).append && typeof document.querySelector(parentID).prepend) !== "undefined"); // Are we compliant?
|
||||
if ("before" == position) {
|
||||
compliant ? p.prepend(newObject) : p.insertBefore(newObject, p.firstChild);
|
||||
} else {
|
||||
document.querySelector(parentID).appendChild(newElement);
|
||||
compliant ? p.append(newObject) : p.appendChild(newObject);
|
||||
}
|
||||
}
|
||||
return newElement;
|
||||
return newObject;
|
||||
}
|
||||
|
||||
function titledContainer (ParentID,ID,Class,Element,Position,Title) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user