From 375decdae3a1c3cff82b3f404509643708abb67a Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 19 Mar 2017 17:55:55 +0400 Subject: [PATCH] remove many things --- plugins/c9.ide.layout.classic/layout.xml | 6 - plugins/c9.ide.run.debug/variables.js | 1 - plugins/c9.ide.ui/lib/dropdown.js | 338 +- plugins/c9.ide.ui/lib/menu/menu.js | 5 - plugins/c9.ide.ui/lib_apf.js | 5532 +--------------------- plugins/c9.ide.ui/ui.js | 5 - 6 files changed, 16 insertions(+), 5871 deletions(-) diff --git a/plugins/c9.ide.layout.classic/layout.xml b/plugins/c9.ide.layout.classic/layout.xml index 85c3f840..d6828b01 100644 --- a/plugins/c9.ide.layout.classic/layout.xml +++ b/plugins/c9.ide.layout.classic/layout.xml @@ -1,10 +1,4 @@ - - diff --git a/plugins/c9.ide.run.debug/variables.js b/plugins/c9.ide.run.debug/variables.js index ae4e8abf..d9fca8fa 100644 --- a/plugins/c9.ide.run.debug/variables.js +++ b/plugins/c9.ide.run.debug/variables.js @@ -94,7 +94,6 @@ define(function(require, exports, module) { if (e.node.tagName == "variable") { if (!e.node.children) return e.expand(); - // dbg.getProperties(e.node, function(err, properties) { if (err) return console.error(err); diff --git a/plugins/c9.ide.ui/lib/dropdown.js b/plugins/c9.ide.ui/lib/dropdown.js index b11b2c59..d794e34a 100644 --- a/plugins/c9.ide.ui/lib/dropdown.js +++ b/plugins/c9.ide.ui/lib/dropdown.js @@ -54,327 +54,6 @@ apf.aml.setElement("model", apf.model); -apf.__DATABINDING__ = 1 << 1; - - - -/** - * This is a baseclass that adds data binding features to this element. - * Databinding takes care of automatically going from data to representation and establishing a - * permanent link between the two. In this way data that is changed will - * change the representation as well. Furthermore, actions that are executed on - * the representation will change the underlying data. - * - * #### Example - * - * ```xml - * - * - * - * Item 1 - * Item 2 - * - * - * - * - * - * - * - * - * ``` - * - * @class apf.DataBinding - * @inherits apf.Presentation - * @baseclass - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.4 - * @default_private - */ -/** - * @event error Fires when a communication error has occured while - * making a request for this element. - * @cancelable Prevents the error from being thrown. - * @bubbles - * @param {Object} e The standard event object. It contains the following properties: - * - error ([[Error]]): the error object that is thrown when the event callback doesn't return false. - * - state ([[Number]]): the state of the call - * - `apf.SUCCESS`: The request was successfull - * - `apf.TIMEOUT`: The request has timed out. - * - `apf.ERROR `: An error has occurred while making the request. - * - `apf.OFFLINE`: The request was made while the application was offline. - * - userdata (`Mixed`): Data that the caller wanted to be available in the callback of the http request. - * - http ([[XMLHttpRequest]]): The object that executed the actual http request. - * - url ([[String]]): The url that was requested. - * - tpModule ([[apf.http]]): The teleport module that is making the request. - * - id ([[Number]]): The ID of the request. - * - message ([[String]]): The error message. - */ -/** - * @event beforeretrieve Fires before a request is made to retrieve data. - * @cancelable Prevents the data from being retrieved. - */ -/** - * @event afterretrieve Fires when the request to retrieve data returns both - * on success and failure. - */ -/** - * @event receive Fires when data is successfully retrieved - * @param {Object} e The standard event object. It contains the following properties: - * - data ([[String]]): the retrieved data - * - */ -apf.DataBinding = function() { - this.$init(true); - - this.$loadqueue = - this.$dbTimer = null; - this.$regbase = this.$regbase | apf.__DATABINDING__; - this.$mainBind = "value"; - - this.$bindings = - this.$cbindings = - this.$attrBindings = false; - - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - model: 1, - each: 1 - //eachvalue : 1 //disabled because of line 1743 valueRule = in multiselect.js - }, this.$attrExcludePropBind); - - // *** Public Methods *** // - - /** - * Sets a value of an XMLNode based on an xpath statement executed on the data of this model. - * - * @param {String} xpath The xpath used to select a XMLNode - * @param {String} value The value to set - * @return {XMLNode} The changed XMLNode - */ - this.setQueryValue = function(xpath, value, type) { - var node = apf.createNodeFromXpath(this[type || 'xmlRoot'], xpath); - if (!node) - return null; - - apf.setNodeValue(node, value, true); - //apf.xmldb.setTextNode(node, value); - return node; - }; - - /** - * Queries the bound data for a string value - * - * @param {String} xpath The XPath statement which queries on the data this element is bound on. - * @param {String} type The node that is used as the context node for the query. It can be one of the following possible values: - * - `"selected"`: The selected data anode of this element. - * - `"xmlRoot"`: The root data node that this element is bound on. - * - `"indicator"`: The data node that is highlighted for keyboard navigation. - * @return {String} The value of the selected XML Node - * - */ - this.queryValue = function(xpath, type) { - /* @todo - * lstRev.query('revision/text()', 'selected'); - * lstRev.query('revision/text()', 'xmlRoot'); - * lstRev.query('revision/text()', 'indicator'); - */ - return apf.queryValue(this[type || 'xmlRoot'], xpath); - }; - /** - * Queries the bound data for an array of string values - * - * @param {String} xpath The XPath statement which queries on the data this element is bound on. - * @param {String} type The node that is used as the context node for the query. It can be one of the following possible values: - * - `"selected"`: The selected data anode of this element. - * - `"xmlRoot"`: The root data node that this element is bound on. - * - `"indicator"`: The data node that is highlighted for keyboard navigation. - * @return {String} The value of the selected XML Node - */ - this.queryValues = function(xpath, type) { - return apf.queryValues(this[type || 'xmlRoot'], xpath); - }; - - /** - * Executes an XPath statement on the data of this model - * - * @param {String} xpath The XPath statement which queries on the data this element is bound on. - * @param {String} type The node that is used as the context node for the query. It can be one of the following possible values: - * - `"selected"`: The selected data anode of this element. - * - `"xmlRoot"`: The root data node that this element is bound on. - * - `"indicator"`: The data node that is highlighted for keyboard navigation. - * @return {Mixed} An [[XMLNode]] or [[NodeList]] with the result of the selection - */ - this.queryNode = function(xpath, type) { - var n = this[type || 'xmlRoot']; - return n ? n.selectSingleNode(xpath) : null; - }; - - /** - * Executes an XPath statement on the data of this model - * - * @param {String} xpath The XPath used to select the XMLNode(s) - * @param {String} type The node that is used as the context node for the query. It can be one of the following possible values: - * - `"selected"`: The selected data anode of this element. - * - `"xmlRoot"`: The root data node that this element is bound on. - * - `"indicator"`: The data node that is highlighted for keyboard navigation. - * @return {Mixed} An [[XMLNode]] or [[NodeList]] with the result of the selection - */ - this.queryNodes = function(xpath, type) { - debugger - var n = this[type || 'xmlRoot']; - return n ? n.selectNodes(xpath) : []; - }; - - - /** - * @attribute {String} model Sets or gets the name of the model to load data from, or a - * datainstruction to load data. - * - * #### Example - * - * ```xml - * - * - * - * - * - * - * - * ``` - * - * #### Example - * - * Here's an example loading from an XML source: - * - * ```xml - * - * - * - * - * - * - * ``` - * - * #### Example - * - * ```xml - * - * - * - * - * - * - * - * ``` - * - * #### Example - * - * This example shows a dropdown from which the user can select a country. - * The list of countries is loaded from a model. Usually this would be loaded - * from a separate url, but for clarity it's inlined. When the user selects - * a country in the dropdown the value of the item is stored in the second - * model (mdlForm) at the position specified by the ref attribute. In this - * case this is the country element. - * - * ```xml - * Name - * - * - * Country - * - * - * - * - * - * USA - * Great Britain - * The Netherlands - * - * - * - * - * - * - * - * - * - * ``` - * - * #### Remarks - * - * This attribute is inherited from a parent when not set. You can use this - * to tell sets of elements to use the same model. - * - * ```xml - * - * Name - * - * - * Happiness - * - * - * - * - * - * - * ``` - * - * When no model is specified the default model is chosen. The default - * model is the first model that is found without a name, or if all models - * have a name, the first model found. - * - * @see apf.DataBinding.model - */ - this.$propHandlers["model"] = function(value) { - this.model = value; - }; - - - /** - * @attribute {String} viewport Sets or gets the way this element renders its data. - * - * The possible values include: - * - `"virtual"`: this element only renders data that it needs to display. - * - `"normal`"`: this element renders all data at startup. - * @experimental - */ - this.$propHandlers["viewport"] = function(value) { - debugger - }; - -}; - - apf.DataBinding.prototype = new apf[apf.Presentation ? "Presentation" : "AmlElement"](); - - -apf.config.$inheritProperties["model"] = 1; -apf.config.$inheritProperties["empty-message"] = 1; -apf.config.$inheritProperties["loading-message"] = 1; -apf.config.$inheritProperties["offline-message"] = 1; -apf.config.$inheritProperties["noloading"] = 1; - - - - - /** * The baseclass for all standard data binding rules. @@ -384,21 +63,7 @@ apf.config.$inheritProperties["noloading"] = 1; * @baseclass * @inherits apf.DataBinding */ -apf.StandardBinding = function() { - this.$init(true); - - - if (apf.Validation) - this.implement(apf.Validation); - - - if (!this.setQueryValue) - this.implement(apf.DataBinding); - - if (!this.defaultValue) //@todo please use this in a sentence - this.defaultValue = ""; - }; -apf.StandardBinding.prototype = new apf.DataBinding(); +apf.StandardBinding = apf.Presentation; @@ -702,7 +367,6 @@ apf.BaseList = function() { this.$mode = this.multicheck ? 1 : 2; } else { - //@todo undo actionRules setting this.removeEventListener("afterrename", $afterRenameMode); //@todo unimplement?? this.$mode = 0; diff --git a/plugins/c9.ide.ui/lib/menu/menu.js b/plugins/c9.ide.ui/lib/menu/menu.js index 643de068..f902c4c2 100644 --- a/plugins/c9.ide.ui/lib/menu/menu.js +++ b/plugins/c9.ide.ui/lib/menu/menu.js @@ -1147,11 +1147,6 @@ apf.item = function(struct, tagName) { // *** Properties and Attributes *** // - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - "match": 1 - }, this.$attrExcludePropBind); - this.$booleanProperties["checked"] = true; this.$booleanProperties["selected"] = true; diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index ec4e30bb..3b0d2e42 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -116,9 +116,8 @@ function(require, module, exports) { * */ apf = { -VERSION: '3.0beta', - // Content Distribution Network URL: - + VERSION: '3.0beta', + getPlugin: function(name) { return apf.nameserver.get("all", name); }, @@ -243,22 +242,6 @@ VERSION: '3.0beta', xPathAxis: {"self":1, "following-sibling":1, "ancestor":1}, //@todo finish list - hasRequireJS: typeof requirejs !== "undefined", - - availHTTP: [], - /** - * @private - */ - releaseHTTP: function(http) { - if (self.XMLHttpRequestUnSafe && http.constructor == XMLHttpRequestUnSafe) - return; - - http.onreadystatechange = function(){}; - - http.abort(); - this.availHTTP.push(http); - }, - /** * @private */ @@ -540,37 +523,12 @@ VERSION: '3.0beta', this.started = true; - - - // DOMReady already fired, so plz continue the loading and parsing - if (this.load_done) - this.execDeferred(); - this.root = true; }, nsqueue: {}, - - - /** - * @private - */ - importClass: function(ref, strip, win) { - if (!ref) - throw new Error(apf.formatErrorString(1018, null, - "importing class", - "Could not load reference. Reference is null")); - - if (!strip) - return apf.jsexec(ref.toString(), win); - - var q = ref.toString().replace(/^\s*function\s*\w*\s*\([^\)]*\)\s*\{/, "") - .replace(/\}\s*$/, ""); - - return apf.jsexec(q, win); - }, all: [], @@ -770,25 +728,6 @@ VERSION: '3.0beta', }, /* Init */ - - /** - * Returns the directory portion of a URL. - * @param {String} url The URL to retrieve from - * @returns {String} The directory portion of a URL - */ - getDirname: function(url) { - //(?:\w+\:\/\/)? - return ((url || "").match(/^([^#]*\/)[^\/]*(?:$|\#)/) || {})[1]; //Mike will check out how to optimize this line - }, - - /** - * Returns the file portion of a URL. - * @param {String} url The URL to retrieve from. - * @return {String} The file portion of a URL. - */ - getFilename: function(url) { - return ((url || "").split("?")[0].match(/(?:\/|^)([^\/]+)$/) || {})[1]; - }, /** * Returns an absolute url based on url. @@ -802,10 +741,6 @@ VERSION: '3.0beta', : (!url || !base || url.match(/^\w+\:\/\//) ? url : base.replace(/\/$/, "") + "/" + url.replace(/^\//, "")); }, - getCtrlKey: function(event) { - return apf.isMac ? event.metaKey : event.ctrlKey; - }, - /** * Determines the way APF tries to render this application. Set this value @@ -845,97 +780,6 @@ VERSION: '3.0beta', } }, - - /** - * @private - */ - execDeferred: function() { - // execute each function in the stack in the order they were added - var len = apf.load_events.length; - while (len--) - (apf.load_events.shift())(); - }, - - load_events: [], - load_timer: null, - load_done: false, - load_init: null, - - /** - * @private - */ - addDomLoadEvent: function(func) { - if (!this.$bdetect) - this.browserDetect(); - - if (apf.load_done) - return func(); - - // create event function stack - //apf.done = arguments.callee.done; - if (!apf.load_init) { - apf.load_init = function() { - if (apf.load_done) return; - // kill the timer - clearInterval(apf.load_timer); - apf.load_timer = null; - apf.load_done = true; - if (apf.started) - apf.execDeferred(); - }; - } - - apf.load_events.push(func); - - if (func && apf.load_events.length == 1) { - // Catch cases where addDomLoadEvent() is called after the browser - // event has already occurred. - var doc = document, UNDEF = "undefined"; - if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") - || (doc.getElementsByTagName("body")[0] || doc.body)) - return apf.load_init(); - - // for Mozilla/Opera9. - // Mozilla, Opera (see further below for it) and webkit nightlies - // currently support this event - if (doc.addEventListener && !apf.isOpera) { - // We're using "window" and not "document" here, because it results - // in a memory leak, especially in FF 1.5: - // https://bugzilla.mozilla.org/show_bug.cgi?id=241518 - // See also: - // http://bitstructures.com/2007/11/javascript-method-callbacks - // http://www-128.ibm.com/developerworks/web/library/wa-memleak/ - window.addEventListener("DOMContentLoaded", apf.load_init, false); - } - else if (apf.isWebkit && !apf.isIphone) { - var aSheets = doc.getElementsByTagName("link"), - i = aSheets.length, - iSheets; - for (; i >= 0; i++) { - if (!aSheets[i] || aSheets[i].getAttribute("rel") != "stylesheet") - aSheets.splice(i, 0); - } - iSheets = aSheets.length; - apf.load_timer = setInterval(function() { - if (/loaded|complete/.test(doc.readyState) - && doc.styleSheets.length == iSheets) - apf.load_init(); // call the onload handler - }, 10); - } - // for other browsers set the window.onload, but also execute the - // old window.onload - else { - var old_onload = window.onload; - window.onload = function () { - apf.load_init(); - if (old_onload) - old_onload(); - }; - } - } - }, - - fireEvent: function(el, type, e, capture) { if (el.dispatchEvent) el.dispatchEvent(type, e, capture); @@ -1011,14 +855,6 @@ apf.setTimeout = function(f, t) { }, t); } -/*$setTimeout = function(f, ms) { - setTimeout(function(){ - console.log(f.toString()); - if (typeof f == "string") eval(f) - else f(); - }, ms); -}*/ - document.documentElement.className += " has_apf"; apf.browserDetect(); @@ -1133,325 +969,6 @@ apf.Class.prototype = new (function(){ }; - - /** - * Binds a property of another compontent to a property of this element. - * - * @param {String} myProp the name of the property of this element - * of which the value is communicated to - * `bObject`. - * @param {Class} bObject the object which will receive the property - * change message. - * @param {String} bProp the property of `bObject` which - * will be set using the value of - * `myProp` optionally - * processed using `strDynamicProp`. - * @param {String} [strDynamicProp] a javascript statement which contains the - * value of `myProp`. The string - * is used to calculate a new value. - * @private - */ - this.$bindProperty = function(myProp, bObject, bProp, fParsed, bRecip) { - if (!fParsed) - return bObject.$handlePropSet(bProp, this[myProp]); - - var eventName = PROP + myProp, eFunc, isBeingCalled, isLang; - (this.$eventsStack[eventName] || (this.$eventsStack[eventName] = [])).push(eFunc = function(e) { - if (isBeingCalled) //Prevent circular refs - return; - - - isBeingCalled = true; - - try { - if (fParsed.asyncs) { //if async - return fParsed.call(bObject, bObject.xmlRoot, function(value) { - bObject.setProperty(bProp, value, true, false, 10); - - - - isBeingCalled = false; - }); - } - else { - var value = fParsed.call(bObject, bObject.xmlRoot); - } - } - catch (e) { - apf.console.warn("[331] Could not execute binding for property " - + bProp + "\n\n" + e.message); - - isBeingCalled = false; - - return; - } - - //Can't do this when using xml nodes, doesnt seem needed anyway - //if (bObject[bProp] != value) - bObject.setProperty(bProp, value, true, false, 10);//e.initial ? 0 : - - - - isBeingCalled = false; - }); - - //Bi-directional property binding - if (bRecip) { - eventName = PROP + bProp; - var _self = this; - // add bidirectional binding to funcHandlers for visualconnect - - - (bObject.$eventsStack[eventName] || (bObject.$eventsStack[eventName] = [])).push( - eFunc.recip = function(){ - if (isBeingCalled) //Prevent circular refs - return; - - isBeingCalled = true; - _self.setProperty(myProp, bObject[bProp], false, false, 10);//e.initial ? 0 : - isBeingCalled = false; - }); - }; - - //eFunc({initial: true}); - - return eFunc; - }; - - /** - * Sets a dynamic property from a string. - * - * The string used for this function is the same as used in AML to set a - * dynamic property: - * ```xml - * - * - * ``` - * - * @param {String} prop The name of the property of this element to set - * using a dynamic rule. - * @param {String} pValue The dynamic property binding rule. - */ - this.$attrExcludePropBind = false; - this.$setDynamicProperty = function(prop, pValue) {debugger - var exclNr = this.$attrExcludePropBind[prop], - options; - - //@todo apf3.0, please generalize this - cache objects, seems slow - if (SEL.indexOf(prop) > -1 || exclNr == 3) { - options = { - xpathmode: 2 - //parsecode : true //@todo is this also good for exclNr 3 ? - } - } - else if (exclNr == 2) { - options = {nostring : true}; - } - else if (exclNr === 0) { - options = { - parsecode: true - - }; - } - - if (this.liveedit) - (options || (options = {})).liveedit = true; - - //Compile pValue through JSLT parser - - { - var fParsed = apf.lm.compile(pValue, options); - } - - //Special case for model due to needed extra signalling - if (prop == MODEL) - (this.$modelParsed = fParsed).instruction = pValue - - - //if it's only text return setProperty() - if (fParsed.type == 2) { - this[prop] = !pValue; //@todo apf3.0 is this needed? - return this.setProperty(prop, fParsed.str, null, null, 10); //@todo is 10 here right? - } - - //if there's xpath: Add apf.DataBinding if not inherited. - //Add compiled binding rule. Load databinding if not loaded. - - var check = 1; - if (exclNr == 2 || fParsed.xpaths.length && exclNr != 1) { - if (!this.hasFeature(apf.__DATABINDING__)) { - this.implement(apf.StandardBinding); - if (this.$attrExcludePropBind[prop] == 1) - check = 0; - } - - if (check) - this.$addAttrBind(prop, fParsed, pValue); - } - - - //if there's prop binding: Add generated function to each obj/prop in the list - var matches = exclNr && exclNr != 3 && prop != MODEL ? {} : fParsed.props, //@todo apf3.0 sign of broken abstraction, please fix this with a bit mask - found = false, - _self = this, - o, node, bProp, p; - - for (p in matches) { - - - o = p.split("."); - if (o.length > 2) { //apf.offline.syncing - bProp = o.pop(); - // try{ - // try { node = eval(o.join(".")); } catch (e) {} - // } - // catch (e) { - // if (arguments[2]) { - // apf.console.warn("[287] Could not execute binding test : " - // + pValue.replace(/= 0; i--) { - this.$clearDynamicProperty(attr[i].nodeName); - attr[i].destroy(); } } @@ -3870,18 +3385,6 @@ apf.getViewPort = function(win) { - -/** - * Opens a window with the string in it. - * @param {String} str The HTML string to display in the new window. - */ -apf.pasteWindow = function(str) { - var win = window.open("about:blank"); - win.document.write(str); -}; - - - /** * Escapes HTML from a string. * @param {String} str The html to be escaped. @@ -3926,77 +3429,6 @@ apf.isCharacter = function(charCode) { && (charCode == 32 || charCode > 42 || charCode == 8); }; -/** - * This random number generator has been added to provide a more robust and - * reliable random number spitter than the native Ecmascript Math.random() - * function. - * - * It is an implementation of the Park-Miller algorithm. (See 'Random Number - * Generators: Good Ones Are Hard to Find', by Stephen K. Park and Keith W. - * Miller, Communications of the ACM, 31(10):1192-1201, 1988.) - * @class apf.randomGenerator - * @author David N. Smith of IBM's T. J. Watson Research Center. - * @author Mike de Boer (mike AT c9 DOT io) - * - */ -apf.randomGenerator = { - d: new Date(), - seed: null, - A: 48271, - M: 2147483647, - Q: null, - R: null, - oneOverM: null, - - /** - * Generates a random [[Number]] between a lower and upper boundary. - * The algorithm uses the system time, in minutes and seconds, to 'seed' - * itself, that is, to create the initial values from which it will generate - * a sequence of numbers. If you are familiar with random number generators, - * you might have reason to use some other value for the seed. Otherwise, - * you should probably not change it. - * @param {Number} lnr Lower boundary - * @param {Number} unr Upper boundary - * @returns A random number between `lnr` and`unr` - * @type Number - */ - generate: function(lnr, unr) { - if (this.seed == null) - this.seed = 2345678901 + (this.d.getSeconds() * 0xFFFFFF) + (this.d.getMinutes() * 0xFFFF); - this.Q = this.M / this.A; - this.R = this.M % this.A; - this.oneOverM = 1.0 / this.M; - return Math.floor((unr - lnr + 1) * this.next() + lnr); - }, - - /** - * Returns a new random number, based on the 'seed', generated by the - * [[apf.randomGenerator.generate]] method. - * @type Number - */ - next: function() { - var hi = this.seed / this.Q; - var lo = this.seed % this.Q; - var test = this.A * lo - this.R * hi; - if (test > 0) - this.seed = test; - else - this.seed = test + this.M; - return (this.seed * this.oneOverM); - } -}; - -/** - * Adds a time stamp to the URL to prevent the browser from caching it. - * @param {String} url The URL to add the timestamp to. - * @return {String} The url... with a timestamp! - */ -apf.getNoCacheUrl = function(url) { - return url - + (url.indexOf("?") == -1 ? "?" : "&") - + "nocache=" + new Date().getTime(); -}; - /** * Checks if the string contains curly braces at the start and end. If so, it's * processed as Javascript via `eval()`. Otherwise, the original string is returned. @@ -4029,39 +3461,6 @@ apf.formatNumber = function(num, prefix) { return prefix + str; }; -/** - * Execute a script in the global scope. - * - * @param {String} str The JavaScript code to execute - * @param {Object} [win] A reference to a window - * @return {String} The executed JavaScript code - */ -apf.jsexec = function(str, win) { - if (!str) - return str; - if (!win) - win = self; - - if (apf.isO3) - eval(str, self); - else if (apf.hasExecScript) { - win.execScript(str); - } - else { - var head = win.document.getElementsByTagName("head")[0]; - if (head) { - var script = win.document.createElement('script'); - script.setAttribute('type', 'text/javascript'); - script.text = str; - head.appendChild(script); - head.removeChild(script); - } else - eval(str, win); - } - - return str; -}; - /* * Shorthand for an empty function. */ @@ -4974,7 +4373,7 @@ apf.queryNodes = function(contextNode, sExpr) { return contextNode.selectNodes(sExpr); //IE55 //if (contextNode.ownerDocument != document) // return contextNode.selectNodes(sExpr); - +console.log(sExpr) return apf.XPath.selectNodes(sExpr, contextNode); }; @@ -5238,538 +4637,6 @@ apf.formatXml = function(strXml) { return lines.join("\n"); }; -//@todo this function needs to be 100% proof, it's the core of the system -//for RDB: xmlNode --> Xpath statement -apf.xmlToXpath = function(xmlNode, xmlContext, useAID) { - if (!xmlNode) //@todo apf3.0 - return ""; - - if (useAID === true && xmlNode.nodeType == 1 && xmlNode.getAttribute(apf.xmldb.xmlIdTag)) { - return "//node()[@" + apf.xmldb.xmlIdTag + "='" - + xmlNode.getAttribute(apf.xmldb.xmlIdTag) + "']"; - } - - if (apf != this && this.lookup && this.select) { - var unique, def = this.lookup[xmlNode.tagName]; - if (def) { - //unique should not have ' in it... -- can be fixed... - unique = xmlNode.selectSingleNode(def).nodeValue; - return "//" + xmlNode.tagName + "[" + def + "='" + unique + "']"; - } - - for (var i = 0, l = this.select.length; i < l; i++) { - if (xmlNode.selectSingleNode(this.select[i][0])) { - unique = xmlNode.selectSingleNode(this.select[i][1]).nodeValue; - return "//" + this.select[i][0] + "[" + this.select[i][1] - + "='" + unique + "']"; - } - } - } - - if (xmlNode == xmlContext) - return "."; - - if (xmlNode.nodeType != 2 && !xmlNode.parentNode && !xmlNode.ownerElement) { - - - return false; - } - - var str = [], lNode = xmlNode; - if (lNode.nodeType == 2) { - str.push("@" + lNode.nodeName); - lNode = lNode.ownerElement || xmlNode.selectSingleNode(".."); - } - - var id;//, pfx = ""; - while (lNode && lNode.nodeType == 1) { - if (lNode == xmlContext) { - //str.unshift("/");//pfx = "//"; - break; - } - str.unshift((lNode.nodeType == 1 ? lNode.tagName : "text()") + - "[" + (useAID && (id = lNode.nodeType == 1 && lNode.getAttribute(apf.xmldb.xmlIdTag)) - ? "@" + apf.xmldb.xmlIdTag + "='" + id + "'" - : (apf.getChildNumber(lNode, lNode.parentNode.selectNodes(lNode.nodeType == 1 ? lNode.tagName : "text()")) + 1)) + - "]"); - lNode = lNode.parentNode; - }; - - return (str[0] == "/" || xmlContext && xmlContext.nodeType == 1 ? "" : "/") + str.join("/"); //pfx + -}; - -//for RDB: Xpath statement --> xmlNode -apf.xpathToXml = function(xpath, xmlNode) { - if (!xmlNode) { - - - return false; - } - - return xmlNode.selectSingleNode(xpath); -}; - - -apf.n = function(xml, xpath) { - return new apf.xmlset(xml, xpath, true); -}; - -apf.b = function(xml, xpath) { - return new apf.xmlset(xml, xpath); -}; - -apf.b.$queue = []; -apf.b.$state = 0; - -/* - * Naive jQuery like set implementation - * @todo add dirty flags - * @todo add query queue - * @todo rewrite to use arrays - */ -apf.xmlset = function(xml, xpath, local, previous) { - if (typeof xml == "string") - xml = apf.getXml(xml); - - this.$xml = xml; - if (xml) - this.$nodes = xml.dataType == apf.ARRAY ? xml : (xpath ? xml.selectNodes(xpath) : [xml]); - this.$xpath = xpath || "."; - this.$local = local; - this.$previous = previous; -}; - -(function(){ - this.add = function(){}; //@todo not implemented - - this.begin = function(){ - apf.b.$state = 1; - return this; - }; - - this.commit = function(at, rmt, uri) { - if (apf.b.$queue.length) { - if (rmt) { - var _self = this; - rmt.addEventListener("rdbsend", function(e) { - if (!uri || e.uri == uri) { - _self.rdbstack = e.message; - rmt.removeEventListener("rdbsend", arguments.callee); - } - }); - } - - at.execute({ - action: 'multicall', - args: apf.b.$queue - }); - - if (rmt) - rmt.$processQueue(rmt); - } - - apf.b.$queue = []; - apf.b.$state = 0; - return this; - }; - - this.rollback = function(){ - apf.b.$queue = []; - apf.b.$state = 0; - return this; - }; - - this.getRDBMessage = function(){ - return this.rdbstack || []; - }; - - this.before = function(el) { - el = typeof el == "function" ? el(i) : el; - - for (var node, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - if (this.$local) - node.parentNode.insertBefore(el, node); - else - apf.xmldb.appendChild(node.parentNode, el, node); - } - return this; - }; - - this.after = function(el) { - el = typeof el == "function" ? el(i) : el; - - for (var node, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - if (this.$local) - node.parentNode.insertBefore(el, node.nextSibling); - else - apf.xmldb.appendChild(node.parentNode, el, node.nextSibling); - } - - return this; - }; - - this.andSelf = function(){}; - - this.append = function(el) { - for (var node, child, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - child = typeof el == "function" ? el(i, node) : el; - - if (apf.b.$state) - apf.b.$queue.push({ - action: 'appendChild', - args: [node, child] - }); - else if (this.$local) - node.appendChild(child); - else - apf.xmldb.appendChild(node, child); - - } - - return this; - }; - - this.appendTo = function(target) { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - target.appendChild(this.$nodes[i]); - } - return this; - }; - - this.prepend = function(el) { - for (var node, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - node.insertBefore(typeof el == "function" ? el(i, node) : el, node.firstChild); - } - - return this; - }; - - this.prependTo = function(target) { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - target.insertBefore(this.$nodes[i], target.firstChild); - } - return this; - }; - - this.attr = function(attrName, value) { - if (arguments.length === 1) { - return this.$nodes && this.$nodes[0] && this.$nodes[0].getAttribute(attrName) || ""; - } - else { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - if (apf.b.$state) - apf.b.$queue.push({ - action: 'setAttribute', - args: [this.$nodes[i], attrName, value] - }); - else if (this.$local) - this.$nodes[i].setAttribute(attrName, value); - else - apf.xmldb.setAttribute(this.$nodes[i], attrName, value); - } - } - - return this; - }; - - this.removeAttr = function(attrName) { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - if (apf.b.$state) - apf.b.$queue.push({ - action: 'removeAttribute', - args: [this.$nodes[i], attrName] - }); - else if (this.$local) - this.$nodes[i].removeAttribute(attrName); - else - apf.xmldb.removeAttribute(this.$nodes[i], attrName); - } - - return this; - }; - - this.xml = function(){ - var str = []; - for (var i = 0, l = this.$nodes.length; i < l; i++) { - str.push(this.$nodes[i].xml); - } - return str.join("\n"); - }; - - this.get = - this.index = function(idx) { - idx = idx || 0; - return apf.getChildNumber(this.$nodes[idx], this.$nodes[idx].parentNode.getElementsByTagName("*")) - }; - - this.eq = function(index) { - return index < 0 ? this.$nodes[this.$nodes.length - index] : this.$nodes[index]; - }; - - this.size = - this.length = function(){ - return this.$nodes.length; - }; - - this.load = function(url) { - - }; - - this.next = function(selector) { - if (!selector) - selector = "node()[local-name()]"; - return new apf.xmlset(this.$xml, "((following-sibling::" + (this.$xpath == "." ? "node()" : this.$xpath) + - ")[1])[self::" + selector.split("|").join("|self::") + "]", this.$local, this); - }; - - this.nextAll = function(selector) { - if (!selector) - selector = "node()[local-name()]"; - return new apf.xmlset(this.$xml, "(following-sibling::" + (this.$xpath == "." ? "node()" : this.$xpath) + - ")[self::" + selector.split("|").join("|self::") + "]", this.$local, this); - }; - - this.nextUntil = function(){}; - - this.prev = function(selector) { - if (!selector) - selector = "node()[local-name()]"; - return new apf.xmlset(this.$xml, "((preceding-sibling::" + (this.$xpath == "." ? "node()" : this.$xpath) + - ")[1])[self::" + selector.split("|").join("|self::") + "]", this.$local, this); - }; - - this.prevAll = function(selector) { - if (!selector) - selector = "node()[local-name()]"; - return new apf.xmlset(this.$xml, "(preceding-sibling::" + (this.$xpath == "." ? "node()" : this.$xpath) + - ")[self::" + selector.split("|").join("|self::") + "]", this.$local, this); - }; - - this.not = function(){}; - - this.parent = function(selector) { - return new apf.xmlset(this.$xml.parentNode, this.$local, this); - }; - - this.parents = function(selector) {}; - this.pushStack = function(){}; - this.replaceAll = function(){}; - this.replaceWith = function(el) { - for (var node, child, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - child = typeof el == "function" ? el(i, node) : el; - - if (apf.b.$state) - apf.b.$queue.push({ - action: 'replaceNode', - args: [child, node] - }); - else if (this.$local) - node.parentNode.replaceChild(child, node); - else - apf.xmldb.replaceNode(child, node); - - } - - return this; - }; - - this.siblings = function(selector) { - //preceding-sibling:: - //return new apf.xmlset(this.$xml, "(" + this.$xpath + ")/node()[self::" + selector.split("|").join("|self::") + "]"); - }; - - this.text = function(){ - - }; - - this.toArray = function(){ - var arr = []; - for (var i = 0, l = this.$nodes.length; i < l; i++) { - arr.push(this.$nodes[i]); - } - return arr; - }; - - this.detach = function(selector) { - var items = []; - - for (var node, i = 0, l = this.$nodes.length; i < l; i++) { - node = this.$nodes[i]; - if (!node.selectSingleNode("self::node()[" + selector + "]")) - continue; - - if (apf.b.$state) - apf.b.$queue.push({ - action: 'removeNode', - args: [node] - }); - else if (this.$local) - node.parentNode.removeChild(node); - else - apf.xmldb.removeNode(node); - - items.push(node); - } - - return new apf.xmlset(items, "", this.$local, this); - }; - - this.remove = function(selector) { - for (var node, n = this.$nodes, i = n.length - 1; i >= 0; i--) { - node = n[i]; - if (selector && !node.selectSingleNode("self::node()[" + selector + "]")) - continue; - - if (apf.b.$state) - apf.b.$queue.push({ - action: 'removeNode', - args: [node] - }); - else if (this.$local) - node.parentNode.removeChild(node); - else - apf.xmldb.removeNode(node); - } - - return this; - }; - - this.children = function(selector) { - var nodes = []; - for (var node, i = 0, l = this.$nodes.length; i < l; i++) { - var list = (node = this.$nodes[i]).selectNodes(selector); - for (var j = 0, jl = list.length; j < jl; j++) { - nodes.push(list[j]); - } - } - return new apf.xmlset(nodes, null, this.$local, this); - }; - - this.children2 = function(selector) { - return new apf.xmlset(this.$xml, "(" + this.$xpath + ")/node()[self::" + - selector.split("|").join("|self::") + "]", this.$local, this); - }; - - this.has = - this.find = function(path) { - return new apf.xmlset(this.$xml, "(" + this.$xpath + ")//" + - path.split("|").join("|self::"), this.$local, this); - }; - - this.query = function(path) { - return new apf.xmlset(this.$xml, "(" + this.$xpath + ")/" + - path.split("|").join("|(" + this.$xpath + ")/"), this.$local, this); - }; - - this.filter = function(filter) { - var newList = []; - for (var i = 0, l = this.$nodes.length; i < l; i++) { - if (this.$nodes[i].selectSingleNode("self::node()[" + filter + "]")) - newList.push(this.$nodes[i]); - } - return new apf.xmlset(newList, null, this.$local, this); - }; - - this.end = function(){ - return this.$previous || this; - }; - - this.is = function(selector) { - return this.filter(selector) ? true : false; - }; - - this.contents = function(){ - return this.children("node()"); - }; - - this.has = function(){ - //return this.children( - }; - - this.val = function(value) { - if (arguments.length) { - apf.setQueryValue(this.$xml, this.$xpath, value); - return this; - } - else - return apf.queryValue(this.$xml, this.$xpath); - }; - - this.vals = function(){ - return apf.queryValues(this.$xml, this.$xpath); - }; - - this.node = function(){ - return apf.queryNode(this.$xml, this.$xpath); - }; - - this.nodes = function(){ - return apf.queryNodes(this.$xml, this.$xpath); - }; - - this.clone = function(deep) { - if (this.$nodes.length == 1) - return new apf.xmlset(this.$nodes[0].cloneNode(true), "", this.$local, this); - - var nodes = []; - for (var i = 0, l = this.$nodes.length; i < l; i++) { - nodes.push(this.$nodes[i].cloneNode(deep == undefined ? true : deep)); - } - - return new apf.xmlset(nodes, "", this.$local, this); - }; - - this.context = function(){ - return this.$xml; - }; - - this.data = function(data) { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - apf.setQueryValue(this.$nodes[i], ".", data); - } - return this; - }; - - this.each = function(func) { - for (var i = 0, l = this.$nodes.length; i < l; i++) { - func.call(this.$nodes[i], i); - } - return this; - }; - - this.eachrev = function(func) { - for (var i = this.$nodes.length - 1; i >= 0; i--) { - func.call(this.$nodes[i], i); - } - return this; - }; - - this.map = function(callback) { - var values = []; - for (var i = 0, l = this.$nodes.length; i < l; i++) { - values.push(callback(this.$nodes[i])); - } - return new apf.xmlset(values, "", this.$local, this); //blrghhh - }; - - this.empty = function(){ - this.children().detach(); - return this; - }; - - this.first = function(){ - return new apf.xmlset(this.$xml, "(" + this.$xpath + ")[1]", this.$local, this); - }; - - this.last = function(){ - return new apf.xmlset(this.$xml, "(" + this.$xpath + ")[last()]", this.$local, this); - }; -}).call(apf.xmlset.prototype); /** * Manages the z-index of all elements in the UI. It takes care of different @@ -5834,205 +4701,6 @@ apf.zmanager = function(){ - - -/** - * @class apf.history - * - * Implements a hash change listener. The 'hash' is the part of the - * location string in your browser that takes care of pointing to a section - * within the current application. - * - * #### Example - * ``` - * www.example.com/index.php#products - * ``` - * - * #### Remarks - * - * In modern browsers (after 2009) the location hash can be set by script and - * {@link apf.history@hashchange} is called when it's changed by using the back or forward - * button of the browsers. In most of the current (2009) browsers this is not the case. - * This object handles that logic for those browsers in such a way that the user - * of the application can use the back and forward buttons in an intuitive manner. - * - * Note: For Internet Explorer 8, when switching between the IE7 compatibility mode - * and IE8 mode the history navigation breaks. A browser restart is then - * required to fix it. Individually history navigation works fine in each mode. - * - */ -/** - * @event hashchange Fires when the hash changes. This can be either by setting - * a new hash value or when a user uses the back or forward button. Typing a - * new hash value in the location bar will also trigger this function. - * - * #### Example - * - * ```javascript - * apf.addEventListener("hashchange", function(e) { - * var info = e.page.split(":"); - * - * switch(info[0]) { - * case "product": //hash is for instance 'product:23849' - * //Sets the application state to display product info - * //For more information see apf.state - * stProduct.activate(); - * //Loads a product by id - * loadProduct(info[1]); - * break; - * case "news": - * stNews.activate(); - * break; - * } - * }); - * ``` - * - * @default_private - */ -apf.history = { - inited: false, - page: null, - past: [], - future: [], - delay: 1, - - init: function(defName, getVar, delay) { - if (this.inited || window.history.pushState) - return; - - if (delay) - this.delay = delay; - - this.inited = true; - - var name, _self = this; - function preInit() { - name = apf.dispatchEvent("hashinit") - || location.href.match(/#(.*)$/) && decodeURI(RegExp.$1) - || apf._GET[getVar || -1] || defName; - - - location.hash = name; - _self.hasChanged(name || null); - } - - if (apf.supportHashChange) { - $setTimeout(function() { - preInit(); - - window.onhashchange = function(){ - var page = location.hash.replace("#", ""); - apf.history.hasChanged(decodeURI(page)); - }; - }); - } - else { - preInit(); - apf.history.lastUrl = location.href.toString(); - this.timer2 = setInterval(function(){ - if (apf.history.lastUrl == location.href.toString()) - return; - - apf.history.lastUrl = location.href.toString(); - //var page = location.href.replace(/^.*#(.*)$/, "$1") - var page = location.hash.replace("#", "");//.replace(/^.*#(.*)$/,"$1"); - apf.history.hasChanged(decodeURI(page)); - }, 20); - } - }, - to_name: null, - - /** - * Sets the hash value of the location bar in the browser. This is used - * to represent the state of the application for use by the back and forward - * buttons, as well as for use when bookmarking or sharing URLs. - * @param {String} name The new hash value - * @param {Boolean} timed Whether to add a delay to setting the value - * @param {Boolean} force Forces the change to overwrite any existing value - */ - setHash: function(name, timed, force) { - if (this.changing || this.page == name || !force - && decodeURIComponent(location.hash) == "#" + decodeURIComponent(name)) { - this.to_name = name; - return; - } - - if (!this.inited) - return this.init(name); - - window.location.href = "#" + name; - - if (!apf.isGecko && !apf.isIphone) - apf.history.lastUrl = location.href.toString(); - }, - - timer: null, - changePage: function(page, force) { - if (!apf.supportHashChange && apf.isIE) { - } - }, - - update: function(page) { - var i, l, idx = 0; - - // check past: - for (i = 0, l = this.past.length; i < l && idx === 0; i++) { - if (this.past[i] == page) - idx = i + 1; - } - if (idx > 0) { - // part of past up till page (Array.slice), EXCLUDING page - this.future = this.past.slice(idx, this.past.length - 1) - .concat(this.future).makeUnique(); - this.past.splice(idx, this.past.length - (idx)); - idx = -idx; - } - else { - // check future: - for (i = 0, l = this.future.length; i < l && idx === 0; i++) { - if (this.future[i] == page) { - idx = i + 1; - // current past + part of the future up till page - // (Array.splice), INCLUDING page - this.past = this.past.concat(this.future - .splice(0, this.future.length - idx)).makeUnique(); - } - } - if (idx === 0) { - this.past.push(page); - idx = 1; - } - } - - return idx; - }, - - hasChanged: function(page, force) { - if (page == this.page && !force) - return; - - this.changing = true; - if (apf.dispatchEvent("hashchange", { - oldURL: this.page, - newURL: page, - page: page, - index: this.update(page) - }) === false) { - page = location.hash = this.page; - }; - this.changing = false; - - this.page = page; - } -}; - - - - - - - - apf.config = new apf.Class().$init(); apf.extend(apf.config, { //Defaults @@ -6056,8 +4724,15 @@ apf.extend(apf.config, { initdelay: true, + debug: false, + disableSpace: true, + allowSelect: false, + allowBlur: true, + // initdelay: false, + + skinset: "default", - name: apf.isO3 ? "o3App" : self.window && window.location.href.replace(/[^0-9A-Za-z_]/g, "_"), + name: "ide", tags: {}, defaults: {}, @@ -6141,17 +4816,6 @@ apf.extend(apf.config, { }); -if (apf.history) - apf.addEventListener("load", function(){ - apf.history.init(apf.config.defaultPage, "page"); - }); - - - - - - - @@ -8231,216 +6895,6 @@ apf.skins = { - - -/** - * Object handling sorting in a similar way as xslt. - * - * @constructor - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.8 - * - * @private - */ -apf.Sort = function(xmlNode) { - var settings = {}; - - //use this function to parse the each node - this.parseXml = function(xmlNode, clear) { - if (clear) settings = {}; - - settings.order = xmlNode.order; - settings.getValue = xmlNode.csort || xmlNode.$compile("sort"); - settings.getNodes = self[xmlNode["nodes-method"]]; - - settings.ascending = (settings.order || "").indexOf("desc") == -1; - settings.order = null; - - if (xmlNode["data-type"]) - settings.method = sort_methods[xmlNode["data-type"]]; - else if (xmlNode["sort-method"]) { - settings.method = self[xmlNode["sort-method"]]; - - - } - else - settings.method = sort_methods["alpha"]; - - var str = xmlNode["date-format"]; - if (str) { - settings.sort_dateFmtStr = str; - settings.method = sort_methods["date"]; - var result = str.match(/(D+|Y+|M+|h+|m+|s+)/g); - if (result) { - for (var pos = {}, i = 0; i < result.length; i++) - pos[result[i].substr(0, 1)] = i + 1; - settings.dateFormat = new RegExp(str.replace(/([^\sDYMhms])/g, '\\$1') - .replace(/YYYY/, "(\\d\\d\\d\\d)") - .replace(/(DD|YY|MM|hh|mm|ss)/g, "(\\d\\d)")); - settings.dateReplace = "$" + pos["M"] + "/$" + pos["D"] + "/$" + pos["Y"]; - if (pos["h"]) - settings.dateReplace += " $" + pos["h"] + ":$" + pos["m"] + ":$" + pos["s"]; - } - } - }; - - this.set = function(struct, clear) { - if (clear) settings = {}; - - apf.extend(settings, struct); - - if (settings.ascending == undefined) - settings.ascending = struct.order - ? struct.order.indexOf("desc") == -1 - : true; - - settings.order = null; - - if (struct["type"]) - settings.method = sort_methods[struct["type"]]; - else if (struct["method"]) - settings.method = self[struct["method"]]; - else if (!settings.method) - settings.method = sort_methods["alpha"]; - - if (struct.format) { - settings.sort_dateFmtStr = struct.format; - //settings.method = sort_methods["date"]; - var result = str.match(/(D+|Y+|M+|h+|m+|s+)/g); - if (result) { - for (var pos = {}, i = 0; i < result.length; i++) - pos[result[i].substr(0, 1)] = i + 1; - settings.dateFormat = new RegExp(str.replace(/([^\sDYMhms])/g, '\\$1') - .replace(/YYYY/, "(\\d\\d\\d\\d)") - .replace(/(DD|YY|MM|hh|mm|ss)/g, "(\\d\\d)")); - settings.dateReplace = "$" + pos["M"] + "/$" + pos["D"] + "/$" + pos["Y"]; - if (pos["h"]) - settings.dateReplace += " $" + pos["h"] + ":$" + pos["m"] + ":$" + pos["s"]; - } - } - - if (!settings.getValue) { - settings.getValue = function(item) { - return apf.queryValue(item, settings.xpath); - } - } - }; - - this.get = function(){ - return apf.extend({}, settings); - }; - - //use this function in __xmlUpdate [this function isnt done yet] - this.findSortSibling = function(pNode, xmlNode) { - var nodes = getNodes ? getNodes(pNode, xmlNode) : this.getTraverseNodes(pNode); - - for (var i = 0; i < nodes.length; i++) - if (!compare(xmlNode, nodes[i], true, sortSettings)) - return nodes[i]; - - return null; - }; - - // Sorting methods for sort() - var sort_intmask = ["", "0", "00", "000", "0000", "00000", "000000", - "0000000", "00000000", "000000000", "0000000000", "00000000000", - "000000000000", "0000000000000", "00000000000000"]; - var sort_methods = { - "alpha" : function (n) { - return n.toString().toLowerCase() - }, - - "number" : function (t) { - if (!t) var t = 0; - return (t.length < sort_intmask.length - ? sort_intmask[sort_intmask.length - t.length] - : "") + t; - }, - - "date" : function (t, args) { - var sort_dateFormat = settings.dateFormat; - var sort_dateReplace = settings.dateReplace; - var sort_dateFmtStr = settings.sort_dateFmtStr; - - var d;//|| (args && sort_dateFmtStr != args[0]) - if (!sort_dateFormat) { - d = new Date(t); - } - else if (sort_dateFmtStr == '*') - d = apf.date.getDateTime(t); - else - d = (new Date(t.replace(sort_dateFormat, sort_dateReplace))).getTime(); - var t = "" + d.getTime();//parseInt(d); - if (t == "NaN") - t = "0"; - return (t.length < sort_intmask.length ? sort_intmask[sort_intmask.length - - t.length] : "") + t; - } - }; - - /* - sort(xpath, sort_xpath, sort_alpha, boolDesc, from, len) - jsort(n,f,p,ps,sm,desc,sp,ep) - */ - //var order, xpath, type, method, getNodes, dateFormat, dateReplace, sort_dateFmtStr, getValue; - this.apply = function(n, args, func, start, len) { - var sa = [], i = n.length; - - // build string-sortable list with sort method - while (i--) { - var v = settings.getValue(n[i]); - if (n) - sa[sa.length] = { - toString: function(){ - return this.v; - }, - xmlNode: n[i], - v: (settings.method || sort_methods.alpha)(v || "", args, n[i]) - }; - } - - // sort it - sa.sort(); - - //iterate like foreach - var end = len ? Math.min(sa.length, start + len) : sa.length; - if (!start) - start = 0; - - if (func) { - if (settings.ascending) - for (i = start; i < end; i++) - f(i, end, sa[i].xmlNode, sa[i].v); - else - for (i = end - 1; i >= start; i--) - f(end - i - 1, end, sa[i].xmlNode, sa[i].v); - } - else { - //this could be optimized by reusing n... time it later - var res = []; - if (settings.ascending) - for (i = start; i < end; i++) - res[res.length] = sa[i].xmlNode; - else - for (i = end - 1; i >= start; i--) - res[res.length] = sa[i].xmlNode; - return res; - } - }; - - if (xmlNode) - this.parseXml(xmlNode); -}; - - - - - - - - /** * The library that is used for the animations inside elements. * @@ -11560,6 +10014,7 @@ apf.AmlNode = function(){ if (!apf.XPath) apf.runXpath(); +console.log(sExpr) return apf.XPath.selectNodes(sExpr, contextNode || (this.nodeType == 9 ? this.documentElement : this)); }; @@ -12082,13 +10537,6 @@ apf.AmlElement = function(struct, tagName) { if (!value && apf.config && prop) value = apf.config[prop]; - - if (value) { - - //Remove any bounds if relevant - this.$clearDynamicProperty(prop); - - } if (isInherit) this.$inheritProperties[prop] = 2; @@ -12376,10 +10824,7 @@ apf.AmlAttr = function(ownerElement, name, value) { return; } - if (this.specified) - host.$clearDynamicProperty(name); - - if (host.localName != "page" && typeof value == "string" && (host.$attrExcludePropBind[name] || + if (host.localName != "page" && typeof value == "string" && ( (value.indexOf("{") > -1 || value.indexOf("[") > -1))) host.$setDynamicProperty(name, value); else @@ -12886,96 +11331,6 @@ apf.AmlNamedNodeMap = function(host) { -apf.AmlProcessingInstruction = function(isPrototype) { - this.$init(isPrototype); -}; - -(function(){ - this.nodeType = this.NODE_PROCESSING_INSTRUCTION; - - /* - * @todo docs - */ - this.data = null; - - /* - * @todo docs - */ - this.target = null; - - this.serialize = function(){ - return ""; - }; - - this.reload = function(){ - this.$handlePropSet("data", this.data); - }; - - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - calcdata: 0 //Start in code mode - }, this.$attrExcludePropBind); - - this.getAttribute = function(){}; - this.$setInheritedAttribute = apf.AmlElement.prototype.$setInheritedAttribute; - this.$supportedProperties = []; - this.$propHandlers = {}; - this.$booleanProperties = {}; - this.$inheritProperties = {}; - - - - this.$setValue = function(value) { - this.setProperty("data", value); - }; - - this.$handlePropSet = function(prop, value, force) { - this[prop] = value; - if (prop == "data") { - this.$clearDynamicProperty("calcdata"); - this.$setDynamicProperty("calcdata", value); - } - - else if (prop == "target") { - //not implemented - } - else if (this.$propHandlers[prop]) { - this.$propHandlers[prop].call(this, value, prop); - } - }; - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - var pHtmlNode = e.pHtmlNode; - if (!pHtmlNode && (this.parentNode.$bindingRule - || !(pHtmlNode = this.parentNode.$int))) - return; - - pHtmlNode.appendChild(this.$ext = document.createElement("span")); - this.$ext.host = this; - - - - this.$setDynamicProperty("calcdata", this.data); - - - }, true); - - /*this.addEventListener("DOMNodeRemovedFromDocument", function(e) { - this.$clearDynamicProperty("calcdata"); - });*/ - - this.$destroy = function(){ - this.$clearDynamicProperty("calcdata"); - this.$propHandlers["calcdata"].call(this, ""); - }; -}).call(apf.AmlProcessingInstruction.prototype = new apf.AmlNode()); - - - - - - - apf.AmlTextRectangle = function(host) { var _self = this; @@ -13319,12 +11674,6 @@ apf.aml.setElement("include", apf.XiInclude); (function(){ this.$parsePrio = "002"; - //1 = force no bind rule, 2 = force bind rule - /*this.$attrExcludePropBind = apf.extend({ - href: 1, - src: 1 - }, this.$attrExcludePropBind);*/ - this.$propHandlers["href"] = this.$propHandlers["src"] = function(value) { if (typeof value != "string") @@ -14649,10 +12998,6 @@ apf.GuiElement.propHandlers = { this.disabled = value; } else { - if (this.hasFeature(apf.__DATABINDING__) && apf.config.autoDisable - && !(!this.$bindings || this.xmlRoot)) - return false; - this.disabled = false; if (apf.document.activeElement == this) @@ -15083,11 +13428,6 @@ apf.Presentation = function(){ }); - //Reload data - if (this.hasFeature(apf.__DATABINDING__) && this.xmlRoot) - this.reload(); - else - if (this.value) this.$propHandlers["value"].call(this, this.value); @@ -15106,27 +13446,6 @@ apf.Presentation = function(){ apf.layout.activateRules(this.$int); } -/* - if (this.hasFeature(apf.__ANCHORING__)) - this.$recalcAnchoring(); - - - - if (this.hasFeature(apf.__ALIGNMENT__)) { - if (this.aData) - this.aData.oHtml = this.$ext; - - if (this.pData) { - this.pData.oHtml = this.$ext; - this.pData.pHtml = this.$int; - - var nodes = this.pData.childNodes; - for (i = 0; i < nodes.length; i++) - nodes[i].pHtml = this.$int; //Should this be recursive?? - } - } - -*/ if (this.draggable && this.$propHandlers["draggable"]) //@todo move these to the event below apf3.0) this.$propHandlers["draggable"].call(this, this.draggable); @@ -19754,2442 +18073,6 @@ apf.runWebkit = function(){ - - - - -/** - * @constructor - * @parser - * - * @author Rik Arends - * @version %I%, %G% - * @since 3.0 - */ -apf.lm = new (function(){ - - var statement_lut = { // all js statements to see its NOT an expression - "var": 1, "for": 1, "while": 1, "do": 1, "if": 1, "else": 1, - "switch": 1, "case": 1, "break": 1, "continue": 1, "default": 1, - "function":2, "return": 1, "try": 1, "catch": 1, "throw":1, - "debugger": 1, "alert": 1, "confirm": 1,"setTimeout": 1,"setInterval": 1,"delete": 1, "export": 1, "import": 1, - "label": 1, "foreach":1, "each": 1, "eachrev":1, "foreachrev":1, "node": 1, "local": 1, "yield": 1, - "let":1, "finally":1, "delete":1 - }, - type_lut = { // used for optimizing the parse regexp - "\n": 1, "\r\n": 1, "==":2, "++":2, "--":2, '"': 5, "'": 5, - "": 6, "/*": 6, "//": 6, "*/": 6, "{": 7, "}": 8, - "[": 9, "]": 10, "(": 11, ")": 12, "<": 13, ">": 14, "+=":2, - "-=":2, "/=":2, "*=":2, "!=":2 - }, - type_close = { // handy - "{": "}", "[": "]", "(": ")", "{{":"}" - }, - xpath_axes = { // used to detect xpath axes or model - "ancestor": 1, "ancestor-or-self": 1, "attribute": 1, "child": 1, - "descendant": 1, "descendant-or-self": 1, "following": 1, - "following-sibling": 1, "namespace": 1, "parent": 1, "preceding": 1, - "self": 1 - }, - misc_tok = { // misc token lookup - ";":1, ",":2, "^":3, "=":4, "+=":4, "-=":4, "/=":4, "*=":4, "/":5, ":":6 - }, - xpath_lut_code = { // which autoxpath to use when doing macro({xpath}) - "~": "_val(_n,", "%": "_nod(_n,", "*": "_nods(_n,", "#": "_cnt(_n,", "$": "_lng(" - }, - xpath_lut_text = { // which autoxpath to use when doing xpath macros in textmode - "~": "_val(_n,", "%": "_xml(_n,", "*": "_xmls(_n,", "#": "_cnt(_n,", "$": "_lng(" - }, - xpath_lut_attr = { // xpath lut for node attributes - "~": "_val(_n,", "%": "_val(_n,", "*": "_val(_n,", "#": "_cnt(_n,", "$": "_lng(" - }, - xpath_lut_node, - xpath_lut_node_normal = { // normal xpath lookup - "~": "_val(_n,", "%": "_xml(_n,", "*": "_xmls(_n,", "#": "_cnt(_n,", "$": "_lng(" - }, - xpath_lut_node_langedit = { // language edit xpath lookup - "~": "_val(_n,", "%": "_xml(_n,", "*": "_xmls(_n,", "#": "_cnt(_n,", "$": "_lnged(" - }, - pre_regexp = { - "[":1, "(":1, ",":1, "=":1, "return":1, "throw":1 - }, - pre_xpath = { - "else":1, "return":1, "delete":1 - }, - pre_plain = { - "do":1, "else":1, "try":1 - }, - op_lut = { // obj.prop += operator lut - "=" : "_asn(", "+=": "_add(", "-=": "_sub(", "/=": "_div(", "*=": "_mul(" - }, - new_block = { - "+":1, "%":1, "-":1, "/":1, "=":1, "(":1, "?":1, "|":1, "^":1, "[":1, - "&":1, "*":1, "!":1, ":":1, "<":1, ",":1 - }, - out_context_word = { // token preceeding a word signalling a new output - "{":1, "} ":1, ")":1, ") ":1, ";":1, "\n":1, "else":1 - }, - out_context_paren = { // token preceeding a paren signalling a new output - "{":1, ";":1, "\n":1, "else":1 - }, // special markers: ') ' tail of xpath macro. ') ' func def, tok=') ' its not an if while etc. - markup_in_code_lut = { - "} ":1, ") ":1,// the } used when it wasnt a code-expression - "(":1, /*")":1,*/ ";":1, "&":1, "^":1, "|":1, ",":1, '"':1, "'":1, "=":1, - "!=":2,"+=":2, "-=":2, "/=":2, "*=":2, "?":1, "{":1, "}":1, ">":1, "[":1, - /*"]":1,*/ "+":1, ":":1, "else":1, "return":1 - }, - block_autoappend = { // token preceeding block signalling auto append - '"':1, "'":1, ">":1, "]":1, "}":1 - }, - unesc_lut = { // unescape in code and xpath mode - "\\\"": "\"", "\\\'": "\'", "\\{": "{", "\\}": "}", "\\[": "[", - "\\]": "]", "\\(":"(", "\\)":")", "\\\\":"\\" - }, - call_exclusion = { - "alert": 1, "confirm" :1, "setTimeout":1, "setInterval":1, "switch":1, - "call":1, "return":1, "throw":1, "case":1, "catch":1, - "abs":1,"acos":1,"asin":1,"atan":1,"atan2":1,"ceil":1, - "cos":1,"exp":1,"floor":1,"log":1,"max":1,"min":1, - "pow":1,"random":1,"round":1,"sin":1,"sqrt":1,"tan":1,"lin":1,"linear":1, - "idx":1,"sort":1,"typeof":1 - }, - is_out_space = { - " ":1, "\n":1 - }, - newline_notallowed = { - "{":1, ";":1, "(":1, "\n":1 - },//@todo !verify and document! character escaping system - unesc_str = { // unescape in string mode - "\\{": "{", "\\}": "}", "\\[": "[", "\\]": "]", "\\(": "(", "\\)": ")" - }, - unesc_txt = { // unescape in text mode - "\\{" : "{", "\\}" : "}", "\\[" : "[", "\\]" : "]", "\\(" : "(", - "\\)" : ")", "\\\\": "\\\\\\\\", "\\" :"\\\\", "\\<" : "<", "\\>" : ">" - }, - xml_code_operators = { // word to operand lookup table for easy use in xml - "lte": "<=", "gte": ">=", "lt": "<", "gt": ">", "and": "&&", "or": "||", - "andbin": "&", "orbin": "|", "LTE": "<=", "GTE": ">=", "LT": "<", - "GT": ">", "AND": "&&", "OR": "||", "ANDBIN": "&", "ORBIN": "|" - }, - xpath_macro = { // which autoxpath to use when doing macro({xpath}) - 0 : "_val(_n,", - 1 : "_valcr(_n,_cr,", - 2 : "_nod(_n,", - 3 : "_nodcr(_n,_cr,", - 4 : "_nods(_n,", - 5 : "_xpt(_n,", - 6 : "_valst(_n,", - 7 : "_valed(_n,", - 8 : "_valattr(_n,", - "foreach" : "_nods(_n,", - "each" : "_nods(_n,", - "foreachrev": "_nods(_n,", - "eachrev" : "_nods(_n,", - "xabs" : "_valst(_n,", - // "edit" : "_argwrap(_n,", - // "edit" : "_val(_n,", // toggled by liveedit - "local" : "_nod(_n,", - "tagName" : "_nod(_n,", - "localName" : "_nod(_n,", - "xml" : "_xmlq(", - "_call" : "_val(_n," - }, - xpath_model = { // which autoxpath to use when doing macro({xpath}) - "_val(_n," : "_valm(", - "_valcr(_n,_cr,": "_valcr(0,_cr,", - "_nod(_n," : "_nodm(", - "_nodcr(_n,_cr,": "_nodcr(0,_cr,", - "_nods(_n," : "_nodsm(", - "_argwrap(_n," : "_argwrapm(", - "_xml(_n," : "_xml(0,", - "_xmls(_n," : "_xmls(0,", - "_cnt(_n," : "_cntm(", - "_xpt(_n," : "_xptm(", - "_valst(_n," : "_valm(", - "_valed(_n," : "_valed(0,", - "_lng(" : "_lng(", - "_lnged(" : "_lnged(" - }, - parserx = /(\r?[\n]|\/\*|\*\/|\/\/|\<\!\-\-|\-\-\>|[=\!+\/\*-]=|\+\+|\-\-|["'{(\[\])}\]\<\>]|$)|([ \t]+)|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF.$_][\w.$_]*)|(\d[x\d.]*)|(\\?[\w._?,:;!=+-\\\/^&|*"'[\]{}()%$#@~`<>]?)/g, - selfrx = /(^|\|)(?!\@|text\(\)|\.\.|[\w\-\:]+?\:\:)/g, // inject self regexp - macro_o = {}, - macro_c = {}, - macro_m = {}, - // config vars - c_async_lut = apf.$asyncObjects || { // used to figure out if the thing before the. is an async obj - "comm" :1, - "rpc" :1, - "http" :1, - "apf.ajax" :1 - }, - c_process_async, - c_xpathmode, // guess 'node' as the type for {} o_xpathpairs, 1 = node, 2 = nodes - c_elemxpath, // which xpath macro to use inside an element - c_statexpath, // which xpath to use for the stateful value - c_injectself, // add self:: in some o_xpathpairs - c_propassign, // support property assigns - c_export, // export function to some object - // outputs - o, ol, // output and output len - o_asyncs, // number of async calls - o_xpathpairs, // all xpaths and their models in pairs - o_props, // the js properties found - o_segs, // segments at groundlevel - o_xpaths, // xpaths at groundlevel - o_models, // number of xpaths with models - // temp and state vars - s = [], sl, // scopestack and scopestack len - bt = [], // backtrack lut - bts = [], // backtrack string stack - parse_mode, // the parse parse_mode - scope, // ol of a scope begni - segment, // the ol of a segment begin - start_tok, // the token a string or comment was started with - str,str_len, // length of the input string - line_no, // line number we are at - nesting, // nesting count - // last state vars - last_tok, // last token - last_type, // last type - last_dot, // . pos when last token was a word - last_model, // last model found - last_prop, // last property found - last_cmt_mode, // the parse mode outside the comment - last_cmt_tok, // last token before comment - last_cmt_type, // last type before comment - last_line, // offset of last newline - last_ns, // last namespace found - last_word; // last word in code mode - // macros used in code() - macro_o["if"] = "if(", - macro_c["if"] = ")", - macro_o["while"] = "while(", - macro_c["while"] = ")", - macro_o["for"] = "for(", - macro_c["for"] = ")", - macro_o["switch"] = "switch(", - macro_c["switch"] = ")", - macro_o["catch"] = "catch(", - macro_c["catch"] = ")", - macro_c["function"] = ") "; - - macro_o.foreach = - macro_o.each = "\nfor(var _t=_t||[],_t=(_t.push(_n,0,(", - macro_c.foreach = - macro_c.each = ")||[]),_t);(_n=_t[_t.length-1][_t[_t.length-2]++])||(_t.length-=2,_n=_t.pop(),0);)", - macro_o.foreachrev = - macro_o.eachrev = "\nfor(var _t=_t||[],_t=(_t.push(_n,0,(", - macro_c.foreachrev = - macro_c.eachrev = ")||[]),_t);(_n=_t[_t.length-1][_t[_t.length-1].length-(_t[_t.length-2]++)-1])||(_t.length-=2,_n=_t.pop(),0);)", - - macro_o.local = "\nfor(var _t=_t||[],_t=(_t.push(_n,((_n=_local(", - macro_c.local = ")),1)),_t);(_t[_t.length-1]--&&_n)||(_t.length--,_n=_t.pop(),0);)", - macro_o._editlm = "_valedx(true, ", // only serves to switch default xpath in edit([xpath]) - macro_o._editnormal = "_valedx(false, ", // only serves to switch default xpath in edit([xpath]) - macro_c.edit = ")", - macro_o.xabs = " ( ", - macro_c.xabs = " ) ", - - macro_o.localName = "_localName(_n", - macro_c.localName = ")", - macro_o.output = "_o.join(''", - macro_c.output = ")", - macro_o.reset = "(_o=[],l=0", - macro_c.reset = ")", - macro_o.index = "apf.getChildNumber.call(apf", - macro_c.index = ")", - macro_o.item = "(_t[_t.length-1][_t[_t.length-2]-1]", - macro_c.item = ")", - macro_o.first = "(_t[_t.length-2]==1", - macro_c.first = ")", - macro_o.last = "(_t[_t.length-2]==_t[_t.length-1].length", - macro_c.last = ")", - macro_o.total = "(_t[_t.length-1].length", - macro_c.total = ")", - macro_o.pos = "(_t[_t.length-2]-1", - macro_c.pos = ")", - - macro_o.tagName = "_tagName(_n", - macro_c.tagName = ")", - macro_o._nodeValue = "_nodeValue(_n", - macro_c._nodeValue = ")", - macro_c.async = "])", - macro_c.precall = "])", - macro_c._call = ")"; - - var call_args_lut = { - _call: ".call(_n", - localName: macro_o.localName, - tagName: macro_o.tagName, - nodeValue: macro_o.nodeValue, - index: macro_o.index - }, - - // centralized code fragments used in parser/generator - cf_block_o = "(function(){var _o=[],_l=0;\n", - cf_block_c = ";return _l==1?_o[0]:_o.join('');}).call(this)", - cf_async_o = "_async(_n,_c,_a,_w,_f,this,", - cf_async_m = "',_a[++_a.i]||[", - cf_obj_output = "_r=", - cf_mode_output, - cf_str_output = "_o[_l++]=", - cf_def_output = "", - cf_func_o = "{var _o=[],_l=0,_n=this;\n", - cf_func_c = ";\nreturn _l==1?_o[0]:_o.join('');}", - - // compile chunks used in compile/match - cc_async_o = "(_a=_a||{}).i=0;try{\n", - cc_async_c = "}catch(_e){if(_e.x)return;throw(_e);}\n", - //cc_async_o = "(_a=_a||{}).i=0;", - //cc_async_c = "", - cc_pc_o = "(_a=_a||{}).i=0;try{_precall(_w);", - cc_pc_c = "}catch(_e){if(_e.x)return;throw(_e);}", - cc_opt_o = "with(_w){", - cc_opt_c = "}", - cc_v_blk_o = "var _o=[],_l=0;_o[_l++]=", - cc_v_blk_ob = "var _o=[],_l=0;\n", - cc_v_blk_c = ";\nreturn _ret(_l==1?_o[0]:_o.join(''));", - cc_v_blk_cb = ";\n_c(_ret(_l==1?_o[0]:_o.join('')),apf.SUCCESS,apf.$lmx);apf.$lmx=null;", - cc_v_ret_o = "return _ret(", - cc_v_ret_c = ");", - cc_v_cb_o = "_c(_ret(", - cc_v_cb_c = "),apf.SUCCESS,apf.$lmx);apf.$lmx=null;\n", - - cc_o_blk_o = "var _r=", - cc_o_blk_ob = "var _r;", - - cc_o_blk_c = ";\nreturn _r;", - cc_o_blk_cb = ";\n_c(_r,apf.SUCCESS,apf.$lmx);apf.$lmx=null;", - cc_o_blk_ce = ";\n_c(0,apf.SUCCESS,apf.$lmx);apf.$lmx=null;;", - cc_o_ret_o = "return ", - cc_o_ret_c = "", - cc_o_cb_o = "_c(", - cc_o_cb_c = ",apf.SUCCESS);", - cc_f_async_o = "var _f=function(_n,_c,_w,_a){", - cc_f_opt_o = "var _f=function(_n,_w){", - cc_f_o = "var _f=function(_n){", - cc_fc_async_o = "var _f=function(_n,_c,_w,_cr,_a){", - cc_fc_opt_o = "var _f=function(_n,_w,_cr,){", - cc_fc_o = "var _f=function(_n,_cr){", - cc_fe_async_o = "var _f=function(event,_c,_w,_a,_n){", - cc_fe_opt_o = "var _f=function(event,_w,_n){", - cc_fe_o = "var _f=function(event,_n){", - cc_f_c = "}", - cc_f_match_o = "var _f=function(_m){", - - cc_m_m_blk = ";\nif(_n=_r){if(!_n.nodeType)_n=_m;", - cc_m_m_value_o = ";\nif(_n=", - cc_m_m_value_c = "){if(!_n.nodeType)_n=_m;", - cc_m_v_string = "\nreturn ", - cc_m_v_o = "\nreturn _ret(", - cc_m_v_c = ");", - cc_m_n_string = "\nreturn _n;", - cc_m_n_o = "\nreturn (_r = (", - // decision point for compileMatch node-mode for the return type - cc_m_n_c = "))?(_r.nodeType?_r:_n):(_r===null?null:_n);", - - cc_m_o = "var _r, _n = _m;", - cc_m_brk = ";\n_n = _m;", - cc_m_v_ret = "\nreturn _ret(_nodeValue(_n));" , - cc_m_n_ret = "\nreturn _n;" , - cc_m_c = "\n}"; - - function switchToBlock(no_output){ // used to switch expression mode to block mode - var u, v; - if (o[scope-1] == "{{") - u = scope-1; // scan for our root expression block to switch to block - else - for (v = sl - 2, u = 0; v >= 0 && o[u=(s[v] & 0xfffffff) - 1] != "{{"; v -=2 ){}; - - if (!no_output && ol > u + 1) // inject auto output unless no output or nothing to output in buffer - o[u] = cf_block_o + cf_str_output - else - o[u] = cf_block_o; - parse_mode = 1; - } - - function parser(tok, rx_lut, rx_white, rx_word, rx_num, rx_misc, pos) { - var u, v, w, - type = rx_lut ? type_lut[rx_lut] : (rx_white ? 0 : (rx_word ? 3 : (rx_num ? 4 : (tok ? 2 : 15)))); - switch (parse_mode) { - case 0: // ===================== expression parse_mode ========================= - case 1: // ========================== block parse_mode ========================= - switch (type) { - case 0: // -------- whitespace -------- - if ((last_type == 3 && last_tok!='$') || last_type == 4) - o[ol++] = " "; - else if (xpath_lut_code[last_tok]) - last_type = 0;// make last_type visible to xpathmode select - break; - case 1: // -------- newline -------- - line_no++, - last_line = pos; - if (o[ol-1] != "\n" && !newline_notallowed[last_tok]) - o[ol++] = "\n"; - if (xpath_lut_code[last_tok]) - last_type = 0;// make last_type visible to xpathmode select - break; - case 2: // -------- misc -------- - if (v = misc_tok[tok]) { - switch (v) { - case 1: // ';' - if (!s[sl-1]) {// close = macro - o[ol++] = ")", - sl -= 2; - } - - if (!parse_mode) { // dont do ; inject newline instead - if (o[ol-1] != "\n" && last_tok != "{" && last_tok != ";") - o[ol++] = "\n"; - } - else if (!sl || s[sl - 1]) // dont inject ; if we are in nested assignment macros - o[ol++] = ";"; - break; - case 2: // ',' - if (!s[sl - 1]) { // close = macro - o[ol++] = ")", - sl -= 2; - } - o[ol++] = ","; - break; - case 3: //'^' // dont output - if (o[ol-1] == "\n" || o[ol - 1] == ";" || last_tok=="{" - || last_tok == "} " || ol == scope) { // dont output-shortcut requirements - if (!parse_mode) - switchToBlock(); - o[ol++] = " "; // two spaces make it modify the output-ifs outcome - } - else - o[ol++] = "^"; - break; - case 4: //'= += -= assignment macro mode - if (last_tok!='<' && last_tok!='>'){ - // we should only switch to block when we are not in a ( ) scope - if (!parse_mode && o[scope-1]!='(') - switchToBlock(true); - o[ol++] = tok; - // lets scan in reverse to see if we have an output or a non-output - - for (v = ol; v >= scope && !statement_lut[o[v]] && !((o[v] == " " - || o[v] == (nesting ? cf_str_output : cf_mode_output)) && (o[v]="",1)); v--){}; - - if (last_type == 3 && last_dot>0 && last_tok.charAt(0)!="."){ // prop = macro - if (c_propassign) { - ol -= 2; - while (is_out_space[o[ol]]) - ol--; - w = last_tok; - o[ol++] = op_lut[tok], o[ol++] = w.slice(0,last_dot), - o[ol++] = ",'", o[ol++] = w.slice(last_dot+1), - o[ol++] = "',", s[sl++] = scope | (parse_mode << 28), - s[sl++] = ""; // notabene, this stored item is checked everywhere - } - } - }else{ - o[ol++] = tok; - }break; - case 5: // '/' // regexp mode - if (pre_regexp[last_tok]) { - s[sl++] = scope | (parse_mode << 28); - s[sl++] = o[ol++] = tok; - scope = segment = ol - 1; - nesting++, parse_mode = 5, start_tok = tok; - } - else - o[ol++] = "/"; - break; - case 6: // ':' // switch to {x:1} object mode - if (sl > 2 && s[sl - 1] == "{{" && (ol < scope + 4 && last_type == 5) - || (ol < scope + 3 && (last_type == 3 || last_type == 4))) { - o[scope-1] = s[sl-1] = "{" - parse_mode = (v = s[sl - 2]) >> 28; - s[sl-2] = v & 0xfffffff, - nesting--; - } - else if (o[ol - 3] == "case" || (last_type == 5 && last_word == "case")) - tok = ";"; //fixes auto output problem - o[ol++] = ":"; - break; - default: - o[ol++] = tok; - break; - } - } - else - o[ol++] = unesc_lut[tok] || tok; - break; - case 3: // -------- word -------- - case 4: // ------- number ------- - if ( v = xml_code_operators[tok] ){ - o[ol++] = tok = v, type = 2; - } else { - v = u = w = 0;// last_word used for case 'bla bla': - last_dot = (last_word = tok).lastIndexOf("."); - if (tok.charAt(0) != '.' // .obj shouldnt trigger block - && ((v = (u = ((out_context_word[last_tok] // check if we need to switch - || o[ol - 1] == "\n") && !new_block[last_tok])) - && !s[sl - 1].indexOf("{") && ol > scope) - || (w = statement_lut[tok])) && !parse_mode){ // check statement - if (w == 2 && s[sl - 1].indexOf("{")) w = 0; // (function() shouldnt trigger blockmode - switchToBlock(w); // pass in statement_lut[tok] as outputflag - } - if (u && !s[sl - 1]) { // assign macro close - o[ol-1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - if (v && parse_mode && !statement_lut[tok] && !call_exclusion[tok]) // inject output - o[ol++] = (nesting ? cf_str_output : cf_mode_output); - - if (last_dot > 0 && tok.charAt(0) != ".") // store property - o_props[o[ol++] = last_prop = tok] = 1; - else o[ol++] = tok; - } - break; - case 5: // -------- stringquotes -------- - if ((v = (u = ((out_context_word[last_tok] || o[ol - 1]== "\n" ) - && !new_block[last_tok])) && !s[sl - 1].indexOf("{") - && ol > scope) && !parse_mode) // check if we need to switch to block mode - switchToBlock(); - - if (u && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - if (v) { // generate output - o[ol++] = (o[ol-2] != "\n" && block_autoappend[last_tok]) - ? "+" - : (nesting ? cf_str_output : cf_mode_output); - } - else if (block_autoappend[last_tok]) - o[ol++] = "+"; - - s[sl++] = scope | (parse_mode << 28), s[sl++] = o[ol++] = tok; - scope = segment = ol - 1, nesting++, parse_mode = 5, start_tok = tok; - break; - case 6: // -------- comment -------- - if (tok == "*/" || tok== "-->") - throw { - t: "Unmatched comment "+tok, - p: pos - }; - last_cmt_mode = parse_mode, last_cmt_tok = last_tok, - last_cmt_type = last_type, parse_mode = 6, start_tok = tok; - break; - case 7: // -------- { -------- - if (o[ol - 1] == ") " || (o[ol - 2] == ") " && ol--)) { // ') ' is function def - if (s[sl - 1] != "(" && s[sl - 1] != "[") { - s[sl++] = scope | (parse_mode << 28), - s[sl++] = "{{", o[ol++] = cf_func_o, - scope = ol, parse_mode = 1, nesting++, o[ol++] = ""; // make the scope check pass - } - else { - s[sl++] = scope, s[sl++] = o[ol++] = tok, scope = ol; - parse_mode = 1; - }// for do else..etc below - } - else if ((macro_o[s[sl + 1]] && last_tok == ") ") || pre_plain[last_tok]) { - s[sl++] = scope, s[sl++] = o[ol++] = tok, scope = ol; - o[ol++] = ""; - } - else { - if ((v = (u = ((out_context_word[last_tok]||o[ol - 1] == "\n") - && !new_block[last_tok])) - && !s[sl - 1].indexOf("{") && ol > scope) && !parse_mode) - switchToBlock(); // block mode detection - - if (u && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), - o[ol++] = ")", o[ol++] = "\n", v = 1, sl -= 2; - } - if (v) { // inject output, +''+ is when between two { } { } (supposedly) - o[ol++] = (o[ol - 2] != "\n" && block_autoappend[last_tok]) - ? "+''+" - : (nesting ? cf_str_output : cf_mode_output); - } - else if (block_autoappend[last_tok]) // inject append - o[ol++] = (last_tok == "}") ? "+''+" : "+"; - - s[sl++] = scope | (parse_mode << 28), s[sl++] = o[ol++] = "{{"; - - if (!nesting && scope != ol) // count output segments on nesting 0 - o_segs++; - - nesting++, segment = scope = ol, parse_mode = 0; - } - break; - case 8: // -------- } -------- - if (!s[sl - 1]) // close = macro - o[ol++] = ")", o[ol++] = "\n",sl -= 2; - - if (type_close[v = s[--sl]] != (o[ol++] = tok)) - throw { - t: "Cannot close " + v + " with " + tok, - p: pos - }; - - if (v == "{{") { // closing code block - if (scope == ol - 1) { - if ( (s[sl - 1] >> 28) <= 1) // empty code in code - o[scope-1] = "{", o[ol - 1] = "}"; - else // empty code elsewhere - o[scope - 1] = o[ol - 1] = "'"; - } - else { - if (!parse_mode) { // expression wraps in () - o[scope - 1] = "(", - o[ol - 1] = ")"; - } - else { // codeblock wraps in (function(){})() - if (o[scope - 1] == cf_func_o) { - if (scope == ol - 2) - o[scope - 1] = "{", o[ol - 1] = "}"; - else - o[ol - 1] = cf_func_c; - } - else - o[ol - 1] = cf_block_c; - } - } - parse_mode = (v=s[--sl])>>28, scope = v&0x0fffffff; - segment = ol, nesting--; - - if (!nesting) // count segs on nesting level 0 - o_segs++; - - if (parse_mode == 7) // attribute hack - o[ol++] = "+\"\\\"", parse_mode = 4; - } else scope = s[--sl]; // was object def or if (){} - - break; - case 9: // -------- [ -------- - if (((last_type == 3 && !pre_xpath[last_tok] && last_tok!='$') || last_tok == ")" || last_tok == "]") && o[ol - 1] != "\n") { - o[ol++] = "[", s[sl++] = scope | (parse_mode << 28), //was array index - s[sl++] = tok, segment = scope = ol; - } - else { - last_model = null; - - if ((w = xpath_lut_code[last_tok])) { - ol--, last_tok = o[ol-1]; // xpath with *%$# - } - else { - w = xpath_macro[s[sl - 1]] || xpath_macro[nesting ? 0 : c_xpathmode]; - } - if ((v = (u = ((out_context_word[last_tok] || o[ol - 1] == "\n") - && !new_block[last_tok])) && !s[sl - 1].indexOf("{") - && (ol > scope || s[sl - 1].length == 1)) && !parse_mode) - switchToBlock(); // check if we need to switch to block mode - - if (u && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - - if (v) { // inject output - o[ol++] = (o[ol - 2] != "\n" && block_autoappend[last_tok]) - ? "+" - : (nesting ? cf_str_output : cf_mode_output); - } - else if (block_autoappend[last_tok]) // inject append - o[ol++] = "+"; - - if (!nesting && ol!=scope) - o_segs++; - // store scope in bt for reparse of array - nesting++, s[sl++] = scope|(parse_mode<<28), s[sl++] = o[ol++] = w, - segment = scope = ol, bt[scope] = pos, parse_mode = 3; - } - break; - case 10: // -------- ] -------- - if (!s[sl-1]) // close = macro - o[ol++]=")",sl -=2; - - if ( type_close[v = s[--sl]] != (o[ol++] = tok)) - throw { - t: "Cannot close " + v + " with " + tok, - p: pos - }; - - scope = s[--sl]&0xfffffff; // clean scope of possible parse_mode 1 - break; - case 11: // -------- ( -------- - if ( ((v = (u=((out_context_paren[last_tok]||o[ol-1]=="\n") && - !new_block[last_tok])) && !s[sl-1].indexOf("{") && - ol>scope)) && !parse_mode) - switchToBlock(); - - if (u && !s[sl-1]) // close = macro - o[ol-1]=="\n"&&(o[ol-1]=""),o[ol++]=")", o[ol++]="\n",v = 1,sl -=2; - - if (v && parse_mode) // inject output - o[ol++] = (nesting?cf_str_output:cf_mode_output), last_type = 0; - - if (w = macro_o[last_tok]) { - if (o[ol-1]==" ") ol--; // support func () - o[ol-1] = w, s[sl++] = scope, s[sl++] = last_tok, scope = segment = ol; - } - else { - if (last_type == 3) { // word( - if (last_dot < 0) { // no dot - v = 0; - if (last_tok == "function" || o[ol - 3] == "function" || o[ol - 4] == "function") { - s[sl++] = scope, s[sl++] = "function", //func def - o[ol++] = "(", scope = segment = ol; - //TODO! check the depth with which functions are made global - if (last_tok!="function" && c_export && sl==4) { - o[v=(o[ol - 4] == "function")?(ol-4):(ol-5)] = - "var "+last_tok+" = "+c_export+"."+last_tok+" = function"; - o[v+2] = ""; - } - } - else { // its a call and not a new - if (!call_exclusion[last_tok] && o[ol-3]!="new") { - o[ol++] = ".call(_n", s[sl++] = scope, - s[sl++] = "_call", scope = segment = ol; - } - else { // its an excluded call - s[sl++] = scope, s[sl++] = o[ol++] = tok, - scope = segment = ol; - } - } - } - else { - if (last_dot > 1 && c_process_async && (c_async_lut[v = last_tok.substring(0,last_dot)] || c_async_lut[v = last_tok])) {// its an async call - if (o[--ol] == " ") - ol--; - o[ol++] = cf_async_o, o[ol++] = v, o[ol++] = ",'"; - o[ol++] = last_tok.slice(last_dot + 1); - o[ol++] = cf_async_m, s[sl++] = scope, s[sl++] = "async", - scope = segment = ol, o_asyncs++; - } - else { // its a obj.prop() type call - if (last_tok.indexOf('.')!=last_dot) // obj.prop.call(); - o_props[last_tok.slice(0,last_dot)] = 1; - - s[sl++] = scope, s[sl++] = o[ol++] = tok, - scope = segment = ol; - } - } - } - else { // function object call - s[sl++] = scope, s[sl++] = o[ol++] = tok, - scope = segment = ol; - } // dont store calls as props - if (last_tok == last_prop) - delete o_props[last_tok]; - } - break; - case 12: // -------- ) -------- - if (!s[sl - 1]) { // close = macro - o[ol-1] == "\n" && (o[ol-1] = ""), o[ol++] = ")", - o[ol++]="\n", v = 1, sl -= 2; - } - - if (w = macro_c[v = s[--sl]]) { // closing a macro - if (v != "_call") - tok = ") "; // make sure any [ ] doesnt get interpreted as array index - if ((u = call_args_lut[v]) && u != o[ol - 1]) - o[scope - 1] = u + ",";// do , insertion for argless macros - o[ol++] = w; // write close-end of macro - } - else if (type_close[v] != (o[ol++] = tok)) { - throw { - t: "Cannot close " + v + " with " + tok, - p: pos - }; - } - scope = s[--sl] & 0xfffffff; // scope should be unimpacted - break; - case 13: // -------- < -------- - // check if < is markup or not - if (ol == scope || markup_in_code_lut[last_tok] || o[ol - 1] == "\n"){ - if ((v = (u = ((out_context_word[last_tok] || o[ol - 1] == "\n") - && !new_block[last_tok])) && !s[sl - 1].indexOf("{") - && ol > scope) && !parse_mode) - switchToBlock(); // switch to block mode - - if (u && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - if (v) { - o[ol++] = (o[ol - 2] != "\n" && block_autoappend[last_tok]) - ? "+''+" - : (nesting ? cf_str_output : cf_mode_output); - } - else if (block_autoappend[last_tok]) - o[ol++] = "+"; - // start markup mode with the markup-stack counting - last_ns = null, o[ol++] = '"', o[ol++] = "<", nesting++, - s[sl++] = scope | (parse_mode << 28), sl += 3, - s[sl - 2] = s[sl - 1] = 0; - - segment = scope = ol - 1, parse_mode = 4; - } - else - o[ol++] = "<"; - break; - case 14: // -------- < -------- - o[ol++] = ">"; - break; - case 15: // end - if (sl && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - break; - } - break; - case 2: // ========================== text parse_mode ========================== - switch (type) { - case 1: // -------- newline -------- - line_no++, last_line = pos; - if (ol != scope && ol != segment) // only output when not first - o[ol++] = "\\n"; - break; - case 2: // -------- misc -------- - if (ol == segment) // segment connectors - o[ol] = (ol++ == scope) ? "\"" : "+\""; - - o[ol++] = unesc_txt[tok] || tok; - break; - case 3: // word - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - if (tok.charAt(tok.length-1)=='$'){ - o[ol++] = tok.slice(0,-1); - o[ol++] = tok = '$';// fix word$[xpath] - }else o[ol++] = tok; - break; - case 5: // -------- stringquotes -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - - o[ol++] = (tok == '"') ? "\\\"" : "'"; - break; - case 7: // -------- { -------- code mode - if (ol == segment) { - if (ol != scope ) - o[ol++] = "+"; - } - else - o[ol++] = "\"+", nesting || o_segs++; - s[sl++] = scope | 0x20000000, s[sl++] = o[ol++] = "{{", - nesting++, segment = scope = ol, parse_mode = 0; - break; - case 9: // -------- [ -------- xpath mode - last_model = null; // get xpath macro - if ((w = xpath_lut_text[last_tok]) && o[ol - 1] == last_tok) { - if (--ol - 1 == scope) - ol --; // remove first "" - } - else // only select c_xpathmode when nesting == 0 - w = xpath_macro[(nesting || scope != ol) ? 0 : c_xpathmode]; - - if (ol != scope) { - o[ol] = (ol++ == segment) ? "+" : (nesting || o_segs++, "\"+"); - - if (!nesting) - o_segs++; - } - - s[sl++] = scope | 0x20000000, s[sl++] = o[ol++] = w, - segment = scope = ol, nesting++, parse_mode = 3; - break; - case 15: // -------- end -------- - if (sl) - throw { - t: "Unclosed " + s[sl-1] + " found at end in textmode", - p: pos - }; - if (ol != scope && ol != segment) - o[ol++] = "\"", nesting || o_segs++; - break; - default: // -------- default -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = tok; - } - break; - case 3: // ========================== xpath parse_mode ========================= - switch(type) { - case 0: // -------- whitespace -------- - if (ol != scope){ // strip initial spaces\l - if (ol == segment) - o[ol++] = "+\""; - o[ol++] = tok; - } - break; - case 1: // -------- newline -------- - line_no++, last_line = pos; - break; - case 2: // -------- misc -------- - if (tok == ":" && last_tok == ":" && !xpath_axes[w = o[ol - 2]] - && ((v = s[sl - 2]) >> 28) != 6) { // found model::xpath split - if (o[ol - 2] == '+"') // model is calculated - o[ol - 2] = o[ol - 1] = "", last_model = "#"; - else { - o[ol - 1] = '"'; - if (segment == scope) // model is normal name - last_model = o.slice(segment + 1, ol - 1).join(""); - else // model is calculated - last_model = "#"; - } - if (!(w = xpath_model[o[scope - 1]])) - throw { - t: "Invalid model found for: "+o[scope-1], - p: pos - }; - - o[scope - 1] = w, o[ol++] = ",", segment = scope = ol; - } - else { - if (tok == "," && (v = (s[sl - 2] >> 28)) <= 1) { // xpath is an array in code - ol = scope-1, u = str.slice(bt[scope] + 1, pos + 1); - // fix up stack to not be an xpath but an array - last_type = 9, parse_mode = v, o[ol++] = last_tok = "["; - s[sl - 2] = (s[sl - 2] & 0xfffffff) | (parse_mode << 28), - s[sl - 1] = last_tok, segment = scope = ol, nesting--; - - if (!nesting) - o_xpaths--; - if (u.length > 1) { // ignore [, optimized escaping - bts.push(str); // push str so str always is the string in replace - (str = u).replace(parserx, parser); // reparse it - str = bts.pop(); // pop it again - } - } - else { - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = unesc_lut[tok] || tok; - } - } - break; - case 3: // word - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - if (tok.charAt(tok.length-1)=='$'){ - o[ol++] = tok.slice(0,-1); - o[ol++] = tok = '$';// fix word$[xpath] - }else o[ol++] = tok; - break - case 5: // -------- stringquotes -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - if (s[sl - 1] == "[") // strings only are used in [ ] - s[sl - 1] = tok; - else if (s[sl - 1] == tok) // close string - s[sl - 1] = "["; - - if (tok == '"') - o[ol++] = "\\"; - o[ol++] = tok; - break; - case 7: // -------- { -------- - if (ol == segment) { - if (ol != scope) - o[ol++] = "+''+"; - } - else - o[ol++] = "\"+"; - - s[sl++] = scope | 0x30000000, s[sl++] = o[ol++] = "{{", - nesting++, segment = scope = ol, parse_mode = 0; - - if (last_model && s[sl - 3] != xpath_lut_text["$"]) { - o_xpathpairs.push(last_model, "#"); - last_model = null, o_models++; - } - break; - case 9: // -------- [ -------- - // lets see if we are an xpath - if (s[sl - 1] == "'" || s[sl - 1] == '"' || - ((last_type != 3 || last_tok=='$') && last_tok != ")" && last_tok != "]") ) { - if (last_model) - o_xpathpairs.push(last_model, "#"), o_models++; - last_model = null; - - if ((w = xpath_lut_text[last_tok]) && o[ol - 1] == last_tok) - ol--; - else - w = xpath_macro[0]; - - if (ol == segment) { - if (ol != scope) - o[ol++] = "+"; - } - else o[ol++] = "\"+"; - - s[sl++] = scope | 0x30000000, s[sl++] = o[ol++] = w, nesting++, - segment = scope = ol, parse_mode = 3; - } - else { - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - - s[sl++] = scope|0x60000000, s[sl++] = o[ol++] = "["; // keep track of [, abuse mode 6 - } - break; - case 10: // -------- ] -------- - sl--, parse_mode = (w = s[--sl]) >> 28, w = w & 0x0fffffff; - - if (parse_mode == 6){ // was part of [] internally to xpath, see above - if (s[sl + 1] != "[") - throw { - t: "In xpath, cannot close " + s[sl + 1] + " with " + tok, - p: pos - }; - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - - o[ol++] = "]"; - parse_mode = 3; - } - else { - if (ol == scope ) { - if ((s[sl] >> 28) <= 1) // empty array in code - o[scope - 1] = "[", o[ol++] = "]"; - else // empty xpath elsewhere - o[scope - 1] = o[ol++] = "\"" ; - segment = ol; - } - else { - //if( s[sl+1] != '[' ) - // throw {t:"Unclosed string in xpath"+s[sl+1], p: pos}; - if (ol != segment) - o[ol++] = "\""; - if (segment == scope){ // we might have an xpath name - v = o.slice(segment + 1, ol - 1).join(""); - if (c_injectself && o[scope - 1] != "," // inject self - && v != (u = v.replace(selfrx, "$1self::")) - && s[sl + 1] != xpath_lut_text["$"]) { - o[scope+1] = v = u; - for (u = scope + 2; u < ol - 1; u++) - o[u] = ""; - } - } - else { - if ((u = o[scope - 1]) != ",") { - v = "#"; - if (c_injectself)// inject dyn self if dyn xpath - o[scope - 1] = u + "_injself(", o[ol++] = ")"; - } - else - v = ""; - } - if (s[sl + 1] != xpath_lut_text["$"] && v) { - o_xpathpairs.push(last_model, v); // only store if not _lng - if (last_model) - o_models++; - } - o[ol++] = ") ", segment = ol; // close xpath with ') ' marker - //logw("CLOSING XPATH"+o.join('#')+nesting); - if (parse_mode == 7) // attribute assign in xml mode - o[ol++] = "+\"\\\"", parse_mode = 4; - } - // lets output an xpath if we werent a language symbol - nesting--, last_model = null; - if (!nesting) - o_segs++, o_xpaths++; - } - scope = w; - break; - case 11: // -------- ( -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - s[sl++] = scope | 0x30000000, // keep track of () in xpath - s[sl++] = o[ol++] = "(";//, last_model = null; - break; - case 12: // -------- ) -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - - if (type_close[v = s[--sl]] != (o[ol++] = tok)) - throw { - t: "Cannot close " + v + " with " + tok, - p: pos - }; - - scope = s[--sl] & 0xfffffff; - break; - case 15: // -------- end -------- - throw { - t: "Unexpected end whilst parsing xpath", - p: pos - }; - break; - default: // -------- default -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = tok; - break; - } - break; - case 4: // =========================== xml parse_mode ========================== - switch (type) {// stack: '<'sl+4,outside=0, ''sl-2,outside=1 '/>'sl-4,outside=1 - case 0: // -------- whitespace -------- - if (ol == segment) - o[ol++] = "+\""; - - o[ol++] = " ", last_type = 0; - break; - case 1: // -------- newline -------- - if (ol == segment) - o[ol++] = "+\""; - - line_no++, last_line = pos, o[ol++] = "\\n", last_type = 1; - break; - case 2: // -------- misc -------- - if (ol == segment) - o[ol++] = "+\""; - if (tok == "/" && last_tok == "<") { - sl -= 4; // -------- - if (ol == segment) - o[ol++] = "+\""; - - o[ol++] = tok; - if (last_tok != "<") { - if (last_tok == "/") { - sl -= 4; // self close tag /> drops stack -4 - if (s[sl + 2]) - throw { - t: "Unexpected / whilst parsing xml", - p: pos - } - if (o[ol - 3] == "<") // remove empty from output - ol -= 2, o[ol - 1] = ""; - } - else - sl -= 2; // nets stackdepth of 2 - if (s[sl]) { // end of xml mode - nesting--, o[ol++] = "\"", scope = s[sl], segment = ol, - parse_mode = scope >> 28, scope = scope & 0x0fffffff; - } - else - s[sl - 1] = 1; // we are outside a tag, flag it on the stack - } - else // remove empty <> from output - ol--, o[ol - 1] = ""; - break; - case 9: // -------- [ -------- xpath mode - last_model = null; - - if (last_tok == "!" && o[ol - 2] == "<" && !s[sl - 1]) { // CDATA mode - o[ol++] = tok, s[sl++] = scope | (parse_mode << 28); - s[sl++] = "]]>", scope = segment = ol - 1; - nesting++, parse_mode = 5; - } - else { - if (s[sl - 1]) { // we are outside a tag - if ((v = xpath_lut_node[last_tok])) - ol --; - else - v = xpath_macro[c_elemxpath]; - - s[sl++] = scope | 0x40000000 - } - else { - s[sl++] = scope | 0x40000000 - if ((v = xpath_lut_attr[last_tok])) { - ol--; - if (o[ol - 1] == "=") - last_tok = "="; - } - else - v = xpath_macro[last_ns ? c_statexpath : 8]; - - if (last_tok == "=")//0x7 flags xpath-in-missing-quotes - o[ol++] = "\\\"", s[sl - 1] = scope | 0x70000000; - } - o[ol] = (ol++ == segment) ? "+''+" : "\"+"; - nesting++, s[sl++] = o[ol++] = v, - segment = scope = ol, parse_mode = 3; - } - break; - case 7: // -------- { -------- code mode - if ( !s[sl - 1] && last_tok == "=") // 0x7 flags code-in-missing-quotes - o[ol++] = "\\\"", s[sl++] = scope | 0x70000000; - else - s[sl++] = scope | 0x40000000 - - o[ol] = (ol++ == segment) ? "+''+" : "\"+"; - s[sl++] = o[ol++] = "{{", nesting++; - segment = scope = ol, parse_mode = 0; - break; - default: - if (ol == segment) - o[ol++] = "+\""; - o[ol++] = tok; - break; - case 15: // -------- end -------- - throw { - t: "Unexpected end whilst parsing xml", - p: pos - }; - break; - }break - case 5: // ========================== string parse_mode ======================== - switch (type) { - case 1: // -------- newline -------- - line_no++, last_line = pos; - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = "\\n"; - break; - case 2: // -------- misc -------- - if (tok == "/" && s[sl - 1] == "/") { // regexp closing character - o[ol++] = "/", scope = s[sl -= 2], segment = ol, - parse_mode = scope >> 28, - scope = scope & 0x0fffffff, nesting--; - } - else { - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = (s[sl - 1] != "/" && unesc_str[tok]) || tok; - } - break; - case 3: // word - if (ol == segment) - o[ol] = (ol++ == scope) ? "" : "+\""; - if (tok.charAt(tok.length-1)=='$'){ - o[ol++] = tok.slice(0,-1); - o[ol++] = tok = '$';// fix word$[xpath] - }else o[ol++] = tok; - break - case 5: // -------- stringquotes -------- - if (s[sl - 1] == tok) { // closed by matching quote - if (scope != segment) // string is segmented, output ) - o[ol] = (ol++ != segment) ? (tok + ")") : ")"; - else - o[ol++] = tok; // else just close - scope = s[sl -= 2], segment = ol, parse_mode = scope >> 28; - scope = scope & 0x0fffffff, nesting--; - } - else { - if (ol == segment) - o[ol] = (ol++ == scope) ? "\"" : "+\""; - o[ol++] = tok == '"' ? "\\\"" : tok; - } - break; - case 6: // -------- default -------- - if (s[sl - 1] == "/" && tok == "*/") { // caught faux comment in regexp /a*/, is close - o[ol++] = "*/", scope = s[sl -= 2], segment = ol, - parse_mode = scope >> 28, scope = scope & 0x0fffffff, nesting--; - } - else { - if (ol == segment) - o[ol] = (ol++ == scope) ? "" : "+\""; - o[ol++] = tok; - } - break; - case 7: // -------- { -------- code mode - if (s[sl - 1] != "'" && s[sl - 1] != "/") { - if (s[sl - 1] == '"') - o[scope] = '("'; - if (ol == segment) { - if (ol != scope) - o[ol++] = "+"; - } - else - o[ol++] = "\"+"; - s[sl++] = scope | 0x50000000, o[ol++] = s[sl++] = "{{", - nesting++, segment = scope = ol, parse_mode = 0; - } - else - o[ol++] = tok; - break; - case 9: // -------- [ -------- xpath mode - if (s[sl - 1] != "'" && s[sl - 1] != "/" // ignore in '' and CDATA[, else xpath - && (s[sl - 1] == '"' && (o[scope] = '("') || ol != scope + 2 - || last_tok != "CDATA") ) { - last_model = null; - if ((w = xpath_lut_text[last_tok]) && o[ol - 1] == last_tok) - ol--; - else - w = xpath_macro[0] - - if (ol != scope) - o[ol] = (ol++ == segment) ? "+" : "\"+"; - - s[sl++] = scope | 0x50000000, s[sl++] = o[ol++] = w, - segment = scope = ol, nesting++, parse_mode = 3; - } - else - o[ol++] = tok; - break; - case 14: // -------- > -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "" : "+\""; - o[ol++] = tok; - - if (s[sl - 1] == "]]>" && last_tok == "]" && o[ol - 3]=="]") { // check if CDATA close - scope = s[sl -= 2], parse_mode = scope >> 28; - scope = scope & 0x0fffffff, nesting--; - sl -= 4; // close the tag since we came from XML mode - if (s[sl]) // was last tag, jump up the stack one more. - nesting--, o[ol++] = "\"", scope = s[sl], segment = ol, - parse_mode = scope >> 28, scope = scope & 0x0fffffff; - else - s[sl - 1] = 1; - } - break; - case 15: // -------- end -------- - throw { - t: "Unexpected end whilst parsing string", - p: pos - }; - break; - default: // -------- default -------- - if (ol == segment) - o[ol] = (ol++ == scope) ? "" : "+\""; - o[ol++] = tok; - break; - } - break; - case 6: // ========================= comment parse_mode ======================== - switch (type) { - case 1: // -------- newline -------- - line_no++, last_line = pos; - if (start_tok == "//") - parse_mode = last_cmt_mode, - tok = last_tok = last_cmt_tok, - type = last_type = last_cmt_type; - break; - case 6: // -------- comment -------- - if ((start_tok == "/*" && tok == "*/") - || (start_tok == "")) { - parse_mode = last_cmt_mode, - tok = last_tok = last_cmt_tok, - type = last_type = last_cmt_type; - } - break; - case 15: // -------- end -------- - if (start_tok != "//"){ - throw { - t: "Unexpected end whilst parsing comment", - p: pos - } - } else { - parse_mode = last_cmt_mode, - tok = last_tok = last_cmt_tok, - type = last_type = last_cmt_type; - if (sl && !s[sl - 1]) { // close = macro - o[ol - 1] == "\n" && (o[ol - 1] = ""), o[ol++] = ")", - o[ol++] = "\n", v = 1, sl -= 2; - } - }; - break; - } - break; - } - if (type > 1) - last_tok = tok, last_type = type; - } - - this.lastCode = function(){ - if (typeof(o) == "object") - return o.join(""); - return o; - }; - - function handleError(e, last_line, part, linenr) { - // TODO: make a proper APF exception with this information: - if (e.t) { - throw new Error(apf.formatErrorString(0, null, - "Parsing live markup source", - "Error whilst parsing: " + e.t + " on line:"+ line_no - + " col:" + (e.p - last_line - 2) - + (part ? (" part: " + part) : "") + "\n" + str)); - } - else { - throw new Error(apf.formatErrorString(0, null, - "Compiling live markup function on line " + linenr, - "Error whilst compiling: " + e.message - //+ "\nStack Trace:\n" + e.stack - + "\nInput:\n" + str - + "\nGenerated:\n" + apf.lm.lastCode())); - } - } - - /** - * description of the method. - * Remarks: - * function{type:1,xpaths:[ model,name], props: ['obj.propname','obj2.otherpropname'], asyncs=1} - * this is a normal compiled function with extra properties - * if the xpath model and/or name is '#' it means it is a runtime calculated modelname or xpath. - * obj{type:2, str:str} it was single string by cfg option !alwayscode - * obj{type:3, xpaths:[ model, name ] } it was a single xpath by cfg simplexpath - * - * @param {String} str the code to compile - * @param {Object} options - * Properties: - * {Boolean} withopt creates with(_w){ code using an options block. (reqd for precall) - * {Boolean} precall wraps 1 async call into precallstore. call with _w._pc = 1 to precall, second time to execute. - * {Boolean} alwayscb always call callback function, even if not async - * {Boolean} nostring even generate code for a simple string - * {Number} xpathmode default type of root level xpath in code mode - * Possible values: - * 0: value - * 1: value with createnode - * 2: node - * 3: node with createnode - * 4: nodes - * 5: xpathobj returns a {model:model,xpath:xpath} object from xpaths - * {Boolean} parsecode start in codemode. if 0 its textmode. - * {Boolean} nostate dont' use _valst macro on [xpath] in namespaced xml. - * {Boolean} liveedit use the _valed macro for [xpath] in namespaced xml. - * {Boolean} langedit use of language items in namespaced xml text. - * {Boolean} injectself injects self:: to suitable xpaths - * {Boolean} event its an event thats being compiled, results in no returnvalue for this function. - * and the first argument is now an 'e' for the event object. - * {Boolean} funcglobal all functions defined in LM are made global - - * - * @return {Function} returns a function with extra properties - * Properties: - * {Number} type description - * Possible values: - * 1 Function return type - * 2 Parsed data is a pure string - * 3 Function return type, but its a single xpath - * 4 Function return type, but single propxs - * {Array} xpaths array of [model,xpath, model,xpath] pairs if model - * or xpath is '#', its dynamic if model is null its a local xpath - * {Number} models number of models - * {Array} props description - * {Number} asyncs description - * {String] str optional, returned with type 2 - */ - var cache = {}, - emptyCfg = {}; - this.resetCache = function(){ - cache = {}; - }; - var lmcache_rx = /^\s*~~(c\d+)~~/; - this.compile = function(istr, cfg) { - if (!cfg) - cfg = emptyCfg; - if (istr == null || !istr.length) { - return (cfg.nostring || cfg.event)?function(){return istr}:{ - type: 2, - str: istr - }; - } - // lets see if we need to fetch precompiled cachemarker - var c, f, is_single_prop; - if (istr.charAt(0)=="~" && (c=istr.match(lmcache_rx))){ - if (c=apf.lm_exec[c[1]]) return c; - alert("ERROR, undefined live markup cache marker found:"+istr); - return {type:2,str:istr}; - } - - var key = (cfg.xpathmode | (cfg.withopt && 0x10) | (cfg.precall && 0x20) - | (cfg.alwayscb && 0x40) | (cfg.nostring && 0x80) | (cfg.parsecode && 0x100) - | (cfg.nostate && 0x200) | (cfg.liveedit && 0x400)| (cfg.langedit && 0x800) - | (cfg.injectself && 0x1000) | (cfg.event && 0x2000) | (cfg.funcglobal && 0x4000)) + istr; - - if (c = cache[key]) - return c; - - - c_injectself = cfg.injectself, c_xpathmode = cfg.xpathmode||0, - c_statexpath = cfg.nostate ? 0 : 6, c_elemxpath = 0; - c_export = cfg.funcglobal?"self":(cfg.withopt?"_w":null); - c_process_async = !cfg.event; - - xpath_macro.edit = cfg.liveedit ? "_argwrap(_n," : "_argwrap(_n,";//"_val(_n,"; - macro_o.edit = cfg.liveedit ? macro_o._editlm : macro_o._editnormal; - - xpath_lut_node = cfg.langedit ? xpath_lut_node_langedit : xpath_lut_node_normal; - - o_props = {}, o_xpathpairs = [], s = [], o = ["","","",""], str = istr, - str_len = str.length; - ol = scope = segment = o.length, - o_segs = o_xpaths = o_asyncs = o_models = nesting = line_no = last_type = last_line = 0; - - if (cfg.parsecode) { - parse_mode = 0, sl = 2, s[0] = ol, s[1] = "{{", last_tok = "{", - cf_mode_output = cfg.event ? "" : (c_xpathmode <= 1 ? cf_str_output : cf_obj_output); - } - else - parse_mode = 2, sl = last_tok = 0, cf_mode_output = cf_str_output; - - if (cfg.nothrow) { - str.replace(parserx, parser); - } - else { - try { - str.replace(parserx, parser); - } - catch (e) { - handleError(e, last_line); - return null; - } - } - - if (cfg.parsecode) { - if (nesting || s[sl - 1].length == 1) - handleError({ - t: "Unclosed " + s[sl-1] + " found at end in codemode", - p: str_len - },last_line); - if (segment!=ol) - o_segs++ - }else if( (ol==7 || ol==8) && o_segs == 1) { - is_single_prop = 0; - for (c in o_props)is_single_prop++; - if (is_single_prop!=1)is_single_prop = 0; - } - if ((!cfg.nostring && !cfg.event)&& (parse_mode == 2 && segment == 4 || ol == 4)) { - return { - type: 2, - str: o.slice(5, -1).join("").replace(/\\n/g, "\n").replace(/\\"/g, '"') - }; // string only - } - if (o_asyncs || cfg.alwayscb) { - - if (cfg.event) { // event - if (parse_mode == 1) - o[3] = ""; - o[ol++] = cc_o_blk_ce; - } - else if (c_xpathmode) { // object return - if (parse_mode == 1) { - o[3] = (o[3] != cf_block_o) ? cc_o_blk_o : cc_o_blk_ob, - o[ol++] = cc_o_blk_cb; - } - else - o[3] = cc_o_cb_o, o[ol++] = cc_o_cb_c; - } - else { // value return - if (parse_mode == 1) - o[3] = (o[3] != cf_block_o) ? cc_v_blk_o : cc_v_blk_ob, - o[ol++] = cc_v_blk_cb; - else - o[3] = cc_v_cb_o, o[ol++] = cc_v_cb_c; - } - - if (o_asyncs) { - // for parse_mode == 1 we can squeeze in before [3] and cb close - // else we put var _r= in 3 and put our ending last and put - // the cb at the end - if (parse_mode==1) { - if (cfg.precall) - o[2] = cc_pc_o, o[ol-1] = cc_pc_c + o[ol-1]; - else - o[2] = cc_async_o, o[ol-1] = cc_async_c + o[ol-1]; - }else{ - o[ol++] = o[3] + '_r' + o[ol-2]; - if (cfg.precall) - o[2] = cc_pc_o, o[3] = cc_o_blk_o, o[ol-2] = cc_pc_c; - else - o[2] = cc_async_o, o[3] = cc_o_blk_o, o[ol-2] = cc_async_c; - } - } - - if (cfg.withopt) - o[1] = cc_opt_o, o[ol++] = cc_opt_c; - - o[0] = cfg.event - ? cc_fe_async_o - : ((c_xpathmode == 1 || c_xpathmode == 3) ? cc_fc_async_o : cc_f_async_o); - o[ol++] = cc_f_c; - } - else { - if (cfg.event) { // event - if (parse_mode == 1) - o[3] = ""; - } - else if (c_xpathmode) { // object return - if (parse_mode == 1) { - o[3] = (o[3] != cf_block_o) ? cc_o_blk_o : cc_o_blk_ob, - o[ol++] = cc_o_blk_c; - } - else - o[3] = cc_o_ret_o, o[ol++] = cc_o_ret_c; - } - else { // value return - if (parse_mode == 1) { - o[3] = (o[3] != cf_block_o) ? cc_v_blk_o : cc_v_blk_ob, - o[ol++] = cc_v_blk_c; - } - else - o[3] = cc_v_ret_o, o[ol++] = cc_v_ret_c; - } - if (cfg.withopt) - o[2] = cc_opt_o, o[ol++] = cc_opt_c; - - o[0] = cfg.event - ? (cfg.withopt ? cc_fe_opt_o : cc_fe_o) - : (cfg.withopt - ? ((c_xpathmode == 1 || c_xpathmode == 3) ? cc_fc_opt_o : cc_f_opt_o) - : ((c_xpathmode == 1 || c_xpathmode == 3) ? cc_fc_o : cc_f_o)); - o[ol++] = cc_f_c; - } - - var code = "with(apf.nameserver.lookup.all){\n" + o.join("") + "\n}"; - - if (cfg.nothrow) { - f = apf.lm_exec.compile(code); - } - else { - f = apf.lm_exec.compile(code); - } - f.type = (o_segs == 1 && o_xpaths == 1) ? 3 : (is_single_prop?4:1); - f.xpaths = o_xpathpairs, f.models = o_models, - f.props = o_props, f.asyncs = o_asyncs; - - cache[key] = f; - return f; - }; - - /** - * description of the method. - * Remarks: - * @param {String} str the code to compile - * @param {Object} options - * Properties: - * {Boolean} node tries to return a node, used as a dual-compile with 'normal mode' - * - * @return {Function} returns a function with extra properties - * Properties: - * {Number} type description - * Possible values: - * 1 Function return type - * 2 Parsed data is a pure string - * 3 Function return type, but its a single xpath - * {Array} xpaths array of [model,xpath, model,xpath] pairs if model - * or xpath is '#', its dynamic if model is null its a local xpath - * {Number} models number of models - * {Array} props description - * {Number} asyncs description - * {String] str optional, returned with type 2 - */ - - this.compileMatch = function(strarray, cfg) { - if (!cfg) - cfg = emptyCfg; - - o_props = {}, o_xpathpairs = [], o = [cc_f_match_o, cc_m_o], s = [], - nesting = 0, ol = o.length, xpath_lut_node = xpath_lut_node_normal; - - for (var st, ob, i = 0, j = strarray.length; i < j; i += 2) { - if (str = strarray[i]) { - str_len = s.length, c_xpathmode = 2; - if (i) - o[ol++] = cc_m_brk; - o[ol++] = ""; - s[0] = ob = ol = scope = segment = o.length, cf_mode_output = cf_obj_output; - line_no = last_type = o_segs = o_xpaths = o_asyncs = parse_mode = last_line = 0; - sl = 2, s[1] = "{{", last_tok = "{"; - c_injectself = 1; - - if (cfg.nothrow) { - str.replace(parserx, parser); - } - else { - try { - str.replace(parserx, parser); - } - catch (e) { - handleError(e,last_line); - return null; - } - } - - if (nesting || s[sl - 1].length == 1) - handleError({ - t: "Unclosed " + s[sl - 1] + " found at end in codemode", - p: str_len - }); - - if (o_asyncs) - handleError({t:"Asynchronous calls not supported in match/value"}); - - if (parse_mode == 1) { // block mode - o[ob - 1] = (o[ob - 1] != cf_block_o) ? cf_mode_output : "", - o[ol++] = cc_m_m_blk; - } - else // value mode - o[ob-1] = cc_m_m_value_o, o[ol++] = cc_m_m_value_c; - } - if (str = strarray[i + 1]) { - str_len = s.length; - if (!strarray[i] && i) - o[ol++] = cc_m_brk; - o[ol++] = ""; - ob = ol = scope = segment = o.length, cf_mode_output = cf_str_output; - c_xpathmode = c_injectself = last_tok = sl = line_no = o_segs = o_xpaths = - last_type = o_asyncs = last_line = 0; - if (cfg.node) - c_xpathmode = 2; - parse_mode = 2, c_injectself = 0; - - if (cfg.nothrow) { - str.replace(parserx, parser); - } - else { - try { - str.replace(parserx, parser); - } - catch (e) { - handleError(e,last_line); - return null; - } - } - - if (o_asyncs) - handleError({t:"Asynchronous calls not supported in match/value"}); - - if (cfg.node) { - if (parse_mode == 2 && segment == ob || ol == ob) - o[ob-1] = cc_m_n_string; - else - o[ob-1] = cc_m_n_o, o[ol++] = cc_m_n_c; - }else{ - if (parse_mode == 2 && segment == ob || ol == ob) - o[ob-1] = cc_m_v_string; - else - o[ob-1] = cc_m_v_o, o[ol++] = cc_m_v_c; - } - - if (strarray[i]) - o[ol++] = cc_m_c; - else - break; - } - else { - if (!strarray[i]) - handleError({t:"Both match and value are empty"}); - - if (cfg.node) - o[ol++] = cc_m_n_ret; - else - o[ol++] = cc_m_v_ret; - - c_xpathmode = 2; - - o[ol++] = cc_m_c; - } - } - o[ol++] = cc_f_c; - - var f; - if (cfg.nothrow) { - f = apf.lm_exec.compile(o.join("")); - } - else { - try{ - f = apf.lm_exec.compile(o.join("")); - } - catch (e) { - handleError(e,last_line); - return null; - } - } - - f.type = 1, f.xpaths = o_xpathpairs, - f.props = o_props, f.asyncs = o_asyncs; - return f; - }; - - this.setWarnLevel = function(lvl) { - apf.lm_exec.setWarnLevel(lvl); - }; - - this.parseExpression = function(istr, cfg) { - if (!cfg) - cfg = emptyCfg; - - o_props = {}, o_xpathpairs = [], o = [], s = [], - nesting = 0, xpath_lut_node = xpath_lut_node_normal; - str = istr, str_len = str.length; - ob = ol = scope = segment = o.length, cf_mode_output = cf_str_output; - c_xpathmode = c_injectself = last_tok = sl = line_no = o_segs = o_xpaths = - last_type = o_asyncs = last_line = 0; - parse_mode = 2; - - if (cfg.nothrow) { - str.replace(parserx, parser); - } - else { - try { - str.replace(parserx, parser); - } - catch (e) { - handleError(e,last_line); - return null; - } - } - return o.join(''); - } - - -})(); - -// apf lm_exec makes sure there is no scope pollution for eval'ed live markup. -apf.lm_exec = new (function(){ - - var wlvl = 1; // 0: no warnings 1: language/models missing, 2:nodes missing, 3:all failed xpaths - - //warning functions - this.setWarnLevel = function(lvl) { - wlvl = lvl; - }; - - function wxpath(x, t) { - apf.console.warn("Live Markup warning in " + t + ", no results for xpath: '" + x + "'"); - } - - function wnode(x, t) { - apf.console.warn("Live Markup warning in " + t + ", xpath on null node: '" + x + "'"); - } - - function wmodel(m, x, t) { - apf.console.log("Live Markup warning in " + t + ", xpath on empty model: '" + m + "' xpath: '" + x + "'"); - } - - function wlang(x, t) { - apf.console.log("Live Markup warning in " + t + ", language symbol not found: '" + x + "'"); - } - - // xml parse function used by all livemarkup objects - function xmlParse(str) { - var n = apf.getXmlDom("<_apflmlist_>" + str + ""); - if (!n || !(n = n.documentElement)) - return null; - return (n.firstChild == n.lastChild) ? n.firstChild : n; - } - - // value of node by xpath - function __val(n, x) { - if (!n) - return ("") - return apf.escapeXML((n = (!n.nodeType && n || (n = n.selectSingleNode(x)) //!= 1 - && (n.nodeType != 1 && n || (n = n.firstChild) && n.nodeType!=1 && n))) - && n.nodeValue || ("")); - } - - var __valattrrx = /(["'])/g; - function __valattrrp(m,a) { - return m=='"'?""":"'"; - } - function __valattr(n, x) { - if (!n) - return ("") - return apf.escapeXML((n = (n.nodeType != 1 && n || (n = n.selectSingleNode(x)) - && (n.nodeType != 1 && n || (n = n.firstChild) && n.nodeType!=1 && n))) - && n.nodeValue.replace(__valattrrx,__valattrrp) || ("")); - } - - - // value of model node by xpath - function __valm(m, x) { - var n; - if (!m || !(n = (m.charAt && ((m.charAt(0) == "<" && xmlParse(m)) - || ((n = apf.nameserver.lookup.model[m]) && n.data))) - || (m.$isModel ? m.data : (m.charAt ? 0 : m)))) - return (""); - return (n = (n.nodeType != 1 && n || (n = n.selectSingleNode(x)) - && (n.nodeType != 1 && n || (n = n.firstChild) && n.nodeType!=1 && n))) - && n.nodeValue || (""); - } - - function __nod(n, x){ // node by xpath - return n ? n.selectSingleNode(x) : (null); - } - - function _nods(n, x){ // array of nodes by xpath - return n ? n.selectNodes(x) : ([]); - } - - function __nodm(m, x){ // node of model by xpath - var n; - if (!m || !(n = (m.charAt && ((m.charAt(0) == "<" && xmlParse(m)) - || ((n = apf.nameserver.lookup.model[m]) && n.data))) - || (m.$isModel ? m.data : (m.charAt ? 0 : m)))) - return (null); - - return n.selectSingleNode(x); - } - - function _nodsm(m, x){ // array of nodes from model by xpath - var n; - if (!m || !(n = (m.charAt && ((m.charAt(0) == "<" && xmlParse(m)) - || ((n = apf.nameserver.lookup.model[m]) && n.data))) - || (m.$isModel ? m.data : (m.charAt ? 0 : m)))) - return ([]); - - return n.selectNodes(x); - } - - function __cnt(n, x){ // count nodes by xpath - return n ? n.selectNodes(x).length:(0); - } - - function __cntm(m, x){ // count nodes from model by xpath - var n; - if (!m || !(n = (m.charAt && ((m.charAt(0) == "<" && xmlParse(m)) - || ((n = apf.nameserver.lookup.model[m]) && n.data))) - || (m.$isModel ? m.data : (m.charAt ? 0 : m)))) - return (0); - - return n.selectNodes(x).length; - } - - function _xpt(n, x){ // return the query wrapped in an object - return { - xpath: x, - toString: function(){ - return "LM Xpath object: " + this.x - } - }; - } - - function _xptm(m, x){ // return the query with model wrapped in an object - if (m && !m.$isModel) { - var node = m; - m = apf.xmldb.findModel(m); - x = apf.xmlToXpath(node, m.data) + "/" + x; - } - - return { - model: m, - xpath: x, - toString: function(){ - return "LM Xpath object with model: " + this.x - } - }; - } - - //----- the following functions are combined model and normal mode ------ - - function _xml(n, m, x){ // serialize node by xpath via .xml - if (n) x = m; - else if (!m || !(n=(m.charAt && ((m.charAt(0)=="<" && xmlParse(m)) || - ((n = apf.nameserver.lookup.model[m]) && n.data))) || - (m.$isModel?m.data:(m.charAt?0:m)))) - return (""); - - return (n && (n = n.selectSingleNode(x))) && n.xml || - (""); - } - - function _xmls(n, m, x){ // serialize nodes by xpath with .xml concatenated - if (n) x = m; - else if (!m || !(n=(m.charAt && ((m.charAt(0)=="<" && xmlParse(m)) || - ((n = apf.nameserver.lookup.model[m]) && n.data))) || - (m.$isModel?m.data:(m.charAt?0:m)))) - return (""); - for (var i = 0,j = ((n=n.selectNodes(x))).length,o = [];i' + ((n?__val(n,m):__valm(m,x)) || " ") + ''; - } - -// function _edit(n, opts) { -// return '' + ((n?__val(n,m):__valm(m,x)) || " ") + ''; -// } - - function _argwrap(n,x) { - return [n,x]; - } - - function _argwrapm(m,x) { - return [0,m,x]; - } - - function _valedx(editMode, args, opt){ // wrap a value with editable div - args[3] = opt; - args[4] = editMode; - return _valed.apply(this, args); - } - - function _valed(n, m, x, options, editMode){ // wrap a value with editable div - var res = (n?__val(n,m):__valm(m,x)); - - if (options && options.multiline && options.editor != "richtext") - res = res.replace(/\n/g, "
"); - - if (editMode !== false) { - var value = res || options && options.initial || " "; - if (!options || !options.richtext) - value = apf.htmlentities(value); - if (options && options.multiline) - value = value - .replace(/<br ?\/?>/g, "
") - .replace(/<(\/?div)>/g, "<$1>"); - - return '' + value - + ''; - } - else { - return res; - } - } - - var selfrx = /(^|\|)(?!\@|text\(\)|\.\.|[\w\-\:]+?\:\:)/g; // inject self regexp - - function _injself(s){ // self inject helper func - return s.charAt?s.replace(selfrx, "$1self::"):s; - } - - apf.$lmx = null; - - function _async(_n,_c,_a,_w,_f,_this,obj,func,args){ // Async handling - var i = _a.i, v; - - if (!_a.ret)_a.ret = []; - - if (_a[i]) - return _a.ret[i]; - - _a[i] = true; // flag this ID so args dont get computed again - - if (!obj.exec) - return _a.ret[i]=(func)?obj[func].apply(obj,args):obj.apply(obj,args); - - var cb = function(data, state, extra) { - if (_w) - delete _w._pc; - - if (state != apf.SUCCESS) { - _c(null, state, extra); - } - else{ - apf.$lmx = extra; - _a.ret[i] = data; - - if (_w) - _f.call(_this,_n,_c,_w,_a); - else - _f.call(_this,_n,_c,_a); - } - }; - - if (_w && _w._pc) { - _w._pc = { - obj: obj, - func: func, - args: args, - message: obj.createMessage && obj.createMessage(func, args), - _c: _c, - cb: cb - }; - }else{ - obj.exec(func, args, cb); - } - throw({ - x: 1 - }); - } - - function _precall(_w){ // precall - var o; - if (typeof(o = _w._pc) != "object" || !o) - return; - - o.obj.exec(o.func, o.args, o.cb, {message: o.message}); - - throw({x:1}); - } - - var _clut = apf.color?apf.color.colorshex:{}, _cparse = /^(rgb|hsv|hsb)\(\s+(\d+)\s+,\s+(\d+)\s+,\s+(\d+)\)/ - - function sort(set, xpath, options) { - var s = new apf.Sort(); - options = options || {}; - if (!xpath.charAt)xpath = ""; - if (xpath.charAt(0)=='@'){ - xpath = xpath.slice(1); - options.getValue = function(n) { - return n.getAttribute(xpath); - } - }else{ - options.getValue = function(n) { - return apf.queryValue(n,xpath); - } - } - s.set(options); - return s.apply(apf.getArrayFromNodelist(set)); - } - - function _cthex(c) { - var t; - if ((t=typeof(c))=='string'){ - if (c.indexOf('#')==0) { - if (c.length==7) return parseInt(c.slice(-1),16); - return parseInt(c.slice(-1),16); // compute repeat - } - if (t = _clut[a])return t; - if (c=c.match(_cparse)){ - if ((t=c[1]) == 'rgb'){ - return (((t=c[2])<0?0:(t>255?255:parseInt(t)))<<16)+ - (((t=c[3])<0?0:(t>255?255:parseInt(t)))<<8)+ - (((t=c[4])<0?0:(t>255?255:parseInt(t)))); - } else { // hsv - var h=parseFloat(c[2]),s=parseFloat(c[3]),v=parseFloat(c[4]), - i,m=v*(1-s),n=v*(1-s*((i=floor(((h<0?-h:h)%1)*6))?h-i:1-(h-i))); - switch(i) { - case 6:case 0: return ((v&0xff)<<16)+((n&0xff)<<8)+(m&0xff); - case 1: return ((n&0xff)<<16)+((v&0xff)<<8)+(m&0xff); - case 2: return ((m&0xff)<<16)+((v&0xff)<<8)+(n&0xff); - case 3: return ((m&0xff)<<16)+((n&0xff)<<8)+(v&0xff); - case 4: return ((n&0xff)<<16)+((m&0xff)<<8)+(v&0xff); - default: case 5: return ((v&0xff)<<16)+((m&0xff)<<8)+(n&0xff); - } - } - } - } else if (t=='number')return t; - return null; - } - - function lin(f, a, b) { - var fa = parseFloat(a), fb = parseFloat(b), fm = 1-(f = f<0?0:(f>1?1:f)); - if (fa!=a || fb!=b) - return (((fa=_cthex(a))&0xff0000)*f+((fb=_cthex(b))&0xff0000)*fm)&0xff0000| - ((fa&0xff00)*f+(fb&0xff00)*fm)&0xff00 | - ((fa&0xff)*f+(fb&0xff)*fm)&0xff; - return f*fa+fm*fb; - } - - var abs = Math.abs, acos = Math.acos, asin = Math.asin, - atan = Math.atan, atan2 = Math.atan2, ceil = Math.ceil, - cos = Math.cos, exp = Math.exp, floor = Math.floor, - log = Math.log, max = Math.max, min = Math.min, - pow = Math.pow, random = Math.random, round = Math.round, - sin = Math.sin, sqrt = Math.sqrt, tan = Math.tan, linear = lin; - - function tsin(x){ return 0.5*sin(x)+0.5;} - function tcos(x){ return 0.5*cos(x)+0.5;} - function usin(x){ return 0.5-0.5*sin(x);} - function ucos(x){ return 0.5-0.5*cos(x);} - function snap(a,b){ return round(a/b)*b; } - function clamp(a,b,c){ return ac?c:a); } - - this.compile = function(code) { - // up-scope much used functions - var _ret = __ret, _val = __val,_valm = __valm, _nod = __nod, - _nodm = __nodm, _cnt = __cnt, _cntm = __cntm, _lng = __lng, _valattr = __valattr; - - eval(code); - - return _f; - } - - this.compileWith = function(code, withs) { - // up-scope much used functions - var _ret = __ret, _val = __val,_valm = __valm, _nod = __nod, - _nodm = __nodm, _cnt = __cnt, _cntm = __cntm, _lng = __lng, _valattr = __valattr; - - eval(code); - - return _f; - } - - var LMBEGINCACHE; - /*LIVEMARKUP BEGIN CACHE - var _ret = __ret, _val = __val,_valm = __valm, _nod = __nod, - _nodm = __nodm, _cnt = __cnt, _cntm = __cntm, _lng = __lng, _valattr = __valattr; - this.c342 = function(_n,_a,_w) { - ..cached LM function.. - } - this.c342.type = 2; - this.c342.xpaths = {...}; - this.c342.props = {...}; - this.c723 = function(....){ - - } - // replace - d.replace(/var_LMBEGINCACHE;[\s\S]*var_LMBEGINCACHE;/,"code"); - _async(_n,_c,_a,_w,_f,this, - _async(_n,_c,_a,_w,apf.lm_exec.c342,this, - LIVEMARKUP END CACHE*/ - var LMENDCACHE; - -})(); - - - - - - - - -/** - * An object that represents a URI, broken down to its parts, according to [RFC3986](http://tools.ietf.org/html/rfc3986). - * - * All parts are publicly accessible after parsing, like 'url.port' or 'url.host'. - * - * #### Example - * - * ```javascript - * var url = new apf.url('http://usr:pwd@www.test.com:81/dir/dir.2/index.htm?q1=0&&test1&test2=value#top'); - * alert(url.port); //will show '81' - * alert(url.host); //will show 'www.test.com' - * alert(url.isSameLocation()) // will show 'true' when the browser is surfing on the www.test.com domain - * ``` - * - * @class apf.url - * @parser - * @default_private - * - * @author Mike de Boer - * @version %I%, %G% - * @since 1.0 - */ -apf.url = function(str) { - var base; - var location = (window.location && window.location.toString()) || ""; - if (str.indexOf(":") == -1 && (base = location).indexOf(":") != -1) { - base = new apf.url(base); - str = apf.getAbsolutePath(base.protocol + "://" + base.host - + (base.directory.charAt(0) == "/" ? "" : "/") - + (base.directory.charAt(base.directory.length - 1) == "/" - ? base.directory - : base.directory + '/'), str).replace(/\/\/\/\//, "///"); - } - var o = apf.url.options, - m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), - i = 14; - this.uri = str.toString(); //copy string - - while (i--) - this[o.key[i]] = m[i] || ""; - - this[o.q.name] = {}; - var _self = this; - this[o.key[12]].replace(o.q.parser, function($0, $1, $2) { - if ($1) - _self[o.q.name][$1] = $2; - }); - - /** - * Checks if the [same origin policy](http://developer.mozilla.org/index.php?title=En/Same_origin_policy_for_JavaScript) is in effect for this URI. - * - * @returns {Boolean} `true` if it's the same. - */ - this.isSameLocation = function(){ - // filter out anchors - if (this.uri.length && this.uri.charAt(0) == "#") - return false; - // totally relative -- ../../someFile.html - if (!this.protocol && !this.port && !this.host) - return true; - - // scheme relative with port specified -- foo.com:8080 - if (!this.protocol && this.host && this.port - && window.location.hostname == this.host - && window.location.port == this.port) { - return true; - } - // scheme relative with no-port specified -- foo.com - if (!this.protocol && this.host && !this.port - && window.location.hostname == this.host - && window.location.port == 80) { - return true; - } - return window.location.protocol == (this.protocol + ":") - && window.location.hostname == this.host - && (window.location.port == this.port || !window.location.port && !this.port); - } -}; - -apf.url.options = { - strictMode: false, - key: ["source", "protocol", "authority", "userInfo", "user", "password", - "host", "port", "relative", "path", "directory", "file", "query", - "anchor"], - q: { - name: "queryKey", - parser: /(?:^|&)([^&=]*)=?([^&]*)/g - }, - parser: { - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ - } -}; - - - - - - - /** * @private */ @@ -22810,377 +18693,7 @@ apf.CodeCompilation = function(code) { }; }; - - - - - - - - -/** - * An element containing all the binding rules for the data - * bound elements referencing this element. - * - * #### Example - * - * ```xml - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - * @see apf.smartbinding - * @baseclass - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.8 - * - * @default_private - */ -apf.BindingRule = function(struct, tagName) { - this.$init(tagName || true, apf.NODE_HIDDEN, struct); -}; - -(function(){ - this.$bindingRule = true; - - this.compile = function(prop) { - return (this["c" + prop] = apf.lm.compile(this[prop], { - xpathmode: 3, - injectself: true - })); - }; - - this.$compile = function(prop, options) { - return (this["c" + prop + "2"] = apf.lm.compile(this[prop], options)); - }; - - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - value: 1, - match: 1 - }, this.$attrExcludePropBind); - - this.$booleanProperties["hasaml"] = true; - - this.$propHandlers["value"] = - this.$propHandlers["match"] = function(value, prop) { - delete this["c" + prop]; - - if (this.$amlLoaded) { - //Find parent that this rule works on - var node = this; - while (node && node.$bindingRule) - node = node.parentNode; - - if (!node) return; - - //Reload parent to propagate change - apf.queue.add("reload" + node.$uniqueId, function(){ - node.reload(); - }); - - //Recompile ruleset - if (node.$bindings.$isCompiled) - node.$bindings.$compiled = node.$bindings.compile( - this.localName != "each" && this.localName); - } - }; - - // *** DOM Handlers *** // - - /*this.addEventListener("DOMAttrModified", function(e) { - - });*/ - - this.addEventListener("DOMNodeInserted", function(e) { - //Find parent that this rule works on - var node = this; - while (node.$bindingRule) - node = node.parentNode; - - //Reload parent to propagate change - //@todo trigger should be maintained on node itself to prevent dual reload - if ("expanded|collapsed".indexOf(this.localName) == -1) - apf.queue.add("reload" + node.$uniqueId, function(){ - node.reload(); - }); - - //If this node is added, add to set - if (e.currentTarget == this) { - (node.$bindings[this.localName] - || (node.$bindings[this.localName] = [])).pushUnique(this); - } - //@todo apf3.0 test if proc instr and cdata needs to be serialized - //Else just update the binding value - else if (!this.attributes.getNamedItem("value")) - this.value = apf.serializeChildren(this); - //Or do nothing - else return; - - //Recompile ruleset - if (node.$bindings.$isCompiled) - node.$bindings.$compiled = node.$bindings.compile( - this.localName != "each" && this.localName); - }); - - this.addEventListener("DOMNodeRemoved", function(e) { - if (this.$amlDestroyed) - return; - - //Find parent that this rule works on - var first, node = this; - while (node && node.$bindingRule) - node = node.parentNode; - - if (!node) - return; - - //If this node is removed, remove to set - if (e.currentTarget == this) { - if (node.$bindings && node.$bindings[this.localName]) - node.$bindings[this.localName].remove(this); - else - return; - } - //@todo apf3.0 test if proc instr and cdata needs to be serialized - //Else just update the binding value - else if (!this.attributes.getNamedItem("value") && (first = this.firstChild)) { - if (first.nodeType == this.NODE_PROCESSING_INSTRUCTION) { - if (first.target == "lm") - this.value = "{" + first.nodeValue + "}"; - else - this.value = first.nodeValue; - } - else - this.value = apf.serializeChildren(this).trim(); - } - //Or do nothing - else return; - - //Reload parent to propagate change - if ("expanded|collapsed".indexOf(this.localName) == -1) - apf.queue.add("reload" + node.$uniqueId, function(){ - if (!node.$amlDestroyed) - node.reload(); - }); - - //Recompile ruleset - if (node.$bindings.$isCompiled) - node.$bindings.$compiled = node.$bindings.compile( - this.localName != "each" && this.localName); - }); - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - - - var first; - if (!this.value && this.localName != "each" && (first = this.$aml - && this.$aml.firstChild || this.firstChild)) { - if (first.nodeType == this.NODE_PROCESSING_INSTRUCTION) { - if (first.target == "lm") - this.value = "{" + first.nodeValue + "}"; - else - this.value = first.nodeValue; - } - else - this.value = apf.serializeChildren(this.$aml).trim(); - } - - //Find the parent this rule works on - var pNode = this.parentNode; - while (pNode.$bindingRule) - pNode = pNode.parentNode; - - //Add the rule to the set - var bindings = pNode.$bindings || (pNode.$bindings = new apf.ruleList()); - (bindings[this.localName] || (bindings[this.localName] = [])).push(this); - - //Compile if necessary - if (pNode.localName != "bindings" && (this.localName != "each" || !this.childNodes.length)) { - var ns = this; - while ((ns = ns.nextSibling) && ns.nodeType != 1); - - if (!ns || !ns.$bindingRule) { - pNode.$cbindings = pNode.$bindings.compile( - pNode.$bindings.$isCompiled ? this.localName : null); - - pNode.dispatchEvent("bindingsload", { - bindings: pNode.$bindings, - compiled: pNode.$cbindings - }); - pNode.$checkLoadQueue(); - } - } - }); -}).call(apf.BindingRule.prototype = new apf.AmlElement()); - -apf.aml.setElement("icon", apf.BindingRule); -apf.aml.setElement("image", apf.BindingRule); -apf.aml.setElement("caption", apf.BindingRule); -apf.aml.setElement("tooltip", apf.BindingRule); -apf.aml.setElement("css", apf.BindingRule); -apf.aml.setElement("selectable", apf.BindingRule); -apf.aml.setElement("value", apf.BindingRule); -apf.aml.setElement("src", apf.BindingRule); -apf.aml.setElement("collapsed", apf.BindingRule); -apf.aml.setElement("expanded", apf.BindingRule); -apf.aml.setElement("empty", apf.BindingRule); - - - - - - - - -/** - * Define some action rules. - * - * @class apf.ActionRule - * @inherits apf.AmlElement - */ -// @todo Doc do all of these. /* - * @attribute {String} match - */ -/* - * @attribute {String} set - */ -/* - * @attribute {String} undo - */ -/* - * @attribute {String} lock - */ -// @todo Doc ALL of these -/* - * @define update - */ -/* - * @attribute {String} get - */ -/* - * @attribute {String} parent - */ -/* - * @define add - */ -/* - * @attribute {Boolean} get - */ -/* - * @attribute {Boolean} parent - */ -apf.ActionRule = function(struct, tagName) { - this.$init(tagName || true, apf.NODE_HIDDEN, struct); -}; - -(function(){ - this.$actionRule = true; - - this.compile = function(prop, options) { - return (this["c" + prop] = apf.lm.compile(this[prop], - options || {xpathmode: 2})); - } - - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - set: 1, - get: 1, - undo: 1, - lock: 1, - match: 1, - parent: 1 - }, this.$attrExcludePropBind); - - this.$propHandlers["set"] = - this.$propHandlers["get"] = - this.$propHandlers["parent"] = - this.$propHandlers["match"] = function(value, prop) { - delete this["c" + prop]; - } - - // *** DOM Handlers *** // - - this.addEventListener("DOMNodeInserted", function(e) { - if (e.currentTarget == this) { - var pNode = this.parentNode; - if (!pNode.$actions) - pNode.$actions = new apf.ruleList(); - - (pNode.$actions[this.localName] - || (pNode.$actions[this.localName] = [])).push(this); - } - else { - if (this.attributes.getNamedItem("value")) - return; - - //@todo apf3.0 test if proc instr and cdata needs to be serialized - this.value = apf.serializeChildren(this); - } - }); - - this.addEventListener("DOMNodeRemoved", function(e) { - if (this.$amlDestroyed) - return; - - if (e.currentTarget == this) { - this.parentNode.$actions[this.localName].remove(this); - } - else { - if (this.attributes.getNamedItem("value")) - return; - - //@todo apf3.0 test if proc instr and cdata needs to be serialized - this.value = apf.serializeChildren(this); - } - }); - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - if (!this.get) - this.get = apf.serializeChildren(this.$aml).trim(); - - var actions = this.parentNode.$actions - || (this.parentNode.$actions = new apf.ruleList()); - - (actions[this.localName] || (actions[this.localName] = [])).push(this); - }); -}).call(apf.ActionRule.prototype = new apf.AmlElement()); - -apf.aml.setElement("rename", apf.ActionRule); -apf.aml.setElement("remove", apf.ActionRule); -apf.aml.setElement("add", apf.ActionRule); -apf.aml.setElement("update", apf.ActionRule); -apf.aml.setElement("copy", apf.ActionRule); -apf.aml.setElement("move", apf.ActionRule); -apf.aml.setElement("check", apf.ActionRule); -apf.aml.setElement("change", apf.ActionRule); - - - - - - - - -/** * @todo description * * @author Ruben Daniels (ruben AT ajax DOT org) @@ -23214,209 +18727,6 @@ apf.aml.setElement("application", apf.application); - -/** - * This element specifies the settings of the APF application. - * - * @class apf.appsettings - * @define appsettings - * @logic - * @inherits apf.AmlElement - * @allowchild auth, authentication, offline, printer, defaults - * - */ -// @todo describe defaults -/** - * @attribute {Boolean} debug Sets or gets whether the debug screen is shown at startup. - * - */ -/** - * @attribute {String} name Sets or gets the name of the application; used by many different services to uniquely identify the application. - */ -/** - * @attribute {Boolean} disable-right-click Sets or gets whether a user can get the browser's contextmenu when the right mouse button is clicked. - * @see apf.contextmenu - */ -/** - * @attribute {Boolean} allow-select Sets or gets whether general text in the application can be selected. - */ -/** - * @attribute {Boolean} allow-blur Sets or gets whether its possible to blur an element while not giving the focus to another element. Defaults to `true`. - */ -/** - * @attribute {Boolean} auto-disable-actions Sets or gets whether smartbinding actions are by default disabled. - * @see term.action - */ -/** - * @attribute {Boolean} auto-disable Sets or gets whether elements that don't have content loaded are automatically disabled. - */ -/** - * @attribute {Boolean} disable-f5 Sets or gets whether the F5 key for refreshing is disabled. - */ -/** - * @attribute {Boolean} disable-space Sets or gets whether the space button default behavior of scrolling the page is disabled. - */ -/** - * @attribute {Boolean} disable-backspace Sets or gets whether the backspace button default behavior of going to the previous history state is disabled. - */ -/** - * @attribute {String} default-page Sets or gets the name of the default page if none is specified using the `#`. Defaults to `"home"`. - * @see apf.history - */ -/** - * @attribute {Boolean} undokeys Sets or gets whether the undo and redo keyboard bindings are enabled. - * @see apf.actiontracker - */ -/** - * @attribute {String | Boolean} outline Sets or gets whether an outline of an element is shown while dragging or resizing. - * @see apf.Interactive - */ -/** - * @attribute {String | Boolean} drag-outline Sets or gets whether an outline of an element is shown while dragging. - * @see apf.Interactive - */ -/** - * @attribute {String | Boolean} resize-outline Sets or gets whether an outline of an element is shown while resizing. - * @see apf.Interactive - */ -/** - * @attribute {String} baseurl Sets or gets the basepath for any relative url used throughout your application. This included teleport definitions and {@link term.datainstruction data instructions}. - * - */ -/** - * @attribute {String} loading-message Sets or gets the global value for the loading message of elements during a loading state. - * @see apf.DataBinding.loading-message - */ -/** - * @attribute {String} offline-message Sets or gets the global value for the offline message of elements not able to display content while offline. - * @see apf.DataBinding.offline-message - */ -/** - * @attribute {String} empty-message Sets or gets the global value for the empty message of elements containing no contents. - * @see apf.DataBinding.empty-message - */ -/** - * @attribute {String} model Sets or gets the default model for this application. - * @see apf.model - */ -/** - * @attribute {String} realtime Sets or gets the global value whether bound values are updated realtime. When set to `false`, elements do not update until they lose focus. - * - */ -/** - * @attribute {String} skinset Sets or gets the skin set used by the application. - * @see apf.Presentation.skinset - */ -/** - * @attribute {String} storage Sets or gets the storage provider to be used for key/value storage. - * - */ -/** - * @attribute {String} offline Sets or gets the storage provider to be used for offline support. - * - */ -/** - * @attribute {String} login Sets or gets the {@link term.datainstruction data instruction} which logs a user into the application. - * - */ -/** - * @attribute {String} logout Sets or gets the {@link term.datainstruction data instruction} which logs a user out of the application. - * - */ -/** - * @attribute {String} iepngfix Sets or gets whether the fix for PNG images with transparency should be applied. Default is `false`. - */ -/** - * @attribute {String} iepngfix-elements Sets or gets a comma-seperated list of CSS identifiers (classes) to which the transparent-PNG fix will be applied. - */ -/** - * @attribute {Boolean} iphone-fullscreen Sets or gets whether the application should cover the entire screen of the iPhone. Default is ztruez. - */ -/** - * @attribute {String} iphone-statusbar Sets or gets the style of the statusbar of the iPhone webbrowser. Posssible values: `'default'`, `'black-translucent'` or `'black'`. - */ -/** - * @attribute {String} iphone-icon Sets or gets path pointing to the icon that should be used when this application is put on the iPhone Dashboard. - */ -/** - * @attribute {Boolean} iphone-icon-is-glossy Sets or gets whether the icon specified with 'iphone-icon' already is glossy or if the iPhone OS should apply that effect. Default is `false`. - */ -/** - * @attribute {Boolean} iphone-fixed-viewport Sets or gets whether the viewport of the application is fixed and whether the zoom should be enabled. Default is `true`. - */ -apf.appsettings = function(struct, tagName) { - this.$init(tagName || "appsettings", apf.NODE_HIDDEN, struct); -}; - -(function(){ - this.$parsePrio = "001"; - - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = { - language: 1, - login: 1, - logout: 1 - }; - - this.$supportedProperties = ["debug", "name", "baseurl", "resource-path", - "disable-right-click", "allow-select", "allow-blur", - "auto-disable-actions", "auto-disable", "disable-f5", - "disable-space", "disable-backspace", "undokeys", - "initdelay", "default-page", "query-append", "outline", "drag-outline", - "resize-outline", "resize-outline", "iepngfix", "iepngfix-elements", - "iphone-fullscreen", "iphone-statusbar", "iphone-icon", - "iphone-icon-is-glossy", "iphone-fixed-viewport", "skinset", - "language", "storage", "offline", "login"]; - this.$booleanProperties = { - - "debug":1, - "disable-right-click":1, - "allow-select":1, - "allow-blur":1, - "auto-disable-actions":1, - "auto-disable":1, - "disable-f5":1, - "disable-space":1, - "disable-backspace":1, - "undokeys":1, - "initdelay":1, - "outline":1, - "iepngfix":1, - "iphone-fullscreen":1, - "iphone-icon-is-glossy":1, - "iphone-fixed-viewport":1 - }; - - var $setProperty = this.setProperty; - this.setProperty = function(prop, value, forceOnMe, setAttr, inherited) { - if (inherited != 2) - $setProperty.apply(this, arguments); - } - - this.$handlePropSet = function(prop, value, force) { - if (this.$booleanProperties[prop]) - value = apf.isTrue(value); - - this[prop] = value; - - apf.config.setProperty(prop, value); - }; - - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - - }); -}).call(apf.appsettings.prototype = new apf.AmlElement()); - -apf.aml.setElement("appsettings", apf.appsettings); - - - - - - - - - /** * This element displays a skinnable rectangle which can contain other * AML elements. Often, it's also used in place of a regular HTML `
`. @@ -23554,214 +18864,6 @@ apf.aml.setElement("section", apf.section); -/** - * @todo description - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.4 - */ - - - -apf.AmlConfig = function(){ - this.$init("config", apf.NODE_VISIBLE); -}; - -(function(){ - this.focussable = false; - this.$canLeechSkin = true; - - this.$draw = function(){ - //Build Main Skin - this.$ext = this.$int = this.$getExternal(this.$isLeechingSkin - ? this.localName - : "main"); - }; - -}).call(apf.AmlConfig.prototype = new apf.Presentation()); - -apf.aml.setElement("config", apf.AmlConfig); - - - - - - - - -/** - * Element displaying the rendered contents of an URL. - * - * @constructor - * - * @define browser - * - * @inheritsElsewhere apf.XForms - * @inherits apf.StandardBinding - * @inherits apf.DataAction - * - * @event load - * @event error - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.4 - * - * @binding value Determines the way the value for the element is retrieved - * from the bound data. - * Example (BROKEN): - * Sets the url based on data loaded into this component. - * - * - * - * - * - * - * Example: - * A shorter way to write this is: - * - * - * - * - * - * - */ -apf.browser = function(struct, tagName) { - this.$init(tagName || "browser", apf.NODE_VISIBLE, struct); -}; -(function(){ - this.implement( - - - apf.DataAction - - - ,apf.StandardBinding - - ); - - /** - * @attribute {String} src the url to be displayed in this element - * @attribute {String} value alias for the 'url' attribute - */ - this.$supportedProperties.push("value", "src"); - this.$propHandlers["src"] = - this.$propHandlers["value"] = function(value, force) { - try { - this.$browser.src = value || "about:blank"; - } - catch (e) { - this.$browser.src = "about:blank"; - } - }; - this.$propHandlers["border"] = apf.Presentation.prototype.$propHandlers["border"]; - - this.getValue = function() { - return this.value || this.src; - }; - - /** - * Retrieves the current url that is displayed. - */ - this.getURL = function(){ - return this.$browser.src; - }; - - /** - * Browses to the previous page - */ - this.back = function(){ - this.$browser.contentWindow.history.back(); - }; - - /** - * Browses to the next page - */ - this.forward = function(){ - this.$browser.contentWindow.history.forward(); - }; - - /** - * Reload the current page - */ - this.reload = function(){ - this.$browser.src = this.$browser.src; - }; - - /** - * Print the currently displayed page - */ - this.print = function(){ - this.$browser.contentWindow.print(); - }; - - /** - * Execute a string of javascript on the page. This is subject to browser - * security and will most likely only work when the browsed page is loaded - * from the same domain. - * @param {String} str javascript string to be executed. - * @param {Boolean} noError whether the execution can throw an exception. Defaults to false. - */ - this.runCode = function(str, noError) { - if (noError) { - try { - this.$browser.contentWindow.eval(str); - } catch (e) {} - } - else { - this.$browser.contentWindow.eval(str); - } - }; - - this.$draw = function(parentNode) { - if (!parentNode) - parentNode = this.$pHtmlNode; - - //Build Main Skin - this.$ext = parentNode.appendChild(document.createElement("iframe")); - this.$ext.setAttribute("frameborder","0"); - //this.$ext.style.width = "100px"; - //this.$ext.style.height = "100px"; - this.$browser = this.$ext; - this.$ext.style.border = "1px solid #999"; - this.$ext.style.background = "white"; - this.$ext.className = "apfbrowser" - - if (this.getAttribute("style")) - this.$ext.setAttribute("style", this.getAttribute("style")); - - var _self = this; - apf.addListener(this.$browser, "load", function(){ - var loc = this.contentWindow.location.href; - _self.dispatchEvent("load", {href: loc}); - if (loc) - _self.setProperty("src", loc); - }); - - apf.addListener(this.$browser, "error", function(){ - _self.dispatchEvent("error"); - if (this.contentWindow.location.href) - _self.setProperty("src", this.contentWindow.location.href); - }); - - //this.$browser = this.$ext.contentWindow.document.body; - this.$ext.host = this; - //this.$browser.host = this; - }; -}).call(apf.browser.prototype = new apf.GuiElement()); - -apf.aml.setElement("browser", apf.browser); - - - @@ -24812,11 +19914,6 @@ apf.contextmenu = function(){ (function(){ this.$amlNodes = []; - //1 = force no bind rule, 2 = force bind rule - this.$attrExcludePropBind = apf.extend({ - "match" : 1 - }, this.$attrExcludePropBind); - this.register = function(amlParent) { if (!amlParent.contextmenus) amlParent.contextmenus = []; @@ -25288,9 +20385,6 @@ apf.preview.prototype = apf.img.prototype; apf.aml.setElement("img", apf.img); apf.aml.setElement("preview", apf.preview); -apf.aml.setElement("name", apf.BindingRule); -apf.aml.setElement("image", apf.BindingRule); - @@ -26984,11 +22078,6 @@ apf.radiobutton = function(struct, tagName) { this.$focussable = apf.KEYBOARD; // This object can get the focus - //1 = force no bind rule, 2 = force bind rule - /*this.$attrExcludePropBind = apf.extend({ - selected: 1 - }, this.$attrExcludePropBind);*/ - // *** Properties and Attributes *** // this.$booleanProperties["selected"] = true; @@ -27563,7 +22652,6 @@ apf.aml.setElement("skin", apf.skin); this.$parseContext = domParser.$parseContext || [this.ownerDocument.documentElement]); } - //var basePath = apf.hostPath;//only for recursion: apf.getDirname(xmlNode.getAttribute("filename")) || loadSkinFile.call(this, path); } @@ -28568,484 +23656,6 @@ apf.StateServer = { -/** - * Any child element of this element is placed in a table. The size of the - * columns and rows of the table can be set by attributes. Child elements can - * span multiple columns. Using `'*' `as a size indicator will use the remaining - * size for that column or row, when the table's size is set. - * - * #### Example - * - * This example shows a window with a table and two buttons that change the - * orientation of the table runtime. The textarea and its label have a span set - * to `'*'`. This means they will span the entire width of all columns, no matter - * how many columns there are. - * - * ```xml, demo - * - * - * - * - * Name - * - * Address - * - * Country - * - * America - * Armenia - * The Netherlands - * - * - * Message - * - * - * - * - * - * - * - * - * - * ``` - * - * @class apf.table - * @define table - * @allowchild {elements}, {anyaml} - * - * @container - * @inherits apf.GuiElement - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 1.0 - */ -apf.table = function(struct, tagName) { - this.$init(tagName || "table", apf.NODE_VISIBLE, struct); -}; - -(function(){ - // *** Properties and Attributes *** // - - this.$focussable = false; - this.$useLateDom = true; - this.$layout = true; - - this.columns = null;//"150,200"; - this.padding = 2; - this.$edge = [5, 5, 5, 5]; - this.cellheight = 19; - - /** - * @attribute {Number | String} columns Sets or gets a comma seperated list of column sizes. - * A column size can be specified in a number (size in pixels), or using a number and a `"%"` sign to indicate a percentage. - * A `'*'` indicates the column spans the rest space. There can be only one `'*'` in the column string. - * - * #### Example - * - * ```xml - * - * ``` - * - */ - /** - * @attribute {String} [padding=2] Sets or gets the space between each element. - */ - /** - * @attribute {String} [edge="5 5 5 5"] Sets or gets the space between the container and the elements, space seperated in pixels for each side. Similar to CSS in the sequence of `top right bottom left`. - * - * #### Example - * - * ```xml - * - * ```` - */ - this.$supportedProperties.push("columns", "padding", "edge", - "cellheight", "span"); - - this.$propHandlers["columns"] = function(value) { - if (!value.match(/^((?:\d+\%?|\*)\s*(?:,\s*|\s*$))+$/)) { - - return; - } - - var col, colsize = this.$columns = value.splitSafe(","); - - var total = 0, cols = this.$table.getElementsByTagName("col"); - if (cols.length) { - for (var sz, i = 0, l = Math.min(cols.length, colsize.length); i < l; i++) { - cols[i].style.width = (sz = colsize[i]).indexOf("%") > -1 ? sz : sz + "px"; - total += parseInt(sz); - } - } - - var start = cols.length - colsize.length; - if (start > 0) { - for (var i = cols.length - start; i < cols.length; i++) { - cols[i].parentNode.removeChild(cols[i]); - } - } - else if (start < 0) { - for (var i = colsize.length + start; i < colsize.length; i++) { - col = this.$table.appendChild(document.createElement("col")); - col.style.width = (sz = colsize[i]).indexOf("%") > -1 ? sz : sz + "px"; - col.setAttribute("valign", "top"); - total += parseInt(sz); - } - } - - this.$table.style.width = String(value).indexOf("%") > -1 - ? "auto" - : (total + ((colsize.length - 1) * this.padding) - + this.$edge[0] + this.$edge[2]) + "px"; - - var cells = this.$tbody.firstChild.getElementsByTagName("td"); - for (var i = cells.length - 1; i >= 0; i--) - cells[i].parentNode.removeChild(cells[i]); - - for (var sz, c, i = 0; i < colsize.length; i++) { - c = this.$tbody.firstChild.appendChild(document.createElement("td")); - c.style.width = (sz = colsize[i]).indexOf("%") > -1 ? sz : sz + "px"; - - /*if (colsize[i].indexOf("%") > -1) - c.appendChild(document.createElement("div")).style.width = "50px";*/ - } - - if (start && this.$amlLoaded) - visibleHandler({sync: true, parentNode: this}); - - this.$resize(); - } - - this.$propHandlers["padding"] = function(value) { - if (!this.$columns) return; - var cells = this.$table.getElementsByTagName("td"); - var lastCol, lastRow, cell, lRow = this.$tbody.lastChild; - for (var i = this.$columns.length, l = cells.length; i < l; i++) { - lastCol = (cell = cells[i]).parentNode.lastChild == cell; - lastRow = cell.parentNode == lRow; - cell.style.padding = "0px " + (lastCol ? 0 : value) + "px " + (lastRow ? 0 : value) + "px 0px"; - } - this.$resize(); - } - - this.$propHandlers["edge"] = function(value) { - this.$table.style.padding = (this.$edge = apf.getBox(value)).join("px ") + "px"; - this.$resize(); - } - - function visibleHandler(e) { - var table = e.parentNode || this.parentNode; - if (e.sync || e.value && !this.$altExt || !e.value && this.$altExt) { - var nodes = table.childNodes; - - var cells = apf.getArrayFromNodelist(table.$tbody.getElementsByTagName("td")); - var rows = table.$tbody.getElementsByTagName("tr"); - var empty = [], row = 1, cs, rs, collen = table.$columns.length; - var z = table.$columns.length, lastCol; - for (var node, td, last, l = nodes.length, i = 0; i < l; i++) { - if ((node = nodes[i]).visible === false) - continue; - - td = node.$altExt = last = cells[z++]; - if (!td) break; - //td = node.$altExt = last = document.createElement("td"); - - if (!rows[row]) - table.$tbody.appendChild(document.createElement("tr")); - - rows[row].appendChild(td); - td.appendChild(node.$ext); - td.setAttribute("colspan", cs = Math.min(collen - (empty[0] || 0), parseInt(node.colspan || node.span || 1))); - td.setAttribute("rowspan", rs = parseInt(node.rowspan || 1)); - - //@todo this is wrong it should be cs * rs - if (!empty[0]) - empty[0] = 0; - empty[0] += cs; - - if (rs > 1) { - for (var k = 1; k < rs; k++) { - if (!empty[k]) - empty[k] = 0; - empty[k] += cs; - } - } - - if (empty[0] >= collen) { - lastCol = true; - empty.shift(); - row++; - } - else lastCol = false; - - td.style.padding = "0px " + (lastCol ? 0 : table.padding) - + "px " + (i == l - 1 ? 0 : table.padding) + "px 0px"; - } - - //Fix padding of last row - var lastCells = rows[rows.length - 1].getElementsByTagName("td"); - for (i = 0, il = lastCells.length; i < il; i++) { - lastCells[i].style.padding = "0 " - + (i == il - 1 ? 0 : table.padding) + "px 0 0" - } - - for (;z < cells.length; z++) - cells[z].parentNode.removeChild(cells[z]); - - if (e.sync) return; - - if (e.value) - table.$addTd(nodes[l - 1]); //what if it's not visible - else { - //last.parentNode.removeChild(last); - this.$altExt = null; - } - } - } - - this.$addTd = function(amlNode) { - var cells = this.$table.getElementsByTagName("td"); - var total = 0, collen = this.$columns.length; - for (var cell, i = 0; i < cells.length; i++) { - total += Math.min(collen, - (parseInt((cell = cells[i]).getAttribute("colspan") || 1) - * parseInt(cell.getAttribute("rowspan") || 1))); - } - - if (total % collen == 0) { //New Row - var row = this.$tbody.appendChild(document.createElement("tr")); - } - else - row = cells[cells.length - 1].parentNode; - - //Add a new cell in the last row - var cel = row.appendChild(document.createElement("td")); - cel.style.position = "relative"; - - if (amlNode.colspan || amlNode.span) - cel.setAttribute("colspan", amlNode.colspan || amlNode.span); - if (amlNode.rowspan) - cel.setAttribute("rowspan", amlNode.rowspan); - - cel.appendChild(amlNode.$ext); - - amlNode.$altExt = cel; - } - - var propHandlers = { - "width" : function(value) { - this.$ext.style.width = "";/*value - ? Math.max(0, value - apf.getWidthDiff(this.$ext)) + "px" - : "";*/ - }, - - "height" : function(value) { - this.$ext.style.height = value - ? Math.max(0, value - apf.getHeightDiff(this.$ext)) + "px" - : ""; - this.parentNode.$resize(); - }, - - "margin" : function(value) { - this.$ext.style.margin = apf.getBox(value).join("px ") + "px"; - this.parentNode.$resize(); - }, - - "colspan" : function(value) { - if (!value) - this.$altExt.removeAttribute("colspan"); - else - this.$altExt.setAttribute("colspan", value); - - visibleHandler.call(this, {sync: true}); - this.parentNode.$resize(); - }, - - "rowspan" : function(value) { - if (!value) - this.$altExt.removeAttribute("rowspan"); - else - this.$altExt.setAttribute("rowspan", value); - - visibleHandler.call(this, {sync: true}); - this.parentNode.$resize(); - }, - - "valign" : function(value) { - this.$altExt.valign = value; - }, - - "align" : function(value) { - if ("left|right".indexOf(value) == -1) - return; - - this.$altExt.align = value; - } - } - propHandlers.span = propHandlers.colspan; - - //@todo move this to enableTable, disableTable - this.register = function(amlNode) { - if (amlNode.$altExt) //@todo hack, need to rearch layouting - return; - - amlNode.$propHandlers["left"] = - amlNode.$propHandlers["top"] = - amlNode.$propHandlers["right"] = - amlNode.$propHandlers["bottom"] = apf.K; - - for (var prop in propHandlers) { - amlNode.$propHandlers[prop] = propHandlers[prop]; - } - - amlNode.addEventListener("prop.visible", visibleHandler); - - this.$addTd(amlNode); - - this.$noResize = true; - - if (amlNode.margin) - propHandlers.margin.call(amlNode, amlNode.margin); - - //Why was this commented out? - if (amlNode.$ext.tagName == "INPUT") { - //amlNode.$ext.style.width = "100%"; - } - else - amlNode.$ext.style.width = "auto"; - - if (this.lastChild == amlNode) - this.$propHandlers["padding"].call(this, this.padding); - - delete this.$noResize; - } - - this.unregister = function(amlNode) { - amlNode.$propHandlers["left"] = - amlNode.$propHandlers["top"] = - amlNode.$propHandlers["right"] = - amlNode.$propHandlers["bottom"] = null; - - for (var prop in propHandlers) { - delete amlNode.$propHandlers[prop]; - } - - amlNode.removeEventListener("prop.visible", visibleHandler); - visibleHandler.call(amlNode, {value: false}); //maybe parent is already reset here? - - if (amlNode.margin) - amlNode.$ext.style.margin = ""; - - if (amlNode.width) - amlNode.$ext.style.width = ""; - } - /* - this.addEventListener("DOMNodeInsertedIntoDocument", function(e) { - this.register(this.parentNode); - }); - */ - - // *** DOM Hooks *** // - - this.addEventListener("DOMNodeRemoved", function(e) { - if (e.$doOnlyAdmin || e.currentTarget == this) - return; - - if (e.relatedNode == this) { - this.unregister(e.currentTarget); - //e.currentTarget.$setLayout(); - } - }); - - this.addEventListener("DOMNodeInserted", function(e) { - if (e.currentTarget == this || e.currentTarget.nodeType != 1) - return; - - if (e.relatedNode == this) { - if (e.$isMoveWithinParent) { - visibleHandler.call(e.currentTarget, {sync: true}); - } - else { - e.currentTarget.$setLayout("table"); - if (e.currentTarget.nextSibling) - visibleHandler.call(e.currentTarget, {sync: true}); - } - } - }); - - this.$draw = function(){ - this.$ext = apf.insertHtmlNode(null, this.$pHtmlNode, null, - "
"); - this.$table = this.$ext.firstChild; - this.$tbody = this.$table.firstChild; - this.$ext.className = "table " + (this.getAttribute("class") || ""); - //this.$ext.style.overflow = "hidden"; - this.$int = this.$ext; - this.$ext.host = this; - - if (this.getAttribute("class")) - apf.setStyleClass(this.$ext, this.getAttribute("class")); - - this.addEventListener("resize", this.$resize); - this.$originalMin = [this.minwidth || 0, this.minheight || 0]; - }; - - //@todo implement percentage by using fixed and add functionality here - this.$resize = function(){ - if (!this.$amlLoaded || this.$noResize) - return; - - if (this.$table.offsetWidth >= this.$ext.offsetWidth) - this.$ext.style.minWidth = (this.minwidth = Math.max(0, this.$table.offsetWidth - - apf.getWidthDiff(this.$ext))) + "px"; - else { - this.$ext.style.minWidth = ""; - this.minwidth = this.$originalMin[0]; - } - - if (this.$table.offsetHeight >= this.$ext.offsetHeight) - this.$ext.style.minHeight = (this.minheight = Math.max(0, this.$table.offsetHeight - - apf.getHeightDiff(this.$ext))) + "px"; - else { - this.$ext.style.minHeight = ""; - this.minheight = this.$originalMin[1]; - } - } - - this.$loadAml = function(x) { - this.$amlLoaded = false; //@todo hack - - if (!this.$columns) - this.$propHandlers.columns.call(this, this.columns = "150, 200"); - this.$amlLoaded = true; //@todo hack - }; -}).call(apf.table.prototype = new apf.GuiElement()); - -apf.aml.setElement("table", apf.table); - - - - - - - - /** * This element displays a rectangle containing arbitrary (X)HTML. @@ -29233,8 +23843,7 @@ apf.text = function(struct, tagName) { }; this.$eachHandler = function(value) { - this.$attrExcludePropBind = apf.extend({}, this.$attrExcludePropBind); - this.$attrExcludePropBind.value = value ? 2 : 0; + debugger }; this.addEventListener("prop.each", this.$eachHandler); @@ -30439,9 +25048,6 @@ apf.aml.setElement("toolbar", apf.toolbar); -apf.aml.setElement("checked", apf.BindingRule); - - @@ -30870,104 +25476,6 @@ apf.textbox.masking = function(){ - -/** - * Live Markup processor for a processing instruction - * - * @author Ruben Daniels (ruben AT ajax DOT org) - * @version %I%, %G% - * @since 0.9 - */ - -apf.LiveMarkupPi = function(){ - //this.$data; - this.$init(); -}; - -/* - @todo optimize the pi, possible with this code: - var div, doc = this.ownerDocument, domParser = doc.$domParser, - docFrag = doc.createDocumentFragment(), - sStart = "", - sEnd = ""; - - docFrag.$int = div; - - domParser.parseFromXml(apf.getXml(sStart + this.$bindingQueue[i] + sEnd), { //@todo might be optimized by doing it only once - doc: doc, - amlNode: docFrag, - beforeNode: null, - include: true - }); -*/ -(function(){ - this.mainBind = "data"; - - this.implement(apf.StandardBinding); - - this.getDocument = function(){ - return this.$data && this.$data.ownerDocument; - }; - - this.clear = function(msg) { - if (msg == "loading" && apf.getInheritedAttribute(this, "loading-message")) { - this.$propHandlers["calcdata"].call(this, "Loading..."); - this.calcdata = ""; - } - }; - - this.$propHandlers["calcdata"] = function(data) { - if (this.$skipChange) //Used by liveedit.js - return; - - if (this.$data) { - - - var nodes = this.$data.childNodes; - for (var i = nodes.length - 1; i >= 0; i--) - nodes[i].destroy(true); - } - - //var dt = new Date().getTime(); - - //if (!this.xmlRoot) - //return this.$ext.innerHTML = "loading..."; - - if (typeof data == "string" && data.indexOf(" -1) { //@todo use the .hasAml attribute - this.$ext.innerHTML = "";//data; - - var doc = this.ownerDocument.$domParser.parseFromString("" + data + "", "text/xml", { - htmlNode: this.$ext, - host: this - //nodelay : true - }) - this.$data = doc.documentElement; - - //apf.queue.empty(); - - //alert(new Date().getTime() - dt); - } - else { - if (this.$data) { - var nodes = this.$data.childNodes; - for (var i = 0; i < nodes.length; i++) - nodes[i].destroy(true); - } - if (this.$ext) - this.$ext.innerHTML = data || ""; - } - }; -}).call(apf.LiveMarkupPi.prototype = new apf.AmlProcessingInstruction(true)); - -apf.aml.setProcessingInstruction("lm", apf.LiveMarkupPi); -apf.aml.setProcessingInstruction("lm-debug", apf.LiveMarkupPi); -apf.aml.setProcessingInstruction("livemarkup", apf.LiveMarkupPi); - - - - - require("./lib/menu/menu")(apf); require("./lib/flexbox")(apf); require("./lib/page")(apf); @@ -30978,16 +25486,6 @@ require("./lib/page")(apf); apf.start(); - - - - -/* - * Bootloader for Ajax.org Platform - * - * Include apf.js, then just go about it as you would with the - * packaged version. Adapt this file to include your preferred modules - */ register(null, {apf: apf}); } }); diff --git a/plugins/c9.ide.ui/ui.js b/plugins/c9.ide.ui/ui.js index dd0f8e75..397485ae 100644 --- a/plugins/c9.ide.ui/ui.js +++ b/plugins/c9.ide.ui/ui.js @@ -774,11 +774,6 @@ define(function(require, module, exports) { */ isFalse: apf.isFalse, - /** - * @ignore - */ - xmldb: apf.xmldb, - /** * @ignore */