diff --git a/plugins/c9.ide.run.debug/breakpoints_test.js b/plugins/c9.ide.run.debug/breakpoints_test.js index eca8be9c..b90fab7e 100644 --- a/plugins/c9.ide.run.debug/breakpoints_test.js +++ b/plugins/c9.ide.run.debug/breakpoints_test.js @@ -90,12 +90,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], + count + " of " + expected); } - expect.html.setConstructor(function(node) { - if (node.$ext) return node.$ext; - - return apf.xmldb.getHtmlNode(node, list); - }); - describe('breakpoints', function() { before(function(done) { apf.config.setProperty("allow-select", false); diff --git a/plugins/c9.ide.run.debug/callstack_test.js b/plugins/c9.ide.run.debug/callstack_test.js index 6b13270a..7808766e 100644 --- a/plugins/c9.ide.run.debug/callstack_test.js +++ b/plugins/c9.ide.run.debug/callstack_test.js @@ -63,12 +63,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], + count + " of " + expected); } - expect.html.setConstructor(function(node) { - if (node.$ext) return node.$ext; - - return apf.xmldb.getHtmlNode(node, datagrid); - }); - describe('breakpoints', function() { before(function(done) { apf.config.setProperty("allow-select", false); diff --git a/plugins/c9.ide.run.debug/variables_test.js b/plugins/c9.ide.run.debug/variables_test.js index b3fa8cc5..256bac09 100644 --- a/plugins/c9.ide.run.debug/variables_test.js +++ b/plugins/c9.ide.run.debug/variables_test.js @@ -63,12 +63,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], + count + " of " + expected); } - expect.html.setConstructor(function(node) { - if (node.$ext) return node.$ext; - - return apf.xmldb.getHtmlNode(node, datagrid); - }); - describe('breakpoints', function() { before(function(done) { apf.config.setProperty("allow-select", false); diff --git a/plugins/c9.ide.run.debug/watches_test.js b/plugins/c9.ide.run.debug/watches_test.js index e50bd9b2..aba2f442 100644 --- a/plugins/c9.ide.run.debug/watches_test.js +++ b/plugins/c9.ide.run.debug/watches_test.js @@ -94,12 +94,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"], throw new Error("Wrong Event Count: " + count + " of " + expected); } - - expect.html.setConstructor(function(node) { - if (node.$ext) return node.$ext; - - return apf.xmldb.getHtmlNode(node, datagrid); - }); var testDebugger = new EventEmitter(); testDebugger.attach = function () { diff --git a/plugins/c9.ide.tree/tree_test.js b/plugins/c9.ide.tree/tree_test.js index ec0cb18f..82a00632 100644 --- a/plugins/c9.ide.tree/tree_test.js +++ b/plugins/c9.ide.tree/tree_test.js @@ -451,8 +451,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], done(); }); it('should update a name', function(done) { - // TODO these were using setAttribute ui.xmldb.setAttribute - // we don't have equivalent method for now var node = fsCache.findNode("/gtest"); fsCache.createNode("/atest", null, node); expect.html("/gtest").to.not.exist; diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index 3b0d2e42..37bc4980 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -7890,1107 +7890,6 @@ return { - - -/** - * The XML database object provides local storage for XML data. This object - * routes all changes to the XML data to the data bound objects. It also - * provides utility functions for XML handling. - * - * @class apf.xmldb - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.8 - * @additional - * - * @default_private - */ -apf.xmldb = new (function(){ - var _self = this; - - this.xmlDocTag = "a_doc"; - this.xmlIdTag = "a_id"; - this.xmlListenTag = "a_listen"; - this.htmlIdTag = "id"; - this.disableRDB = false; - - this.$xmlDocLut = []; - this.$nodeCount = {}; - - var cleanRE = / (?:a_doc|a_id|a_listen|a_loaded)=(?:"|')[^'"]+(?:"|')/g, - whiteRE = />[\s\n\r\t]+= 0; i--) { - if (lut[ids[i]]) { - delete this.$listeners[ids[i]]; - delete lut[ids[1]]; - } - } - - xmlNode.setAttribute(this.xmlListenTag, Object.keys(lut).join(";"));// + ";" - } - - /* - * @todo Use this function when an element really unbinds from a - * piece of data and does not uses it for caching - * @private - */ - this.removeNodeListener = function(xmlNode, o, id) { - var listen = xmlNode.getAttribute(this.xmlListenTag); - var nodes = (listen ? listen.split(";") : []); - if (id && id.charAt(0) == "p") { - id = this.$listeners[id]; - delete this.$listeners[id]; - } - else { - id = "e" + o.$uniqueId; - - - } - - for (var newnodes = [], i = 0; i < nodes.length; i++) { - if (nodes[i] != id) - newnodes.push(nodes[i]); - } - - xmlNode.setAttribute(this.xmlListenTag, newnodes.join(";"));// + ";" - - return xmlNode; - }; - - /** - * Sets the value of a text node. If the node doesn't exist, it is created. - * - * Changes are propagated to the databound elements listening for changes - * on the data changed. - * - * @param {XMLElement} pNode The parent of the text node. - * @param {String} value The value of the text node. - * @param {String} [xpath] The xpath statement which selects the text node. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.setTextNode = - apf.setTextNode = function(pNode, value, xpath, undoObj, range) { - var tNode; - - if (xpath) { - tNode = pNode.selectSingleNode(xpath); - if (!tNode) - return; - pNode = tNode.nodeType == 1 ? tNode : null; - } - if (pNode.nodeType != 1) - tNode = pNode; - else if (pNode || !tNode) { - tNode = pNode.selectSingleNode("text()"); - - if (!tNode) - tNode = pNode.appendChild(pNode.ownerDocument.createTextNode(""));//createCDATASection - } - - //Action Tracker Support - if (undoObj && !undoObj.$filled) { - undoObj.extra.oldValue = tNode.nodeValue; - undoObj.$filled = true; - } - - //Apply Changes - if (range) { //@todo apf3.0 range - undoObj.extra.range = range; - - } - else { - tNode.nodeValue = value; - - if (tNode.$regbase) - tNode.$setValue(value); - } - - this.applyChanges("text", tNode.parentNode, undoObj); - - - this.applyRDB(["setTextNode", pNode, value, xpath], undoObj || {xmlNode: pNode}); //@todo apf3.0 for range support - - }; - - /** - * Sets an attribute on a node. Changes are propagated to the databound - * elements listening for changes on the data changed. - * - * @param {XMLElement} xmlNode The XML node to set the attribute on. - * @param {String} name The name of the attribute. - * @param {String} value The value of the attribute. - * @param {String} [xpath] The xpath statement to select the attribute. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.setAttribute = - apf.setAttribute = function(xmlNode, name, value, xpath, undoObj, range) { - //Action Tracker Support - if (undoObj && !undoObj.$filled) { - undoObj.name = name; - undoObj.$filled = true; - } - - //Apply Changes - if (range) { //@todo apf3.0 range - undoObj.extra.range = range; - } - else - (xpath ? xmlNode.selectSingleNode(xpath) : xmlNode).setAttribute(name, value); - - this.applyChanges("attribute", xmlNode, undoObj); - - this.applyRDB(["setAttribute", xmlNode, name, value, xpath], undoObj || {xmlNode: xmlNode}); //@todo apf3.0 for range support - - }; - - /** - * Removes an attribute of an XML node. Changes are propagated to the - * databound elements listening for changes on the data changed. - * - * @param {XMLElement} xmlNode The XML node to delete the attribute from - * @param {String} name The name of the attribute. - * @param {String} [xpath] The xpath statement to select the attribute. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.removeAttribute = - apf.removeAttribute = function(xmlNode, name, xpath, undoObj) { - //if(xmlNode.nodeType != 1) xmlNode.nodeValue = value; - - //Action Tracker Support - if (undoObj && !undoObj.$filled) { - undoObj.name = name; - undoObj.$filled = true; - } - - //Apply Changes - (xpath ? xmlNode.selectSingleNode(xpath) : xmlNode).removeAttribute(name); - this.applyChanges("attribute", xmlNode, undoObj); - - - this.applyRDB(["removeAttribute", xmlNode, name, xpath], undoObj || {xmlNode: xmlNode}); - - }; - - /** - * Replace one node with another. Changes are propagated to the - * databound elements listening for changes on the data changed. - * - * @param {XMLElement} oldNode The XML node to remove. - * @param {XMLElement} newNode The XML node to set. - * @param {String} [xpath] The xpath statement to select the attribute. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.replaceNode = - apf.replaceNode = function(newNode, oldNode, xpath, undoObj) { - //if(xmlNode.nodeType != 1) xmlNode.nodeValue = value; - - //Apply Changes - if (xpath) - oldNode = oldNode.selectSingleNode(xpath); - - // @todo: only do this once! - should store on the undo object - if (oldNode.ownerDocument.importNode && newNode.ownerDocument != oldNode.ownerDocument) { - var oldNodeS = newNode; - newNode = oldNode.ownerDocument.importNode(newNode, true); //Safari issue not auto importing nodes - if (oldNodeS.parentNode) - oldNodeS.parentNode.removeChild(oldNodeS); - } - - - this.applyRDB(["replaceNode", oldNode, this.cleanXml(newNode.xml), xpath], undoObj || {xmlNode: oldNode}); - - - //Action Tracker Support - if (undoObj && !undoObj.$filled) { - undoObj.$filled = true; - undoObj.oldNode = oldNode; - undoObj.xmlNode = newNode; - } - - this.cleanNode(newNode); - - var parentNode = oldNode.parentNode; - if (!parentNode) - return; - - parentNode.replaceChild(newNode, oldNode); - this.copyConnections(oldNode, newNode); - - this.applyChanges("replacenode", newNode, undoObj); - - return newNode; - }; - - /** - * Creates a new element under a parent XML node. Changes are propagated - * to the databound elements listening for changes on the data changed. - * - * @param {XMLElement} pNode The parent XML node to add the new element to. - * @param {String} tagName The tagName of the {@link term.datanode data node} to add. - * @param {Array} attr list of the attributes to set. Each item is another array with the name and value. - * @param {XMLElement} beforeNode The XML node which indicates the insertion point. - * @param {String} [xpath] The xpath statement to select the attribute. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.addChildNode = - apf.addChildNode = function(pNode, tagName, attr, beforeNode, undoObj) { - //Create New Node - var xmlNode = pNode.insertBefore(pNode.ownerDocument - .createElement(tagName), beforeNode); - - //Set Attributes - for (var i = 0; i < attr.length; i++) - xmlNode.setAttribute(attr[i][0], attr[i][1]); - - //Action Tracker Support - if (undoObj && !undoObj.$filled) { - undoObj.extra.addedNode = xmlNode; - undoObj.$filled = true; - } - - this.applyChanges("add", xmlNode, undoObj); - - - this.applyRDB(["addChildNode", pNode, tagName, attr, beforeNode], undoObj || {xmlNode: pNode}); - - - return xmlNode; - }; - - /** - * Appends an XML node to a parent. Changes are propagated - * to the databound elements listening for changes on the data changed. - * - * @param {XMLElement} pNode The parent XML node to add the element to. - * @param {XMLElement} xmlNode The XML node to insert. - * @param {XMLElement} beforeNode The XML node which indicates the insertion point. - * @param {Boolean} unique Specifies whether the parent can only contain one element with a certain tag name. - * @param {String} [xpath] The xpath statement to select the parent node. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.appendChild = - apf.appendChild = function(pNode, xmlNode, beforeNode, unique, xpath, undoObj) { - if (pNode == xmlNode.parentNode) //Shouldn't this be the same document? - return apf.xmldb.moveNode(pNode, xmlNode, beforeNode, null, xpath, undoObj); - - if (unique && pNode.selectSingleNode(xmlNode.tagName)) - return false; - - // @todo: only do this once! - should store on the undo object - if (pNode.ownerDocument.importNode && pNode.ownerDocument != xmlNode.ownerDocument) { - var oldNode = xmlNode; - xmlNode = pNode.ownerDocument.importNode(xmlNode, true); //Safari issue not auto importing nodes - if (oldNode.parentNode) - oldNode.parentNode.removeChild(oldNode); - } - - - this.applyRDB(["appendChild", pNode, this.cleanXml(xmlNode.xml), beforeNode, unique, xpath], undoObj || {xmlNode: pNode}); - - - //Add xmlNode to parent pNode or one selected by xpath statement - if (xpath) { - var addedNodes = []; - pNode = apf.createNodeFromXpath(pNode, xpath, addedNodes); - if (addedNodes.length) { - pNode.appendChild(xmlNode); - while (addedNodes.length) { - if (pNode == addedNodes.pop() && addedNodes.length) - pNode = pNode.parentNode; - } - } - } - else if (xmlNode.parentNode) - this.removeNode(xmlNode); - - if (undoObj && !undoObj.$filled) { - undoObj.$filled = true; - this.cleanNode(xmlNode); - } - else - this.cleanNode(xmlNode); - - pNode.insertBefore(xmlNode, beforeNode); - - //detect if xmlNode should be removed somewhere else - //- [17-2-2004] changed pNode (2nd arg applychange) into xmlNode - - this.applyChanges("add", xmlNode, undoObj); - - return xmlNode; - }; - - /** - * Moves an XML node to a parent node. Changes are propagated - * to the databound elements listening for changes on the data changed. - * - * @param {XMLElement} pNode The new parent XML node of the node. - * @param {XMLElement} xmlNode The XML node to move. - * @param {XMLElement} beforeNode The XML node which indicates the insertion point. - * @param {String} [xpath] The xpath statement to select the parent node. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.moveNode = - apf.moveNode = function(pNode, xmlNode, beforeNode, xpath, undoObj) { - //Action Tracker Support - if (!undoObj) - undoObj = {extra:{}}; - - undoObj.extra.oldParent = xmlNode.parentNode; - undoObj.extra.beforeNode = xmlNode.nextSibling; - undoObj.extra.parent = (xpath ? pNode.selectSingleNode(xpath) : pNode); - - this.applyChanges("move-away", xmlNode, undoObj); - - //Set new id if the node change document (for safari this should be fixed) - //@todo I don't get this if... - /*if (!apf.isWebkit - && xmlNode.getAttribute(this.xmlIdTag) - && apf.xmldb.getXmlDocId(xmlNode) != apf.xmldb.getXmlDocId(pNode)) { - xmlNode.removeAttribute(this.xmlIdTag)); - this.nodeConnect(apf.xmldb.getXmlDocId(pNode), xmlNode); - }*/ - - // @todo: only do this once! - should store on the undo object - if (pNode.ownerDocument.importNode && pNode.ownerDocument != xmlNode.ownerDocument) { - var oldNode = xmlNode; - xmlNode = pNode.ownerDocument.importNode(xmlNode, true); //Safari issue not auto importing nodes - if (oldNode.parentNode) - oldNode.parentNode.removeChild(oldNode); - } - - - this.applyRDB(["moveNode", pNode, xmlNode, beforeNode, xpath], undoObj || {xmlNode: pNode}); //note: important that transport of rdb is async - - - undoObj.extra.parent.insertBefore(xmlNode, beforeNode); - this.applyChanges("move", xmlNode, undoObj); - }; - - /** - * Removes an XML node from its parent. Changes are propagated - * to the databound elements listening for changes on the data changed. - * - * @param {XMLElement} xmlNode The XML node to remove from the dom tree. - * @param {String} [xpath] The xpath statement to select the parent node. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.removeNode = - apf.removeNode = function(xmlNode, xpath, undoObj) { - if (xpath) - xmlNode = xmlNode.selectSingleNode(xpath); - - //ActionTracker Support - if (undoObj && !undoObj.$filled) { - undoObj.$filled = true; - undoObj.extra.parent = xmlNode.parentNode; - undoObj.extra.removedNode = xmlNode; - undoObj.extra.beforeNode = xmlNode.nextSibling; - } - - - this.applyRDB(["removeNode", xmlNode, xpath], undoObj || {xmlNode: xmlNode}); //note: important that transport of rdb is async - - - //Apply Changes - this.applyChanges("remove", xmlNode, undoObj); - var p = xmlNode.parentNode; - if (!p) - return; - - p.removeChild(xmlNode); - this.applyChanges("redo-remove", xmlNode, null, p);//undoObj - - //@todo clean xmlNode after removal?? - }; - - /** - * Removes a list of XML nodes from their parent. Changes are propagated - * to the databound elements listening for changes on the data changed. - * - * @param {Array} xmlNodeList A list of XML nodes to remove. - * @param {apf.UndoData} [undoObj] The undo object that is responsible for archiving the changes. - */ - this.removeNodeList = - apf.removeNodeList = function(xmlNodeList, undoObj) { - - this.applyRDB(["removeNodeList", xmlNodeList, null], undoObj || {xmlNode: p}); - - - //if(xpath) xmlNode = xmlNode.selectSingleNode(xpath); - for (var rData = [], i = 0; i < xmlNodeList.length; i++) { //This can be optimized by looping nearer to xmlUpdate - //ActionTracker Support - if (undoObj) { - rData.push({ - pNode: xmlNodeList[i].parentNode, - removedNode: xmlNodeList[i], - beforeNode: xmlNodeList[i].nextSibling - }); - } - - //Apply Changes - this.applyChanges("remove", xmlNodeList[i], undoObj); - var p = xmlNodeList[i].parentNode; - p.removeChild(xmlNodeList[i]); - this.applyChanges("redo-remove", xmlNodeList[i], null, p);//undoObj - } - - if (undoObj && !undoObj.$filled) { - undoObj.$filled = true; - undoObj.extra.removeList = rData; - } - }; - - /* - * Looks for this.$listeners and executes their $xmlUpdate methods. - * @private - */ - var notifyQueue = {}, notifyTimer; - this.$hasQueue = false; - this.applyChanges = function(action, xmlNode, undoObj, nextloop) { - if (undoObj && undoObj.$dontapply) return; - - - if (undoObj && !undoObj.xmlNode) //@todo are we sure about this? - undoObj.xmlNode = xmlNode; - - //Set Variables - var oParent = nextloop, - loopNode = (xmlNode.nodeType == 1 ? xmlNode : xmlNode.parentNode); - - //var xmlId = xmlNode.getAttribute(this.xmlIdTag); - - if (!this.delayUpdate && "|remove|move-away|".indexOf("|" + action + "|") > -1) - this.notifyQueued(); //empty queue - - var listen, uId, uIds, i, j, hash, info, amlNode, runTimer, found, done = {}; - while (loopNode && loopNode.nodeType == 1) { - //Get List of Node this.$listeners ID's - listen = loopNode.getAttribute(this.xmlListenTag); - - if (listen) { - uIds = listen.split(";"); - - for (i = 0; i < uIds.length; i++) { - uId = uIds[i]; - if (!uId || done[uId]) continue; - done[uId] = true; - - //Property support - /*if (uId.charAt(0) == "p") { - uId = uId.split("|"); - - //@todo apf3.0 should this be exactly like in class.js? - //@todo optimize this to check the async flag: parsed[3] & 4 - - amlNode = apf.all[uId[1]]; //It's possible the aml node dissapeared in this loop. - if (amlNode) { - var model = apf.all[uId[3]]; - var xpath = model.$propBinds[uId[1]][uId[2]].root; - - amlNode.$execProperty(uId[2], xpath - ? model.data.selectSingleNode(xpath) - : model.data); - } - continue; - }*/ - - hash = notifyQueue[uId]; - if (!hash) - notifyQueue[uId] = hash = []; - - // Filtering - if (!apf.isO3 && "|update|attribute|text|".indexOf("|" + action + "|") > -1) { - found = false; - for (j = 0; j < hash.length; j++) { - if (hash[j] && xmlNode == hash[j][1] - && "|update|attribute|text|" - .indexOf("|" + hash[j][0] + "|") > -1) { - hash[j] = null; - found = true; - continue; - } - } - - hash.push([action, xmlNode, loopNode, undoObj, oParent]); - runTimer = true; - continue; - } - - //!this.delayUpdate && <- that doesnt work because of information that is destroyed - if (apf.isO3 || "|remove|move-away|move|add|".indexOf("|" + action + "|") > -1) { - if (this.$listeners[uId]) { - this.$listeners[uId]([action, xmlNode, - loopNode, undoObj, oParent]); - } - /*amlNode = apf.all[uId]; - if (amlNode) - amlNode.$xmlUpdate(action, xmlNode, - loopNode, undoObj, oParent);*/ - } - else { - hash.push([action, xmlNode, loopNode, undoObj, oParent]); - runTimer = true; - } - } - } - - //Go one level up - loopNode = loopNode.parentNode || nextloop; - if (loopNode == nextloop) - nextloop = null; - } - - if (true || undoObj && !this.delayUpdate) { - //Ok this was an action let's not delay execution - apf.xmldb.notifyQueued(); - } - else if (runTimer) { - apf.setZeroTimeout.clearTimeout(notifyTimer); - //@todo find a better solution for this (at the end of a event stack unroll) - this.$hasQueue = true; - notifyTimer = apf.setZeroTimeout(function(){ - //this.$hasQueue = true; - apf.xmldb.notifyQueued(); - }); - } - }; - - /* - * @todo in actiontracker - add stack auto purging - * - when undo item is purged which was a removed, remove cache item - * @todo shouldn't the removeNode method remove all this.$listeners? - * @todo rename to processQueue - * @private - */ - this.notifyQueued = function(){ - this.$hasQueue = false; - - var myQueue = notifyQueue; - notifyQueue = {}; - - apf.setZeroTimeout.clearTimeout(notifyTimer); - for (var uId in myQueue) { - if (!uId) continue; - - var q = myQueue[uId]; - var func = this.$listeners[uId]; - //!amlNode || - if (!q || !func) - continue; - - //Run queue items - for (var i = 0; i < q.length; i++) { - if (!q[i]) - continue; - - //Update xml data - //amlNode.$xmlUpdate.apply(amlNode, q[i]); - func(q[i]); - } - } - - - }; - - /** - * @private - */ - this.notifyListeners = function(xmlNode) { - //This should be done recursive - var listen = xmlNode.getAttribute(apf.xmldb.xmlListenTag); - if (listen) { - listen = listen.split(";"); - for (var j = 0; j < listen.length; j++) { - apf.all[listen[j]].$xmlUpdate("synchronize", xmlNode, xmlNode); - //load(xmlNode); - } - } - }; - - - /* - * Sends Message through transport to tell remote databound this.$listeners - * that data has been changed - * @private - */ - this.applyRDB = function(args, undoObj) { - return; - - var xmlNode = undoObj.localName || !undoObj.xmlNode - ? args[1] && args[1].length && args[1][0] || args[1] - : undoObj.xmlNode; - - if (xmlNode.nodeType == 2) - xmlNode = xmlNode.ownerElement || xmlNode.selectSingleNode(".."); - - var mdlId = apf.xmldb.getXmlDocId(xmlNode), - model = apf.nameserver.get("model", mdlId); - if (!model && apf.isO3) - model = self[mdlId]; - if (!model) { - if (!apf.nameserver.getAll("remote").length) - return; - - return; - } - - if (!model.rdb) return; - var rdb = model.rdb; - - // Add the messages to the undo object - if (undoObj.action) - rdb.$queueMessage(args, model, undoObj); - // Or send message now - else { - clearTimeout(rdb.queueTimer); - - rdb.$queueMessage(args, model, rdb); - // use a timeout to batch consecutive calls into one RDB call - rdb.queueTimer = $setTimeout(function() { - rdb.$processQueue(rdb); - }); - } - - }; - - - /** - * @private - */ - this.copyConnections = function(fromNode, toNode) { - //This should copy recursive - try { - toNode.setAttribute(this.xmlListenTag, fromNode.getAttribute(this.xmlListenTag)); - } - catch (e) {} - try { - toNode.setAttribute(this.xmlIdTag, fromNode.getAttribute(this.xmlIdTag)); - } - catch (e) {} - }; - - /** - * @private - */ - this.cleanXml = function(xml) { - if (typeof xml != "string") - return xml; - return xml.replace(cleanRE, "").replace(whiteRE, "><"); - }; - - /** - * @private - */ - this.cleanNode = function(xmlNode) { - try { - var i, nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlListenTag + "]"); - for (i = nodes.length - 1; i >= 0; i--) - nodes[i].removeAttribute(this.xmlListenTag); - nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlIdTag + "]"); - for (i = nodes.length - 1; i >= 0; i--) - nodes[i].removeAttribute(this.xmlIdTag); - nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlDocTag + "]"); - for (i = nodes.length - 1; i >= 0; i--) - nodes[i].removeAttribute(this.xmlDocTag); - nodes = xmlNode.selectNodes("descendant-or-self::node()[@a_loaded]"); - for (i = nodes.length - 1; i >= 0; i--) - nodes[i].removeAttribute("a_loaded"); - } - catch (e) {} - - return xmlNode; - }; - - /** - * Returns a copy of the passed {@link term.datanode data node}. Bound - * data nodes contain special attributes to track them. These attributes - * are removed from the copied node when using this method. - * - * @param {XMLElement} xmlNode The {@link term.datanode data node} to copy. - * @return {XMLElement} The copy of the {@link term.datanode data node}. - */ - this.copy = - this.getCleanCopy = - apf.getCleanCopy = function(xmlNode) { - return apf.xmldb.cleanNode(xmlNode.cloneNode(true)); - }; - - /** - * Unbind all APF Elements from a certain Form - * @private - */ - this.unbind = function(frm) { - //Loop through objects of all apf - for (var lookup = {}, i = 0; i < frm.apf.all.length; i++) - if (frm.apf.all[i] && frm.apf.all[i].unloadBindings) - lookup[frm.apf.all[i].unloadBindings()] = true; - - //Remove Listen Nodes - for (var k = 0; k < this.$xmlDocLut.length; k++) { - - if (!this.$xmlDocLut[k]) continue; - - - var Nodes = this.$xmlDocLut[k].selectNodes("//self::node()[@" - + this.xmlListenTag + "]"); - if (!Nodes) continue; - - //Loop through Nodes and rebuild listen array - for (var i = 0; i < Nodes.length; i++) { - var listen = Nodes[i].getAttribute(this.xmlListenTag).split(";"); - for (var nListen = [], j = 0; j < listen.length; j++) - if (!lookup[listen[j]]) - nListen.push(listen[j]); - - //Optimization?? - if (nListen.length != listen.length) - Nodes[i].setAttribute(this.xmlListenTag, nListen.join(";")); - } - } - - if (window.clearInterval) - window.clearInterval(this.$gcInterval); - }; - - /* - * @private - * @todo xml doc leakage - */ - this.getXmlDocId = function(xmlNode, model) { - var docEl = xmlNode.ownerDocument.documentElement; - if (!apf.isChildOf(docEl, xmlNode)) - docEl = xmlNode; - - var docId = (docEl || xmlNode).getAttribute(this.xmlDocTag) - || this.$xmlDocLut.indexOf(docEl || xmlNode.ownerDocument || xmlNode); - - if (model && apf.nameserver.get("model", docId) != model) { - docId = null; - docEl = xmlNode; - } - - if (!docId || docId == -1) { - docId = this.$xmlDocLut.push(docEl || xmlNode.ownerDocument || xmlNode) - 1; - if (docEl) - docEl.setAttribute(this.xmlDocTag, String(docId)); - } - - if (model) - apf.nameserver.register("model", docId, model); - - - return docId; - }; -}); - - - - /** * The parser of the Ajax.org Markup Language. Besides aml this parser takes care * of distributing parsing tasks to other parsers like the native html parser and @@ -17729,40 +16628,6 @@ apf.runNonIe = function (){ defineProp(Array.prototype, "item", function(i){return this[i];}); defineProp(Array.prototype, "expr", ""); - /*try{ - XMLDocument.prototype.readyState = 0; - }catch(e){}*/ - - XMLDocument.prototype.$clearDOM = function(){ - while (this.hasChildNodes()) - this.removeChild(this.firstChild); - }; - - XMLDocument.prototype.$copyDOM = function(oDoc) { - this.$clearDOM(); - - if (oDoc.nodeType == 9 || oDoc.nodeType == 11) { - var oNodes = oDoc.childNodes; - - for (var i = 0; i < oNodes.length; i++) - this.appendChild(this.importNode(oNodes[i], true)); - } - else if (oDoc.nodeType == 1) - this.appendChild(this.importNode(oDoc, true)); - }; - - //XMLDocument.loadXML(); - XMLDocument.prototype.loadXML = function(strXML) { - apf.xmldb.setReadyState(this, 1); - var sOldXML = this.xml || this.serialize(); - var oDoc = (new DOMParser()).parseFromString(strXML, "text/xml"); - apf.xmldb.setReadyState(this, 2); - this.$copyDOM(oDoc); - apf.xmldb.setReadyState(this, 3); - apf.xmldb.loadHandler(this); - return sOldXML; - }; - Node.prototype.getElementById = function(id) {}; HTMLElement.prototype.replaceNode = @@ -17884,21 +16749,6 @@ apf.runNonIe = function (){ return xml; }; - - apf.xmldb.setReadyState = function(oDoc, iReadyState) { - oDoc.readyState = iReadyState; - if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") - oDoc.onreadystatechange(); - }; - - apf.xmldb.loadHandler = function(oDoc) { - if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror") - oDoc.parseError = -1; - - apf.xmldb.setReadyState(oDoc, 4); - }; - - apf.getOpacity = function(oHtml) { return apf.getStyle(oHtml, "opacity");