1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00
phorge-phorge/webroot/rsrc/js/application/differential/behavior-user-select.js
vrana 0732f2f9dd Hide selection to provide a visual cue about clipboard JS magic in Differential
Summary: Inspired by D2242.

Test Plan:
Select text in left pane.
Select text in right pane.
Select all.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2249
2012-04-24 18:53:48 -07:00

32 lines
740 B
JavaScript

/**
* @provides javelin-behavior-differential-user-select
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
*/
JX.behavior('differential-user-select', function() {
var unselectable;
function isOnRight(node) {
return node.parentNode.firstChild != node.previousSibling;
}
JX.Stratcom.listen(
'mousedown',
null,
function(e) {
var key = 'differential-unselectable';
if (unselectable) {
JX.DOM.alterClass(unselectable, key, false);
}
var diff = e.getNode('differential-diff');
var td = e.getNode('tag:td');
if (diff && td && isOnRight(td)) {
unselectable = diff;
JX.DOM.alterClass(diff, key, true);
}
});
});