Files
desktop-app/paste.html
2015-01-18 23:15:00 +08:00

73 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="apple-touch-fullscreen" content="yes">
<meta name=”apple-mobile-web-app-capable” content=”yes” />
<meta name="keywords" content="leanote,leanote.com">
<meta name="description" content="leanote, Not Just A Notebook">
<title>Leanote, Not Just A Notebook</title>
</head>
<body>
<div id="page">
<textarea>
</textarea>
<script src="public/js/jquery-1.9.0.min.js"></script>
<script>
$(document).on('contextmenu', function (e) {
e.preventDefault();
var $target = $(e.target);
var selectionType = window.getSelection().type.toUpperCase();
// if ($target.is(':text')) { // TODO url/email/... 未加入判断哦
var clipData = gui.Clipboard.get().get();
menu.canPaste(clipData.length > 0);
menu.canCopy(selectionType === 'RANGE');
menu.popup(e.originalEvent.x, e.originalEvent.y);
// }
});
var gui = require('nw.gui');
console.log("life")
console.log(gui);
function Menu() {
this.menu = new gui.Menu();
this.cut = new gui.MenuItem({
label: '剪切',
click: function () {
document.execCommand('cut');
}
});
this.copy = new gui.MenuItem({
label: '复制',
click: function () {
document.execCommand('copy');
}
});
this.paste = new gui.MenuItem({
label: '粘贴',
click: function () {
document.execCommand('paste');
}
});
this.menu.append(this.cut);
this.menu.append(this.copy);
this.menu.append(this.paste);
}
Menu.prototype.canCopy = function (bool) {
this.cut.enabled = bool;
this.copy.enabled = bool;
};
Menu.prototype.canPaste = function (bool) {
this.paste.enabled = bool;
};
Menu.prototype.popup = function (x, y) {
this.menu.popup(x, y);
};
var menu = new Menu();
</script>
</body>
</html>