semicolonify demo files;
This commit is contained in:
parent
753dbbece5
commit
fada97f807
7 changed files with 59 additions and 62 deletions
|
|
@ -34,7 +34,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
require("ace/lib/fixoldbrowsers");
|
require("ace/lib/fixoldbrowsers");
|
||||||
|
|
||||||
require("ace/multi_select")
|
require("ace/multi_select");
|
||||||
require("ace/ext/spellcheck");
|
require("ace/ext/spellcheck");
|
||||||
require("./inline_editor");
|
require("./inline_editor");
|
||||||
require("./dev_util");
|
require("./dev_util");
|
||||||
|
|
@ -165,11 +165,11 @@ env.editor.commands.addCommands([{
|
||||||
bindKey: "ctrl+enter",
|
bindKey: "ctrl+enter",
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
try {
|
try {
|
||||||
var r = window.eval(editor.getCopyText()||editor.getValue());
|
var r = window.eval(editor.getCopyText() || editor.getValue());
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
r = e;
|
r = e;
|
||||||
}
|
}
|
||||||
editor.cmdLine.setValue(r + "")
|
editor.cmdLine.setValue(r + "");
|
||||||
},
|
},
|
||||||
readOnly: true
|
readOnly: true
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -178,8 +178,8 @@ env.editor.commands.addCommands([{
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
config.loadModule("ace/ext/keybinding_menu", function(module) {
|
config.loadModule("ace/ext/keybinding_menu", function(module) {
|
||||||
module.init(editor);
|
module.init(editor);
|
||||||
editor.showKeyboardShortcuts()
|
editor.showKeyboardShortcuts();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "increaseFontSize",
|
name: "increaseFontSize",
|
||||||
|
|
@ -225,7 +225,7 @@ commands.addCommand({
|
||||||
bindKey: {win: "Ctrl-S", mac: "Command-S"},
|
bindKey: {win: "Ctrl-S", mac: "Command-S"},
|
||||||
exec: function(arg) {
|
exec: function(arg) {
|
||||||
var session = env.editor.session;
|
var session = env.editor.session;
|
||||||
name = session.name.match(/[^\/]+$/)
|
var name = session.name.match(/[^\/]+$/);
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"saved_file:" + name,
|
"saved_file:" + name,
|
||||||
session.getValue()
|
session.getValue()
|
||||||
|
|
@ -239,7 +239,7 @@ commands.addCommand({
|
||||||
bindKey: {win: "Ctrl-O", mac: "Command-O"},
|
bindKey: {win: "Ctrl-O", mac: "Command-O"},
|
||||||
exec: function(arg) {
|
exec: function(arg) {
|
||||||
var session = env.editor.session;
|
var session = env.editor.session;
|
||||||
name = session.name.match(/[^\/]+$/)
|
var name = session.name.match(/[^\/]+$/);
|
||||||
var value = localStorage.getItem("saved_file:" + name);
|
var value = localStorage.getItem("saved_file:" + name);
|
||||||
if (typeof value == "string") {
|
if (typeof value == "string") {
|
||||||
session.setValue(value);
|
session.setValue(value);
|
||||||
|
|
@ -314,7 +314,7 @@ doclist.history = doclist.docs.map(function(doc) {
|
||||||
});
|
});
|
||||||
doclist.history.index = 0;
|
doclist.history.index = 0;
|
||||||
doclist.cycleOpen = function(editor, dir) {
|
doclist.cycleOpen = function(editor, dir) {
|
||||||
var h = this.history
|
var h = this.history;
|
||||||
h.index += dir;
|
h.index += dir;
|
||||||
if (h.index >= h.length)
|
if (h.index >= h.length)
|
||||||
h.index = 0;
|
h.index = 0;
|
||||||
|
|
@ -323,17 +323,16 @@ doclist.cycleOpen = function(editor, dir) {
|
||||||
var s = h[h.index];
|
var s = h[h.index];
|
||||||
docEl.value = s;
|
docEl.value = s;
|
||||||
docEl.onchange();
|
docEl.onchange();
|
||||||
h.index
|
};
|
||||||
}
|
|
||||||
doclist.addToHistory = function(name) {
|
doclist.addToHistory = function(name) {
|
||||||
var h = this.history
|
var h = this.history;
|
||||||
var i = h.indexOf(name);
|
var i = h.indexOf(name);
|
||||||
if (i != h.index) {
|
if (i != h.index) {
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
h.splice(i, 1);
|
h.splice(i, 1);
|
||||||
h.index = h.push(name);
|
h.index = h.push(name);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
bindDropdown("doc", function(name) {
|
bindDropdown("doc", function(name) {
|
||||||
doclist.loadDoc(name, function(session) {
|
doclist.loadDoc(name, function(session) {
|
||||||
|
|
@ -372,15 +371,15 @@ function updateUIEditorOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
event.addListener(themeEl, "mouseover", function(e){
|
event.addListener(themeEl, "mouseover", function(e){
|
||||||
this.desiredValue = e.target.value;
|
themeEl.desiredValue = e.target.value;
|
||||||
if (!this.$timer)
|
if (!themeEl.$timer)
|
||||||
this.$timer = setTimeout(this.updateTheme);
|
themeEl.$timer = setTimeout(themeEl.updateTheme);
|
||||||
});
|
});
|
||||||
|
|
||||||
event.addListener(themeEl, "mouseout", function(e){
|
event.addListener(themeEl, "mouseout", function(e){
|
||||||
this.desiredValue = null;
|
themeEl.desiredValue = null;
|
||||||
if (!this.$timer)
|
if (!themeEl.$timer)
|
||||||
this.$timer = setTimeout(this.updateTheme, 20);
|
themeEl.$timer = setTimeout(themeEl.updateTheme, 20);
|
||||||
});
|
});
|
||||||
|
|
||||||
themeEl.updateTheme = function(){
|
themeEl.updateTheme = function(){
|
||||||
|
|
@ -568,24 +567,25 @@ env.editSnippets = function() {
|
||||||
var text = m.snippetText;
|
var text = m.snippetText;
|
||||||
var s = doclist.initDoc(text, "", {});
|
var s = doclist.initDoc(text, "", {});
|
||||||
s.setMode("ace/mode/snippets");
|
s.setMode("ace/mode/snippets");
|
||||||
doclist["snippets/" + id] = s
|
doclist["snippets/" + id] = s;
|
||||||
}
|
}
|
||||||
editor.on("blur", function() {
|
editor.on("blur", function() {
|
||||||
m.snippetText = editor.getValue();
|
m.snippetText = editor.getValue();
|
||||||
snippetManager.unregister(m.snippets);
|
snippetManager.unregister(m.snippets);
|
||||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText, m.scope);
|
m.snippets = snippetManager.parseSnippetFile(m.snippetText, m.scope);
|
||||||
snippetManager.register(m.snippets);
|
snippetManager.register(m.snippets);
|
||||||
})
|
});
|
||||||
sp.$editors[0].once("changeMode", function() {
|
sp.$editors[0].once("changeMode", function() {
|
||||||
sp.setSplits(1);
|
sp.setSplits(1);
|
||||||
})
|
});
|
||||||
editor.setSession(doclist["snippets/" + id], 1);
|
editor.setSession(doclist["snippets/" + id], 1);
|
||||||
editor.focus();
|
editor.focus();
|
||||||
}
|
};
|
||||||
|
|
||||||
require("ace/ext/language_tools");
|
require("ace/ext/language_tools");
|
||||||
env.editor.setOptions({
|
env.editor.setOptions({
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
enableSnippets: true
|
enableSnippets: true
|
||||||
})
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -49,10 +49,10 @@ function def(o, key, get) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
def(window, "ace", function(){ warn(); return env.editor });
|
def(window, "ace", function(){ warn(); return window.env.editor });
|
||||||
def(window, "editor", function(){ warn(); return env.editor });
|
def(window, "editor", function(){ warn(); return window.env.editor });
|
||||||
def(window, "session", function(){ warn(); return env.editor.session });
|
def(window, "session", function(){ warn(); return window.env.editor.session });
|
||||||
def(window, "split", function(){ warn(); return env.split });
|
def(window, "split", function(){ warn(); return window.env.split });
|
||||||
|
|
||||||
|
|
||||||
/* for textinput debuggging
|
/* for textinput debuggging
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ modelist.modes.forEach(function(m) {
|
||||||
if (ext[0] === "^") {
|
if (ext[0] === "^") {
|
||||||
path = ext.substr(1);
|
path = ext.substr(1);
|
||||||
} else {
|
} else {
|
||||||
var path = m.name + "." + ext
|
var path = m.name + "." + ext;
|
||||||
}
|
}
|
||||||
path = "docs/" + path;
|
path = "docs/" + path;
|
||||||
if (!docs[path]) {
|
if (!docs[path]) {
|
||||||
|
|
@ -103,7 +103,7 @@ modelist.modes.forEach(function(m) {
|
||||||
} else if (typeof docs[path] == "object" && !docs[path].name) {
|
} else if (typeof docs[path] == "object" && !docs[path].name) {
|
||||||
docs[path].name = m.caption;
|
docs[path].name = m.caption;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ function sort(list) {
|
||||||
return list.sort(function(a, b) {
|
return list.sort(function(a, b) {
|
||||||
var cmp = (b.order || 0) - (a.order || 0);
|
var cmp = (b.order || 0) - (a.order || 0);
|
||||||
return cmp || a.name && a.name.localeCompare(b.name);
|
return cmp || a.name && a.name.localeCompare(b.name);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareDocList(docs) {
|
function prepareDocList(docs) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ module.exports = function(editor) {
|
||||||
return event.stopEvent(e);
|
return event.stopEvent(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
var Editor = require("ace/editor").Editor;
|
var Editor = require("ace/editor").Editor;
|
||||||
config.defineOptions(Editor.prototype, "editor", {
|
config.defineOptions(Editor.prototype, "editor", {
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var LineWidgets = require("ace/line_widgets").LineWidgets;
|
var LineWidgets = require("ace/line_widgets").LineWidgets;
|
||||||
var Editor = require("ace/editor").Editor
|
var Editor = require("ace/editor").Editor;
|
||||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer
|
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||||
var dom = require("ace/lib/dom");
|
var dom = require("ace/lib/dom");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,12 +42,12 @@ require("ace/commands/default_commands").commands.push({
|
||||||
name: "openInlineEditor",
|
name: "openInlineEditor",
|
||||||
bindKey: "F3",
|
bindKey: "F3",
|
||||||
exec: function(editor) {
|
exec: function(editor) {
|
||||||
var split = env.split
|
var split = window.env.split;
|
||||||
var s = editor.session
|
var s = editor.session;
|
||||||
var inlineEditor = new Editor(new Renderer())
|
var inlineEditor = new Editor(new Renderer());
|
||||||
var splitSession = split.$cloneSession(s)
|
var splitSession = split.$cloneSession(s);
|
||||||
|
|
||||||
var row = editor.getCursorPosition().row
|
var row = editor.getCursorPosition().row;
|
||||||
if (editor.session.lineWidgets && editor.session.lineWidgets[row]) {
|
if (editor.session.lineWidgets && editor.session.lineWidgets[row]) {
|
||||||
editor.session.lineWidgets[row].destroy();
|
editor.session.lineWidgets[row].destroy();
|
||||||
return;
|
return;
|
||||||
|
|
@ -70,36 +70,36 @@ require("ace/commands/default_commands").commands.push({
|
||||||
}
|
}
|
||||||
|
|
||||||
var h = rowCount*editor.renderer.layerConfig.lineHeight;
|
var h = rowCount*editor.renderer.layerConfig.lineHeight;
|
||||||
inlineEditor.container.style.height = h + "px"
|
inlineEditor.container.style.height = h + "px";
|
||||||
|
|
||||||
el.style.position = "absolute"
|
el.style.position = "absolute";
|
||||||
el.style.zIndex = "4"
|
el.style.zIndex = "4";
|
||||||
el.style.borderTop = "solid blue 2px"
|
el.style.borderTop = "solid blue 2px";
|
||||||
el.style.borderBottom = "solid blue 2px"
|
el.style.borderBottom = "solid blue 2px";
|
||||||
|
|
||||||
inlineEditor.setSession(splitSession)
|
inlineEditor.setSession(splitSession);
|
||||||
editor.session.widgetManager.addLineWidget(w);
|
editor.session.widgetManager.addLineWidget(w);
|
||||||
|
|
||||||
var kb = {
|
var kb = {
|
||||||
handleKeyboard:function(_,hashId, keyString) {
|
handleKeyboard:function(_,hashId, keyString) {
|
||||||
if (hashId == 0 && keyString == "esc") {
|
if (hashId === 0 && keyString === "esc") {
|
||||||
w.destroy();
|
w.destroy();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
w.destroy = function() {
|
w.destroy = function() {
|
||||||
editor.keyBinding.removeKeyboardHandler(kb);
|
editor.keyBinding.removeKeyboardHandler(kb);
|
||||||
s.widgetManager.removeLineWidget(w);
|
s.widgetManager.removeLineWidget(w);
|
||||||
}
|
};
|
||||||
|
|
||||||
editor.keyBinding.addKeyboardHandler(kb)
|
editor.keyBinding.addKeyboardHandler(kb);
|
||||||
inlineEditor.keyBinding.addKeyboardHandler(kb)
|
inlineEditor.keyBinding.addKeyboardHandler(kb);
|
||||||
editor.on("changeSession", function(e) {
|
editor.on("changeSession", function(e) {
|
||||||
w.el.parentNode && w.el.parentNode.removeChild(w.el)
|
w.el.parentNode && w.el.parentNode.removeChild(w.el);
|
||||||
});
|
});
|
||||||
inlineEditor.setTheme("ace/theme/solarized_light")
|
inlineEditor.setTheme("ace/theme/solarized_light");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ var TokenTooltip = function(editor) {
|
||||||
if (this.lastT - (r.timeStamp || 0) > 1000) {
|
if (this.lastT - (r.timeStamp || 0) > 1000) {
|
||||||
r.rect = null;
|
r.rect = null;
|
||||||
r.timeStamp = this.lastT;
|
r.timeStamp = this.lastT;
|
||||||
this.maxHeight = innerHeight;
|
this.maxHeight = window.innerHeight;
|
||||||
this.maxWidth = innerWidth;
|
this.maxWidth = window.innerWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect());
|
var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect());
|
||||||
|
|
@ -145,8 +145,8 @@ var TokenTooltip = function(editor) {
|
||||||
this.updateTooltipPosition = function(x, y) {
|
this.updateTooltipPosition = function(x, y) {
|
||||||
var st = tooltipNode.style;
|
var st = tooltipNode.style;
|
||||||
if (x + 10 + this.tooltipWidth > this.maxWidth)
|
if (x + 10 + this.tooltipWidth > this.maxWidth)
|
||||||
x = innerWidth - this.tooltipWidth - 10;
|
x = window.innerWidth - this.tooltipWidth - 10;
|
||||||
if (y > innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight)
|
if (y > window.innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight)
|
||||||
y = y - this.tooltipHeight - 30;
|
y = y - this.tooltipHeight - 30;
|
||||||
|
|
||||||
st.left = x + 10 + "px";
|
st.left = x + 10 + "px";
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ var MultiSelect = require("ace/multi_select").MultiSelect;
|
||||||
|
|
||||||
exports.createEditor = function(el) {
|
exports.createEditor = function(el) {
|
||||||
return new Editor(new Renderer(el));
|
return new Editor(new Renderer(el));
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.createSplitEditor = function(el) {
|
exports.createSplitEditor = function(el) {
|
||||||
if (typeof(el) == "string")
|
if (typeof(el) == "string")
|
||||||
|
|
@ -62,9 +62,6 @@ exports.createSplitEditor = function(el) {
|
||||||
split.editor1 = split[1] = new Editor(new Renderer(e1));
|
split.editor1 = split[1] = new Editor(new Renderer(e1));
|
||||||
split.splitter = s;
|
split.splitter = s;
|
||||||
|
|
||||||
MultiSelect(split.editor0);
|
|
||||||
MultiSelect(split.editor1);
|
|
||||||
|
|
||||||
s.ratio = 0.5;
|
s.ratio = 0.5;
|
||||||
|
|
||||||
split.resize = function resize(){
|
split.resize = function resize(){
|
||||||
|
|
@ -108,8 +105,8 @@ exports.createSplitEditor = function(el) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var onResizeInterval = function() {
|
var onResizeInterval = function() {
|
||||||
s.ratio = (x - rect.left) / rect.width
|
s.ratio = (x - rect.left) / rect.width;
|
||||||
split.resize()
|
split.resize();
|
||||||
};
|
};
|
||||||
|
|
||||||
event.capture(s, onMouseMove, onResizeEnd);
|
event.capture(s, onMouseMove, onResizeEnd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue