Organized module locations. Fixed a context menu bug.
This commit is contained in:
parent
e567869075
commit
dfe8749c58
19 changed files with 179 additions and 145 deletions
|
@ -1,4 +1,9 @@
|
|||
define(["command", "editor", "statusbar", "settings!user"], function(command, editor, status, Settings) {
|
||||
define([
|
||||
"command",
|
||||
"editor",
|
||||
"ui/statusbar",
|
||||
"settings!user"
|
||||
], function(command, editor, status, Settings) {
|
||||
|
||||
var userConfig = Settings.get("user");
|
||||
command.on("init:restart", function() {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
define(["command", "settings!api"], function(command, Settings) {
|
||||
define([
|
||||
"command",
|
||||
"settings!api"
|
||||
], function(command, Settings) {
|
||||
|
||||
//handles sending custom messages based on Caret commands (builds, plugins, etc)
|
||||
var targets = Settings.get("api");
|
||||
command.on("init:restart", function() {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
define(["dom2"], function() {
|
||||
define([
|
||||
"util/dom2"
|
||||
], function() {
|
||||
|
||||
/*
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
define(["file", "command", "settings!ace,user", "dom2"], function(File, command, Settings) {
|
||||
define([
|
||||
"storage/file",
|
||||
"command",
|
||||
"settings!ace,user",
|
||||
"util/dom2"
|
||||
], function(File, command, Settings) {
|
||||
/*
|
||||
Module for loading the editor, adding window resizing and other events. Returns the editor straight from Ace.
|
||||
*/
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
define([
|
||||
"sessions",
|
||||
"file",
|
||||
"dialog",
|
||||
"storage/file",
|
||||
"ui/dialog",
|
||||
"command",
|
||||
"settings!", //not excited, it just runs as a RequireJS plugin,
|
||||
"manos"
|
||||
"util/manos"
|
||||
], function(sessions, File, dialog, command, Settings, M) {
|
||||
|
||||
var openFile = function() {
|
||||
|
|
18
js/main.js
18
js/main.js
|
@ -1,13 +1,13 @@
|
|||
require([
|
||||
"command",
|
||||
"settings!user",
|
||||
"dialog",
|
||||
"projectManager",
|
||||
"keys",
|
||||
"fileManager",
|
||||
"menus",
|
||||
"palette",
|
||||
"api"
|
||||
"command",
|
||||
"settings!user",
|
||||
"ui/dialog",
|
||||
"ui/projectManager",
|
||||
"ui/keys",
|
||||
"fileManager",
|
||||
"ui/menus",
|
||||
"ui/palette",
|
||||
"api"
|
||||
], function(command, Settings, dialog) {
|
||||
|
||||
var frame = chrome.app.window.current();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
define([
|
||||
"editor",
|
||||
"dialog",
|
||||
"ui/dialog",
|
||||
"command",
|
||||
"file",
|
||||
"storage/file",
|
||||
"tab",
|
||||
"settings!ace,user",
|
||||
"statusbar",
|
||||
"ui/statusbar",
|
||||
"aceBindings"
|
||||
],
|
||||
function(editor, dialog, command, File, Tab, Settings, status) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
define(["command"], function(command) {
|
||||
define([
|
||||
"command"
|
||||
], function(command) {
|
||||
|
||||
var defaults = {};
|
||||
var local = {};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
define(["manos"], function(M) {
|
||||
define([
|
||||
"util/manos"
|
||||
], function(M) {
|
||||
|
||||
/*
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
define(["command", "file"], function(command, File) {
|
||||
define([
|
||||
"command",
|
||||
"storage/file"
|
||||
], function(command, File) {
|
||||
|
||||
var EditSession = ace.require("ace/edit_session").EditSession;
|
||||
|
||||
|
|
|
@ -20,11 +20,12 @@ define(function() {
|
|||
|
||||
var createRoute = function(route, handler) {
|
||||
var parts = route.split("/");
|
||||
var positions = {};
|
||||
parts = parts.map(function(s, i) {
|
||||
var positionMap = {};
|
||||
var position = 1;
|
||||
parts = parts.map(function(s) {
|
||||
if (s[0] == ":") {
|
||||
//set the key to be used on parsing
|
||||
positions[i] = s.replace(/^:/, "");
|
||||
positionMap[position++] = s.replace(/^:/, "");
|
||||
return "*";
|
||||
}
|
||||
return s.replace(/[\^()\[\]]/, function(match) { return "\\" + match });
|
||||
|
@ -34,8 +35,8 @@ define(function() {
|
|||
var result = re.exec(url);
|
||||
if (!result) return result;
|
||||
var params = {};
|
||||
for (var place in positions) {
|
||||
var key = positions[place];
|
||||
for (var place in positionMap) {
|
||||
var key = positionMap[place];
|
||||
params[key] = result[place];
|
||||
}
|
||||
params.url = url;
|
|
@ -1,4 +1,7 @@
|
|||
define(["editor", "dom2"], function(editor) {
|
||||
define([
|
||||
"editor",
|
||||
"util/dom2"
|
||||
], function(editor) {
|
||||
|
||||
return function(text, buttons, callback) {
|
||||
if (typeof buttons == "function" || typeof buttons == "undefined") {
|
|
@ -1,4 +1,9 @@
|
|||
define(["settings!keys", "command", "editor", "dom2"], function(Settings, command, editor) {
|
||||
define([
|
||||
"settings!keys",
|
||||
"command",
|
||||
"editor",
|
||||
"util/dom2"
|
||||
], function(Settings, command, editor) {
|
||||
|
||||
/*
|
||||
Still need to set Sublime keybindings
|
|
@ -1,9 +1,9 @@
|
|||
define([
|
||||
"settings!menus,keys",
|
||||
"editor",
|
||||
"dialog",
|
||||
"command",
|
||||
"dom2"
|
||||
"settings!menus,keys",
|
||||
"editor",
|
||||
"ui/dialog",
|
||||
"command",
|
||||
"util/dom2"
|
||||
], function(Settings, editor, dialog, command) {
|
||||
|
||||
var commands = editor.commands.commands;
|
|
@ -1,10 +1,10 @@
|
|||
define([
|
||||
"sessions",
|
||||
"command",
|
||||
"editor",
|
||||
"settings!menus,user",
|
||||
"statusbar",
|
||||
"dom2"
|
||||
"sessions",
|
||||
"command",
|
||||
"editor",
|
||||
"settings!menus,user",
|
||||
"ui/statusbar",
|
||||
"util/dom2"
|
||||
], function(sessions, command, editor, Settings, status) {
|
||||
|
||||
var TokenIterator = ace.require("ace/token_iterator").TokenIterator;
|
|
@ -1,13 +1,13 @@
|
|||
define([
|
||||
"settings!",
|
||||
"command",
|
||||
"sessions",
|
||||
"file",
|
||||
"manos",
|
||||
"dialog",
|
||||
"contextMenus",
|
||||
"editor",
|
||||
"dom2"
|
||||
"settings!",
|
||||
"command",
|
||||
"sessions",
|
||||
"storage/file",
|
||||
"util/manos",
|
||||
"ui/dialog",
|
||||
"ui/contextMenus",
|
||||
"editor",
|
||||
"util/dom2"
|
||||
], function(Settings, command, sessions, File, M, dialog, context, editor) {
|
||||
|
||||
/*
|
|
@ -1,4 +1,6 @@
|
|||
define(["editor"], function(editor) {
|
||||
define([
|
||||
"editor"
|
||||
], function(editor) {
|
||||
|
||||
var external = "";
|
||||
var element = document.find(".status-text");
|
|
@ -1,95 +1,95 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
|
||||
Yes, you're not supposed to extend native prototypes. But in ChromeOS, who cares? Nobody's sharing your context. Why not paper over the cracks in the DOM? This library extends elements to do the following:
|
||||
|
||||
- create a query() method that returns an array, instead of a nodeList
|
||||
- create remove() and append() that work the way you expect them to.
|
||||
- alias event listener methods to the much shorter on() and off()
|
||||
- add a style method that handles prefixed CSS
|
||||
|
||||
*/
|
||||
|
||||
var el = Element.prototype;
|
||||
var doc = Document.prototype;
|
||||
var frag = DocumentFragment.prototype;
|
||||
var win = Window.prototype;
|
||||
|
||||
el.find = doc.find = frag.find = function(selector) {
|
||||
return this.querySelector(selector);
|
||||
};
|
||||
|
||||
el.findAll = doc.findAll = frag.findAll = function(selector) {
|
||||
var a = [];
|
||||
a.push.apply(a, this.querySelectorAll(selector));
|
||||
return a;
|
||||
};
|
||||
|
||||
el.matches = el.matches || el.webkitMatchesSelector;
|
||||
|
||||
el.remove = function() {
|
||||
this.parentElement.removeChild(this);
|
||||
};
|
||||
|
||||
el.append = frag.append = function(element) {
|
||||
if (typeof element == "string") {
|
||||
this.innerHTML += element;
|
||||
} else {
|
||||
this.appendChild(element);
|
||||
}
|
||||
};
|
||||
|
||||
win.on = el.on = function(type, listener) {
|
||||
this.addEventListener(type, listener);
|
||||
return this;
|
||||
};
|
||||
|
||||
win.off = el.off = function(type, listener) {
|
||||
this.removeEventListener(type, listener);
|
||||
};
|
||||
|
||||
el.css = function(style, one) {
|
||||
if (typeof style === "string") {
|
||||
var hash = {};
|
||||
hash[style] = one;
|
||||
style = hash;
|
||||
}
|
||||
for (var key in style) {
|
||||
var val = style[key];
|
||||
if (key.indexOf("-") > 0) {
|
||||
key.replace(/-(\w)/g, function(_, match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
if (!(key in this.style)) {
|
||||
["webkit", "moz", "ms"].some(function(prefix) {
|
||||
var test = prefix + key[0].toUpperCase() + key.substr(1);
|
||||
if (test in this.style) {
|
||||
key = test;
|
||||
return true;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
this.style[key] = val;
|
||||
}
|
||||
};
|
||||
|
||||
el.addClass = function(name) {
|
||||
this.classList.add(name);
|
||||
};
|
||||
|
||||
el.removeClass = function(name) {
|
||||
this.classList.remove(name);
|
||||
};
|
||||
|
||||
el.toggle = function(name) {
|
||||
this.classList.toggle(name);
|
||||
};
|
||||
|
||||
el.hasClass = function(name) {
|
||||
return this.classList.contains(name);
|
||||
}
|
||||
|
||||
})();
|
||||
define(function() {
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
|
||||
Yes, you're not supposed to extend native prototypes. But in ChromeOS, who cares? Nobody's sharing your context. Why not paper over the cracks in the DOM? This library extends elements to do the following:
|
||||
|
||||
- create a query() method that returns an array, instead of a nodeList
|
||||
- create remove() and append() that work the way you expect them to.
|
||||
- alias event listener methods to the much shorter on() and off()
|
||||
- add a style method that handles prefixed CSS
|
||||
|
||||
*/
|
||||
|
||||
var el = Element.prototype;
|
||||
var doc = Document.prototype;
|
||||
var frag = DocumentFragment.prototype;
|
||||
var win = Window.prototype;
|
||||
|
||||
el.find = doc.find = frag.find = function(selector) {
|
||||
return this.querySelector(selector);
|
||||
};
|
||||
|
||||
el.findAll = doc.findAll = frag.findAll = function(selector) {
|
||||
var a = [];
|
||||
a.push.apply(a, this.querySelectorAll(selector));
|
||||
return a;
|
||||
};
|
||||
|
||||
el.matches = el.matches || el.webkitMatchesSelector;
|
||||
|
||||
el.remove = function() {
|
||||
this.parentElement.removeChild(this);
|
||||
};
|
||||
|
||||
el.append = frag.append = function(element) {
|
||||
if (typeof element == "string") {
|
||||
this.innerHTML += element;
|
||||
} else {
|
||||
this.appendChild(element);
|
||||
}
|
||||
};
|
||||
|
||||
win.on = el.on = function(type, listener) {
|
||||
this.addEventListener(type, listener);
|
||||
return this;
|
||||
};
|
||||
|
||||
win.off = el.off = function(type, listener) {
|
||||
this.removeEventListener(type, listener);
|
||||
};
|
||||
|
||||
el.css = function(style, one) {
|
||||
if (typeof style === "string") {
|
||||
var hash = {};
|
||||
hash[style] = one;
|
||||
style = hash;
|
||||
}
|
||||
for (var key in style) {
|
||||
var val = style[key];
|
||||
if (key.indexOf("-") > 0) {
|
||||
key.replace(/-(\w)/g, function(_, match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
}
|
||||
if (!(key in this.style)) {
|
||||
["webkit", "moz", "ms"].some(function(prefix) {
|
||||
var test = prefix + key[0].toUpperCase() + key.substr(1);
|
||||
if (test in this.style) {
|
||||
key = test;
|
||||
return true;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
this.style[key] = val;
|
||||
}
|
||||
};
|
||||
|
||||
el.addClass = function(name) {
|
||||
this.classList.add(name);
|
||||
};
|
||||
|
||||
el.removeClass = function(name) {
|
||||
this.classList.remove(name);
|
||||
};
|
||||
|
||||
el.toggle = function(name) {
|
||||
this.classList.toggle(name);
|
||||
};
|
||||
|
||||
el.hasClass = function(name) {
|
||||
return this.classList.contains(name);
|
||||
}
|
||||
|
||||
})
|
Loading…
Reference in a new issue