Skip to content

Commit bd4ce35

Browse files
author
epriestley
committed
Fix inline highlight behaviors for Pholio
Summary: Some recent CSS change tweaked these out a bit. They were also sort of weird looking after fixing the double-draw thing: - Make them work properly; - make the implementation a bit simpler; - make them clearer visually. Also fix a bug where "border" and "fill" were accidentally reversed. Test Plan: {F34625} (The highlight on the reticle is a little hard to pick out in the screenshot, but very obvious in practice.) Reviewers: chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D5228
1 parent fdc30fc commit bd4ce35

File tree

4 files changed

+99
-86
lines changed

4 files changed

+99
-86
lines changed

src/__celerity_resource_map__.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@
18911891
),
18921892
'javelin-behavior-pholio-mock-view' =>
18931893
array(
1894-
'uri' => '/res/57c05b5f/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
1894+
'uri' => '/res/02f1a38f/rsrc/js/application/pholio/behavior-pholio-mock-view.js',
18951895
'type' => 'js',
18961896
'requires' =>
18971897
array(
@@ -3238,7 +3238,7 @@
32383238
),
32393239
'pholio-css' =>
32403240
array(
3241-
'uri' => '/res/217df4c4/rsrc/css/application/pholio/pholio.css',
3241+
'uri' => '/res/580babaa/rsrc/css/application/pholio/pholio.css',
32423242
'type' => 'css',
32433243
'requires' =>
32443244
array(
@@ -3247,7 +3247,7 @@
32473247
),
32483248
'pholio-inline-comments-css' =>
32493249
array(
3250-
'uri' => '/res/918836a4/rsrc/css/application/pholio/pholio-inline-comments.css',
3250+
'uri' => '/res/be86f544/rsrc/css/application/pholio/pholio-inline-comments.css',
32513251
'type' => 'css',
32523252
'requires' =>
32533253
array(

webroot/rsrc/css/application/pholio/pholio-inline-comments.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,12 @@
7979
font-weight: normal;
8080
color: #2178db;
8181
}
82+
83+
.device-desktop .pholio-mock-inline-comment-highlight.pholio-mock-select-fill {
84+
opacity: 0.5;
85+
}
86+
87+
.device-desktop .pholio-mock-inline-comment-highlight.pholio-inline-comment {
88+
background: #555555;
89+
border-color: #aaaaaa;
90+
}

webroot/rsrc/css/application/pholio/pholio.css

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
cursor: crosshair;
4646
}
4747

48-
.pholio-mock-select-border {
48+
.pholio-mock-select-fill {
4949
position: absolute;
5050
background: #ffffff;
5151
opacity: 0.25;
5252
box-sizing: border-box;
5353
border: 1px solid #000000;
5454
}
5555

56-
.pholio-mock-select-fill {
56+
.pholio-mock-select-border {
5757
position: absolute;
5858
border: 1px dashed #ffffff;
5959
box-sizing: border-box;
@@ -80,11 +80,6 @@
8080
margin-bottom: 4px;
8181
}
8282

83-
.pholio-mock-inline-comment-highlight {
84-
background-color: #222;
85-
border-color: #555;
86-
}
87-
8883
.pholio-image-loading img {
8984
opacity: 0.50;
9085
}

webroot/rsrc/js/application/pholio/behavior-pholio-mock-view.js

Lines changed: 85 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ JX.behavior('pholio-mock-view', function(config) {
3232
var loading = false;
3333
var stageElement = JX.$(config.panelID);
3434
var viewElement = JX.$(config.viewportID);
35+
var gutterElement = JX.$('mock-inline-comments');
3536
var reticles = [];
37+
var cards = [];
38+
var inline_phid_map = {};
3639

3740
function begin_load() {
3841
if (loading) {
3942
return;
4043
}
4144
loading = true;
42-
clear_reticles();
45+
clear_stage();
4346
draw_loading();
4447
}
4548

@@ -55,23 +58,70 @@ JX.behavior('pholio-mock-view', function(config) {
5558
JX.DOM.alterClass(stageElement, 'pholio-image-loading', loading);
5659
}
5760

58-
function add_reticle(reticle) {
61+
function add_inline_node(node, phid) {
62+
inline_phid_map[phid] = (inline_phid_map[phid] || []);
63+
inline_phid_map[phid].push(node);
64+
}
65+
66+
function add_reticle(reticle, phid) {
67+
mark_ref(reticle, phid);
68+
5969
reticles.push(reticle);
70+
add_inline_node(reticle, phid);
71+
6072
viewElement.appendChild(reticle);
6173
}
6274

63-
function clear_reticles() {
75+
function clear_stage() {
6476
for (var ii = 0; ii < reticles.length; ii++) {
6577
JX.DOM.remove(reticles[ii]);
6678
}
79+
for (var ii = 0; ii < cards.length; ii++) {
80+
JX.DOM.remove(cards[ii]);
81+
}
6782
reticles = [];
83+
cards = [];
84+
inline_phid_map = {};
85+
}
86+
87+
function highlight_inline(phid, show) {
88+
var nodes = inline_phid_map[phid] || [];
89+
var cls = 'pholio-mock-inline-comment-highlight';
90+
for (var ii = 0; ii < nodes.length; ii++) {
91+
JX.DOM.alterClass(nodes[ii], cls, show);
92+
}
93+
}
94+
95+
function remove_inline(phid) {
96+
var nodes = inline_phid_map[phid] || [];
97+
for (var ii = 0; ii < nodes.length; ii++) {
98+
JX.DOM.remove(nodes[ii]);
99+
}
100+
delete inline_phid_map[phid];
101+
}
102+
103+
function mark_ref(node, phid) {
104+
JX.Stratcom.addSigil(node, 'pholio-inline-ref');
105+
JX.Stratcom.addData(node, {phid: phid});
106+
}
107+
108+
function add_card(card, phid) {
109+
mark_ref(card, phid);
110+
111+
cards.push(card);
112+
add_inline_node(card, phid);
113+
114+
gutterElement.appendChild(card);
68115
}
69116

70117
return {
71118
beginLoad: begin_load,
72119
endLoad: end_load,
73120
addReticle: add_reticle,
74-
clearReticles: clear_reticles
121+
clearStage: clear_stage,
122+
highlightInline: highlight_inline,
123+
removeInline: remove_inline,
124+
addCard: add_card
75125
};
76126
})();
77127

@@ -223,31 +273,12 @@ JX.behavior('pholio-mock-view', function(config) {
223273

224274
JX.Stratcom.listen(
225275
['mouseover', 'mouseout'],
226-
'image_selection',
227-
function(e) {
228-
var data = e.getNodeData('image_selection');
229-
var comment = JX.$(data.phid + "_comment");
230-
var highlight = (e.getType() == 'mouseover');
231-
232-
JX.DOM.alterClass(
233-
comment,
234-
'pholio-mock-inline-comment-highlight',
235-
highlight);
236-
});
237-
238-
JX.Stratcom.listen(
239-
['mouseover', 'mouseout'],
240-
'inline_comment',
276+
'pholio-inline-ref',
241277
function(e) {
242-
var data = e.getNodeData('inline_comment');
243-
var selection = JX.$(data.phid + "_selection");
244-
var highlight = (e.getType() == 'mouseover');
245-
246-
JX.DOM.alterClass(
247-
selection,
248-
'pholio-mock-inline-comment-highlight',
249-
highlight);
250-
});
278+
var phid = e.getNodeData('pholio-inline-ref').phid;
279+
var show = (e.getType() == 'mouseover');
280+
stage.highlightInline(phid, show);
281+
});
251282

252283
JX.Stratcom.listen(
253284
'mouseup',
@@ -289,10 +320,9 @@ JX.behavior('pholio-mock-view', function(config) {
289320
return;
290321
}
291322

323+
stage.clearStage();
292324
var comment_holder = JX.$('mock-inline-comments');
293325
JX.DOM.setContent(comment_holder, render_image_info(active_image));
294-
stage.clearReticles();
295-
296326

297327
var inlines = inline_comments[active_image.id];
298328
if (!inlines || !inlines.length) {
@@ -301,49 +331,24 @@ JX.behavior('pholio-mock-view', function(config) {
301331

302332
for (var ii = 0; ii < inlines.length; ii++) {
303333
var inline = inlines[ii];
304-
JX.DOM.appendContent(comment_holder, JX.$H(inline.contentHTML));
334+
var card = JX.$H(inline.contentHTML).getFragment().firstChild;
335+
336+
stage.addCard(card, inline.phid);
305337

306338
if (!active_image.tag) {
307339
// The image itself hasn't loaded yet, so we can't draw the inline
308340
// reticles.
309341
continue;
310342
}
311343

312-
var inlineSelection = JX.$N(
313-
'div',
314-
{
315-
id: inline.phid + "_selection",
316-
className: 'pholio-mock-select-border'
317-
});
318-
319-
JX.Stratcom.addData(
320-
inlineSelection,
321-
{phid: inline.phid});
322-
323-
JX.Stratcom.addSigil(inlineSelection, "image_selection");
324-
325-
stage.addReticle(inlineSelection);
326-
327-
position_inline_rectangle(inline, inlineSelection);
344+
var inline_selection = render_reticle_fill();
345+
stage.addReticle(inline_selection, inline.phid);
346+
position_inline_rectangle(inline, inline_selection);
328347

329348
if (!inline.transactionphid) {
330-
331-
var inlineDraft = JX.$N(
332-
'div',
333-
{
334-
className: 'pholio-mock-select-fill',
335-
id: inline.phid + "_fill"
336-
});
337-
338-
position_inline_rectangle(inline, inlineDraft);
339-
340-
JX.Stratcom.addData(
341-
inlineDraft,
342-
{phid: inline.phid});
343-
344-
JX.Stratcom.addSigil(inlineDraft, "image_selection");
345-
346-
stage.addReticle(inlineDraft);
349+
var inline_draft = render_reticle_border();
350+
stage.addReticle(inline_draft, inline.phid);
351+
position_inline_rectangle(inline, inline_draft);
347352
}
348353
}
349354
}
@@ -376,13 +381,8 @@ JX.behavior('pholio-mock-view', function(config) {
376381
}
377382

378383
function redraw_selection() {
379-
selection_border = selection_border || JX.$N(
380-
'div',
381-
{className: 'pholio-mock-select-border'});
382-
383-
selection_fill = selection_fill || JX.$N(
384-
'div',
385-
{className: 'pholio-mock-select-fill'});
384+
selection_border = selection_border || render_reticle_border();
385+
selection_fill = selection_fill || render_reticle_fill();
386386

387387
var p = JX.$V(
388388
Math.min(drag_begin.x, drag_end.x),
@@ -399,7 +399,7 @@ JX.behavior('pholio-mock-view', function(config) {
399399
d.x *= scale;
400400
d.y *= scale;
401401

402-
var nodes = [selection_border, selection_fill];
402+
var nodes = [selection_fill, selection_border];
403403
for (var ii = 0; ii < nodes.length; ii++) {
404404
var node = nodes[ii];
405405
viewport.appendChild(node);
@@ -431,10 +431,7 @@ JX.behavior('pholio-mock-view', function(config) {
431431
e.kill();
432432
interrupt_typing();
433433

434-
JX.DOM.hide(
435-
JX.$(data.phid + "_comment"),
436-
JX.$(data.phid + "_fill"),
437-
JX.$(data.phid + "_selection"));
434+
stage.removeInline(data.phid);
438435

439436
var deleteURI = '/pholio/inline/delete/' + data.id + '/';
440437
var del = new JX.Request(deleteURI, function(r) {
@@ -630,4 +627,16 @@ JX.behavior('pholio-mock-view', function(config) {
630627
return info;
631628
}
632629

630+
function render_reticle_border() {
631+
return JX.$N(
632+
'div',
633+
{className: 'pholio-mock-select-border'});
634+
}
635+
636+
function render_reticle_fill() {
637+
return JX.$N(
638+
'div',
639+
{className: 'pholio-mock-select-fill'});
640+
}
641+
633642
});

0 commit comments

Comments
 (0)