2013-01-28 20:18:50 +01:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-pholio-mock-view
|
|
|
|
* @requires javelin-behavior
|
2013-02-23 15:28:34 +01:00
|
|
|
* javelin-util
|
2013-01-28 20:18:50 +01:00
|
|
|
* javelin-stratcom
|
2013-02-01 19:53:15 +01:00
|
|
|
* javelin-dom
|
|
|
|
* javelin-vector
|
2013-02-07 15:26:36 +01:00
|
|
|
* javelin-magical-init
|
|
|
|
* javelin-request
|
2013-01-28 20:18:50 +01:00
|
|
|
*/
|
|
|
|
JX.behavior('pholio-mock-view', function(config) {
|
2013-02-01 19:53:15 +01:00
|
|
|
var is_dragging = false;
|
2013-02-22 15:39:08 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
var drag_begin;
|
|
|
|
var drag_end;
|
2013-02-23 15:28:34 +01:00
|
|
|
var panel = JX.$(config.panelID);
|
|
|
|
var viewport = JX.$(config.viewportID);
|
2013-02-07 15:26:36 +01:00
|
|
|
|
|
|
|
var selection_border;
|
|
|
|
var selection_fill;
|
2013-02-22 19:34:32 +01:00
|
|
|
var active_image;
|
2013-02-01 19:53:15 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var inline_comments = {};
|
|
|
|
|
2013-03-05 01:59:16 +01:00
|
|
|
|
|
|
|
/* -( Stage )-------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
var stage = (function() {
|
|
|
|
var loading = false;
|
|
|
|
var stageElement = JX.$(config.panelID);
|
|
|
|
var viewElement = JX.$(config.viewportID);
|
|
|
|
var reticles = [];
|
|
|
|
|
|
|
|
function begin_load() {
|
|
|
|
if (loading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
loading = true;
|
|
|
|
clear_reticles();
|
|
|
|
draw_loading();
|
|
|
|
}
|
|
|
|
|
|
|
|
function end_load() {
|
|
|
|
if (!loading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
loading = false;
|
|
|
|
draw_loading();
|
|
|
|
}
|
|
|
|
|
|
|
|
function draw_loading() {
|
|
|
|
JX.DOM.alterClass(stageElement, 'pholio-image-loading', loading);
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_reticle(reticle) {
|
|
|
|
reticles.push(reticle);
|
|
|
|
viewElement.appendChild(reticle);
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear_reticles() {
|
|
|
|
for (var ii = 0; ii < reticles.length; ii++) {
|
|
|
|
JX.DOM.remove(reticles[ii]);
|
|
|
|
}
|
|
|
|
reticles = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
beginLoad: begin_load,
|
|
|
|
endLoad: end_load,
|
|
|
|
addReticle: add_reticle,
|
|
|
|
clearReticles: clear_reticles
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2013-02-22 19:34:32 +01:00
|
|
|
function get_image(id) {
|
|
|
|
for (var ii = 0; ii < config.images.length; ii++) {
|
|
|
|
if (config.images[ii].id == id) {
|
|
|
|
return config.images[ii];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
function onload_image(id) {
|
|
|
|
if (active_image.id != id) {
|
|
|
|
// The user has clicked another image before this one loaded, so just
|
|
|
|
// bail.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:56 +01:00
|
|
|
active_image.tag = this;
|
|
|
|
redraw_image();
|
|
|
|
}
|
|
|
|
|
|
|
|
function redraw_image() {
|
|
|
|
if (!active_image || !active_image.tag) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var tag = active_image.tag;
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
// If the image is too wide for the viewport, scale it down so it fits.
|
|
|
|
// (If it is too tall, we just let the user scroll.)
|
|
|
|
var w = JX.Vector.getDim(panel);
|
|
|
|
w.x -= 40;
|
2013-02-23 15:28:56 +01:00
|
|
|
if (w.x < tag.naturalWidth) {
|
|
|
|
var scale = w.x / tag.naturalWidth;
|
|
|
|
tag.width = Math.floor(scale * tag.naturalWidth);
|
|
|
|
tag.height = Math.floor(scale * tag.naturalHeight);
|
|
|
|
} else {
|
|
|
|
tag.width = tag.naturalWidth;
|
|
|
|
tag.height = tag.naturalHeight;
|
2013-02-23 15:28:34 +01:00
|
|
|
}
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-23 15:28:56 +01:00
|
|
|
var new_y = (JX.Vector.getViewport().y * 0.85) - 150;
|
|
|
|
new_y = Math.max(320, new_y);
|
|
|
|
|
|
|
|
if (tag.height + 40 < new_y) {
|
|
|
|
panel.style.height = new_y + 'px';
|
|
|
|
viewport.style.top = Math.floor(((new_y + 40) - tag.height) / 2) + 'px';
|
|
|
|
} else {
|
|
|
|
panel.style.height = '';
|
|
|
|
viewport.style.top = '';
|
|
|
|
}
|
2013-02-23 15:28:34 +01:00
|
|
|
|
2013-03-05 01:59:16 +01:00
|
|
|
stage.endLoad();
|
|
|
|
|
2013-02-23 15:28:56 +01:00
|
|
|
JX.DOM.setContent(viewport, tag);
|
2013-02-23 15:28:34 +01:00
|
|
|
|
|
|
|
redraw_inlines(active_image.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function select_image(image_id) {
|
|
|
|
active_image = get_image(image_id);
|
|
|
|
active_image.tag = null;
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-03-05 01:59:16 +01:00
|
|
|
stage.beginLoad();
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
var img = JX.$N('img', {className: 'pholio-mock-image'});
|
|
|
|
img.onload = JX.bind(img, onload_image, active_image.id);
|
|
|
|
img.src = active_image.fullURI;
|
2013-02-22 19:34:32 +01:00
|
|
|
|
2013-02-27 19:45:51 +01:00
|
|
|
var thumbs = JX.DOM.scry(
|
|
|
|
JX.$('pholio-mock-carousel'),
|
|
|
|
'div',
|
|
|
|
'mock-thumbnail');
|
|
|
|
|
|
|
|
for(var k in thumbs) {
|
|
|
|
var thumb_meta = JX.Stratcom.getData(thumbs[k]);
|
|
|
|
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
thumbs[k],
|
|
|
|
'pholio-mock-carousel-thumb-current',
|
|
|
|
(active_image.id == thumb_meta.imageID));
|
|
|
|
}
|
|
|
|
|
2013-02-22 19:34:32 +01:00
|
|
|
load_inline_comments();
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
2013-03-05 01:59:16 +01:00
|
|
|
['mousedown', 'click'],
|
2013-02-22 19:34:32 +01:00
|
|
|
'mock-thumbnail',
|
|
|
|
function(e) {
|
2013-03-05 01:59:16 +01:00
|
|
|
if (!e.isNormalMouseEvent()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-22 19:34:32 +01:00
|
|
|
e.kill();
|
|
|
|
select_image(e.getNodeData('mock-thumbnail').imageID);
|
2013-02-01 19:53:15 +01:00
|
|
|
});
|
|
|
|
|
2013-02-22 19:34:32 +01:00
|
|
|
// Select and show the first image.
|
|
|
|
select_image(config.images[0].id);
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
JX.Stratcom.listen('mousedown', 'mock-panel', function(e) {
|
2013-02-01 19:53:15 +01:00
|
|
|
if (!e.isNormalMouseEvent()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
if (drag_begin) {
|
|
|
|
return;
|
2013-02-22 15:39:08 +01:00
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
e.kill();
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
is_dragging = true;
|
|
|
|
drag_begin = get_image_xy(JX.$V(e));
|
|
|
|
drag_end = drag_begin;
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
redraw_selection();
|
2013-02-01 19:53:15 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
JX.enableDispatch(document.body, 'mousemove');
|
2013-02-23 15:28:23 +01:00
|
|
|
JX.Stratcom.listen('mousemove', null, function(e) {
|
2013-02-01 19:53:15 +01:00
|
|
|
if (!is_dragging) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-23 15:28:23 +01:00
|
|
|
drag_end = get_image_xy(JX.$V(e));
|
|
|
|
redraw_selection();
|
2013-02-01 19:53:15 +01:00
|
|
|
});
|
|
|
|
|
2013-02-23 15:27:35 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['mouseover', 'mouseout'],
|
|
|
|
'image_selection',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('image_selection');
|
|
|
|
var comment = JX.$(data.phid + "_comment");
|
|
|
|
var highlight = (e.getType() == 'mouseover');
|
|
|
|
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
comment,
|
|
|
|
'pholio-mock-inline-comment-highlight',
|
|
|
|
highlight);
|
|
|
|
});
|
|
|
|
|
2013-02-27 19:45:51 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['mouseover', 'mouseout'],
|
|
|
|
'inline_comment',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('inline_comment');
|
|
|
|
var selection = JX.$(data.phid + "_selection");
|
|
|
|
var highlight = (e.getType() == 'mouseover');
|
|
|
|
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
selection,
|
|
|
|
'pholio-mock-inline-comment-highlight',
|
|
|
|
highlight);
|
|
|
|
});
|
|
|
|
|
2013-02-01 19:53:15 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'mouseup',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
if (!is_dragging) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
is_dragging = false;
|
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
drag_end = get_image_xy(JX.$V(e));
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-22 15:39:08 +01:00
|
|
|
var create_inline = new JX.Request("/pholio/inline/save/", function(r) {
|
|
|
|
JX.DOM.appendContent(JX.$('pholio-mock-image-container'), JX.$H(r));
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-22 15:39:08 +01:00
|
|
|
var dialog = JX.$('pholio-new-inline-comment-dialog');
|
2013-02-01 19:53:15 +01:00
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
var viewportVector = JX.$V(viewport);
|
|
|
|
var viewportDimensions = JX.Vector.getDim(viewport);
|
2013-02-06 20:28:03 +01:00
|
|
|
|
2013-02-22 15:39:08 +01:00
|
|
|
JX.$V(
|
2013-02-23 15:28:23 +01:00
|
|
|
// TODO: This is a little funky for now.
|
|
|
|
Math.max(drag_begin.x, drag_end.x),
|
|
|
|
Math.max(drag_begin.y, drag_end.y)
|
2013-02-22 15:39:08 +01:00
|
|
|
).setPos(dialog);
|
|
|
|
|
|
|
|
});
|
|
|
|
create_inline.addData({mockID: config.mockID});
|
|
|
|
create_inline.send();
|
2013-02-06 20:28:03 +01:00
|
|
|
|
2013-01-28 20:18:50 +01:00
|
|
|
});
|
2013-02-01 19:53:15 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
function redraw_inlines(id) {
|
|
|
|
if (!active_image) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
if (active_image.id != id) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var comment_holder = JX.$('mock-inline-comments');
|
|
|
|
JX.DOM.setContent(comment_holder, '');
|
2013-03-05 01:59:16 +01:00
|
|
|
stage.clearReticles();
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var inlines = inline_comments[active_image.id];
|
|
|
|
if (!inlines || !inlines.length) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
for (var ii = 0; ii < inlines.length; ii++) {
|
|
|
|
var inline = inlines[ii];
|
2013-02-23 15:28:34 +01:00
|
|
|
JX.DOM.appendContent(comment_holder, JX.$H(inline.contentHTML));
|
|
|
|
|
|
|
|
if (!active_image.tag) {
|
|
|
|
// The image itself hasn't loaded yet, so we can't draw the inline
|
|
|
|
// reticles.
|
|
|
|
continue;
|
|
|
|
}
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var inlineSelection = JX.$N(
|
|
|
|
'div',
|
|
|
|
{
|
|
|
|
id: inline.phid + "_selection",
|
|
|
|
className: 'pholio-mock-select-border'
|
|
|
|
});
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.addData(
|
|
|
|
inlineSelection,
|
|
|
|
{phid: inline.phid});
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.addSigil(inlineSelection, "image_selection");
|
2013-02-13 16:10:14 +01:00
|
|
|
|
2013-03-05 01:59:16 +01:00
|
|
|
stage.addReticle(inlineSelection);
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
position_inline_rectangle(inline, inlineSelection);
|
2013-02-13 16:10:14 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
if (!inline.transactionphid) {
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var inlineDraft = JX.$N(
|
|
|
|
'div',
|
|
|
|
{
|
|
|
|
className: 'pholio-mock-select-fill',
|
|
|
|
id: inline.phid + "_fill"
|
|
|
|
});
|
2013-02-13 16:10:14 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
position_inline_rectangle(inline, inlineDraft);
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.addData(
|
|
|
|
inlineDraft,
|
|
|
|
{phid: inline.phid});
|
|
|
|
|
|
|
|
JX.Stratcom.addSigil(inlineDraft, "image_selection");
|
2013-03-05 01:59:16 +01:00
|
|
|
|
|
|
|
stage.addReticle(inlineDraft);
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
}
|
2013-02-08 16:24:17 +01:00
|
|
|
}
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
}
|
2013-02-08 16:24:17 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
function position_inline_rectangle(inline, rect) {
|
2013-02-23 15:28:34 +01:00
|
|
|
var scale = active_image.tag.width / active_image.tag.naturalWidth;
|
|
|
|
|
|
|
|
JX.$V(scale * inline.x, scale * inline.y).setPos(rect);
|
|
|
|
JX.$V(scale * inline.width, scale * inline.height).setDim(rect);
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
}
|
2013-02-22 15:39:08 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
function get_image_xy(p) {
|
2013-02-23 15:28:34 +01:00
|
|
|
var img = active_image.tag;
|
|
|
|
var imgp = JX.$V(img);
|
|
|
|
|
|
|
|
var scale = 1 / get_image_scale();
|
2013-02-23 15:28:23 +01:00
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
var x = scale * Math.max(0, Math.min(p.x - imgp.x, img.width));
|
|
|
|
var y = scale * Math.max(0, Math.min(p.y - imgp.y, img.height));
|
2013-02-23 15:28:23 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
function get_image_scale() {
|
|
|
|
var img = active_image.tag;
|
|
|
|
return img.width / img.naturalWidth;
|
|
|
|
}
|
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
function redraw_selection() {
|
|
|
|
selection_border = selection_border || JX.$N(
|
|
|
|
'div',
|
|
|
|
{className: 'pholio-mock-select-border'});
|
|
|
|
|
|
|
|
selection_fill = selection_fill || JX.$N(
|
|
|
|
'div',
|
|
|
|
{className: 'pholio-mock-select-fill'});
|
|
|
|
|
|
|
|
var p = JX.$V(
|
|
|
|
Math.min(drag_begin.x, drag_end.x),
|
|
|
|
Math.min(drag_begin.y, drag_end.y));
|
|
|
|
|
|
|
|
var d = JX.$V(
|
|
|
|
Math.max(drag_begin.x, drag_end.x) - p.x,
|
|
|
|
Math.max(drag_begin.y, drag_end.y) - p.y);
|
|
|
|
|
2013-02-23 15:28:34 +01:00
|
|
|
var scale = get_image_scale();
|
|
|
|
|
|
|
|
p.x *= scale;
|
|
|
|
p.y *= scale;
|
|
|
|
d.x *= scale;
|
|
|
|
d.y *= scale;
|
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
var nodes = [selection_border, selection_fill];
|
|
|
|
for (var ii = 0; ii < nodes.length; ii++) {
|
|
|
|
var node = nodes[ii];
|
2013-02-23 15:28:34 +01:00
|
|
|
viewport.appendChild(node);
|
2013-02-23 15:28:23 +01:00
|
|
|
p.setPos(node);
|
|
|
|
d.setDim(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear_selection() {
|
|
|
|
selection_fill && JX.DOM.remove(selection_fill);
|
|
|
|
selection_border && JX.DOM.remove(selection_border);
|
|
|
|
}
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
function load_inline_comments() {
|
|
|
|
var comment_holder = JX.$('mock-inline-comments');
|
|
|
|
JX.DOM.setContent(comment_holder, '');
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var id = active_image.id;
|
|
|
|
var inline_comments_uri = "/pholio/inline/" + id + "/";
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
new JX.Request(inline_comments_uri, function(r) {
|
|
|
|
inline_comments[id] = r;
|
|
|
|
redraw_inlines(id);
|
|
|
|
}).send();
|
|
|
|
}
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-delete',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('inline-delete');
|
|
|
|
e.kill();
|
|
|
|
interrupt_typing();
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.DOM.hide(
|
|
|
|
JX.$(data.phid + "_comment"),
|
|
|
|
JX.$(data.phid + "_fill"),
|
|
|
|
JX.$(data.phid + "_selection"));
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var deleteURI = '/pholio/inline/delete/' + data.id + '/';
|
|
|
|
var del = new JX.Request(deleteURI, function(r) {
|
2013-02-22 15:39:08 +01:00
|
|
|
|
|
|
|
});
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
del.send();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-edit',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('inline-edit');
|
|
|
|
e.kill();
|
|
|
|
|
|
|
|
interrupt_typing();
|
|
|
|
|
|
|
|
var editURI = "/pholio/inline/edit/" + data.id + '/';
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var edit_dialog = new JX.Request(editURI, function(r) {
|
|
|
|
var dialog = JX.$N(
|
|
|
|
'div',
|
|
|
|
{
|
|
|
|
className: 'pholio-edit-inline-popup'
|
|
|
|
},
|
|
|
|
JX.$H(r));
|
|
|
|
|
|
|
|
JX.DOM.setContent(JX.$(data.phid + '_comment'), dialog);
|
2013-02-22 15:39:08 +01:00
|
|
|
});
|
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
edit_dialog.send();
|
2013-02-22 15:39:08 +01:00
|
|
|
});
|
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-edit-cancel',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('inline-edit-cancel');
|
|
|
|
e.kill();
|
|
|
|
load_inline_comment(data.id);
|
|
|
|
});
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-edit-submit',
|
|
|
|
function(e) {
|
|
|
|
var data = e.getNodeData('inline-edit-submit');
|
|
|
|
var editURI = "/pholio/inline/edit/" + data.id + '/';
|
|
|
|
e.kill();
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var edit = new JX.Request(editURI, function(r) {
|
|
|
|
load_inline_comment(data.id);
|
|
|
|
});
|
|
|
|
edit.addData({
|
|
|
|
op: 'update',
|
|
|
|
content: JX.DOM.find(JX.$(data.phid + '_comment'), 'textarea').value
|
|
|
|
});
|
|
|
|
edit.send();
|
|
|
|
});
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-save-cancel',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
|
|
|
interrupt_typing();
|
|
|
|
}
|
|
|
|
);
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'inline-save-submit',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var new_content = JX.DOM.find(
|
|
|
|
JX.$('pholio-new-inline-comment-dialog'),
|
|
|
|
'textarea').value;
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
if (new_content == null || new_content.length == 0) {
|
|
|
|
alert("Empty comment")
|
|
|
|
return;
|
|
|
|
}
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var saveURI = "/pholio/inline/save/";
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var inlineComment = new JX.Request(saveURI, function(r) {
|
2013-02-23 15:28:23 +01:00
|
|
|
if (!inline_comments[active_image.id]) {
|
|
|
|
inline_comments[active_image.id] = [];
|
|
|
|
}
|
|
|
|
inline_comments[active_image.id].push(r);
|
2013-02-22 15:39:08 +01:00
|
|
|
|
2013-02-23 15:28:23 +01:00
|
|
|
interrupt_typing();
|
|
|
|
redraw_inlines(active_image.id);
|
|
|
|
});
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
var commentToAdd = {
|
|
|
|
mockID: config.mockID,
|
|
|
|
op: 'save',
|
|
|
|
imageID: active_image.id,
|
2013-02-23 15:28:23 +01:00
|
|
|
startX: Math.min(drag_begin.x, drag_end.x),
|
|
|
|
startY: Math.min(drag_begin.y, drag_end.y),
|
|
|
|
endX: Math.max(drag_begin.x, drag_end.x),
|
|
|
|
endY: Math.max(drag_begin.y, drag_end.y),
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
comment: new_content
|
|
|
|
};
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
inlineComment.addData(commentToAdd);
|
|
|
|
inlineComment.send();
|
2013-02-22 15:39:08 +01:00
|
|
|
}
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
);
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
function load_inline_comment(id) {
|
|
|
|
var viewInlineURI = '/pholio/inline/view/' + id + '/';
|
|
|
|
var inline_comment = new JX.Request(viewInlineURI, function(r) {
|
|
|
|
JX.DOM.replace(JX.$(r.phid + '_comment'), JX.$H(r.contentHTML));
|
|
|
|
});
|
|
|
|
inline_comment.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
function interrupt_typing() {
|
2013-02-23 15:28:23 +01:00
|
|
|
clear_selection();
|
|
|
|
|
|
|
|
try {
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
JX.DOM.remove(JX.$('pholio-new-inline-comment-dialog'));
|
2013-02-23 15:28:23 +01:00
|
|
|
} catch (x) {
|
|
|
|
// TODO: For now, ignore this.
|
2013-02-22 15:39:08 +01:00
|
|
|
}
|
2013-02-23 15:28:23 +01:00
|
|
|
|
|
|
|
drag_begin = null;
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
}
|
2013-02-22 15:39:08 +01:00
|
|
|
|
Separate loading inline comments from drawing inline comments
Summary:
Currently, we issue one Ajax request to get inline comments, and then draw them when they come back. This has some limitations:
- A user could quickly click image 1, and then click image 2. The request for image 1 may take longer to come back than image 2. In this case, we'd draw the image 2 inlines and then draw the image 1 inlines when that request arrived, resulting in image 2 shown with both image 1 and image 2 comments. This is hard to make happen in a sandbox because the requests are so fast, but prevent it by drawing only the currently visible image's inlines.
- Every time we want to draw inlines, we need to request them -- even if we've already loaded them! This allows us to draw them without reloading them (although we don't actually do this, yet). When we do, it will make it faster to switch between images you've aleady looked at (and we can do other optimizations).
Test Plan: Clicked between images, saw inlines draw correctly. Added a new inline. Moused over inlines.
Reviewers: chad, ljalonen
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D5083
2013-02-23 15:27:45 +01:00
|
|
|
load_inline_comments();
|
2013-02-23 15:28:34 +01:00
|
|
|
|
2013-02-23 15:28:56 +01:00
|
|
|
JX.Stratcom.listen('resize', null, redraw_image);
|
|
|
|
redraw_image();
|
|
|
|
|
2013-01-28 20:18:50 +01:00
|
|
|
});
|