kopia lustrzana https://github.com/c9/core
add ui.buildDom method
rodzic
8c26c4e16b
commit
3edf66c0d1
|
@ -185,10 +185,9 @@ define(function(require, exports, module) {
|
|||
|
||||
var cssClass = theme.cssClass;
|
||||
|
||||
var div = document.createElement("div");
|
||||
document.body.appendChild(div);
|
||||
div.innerHTML = "<div class='ace_gutter'></div>";
|
||||
div.className = cssClass;
|
||||
var div = ui.buildDom(["div", { class: cssClass }, [
|
||||
"span", { class: "ace_gutter" }
|
||||
]], document.body);
|
||||
|
||||
theme.bg = ui.getStyle(div.firstChild, "backgroundColor");
|
||||
theme.fg = ui.getStyle(div.firstChild, "color");
|
||||
|
|
|
@ -180,14 +180,14 @@ define(function(require, exports, module) {
|
|||
|
||||
rb1.$group.on("afterchange", change);
|
||||
|
||||
intro.$int.innerHTML =
|
||||
'<h1>Themes</h1><p>You can also style Cloud9 by editing '
|
||||
+ ' <a href="javascript:void(0)">your stylesheet</a>.</p>'
|
||||
+ '<p class="hint">Set all the colors free!</p>';
|
||||
|
||||
intro.$int.querySelector("a").onclick = function() {
|
||||
configure.editStylesCss();
|
||||
};
|
||||
ui.buildDom([
|
||||
["h1", null, "Themes"],
|
||||
["p", null, "You can also style Cloud9 by editing",
|
||||
["a", { href: "javascript:void(0)", onclick: function() { configure.editStylesCss(); } },
|
||||
"your stylesheet"]
|
||||
],
|
||||
["p", { class: "hint" }, "Set all the colors free!"]
|
||||
], intro.$int);
|
||||
}
|
||||
|
||||
/***** Methods *****/
|
||||
|
|
|
@ -50,10 +50,10 @@ define(function(require, exports, module) {
|
|||
var emit = plugin.getEmitter();
|
||||
|
||||
// open collab documents
|
||||
var documents = {};
|
||||
var openFallbackTimeouts = {};
|
||||
var saveFallbackTimeouts = {};
|
||||
var usersLeaving = {};
|
||||
var documents = Object.create(null);
|
||||
var openFallbackTimeouts = Object.create(null);
|
||||
var saveFallbackTimeouts = Object.create(null);
|
||||
var usersLeaving = Object.create(null);
|
||||
var failedSaveAttempts = 0;
|
||||
var OPEN_FILESYSTEM_FALLBACK_TIMEOUT = 6000;
|
||||
var SAVE_FILESYSTEM_FALLBACK_TIMEOUT = 30000;
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*global define console document apf */
|
||||
define(function(require, module, exports) {
|
||||
main.consumes = ["Plugin", "ace", "settings", "tabManager",
|
||||
"collab.util", "collab.workspace", "timeslider"];
|
||||
"collab.util", "collab.workspace", "timeslider", "ui"];
|
||||
main.provides = ["CursorLayer"];
|
||||
return main;
|
||||
|
||||
function main(options, imports, register) {
|
||||
var Plugin = imports.Plugin;
|
||||
var settings = imports.settings;
|
||||
var Plugin = imports.Plugin;
|
||||
var ace = imports.ace;
|
||||
var ui = imports.ui;
|
||||
var tabs = imports.tabManager;
|
||||
var util = imports["collab.util"];
|
||||
var workspace = imports["collab.workspace"];
|
||||
|
@ -254,22 +255,15 @@ define(function(require, module, exports) {
|
|||
}
|
||||
|
||||
function drawTooltip(selection, fullname) {
|
||||
var node = document.createElement("div");
|
||||
document.body.appendChild(node);
|
||||
var html = ui.buildDom([
|
||||
["div", { class: "cool_tooltip_cursor", style: "display:none" },
|
||||
["span", { class: "cool_tooltip_cursor_caption" }, fullname]
|
||||
],
|
||||
["div", { class: "cool_tooltip_cursor_arrow", style: "display:none" }]
|
||||
], document.body);
|
||||
|
||||
node.className = "cool_tooltip_cursor";
|
||||
node.innerHTML = "<span class='cool_tooltip_cursor_caption'>" + util.escapeHTML(fullname) + "</span>";
|
||||
|
||||
// create the arrow
|
||||
var arrow = document.createElement("div");
|
||||
document.body.appendChild(arrow);
|
||||
arrow.className = "cool_tooltip_cursor_arrow";
|
||||
|
||||
arrow.style.display = "none";
|
||||
node.style.display = "none";
|
||||
|
||||
selection.tooltip = node;
|
||||
selection.arrow = arrow;
|
||||
selection.tooltip = html[0];
|
||||
selection.arrow = html[1];
|
||||
}
|
||||
|
||||
function showTooltip(selection, user, coords) {
|
||||
|
|
|
@ -583,7 +583,47 @@ document.documentElement.className += " has_apf";
|
|||
apf.browserDetect();
|
||||
|
||||
|
||||
|
||||
apf.buildDom = function buildDom(arr, parent) {
|
||||
if (typeof arr == "string") {
|
||||
var txt = document.createTextNode(arr);
|
||||
if (parent)
|
||||
parent.appendChild(txt);
|
||||
return txt;
|
||||
}
|
||||
|
||||
if (!Array.isArray(arr))
|
||||
return arr;
|
||||
if (typeof arr[0] == "object") {
|
||||
var els = [];
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var ch = buildDom(arr[i]);
|
||||
els.push(ch);
|
||||
if (parent)
|
||||
parent.appendChild(ch);
|
||||
}
|
||||
return els;
|
||||
}
|
||||
|
||||
var el = document.createElement(arr[0]);
|
||||
var options = arr[1];
|
||||
if (options) {
|
||||
Object.keys(options).forEach(function(n) {
|
||||
var val = options[n];
|
||||
if (n == "class") {
|
||||
el.className = Array.isArray(val) ? val.join(" ") : val;
|
||||
}
|
||||
else if (typeof val == "function")
|
||||
el[n] = val;
|
||||
else
|
||||
el.setAttribute(n, val);
|
||||
});
|
||||
}
|
||||
for (var i = 2; i < arr.length; i++)
|
||||
buildDom(arr[i], el);
|
||||
if (parent)
|
||||
parent.appendChild(el);
|
||||
return el;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -573,6 +573,10 @@ define(function(require, module, exports) {
|
|||
*/
|
||||
insertByIndex: insertByIndex,
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
buildDom: apf.buildDom,
|
||||
|
||||
/**
|
||||
* Escapes "&", greater than, less than signs, quotation marks,
|
||||
|
|
Ładowanie…
Reference in New Issue