Skip to content

Commit

Permalink
selection in frames fixed; removal of console output
Browse files Browse the repository at this point in the history
  • Loading branch information
riedelcastro committed Nov 9, 2017
1 parent edc6677 commit c4400c4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 45 deletions.
62 changes: 38 additions & 24 deletions egal/static/egal.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
return 'drup_elem_' + self.currentId;
};

console.log("Created Egal");
// console.log("Created Egal");

this.makeCircle = new MakeCircleContext(this);
this.makeRect = new MakeRectangleContext(this);
Expand All @@ -87,7 +87,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
function linkContextButtonNew(selector, context, update) {
$(selector).click(function () {
self.currentContext = context;
console.log("Button Clicked!");
// console.log("Button Clicked!");
$(self.container + " .egal-menu li").removeClass("active");
$(selector).addClass("active");
self.selectionContext.selectElement(null);
Expand Down Expand Up @@ -208,14 +208,30 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
});
$(self.container + " .firstFrameShow").change(function () {
self.currentFirstFrame = parseInt($(self.container + " .firstFrameShow").val());
if (self.currentFirstFrame < 0) {
self.currentFirstFrame = 0;
$(self.container + " .firstFrameShow").val(self.currentFirstFrame);
}
if (self.currentFirstFrame > self.currentLastFrame) {
self.currentLastFrame = self.currentFirstFrame;
$(self.container + " .lastFrameShow").val(self.currentLastFrame);
}
self.hideOutsideFrames();
});
$(self.container + " .lastFrameShow").change(function () {
self.currentLastFrame = parseInt($(self.container + " .lastFrameShow").val());
if (self.currentLastFrame < 0) {
self.currentLastFrame = 0;
$(self.container + " .lastFrameShow").val(self.currentLastFrame);
}
if (self.currentFirstFrame > self.currentLastFrame) {
self.currentFirstFrame = self.currentLastFrame;
$(self.container + " .firstFrameShow").val(self.currentFirstFrame);
}
self.hideOutsideFrames();
});
linkActionButton(self.container + " .stepForward", function () {
console.log("Stepping forward!");
// console.log("Stepping forward!");
self.currentFirstFrame += 1;
$(self.container + " .firstFrameShow").val(self.currentFirstFrame);
if (self.currentLastFrame < self.currentFirstFrame) {
Expand Down Expand Up @@ -293,9 +309,9 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
var elems = self.snap.selectAll(".drupElem")
for (var i = 0; i < elems.length; i++) {
var elem = $(elems[i].node);
console.log(elem);
console.log(elem.attr("first-frame"));
console.log(elem.attr("last-frame"));
// console.log(elem);
// console.log(elem.attr("first-frame"));
// console.log(elem.attr("last-frame"));
var firstFrame = elem.attr("first-frame") === undefined ? 1 : elem.attr("first-frame");
var lastFrame = elem.attr("last-frame") === undefined ? 10000 : elem.attr("last-frame");

Expand Down Expand Up @@ -432,9 +448,9 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
["Typeset", MathJax.Hub, tmpLatex[0]],
function () {
//for SVG output
console.log(tmpLatex.find("svg"));
// console.log(tmpLatex.find("svg"));
tmpLatex.find("svg").each(function (i, mj) {
console.log(mj);
// console.log(mj);
var jmj = $(mj);
var text = div2text[mj.parentNode.parentNode.parentNode.id];
var bbox = new Snap(text).getBBox();
Expand Down Expand Up @@ -475,7 +491,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx


tmpLatex.remove();
console.log("Done!");
// console.log("Done!");
}
);
//Call MathJax.Hub.Queue(["Typeset",..], copy)
Expand Down Expand Up @@ -586,7 +602,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
contentType: "text/xml",
dataType: "text",
success: function (data, status) {
console.log(data);
// console.log(data);
}
})
};
Expand Down Expand Up @@ -626,7 +642,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
group.append(drupyter.snap.circle(cx - radius, cy, 5).attr(attr).addClass("endPoint left sub"));
group.append(drupyter.snap.circle(cx + radius, cy, 5).attr(attr).addClass("endPoint right sub"));
// var group = drupyter.snap.group(circle, upEndPoint, downEndPoint, leftEndPoint, rightEndPoint);
console.log(group);
// console.log(group);
drupyter.registerAndDecorateElement(group);
drupyter.saveCurrentSVG();
circle = null;
Expand Down Expand Up @@ -663,7 +679,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
};

this.onClickElement = function (e, element) {
console.log("Selected in MakeCircle Mode");
// console.log("Selected in MakeCircle Mode");
}

}
Expand Down Expand Up @@ -711,7 +727,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
createForeignTextInput(element, bbox.cx - (bbox.width - 20) / 2, bbox.cy - 15, bbox.width - 20, 20,
init, 20,
function (textVal) {
console.log(textVal);
// console.log(textVal);
drupyter.convertLatexBack($(label.node));
label = element.select(".egal-label"); //conversion may have replaced the label.
label.attr({
Expand Down Expand Up @@ -746,11 +762,9 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
var bbox = elem.getBBox();
// console.log(bbox);
// console.log(bbox.x2);
// console.log(bbox.y2);
if ($(elem.node).is(":visible")) {
if (elem.node.style.display !== "none") {
if (x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height) {
// console.log("Selected");
// console.log(elem);
// console.log("Selected");
// blurb = elem;
Expand Down Expand Up @@ -779,10 +793,10 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx

this.pasteSelection = function () {
if (this.currentSelection.length > 0) {
console.log("Yo!");
// console.log("Yo!");
var created = [];
my$each(this.currentSelection, function (i, elem) {
console.log(elem);
// console.log(elem);
var cloned = elem.clone();
// $(cloned.node).find("*").unbind();
cloned.selectAll(".sub").forEach(function (e) {
Expand All @@ -807,7 +821,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
};

function mergeBBoxes(snapSet) {
console.log(snapSet);
// console.log(snapSet);
var bbox = null;
// console.log(snapSet);
snapSet.forEach(function (c) {
Expand Down Expand Up @@ -1323,7 +1337,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx
if (!line) {
line = drupyter.snap.line(bbox.cx, bbox.cy, bbox.cx, bbox.cy).attr({
stroke: '#000',
}).addClass("drupElem connector egal-line");
}).addClass("connector egal-line");
line.attr("data-n1", endPoint.attr("id"));
if (this.arrow) {
line.attr({"marker-end": drupyter.marker});
Expand Down Expand Up @@ -1510,7 +1524,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx

this.onMouseMove = function (e, element) {
if (rect) {
console.log("Changing ...");
// console.log("Changing ...");
var offset = $(element.node).offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
Expand Down Expand Up @@ -1562,7 +1576,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx

this.onMouseMove = function (e, element) {
if (line) {
console.log("Changing ...");
// console.log("Changing ...");
var offset = $(element.node).offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
Expand Down Expand Up @@ -1624,7 +1638,7 @@ define(['jquery', './snap.svg', './text!./menu.html'], function ($, snap, menuTx

this.onMouseMove = function (e, element) {
if (line) {
console.log("Changing ...");
// console.log("Changing ...");
var offset = $(element.node).offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
Expand Down
36 changes: 18 additions & 18 deletions egal/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ define(['./egal', 'base/js/namespace', 'jquery'], function (egal, Jupyter, $) {
var inputArea = cell.element.find("div div.input_area");
var cellToolBar = cell.element.find(".celltoolbar");
if (!hasBeenSetup) {
console.log(cellToolBar);
console.log(divId);
console.log(cell.element.find("div div.input_area #" + divId));
console.log(hasBeenSetup);
// console.log(cellToolBar);
// console.log(divId);
// console.log(cell.element.find("div div.input_area #" + divId));
// console.log(hasBeenSetup);
if (cell.metadata.is_egal && cell.cell_type === "raw") {
cell.element.find("div div.input_area > *").toggle();
old_color = inputArea.css("background-color");
Expand All @@ -38,11 +38,11 @@ define(['./egal', 'base/js/namespace', 'jquery'], function (egal, Jupyter, $) {
inputArea.css("border-style", "none");
cellToolBar.css("border-bottom", "thin solid #CFCFCF");
cell.element.click(function () {
console.log("Clicked on Egal!");
// console.log("Clicked on Egal!");
cell.keyboard_manager.disable();

cell.edit_mode();
console.log(cell.mode);
// console.log(cell.mode);
// cell.element.get(0).focus();
});
// cell.cell_type = "raw";
Expand Down Expand Up @@ -81,7 +81,7 @@ define(['./egal', 'base/js/namespace', 'jquery'], function (egal, Jupyter, $) {
};

var load_ipython_extension = function () {
console.log("Loading egal ...");
// console.log("Loading egal ...");
Jupyter.toolbar.add_buttons_group([{
id: 'btn-hide-input',
label: 'Insert Egal Cell',
Expand All @@ -105,24 +105,24 @@ define(['./egal', 'base/js/namespace', 'jquery'], function (egal, Jupyter, $) {
});
} else {
// notebook already loaded. Update directly
console.log("Already loaded! ");
// console.log("Already loaded! ");
require(['base/js/events'], function (events) {
events.on("create.Cell", function (e, cell) {
console.log("Cell created!");
console.log(cell);
console.log(e);
console.log(cell.cell.metadata);
console.log(cell.cell._metadata);
// console.log("Cell created!");
// console.log(cell);
// console.log(e);
// console.log(cell.cell.metadata);
// console.log(cell.cell._metadata);
if (cell.cell.metadata.is_egal) {
setup_egal_cell(cell.cell);
}
});
events.on("select.Cell", function (e, cell) {
console.log("Select edit mode!");
console.log(cell);
console.log(e);
console.log(cell.cell.metadata);
console.log(cell.cell._metadata);
// console.log("Select edit mode!");
// console.log(cell);
// console.log(e);
// console.log(cell.cell.metadata);
// console.log(cell.cell._metadata);
if (cell.cell.metadata.is_egal) {
setup_egal_cell(cell.cell);
}
Expand Down
Loading

0 comments on commit c4400c4

Please sign in to comment.