kopia lustrzana https://github.com/c9/core
commit
e9299df383
|
@ -23,39 +23,17 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
function main(options, imports, register) {
|
function main(options, imports, register) {
|
||||||
var Plugin = imports.Plugin;
|
var Plugin = imports.Plugin;
|
||||||
var showError = imports["dialog.error"].show;
|
|
||||||
|
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||||
|
|
||||||
var requested, nativeObject;
|
var nativeObject;
|
||||||
|
|
||||||
var loaded = false;
|
var loaded = false;
|
||||||
function load(){
|
function load(){
|
||||||
if (loaded) return false;
|
if (loaded) return false;
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
// Chrome Specific
|
|
||||||
if (window.chrome && window.chrome.permissions) {
|
|
||||||
var chrome = window.chrome;
|
|
||||||
var permissions = {
|
|
||||||
permissions: ["clipboardRead", "clipboardWrite"],
|
|
||||||
origins: [location.origin]
|
|
||||||
};
|
|
||||||
|
|
||||||
chrome.permissions.contains(permissions, function(allowed) {
|
|
||||||
if (!allowed) {
|
|
||||||
chrome.permissions.request(permissions, function(result) {
|
|
||||||
if (result) {
|
|
||||||
showError("The browser has granted copy "
|
|
||||||
+ "and paste permissions. Restart the "
|
|
||||||
+ "browser to enable these permissions");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** Methods *****/
|
||||||
|
@ -94,10 +72,7 @@ define(function(require, exports, module) {
|
||||||
};
|
};
|
||||||
document.addEventListener("copy", setData, true);
|
document.addEventListener("copy", setData, true);
|
||||||
|
|
||||||
// @todo test if this is sync
|
|
||||||
requested = true;
|
|
||||||
var result = execCommand("copy");
|
var result = execCommand("copy");
|
||||||
requested = false;
|
|
||||||
|
|
||||||
document.removeEventListener("copy", setData, true);
|
document.removeEventListener("copy", setData, true);
|
||||||
|
|
||||||
|
@ -123,10 +98,7 @@ define(function(require, exports, module) {
|
||||||
};
|
};
|
||||||
document.addEventListener("paste", getData, true);
|
document.addEventListener("paste", getData, true);
|
||||||
|
|
||||||
// @todo test if this is sync
|
|
||||||
requested = true;
|
|
||||||
var result = execCommand("paste");
|
var result = execCommand("paste");
|
||||||
requested = false;
|
|
||||||
|
|
||||||
document.removeEventListener("paste", getData, true);
|
document.removeEventListener("paste", getData, true);
|
||||||
|
|
||||||
|
@ -173,6 +145,7 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
plugin.on("unload", function(){
|
plugin.on("unload", function(){
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
nativeObject = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** Register and define API *****/
|
||||||
|
|
Ładowanie…
Reference in New Issue