From fd5e2362e0284dc4e1dc4e5b7d8cd3305fdde6a1 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 12 Jan 2017 14:56:49 +0400 Subject: [PATCH] remove more unused code from apf --- plugins/c9.ide.layout.classic/layout.js | 3 - plugins/c9.ide.layout.classic/layout.xml | 14 - plugins/c9.ide.ui/lib_apf.js | 3290 +--------------------- 3 files changed, 7 insertions(+), 3300 deletions(-) diff --git a/plugins/c9.ide.layout.classic/layout.js b/plugins/c9.ide.layout.classic/layout.js index 250fbf9f..e412e837 100644 --- a/plugins/c9.ide.layout.classic/layout.js +++ b/plugins/c9.ide.layout.classic/layout.js @@ -103,9 +103,6 @@ define(function(require, exports, module) { colRight.parentNode.$handle.setAttribute("id", "splitterPanelRight"); plugin.addElement(hboxMain.$handle); plugin.addElement(colRight.parentNode.$handle); - - // Intentionally global - window.sbShared = plugin.getElement("sbShared"); // update c9 main logo link logobar = plugin.getElement("logobar"); diff --git a/plugins/c9.ide.layout.classic/layout.xml b/plugins/c9.ide.layout.classic/layout.xml index 3c46a4a4..7777defb 100644 --- a/plugins/c9.ide.layout.classic/layout.xml +++ b/plugins/c9.ide.layout.classic/layout.xml @@ -9,21 +9,7 @@ storage = "cookie" baseurl = "{apf.host ? apf.host : ''}" requested-with-getparam = "xhr"/> - - - - - diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index 613b95cf..08422622 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -251,8 +251,6 @@ VERSION: '3.0beta', * @private */ releaseHTTP: function(http) { - if (apf.brokenHttpAbort) - return; if (self.XMLHttpRequestUnSafe && http.constructor == XMLHttpRequestUnSafe) return; @@ -380,7 +378,6 @@ VERSION: '3.0beta', //Set Compatibility this.TAGNAME = apf.isIE ? "baseName" : "localName"; this.styleSheetRules = apf.isIE ? "rules" : "cssRules"; - this.brokenHttpAbort = apf.isIE6; this.canUseHtmlAsXml = apf.isIE; this.supportNamespaces = !apf.isIE && !apf.isIE11; this.hasConditionCompilation = apf.isIE; @@ -399,7 +396,6 @@ VERSION: '3.0beta', this.hasCssUpdateScrollbarBug = apf.isIE; this.canUseInnerHtmlWithTables = !apf.isIE; this.hasSingleResizeEvent = !apf.isIE; - this.supportPng24 = !apf.isIE6 && !apf.isIE5; this.hasDynamicItemList = !apf.isIE || apf.isIE >= 7; this.hasSingleRszEvent = !apf.isIE; this.hasXPathHtmlSupport = !apf.isIE; @@ -412,11 +408,8 @@ VERSION: '3.0beta', this.supportFixedPosition = !apf.isIE || apf.isIE >= 7; this.hasHtmlIdsInJs = apf.isIE && apf.isIE < 8 || apf.isWebkit; this.needsCssPx = !apf.isIE; - this.hasCSSChildOfSelector = !apf.isIE || apf.isIE >= 8; - this.hasStyleAnchors = !apf.isIE || apf.isIE >= 8; - this.styleAttrIsObj = apf.isIE < 8; + this.hasAutocompleteXulBug = apf.isGecko; - this.loadsLocalFilesSync = apf.isIE || apf.isGecko; this.mouseEventBuffer = apf.isIE ? 20 : 6; this.hasComputedStyle = typeof document.defaultView != "undefined" && typeof document.defaultView.getComputedStyle != "undefined"; @@ -1943,7 +1936,6 @@ apf.Class.prototype = new (function(){ * @return {Mixed} return value of the event */ this.dispatchEvent = function(eventName, options, e) { - //var allowEvents = {"DOMNodeInsertedIntoDocument":1,"DOMNodeRemovedFromDocument":1}; var arr, result, rValue, i, l; if (!apf.AmlEvent) @@ -1953,13 +1945,7 @@ apf.Class.prototype = new (function(){ this.$eventDepth++; e = options && options.name ? options : e; - - /*if (this.disabled && !allowEvents[eventName]) { - result = false; - } - else {*/ - //@todo rewrite this and all dependencies to match w3c if ((!e || !e.currentTarget) && (!options || !options.currentTarget)) { if (!(options || (options = {})).currentTarget) @@ -1996,24 +1982,14 @@ apf.Class.prototype = new (function(){ } } } - //} - - /*var p; - while (this.$removalQueue.length) { - p = this.$removalQueue.shift(); - p[0].remove(p[1]); - }*/ - if ((e && e.bubbles && !e.cancelBubble || !e && options && options.bubbles) && this != apf) { rValue = (this.parentNode || this.ownerElement || apf).dispatchEvent(eventName, options, e); - // || (e = new apf.AmlEvent(eventName, options)) if (typeof rValue != UNDEF) result = rValue; } - if (--apf.$eventDepth == 0 && this.ownerDocument && !this.ownerDocument.$domParser.$parseContext && !apf.isDestroying && apf.loaded @@ -2026,7 +2002,6 @@ apf.Class.prototype = new (function(){ this.$eventDepth--; - if (options) { try { delete options.currentTarget; @@ -6487,226 +6462,12 @@ if (apf.history) -apf.offline = { - onLine: true -}; - - -/** - * Stores data using a {@link term.datainstruction data instruction}. - * - * - * @param {String} instruction The {@link term.datainstruction data instruction} to be used to store the data. - * @param {Object} [options] The options for this instruction. Available properties include: - * - multicall ([[Boolean]]): Whether this call should not be executed immediately, but saved for later sending using the `purge()` command - * - userdata (`Mixed`): Any data that is useful to access in the callback function - * - args ([[Array]]): The arguments of the call, overriding any specified in the data instruction - * - [xmlContext] ([[XMLElement]]): The subject of the xpath queries - * - [callback] ([[Function]]): The code that is executed when the call returns, either successfully or not - * {: #saveDataOptions} - */ -apf.saveData = - -/** - * Retrieves data using a {@link term.datainstruction data instruction}. - * - * #### Example - * - * Here are several uses for data instructions: - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - * @method getData - * @param {String} instruction The {@link term.datainstruction data instruction} to be used to retrieve the data. - * @param {XMLElement} [xmlContext] The subject of the xpath queries - * @param {Object} [options] The options for this instruction. Available properties include: - * - multicall ([[Boolean]]): Whether this call should not be executed immediately, but saved for later sending using the `purge()` command - * - userdata (`Mixed`): Any data that is useful to access in the callback function - * - args ([[Array]]): The arguments of the call, overriding any specified in the data instruction - * - [xmlContext] ([[XMLElement]]): The subject of the xpath queries - * - [callback] ([[Function]]): The code that is executed when the call returns, either successfully or not - * @param {Function} [callback] The code that is executed when the call returns, either successfully or not - */ -apf.getData = function(instruction, options) { - if (!instruction) return false; - - //Instruction type detection - var result, chr = instruction.charAt(0), callback = options.callback; - - - var gCallback = - - - function(data, state, extra) { - var callback = options.callback - - if (state != apf.SUCCESS) - return callback(data, state, extra || {}); - - //Change this to warning? - /*if (!data) { - throw new Error(apf.formatErrorString(0, null, - "Loading new data", "Could not load data. \n\ - Data instruction: '" + instruction + "'")); - }*/ - - return callback(data, state, extra || {}); - } - - if (!options) options = {}; //@todo optimize? - var fParsed = options.fParsed || (instruction.indexOf("{") > -1 || instruction.indexOf("[") > -1 - ? apf.lm.compile(instruction, { - withopt: true, - precall: options.precall, - alwayscb: true, - simplexpath: true - }) - : {str: instruction, type: 2}); - - if (options.precall && !options._pc) { - options.asyncs = fParsed.asyncs; - options._pc = 1; - } - - //@todo hack because we're not using compileNode.. an imperfection.. - if (fParsed.type == 3) { - if (fParsed.xpaths[0]) { - var model = fParsed.xpaths[0], xpath = fParsed.xpaths[1]; - - //@todo can this be async? - if (model == "#" || xpath == "#") { //When there is a set model and not a generated xpath - var m = (apf.lm.compile(instruction, { - xpathmode: 5 - }))(); - - //@todo apf3 this needs to be fixed in live markup - if (typeof m != "string") { - model = m.model && m.model.$isModel && m.model; - if (model) - xpath = m.xpath; - else if (m.model) { - model = apf.xmldb.findModel(m.model); - xpath = apf.xmlToXpath(m.model, model.data) + (m.xpath ? "/" + m.xpath : ""); //@todo make this better - } - else { - //Model is not yet available. When it comes available we will be recalled (at least for prop binds) - return; - } - } - else model = null; - } - else { - - model = apf.nameserver.get("model", model) - - } - - - - return gCallback(model.data.selectSingleNode(xpath), apf.SUCCESS, {}); - } - else { - - - return gCallback(options.xmlNode.data.selectSingleNode(fParsed.xpaths[1]), apf.SUCCESS, {}); - } - } - - //xml generation - if (chr == "<") { - //string only - if (fParsed.type == 2) - result = fParsed.str; - else - return fParsed(options.xmlNode, gCallback, options); - } - //jslt fetching data - else if ((chr == "[" || chr == "{")) { //(fParsed.asyncs || fParsed.models) && - return fParsed(options.xmlNode, gCallback, options); - } - //url - else { - if (fParsed.type == 1 || fParsed.type == 3) { - var callback2 = callback; - callback = options.callback = function(data, state, extra) { - if (options._pc === true) - return; - - if (state != apf.SUCCESS) - return callback2.apply(this, arguments); - - var url = data.split(" "), method = "get"; - if (url.length > 1 && url[0].length < 10) { - method = url.shift(); - url = url.join(" "); - } - else url = data; - - callback = options.callback = callback2; - apf.oHttp.exec(method, [url], gCallback, options); - } - fParsed(options.xmlNode, gCallback, options); - } - else { - if (options._pc === true) - return; - - var url = instruction.split(" "), method = "get"; - if (url.length > 1 && url[0].length < 10) { - method = url.shift(); - url = url.join(" "); - } - else { - url = instruction; - } - - apf.oHttp.exec(method, [url.replace(/\\/g, "")], gCallback, options); - } - } - - if (result) { - if (callback) - gCallback(result, apf.SUCCESS, {}); - else { - //apf.console.warn("Returning data directly in apf.getData(). \ - //This means that all callback communication ends in void!"); - return result; - } - } -}; - - /** * Creates a model object based on a {@link term.datainstruction data instruction}. * @@ -14569,7 +14330,8 @@ apf.Anchoring = function(){ else this.$ext.style.left = left + "px"; } - if ((apf.hasStyleAnchors || !hasLeft) && hasRight) { + + if (hasRight) { if (parseInt(right) != right) { right = setPercentage(right, "pWidth"); rules.push("oHtml.style.right = (" + right + ") + 'px'"); @@ -14579,11 +14341,7 @@ apf.Anchoring = function(){ } if (hasLeft && hasRight) { //right != null && left != null) { - if (!apf.hasStyleAnchors) - rules.push("oHtml.style.width = (pWidth - (" + right - + ") - (" + left + ") - " + this.$hordiff + ") + 'px'"); - else - this.$ext.style.width = ""; + this.$ext.style.width = ""; } else if (hasWidth && typeof this.maxwidth == "number" && typeof this.minwidth == "number") { if (parseInt(width) != width) { @@ -14630,7 +14388,7 @@ apf.Anchoring = function(){ else this.$ext.style.top = top + "px"; } - if ((apf.hasStyleAnchors || !hasTop) && hasBottom) { + if (hasBottom) { if (parseInt(bottom) != bottom) { rules.push("oHtml.style.bottom = (" + bottom + ") + 'px'"); } @@ -14638,11 +14396,7 @@ apf.Anchoring = function(){ this.$ext.style.bottom = bottom + "px"; } if (hasTop && hasBottom) { //bottom != null && top != null) { - if (!apf.hasStyleAnchors) - rules.push("oHtml.style.height = (pHeight - (" + bottom + - ") - (" + top + ") - " + this.$verdiff + ") + 'px'"); - else - this.$ext.style.height = ""; + this.$ext.style.height = ""; } else if (hasHeight && typeof this.minheight == "number") { if (parseInt(height) != height) { @@ -15244,16 +14998,6 @@ apf.GuiElement = function(){ } } - //IE6 compatiblity - /* - @todo please test that disabling this is OK - if (!apf.config.disableRightClick) { - document.oncontextmenu = function(){ - document.oncontextmenu = null; - e.cancelBubble = true; - return false; - } - }*/ } else { var menu; @@ -15852,16 +15596,6 @@ apf.Presentation = function(){ //this.$int.onresize = oInt.onresize; } - - //DragDrop - if (this.hasFeature(apf.__DRAGDROP__)) { - if (document.elementFromPointAdd) { - document.elementFromPointRemove(oExt); - document.elementFromPointAdd(this.$ext); - } - } - - //Check disabled state if (this.disabled) this.$disable(); //@todo apf3.0 test @@ -18069,1510 +17803,6 @@ apf.config.$inheritProperties["render-delay"] = 1; -apf.__DRAGDROP__ = 1 << 5; - - - -/** - * All elements inheriting from this {@link term.baseclass baseclass} have drag & drop - * features. - * - * This baseclass operates on the bound data of this element. - * When a rendered item is dragged and dropped, the bound data is moved or - * copied from one element to another, or to the same element but at a different - * position. This is possible because the rendered item has a - * {@link term.smartbinding bidirectional connection} to the data. Drag & drop can - * be turned on with a simple boolean, or by specifying detailed rules to set - * which data can be dragged and dropped and where. - * - * - * #### Example - * - * This is a simple example, enabling drag & drop for a list: - * - * ```xml - * - * ``` - * - * - * #### Example - * - * This example shows a smartbinding that represents files and folders. It uses a - * {@link term.datainstruction data instruction} to communicate to the webdav - * server when an item is copied or moved. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - * #### Example - * - * This example shows a small mail application. The tree element displays a root - * node, accounts and folders in a tree. The datagrid contains the mails. This - * rule specifies which data nodes can be dropped where. Folders can be dropped - * in folders and accounts. Mails can be dropped in folders. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *``` - * - * @class apf.DragDrop - * @baseclass - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.5 - * @define dragdrop - * @allowchild drop, drag - * @define drag - */ -/** - * @event dragdata Fires before a drag & drop operation is started to determine the data that is dragged. - * @param {Object} e The standard event object. It contains the following property: - * - `data` ([[XMLElement]]): The default data for the drag & drop operation - */ -/** - * @event dragstart Fires before a drag operation is started. - * @cancelable Prevents the drag operation to start. - * @param {Object} e The standard event object. It contains the following properties: - * - `data` ([[XMLElement]]): The data for the drag & drop operation - * - `selection` ([[XMLElement]]): The selection at the start of the drag operation - * - `indicator` ([[HTMLElement]]): The HTML element that is shown while dragging the data - * - `host` ([[apf.AmlElement]]): The AML source element. - */ -/** - * @event dragover Fires when the users drags over this AML element. - * @cancelable Prevents the possibility to drop. - * @param {Object} e The standard event object. It contains the following properties: - * {XMLElement} data The data for the drag & drop operation - * {XMLElement} selection The selection at the start of the drag operation - * {HTMLElement} indicator The HTML element that is shown while dragging the data - * {apf.AmlElement} host the AML source element. - */ -/** - * @event dragout Fires when the user moves away from this AML element. - * @param {Object} e The standard event object. It contains the following properties: - * {XMLElement} data the data for the drag & drop operation - * {XMLElement} selection the selection at the start of the drag operation - * {HTMLElement} indicator the HTML element that is shown while dragging the data - * {apf.AmlElement} host the aml source element. - */ -/** - * @event dragdrop Fires when the user drops an item on this aml element. - * @cancelable Prevents the possibility to drop. - * @param {Object} e The standard event object. It contains the following properties: - * {XMLElement} data The data for the drag & drop operation - * {XMLElement} selection The selection at the start of the drag operation - * {HTMLElement} indicator The html element that is shown while dragging the data - * {apf.AmlElement} host The AML source element. - * {Boolean} candrop Specifies whether the data can be inserted at the point hovered over by the user - * - * - */ -/** - * @attribute {String} match An XPath statement querying the - * {@link term.datanode data node} that is - * dragged. If the query matches a node it - * is allowed to be dropped. The XPath is - * automatically prefixed by `'self::'`. - */ -/** - * @attribute {String} copy A JavaScript expression that determines - * whether the dragged element is a copy or - * a move. Use event.ctrlKey to use the Ctrl - * key to determine whether the element is copied. - * - */ -/** - * @attribute {String} match An XPath statement querying the - * {@link term.datanode data node} that is - * dragged. If the query matches a node it - * is allowed to be dropped. The XPath is - * automatically prefixed by `'self::'`. - */ -/** - * @attribute {String} target An XPath statement determining the new - * parent of the dropped {@link term.datanode data node}. - * The XPath is automatically prefixed by `'self::'`. - */ -/** - * @attribute {String} action The action to perform when the - * {@link term.datanode data node} is inserted. - * The possible values include: - * - * - `tree-append`: Appends the {@link term.datanode data node} to the element its dropped on. - * - `list-append`: Appends the {@link term.datanode data node} to the root element of this element. - * - `insert-before`: Inserts the {@link term.datanode data node} before the elements its dropped on. - */ -/** - * @attribute {String} copy A JavaScript expression that determines - * whether the drop is a copy or a move. - * Use event.ctrlKey to use the [[keys: Ctrl]] key to - * determine whether the element is copied. - */ -apf.DragDrop = function(){ - this.$regbase = this.$regbase | apf.__DRAGDROP__; - - this.$dragInited = false; - - /* ********************** - Actions - ***********************/ - - /** - * Copies a {@link term.datanode data node} to the bound data of this element. - * - * @action - * @param {XMLElement} xmlNode The {@link term.datanode data node} which is copied. - * @param {XMLElement} [pNode] The new parent element of the copied - * {@link term.datanode data node}. If none is - * specified the root element of the data - * loaded in this element is used. - * @param {XMLElement} [beforeNode] The position where the {@link term.datanode data node} - * is inserted. - */ - this.copy = function(nodeList, pNode, beforeNode, isMove) { - if (nodeList.nodeType) - nodeList = [nodeList]; - - var exec, - changes = [], - i = 0, - l = nodeList.length; - for (; i < l; i++) { - changes.push({ - action: isMove ? "moveNode" : "appendChild", - args: [pNode, isMove - ? nodeList[i] - : nodeList[i] = nodeList[i].cloneNode(true), beforeNode] - }); - } - - if (this.$actions[(isMove ? "movegroup" : "copygroup")]) { - exec = this.$executeAction("multicall", changes, - (isMove ? "movegroup" : "copygroup"), nodeList[0]); - } - else { - exec = this.$executeAction("multicall", changes, - (isMove ? "move" : "copy"), nodeList[0], null, null, - nodeList.length > 1 ? nodeList : null); - } - - if (exec !== false) - return nodeList; - - return false; - }; - - /** - * Moves a {@link term.datanode data node} to the bound data of this element. - * - * @action - * @param {XMLElement} xmlNode The {@link term.datanode data node} which is copied. - * @param {XMLElement} [pNode] The new parent element of the moved - * {@link term.datanode data node}. If none - * specified the root element of the data - * loaded in this element is used. - * @param {XMLElement} [beforeNode] The position where the - * {@link term.datanode data node} is inserted. - */ - this.move = function(nodeList, pNode, beforeNode) { - return this.copy(nodeList, pNode, beforeNode, true); - }; - - /** - * Determines whether the user is allowed to drag the passed - * {@link term.datanode data node}. - * - * For instance, imagine a mail application with a root - * node, accounts and folders in a tree, and mails in a datagrid. The rules - * would specify you can drag & drop folders within an account, and emails between - * folders, but not on accounts or the root. - * - * @param {XMLElement} dataNode The {@link term.datanode data node} subject to the test. - * @return {Boolean} The result of the test - * @see apf.DragDrop.isDragAllowed - */ - this.isDragAllowed = function(x, data) { - - - if (!this.dragroot && this.xmlRoot.firstChild == x[0]) - return false; - - if (this.disabled || !x || !x.length || !x[0]) - return false; - - if (this.drag || this.dragcopy) { - if (data) - data.merge(x); - return true; - } - - /*var rules = this.$bindings["drag"] - || this.$attrBindings && this.$attrBindings["drag"]; - if (!rules || !rules.length) - return false;*/ - - var d, - ruleList = [], - j = 0, - l = x.length; - for (; j < l; j++) { - d = this.$getDataNode("drag", x[j], null, ruleList); - if (!d) return false; //It's all or nothing - if (data) - data.push(d); - } - - return ruleList.length ? ruleList : false; - }; - - /** - * Determines whether the user is allowed to drop the passed - * {@link term.datanode data node}. - * - * For instance, imagine a mail application with a root - * node, accounts and folders in a tree, and mails in a datagrid. The rules - * would specify you can drag & drop folders within an account, and emails between - * folders, but not on accounts or the root. - * - * @param {XMLElement} dataNode The {@link term.datanode data node} subject - * to the test. - * @param {XMLElement} target The {@link term.datanode data node} on which - * the dragged data node is dropped. - * @return {Boolean} The result of the test - * @see apf.DragDrop.isDragAllowed - */ - this.isDropAllowed = function(x, target) { - - - if (this.disabled || !x || !x.length || !target) //!x[0] ??? - return false; - - if (!this.dragroot == false && this.xmlRoot.firstChild == x[0]) - return false; - - for (var i = x.length - 1; i >= 0; i--) - if (apf.isChildOf(x[i], target, true)) - return false; - - var data, tgt, hasDropRule = this.$attrBindings && this.$attrBindings["drop"]; - if (this.drop && (!hasDropRule || hasDropRule.value == "true")) { - this.$setDynamicProperty("drop", this.hasFeature(apf.__MULTISELECT__) - ? "[" + this.each + "]" - : "[node()]"); //@todo apf3.0 make sure each is without {} - hasDropRule = true; - } - - if (hasDropRule) { - for (var j = 0, l = x.length; j < l; j++) { - data = this.$getDataNode("drop", x[j]); - if (!data) - break; - } - if (j == l && target && !apf.isChildOf(data, target, true)) - return [target, null]; - } - - var rules = this.$bindings["drop"]; - if (!rules || !rules.length) - return false; - - //@todo this can be optimized when needed - var rule, strTgt, - i = 0, - rl = rules.length; - for (; i < rl; i++) { - rule = this.$bindings.getRuleIndex("drop", i); - - for (var j = 0, l = x.length; j < l; j++) { - data = rule.cvalue ? rule.cvalue(x[j]) : rule.cmatch(x[j]); - if (!data) - break; - } - if (j != l) - continue; - - strTgt = rule.target;//node.getAttribute("target"); - if (!strTgt || strTgt == ".") { - //op = node.getAttribute("action") - //|| (this.$isTreeArch ? "tree-append" : "list-append"); - tgt = target;/*(op == "list-append" || target == this.xmlRoot - ? this.xmlRoot - : null);*/ - } - else { - tgt = (rule.ctarget || rule.compile("target"))(target); - } - - if (tgt && !apf.isChildOf(data, tgt, true)) - return [tgt, rule]; - } - - return false; - }; - - this.$dragDrop = function(xmlReceiver, xmlNodeList, rule, defaction, isParent, srcRule, event, forceCopy) { - /* - Possibilities: - - tree-append [default]: xmlNode.appendChild(movedNode); - list-append : xmlNode.parentNode.appendChild(movedNode); - insert-before : xmlNode.parentNode.insertBefore(movedNode, xmlNode); - */ - var action = rule && rule.action;//node && node.getAttribute("action"); - - if (action) - action = (rule.caction || rule.compile("action"))(xmlNodeList[0]); - else - action = defaction; - - // @todo apf3.0 action not known here yet... should be moved down? - if (action == "tree-append" && isParent) - return false; - - if (!event) - event = {}; - - //copy convenience variables - var context = { - internal: apf.DragServer.dragdata && apf.DragServer.dragdata.host == this, - ctrlKey: event.ctrlKey, - keyCode: event.keyCode - }, - //@todo apf3.0 below should actually be compileNode with with_options - ifcopy = rule && rule.copy;//.getAttribute("copy"); - - if (typeof forceCopy == "boolean") - ifcopy = forceCopy; - else if (ifcopy) { - context.event = event || {}; - ifcopy = !apf.isFalse((rule.ccopy || rule.compile("copy"))(xmlNodeList[0], context)); - } - else if (typeof this.dragcopy == "boolean" || typeof this.dropcopy == "boolean") { //@todo apf3.0 boolean here? - if (this.dropcopy) { - ifcopy = this.dropcopy; - } - else if (this.dragcopy) { - ifcopy = event.ctrlKey; - } - else { - //@todo read this from src - var copyRule = this.$attrBindings && this.$attrBindings["dragcopy"]; - if (copyRule) { - ifcopy = !apf.isFalse((copyRule.cvalue2 - || copyRule.compile("value", { - withopt: true - }))(xmlNodeList[0], context)); - } - } - } - - if (!ifcopy && srcRule) { //Implemented one copy is all copy - for (var i = 0, l = srcRule.length; i < l; i++) { - ifcopy = typeof srcRule[i] == "object" && srcRule[i].copy - ? !apf.isFalse((srcRule[i].ccopy || srcRule[i].compile("copy"))(xmlNodeList[0], context)) - : event.ctrlKey; - if (ifcopy) break; - } - } - - var sNode, - actRule = ifcopy ? "copy" : "move", - parentXpath = rule ? rule.getAttribute("parent") : null; //@todo apf3.0 Should be lm syntax - switch (action) { - case "list-append": - xmlReceiver = (isParent - ? xmlReceiver - : this.getTraverseParent(xmlReceiver)); - if (parentXpath) { - if (xmlReceiver.selectSingleNode(parentXpath)) - xmlReceiver = xmlReceiver.selectSingleNode(parentXpath); - else { - xmlReceiver.appendChild(xmlReceiver.ownerDocument.createElement(parentXpath)); - xmlReceiver = xmlReceiver.selectSingleNode(parentXpath); - } - } - sNode = this[actRule](xmlNodeList, xmlReceiver); - break; - case "insert-before": - sNode = isParent - ? this[actRule](xmlNodeList, xmlReceiver) - : this[actRule](xmlNodeList, xmlReceiver.parentNode, xmlReceiver); - break; - case "tree-append": - if (parentXpath) { - if (xmlReceiver.selectSingleNode(parentXpath)) - xmlReceiver = xmlReceiver.selectSingleNode(parentXpath); - else { - xmlReceiver.appendChild(xmlReceiver.ownerDocument.createElement(parentXpath)); - xmlReceiver = xmlReceiver.selectSingleNode(parentXpath); - } - } - sNode = this[actRule](xmlNodeList, xmlReceiver); - break; - } - - if (this.selectable && sNode) { - this.selectList(sNode);//, null, null, null, true); - this.setCaret(sNode[0]); - this.focus(); - } - - return sNode; - }; - - /* ********************** - Init - ***********************/ - - /* - * Loads the dragdrop rules from the dragdrop element - * - * @param {Array} rules The rules array created using {@link core.apf.method.getrules} - * @param {XMLElement} [node] The reference to the drag & drop element - * @see SmartBinding - * @private - */ - this.enableDragDrop = function(){ - - - //Set cursors - //SHOULD come from skin - this.icoAllowed = "";//this.xmlDragDrop.getAttribute("allowed"); - this.icoDenied = "";//this.xmlDragDrop.getAttribute("denied"); - - //Setup External Object - this.$ext.dragdrop = false; - - var _self = this; - - this.$ext[apf.isIphone ? "ontouchstart" : "onmousedown"] = function(e) { - if (_self.disabled) - return; - - e = e || window.event; - - - var fEl, - srcEl = e.originalTarget || e.srcElement || e.target, - multiselect = _self.hasFeature(apf.__MULTISELECT__); - if (multiselect && srcEl == _self.$container) - return; - _self.dragging = 0; - - try{ //Firefox can crash here because of some chrome permission issue - if (!apf.isIphone && _self.allowdeselect - && (srcEl == this || srcEl.getAttribute(apf.xmldb.htmlIdTag) - && _self.$getLayoutNode("item", "select", this) != this)) - return; //This broke making a selection with the mouse in rename: _self.clearSelection(); //@todo hacky - should detect what element has the select from the skin - }catch(e) {return;} - - //MultiSelect must have carret behaviour AND deselect at clicking white - if (_self.$findValueNode) - fEl = _self.$findValueNode(srcEl); - var el = (fEl - ? apf.xmldb.getNode(fEl) - : apf.xmldb.findXmlNode(srcEl)); - if (multiselect && (!_self.selected || !el || el == _self.xmlRoot)) - return; - - if (_self.isDragAllowed(multiselect ? _self.$getSelection() : el)) { - - - apf.DragServer.start(_self, srcEl, e); - } - - //e.cancelBubble = true; - }; - - this.$ext[apf.isIphone ? "ontouchmove" : "onmousemove"] = function(e) { - if (this.host.dragging != 1 || _self.disabled) return; - }; - - - { - this.$ext.onmouseup = function(){ - if (_self.disabled) - return; - - this.host.dragging = 0; - }; - - this.$ext.ondragcopy = - this.$ext.ondragstart = function(){return false;}; - } - - if (document.elementFromPointAdd) - document.elementFromPointAdd(this.$ext); - - if (this.$initDragDrop && !this.$dragInited) { - this.$initDragDrop(); - this.$dragInited = 2; - } - else { - this.$dragInited = true; - } - }; - - function disableDragDrop(){ - this.$dragInited = false; //@todo solve oExt event conflicts - - - { - this.$ext.onmousedown = this.$ext.onmousemove - = this.$ext.onmouseup = null; - } - - if (document.elementFromPointRemove) - document.elementFromPointRemove(this.$ext); - } - - this.implement( - - this.hasFeature(apf.__MULTISELECT__) - ? apf.MultiselectDragDrop : - - apf.StandardDragDrop); - - //this.$booleanProperties["drag"] = true; - //this.$booleanProperties["dragcopy"] = true; - this.$supportedProperties.push("drop", "drag", "dragcopy"); - - /** - * @attribute {Boolean} drag Sets or gets whether the element allows dragging of its items. - * - * #### Example - * - * ```xml - * - * - * item 1 - * item 2 - * item 3 - * - *``` - * - */ - /** - * @attribute {Boolean} dragcopy whether dragged items are copied. - * - * #### Example - * - * ```xml - * - * - * - * - * - * - * - * - * - * ``` - * - * #### Example - * - * Items are only copied when the user holds the [[keys: Ctrl]] key - * - * ```xml - * - * item 1 - * item 2 - * item 3 - * - * ``` - */ - /** - * @attribute {Boolean} drop Sets or gets whether the element allows items to be dropped. - * - * #### Example - * - * - * ```xml - * - * item 1 - * item 2 - * item 3 - * - * ``` - * @attribute {String} dragdrop Sets or gets the name of the dragdrop element for this element. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - this.$propHandlers["dragcopy"] = - this.$propHandlers["dropcopy"] = - this.$propHandlers["drag"] = - this.$propHandlers["drop"] = function(value, prop) { - this[prop] = apf.isTrue(value); - - if (this.$dragInited && prop == "drag" && value && this.$dragInited != 2) { - this.$initDragDrop(); - this.$dragInited = 2; - return; - } - - if (prop == "dragcopy" || prop == "dropcopy") - return; - - if (!value && !this.drag && !this.drop && !this.$bindings - && (this.$attrBindings && (!this.$attrBindings["drag"] || !this.$attrBindings["drop"]))) - disableDragDrop.call(this); - else if (value && !this.$dragInited) - this.enableDragDrop(); - }; - - this.addEventListener("DOMNodeRemovedFromDocument", function(e) { - disableDragDrop.call(this); - - if (this.oDrag) { - apf.destroyHtmlNode(this.oDrag); - this.oDrag = null; - } - }); -}; - -apf.GuiElement.propHandlers["dragcopy"] = -apf.GuiElement.propHandlers["dropcopy"] = -apf.GuiElement.propHandlers["drop"] = -apf.GuiElement.propHandlers["drag"] = function(value, prop) { - if (!apf.isFalse(value)) { - if (!this.hasFeature(apf.__DRAGDROP__)) { - this.implement(apf.DragDrop); - this.enableDragDrop(); - } - - this[prop] = apf.isTrue(value); - } -}; - -/* - * Central object for dragdrop handling. - * @private - */ -apf.DragServer = { - Init: function(){ - - - apf.addEventListener("hotkey", function(e) { - if (apf.window.dragging && e.keyCode == 27) { - if (document.body.lastHost && document.body.lastHost.dragOut) - document.body.lastHost.dragOut(apf.dragHost); - - return apf.DragServer.stopdrag(); - } - }); - }, - - start: function(amlNode, srcEl, e, customNode) { - if (document.elementFromPointReset) - document.elementFromPointReset(); - - amlNode.dragging = 1; - - var d = window.document; - d = (!d.compatMode || d.compatMode == "CSS1Compat") - ? d.html || d.documentElement - : d.body - - var scrollX = (apf.isIE ? d.scrollLeft : window.pageXOffset), - scrollY = (apf.isIE ? d.scrollTop : window.pageYOffset), - oParent = amlNode.$ext.offsetParent, - pos - while (oParent && oParent != d && oParent.tagName != "BODY") { - scrollX -= oParent.scrollLeft; - scrollY -= oParent.scrollTop; - oParent = oParent.offsetParent; - } - - //The coordinates need to be relative to the html element that - //represents the xml data node. - if (!srcEl && customNode) { - pos = [0, 0]; - } - else { - var loopEl = srcEl, lastId; - while (loopEl && loopEl.nodeType == 1 - && !(lastId = loopEl.getAttribute(apf.xmldb.htmlIdTag))) { - loopEl = loopEl.parentNode; - } - if (!lastId) - return; - pos = apf.getAbsolutePosition(loopEl); - } - - //Set coordinates object - apf.DragServer.coordinates = { - srcElement: srcEl, - doc: d, - scrollX: scrollX, - scrollY: scrollY, - offsetX: e.clientX - pos[0], - offsetY: e.clientY - pos[1], - clientX: e.pageX ? e.pageX - window.pageXOffset : e.clientX, - clientY: e.pageY ? e.pageY - window.pageYOffset : e.clientY - }; - - //Create Drag Data Object - var selection = customNode || amlNode.hasFeature(apf.__MULTISELECT__) - ? amlNode.getSelection() - : [amlNode.xmlRoot], - data = [], - srcRules = amlNode.isDragAllowed(selection, data); - if (!srcRules) return; - - if (amlNode.hasEventListener("dragdata")) - data = amlNode.dispatchEvent("dragdata", {data : data}); - - /*for(var i = 0, l = data.length; i < l; i++) { - data[i] = apf.getCleanCopy(data[i]); - }*/ - - this.dragdata = { - rules: srcRules, - selection: selection, - data: data, - indicator: amlNode.$showDragIndicator(selection, this.coordinates), - host: amlNode - }; - - //EVENT - cancelable: ondragstart - if (amlNode.dispatchEvent("dragstart", this.dragdata) === false) - return false;//(this.amlNode.$tempsel ? select(this.amlNode.$tempsel) : false); - - amlNode.dragging = 2; - - apf.dragMode = true; - document.onmousemove = this.onmousemove; - document.onmouseup = this.onmouseup; - }, - - stop: function(runEvent, success, e) { - if (this.last) this.dragout(); - - this.dragdata.host.dispatchEvent("dragstop", apf.extend(this.dragdata, { - success: success - })); - - //Reset Objects - this.dragdata.host.dragging = 0; - this.dragdata.host.$hideDragIndicator(success); - - /*if (runEvent && this.dragdata.host.$dragstop) - this.dragdata.host.$dragstop();*/ - - apf.dragMode = false; - document.onmousemove = - document.onmouseup = null; - - this.dragdata = null; - }, - - dragover: function(o, el, e) { - var _self = this, - originalEl = el; - - function checkPermission(targetEl) { - return o.isDropAllowed && o.xmlRoot - ? o.isDropAllowed(_self.dragdata.data, targetEl) - : apf.isTrue(apf.getInheritedAttribute(o, "", function(p) { - if (p.drop) { - o = p; - if (o == apf.DragServer.last) - return false; - return true; - } - })); - } - - e = e || window.event; - - //@todo optimize by not checking the same node dragged over twice in a row - var fEl; - if (o.$findValueNode) - fEl = o.$findValueNode(el); - - if (this.lastFel && this.lastFel == fEl - || !this.lastFel && this.last == o) //optimization - return; - - //Check Permission - var elSel = (fEl - ? apf.xmldb.getNode(fEl) - : apf.xmldb.findXmlNode(el)), - candrop = checkPermission(elSel || o.xmlRoot); - - if (this.last && this.last != o) - this.dragout(this.last, e); - - this.last = o; - this.lastFel = fEl; - - if (!candrop) { - if (o && o.$dragover) { - var parentNode = (elSel || o.xmlRoot).parentNode; - if (parentNode && (el = apf.xmldb.findHtmlNode(parentNode, o))) { - if (o.$findValueNode) - fEl = o.$findValueNode(el); - - elSel = (fEl - ? apf.xmldb.getNode(fEl) - : apf.xmldb.findXmlNode(el)); - - candrop = checkPermission(parentNode); - this.lastFel = el; - - - if (!candrop) - return; - } - else - return; - } - else - return; - } - - //EVENT - cancelable: ondragover - if (o.dispatchEvent("dragover", this.dragdata, { - target: (elSel || o.xmlRoot), - lastEl: o.lastel, - originalEl: originalEl - }) === false) - candrop = false; - - //Set Cursor - var srcEl = e.originalTarget || e.srcElement || e.target; - /*srcEl.style.cursor = (candrop ? o.icoAllowed : o.icoDenied); - if (srcEl.onmouseout != this.m_out) { - srcEl.$onmouseout = srcEl.onmouseout; - srcEl.onmouseout = this.m_out; - } - o.$ext.style.cursor = (candrop ? o.icoAllowed : o.icoDenied);*/ - - //REQUIRED INTERFACE: __dragover() - if (o && o.$dragover) - o.$dragover(el, this.dragdata, candrop); - }, - - dragout: function(o, e) { - //if (this.last == o) - //return false; - - this.lastFel = null; - - //EVENT: ondragout - if (o) { - this.dragdata.htmlEvent = e; - o.dispatchEvent("dragout", this.dragdata); - } - - //REQUIRED INTERFACE: __dragout() - if (this.last && this.last.$dragout) - this.last.$dragout(null, this.dragdata); - - //Reset Cursor - //o.$ext.style.cursor = "default"; - this.last = null; - }, - - dragdrop: function(o, el, srcO, e) { - var _self = this; - - function checkPermission(targetEl) { - return o.isDropAllowed && o.xmlRoot - ? o.isDropAllowed(_self.dragdata.data, targetEl) - : apf.isTrue(apf.getInheritedAttribute(o, "", function(p) { - if (p.drop) { - o = p; - return true; - } - })); - } - - //Check Permission - var isParent, lastTop, - elSel = (o.$findValueNode - ? apf.xmldb.getNode(o.$findValueNode(el)) - : apf.xmldb.findXmlNode(el)), - candrop = checkPermission(elSel || o.xmlRoot); - - if (this.dragdata.indicator) { - lastTop = this.dragdata.indicator.style.top; - this.dragdata.indicator.style.top = "10000px"; - } - - if (!candrop) { - if (o && o.$dragover) { - var parentNode = (elSel || o.xmlRoot).parentNode, - htmlParentNode; - if (parentNode && (htmlParentNode = apf.xmldb.findHtmlNode(parentNode, o))) { - isParent = true; - candrop = checkPermission(parentNode); - el = htmlParentNode; - } - } - } - - //EVENT - cancelable: ondragdrop - if (candrop) { - if (o.dispatchEvent("dragdrop", apf.extend({candrop : candrop, htmlEvent : e, top: lastTop}, - this.dragdata)) === false) { - candrop = false; - } - else { - if (!o.xmlRoot) { - var m = o.getModel - ? o.getModel(true) - : - - apf.nameserver.get("model", o.model) - - if (m) - m.load(this.dragdata.data[0]) - //else warn?? - return true; - } - else { - var action = candrop[1] - && candrop[1].action - || (o.$isTreeArch ? "tree-append" : "list-append"); - if (action == "list-append" && (!o.$isTreeArch && o == this.dragdata.host)) - candrop = false; - } - } - } - - if (this.dragdata.indicator) - this.dragdata.indicator.style.top = lastTop; - - //Exit if not allowed - if (!candrop) { - this.dragout(o, e); - return false; - } - - if (o.$dragDrop) { - //Move XML - var rNode = o.$dragDrop(candrop[0], this.dragdata.data, candrop[1], - action, isParent || candrop[0] == o.xmlRoot, this.dragdata.rules, e); - this.dragdata.resultNode = rNode; - } - - if (o.$dragdrop) { - o.$dragdrop(el, apf.extend({ - htmlEvent: e, - xmlNode: rNode - }, this.dragdata), candrop); - } - - //Reset Cursor - //o.$ext.style.cursor = "default"; - this.last = null; - this.lastFel = null; - - return true; - }, - - /* ********************** - Mouse Movements - ***********************/ - - onmousemove: function(e) { - if (!apf.DragServer.dragdata) return; - e = e || window.event; - - - var dragdata = apf.DragServer.dragdata, - c = { - clientX: e.pageX ? e.pageX - window.pageXOffset : e.clientX, - clientY: e.pageY ? e.pageY - window.pageYOffset : e.clientY - }; - - if (!dragdata.started - && Math.abs(apf.DragServer.coordinates.clientX - c.clientX) < 6 - && Math.abs(apf.DragServer.coordinates.clientY - c.clientY) < 6) - return; - - if (!dragdata.started) { - if (dragdata.host.$dragstart) - dragdata.host.$dragstart(null, dragdata); - dragdata.started = true; - } - - //dragdata.indicator.style.top = e.clientY+"px"; - //dragdata.indicator.style.left = e.clientX+"px"; - - if (dragdata.indicator) { - var storeIndicatorTopPos = dragdata.indicator.style.top; - //console.log("INDICATOR BEFORE: "+dragdata.indicator.style.top+" "+dragdata.indicator.style.left); - //get Element at x, y - dragdata.indicator.style.display = "block"; - dragdata.indicator.style.top = "10000px"; - } - apf.DragServer.dragdata.x = e.pageX ? e.pageX - (!apf.isIE - ? window.pageXOffset - : 0) : c.clientX; - apf.DragServer.dragdata.y = e.pageY ? e.pageY - (!apf.isIE - ? window.pageYOffset - : 0) : c.clientY; - var el = document.elementFromPoint(apf.DragServer.dragdata.x, - apf.DragServer.dragdata.y); - if (!el) { - el = document.elementFromPoint(apf.DragServer.dragdata.x, - apf.DragServer.dragdata.y); - } - - if (dragdata.indicator) - dragdata.indicator.style.top = storeIndicatorTopPos; - //console.log("INDICATOR AFTER: "+dragdata.indicator.style.top+" " - //+dragdata.indicator.style.left+" "+apf.DragServer.dragdata.x+" "+apf.DragServer.dragdata.y); - //Set Indicator - dragdata.host.$moveDragIndicator(c); - - //get element and call events - var receiver = apf.findHost(el); - - //Run Events - if (receiver) - apf.DragServer.dragover(receiver, el, e); - else if (apf.DragServer.last) - apf.DragServer.dragout(apf.DragServer.last, e); - - apf.DragServer.lastTime = new Date().getTime(); - }, - - onmouseup: function(e) { - e = e || window.event; - - - var c = { - clientX: e.pageX ? e.pageX - window.pageXOffset : e.clientX, - clientY: e.pageY ? e.pageY - window.pageYOffset : e.clientY - }; - - if (!apf.DragServer.dragdata.started - && Math.abs(apf.DragServer.coordinates.clientX - c.clientX) < 6 - && Math.abs(apf.DragServer.coordinates.clientY - c.clientY) < 6) { - apf.DragServer.stop(true, null, e) - return; - } - - //get Element at x, y - var indicator = apf.DragServer.dragdata.indicator, - storeIndicatorTopPos = indicator.style.top; - //apf.console.info("INDICATOR UP BEFORE: "+indicator.style.top+" "+indicator.style.left); - if (indicator) - indicator.style.top = "10000px"; - - apf.DragServer.dragdata.x = e.pageX ? e.pageX - (!apf.isIE - ? window.pageXOffset - : 0) : c.clientX; - apf.DragServer.dragdata.y = e.pageY ? e.pageY - (!apf.isIE - ? window.pageYOffset - : 0) : c.clientY; - - var el = document.elementFromPoint(apf.DragServer.dragdata.x, - apf.DragServer.dragdata.y); - if (!el) { - el = document.elementFromPoint(apf.DragServer.dragdata.x, - apf.DragServer.dragdata.y); - } - - indicator.style.top = storeIndicatorTopPos; - //apf.console.info("INDICATOR UP AFTER: "+indicator.style.top+" "+indicator.style.left); - - //get element and call events - var host = apf.findHost(el); - - //Run Events - if (apf.DragServer.host && host != apf.DragServer.host) - apf.DragServer.dragout(apf.DragServer.host, e); - var success = apf.DragServer.dragdrop(host, el, apf.DragServer.dragdata.host, e); - apf.DragServer.stop(true, success, e); - } -}; - -/* - * @private - */ -apf.MultiselectDragDrop = function() { - // *** Drag & Drop *** // - - this.diffX = - this.diffY = 0; - this.multiple = false; - this.lastDragNode = null; - this.lastel = null; - - this.$showDragIndicator = function(sel, e) { - var srcEl = e.originalTarget || e.srcElement || e.target; - - this.multiple = sel.length > 1; - - if (this.multiple) { - this.diffX = e.scrollX; - this.diffY = e.scrollY; - } - else { - var itemNode = apf.xmldb.findHtmlNode(sel[0], this); - this.diffX = -1 * (e.offsetX - parseInt(apf.getStyleRecur(itemNode, "padding-left").replace(/px$/, "") - 10)); - this.diffY = -1 * e.offsetY; - } - - var prefix = this.oDrag.className.split(" ")[0] - //@todo the class should be removed here - this.$setStyleClass(this.oDrag, (this.multiple - ? prefix + "_multiple" : "") + (this["class"] ? " " + this["class"] : ""), [prefix + "_multiple"]); - - if (this.multiple) { - document.body.appendChild(this.oDrag); - return this.oDrag; - } - else if (this.localName == "datagrid") { - if (this.lastDragNode) - apf.destroyHtmlNode(this.lastDragNode); - - sel = this.$selected || this.$caret; - var oDrag = sel.cloneNode(true); - oDrag.removeAttribute("onmousedown");oDrag.onmousedown = null; - oDrag.removeAttribute("onmouseup");oDrag.onmouseup = null; - oDrag.removeAttribute("onmouseout");oDrag.onmouseout = null; - oDrag.removeAttribute("ondblclick");oDrag.ondblclick = null; - document.body.appendChild(oDrag); - - oDrag.style.position = "absolute"; - oDrag.style.width = sel.offsetWidth + "px"; - oDrag.style.display = "none"; - oDrag.removeAttribute("id"); - - this.$setStyleClass(oDrag, "draggrid"); - var nodes = sel.childNodes; - var dragnodes = oDrag.childNodes; - for (var i = nodes.length - 1; i >= 0; i--) { - if (dragnodes[i].nodeType == 1) - dragnodes[i].style.width = apf.getStyle(nodes[i], "width"); - } - //@todo apf3.0 remove all the event handlers of the children. - return (this.lastDragNode = oDrag); - } - else { - var sel = this.$selected || this.$caret, - width = apf.getStyle(this.oDrag, "width"); - - if (!sel) - return; - - // if (!width || width == "auto") - // this.oDrag.style.width = (sel.offsetWidth - apf.getWidthDiff(this.oDrag)) + "px"; - this.$updateNode(this.selected, this.oDrag); - } - - apf.window.zManager.set("drag", this.oDrag); - - return this.oDrag; - }; - - this.$hideDragIndicator = function(success) { - var oDrag = this.lastDragNode || this.oDrag, _self = this; - if (!this.multiple && !success && oDrag.style.display == "block") { - if (!this.$selected && !this.$caret) - return; - - var pos = apf.getAbsolutePosition(this.$selected || this.$caret); - apf.tween.multi(oDrag, { - anim: apf.tween.easeInOutCubic, - steps: 20, - interval: 15, - tweens: [ - {type: "left", from: oDrag.offsetLeft, to: (pos[0] + parseInt(apf.getStyleRecur(this.$selected, "padding-left").replace(/px$/, "")))}, - {type: "top", from: oDrag.offsetTop, to: pos[1]} - ], - onfinish: function(){ - if (_self.lastDragNode) { - apf.destroyHtmlNode(_self.lastDragNode); - _self.lastDragNode = null; - } - else { - _self.oDrag.style.display = "none"; - } - } - }); - } - else if (this.lastDragNode) { - apf.destroyHtmlNode(this.lastDragNode); - this.lastDragNode = null; - } - else { - this.oDrag.style.display = "none"; - } - }; - - this.$moveDragIndicator = function(e) { - var oDrag = this.lastDragNode || this.oDrag; - oDrag.style.left = (e.clientX + this.diffX) + "px";// - this.oDrag.startX - oDrag.style.top = (e.clientY + this.diffY + (this.multiple ? 15 : 0)) + "px";// - this.oDrag.startY - }; - - this.addEventListener("$skinchange", function(){ - this.$initDragDrop(); - }); - - this.$initDragDrop = function(){ - if (!this.$hasLayoutNode("dragindicator")) - return; - - this.oDrag = apf.insertHtmlNode( - this.$getLayoutNode("dragindicator"), document.body); - - apf.window.zManager.set("drag", this.oDrag); - - this.oDrag.style.position = "absolute"; - this.oDrag.style.cursor = "default"; - this.oDrag.style.display = "none"; - }; - - this.$findValueNode = function(el) { - if (!el) return null; - - while (el && el.nodeType == 1 - && !el.getAttribute(apf.xmldb.htmlIdTag)) { - if (this.$isTreeArch && el.previousSibling - && el.previousSibling.nodeType == 1) //@todo hack!! apf3.0 fix this. - el = el.previousSibling; - else - el = el.parentNode; - } - - return (el && el.nodeType == 1 && el.getAttribute(apf.xmldb.htmlIdTag)) - ? el - : null; - }; - - - this.$dragout = function(el, dragdata, extra) { - if (this.lastel) - this.$setStyleClass(this.lastel, "", ["dragDenied", "dragInsert", - "dragAppend", "selected", "indicate"]); - - var sel = this.$getSelection(true); - for (var i = 0, l = sel.length; i < l; i++) - this.$setStyleClass(sel[i], "selected", ["dragDenied", - "dragInsert", "dragAppend", "indicate"]); - - this.$setStyleClass(this.$ext, "", [this.$baseCSSname + "Drop"]); - - this.lastel = null; - }; - - if (!this.$dragdrop) - this.$dragdrop = this.$dragout; - - this.$dragover = function(el, dragdata, extra) { - this.$setStyleClass(this.$ext, this.$baseCSSname + "Drop"); - - var sel = this.$getSelection(true); - for (var i = 0, l = sel.length; i < l; i++) - this.$setStyleClass(sel[i], "", ["dragDenied", - "dragInsert", "dragAppend", "selected", "indicate"]); - - if (this.lastel) - this.$setStyleClass(this.lastel, "", ["dragDenied", - "dragInsert", "dragAppend", "selected", "indicate"]); - - var action = extra[1] && extra[1].action; - this.lastel = this.$findValueNode(el); - if (this.$isTreeArch && action == "list-append") { - var htmlNode = apf.xmldb.findHtmlNode(this.getTraverseParent(apf.xmldb.getNode(this.lastel)), this); - - this.lastel = htmlNode - ? this.$getLayoutNode("item", "container", htmlNode) - : this.$container; - - this.$setStyleClass(this.lastel, "dragInsert"); - } - else { - this.$setStyleClass(this.lastel, extra - ? (action == "insert-before" - ? "dragInsert" - : "dragAppend") - : "dragDenied"); - } - }; - -}; - -/* - * @private - */ -apf.StandardDragDrop = function() { - this.$showDragIndicator = function(sel, e) { - var x = e.offsetX + 22, - y = e.offsetY; - - this.oDrag.startX = x; - this.oDrag.startY = y; - - - document.body.appendChild(this.oDrag); - //this.oDrag.getElementsByTagName("DIV")[0].innerHTML = this.selected.innerHTML; - //this.oDrag.getElementsByTagName("IMG")[0].src = this.selected.parentNode.parentNode.childNodes[1].firstChild.src; - var oInt = this.$getLayoutNode("main", "caption", this.oDrag); - if (oInt.nodeType != 1) - oInt = oInt.parentNode; - - oInt.innerHTML = this.$applyBindRule("caption", this.xmlRoot) || ""; - - return this.oDrag; - }; - - this.$hideDragIndicator = function(){ - this.oDrag.style.display = "none"; - }; - - this.$moveDragIndicator = function(e) { - this.oDrag.style.left = (e.clientX - this.oDrag.startX - + document.documentElement.scrollLeft) + "px"; - this.oDrag.style.top = (e.clientY - this.oDrag.startY - + document.documentElement.scrollTop) + "px"; - }; - - //@todo falsely assuming only attributes are used for non multiselect widgets - this.$initDragDrop = function(){ - if (!this.getAttribute("drag")) - return; - - this.oDrag = document.body.appendChild(this.$ext.cloneNode(true)); - - apf.window.zManager.set("drag", this.oDrag); - - this.oDrag.style.position = "absolute"; - this.oDrag.style.cursor = "default"; - this.oDrag.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; - this.oDrag.style.MozOpacity = 0.5; - this.oDrag.style.opacity = 0.5; - this.oDrag.style.display = "none"; - }; -}; - -apf.DragServer.Init(); - - - - - @@ -20829,9 +19059,6 @@ apf.__TRANSACTION__ = 1 << 3; -apf.__VIRTUALVIEWPORT__ = 1 << 19; - - @@ -30720,916 +28947,11 @@ apf.aml.setElement("script", apf.script); -//@todo: fix the stuff with all the uppercase variable and function names...wazzup? - -/** - * @constructor - * @private - */ -apf.scrollbar = function(struct, tagName) { - this.$init(tagName || "scrollbar", apf.NODE_VISIBLE, struct); -}; - -(function(){ - this.realtime = true; - this.visible = false; - this.overflow = "scroll"; - this.position = 0; - - this.$visible = true; - this.$scrollSizeValue = 0; - this.$stepValue = 0.03; - this.$bigStepValue = 0.1; - this.$timer = null; - this.$scrollSizeWait; - this.$slideMaxSize; - - this.$booleanProperties = ["showonscroll"]; - - this.addEventListener("focus", function(){ - this.$viewport.focus(); - }); - - this.$propHandlers["showonscroll"] = function(value) { - clearTimeout(this.$hideOnScrollTimer); - - if (value) { - this.$ext.style.display = "none"; - } - else { - this.$ext.style.display = "block"; - this.show(); //Trigger positioning event - } - }; - - this.$propHandlers["overflow"] = function(value) { - if (this.showonscroll) - return; - - if (value == "auto") { - this.$ext.style.display = "none"; - this.$resize(); - } - else if (value == "scroll") { - this.setProperty("visible", true); - } - } - - this.$propHandlers["for"] = function(value) { - if (value) { - var amlNode = typeof value == "string" ? self[value] : value; - if (!amlNode || !amlNode.$amlLoaded) { - var _self = this; - apf.queue.add("scrollbar" + this.$uniqueId, function(){ - if (!amlNode) { - amlNode = typeof value == "string" ? self[value] : value; - - if (!amlNode) { - throw new Error(apf.formatErrorString(0, _self, - "Attaching scrollbar to element", - "Could not find element to attach scrollbar to: " + value)); - } - } - _self.attach(amlNode); - }); - } - else - this.attach(amlNode); - } - } - - this.addEventListener("prop.visible", function(e) { - if (!this.$updating) { - this.$visible = e.value; - } - }); - - this.attach = function(viewport) { - if (viewport.nodeFunc) { - - if (viewport.hasFeature(apf.__VIRTUALVIEWPORT__)) - viewport = viewport.$viewport; - else - - viewport = new apf.ViewPortAml(viewport); - } - else if (viewport.style) - viewport = new apf.ViewPortHtml(viewport); - - this.$attach(viewport); - }; - - /** - * @todo detach - */ - this.$attach = function(viewport) { - if (!viewport) - return apf.console.warn("Scrollbar could not connect to viewport"); - - var _self = this; - - this.$viewport = viewport; - - if (this.$viewport.scrollbar != this) { - this.$viewport.setScrollbar(this, function(e) { - if (_self.$viewport != viewport) - return; - - _self.$update(); - - if (_self.showonscroll) { // && e.byUser) { - if (!_self.scrolling) - _self.$resize(); - - _self.scrolling = true; - - clearTimeout(_self.$hideOnScrollTimer); - if (_self.$hideOnScrollControl) - _self.$hideOnScrollControl.stop(); - - apf.setOpacity(_self.$ext, 1); - !_self.visible ? _self.show() : _self.$ext.style.display = "block"; - _self.$update(); - - _self.$hideOnScrollTimer = _self.animHideScrollbar(500, function(){ - _self.scrolling = false; - }); - } - }); - } - - this.$recalc(); - this.$update(); - - return this; - }; - - this.$resize = function(){ - if (!this.$viewport || !this.$viewport.isVisible()) - return; - - this.$recalc(); - this.$update(); - - if (!this.$viewport.virtual) - return; - - this.setScrollPosition(this.position, true); - } - - this.$recalc = function(){ - this.$viewheight = this.$viewport.getHeight(); - this.$scrollSizeheight = this.$viewheight; - this.$scrollSizeWait = 0;//(this.$host.len * COLS)/2; - this.$stepValue = (this.$viewheight / this.$scrollSizeheight) / 20; - this.$bigStepValue = this.$stepValue * 3; - this.$slideMaxSize = this.$caret.parentNode[this.$offsetSize] - - (this.$btnDown ? this.$btnDown[this.$offsetSize] : 0) - - (this.$btnUp ? this.$btnUp[this.$offsetSize] : 0); - } - - //@todo this function is called way too many times - this.$update = function(){ - // Commented this out because otherwise a tree expansion wouldn't - // show the scrollbar again - //if (this.animating || !this.$visible) - // return; - - if (this.showonscroll && !this.$ext.offsetHeight) - return; - - var viewport = this.$viewport; - if (!viewport || !viewport.isVisible()) - return; - - this.$updating = true; - - //Disable scrollbar - var vp = viewport.getHeight(); - var sz = viewport.getScrollHeight(); - - if (vp >= sz) { - if (this.overflow == "scroll") { - this.$caret.style.display = "none"; - this.disable(); - } - else if (this.visible) { - this.hide(); - - //this.$ext.style.display = "none"; - } - //if (this.id == "sbtest") console.log(vp + ":" + sz); - //oHtml.style.overflowY = "visible"; - } - //Enable scrollbar - else { - if (this.overflow == "scroll") { - this.$caret.style.display = "block"; - this.enable(); - } - else if (!this.visible) { - this.show(); - //this.$ext.style.display = "block"; - //this.$caret.style.display = "block"; - } - - if (!this.$slideMaxSize) - this.$recalc(); - if (!this.$slideMaxSize) - return; - - //oHtml.style.overflowY = "scroll"; - - //Set scroll size - this.$caret.style[this.$size] = (Math.max(5, (vp / sz - * this.$slideMaxSize)) - apf[this.$getDiff](this.$caret)) + "px"; - //if (this.$caret.offsetHeight - 4 == this.$slideMaxSize) - //this.$ext.style.display = "none"; - - this.position = viewport.getScrollTop() / (sz - vp); - - var bUpHeight = this.$btnUp ? this.$btnUp[this.$offsetSize] : 0; - this.$caret.style[this.$pos] = (bUpHeight + (apf[this.$getInner](this.$caret.parentNode) - - (bUpHeight * 2) - this.$caret[this.$offsetSize]) * this.position) + "px"; - } - - this.$updating = false; - } - - this.setScrollPosition = function(position, preventEvent) { - if (position == NaN) { - - return; - } - - if (position > 1) - position = 1; - if (position < 0) - position = 0; - - this.position = position; - - // Set the caret position - var bUpHeight = this.$btnUp ? this.$btnUp[this.$offsetSize] : 0; - this.$caret.style[this.$pos] = (bUpHeight + (apf[this.$getInner](this.$caret.parentNode) - - (bUpHeight * 2) - this.$caret[this.$offsetSize]) * this.position) + "px"; - - // Don't signal anything when animating or when not visible - if (this.animating || !this.$visible) - return; - - var vp = this.$viewport; - var to = (vp.getScrollHeight() - vp.getHeight()) * position; - - vp.setScrollTop(to, preventEvent); - } - - this.animShowScrollbar = function(timeout, cb) { - var _self = this; - return setTimeout(function(){ - _self.$ext.style.display = "block"; - - if (_self.$showOnScrollControl - && _self.$showOnScrollControl.state == apf.tween.RUNNING) - return; - - if (_self.$hideOnScrollControl) - _self.$hideOnScrollControl.stop(); - - _self.$resize(); - - apf.tween.single(_self.$ext, { - control: _self.$hideOnScrollControl = {}, - type: "fade", - from: 0, - to: 1, - onfinish: function(){ - cb && cb(); - } - }); - }, timeout) - } - - this.animHideScrollbar = function(timeout, cb) { - var _self = this; - return setTimeout(function(){ - if (_self.$hideOnScrollControl - && _self.$hideOnScrollControl.state == apf.tween.RUNNING) - return; - - if (_self.$showOnScrollControl) - _self.$showOnScrollControl.stop(); - apf.tween.single(_self.$ext, { - control: _self.$hideOnScrollControl = {}, - type: "fade", - from: 1, - to: 0, - steps: 20, - onfinish: function(){ - _self.$ext.style.display = "none"; - apf.setOpacity(_self.$ext, 1); - - cb && cb(); - } - }); - }, timeout) - } - - this.scrollUp = function (v) { - if (v > this.$caret[this.$offsetPos]) - return this.$ext.onmouseup(); - this.setScrollPosition(this.position + this.$bigStepValue); - - if (this.$slideFast) { - this.$slideFast.style[this.$size] = Math.max(1, this.$caret[this.$offsetPos] - - this.$btnUp[this.$offsetSize]) + "px"; - this.$slideFast.style[this.$pos] = this.$btnUp[this.$offsetSize] + "px"; - } - } - - this.scrollDown = function (v) { - if (v < this.$caret[this.$offsetPos] + this.$caret[this.$offsetSize]) - return this.$ext.onmouseup(); - this.setScrollPosition(this.position + this.$bigStepValue); - - if (this.$slideFast) { - this.$slideFast.style[this.$pos] = (this.$caret[this.$offsetPos] + this.$caret[this.$offsetSize]) + "px"; - this.$slideFast.style[this.$size] = Math.max(1, apf[this.$getInner](this.$caret.parentNode) - this.$slideFast[this.$offsetPos] - - this.$btnUp[this.$offsetSize]) + "px"; - } - } - - this.$draw = function(){ - //Build Skin - this.$getNewContext("main"); - this.$ext = this.$getExternal(); - //this.$ext.style.display = "none"; - - this.$caret = this.$getLayoutNode("main", "indicator", this.$ext); - this.$slideFast = this.$getLayoutNode("main", "slidefast", this.$ext); - this.$btnUp = this.$getLayoutNode("main", "btnup", this.$ext) - this.$btnDown = this.$getLayoutNode("main", "btndown", this.$ext); - - this.horizontal = apf.isTrue(this.$getOption("main", "horizontal")); - - this.$windowSize = this.horizontal ? "getWindowWidth" : "getWindowHeight"; - this.$offsetSize = this.horizontal ? "offsetWidth" : "offsetHeight"; - this.$size = this.horizontal ? "width" : "height"; - this.$offsetPos = this.horizontal ? "offsetLeft" : "offsetTop"; - this.$pos = this.horizontal ? "left" : "top"; - this.$scrollSize = this.horizontal ? "scrollWidth" : "scrollHeight"; - this.$scrollPos = this.horizontal ? "scrollLeft" : "scrollTop"; - this.$getDiff = this.horizontal ? "getWidthDiff" : "getHeightDiff"; - this.$getInner = this.horizontal ? "getHtmlInnerWidth" : "getHtmlInnerHeight"; - this.$eventDir = this.horizontal - ? (apf.isIE || apf.isWebkit ? "offsetX" : "layerX") - : (apf.isIE || apf.isWebkit ? "offsetY" : "layerY"); - this.$clientDir = this.horizontal ? "clientX" : "clientY"; - this.$posIndex = this.horizontal ? 0 : 1; - - this.$startPos = false; - - this.$caret.ondragstart = function(){ - return false - }; - - var _self = this; - if (this.$btnUp) { - this.$btnUp.onmousedown = function(e) { - if (_self.disabled) - return; - - if (!e) - e = event; - this.className = "btnup btnupdown"; - clearTimeout(_self.$timer); - - _self.setScrollPosition(_self.position - _self.$stepValue); - apf.stopPropagation(e); - - //apf.window.$mousedown(e); - - _self.$timer = $setTimeout(function(){ - _self.$timer = setInterval(function(){ - _self.setScrollPosition(_self.position - _self.$stepValue); - }, 20); - }, 300); - }; - - this.$btnUp.onmouseout = this.$btnUp.onmouseup = function(){ - if (_self.disabled) - return; - - this.className = "btnup"; - clearInterval(_self.$timer); - }; - } - - if (this.$btnDown) { - this.$btnDown.onmousedown = function(e) { - if (_self.disabled) - return; - - if (!e) - e = event; - this.className = "btndown btndowndown"; - clearTimeout(_self.$timer); - - _self.setScrollPosition(_self.position + _self.$stepValue) - apf.stopPropagation(e); - - //apf.window.$mousedown(e); - - _self.$timer = $setTimeout(function(){ - _self.$timer = setInterval(function(){ - _self.setScrollPosition(_self.position + _self.$stepValue) - }, 20); - }, 300); - }; - - this.$btnDown.onmouseout = this.$btnDown.onmouseup = function(){ - if (_self.disabled) - return; - - this.className = "btndown"; - clearInterval(_self.$timer); - }; - } - - this.$caret.onmousedown = function(e) { - if (_self.disabled) - return; - - if (!e) - e = event; - - var tgt = e.target || e.srcElement; - var pos = tgt != this - ? [tgt.offsetLeft, tgt.offsetTop] //Could be improved - : [0, 0]; - - var relDelta = e[_self.$eventDir] + pos[_self.$posIndex]; - _self.$startPos = relDelta + - (_self.$btnUp ? _self.$btnUp[_self.$offsetSize] : 0); - - if (this.setCapture) - this.setCapture(); - - _self.$setStyleClass(_self.$ext, _self.$baseCSSname + "Down"); - _self.dispatchEvent("mousedown", {}); - - _self.dragging = true; - - document.onmousemove = function(e) { - if (!e) - e = event; - //if(e.button != 1) return _self.onmouseup(); - if (_self.$startPos === false) - return false; - - var bUpHeight = _self.$btnUp ? _self.$btnUp[_self.$offsetSize] : 0; - var next = bUpHeight + (e[_self.$clientDir] - _self.$startPos - + (apf.isWebkit ? document.body : document.documentElement)[_self.$scrollPos] - - apf.getAbsolutePosition(_self.$caret.parentNode)[_self.horizontal ? 0 : 1]); // - 2 - var min = bUpHeight; - if (next < min) - next = min; - var max = (apf[_self.$getInner](_self.$caret.parentNode) - - bUpHeight - _self.$caret[_self.$offsetSize]); - if (next > max) - next = max; - //_self.$caret.style.top = next + "px" - - _self.setScrollPosition((next - min) / (max - min)); - }; - - document.onmouseup = function(){ - _self.$startPos = false; - if (!_self.realtime) - _self.setScrollPosition(_self.position); - - if (this.releaseCapture) - this.releaseCapture(); - - _self.$setStyleClass(_self.$ext, "", [_self.$baseCSSname + "Down"]); - _self.dispatchEvent("mouseup", {}); - - _self.dragging = false; - - document.onmouseup = - document.onmousemove = null; - }; - - apf.stopPropagation(e); - //apf.window.$mousedown(e); - - return false; - }; - - this.$ext.onmousedown = function(e) { - if (_self.disabled) - return; - if (!e) - e = event; - clearInterval(_self.$timer); - var offset; - if (e[_self.$eventDir] > _self.$caret[_self.$offsetPos] + _self.$caret[_self.$offsetSize]) { - _self.setScrollPosition(_self.position + _self.$bigStepValue); - - if (_self.$slideFast) { - _self.$slideFast.style.display = "block"; - _self.$slideFast.style[_self.$pos] = (_self.$caret[_self.$offsetPos] - + _self.$caret[_self.$offsetSize]) + "px"; - _self.$slideFast.style[_self.$size] = (apf[_self.$getInner](_self.$caret.parentNode) - _self.$slideFast[_self.$offsetPos] - - _self.$btnUp[_self.$offsetSize]) + "px"; - } - - offset = e[_self.$eventDir]; - _self.$timer = $setTimeout(function(){ - _self.$timer = setInterval(function(){ - _self.scrollDown(offset, null, null, true); - }, 20); - }, 300); - } - else if (e[_self.$eventDir] < _self.$caret[_self.$offsetPos]) { - _self.setScrollPosition(_self.position - _self.$bigStepValue); - - if (_self.$slideFast) { - _self.$slideFast.style.display = "block"; - _self.$slideFast.style[_self.$pos] = _self.$btnUp[_self.$offsetSize] + "px"; - _self.$slideFast.style[_self.$size] = (_self.$caret[_self.$offsetPos] - _self.$btnUp[_self.$offsetSize]) + "px"; - } - - offset = e[_self.$eventDir]; - _self.$timer = $setTimeout(function(){ - _self.$timer = setInterval(function(){ - _self.scrollUp(offset, null, null, true); - }, 20); - }, 300); - } - }; - - this.$ext.onmouseup = function(){ - if (_self.disabled) - return; - - clearInterval(_self.$timer); - if (!_self.realtime) - _self.setScrollPosition(_self.position); - if (_self.$slideFast) - _self.$slideFast.style.display = "none"; - }; - - this.$ext.onmouseover = function(e) { - _self.dispatchEvent("mouseover", {htmlEvent : e || event}); - }; - - this.$ext.onmouseout = function(e) { - _self.dispatchEvent("mouseout", {htmlEvent : e || event}); - }; - } - - this.$loadAml = function(){ - if (this.overflow == "scroll") - this.disable(); - else { - this.$caret.style.display = "block"; - this.enable(); - } - - this.addEventListener("resize", this.$resize); - this.$update(); - } -}).call(apf.scrollbar.prototype = new apf.Presentation()); -apf.aml.setElement("scrollbar", apf.scrollbar); apf.GuiElement.propHandlers["scrollbar"] = function(value) { - if (this.$sharedScrollbar == undefined) { - var values = value.split(" "); - var name = values[0]; - var top = values[1] || 0; - var right = values[2] || 0; - var bottom = values[3] || 0; - - var _self = this; - this.$sharedScrollbar = self[name] || false; - if (!this.$sharedScrollbar) - return; - - function hasOnScroll(){ - return sb && apf.isTrue(sb.getAttribute("showonscroll")); - } - - var oHtml = this.$container || this.$int || this.$ext, timer, sb; - var mouseMove; - apf.addListener(oHtml, "mousemove", mouseMove = function(e) { - if (!_self.$sharedScrollbar) - _self.$sharedScrollbar = self[name]; - - sb = _self.$sharedScrollbar; - - if (!sb.$addedMouseOut) { - apf.addListener(sb.$ext, "mouseout", function(e) { - if (!hasOnScroll()) - return; - - if (apf.findHost(e.fromElement) == sb && apf.findHost(e.toElement) != sb) { - clearTimeout(timer); - hideScrollbar(); - } - }); - sb.$addedMouseOut = true; - } - - if (!sb.$viewport || sb.$viewport.amlNode != _self) { - var pNode = (_self.$ext == oHtml ? _self.$ext.parentNode : _self.$ext); - pNode.appendChild(sb.$ext); - - if (apf.getStyle(pNode, "position") == "static") - pNode.style.position = "relative"; - - sb.setProperty("showonscroll", true); - sb.$ext.style.display = "block"; - sb.setAttribute("top", top); - sb.setAttribute("right", right); - sb.setAttribute("bottom", bottom); - sb.setAttribute("for", _self); - sb.$ext.style.display = "none"; - sb.dragging = false; - - if (sb.$hideOnScrollControl) - sb.$hideOnScrollControl.stop(); - } - - if (hasOnScroll() && e) { - clearTimeout(timer); - - var pos = apf.getAbsolutePosition(oHtml); - var rightPos = oHtml.offsetWidth - (e.clientX - pos[0]); - var show = rightPos < 25 && rightPos > right; - if (show && sb.$ext.style.display == "none" - || !show && sb.$ext.style.display == "block") { - if (show) - showScrollbar(); - else - hideScrollbar(); - } - else if (!show) - sb.showonscroll = true; - } - }); - - this.$sharedScrollbarMove = mouseMove; - - function showScrollbar(){ - sb.setProperty("showonscroll", false); - sb.$ext.style.display = "none"; - timer = sb.animShowScrollbar(200); - } - - function hideScrollbar(timeout) { - if (sb.scrolling) - return; - - if (!sb.dragging) - timer = sb.animHideScrollbar(timeout || 200, function(){ - sb.setProperty("showonscroll", true); - }); - else - apf.addListener(document, "mouseup", function(e) { - var tgt = apf.findHost(e.target); - if (tgt == sb) - return; - - if (tgt == _self) - mouseMove(e); - else - hideScrollbar(); - - apf.removeListener(document, "mouseup", arguments.callee); - }); - } - - apf.addListener(oHtml, "mouseout", function(e) { - if (!hasOnScroll()) - return; - - var el = apf.findHost(e.toElement || e.rangeParent); - if (el != sb && el != sbShared.$viewport.amlNode) { - clearTimeout(timer); - hideScrollbar(); - } - }); - } + debugger }; -apf.ViewPortAml = function(amlNode) { - this.amlNode = amlNode; - - var _self = this; - var update = function(){ - if (_self.scrollbar) - _self.scrollbar.$update(); - }; - - amlNode.addEventListener("resize", update); - if (amlNode.hasFeature(apf.__DATABINDING__)) { - amlNode.addEventListener("afterload", update); - amlNode.addEventListener("xmlupdate", update); - } - - amlNode.addEventListener("prop.value", update); - - if (amlNode.$isTreeArch) { - amlNode.addEventListener("collapse", update); - amlNode.addEventListener("expand", update); - } - - amlNode.addEventListener("mousescroll", function(e) { - _self.$mousescroll(e); - }); - - var htmlNode = _self.$getHtmlHost(); - apf.addListener(htmlNode, "scroll", function(){ - if (_self.scrollbar.animating || !_self.scrollbar.$visible) - return; - - _self.setScrollTop(this.scrollTop); - }); - - if ("HTML|BODY".indexOf(htmlNode.tagName) > -1) { - var lastHeight = htmlNode.scrollHeight; - setInterval(function(){ - if (lastHeight != htmlNode.scrollHeight) { - lastHeight = htmlNode.scrollHeight; - _self.scrollbar.$recalc(); - _self.scrollbar.$update(); - } - }, 100); - } -}; - -(function(){ - this.setScrollbar = function(scrollbar, onscroll) { - this.scrollbar = scrollbar; - - this.amlNode.addEventListener("scroll", onscroll); - } - - this.isVisible = function(){ - var htmlNode = this.$getHtmlHost(); - return htmlNode.offsetHeight || htmlNode.offsetWidth ? true : false; - } - - this.focus = function(){ - if (this.amlNode.focus && this.amlNode.$isWindowContainer !== true) - this.amlNode.focus(); - } - - this.getScrollTop = function(){ - var htmlNode = this.$getHtmlHost(); - return htmlNode.scrollTop; - } - - this.getScrollLeft = function(){ - var htmlNode = this.$getHtmlHost(); - return htmlNode.scrollLeft; - } - - this.getScrollHeight = function(){ - var htmlNode = this.$getHtmlHost(); - return (htmlNode.scrollHeight); - } - - this.getScrollWidth = function(){ - var htmlNode = this.$getHtmlHost(); - return (htmlNode.scrollWidth); - } - - this.getHeight = function(){ - var htmlNode = this.$getHtmlHost(); - return htmlNode.tagName == "HTML" || htmlNode.tagName == "BODY" - ? apf.getWindowHeight() - : apf.getHtmlInnerHeight(htmlNode); - } - - this.getWidth = function(){ - var htmlNode = this.$getHtmlHost(); - return htmlNode.tagName == "HTML" || htmlNode.tagName == "BODY" - ? apf.getWindowHeight() - : apf.getHtmlInnerWidth(htmlNode); - } - - this.setScrollTop = function(value, preventEvent, byUser) { - var htmlNode = this.$getHtmlHost(); - htmlNode.scrollTop = value; - - if (!preventEvent) { - this.amlNode.dispatchEvent("scroll", { - direction: "vertical", - byUser: byUser, - viewport: this, - scrollbar: this.scrollbar - }); - } - } - - this.setScrollLeft = function(value, preventEvent, byUser) { - var htmlNode = this.$getHtmlHost(); - htmlNode.scrollLeft = value; - - if (!preventEvent) { - this.amlNode.dispatchEvent("scroll", { - direction: "horizontal", - byUser: byUser, - viewport: this, - scrollbar: this.scrollbar - }); - } - } - - // *** Private *** // - - this.$getHtmlHost = function(){ - var htmlNode = this.amlNode.$int || this.amlNode.$container; - return (htmlNode.tagName == "BODY" || htmlNode.tagName == "HTML" - ? (apf.isSafari || apf.isChrome ? document.body : htmlNode.parentNode) - : htmlNode); - } - - this.$mousescroll = function(e) { - if (this.scrollbar.horizontal) - return; - - if (e.returnValue === false) - return; - - var oHtml = this.$getHtmlHost(); - - var sb = this.scrollbar; - var div = this.getScrollHeight() - this.getHeight(); - if (div) { - if (oHtml[sb.$scrollPos] == 0 && e.delta > 0) { - if (this.$lastScrollState === 0) - return; - setTimeout(function(){this.$lastScrollState = 0;}, 300); - } - else if (oHtml[sb.$scrollPos] == this.getScrollHeight() - oHtml[sb.$offsetSize] && e.delta < 0) { - if (this.$lastScrollState === 1) - return; - setTimeout(function(){this.$lastScrollState = 1;}, 300); - } - delete this.$lastScrollState; - - this.setScrollTop(this.getScrollTop() - + -1 * e.delta * Math.min(45, this.getHeight()/10), false, true); - - e.preventDefault(); - } - } -}).call(apf.ViewPortAml.prototype); - -apf.ViewPortHtml = function(htmlNode) { - // *** Private *** // - - this.$getHtmlHost = function(){ - return htmlNode; - } - - // *** Init *** // - - var _self = this; - - htmlNode = (htmlNode.tagName == "BODY" || htmlNode.tagName == "HTML" - ? (apf.isSafari || apf.isChrome ? document.body : htmlNode.parentNode) - : htmlNode); - - apf.addEventListener("mousescroll", function(e) { - if (htmlNode == e.target - || (htmlNode == document.documentElement && e.target == document.body)) - _self.$mousescroll(e); - }) - - apf.addListener(htmlNode, "scroll", function(){ - _self.setScrollTop(this.scrollTop); - }); - - if ("HTML|BODY".indexOf(htmlNode.tagName) > -1) { - var lastHeight = htmlNode.scrollHeight; - setInterval(function(){ - if (lastHeight != htmlNode.scrollHeight) { - lastHeight = htmlNode.scrollHeight; - _self.scrollbar.$recalc(); - _self.scrollbar.$update(); - } - }, 100); - } - - this.amlNode = new apf.Class().$init(); -} - -apf.ViewPortHtml.prototype = apf.ViewPortAml.prototype; - @@ -31833,403 +29155,6 @@ apf.aml.setElement("skin", apf.skin); -/** - * An element containing information on how databound elements process data. - * - * The {@link term.smartbinding smartbinding} element specifies how data is transformed and rendered - * in databound elements. It also specifies how changes on the bound data are - * send to their original data source ({@link apf.actions actions}) and - * which {@link term.datanode data nodes} can be dragged and dropped ({@link apf.DragDrop dragdrop}). - * - * #### Remarks - * - * Each element has its own set of binding rules it uses to render the data - * elements. The same goes for it's actions. To give an example, a slider has - * one action called 'change'. This action is called when then value of the - * slider changes. A tree element has several actions - among others: 'add', - * 'remove', 'move', 'copy' and 'rename'. - * - * Smartbindings enable many other features in a Ajax.org Platform - * application. Actions done by the user can be undone by calling - * {@link apf.actiontracker.undo} of the element. The - * Remote Databinding element can send changes on data to other clients. - * - * This element is created especially for reuse. Multiple elements can reference - * a single smartbinding element by setting the value of the 'smartbinding' - * attribute to the ID of this smartbinding element. If an element is only used - * for a single other element it can be set as it's child. In fact, each of the - * children of the smartbinding element can exist outside the smartbinding - * element and referenced indepently. - * - * #### Example - * - * A simple example of a smartbinding transforming data into representation - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * LCD Panel - * - * - * - * ``` - * - * #### Example - * - * This is an elaborate example showing how to create a filesystem tree with - * files and folders in a tree. The smartbinding element describes how the - * files and folders are transformed to tree elements and how actions within - * the tree are sent to the data source; in this case, WebDAV. - * is used. The drag and drop rules specify which elements can be dragged and - * where they can be dropped. - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * function filesort(value, args, xmlNode) { - * return (xmlNode.tagName == "folder" ? 0 : 1) + value; - * } - * - * function getIcon(xmlNode) { - * xmlNode.getAttribute('name').match(/\.([^\.]*)$/); - * - * var ext = RegExp.$1; - * return (SupportedIcons[ext.toUpperCase()] - * ? SupportedIcons[ext.toUpperCase()] + ".png" - * : "unknown.png"); - * } - * - * ``` - * - * #### Example - * - * This example shows a smartbinding element which references to its children as - * stand alone elements. - * - * ```xml - * - * ... - * - * - * ... - * - * - * ... - * - * - * - * - * - * - * - * ``` - * - * - * #### Example - * - * The shortest method to add binding rules to an element is as follows: - * - * ```xml - * - * ``` - * - * @see baseclass.databinding - * @see baseclass.databinding.attribute.smartbinding - * @see term.smartbinding - * @see term.binding - * @see term.action - * - * @define smartbinding - * @allowchild bindings, actions, ref, action, dragdrop, model - * - * - * @class apf.smartbinding - * @apfclass - * @inherits apf.AmlElement - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.8 - * - * @default_private - */ -apf.smartbinding = function(struct, tagName) { - this.$init(tagName || "smartbinding", apf.NODE_HIDDEN, struct); - - this.$bindNodes = {}; -}; - -(function(){ - this.$supportedProperties = ["bindings", "actions", "model"]; - this.$handlePropSet = function(prop, value, force) { - switch(prop) { - //@todo apf3 change this to use apf.setModel(); - case "model": - - if (typeof value == "string") - value = apf.nameserver.get("model", value); - this.model = apf.nameserver.register("model", this.name, value); - //this.modelBaseXpath = xpath; - - var amlNode; - for (var uniqueId in this.$bindNodes) { - amlNode = this.$bindNodes[uniqueId]; - this.model.unregister(amlNode); - this.model.register(amlNode, this.$modelXpath[amlNode.getHost - ? amlNode.getHost().$uniqueId - //this is a hack.. by making Models with links to other - //models possible, this should not be needed - : amlNode.$uniqueId] || this.modelBaseXpath); - //this.$bindNodes[uniqueId].load(this.model); - } - - break; - case "bindings": - if (this.$bindings) - this.remove(this.$bindings); - - this.$bindings = typeof value == "object" - ? value - : - - apf.nameserver.lookup("bindings", value); - - - this.add(this.$bindings); - - break; - case "actions": - if (this.$actions) - this.remove(this.$actions); - - this.$actions = typeof value == "object" - ? value - : - - apf.nameserver.lookup("actions", value); - - - this.add(this.$actions); - - break; - } - - this[prop] = value; - - - }; - - this.add = function(node) { - for (var uId in this.$bindNodes) - node.register(this.$bindNodes[uId]); - - this["$" + node.localName] = node; - }; - - this.remove = function(node) { - for (var uId in this.$bindNodes) - node.unregister(this.$bindNodes[uId]); - }; - - this.register = function(amlNode) { - this.$bindNodes[amlNode.$uniqueId] = amlNode; - - if (this.$bindings) - this.$bindings.register(amlNode); - if (this.$actions) - this.$actions.register(amlNode); - if (this.$model) - this.$model.register(amlNode); - }; - - this.unregister = function(amlNode) { - //unregister element - this.$bindNodes[amlNode.$uniqueId] = null; - delete this.$bindNodes[amlNode.$uniqueId]; - - if (this.$bindings) - this.$bindings.unregister(amlNode); - if (this.$actions) - this.$actions.unregister(amlNode); - if (this.$model) - this.$model.unregister(amlNode); - }; - - /** - * Loads XML data in the model of this smartbinding element. - * - * @param {Mixed} xmlNode the {@link term.datanode data node} loaded into - * the model of this smartbinding element. This can be an XMLElement, a - * string or null. - * @private - */ - this.load = function(xmlNode) { - //@todo fix this - new apf.model().register(this).load(xmlNode); - }; - - this.clear = function(state) { - //for all elements do clear(state); - }; - - /* - * @private - * - * @attribute {String} bindings the id of the bindings element that contains - * the {@link term.binding binding rules} for all elements connected to - * this smartbinding element - * - * #### Example - * - * ```xml - * - * ``` - * @see element.bindings - * @see term.binding - * @see term.smartbinding - * - * @attribute {String} actions the id of the actions element that provides - * the {@link term.action action rules} for all elements connected to - * this smartbinding element - * - * #### Example - * - * ```xml - * - * ``` - * @see apf.actions - * @see term.action - * @see term.smartbinding - * - * @attribute {String} dragdrop the id of the dragdrop element that provides - * the drag and drop rules for all elements connected to this smartbinding - * element - * - * #### Example - * - * ```xml - * - * ``` - * @see apf.DragDrop - * @see term.smartbinding - * - * @attribute {String} model the id of the model element that provides - * the data for all elements connected to this smartbinding element. - * - * #### Example - * - * ```xml - * - * ``` - * @see element.model - * @see term.smartbinding - * - * @define bindings element containing all the binding rules for the data - * bound elements referencing this element. - * - * #### Example - * - * ```xml - * - * - * - * - * - * - * - * ``` - * @see apf.smartbinding - * @allowchild {bindings} - * - * - */ - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - if (this.parentNode.hasFeature(apf.__DATABINDING__)) - this.register(this.parentNode); - - - }); -}).call(apf.smartbinding.prototype = new apf.AmlElement()); - -apf.aml.setElement("smartbinding", apf.smartbinding); - - - - - - - - -/** - * Element - * - * @constructor - * - * @define source - * - * - * @author Mike de Boer (mike AT javeline DOT com) - * @version %I%, %G% - * @since 3.0 - */ -apf.source = function(struct, tagName) { - this.$init(tagName || "source", apf.NODE_HIDDEN, struct); -}; - -(function(){ - this.$supportedProperties.push("src", "type"); - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - if (this.parentNode.$addSource) - this.parentNode.$addSource(this); - }); -}).call(apf.source.prototype = new apf.AmlElement()); - -apf.aml.setElement("source", apf.source); - - - - - - /** * This element is used to choose a number via plus/minus buttons. @@ -33128,207 +30053,6 @@ apf.StateServer = { } } -/** - * This element specifies a certain state of (a part of) the application. By - * "state", we mean a collection of properties on objects that have a certain - * value at one time. - * - * This element allows you to specify which properties on - * which elements should be set when a state is activated. This element can - * belong to a state-group containing multiple elements with a default state. - * - * #### Example - * - * ```xml, demo - * - * - * - * - * - * - * State - User - * State - Admin - * - * - * - * ``` - * - * @class apf.state - * @define state - * - * @logic - * @inherits apf.AmlElement - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.9 - */ -/** - * @event change Fires when the active property of this element changes. - * - */ -apf.state = function(struct, tagName) { - this.$init(tagName || "state", apf.NODE_HIDDEN, struct); - - this.$signalElements = []; - this.$groupAdded = {}; - this.$locationAdded = ''; -}; - -(function(){ - // *** Properties and Attributes *** // - - this.$supportedProperties.push("active"); - this.$booleanProperties["active"] = true; - - /** - * @attribute {Boolean} active whether this state is the active state - */ - this.$propHandlers["active"] = function(value) { - //Activate State - if (apf.isTrue(value)) { - if (this.group) { - var nodes = apf.StateServer.groups[this.group]; - if (!nodes) { - apf.StateServer.addGroup(this.group, this); - nodes = apf.StateServer.groups[this.group]; - } - - for (var i = 0; i < nodes.length; i++) { - if (nodes[i] != this && nodes[i].active !== false) - nodes[i].deactivate(); - } - } - - var q = this.$signalElements; - for (var i = 0; i < q.length; i++) { - if (!self[q[i][0]] || !self[q[i][0]].setProperty) { - - - continue; - } - - self[q[i][0]].setProperty(q[i][1], this[q[i].join(".")]); - } - - if (this.group) { - var attr = this.attributes; - for (var i = 0; i < attr.length; i++) { - if (attr[i].nodeName.match(/^on|^(?:group|id)$|^.*\..*$/)) - continue; - self[this.group].setProperty(attr[i].nodeName, - attr[i].nodeValue); - } - apf.StateServer.groups[this.group].pState.dispatchEvent("change"); - } - - this.dispatchEvent("activate"); - - - } - - //Deactivate State - else { - this.setProperty("active", false); - this.dispatchEvent("deactivate"); - - - } - }; - - - // *** Public methods *** // - - - - /** - * Sets the value of this element. This should be one of the values - * specified in the values attribute. - * @param {String} value Sets the new value of this element - */ - this.setValue = function(value) { - this.active = 9999; - this.setProperty("active", value, false, true); - }; - - /** - * Actives this state, setting all the properties on the elements that - * were specified. - */ - this.activate = function(){ - this.active = 9999; - this.setProperty("active", true, false, true); - }; - - /** - * Deactivates the state of this element. This is mostly a way to let all - * elements that have property bound to this state know it is no longer - * active. - */ - this.deactivate = function(){ - this.setProperty("active", false, false, true); - }; - - - - // *** Init *** // - - this.$propHandlers["group"] = function(value) { - if (value) { - apf.StateServer.addGroup(value, this); - this.$groupAdded = {'value' : value, elState : this}; - } - else { - apf.StateServer.removeGroup(this.$groupAdded.value, this.$groupAdded.elState); - this.$groupAdded = {}; - } - } - - this.$propHandlers["location"] = function(value) { - if (value) { - apf.StateServer.locs[value] = this; - this.$locationAdded = value; - } - else { - delete apf.StateServer.locs[this.$locationAdded]; - this.$locationAdded = ''; - } - } - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - apf.StateServer.addState(this); - - //Properties initialization - var attr = this.attributes; - for (var s, i = 0; i < attr.length; i++) { - s = attr[i].nodeName.split("."); - if (s.length == 2) - this.$signalElements.push(s); - } - }); - - this.addEventListener("DOMNodeRemovedFromDocument", function(){ - this.$signalElements = null; - apf.StateServer.removeState(this); - if (this.group) - apf.StateServer.removeGroup(this.group, this); - }); -}).call(apf.state.prototype = new apf.AmlElement()); - -apf.aml.setElement("state", apf.state); - -