diff --git a/plugins/c9.ide.ui/lib/dropdown.js b/plugins/c9.ide.ui/lib/dropdown.js index d794e34a..5a7fd182 100644 --- a/plugins/c9.ide.ui/lib/dropdown.js +++ b/plugins/c9.ide.ui/lib/dropdown.js @@ -163,843 +163,6 @@ apf.ChildValue = function(){ -apf.__DATAACTION__ = 1 << 25; - - -/** - * A [[term.baseclass baseclass]] that adds data action features to this element. - * @class apf.DataAction - */ -apf.DataAction = function(){}; - - - -apf.__CACHE__ = 1 << 2; - - -apf.GuiElement.propHandlers["caching"] = function(value) { - debugger -}; - - - - - - - - - - - - - -/** - * The baseclass of elements that allows the user to select one or more items - * out of a list. - * - * @class apf.BaseList - * @baseclass - * - * @inherits apf.MultiSelect - * @inherits apf.Cache - * @inherits apf.DataAction - * @inheritsElsewhere apf.XForms - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.8 - * @default_private - * - */ -/** - * @binding caption Determines the caption of a node. - */ -/** - * @binding icon Determines the icon of a node. -* - * This binding rule is used - * to determine the icon displayed when using a list skin. The {@link baseclass.baselist.binding.image image binding} - * is used to determine the image in the thumbnail skin. - */ -/** - * @binding image Determines the image of a node. - * - * This binding rule is used - * to determine the image displayed when using a thumbnail skin. The {@link baseclass.baselist.binding.icon icon binding} - * is used to determine the icon in the list skin. - * - * #### Example - * - * In this example, the image URL is read from the thumbnail attribute of the data node. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - */ -/** - * @binding css Determines a CSS class for a node. - * - * #### Example - * - * In this example a node is bold when the folder contains unread messages: - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - */ -/** - * @binding tooltip Determines the tooltip of a node. - */ -/** - * @event notunique Fires when the `more` attribute is set and an item is added that has a caption that already exists in the list. - * @param {Object} e The standard event object, with the following properties: - * - value ([[String]]): The value that was entered - */ -apf.BaseList = function() { - this.$init(true); - - - this.$dynCssClasses = []; - - - this.listNodes = []; -}; - -(function() { - - this.implement( - - apf.DataAction, - - - apf.K - ); - - - // *** Properties and Attributes *** // - - this.$focussable = true; // This object can get the focus - this.$isWindowContainer = -1; - - this.multiselect = true; // Initially Disable MultiSelect - - /** - * @attribute {String} fill Sets or gets the set of items that should be loaded into this - * element. Items are seperated by a comma (`,`). Ranges are specified by a start and end value seperated by a dash (`-`). - * - * #### Example - * - * This example loads a list with items starting at 1980 and ending at 2050. It also loads several other items and ranges. - * - * ```xml - * - * - * - * - * - - * ``` - */ - this.$propHandlers["fill"] = function(value) { - if (value) - this.loadFillData(this.getAttribute("fill")); - else - this.clear(); - }; - - - - /** - * @attribute {String} mode Sets or gets the way this element interacts with the user. - * - * The following values are possible: - * - * - `check`: the user can select a single item from this element. The selected item is indicated. - * - `radio`: the user can select multiple items from this element. Each selected item is indicated. - */ - this.$mode = 0; - this.$propHandlers["mode"] = function(value) { - if ("check|radio".indexOf(value) > -1) { - if (!this.hasFeature(apf.__MULTICHECK__)) - this.implement(apf.MultiCheck); - - this.addEventListener("afterrename", $afterRenameMode); //what does this do? - - this.multicheck = value == "check"; //radio is single - this.$mode = this.multicheck ? 1 : 2; - } - else { - this.removeEventListener("afterrename", $afterRenameMode); - //@todo unimplement?? - this.$mode = 0; - } - }; - - //@todo apf3.0 retest this completely - function $afterRenameMode() { - } - - - - // *** Keyboard support *** // - - - - //Handler for a plane list - this.$keyHandler = function(e) { - var key = e.keyCode, - ctrlKey = e.ctrlKey, - shiftKey = e.shiftKey, - selHtml = this.$caret || this.$selected; - - if (e.returnValue == -1 || !selHtml || this.renaming) //@todo how about allowdeselect? - return; - - var selXml = this.caret || this.selected, - oExt = this.$ext, - // variables used in the switch statement below: - node, margin, items, lines, hasScroll, hasScrollX, hasScrollY; - - switch (key) { - case 13: - if (this.$tempsel) - this.$selectTemp(); - - if (this.ctrlselect == "enter") - this.select(this.caret, true); - - this.choose(this.selected); - break; - case 32: - if (ctrlKey || !this.isSelected(this.caret)) - this.select(this.caret, ctrlKey); - break; - case 109: - case 46: - //DELETE - if (this.disableremove) - return; - - if (this.$tempsel) - this.$selectTemp(); - - this.remove(); - break; - case 36: - //HOME - var node = this.getFirstTraverseNode(); - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node); - - - this.select(node, false, shiftKey); - this.$container.scrollTop = 0; - break; - case 35: - //END - var node = this.getLastTraverseNode(); - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node, true); - - - this.select(node, false, shiftKey); - this.$container.scrollTop = this.$container.scrollHeight; - break; - case 107: - //+ - if (this.more) - this.startMore(); - break; - case 37: - //LEFT - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - items = selHtml.offsetWidth - ? Math.floor((oExt.offsetWidth - - (hasScroll ? 15 : 0)) / (selHtml.offsetWidth - + margin[1] + margin[3])) - : 1; - - //margin = apf.getBox(apf.getStyle(selHtml, "margin")); - - node = this.getNextTraverseSelected(node, false); - if (node) - this.$setTempSelected(node, ctrlKey, shiftKey, true); - else - return; - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop < oExt.scrollTop) { - oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items - ? 0 - : selHtml.offsetTop - margin[0]; - } - break; - case 38: - //UP - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - hasScroll = oExt.scrollHeight > oExt.offsetHeight; - items = selHtml.offsetWidth - ? Math.floor((oExt.offsetWidth - - (hasScroll ? 15 : 0)) / (selHtml.offsetWidth - + margin[1] + margin[3])) - : 1; - - node = this.getNextTraverseSelected(node, false, items); - if (node) - this.$setTempSelected (node, ctrlKey, shiftKey, true); - else - return; - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node); - - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop < oExt.scrollTop) { - oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items - ? 0 - : selHtml.offsetTop - margin[0]; - } - break; - case 39: - //RIGHT - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - node = this.getNextTraverseSelected(node, true); - if (node) - this.$setTempSelected (node, ctrlKey, shiftKey); - else - return; - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop + selHtml.offsetHeight - > oExt.scrollTop + oExt.offsetHeight) { - oExt.scrollTop = selHtml.offsetTop - - oExt.offsetHeight + selHtml.offsetHeight - + margin[0]; - } - break; - case 40: - //DOWN - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - hasScroll = oExt.scrollHeight > oExt.offsetHeight; - items = selHtml.offsetWidth - ? Math.floor((oExt.offsetWidth - - (hasScroll ? 15 : 0)) / (selHtml.offsetWidth - + margin[1] + margin[3])) - : 1; - - node = this.getNextTraverseSelected(node, true, items); - if (node) - this.$setTempSelected (node, ctrlKey, shiftKey); - else - return; - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node, true); - - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop + selHtml.offsetHeight - > oExt.scrollTop + oExt.offsetHeight) { // - (hasScroll ? 10 : 0) - oExt.scrollTop = selHtml.offsetTop - - oExt.offsetHeight + selHtml.offsetHeight - + margin[0]; //+ (hasScroll ? 10 : 0) - } - break; - case 33: - //PGUP - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - hasScrollY = oExt.scrollHeight > oExt.offsetHeight; - hasScrollX = oExt.scrollWidth > oExt.offsetWidth; - items = Math.floor((oExt.offsetWidth - - (hasScrollY ? 15 : 0)) / (selHtml.offsetWidth - + margin[1] + margin[3])); - lines = Math.floor((oExt.offsetHeight - - (hasScrollX ? 15 : 0)) / (selHtml.offsetHeight - + margin[0] + margin[2])); - - node = this.getNextTraverseSelected(node, false, items * lines); - if (!node) - node = this.getFirstTraverseNode(); - if (node) - this.$setTempSelected (node, ctrlKey, shiftKey, true); - else - return; - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node); - - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop < oExt.scrollTop) { - oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items - ? 0 - : selHtml.offsetTop - margin[0]; - } - break; - case 34: - //PGDN - if (!selXml && !this.$tempsel) - return; - - node = this.$tempsel - ? apf.xmldb.getNode(this.$tempsel) - : selXml; - - margin = apf.getBox(apf.getStyle(selHtml, "margin")); - hasScrollY = oExt.scrollHeight > oExt.offsetHeight; - hasScrollX = oExt.scrollWidth > oExt.offsetWidth; - items = Math.floor((oExt.offsetWidth - (hasScrollY ? 15 : 0)) - / (selHtml.offsetWidth + margin[1] + margin[3])); - lines = Math.floor((oExt.offsetHeight - (hasScrollX ? 15 : 0)) - / (selHtml.offsetHeight + margin[0] + margin[2])); - - node = this.getNextTraverseSelected(selXml, true, items * lines); - if (!node) - node = this.getLastTraverseNode(); - if (node) - this.$setTempSelected (node, ctrlKey, shiftKey); - else - return; - - - if (this.hasFeature(apf.__VIRTUALVIEWPORT__)) - return this.$viewport.scrollIntoView(node, true); - - - selHtml = apf.xmldb.findHtmlNode(node, this); - if (selHtml.offsetTop + selHtml.offsetHeight - > oExt.scrollTop + oExt.offsetHeight) { // - (hasScrollY ? 10 : 0) - oExt.scrollTop = selHtml.offsetTop - - oExt.offsetHeight + selHtml.offsetHeight - + margin[0]; //+ 10 + (hasScrollY ? 10 : 0) - } - break; - - default: - if (key == 65 && ctrlKey) { - this.selectAll(); - } - else if (this.$hasBindRule("caption")) { - if (!this.xmlRoot || this.autorename) return; - - //this should move to a onkeypress based function - if (!this.lookup || new Date().getTime() - - this.lookup.date.getTime() > 300) { - this.lookup = { - str: "", - date: new Date() - }; - } - - this.lookup.str += String.fromCharCode(key); - - var nodes = this.getTraverseNodes(); //@todo start at current indicator - for (var v, i = 0; i < nodes.length; i++) { - v = this.$applyBindRule("caption", nodes[i]); - if (v && v.substr(0, this.lookup.str.length) - .toUpperCase() == this.lookup.str) { - - if (!this.isSelected(nodes[i])) { - this.select(nodes[i]); - } - - if (selHtml) { - this.$container.scrollTop = selHtml.offsetTop - - (this.$container.offsetHeight - - selHtml.offsetHeight) / 2; - } - return; - } - } - return; - } - break; - } - - this.lookup = null; - return false; - }; - - - - // *** Private databinding functions *** // - - this.$deInitNode = function(xmlNode, htmlNode) { - if (!htmlNode) return; - - //Remove htmlNodes from tree - htmlNode.parentNode.removeChild(htmlNode); - }; - - this.$updateNode = function(xmlNode, htmlNode, noModifier) { - //Update Identity (Look) - var elIcon = this.$getLayoutNode("item", "icon", htmlNode); - - if (elIcon) { - if (elIcon.nodeType == 1) { - elIcon.style.backgroundImage = "url(" + - apf.getAbsolutePath(this.iconPath, - this.$applyBindRule("icon", xmlNode)) + ")"; - } - else { - elIcon.nodeValue = apf.getAbsolutePath(this.iconPath, - this.$applyBindRule("icon", xmlNode)); - } - } - else { - //.style.backgroundImage = "url(" + this.$applyBindRule("image", xmlNode) + ")"; - var elImage = this.$getLayoutNode("item", "image", htmlNode); - if (elImage) { - if (elImage.nodeType == 1) { - elImage.style.backgroundImage = "url(" + - apf.getAbsolutePath(apf.hostPath, - this.$applyBindRule("image", xmlNode)) + ")"; - } - else { - elImage.nodeValue = apf.getAbsolutePath(apf.hostPath, - this.$applyBindRule("image", xmlNode)); - } - } - } - - var elCaption = this.$getLayoutNode("item", "caption", htmlNode); - if (elCaption) { - if (elCaption.nodeType == 1) { - - elCaption.innerHTML = this.$applyBindRule("caption", xmlNode); - } - else - elCaption.nodeValue = this.$applyBindRule("caption", xmlNode); - } - - - //@todo - - - htmlNode.title = this.$applyBindRule("title", xmlNode) || ""; - - - var cssClass = this.$applyBindRule("css", xmlNode); - - if (cssClass || this.$dynCssClasses.length) { - this.$setStyleClass(htmlNode, cssClass, this.$dynCssClasses); - if (cssClass && !this.$dynCssClasses.contains(cssClass)) { - this.$dynCssClasses.push(cssClass); - } - } - - - if (!noModifier && this.$updateModifier) - this.$updateModifier(xmlNode, htmlNode); - }; - - this.$moveNode = function(xmlNode, htmlNode) { - if (!htmlNode) return; - - var oPHtmlNode = htmlNode.parentNode; - var nNode = this.getNextTraverse(xmlNode); //@todo could optimize because getTraverseNodes returns array indexOf - var beforeNode = nNode - ? apf.xmldb.findHtmlNode(nNode, this) - : null; - - oPHtmlNode.insertBefore(htmlNode, beforeNode); - //if(this.emptyMessage && !oPHtmlNode.childNodes.length) this.setEmpty(oPHtmlNode); - }; - - this.$add = function(xmlNode, Lid, xmlParentNode, htmlParentNode, beforeNode) { - - }; - - this.addEventListener("$skinchange", function(e) { - if (this.more) - delete this.moreItem; - }); - - this.$fill = function() { - if (this.more && !this.moreItem) { - this.$getNewContext("item"); - var Item = this.$getLayoutNode("item"), - elCaption = this.$getLayoutNode("item", "caption"), - elSelect = this.$getLayoutNode("item", "select"); - - Item.setAttribute("class", this.$baseCSSname + "More"); - elSelect.setAttribute("onmousedown", 'var o = apf.lookup(' + this.$uniqueId - + ');o.clearSelection();o.$setStyleClass(this, "more_down", null, true);'); - elSelect.setAttribute("onmouseout", 'apf.lookup(' + this.$uniqueId - + ').$setStyleClass(this, "", ["more_down"], true);'); - elSelect.setAttribute("onmouseup", 'apf.lookup(' + this.$uniqueId - + ').startMore(this, true)'); - - if (elCaption) - apf.setNodeValue(elCaption, - this.more.match(/caption:(.*)(;|$)/i)[1]); - this.listNodes.push(Item); - } - - apf.insertHtmlNodes(this.listNodes, this.$container); - this.listNodes.length = 0; - - if (this.more && !this.moreItem) { - this.moreItem = this.$container.lastChild; - } - - }; - - /** - * Adds a new item to the list, and lets the users type in the new name. - * - * This functionality is especially useful in the interface when - * the list mode is set to `check` or `radio`--for instance in a form. - */ - this.startMore = function(o, userAction) { - if (userAction && this.disabled) - return; - - this.$setStyleClass(o, "", ["more_down"]); - - var xmlNode; - if (!this.$actions["add"]) { - if (this.each && !this.each.match(/[\/\[]/)) { - xmlNode = "<" + this.each + (this.each.match(/^a:/) - ? " xmlns:a='" + apf.ns.aml + "'" - : "") + " custom='1' />"; - } - else { - - //return false; - xmlNode = ""; - } - } - - this.add(xmlNode, null, null, function(addedNode) { - this.select(addedNode, null, null, null, null, true); - if (this.morePos == "begin") - this.$container.insertBefore(this.moreItem, this.$container.firstChild); - else - this.$container.appendChild(this.moreItem); - - var undoLastAction = function() { - this.getActionTracker().undo(this.autoselect ? 2 : 1); - - this.removeEventListener("stoprename", undoLastAction); - this.removeEventListener("beforerename", removeSetRenameEvent); - this.removeEventListener("afterrename", afterRename); - } - var afterRename = function() { - //this.select(addedNode); - this.removeEventListener("afterrename", afterRename); - }; - var removeSetRenameEvent = function(e) { - this.removeEventListener("stoprename", undoLastAction); - this.removeEventListener("beforerename", removeSetRenameEvent); - - //There is already a choice with the same value - var xmlNode = this.findXmlNodeByValue(e.args[1]); - if (xmlNode || !e.args[1]) { - if (e.args[1] && this.dispatchEvent("notunique", { - value: e.args[1] - }) === false) { - this.startRename(); - - this.addEventListener("stoprename", undoLastAction); - this.addEventListener("beforerename", removeSetRenameEvent); - } - else { - this.removeEventListener("afterrename", afterRename); - - this.getActionTracker().undo();//this.autoselect ? 2 : 1); - if (!this.isSelected(xmlNode)) - this.select(xmlNode); - } - - return false; - } - }; - - this.addEventListener("stoprename", undoLastAction); - this.addEventListener("beforerename", removeSetRenameEvent); - this.addEventListener("afterrename", afterRename); - - - this.startDelayedRename({}, 1); - - }); - }; - - // *** Selection *** // - - this.$calcSelectRange = function(xmlStartNode, xmlEndNode) { - var r = [], - nodes = this.hasFeature(apf.__VIRTUALVIEWPORT__) - ? this.xmlRoot.selectNodes(this.each) - : this.getTraverseNodes(), - f, i; - for (f = false, i = 0; i < nodes.length; i++) { - if (nodes[i] == xmlStartNode) - f = true; - if (f) - r.push(nodes[i]); - if (nodes[i] == xmlEndNode) - f = false; - } - - if (!r.length || f) { - r = []; - for (f = false, i = nodes.length - 1; i >= 0; i--) { - if (nodes[i] == xmlStartNode) - f = true; - if (f) - r.push(nodes[i]); - if (nodes[i] == xmlEndNode) - f = false; - } - } - - return r; - }; - - this.$selectDefault = function(XMLRoot) { - this.select(this.getTraverseNodes()[0], null, null, null, true); - }; - - /** - * Generates a list of items based on a string. - * @param {String} str The description of the items. Items are seperated by a comma (`,`). Ranges are specified by a start and end value seperated by a dash (`-`). - * - * #### Example - * - * This example loads a list with items starting at 1980 and ending at 2050. - * - * #### ```xml - * lst.loadFillData("1980-2050"); - * lst.loadFillData("red,green,blue,white"); - * lst.loadFillData("None,100-110,1000-1100"); // 101, 102...110, 1000,1001, e.t.c. - * lst.loadFillData("1-10"); // 1 2 3 4 e.t.c. - * lst.loadFillData("01-10"); //01, 02, 03, 04, e.t.c. - * ``` - */ - this.loadFillData = function(str) { - var len, start, end, parts = str.splitSafe(","), data = []; - - for (var p, part, i = 0; i < parts.length; i++) { - if ((part = parts[i]).match(/^\d+-\d+$/)) { - p = part.split("-"); - start = parseInt(p[0]); - end = parseInt(p[1]); - - if (p[0].length == p[1].length) { - len = Math.max(p[0].length, p[1].length); - for (var j = start; j < end + 1; j++) { - data.push("" + (j + "").pad(len, "0") + ""); - } - } - else { - for (var j = start; j < end + 1; j++) { - data.push("" + j + ""); - } - } - } - else { - data.push("" + part + ""); - } - } - - //@todo this is all an ugly hack (copied from item.js line 486) - //this.$preventDataLoad = true;//@todo apf3.0 add remove for this - - this.$initingModel = true; - - this.each = "item"; - this.$setDynamicProperty("caption", "[label/text()|@caption|text()]"); - this.$setDynamicProperty("eachvalue", "[value/text()|@value|text()]"); - this.$canLoadDataAttr = false; - - this.load("" + data.join("") + ""); - }; - -}).call(apf.BaseList.prototype = new apf.MultiSelect()); - - - @@ -1098,8 +261,6 @@ apf.BaseList = function() { * @allowchild item, {smartbinding} * * - * @inherits apf.BaseList - * * @author Ruben Daniels (ruben AT ajax DOT org) * @version %I%, %G% * @since 0.4 @@ -1483,7 +644,7 @@ apf.dropdown = function(struct, tagName) { }; -}).call(apf.dropdown.prototype = new apf.BaseList()); +}).call(apf.dropdown.prototype = new apf.Presentation()); apf.config.$inheritProperties["initial-message"] = 1; @@ -1494,300 +655,6 @@ apf.aml.setElement("dropdown", apf.dropdown); - - - - - - - - -/** - * This element displays a skinnable list of options which can be selected. - * - * Selection of multiple items is allowed. Items can be renamed - * and removed. The list can be used as a collection of checkboxes or - * radiobuttons. This is especially useful for use in forms. - * - * This element is one of the most often used elements. It can display lists - * of items in a CMS-style interface, or display a list of search results in - * a more website like interface. - * - * #### Example: A Simple List - * - * ```xml, demo - * - * - * - * The Netherlands - * United States of America - * United Kingdom - * - * - * - * ``` - * - * #### Example: Loading from a Model - * - * ```xml, demo - * - * - * - * - * - * - * ``` - * - * #### Example: Using XPaths - * - * ```xml, demo - * - * - * - * - * - * - * - * - * - * - * - * ``` - * @class apf.list - * @define list - * @allowchild {smartbinding} - * - * @selection - * @inherits apf.BaseList - * @inherits apf.Rename - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.4 - */ -/** - * @event click Fires when a user presses a mouse button while over this element. - */ - -apf.list = function(struct, tagName) { - this.$init(tagName || "list", apf.NODE_VISIBLE, struct); -}; - -(function() { - this.morePos = "end"; - - - - this.$getCaptionElement = function() { - if (!(this.$caret || this.$selected)) - return; - - var x = this.$getLayoutNode("item", "caption", this.$caret || this.$selected); - if (!x) - return; - return x.nodeType == 1 ? x : x.parentNode; - }; - - - - - - - - // *** Properties and Attributes *** // - - this.$supportedProperties.push("appearance", "mode", "more", "thumbsize", "morepos"); - - this.$propHandlers["morepos"] = function(value) { - this.morePos = value; - }; - - this.$propHandlers["thumbsize"] = function(value) { - var className = this.thumbclass; - - apf.setStyleRule(className, "width", value + "px"); - apf.setStyleRule(className, "height", value + "px"); - }; - - - /** - * @attribute {String} appearance Sets or gets the type of select this element is. - * This is an xforms property and only available if APF is compiled - * with `__WITH_XFORMS` set to `1`. - * - * Possible values include: - * - * - `"full"` : depending on the tagName this element is either a list of radio options or of checked options. - * - `"compact"`: this elements functions like a list with multiselect off. - * - `"minimal"`: this element functions as a dropdown element. - */ - this.$propHandlers["appearance"] = function(value) { - - }; - - - /** - * @attribute {String} more Adds a new item to the list and lets the users - * type in the new name. This is especially useful in the interface when - * the mode is set to check or radio--for instance in a form. - * - * #### Example - * - * This example shows a list in form offering the user several options. The - * user can add a new option. A server script could remember the addition - * and present it to all new users of the form. - * - * ```xml - * - * - * - * Suggestion 1 - * Suggestion 2 - * - * - * - * Which newspapers do you read? - * - * - * - * - * - * - * - * - * - * - * New Answer - * - * - * - * ``` - */ - this.$propHandlers["more"] = function(value) { - if (value) { - this.delayedselect = false; - this.addEventListener("xmlupdate", $xmlUpdate); - this.addEventListener("afterload", $xmlUpdate); - //this.addEventListener("afterrename", $afterRenameMore); - //this.addEventListener("beforeselect", $beforeSelect); - - this.$addMoreItem = function(msg) { - if (!this.moreItem) - this.$fill(); - if (this.morePos == "begin") - this.$container.insertBefore(this.moreItem, this.$container.firstChild); - else - this.$container.appendChild(this.moreItem); - }; - this.$updateClearMessage = function(){} - this.$removeClearMessage = function() {}; - } - else { - this.removeEventListener("xmlupdate", $xmlUpdate); - this.removeEventListener("afterload", $xmlUpdate); - //this.removeEventListener("afterrename", $afterRenameMore); - //this.removeEventListener("beforeselect", $beforeSelect); - } - }; - - function $xmlUpdate(e) { - if ((!e.action || "insert|add|synchronize|move".indexOf(e.action) > -1) && this.moreItem) { - if (this.morePos == "begin") - this.$container.insertBefore(this.moreItem, this.$container.firstChild); - else - this.$container.appendChild(this.moreItem); - } - } - - /*function $afterRenameMore(){ - var caption = this.$applyBindRule("caption", this.caret) - var xmlNode = this.findXmlNodeByValue(caption); - - var curNode = this.caret; - if (xmlNode != curNode || !caption) { - if (xmlNode && !this.isSelected(xmlNode)) - this.select(xmlNode); - this.remove(curNode); - } - else - if (!this.isSelected(curNode)) - this.select(curNode); - } - - function $beforeSelect(e) { - //This is a hack - if (e.xmlNode && this.isSelected(e.xmlNode) - && e.xmlNode.getAttribute('custom') == '1') { - this.setCaret(e.xmlNode); - this.selected = e.xmlNode; - $setTimeout(function(){ - _self.startRename() - }); - return false; - } - }*/ - - - // *** Keyboard support *** // - - - this.addEventListener("keydown", this.$keyHandler, true); - - - // *** Init *** // - - this.$draw = function() { - this.appearance = this.getAttribute("appearance") || "compact"; - - //Build Main Skin - this.$ext = this.$getExternal(); - this.$container = this.$getLayoutNode("main", "container", this.$ext); - - var _self = this; - this.$ext.onclick = function(e) { - _self.dispatchEvent("click", { - htmlEvent: e || event - }); - } - - - - //Get Options form skin - //Types: 1=One dimensional List, 2=Two dimensional List - this.listtype = parseInt(this.$getOption("main", "type")) || 1; - //Types: 1=Check on click, 2=Check independent - this.behaviour = parseInt(this.$getOption("main", "behaviour")) || 1; - - this.thumbsize = this.$getOption("main", "thumbsize"); - this.thumbclass = this.$getOption("main", "thumbclass"); - }; - - this.$loadAml = function(x) { - }; - - this.$destroy = function() { - if (this.$ext) - this.$ext.onclick = null; - apf.destroyHtmlNode(this.oDrag); - this.oDrag = null; - }; -}).call(apf.list.prototype = new apf.BaseList()); - -apf.aml.setElement("list", apf.list); - - - - - }; }); \ No newline at end of file diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index 37bc4980..d83c308d 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -1009,27 +1009,6 @@ apf.Class.prototype = new (function(){ //Check if property has changed if (isChanged) { - if (!forceOnMe) { //Recursion protection - //Check if this property is bound to data - if (typeof value != OBJ //this.xmlRoot && - && (!(s = {}[prop]))// || s == 2 - && (r = (this.$attrBindings && this.$attrBindings[prop] - || prop != VALUE && this.xmlRoot && this.$bindings[prop] - && this.$bindings[prop][0]))) { - - //Check if rule has single xpath - if (r.cvalue.type == 3) { - - - //Set the xml value - this should probably use execProperty - return apf.setNodeValue( - this.$getDataNode(prop.toLowerCase(), this.xmlRoot, true), - value, true); - } - } - - } - if (setAttr && !this.$funcHandlers[prop]) this.setAttribute(prop, value, true); @@ -2771,8 +2750,8 @@ apf.plane = { if (!_self.options || !_self.options.customCover) return obj; - obj.innerHTML = apf.getXmlString(_self.options.customCover); - return obj.firstChild; + debugger + return obj; } function createCover(){ @@ -4070,128 +4049,6 @@ apf.getChildNumber = function(node, fromList) { return -1; }; - - // @todo More information will follow....when? -/** - * Integrates nodes as children of a parent. Optionally, attributes are - * copied as well. - * - * @param {XMLNode} xmlNode The data to merge. - * @param {XMLNode} parent The node to merge on. - * @param {Object} options An object with the following optional properties: - * - [copyAttributes] ([[Boolean]]): Whether the attributes of `xmlNode` are copied as well. - * - [clearContents] ([[Boolean]]): Whether the contents of parent is cleared. - * - [start] ([[Number]]): This feature is used for the virtual viewport. More information will follow. - * - [length] ([[Number]]): This feature is used for the virtual viewport. More information will follow. - * - [documentId] ([[Number]]): This feature is used for the virtual viewport. More information will follow. - * - [marker] ([[XMLElement]]): This feature is used for the virtual viewport. More information will follow. - * @return {XMLNode} The created xml node - */ -apf.mergeXml = function(XMLRoot, parentNode, options) { - if (typeof parentNode != "object") - parentNode = apf.xmldb.getElementById(parentNode); - - if (options && options.clearContents) { - //Signal listening elements - var node, j, i, - nodes = parentNode.selectNodes("descendant::node()[@" + apf.xmldb.xmlListenTag + "]"); - for (i = nodes.length - 1; i >= 0; i--) { - var s = nodes[i].getAttribute(apf.xmldb.xmlListenTag).split(";"); - for (j = s.length - 1; j >= 0; j--) { - node = apf.all[s[j]]; - if (!node) continue; - if (node.dataParent && node.dataParent.xpath) - node.dataParent.parent.signalXmlUpdate[node.$uniqueId] = true; - else if (node.$model) - node.$model.$waitForXml(node); - } - } - - //clean parent - nodes = parentNode.childNodes; - for (i = nodes.length - 1; i >= 0; i--) - apf.xmldb.removeNode(nodes[i]); - // parentNode.removeChild(nodes[i]); - } - - - if (options && options.start) { //Assuming each node is in count - var reserved, beforeNode, nodes, doc, i, l, marker = options.marker; - if (!marker) { - //optionally find marker - } - - //This code assumes that the dataset fits inside this marker - - //Start of marker - if (marker.getAttribute("start") - options.start == 0) { - marker.setAttribute("start", options.start + options.length); - reserved = parseInt(marker.getAttribute("reserved"), 10); - marker.setAttribute("reserved", reserved + options.length); - beforeNode = marker; - } - //End of marker - else if (options.start + options.length == marker.getAttribute("end")) { - marker.setAttribute("end", options.start + options.length); - beforeNode = marker.nextSibling; - reserved = parseInt(marker.getAttribute("reserved"), 10) + - parseInt(marker.getAttribute("end"), 10) - options.length; - } - //Middle of marker - else { - var m2 = marker.parentNode.insertBefore(marker.cloneNode(true), marker); - m2.setAttribute("end", options.start - 1); - marker.setAttribute("start", options.start + options.length); - reserved = parseInt(marker.getAttribute("reserved"), 10); - marker.setAttribute("reserved", reserved + options.length); - beforeNode = marker; - } - - nodes = XMLRoot.childNodes; - - if (parentNode.ownerDocument.importNode) { - doc = parentNode.ownerDocument; - for (i = 0, l = nodes.length; i < l; i++) { - parentNode.insertBefore(doc.importNode(nodes[i], true), beforeNode) - .setAttribute(apf.xmldb.xmlIdTag, options.documentId + "|" + (reserved + i)); - } - } - else { - for (i = nodes.length - 1; i >= 0; i--) { - parentNode.insertBefore(nodes[0], beforeNode) - .setAttribute(apf.xmldb.xmlIdTag, options.documentId + "|" + (reserved + i)); - } - } - } - else - - { - beforeNode = options && options.beforeNode ? options.beforeNode : apf.getNode(parentNode, [0]); - nodes = XMLRoot.childNodes; - - if (options.filter) - nodes = options.filter(parentNode, nodes); - - if (parentNode.ownerDocument.importNode) { - doc = parentNode.ownerDocument; - for (i = 0, l = nodes.length; i < l; i++) - parentNode.insertBefore(doc.importNode(nodes[i], true), beforeNode); - } - else - for (i = nodes.length - 1; i >= 0; i--) - parentNode.insertBefore(nodes[0], beforeNode); - } - - if (options && options.copyAttributes) { - var attr = XMLRoot.attributes; - for (i = 0; i < attr.length; i++) - if (attr[i].nodeName != apf.xmldb.xmlIdTag) - parentNode.setAttribute(attr[i].nodeName, attr[i].nodeValue); - } - - return parentNode; -}; - /** * Sets the node value of a DOM node. * @@ -4201,118 +4058,25 @@ apf.mergeXml = function(XMLRoot, parentNode, options) { * @param {Boolean} applyChanges Whether the changes are propagated to the databound elements. * @param {apf.UndoData} undoObj The undo object that is responsible for archiving the changes. */ -apf.setNodeValue = function(xmlNode, nodeValue, applyChanges, options) { +apf.setNodeValue = function(xmlNode, nodeValue) { if (!xmlNode) return; - var undoObj, xpath, newNodes; - if (options) { - undoObj = options.undoObj; - xpath = options.xpath; - newNodes = options.newNodes; - - undoObj.extra.oldValue = options.forceNew - ? "" - : apf.queryValue(xmlNode, xpath); - - undoObj.xmlNode = xmlNode; - if (xpath) { - xmlNode = apf.createNodeFromXpath(xmlNode, xpath, newNodes, options.forceNew); - } - - undoObj.extra.appliedNode = xmlNode; - } - if (xmlNode.nodeType == 1) { if (!xmlNode.firstChild) xmlNode.appendChild(xmlNode.ownerDocument.createTextNode("")); xmlNode.firstChild.nodeValue = apf.isNot(nodeValue) ? "" : nodeValue; - - if (applyChanges) - apf.xmldb.applyChanges("text", xmlNode, undoObj); } else { - // @todo: this should be fixed in libxml - if (apf.isO3 && xmlNode.nodeType == 2) - nodeValue = nodeValue.replace(/&/g, "&"); - var oldValue = xmlNode.nodeValue; xmlNode.nodeValue = nodeValue === undefined || nodeValue === null || nodeValue == NaN ? "" : String(nodeValue); - if (undoObj) { - undoObj.name = xmlNode.nodeName; - } - //AML support - getters/setters would be awesome if (xmlNode.$triggerUpdate) xmlNode.$triggerUpdate(null, oldValue); - - if (applyChanges) { - apf.xmldb.applyChanges(xmlNode.nodeType == 2 ? "attribute" : "text", xmlNode.parentNode || - xmlNode.ownerElement || xmlNode.selectSingleNode(".."), undoObj); - } } - - - if (applyChanges) { - var node; - if (xpath) { - var node = undoObj.xmlNode;//.selectSingleNode(newNodes.foundpath); - if (node.nodeType == 9) { - node = node.documentElement; - xpath = xpath.replace(/^[^\/]*\//, "");//xpath.substr(newNodes.foundpath.length); - } - } - else - node = xmlNode; - - apf.xmldb.applyRDB(["setValueByXpath", node, nodeValue, xpath, - options && options.forceNew], - undoObj || {xmlNode: xmlNode} - ); - } - -}; - -/** - * Sets a value of an XML node based on an xpath statement executed on a referenced XMLNode. - * - * @param {XMLNode} xmlNode The reference XML node. - * @param {String} xpath The xpath used to select a XML node. - * @param {String} value The value to set. - * @param {Boolean} local Whether the call updates databound UI. - * @return {XMLNode} The changed XML node - */ -apf.setQueryValue = function(xmlNode, xpath, value, local) { - var node = apf.createNodeFromXpath(xmlNode, xpath); - if (!node) - return null; - - apf.setNodeValue(node, value, !local); - //apf.xmldb.setTextNode(node, value); - return node; -}; - -/** - * Removes an XML node based on an xpath statement executed on a referenced XML node. - * - * @param {XMLNode} xmlNode The reference XML node. - * @param {String} xpath The xpath used to select a XML node. - * @return {XMLNode} The changed XML node - */ -apf.removeQueryNode = function(xmlNode, xpath, local) { - var node = apf.queryNode(xmlNode, xpath); - if (!node) - return false; - - if (local) - node.parentNode.removeChild(node); - else - apf.xmldb.removeNode(node); - - return node; }; /** @@ -4583,17 +4347,6 @@ apf.serializeChildren = function(xmlNode) { return s.join(""); }; -/** - * Returns a string version of the {@link term.datanode data node}. - * - * @param {XMLElement} xmlNode The {@link term.datanode data node} to serialize. - * @return {String} The serialized version of the {@link term.datanode data node}. - */ -apf.getXmlString = function(xmlNode) { - var xml = apf.xmldb.cleanNode(xmlNode.cloneNode(true)); - return xml.xml || xml.serialize(); -}; - /** * Creates XML nodes from an XML string recursively. * @@ -4820,115 +4573,6 @@ apf.extend(apf.config, { - - - -/** - * Creates a model object based on a {@link term.datainstruction data instruction}. - * - * @param {String} instruction The {@link term.datainstruction data instruction} to be used to retrieve the data for the model - * @param {apf.AmlNode} amlNode The element the model is added to - */ -apf.setModel = function(instruction, amlNode) { - if (!instruction) return; - - //Find existing model - var fParsed = instruction.indexOf("{") > -1 || instruction.indexOf("[") > -1 - ? apf.lm.compile(instruction, { - //precall : false, - alwayscb: true - }) - : { - type: 2, - str: instruction - }; - - if (instruction == "@default" || fParsed.type == 2) { - - var model = apf.nameserver.get("model", instruction); - if (model) - return model.register(amlNode); - else - - if (instruction == "@default") - return; - - //@todo apf3.0 check here if string is valid url (relative or absolute) - if (instruction.indexOf(".") == -1 && instruction.indexOf("/") == -1) { - - return; - } - } - - //Just an xpath doesnt work. We don't have context - //var l, x; - if (fParsed.type == 3) {//This won't work for complex xpaths - if (fParsed.models) { //check for # in xpaths[i] to determine if its calculated - if (fParsed.xpaths.length == 2 && fParsed.xpaths[0] != '#' && fParsed.xpaths [1] != '#') { - - - - apf.nameserver.get("model", fParsed.xpaths[0]).register(amlNode, fParsed.xpaths[1]); - - return; - } - } - - } - - if (amlNode.clear) - amlNode.clear("loading"); - - //Complex data fetch (possibly async) - data is loaded only once. - //Potential property binding has to take of the rest - apf.getData(instruction, { - parsed: fParsed, - xmlNode: amlNode && amlNode.xmlRoot, - callback: function(data, state, extra) { - //@todo apf3.0 call onerror on amlNode - if (state != apf.SUCCESS) { - throw new Error(apf.formatErrorString(0, null, - "Loading new data", "Could not load data into model. \ - \nMessage: " + extra.message + "\ - \nInstruction: '" + instruction + "'")); - } - - if (!data) - return amlNode.clear && amlNode.clear(); - - if (typeof data == "string") { - if (data.charAt(0) == "<") - data = apf.getXml(data); - else { - //Assuming web service returned url - if (data.indexOf("http://") == 0) - return apf.setModel(data, amlNode); - else { - throw new Error("Invalid data from server");//@todo apf3.0 make proper apf error handling. apf.onerror - } - } - } - - if (data.nodeFunc) { //Assuming a model was passed -- data.localName == "model" && - data.register(amlNode); - return; - } - - var model = apf.xmldb.findModel(data); //See if data is already loaded into a model - if (model) - model.register(amlNode, apf.xmlToXpath(data, model.data)); //@todo move function to xml library - else - new apf.model().register(amlNode).load(data); - }}); -}; - - - - - - - - /* * @version: 1.0 Alpha-1 * @author: Coolite Inc. http://www.coolite.com/ @@ -5969,107 +5613,6 @@ apf.setModel = function(instruction, amlNode) { - - -/** - * @class apf.layout - * - * Takes care of the spatial order of elements within the display area - * of the browser. Layouts can be saved to XML and loaded again. Window - * elements are dockable, which means the user can change the layout as s/he - * wishes. The state of the layout can be saved as XML at any time. - * - * #### Example - * - * This example shows five windows which have a layout defined in layout.xml. - * - * ```xml - * - * - * - * - * - * - * - * - * ``` - * - * This is the layout file containing two layouts (_layout.xml_): - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - * By binding on the _layout.xml_ you can easily create a layout manager. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * Add Layout - * - * ``` - * - * @default_private - */ - // @todo a __WITH_DOM_REPARENTING should be added which can remove many of the functions of this element. - apf.layout = { compile: function(oHtml) { var l = this.layouts[oHtml.getAttribute("id")]; @@ -6550,9 +6093,6 @@ apf.queue = { apf.layout.processQueue(); - if (apf.xmldb && apf.xmldb.$hasQueue) - apf.xmldb.notifyQueued(); - var q = this.q; this.q = {}; @@ -13049,7 +12589,6 @@ apf.BaseButton = function(){ * @baseclass * * @inherits apf.StandardBinding - * @inherits apf.DataAction * * @author Ruben Daniels (ruben AT ajax DOT org) * @version %I%, %G% @@ -13061,9 +12600,6 @@ apf.BaseSimple = function(){ (function() { - this.implement(apf.DataAction); - - this.getValue = function(){ return this.value; }; @@ -14775,347 +14311,6 @@ apf.__MEDIA__ = 1 << 20; -apf.__MULTICHECK__ = 1 << 22; - - - -/** - * All elements inheriting from this {@link term.baseclass baseclass} have checkable items. - * - * @class apf.MultiCheck - * @baseclass - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 3.0 - * - * - */ -// @todo type detection, errors (see functions in multiselect) -apf.MultiCheck = function(){ - this.$regbase = this.$regbase | apf.__MULTICHECK__; - - // *** Properties *** // - - this.multicheck = true; - this.checklength = 0; - this.$checkedList = []; - - // *** Public Methods *** // - - /** - * @event beforecheck Fires before a check is made - * @param {Object} e The standard event object, with the following properties: - * - `xmlNode` ([[XMLElement]]): the {@link term.datanode data node} that will be checked. - */ - /** - * @event aftercheck Fires after a check is made - * @param {Object} e The standard event object, with the following properties: - * - `xmlNode` ([[XMLElement]]): the {@link term.datanode data node} that was checked. - * - */ - /** - * Checks a single, or a set of, elements. - * - * The checking can be visually represented in this element. - * The element can be checked, partialy checked, or unchecked - * - * @param {Mixed} xmlNode The identifier to determine the selection. - * @return {Boolean} Indicates whether the selection could not be made (`false`) - */ - this.check = function(xmlNode, userAction) { - if (userAction && this.disabled - || this.$checkedList.indexOf(xmlNode) > -1) - return; - - if (userAction - && this.$executeSingleValue("check", "checked", xmlNode, "true") !== false) - return; - - if (this.dispatchEvent("beforecheck", {xmlNode : xmlNode}) === false) - return false; - - if (!this.multicheck && this.$checkedList.length) - this.clearChecked(true); - - this.$checkedList.push(xmlNode); - - - - this.$setStyleClass(apf.xmldb.getHtmlNode(xmlNode, this), - "checked", ["partial"]); - -// this.dispatchEvent("aftercheck", { -// list : this.$checkedList, -// xmlNode : xmlNode -// }); - }; - - /** - * @event beforeuncheck Fires before a uncheck is made - * @param {Object} e The standard event object, with the following properties: - * - `xmlNode` ([[XMLElement]]): the {@link term.datanode data node} that will be unchecked. - * - */ - /** - * @event afteruncheck Fires after a uncheck is made - * @param {Object} e The standard event object, with the following properties: - * - `xmlNode` ([[XMLElement]]): the {@link term.datanode data node} that was unchecked. - * - */ - /** - * Unchecks a single, or set of, elements. - * - * @param {Mixed} xmlNode The identifier to determine the selection. - * @return {Boolean} Indicates if the selection could be made (`false`) - */ - this.uncheck = function(xmlNode, userAction) { - if (userAction && this.disabled - || this.$checkedList.indexOf(xmlNode) == -1) - return; - - if (userAction - && this.$executeSingleValue("check", "checked", xmlNode, "false") !== false) - return; - - - - if (this.dispatchEvent("beforeuncheck", { - xmlNode: xmlNode - }) === false) - return false; - - this.$checkedList.remove(xmlNode); - this.$setStyleClass(apf.xmldb.getHtmlNode(xmlNode, this), - "", ["checked", "partial"]); - - this.dispatchEvent("afteruncheck", { - list: this.$checkedList, - xmlNode: xmlNode - }); - }; - - /** - * Toggles between a check and uncheck of a single, or set of, elements. - * - * @param {Mixed} xmlNode The identifier to determine the selection. - * - */ - this.checkToggle = function(xmlNode, userAction) { - if (userAction && this.disabled) - return; - - if (xmlNode.style) { - var htmlNode = xmlNode, - id = htmlNode.getAttribute(apf.xmldb.htmlIdTag); - while (!id && htmlNode.parentNode) - id = (htmlNode = htmlNode.parentNode) - .getAttribute(apf.xmldb.htmlIdTag); - xmlNode = apf.xmldb.getNode(htmlNode) - } - - if (this.$checkedList.indexOf(xmlNode) > -1) - this.uncheck(xmlNode, userAction); - else - this.check(xmlNode, userAction); - }; - - /** - * Checks a set of items. - * - * @param {Array} xmlNodeList The {@link term.datanode data nodes} that will be selected. - * @param {Boolean} uncheck If `true`, checks the items - * @param {Boolean} noClear If `true`, does not also clears the selection - * @param {Boolean} noEvent Indicates whether to call any events - * @event beforecheck Fires before a check is made - * object: - * - * @event aftercheck Fires after a check is made - * object: - * {XMLElement} xmlNode the {@link term.datanode data node} that is deselected. - */ - this.checkList = function(xmlNodeList, uncheck, noClear, noEvent, userAction) { - if (!xmlNodeList.indexOf) - xmlNodeList = apf.getArrayFromNodelist(xmlNodeList); - //@todo is this need for ie8 and/or other browsers - - if (userAction) { - if (this.disabled) - return; - - var changes = []; - for (var c, i = 0; i < xmlNodeList.length; i++) { - c = this.$executeSingleValue("check", "checked", xmlNodeList[i], uncheck ? "false" : "true", true) - if (c === false) break; - changes.push(c); - } - - if (changes.length) { - return this.$executeAction("multicall", changes, "checked", - xmlNodeList[0], null, null, - xmlNodeList.length > 1 ? xmlNodeList : null); - } - } - - if (userAction && this.disabled) return; - - if (!noEvent && this.dispatchEvent("beforecheck", { - list: xmlNodeList - }) === false) - return false; - - if (!uncheck && !noClear) - this.clearChecked(true); - - if (!this.multicheck) - xmlNodeList = [xmlNodeList[0]]; - - var i; - if (uncheck) { - for (i = xmlNodeList.length - 1; i >= 0; i--) { - this.$checkedList.remove(xmlNodeList[i]); - this.$setStyleClass( - apf.xmldb.getHtmlNode(xmlNodeList[i], this), "", ["checked"]); - } - } - else { - for (i = xmlNodeList.length - 1; i >= 0; i--) { - this.$checkedList.push(xmlNodeList[i]); - this.$setStyleClass( - apf.xmldb.getHtmlNode(xmlNodeList[i], this), "checked"); - } - } - - - - if (!noEvent) - this.dispatchEvent("aftercheck", { - list: xmlNodeList - }); - }; - - /** - * Removes the selection of one or more checked nodes. - * - * @param {Boolean} [noEvent] Indicates whether to call any events - */ - this.clearChecked = function(noEvent) { - if (!noEvent && this.dispatchEvent("beforeuncheck", { - xmlNode: this.$checkedList - }) === false) - return false; - - for (var i = this.$checkedList.length - 1; i >= 0; i--) { - this.$setStyleClass( - apf.xmldb.getHtmlNode(this.$checkedList[i], this), "", ["checked"]); - } - - this.$checkedList.length = 0; - - if (!noEvent) { - this.dispatchEvent("afteruncheck", { - list: this.$checkedList - }); - } - }; - - /** - * Determines whether a node is checked. - * - * @param {XMLElement} xmlNode The {@link term.datanode data node} to be checked. - * @return {Boolean} Whether the element is selected. - */ - this.isChecked = function(xmlNode) { - return this.$checkedList.indexOf(xmlNode) > -1; - }; - - /** - * Retrieves an array or a document fragment containing all the checked - * {@link term.datanode data nodes} from this element. - * - * @param {Boolean} [xmldoc] Specifies whether the method should return a document fragment. - * @return {Mixed} The selection of this element. - */ - this.getChecked = function(xmldoc) { - var i, r; - if (xmldoc) { - r = this.xmlRoot - ? this.xmlRoot.ownerDocument.createDocumentFragment() - : apf.getXmlDom().createDocumentFragment(); - for (i = 0; i < this.$checkedList.length; i++) - apf.xmldb.cleanNode(r.appendChild( - this.$checkedList[i].cloneNode(true))); - } - else { - for (r = [], i = 0; i < this.$checkedList.length; i++) - r.push(this.$checkedList[i]); - } - - return r; - }; - - /** - * Checks all the {@link term.eachnode each nodes} of this element - * - */ - this.checkAll = function(userAction) { - if (!this.multicheck || userAction && this.disabled || !this.xmlRoot) - return; - - var nodes = this.$isTreeArch - ? this.xmlRoot.selectNodes(".//" - + this.each.split("|").join("|.//")) - : this.getTraverseNodes(); - - this.checkList(nodes); - }; - - this.addEventListener("beforeload", function(){ - if (!this.$hasBindRule("checked")) //only reset state when check state isnt recorded - this.clearChecked(true); - }); - - this.addEventListener("afterload", function(){ - if (!this.$hasBindRule("checked") && this.$checkedList.length) //only reset state when check state isnt recorded - this.checkList(this.$checkedList, false, true, false); //@todo could be optimized (no event calling) - }); - - this.addEventListener("xmlupdate", function(e) { - if (e.action == "attribute" || e.action == "text" - || e.action == "synchronize" || e.action == "update") { - //@todo list support! - var c1 = apf.isTrue(this.$applyBindRule("checked", e.xmlNode)); - var c2 = this.isChecked(e.xmlNode); - if (c1 != c2) { - if (c1) { - this.check(e.xmlNode); - } - else { - this.uncheck(e.xmlNode); - } - } - } - }); - - - this.addEventListener("aftercheck", function(){ - //@todo inconsistent because setting this is in event callback - if (this.checklength != this.$checkedList.length) - this.setProperty("checklength", this.$checkedList.length); - }); - - this.addEventListener("afteruncheck", function(){ - //@todo inconsistent because setting this is in event callback - if (this.checklength != this.$checkedList.length) - this.setProperty("checklength", this.$checkedList.length); - }); - -}; - - - - - - apf.__TRANSACTION__ = 1 << 3; @@ -16638,38 +15833,6 @@ apf.runNonIe = function (){ this.parentNode.removeChild(this); }; - //XMLDocument.load - XMLDocument.prototype.$load = XMLDocument.prototype.load; - XMLDocument.prototype.load = function(sURI) { - var oDoc = document.implementation.createDocument("", "", null); - oDoc.$copyDOM(this); - this.parseError = 0; - apf.xmldb.setReadyState(this, 1); - - try { - if (this.async == false && ASYNCNOTSUPPORTED) { - var tmp = new XMLHttpRequest(); - tmp.open("GET", sURI, false); - tmp.overrideMimeType("text/xml"); - tmp.send(null); - apf.xmldb.setReadyState(this, 2); - this.$copyDOM(tmp.responseXML); - apf.xmldb.setReadyState(this, 3); - } else - this.$load(sURI); - } - catch (objException) { - this.parseError = -1; - } - finally { - apf.xmldb.loadHandler(this); - } - - return oDoc; - }; - - - /** @@ -16689,14 +15852,7 @@ apf.runNonIe = function (){ XMLDocument.prototype.setProperty = function(x,y) {}; /* ******** XML Compatibility ************************************************ - Extensions to the xmldb ****************************************************************************/ - apf.getHttpReq = function(){ - if (apf.availHTTP.length) - return apf.availHTTP.pop(); - return new XMLHttpRequest(); - }; - apf.getXmlDom = function(message, noError, preserveWhiteSpaces) { var xmlParser; if (message) { @@ -18484,12 +17640,6 @@ apf.checkbox = function(struct, tagName) { }; (function() { - this.implement( - - - apf.DataAction - - ); //Options this.$focussable = apf.KEYBOARD; // This object can get the focus @@ -19306,9 +18456,6 @@ apf.label = function(struct, tagName) { (function(){ this.implement( - - apf.DataAction, - apf.ChildValue ); @@ -19405,9 +18552,6 @@ apf.colorbox = function(struct, tagName) { (function(){ this.implement( - - apf.DataAction, - apf.ChildValue ); @@ -20605,8 +19749,6 @@ apf.aml.setElement("param", apf.param); * @allowchild {smartbinding} * * @form - * @inherits apf.StandardBinding - * @inherits apf.DataAction * * @author Ruben Daniels (ruben AT ajax DOT org) * @version %I%, %G% @@ -20645,9 +19787,6 @@ apf.progressbar = function(struct, tagName) { (function(){ - this.implement(apf.DataAction); - - this.$focussable = false; // This object can get the focus // *** Properties and Attributes *** // @@ -21307,11 +20446,7 @@ apf.$group = apf.group = function(struct, tagName) { this.$init(tagName || "group", apf.NODE_VISIBLE, struct); this.implement( - apf.StandardBinding, - - apf.DataAction - - + apf.StandardBinding ); var radiobuttons = []; @@ -21662,7 +20797,6 @@ apf.aml.setElement("skin", apf.skin); * @version %I%, %G% * * @inherits apf.StandardBinding - * @inherits apf.DataAction * @inheritsElsewhere apf.XForms * */ @@ -21692,13 +20826,6 @@ apf.spinner = function(struct, tagName) { }; (function() { - this.implement( - - apf.DataAction - - - ); - this.$supportedProperties.push("width", "value", "max", "min", "caption", "realtime"); this.$booleanProperties["realtime"] = true; @@ -23027,13 +22154,6 @@ apf.textbox = function(struct, tagName) { }; (function(){ - this.implement( - - apf.DataAction - - - ); - this.$focussable = true; // This object can get the focus this.$masking = false; this.$autoComplete = false;