rewrite dropdown.js

pull/125/merge
nightwing 2017-03-05 22:42:14 +04:00
rodzic 31fad9a5b4
commit a66be5a9e3
8 zmienionych plików z 72 dodań i 6578 usunięć

Wyświetl plik

@ -75,21 +75,19 @@ define(function(require, exports, module) {
settings.on("read", function() {
var lines = settings.getJson("state/gotoline") || [];
var xml = "";
for (var i = 0, l = lines.length; i < l; i += 2) {
xml += "<line nr='" + lines[i] + "' />";
}
model.load("<lines>" + xml + "</lines>");
lines = lines.map(function(i) {
return { value: i };
});
model.load(lines);
}, plugin);
settings.on("write", function() {
if (changed) {
var nodes = model.data.childNodes;
var lines = [];
for (var i = 0, l = Math.min(20, nodes.length); i < l; i++) {
lines.push(nodes[i].getAttribute("nr"));
}
var lines = (model.data || []).map(function(n) {
return n.value;
});
settings.setJson("state/gotoline", lines);
changed = false;
}
}, plugin);
}

Wyświetl plik

@ -12,8 +12,6 @@
<a:textbox id="input" focusselect="true" />
<a:list id="list"
flex = "1"
caption = "[@nr]"
each = "[line]"
autoselect = "false"
multiselect = "false"
empty-message = "empty" />

Wyświetl plik

@ -378,10 +378,10 @@ define(function(require, exports, module) {
}
ddSFSelection.childNodes[1].setAttribute("caption",
apf.escapeXML("Project (excludes .gitignore'd)"));
"Project (excludes .gitignore'd)");
ddSFSelection.childNodes[2].setAttribute("caption",
apf.escapeXML("Selection: " + (name || "/")));
"Selection: " + (name || "/"));
if (ddSFSelection.value == "selection") {
ddSFSelection.setAttribute("value", "");

Wyświetl plik

@ -200,10 +200,8 @@ define(function(require, exports, module) {
break;
case "dropdown":
var model = options.model || new ui.model();
var data = options.items && options.items.map(function(item) {
return "<item value='" + item.value + "'><![CDATA[" + item.caption + "]]></item>";
}).join("");
if (data) model.load("<items>" + data + "</items>");
var data = options.items;
if (data) model.load(data);
var dd;
childNodes = [
@ -224,9 +222,9 @@ define(function(require, exports, module) {
value: options.path
? settings.get(options.path)
: (options.defaultValue || ""),
each: options.each || "[item]",
caption: options.caption || "[text()]",
eachvalue: options.eachvalue || "[@value]",
each: options.each || "item",
caption: options.caption,
eachvalue: options.eachvalue || "value",
"empty-message": options["empty-message"]
})
];

Wyświetl plik

@ -1042,7 +1042,7 @@ apf.divider = function(struct, tagName) {
this.minwidth = 0;
this.minheight = 0;
this.implement(apf.ChildValue);
// this.implement(apf.ChildValue);
this.$childProperty = "caption";
//@todo apf3.0 fix this
@ -1143,7 +1143,7 @@ apf.item = function(struct, tagName) {
this.checked = false;
this.selected = false;
this.implement(apf.ChildValue);
// this.implement(apf.ChildValue);
// *** Properties and Attributes *** //
@ -1519,7 +1519,7 @@ apf.item = function(struct, tagName) {
this.parentNode.$hideTree = true;
//@todo This statement makes the menu loose focus.
if (!this.parentNode.sticky)
if (!this.parentNode.sticky && this.parentNode.localName != "dropdown")
this.parentNode.hide();//true not focus?/
this.parentNode.dispatchEvent("itemclick", {
@ -1665,108 +1665,6 @@ apf.item = function(struct, tagName) {
while (p.$canLeechSkin == "item")
p = p.parentNode;
if (p.hasFeature(apf.__MULTISELECT__)) {
var _self = this;
//@todo DOMNodeInserted should reset this
//@todo DOMNodeRemoved should reset this
if (!this.$hasSetSkinListener) {
var f;
this.parentNode.addEventListener("$skinchange", f = function() {
if (_self.$amlDestroyed) //@todo apf3.x
return;
if (_self.$ext.parentNode)
this.$deInitNode(_self, _self.$ext);
var oInt = p == _self.parentNode ? p.$container : _self.parentNode.$container;
var node = oInt.lastChild;//@todo this should be more generic
p.$add(_self, _self.getAttribute(apf.xmldb.xmlIdTag) + "|" + this.$uniqueId,
_self.parentNode, oInt != p.$container && oInt, null);
p.$fill();
if (p.$isTreeArch) {
_self.$container = p.$getLayoutNode("item", "container",
_self.$ext = node && node.nextSibling || oInt.firstChild);//@todo this should be more generic
}
else _self.$ext = node && node.nextSibling || oInt.firstChild;
var ns = _self;
while ((ns = ns.nextSibling) && ns.nodeType != 1);
if (!ns || ns.$canLeechSkin != "item")
p.dispatchEvent("afterload");
});
this.addEventListener("DOMNodeRemoved", function(e) {
if (e.currentTarget == this)
this.parentNode.removeEventListener("$skinchange", f);
});
this.$hasSetSkinListener = true;
}
if (!p.$itemInited) {
p.canrename = false; //@todo fix rename
p.$removeClearMessage(); //@todo this should be more generic
p.$itemInited = [p.getTraverseNodes, p.getFirstTraverseNode, p.getTraverseParent];
p.getTraverseNodes = function(xmlNode) {
return (xmlNode || p).getElementsByTagNameNS(apf.ns.apf, "item");
};
p.getFirstTraverseNode = function(xmlNode) {
return (xmlNode || p).getElementsByTagNameNS(apf.ns.apf, "item")[0];
};
p.getTraverseParent = function(xmlNode) {
return xmlNode && xmlNode.parentNode;
};
p.each = (this.prefix ? this.prefix + ":" : "") + "item";
//@todo this is all an ugly hack (copied to baselist.js line 868)
p.$preventDataLoad = true;//@todo apf3.0 add remove for this
p.$initingModel = true;
p.$setDynamicProperty("icon", "[@icon]");
p.$setDynamicProperty("image", "[@image]");
p.$setDynamicProperty("caption", "[label/text()|@caption|text()]");
p.$setDynamicProperty("eachvalue", "[value/text()|@value|text()]");
p.$canLoadDataAttr = false;
if (!p.xmlRoot)
p.xmlRoot = p;
}
this.$loadAml = function() {
//hack
if (!this.getAttribute("caption"))
this.setAttribute("caption", this.caption);
var oInt = p == this.parentNode ? p.$container : this.parentNode.$container;
var node = oInt.lastChild;//@todo this should be more generic
if (!p.documentId)
p.documentId = apf.xmldb.getXmlDocId(this);
p.$add(this, apf.xmldb.nodeConnect(p.documentId, this, null, p),
this.parentNode, oInt != p.$container && oInt, null);
p.$fill();
if (p.$isTreeArch) {
this.$container = p.$getLayoutNode("item", "container",
this.$ext = node && node.nextSibling || oInt.firstChild);//@todo this should be more generic
}
else this.$ext = node && node.nextSibling || oInt.firstChild;
var ns = this;
while ((ns = ns.nextSibling) && ns.nodeType != 1);
if (!ns || ns.$canLeechSkin != "item") {
p.dispatchEvent("afterload");
if (p.autoselect)
p.$selectDefault(this.parentNode);
}
};
return;
}
this.$ext = this.$getExternal(this.$isLeechingSkin
? "item" //this.type
: "main", null, function($ext) {

Wyświetl plik

@ -1275,11 +1275,6 @@ apf.splitter.templates = {
}
}
//e.returnValue = false;
//e.cancelBubble = true;
//apf.stopEvent(e);
apf.plane.show(this);
@ -1551,8 +1546,6 @@ apf.splitter.templates = {
update(e);
apf.stopEvent(e);
//e.returnValue = false;
//e.cancelBubble = true;
_self.dispatchEvent("dragmove");
};

Wyświetl plik

@ -6301,113 +6301,6 @@ if (apf.history)
/**
* Creates a model object based on a {@link term.datainstruction data instruction}.
*
* @param {String} instruction The {@link term.datainstruction data instruction} to be used to retrieve the data for the model
* @param {apf.AmlNode} amlNode The element the model is added to
*/
apf.setModel = function(instruction, amlNode) {
if (!instruction) return;
//Find existing model
var fParsed = instruction.indexOf("{") > -1 || instruction.indexOf("[") > -1
? apf.lm.compile(instruction, {
//precall : false,
alwayscb: true
})
: {
type: 2,
str: instruction
};
if (instruction == "@default" || fParsed.type == 2) {
var model = apf.nameserver.get("model", instruction);
if (model)
return model.register(amlNode);
else
if (instruction == "@default")
return;
//@todo apf3.0 check here if string is valid url (relative or absolute)
if (instruction.indexOf(".") == -1 && instruction.indexOf("/") == -1) {
return;
}
}
//Just an xpath doesnt work. We don't have context
//var l, x;
if (fParsed.type == 3) {//This won't work for complex xpaths
if (fParsed.models) { //check for # in xpaths[i] to determine if its calculated
if (fParsed.xpaths.length == 2 && fParsed.xpaths[0] != '#' && fParsed.xpaths [1] != '#') {
apf.nameserver.get("model", fParsed.xpaths[0]).register(amlNode, fParsed.xpaths[1]);
return;
}
}
}
if (amlNode.clear)
amlNode.clear("loading");
//Complex data fetch (possibly async) - data is loaded only once.
//Potential property binding has to take of the rest
apf.getData(instruction, {
parsed: fParsed,
xmlNode: amlNode && amlNode.xmlRoot,
callback: function(data, state, extra) {
//@todo apf3.0 call onerror on amlNode
if (state != apf.SUCCESS) {
throw new Error(apf.formatErrorString(0, null,
"Loading new data", "Could not load data into model. \
\nMessage: " + extra.message + "\
\nInstruction: '" + instruction + "'"));
}
if (!data)
return amlNode.clear && amlNode.clear();
if (typeof data == "string") {
if (data.charAt(0) == "<")
data = apf.getXml(data);
else {
//Assuming web service returned url
if (data.indexOf("http://") == 0)
return apf.setModel(data, amlNode);
else {
throw new Error("Invalid data from server");//@todo apf3.0 make proper apf error handling. apf.onerror
}
}
}
if (data.nodeFunc) { //Assuming a model was passed -- data.localName == "model" &&
data.register(amlNode);
return;
}
var model = apf.xmldb.findModel(data); //See if data is already loaded into a model
if (model)
model.register(amlNode, apf.xmlToXpath(data, model.data)); //@todo move function to xml library
else
new apf.model().register(amlNode).load(data);
}});
};
/*
* @version: 1.0 Alpha-1
* @author: Coolite Inc. http://www.coolite.com/
@ -12424,34 +12317,11 @@ apf.AmlText = function(isPrototype) {
var pHtmlNode;
if (!(pHtmlNode = this.parentNode.$int) || this.parentNode.hasFeature(apf.__CHILDVALUE__))
return;
debugger
this.$amlLoaded = true;
var nodeValue = this.nodeValue;
//@todo optimize for inside elements?
if (apf.config.liveText && !this.parentNode.hasFeature(apf.__CHILDVALUE__)
&& (nodeValue.indexOf("{") > -1 || nodeValue.indexOf("[") > -1)) {
//Convert to live markup pi
this.$supportedProperties = [];
this.$propHandlers = {};
this.$booleanProperties = {};
this.$inheritProperties = {};
this.$propHandlers["calcdata"] = apf.LiveMarkupPi.prototype.$propHandlers["calcdata"];
this.$setInheritedAttribute = apf.AmlElement.prototype.$setInheritedAttribute;
this.implement(apf.StandardBinding);
pHtmlNode.appendChild(this.$ext = document.createElement("span"));
this.$setDynamicProperty("calcdata", this.nodeValue);
return;
}
if (apf.hasTextNodeWhiteSpaceBug) {
var nodeValue = nodeValue.replace(/[\t\n\r ]+/g, " ");