Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First changes towards a better settings API

  • Loading branch information...
commit a1f16af1d34e251144aad335c00bbc20151b56dd 1 parent 5249210
@sergi sergi authored
View
59 client/ext/settings/settings.js
@@ -16,6 +16,8 @@ var template = require("text!ext/settings/template.xml");
var panels = require("ext/panels/panels");
var skin = require("text!ext/settings/skin.xml");
+var slice = Array.prototype.slice;
+
module.exports = ext.register("ext/settings/settings", {
name : "Preferences",
dev : "Ajax.org",
@@ -49,10 +51,11 @@ module.exports = ext.register("ext/settings/settings", {
},
saveSettingsPanel: function() {
- var pages = self.pgSettings ? pgSettings.getPages() : [],
- i = 0,
- l = pages.length,
- changed = false;
+ var pages = self.pgSettings ? pgSettings.getPages() : [];
+ var i = 0;
+ var l = pages.length;
+ var changed = false;
+
for (; i < l; ++i) {
if (!pages[i].$at) continue;
if (pages[i].$at.undolength > 0) {
@@ -60,10 +63,10 @@ module.exports = ext.register("ext/settings/settings", {
changed = true;
}
}
- if (ide.dispatchEvent("savesettings", {
- model : this.model
- }) !== false || changed)
+
+ if (ide.dispatchEvent("savesettings", { model : this.model }) !== false || changed) {
this.saveToFile();
+ }
},
addSection : function(tagName, name, xpath, cbCommit){
@@ -72,6 +75,46 @@ module.exports = ext.register("ext/settings/settings", {
this.model.appendXml('<' + tagName + ' name="' + name +'" />', xpath);
},
+ addMarkupToSection: function(markup, sectionName) {
+ var els;
+ var bar = barSettings;
+
+ if (typeof markup == "string") {
+ bar.insertMarkup(markup);
+ els = bar.childNodes;
+ }
+ else {
+ els = markup;
+ if (!apf.isArray(els)) {
+ els = [els];
+ }
+ els.forEach(bar.appendChild);
+ }
+
+ var headers = slice.call(bar.$ext.getElementsByTagName("div"));
+ headers = headers.filter(function(header) {
+ return header.className && header.className.indexOf("header") > -1;
+ });
+
+ var insertInHeader = function(header, el, insBefore) {
+ if (insBefore)
+ header.parentNode.insertBefore(el.$ext, insBefore);
+ else
+ header.parentNode.appendChild(el.$ext);
+ };
+
+ sectionName = sectionName.toLowerCase();
+ for (var i = 0, l = headers.length; i < l; ++i) {
+ if (headers[i].innerText.toLowerCase().indexOf(sectionName) === -1) {
+ continue;
+ }
+
+ for (var el_i = 0, el_l = els.length; el_i < el_l; el_i++) {
+ insertInHeader(headers[i], els[el_i], headers[i + 1]);
+ }
+ }
+ },
+
load : function(){
var _self = this;
@@ -90,7 +133,7 @@ module.exports = ext.register("ext/settings/settings", {
ide.removeEventListener("socketMessage", arguments.callee);
}
});
-
+
if (ide.onLine === true)
ide.send(JSON.stringify({command: "settings", action: "get"}));
return;
View
8 client/ext/settings/settings.xml
@@ -1,11 +1,11 @@
<a:application xmlns:a="http://ajax.org/2005/aml">
- <a:skin id="prefs"
- src = "{require('ext/settings/settings').skin}"
+ <a:skin id="prefs"
+ src = "{require('ext/settings/settings').skin}"
media-path = "/static/ext/settings/images/" />
<a:window id="winSettings"
skin = "fm-window"
- class = "unselectable"
+ class = "unselectable"
title = "Preferences"
visible = "true"
flex = "1"
@@ -31,4 +31,4 @@
/>
</a:hbox>
</a:window>
-</a:application>
+</a:application>
View
3  client/ext/stripws/stripws.js
@@ -94,7 +94,8 @@ module.exports = ext.register("ext/stripws/stripws", {
});
ide.addEventListener("init.ext/settings/settings", function (e) {
- barSettings.insertMarkup(settings);
+ extSettings.addMarkupToSection(settings, "code editor");
+ //barSettings.insertMarkup(settings);
});
},
Please sign in to comment.
Something went wrong with that request. Please try again.