Skip to content

Commit

Permalink
Added Redo, Undo and Color Select funcionality. Some bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiego committed Aug 23, 2015
1 parent cf2a387 commit 32f1a6c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 9 deletions.
39 changes: 37 additions & 2 deletions app/assets/css/master.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
body.chrome-annotation-opened{
overflow-y: hidden;
}

#chrome-annotation-write-pad-id {
z-index: 9999;
z-index: 99990;
position: fixed;
top: 0;
transition: transform 1s ease-in-out;
Expand All @@ -12,5 +16,36 @@

#chrome-annotation-write-pad-id.opened > canvas {
cursor: crosshair;
background-color: rgba(103, 128, 159, 0.5);
}

#chrome-annotation-write-pad-id > nav {
box-sizing: border-box;
width: 240px;
height: 52px;
padding: 5px;
background-color: rgba(0, 0, 0, 0.5);
position: absolute;
bottom: 0px;
}

#chrome-annotation-write-pad-id > nav > button {
float: left;
min-width: 40px;
height: 40px;
border: 1px solid #FFF;
background: rgba(0, 0, 0, 0.5);
margin: 0 5px;
text-align: center;
color: #FFF;
cursor: pointer;
}

#chrome-annotation-write-pad-id > nav > input {
float: left;
min-width: 36px;
height: 36px;
border: 1px solid #FFF;
margin: 0 5px;
color: #FFF;
cursor: pointer;
}
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version" : 2,
"name" : "ChromeAnnotation",
"version" : "1.0",
"version" : "1.3.1",

"description" : "Give you the possibility to annotate and print something on the screen",
"background" : {
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/CanvasObject.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
function ChromeAnnotationCanvas() {
var elem = document.createElement("div"),
wrap = document.createElement("div"),
canvas = document.createElement("canvas");
canvas = document.createElement("canvas")
painel = new ChromeAnnotationPainel();

wrap.id = "chrome-annotation-write-pad-id";
wrap.appendChild(canvas);
wrap.appendChild(painel.get());
elem.appendChild(wrap);

this.get = function() {
Expand Down
29 changes: 28 additions & 1 deletion app/scripts/PainelObject.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
function ChromeAnnotationPainel() {
var nav = document.createElement("nav"),
btnColor = document.createElement("button"),
btnUndo = document.createElement("button"),
btnDo = document.createElement("button"),
btnPrint = document.createElement("button"),
colorPiker = document.createElement("input");

};


btnUndo.innerHTML = "UNDO";
btnDo.innerHTML = "DO";
btnPrint.innerHTML = "PRINT";

colorPiker.type = "color";
colorPiker.id = "chrome-annotation-painel-color-button";
btnDo.id = "chrome-annotation-painel-do-button";
btnUndo.id = "chrome-annotation-painel-undo-button";
btnPrint.id = "chrome-annotation-painel-print-button";

nav.appendChild(colorPiker);
nav.appendChild(btnDo);
nav.appendChild(btnUndo);
nav.appendChild(btnPrint);


this.get = function() {
return nav;
}
}
10 changes: 7 additions & 3 deletions app/scripts/_ChromeEvents.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
chrome.browserAction.onClicked.addListener(function(tab){
var canvas = new ChromeAnnotationCanvas(),
commands = [
'if(!document.getElementById("chrome-annotation-write-pad-id")) {body.innerHTML += \'' + canvas.get() + '\'',
'var sketchpad = new Sketchpad({element: document.querySelectorAll("#chrome-annotation-write-pad-id canvas")[0],width: window.innerWidth,height: window.innerHeight})}',
'document.getElementById("chrome-annotation-write-pad-id").classList.toggle("opened")'
'if(!document.getElementById("chrome-annotation-write-pad-id")) {document.body.innerHTML += \'' + canvas.get() + '\'',
'window.sketchpad = new Sketchpad({element: document.querySelectorAll("#chrome-annotation-write-pad-id canvas")[0],width: window.innerWidth,height: window.innerHeight})}',
'document.getElementById("chrome-annotation-write-pad-id").classList.toggle("opened")',
'document.body.classList.toggle("chrome-annotation-opened")',
'document.getElementById("chrome-annotation-painel-do-button").addEventListener("click", function () {window.sketchpad.redo()})',
'document.getElementById("chrome-annotation-painel-undo-button").addEventListener("click", function () {window.sketchpad.undo()})',
'document.getElementById("chrome-annotation-painel-color-button").addEventListener("change", function () {window.sketchpad.color = document.getElementById("chrome-annotation-painel-color-button").value})'
];

chrome.tabs.executeScript({
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/_NavEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.getElementById("chrome-annotation-painel-do-button").addEventListener("click", function () {
alert("ok")
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrome-annotation",
"version": "1.0.0",
"version": "1.3.1",
"description": "Give you the possibility to annotate and print something on the screen",
"main": "package.json",
"scripts": {
Expand Down

0 comments on commit 32f1a6c

Please sign in to comment.