kopia lustrzana https://github.com/c9/core
Enable the store in the IDE and load it in an iframe
rodzic
5db984340f
commit
f40b6fa368
|
@ -24,12 +24,12 @@ define(function(require, exports, module) {
|
||||||
var extensions = [];
|
var extensions = [];
|
||||||
var packages = {};
|
var packages = {};
|
||||||
|
|
||||||
var handle = editors.register("plugin.packages", "Packages Browser",
|
var handle = editors.register("plugin.packages", "Package Browser",
|
||||||
PackagesBrowser, extensions);
|
PackageBrowser, extensions);
|
||||||
var emit = handle.getEmitter();
|
var emit = handle.getEmitter();
|
||||||
emit.setMaxListeners(1000);
|
emit.setMaxListeners(1000);
|
||||||
|
|
||||||
var HASSDK = c9.location.indexOf("sdk=1") > -1;
|
var HASSDK = c9.location.indexOf("sdk=0") === -1;
|
||||||
|
|
||||||
function focusOpenPackages(){
|
function focusOpenPackages(){
|
||||||
var pages = tabs.getTabs();
|
var pages = tabs.getTabs();
|
||||||
|
@ -49,8 +49,8 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.addCommand({
|
commands.addCommand({
|
||||||
name: "openpackagesbrowser",
|
name: "openpackagebrowser",
|
||||||
hint: "open the packages browser",
|
hint: "open the package browser",
|
||||||
group: "General",
|
group: "General",
|
||||||
// bindKey: { mac: "Command-,", win: "Ctrl-," },
|
// bindKey: { mac: "Command-,", win: "Ctrl-," },
|
||||||
exec: function () {
|
exec: function () {
|
||||||
|
@ -69,9 +69,10 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
}, handle);
|
}, handle);
|
||||||
|
|
||||||
menus.addItemByPath("Cloud9/Plugin Store", new ui.item({
|
menus.addItemByPath("Cloud9/~", new ui.divider(), 1000, handle);
|
||||||
command: "openpackagesbrowser"
|
menus.addItemByPath("Cloud9/Package Browser", new ui.item({
|
||||||
}), 301, handle);
|
command: "openpackagebrowser"
|
||||||
|
}), 1100, handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** Methods *****/
|
||||||
|
@ -123,10 +124,10 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
/***** Editor *****/
|
/***** Editor *****/
|
||||||
|
|
||||||
function PackagesBrowser(){
|
function PackageBrowser(){
|
||||||
var plugin = new Editor("Ajax.org", main.consumes, extensions);
|
var plugin = new Editor("Ajax.org", main.consumes, extensions);
|
||||||
//var emit = plugin.getEmitter();
|
//var emit = plugin.getEmitter();
|
||||||
var tab;
|
var tab, iframe;
|
||||||
|
|
||||||
plugin.on("resize", function(e) {
|
plugin.on("resize", function(e) {
|
||||||
emit("resize", e);
|
emit("resize", e);
|
||||||
|
@ -136,33 +137,15 @@ define(function(require, exports, module) {
|
||||||
tab = e.tab;
|
tab = e.tab;
|
||||||
var htmlNode = e.htmlNode;
|
var htmlNode = e.htmlNode;
|
||||||
|
|
||||||
api.packages.get("", function(err, list){
|
iframe = htmlNode.appendChild(document.createElement("iframe"));
|
||||||
if (c9.standalone) {
|
iframe.style.position = "absolute";
|
||||||
err = null;
|
iframe.style.top = 0;
|
||||||
list = [{ name: "example", apikey:"0000000000000000000000000000=", packagePath: "plugins/c9.example/example" }];
|
iframe.style.left = 0;
|
||||||
}
|
iframe.style.width = "100%";
|
||||||
|
iframe.style.height = "100%";
|
||||||
|
iframe.style.border = 0;
|
||||||
|
|
||||||
if (err) return;
|
iframe.src = location.origin + "/profile/packages?nobar=1&pid=" + c9.projectId;
|
||||||
|
|
||||||
var sHtml = "";
|
|
||||||
list.forEach(function(plugin){ // @todo use react instead in an iframe
|
|
||||||
packages[plugin.name] = plugin;
|
|
||||||
|
|
||||||
sHtml += "<div>"
|
|
||||||
+ "<span>" + plugin.name + "</span> | "
|
|
||||||
+ "<a href='javascript:void(0)' plugin-name='" + plugin.name + "' target='project'>Install In Workspace</a> | "
|
|
||||||
+ "<a href='javascript:void(0)' plugin-name='" + plugin.name + "' target='user'>Install To User</a>"
|
|
||||||
+ "</div>";
|
|
||||||
});
|
|
||||||
|
|
||||||
htmlNode.innerHTML = sHtml;
|
|
||||||
htmlNode.addEventListener("click", function(e){
|
|
||||||
if (e.target.tagName == "A") {
|
|
||||||
installPlugin(e.target.getAttribute("plugin-name"),
|
|
||||||
e.target.getAttribute("target"), function(){});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
plugin.on("getState", function(e) {
|
plugin.on("getState", function(e) {
|
||||||
|
|
Ładowanie…
Reference in New Issue