Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/behavior-oncopy.js
/** | /** | ||||
* @provides javelin-behavior-phabricator-oncopy | * @provides javelin-behavior-phabricator-oncopy | ||||
* @requires javelin-behavior | * @requires javelin-behavior | ||||
* javelin-dom | * javelin-dom | ||||
*/ | */ | ||||
JX.behavior('phabricator-oncopy', function() { | JX.behavior('phabricator-oncopy', function() { | ||||
var copy_root; | var copy_root; | ||||
var copy_mode; | var copy_mode; | ||||
function onstartselect(e) { | function onstartselect(e) { | ||||
var target = e.getTarget(); | var target = e.getTarget(); | ||||
// See T13513. If the user selects multiple lines in a 2-up diff and then | |||||
// clicks "New Inline Comment" in the context menu that pops up, the | |||||
// mousedown causes us to arrive here and remove the "selectable" CSS | |||||
// styles, and creates a flash of selected content across both sides of | |||||
// the diff, which is distracting. To attempt to avoid this, bail out if | |||||
// the user clicked a link. | |||||
if (JX.DOM.isType(target, 'a')) { | |||||
return; | |||||
} | |||||
var container; | var container; | ||||
try { | try { | ||||
// NOTE: For now, all elements with custom oncopy behavior are tables, | // NOTE: For now, all elements with custom oncopy behavior are tables, | ||||
// so this tag selection will hit everything we need it to. | // so this tag selection will hit everything we need it to. | ||||
container = JX.DOM.findAbove(target, 'table', 'intercept-copy'); | container = JX.DOM.findAbove(target, 'table', 'intercept-copy'); | ||||
} catch (ex) { | } catch (ex) { | ||||
container = null; | container = null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 301 Lines • Show Last 20 Lines |