mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-16 10:30:56 +01:00
87a4940924
Summary: Ref T12733. When creating a new comment, the objective could appear to far up in the scrollbar because we were anchoring it to an invisible row. Instead, anchor to the "edit" row while editing. Test Plan: Created a new comment at the very top of a file, saw "File, Star" icons instead of "Star, File". Reviewers: chad Reviewed By: chad Maniphest Tasks: T12733 Differential Revision: https://secure.phabricator.com/D17978
123 lines
2.3 KiB
JavaScript
123 lines
2.3 KiB
JavaScript
/**
|
|
* @provides phabricator-scroll-objective
|
|
* @requires javelin-dom
|
|
* javelin-util
|
|
* javelin-stratcom
|
|
* javelin-install
|
|
* javelin-workflow
|
|
* @javelin
|
|
*/
|
|
|
|
|
|
JX.install('ScrollObjective', {
|
|
|
|
construct : function() {
|
|
var node = this.getNode();
|
|
|
|
var onclick = JX.bind(this, this._onclick);
|
|
JX.DOM.listen(node, 'click', null, onclick);
|
|
},
|
|
|
|
members: {
|
|
_list: null,
|
|
|
|
_node: null,
|
|
_anchor: null,
|
|
|
|
_visible: false,
|
|
_callback: false,
|
|
|
|
getNode: function() {
|
|
if (!this._node) {
|
|
var attributes = {
|
|
className: 'scroll-objective'
|
|
};
|
|
|
|
var content = this._getIconObject().getNode();
|
|
|
|
var node = JX.$N('div', attributes, content);
|
|
|
|
this._node = node;
|
|
}
|
|
|
|
return this._node;
|
|
},
|
|
|
|
setCallback: function(callback) {
|
|
this._callback = callback;
|
|
return this;
|
|
},
|
|
|
|
setObjectiveList: function(list) {
|
|
this._list = list;
|
|
return this;
|
|
},
|
|
|
|
_getIconObject: function() {
|
|
if (!this._iconObject) {
|
|
this._iconObject = new JX.PHUIXIconView();
|
|
}
|
|
return this._iconObject;
|
|
},
|
|
|
|
_onclick: function(e) {
|
|
(this._callback && this._callback(e));
|
|
|
|
if (e.getPrevented()) {
|
|
return;
|
|
}
|
|
|
|
e.kill();
|
|
|
|
// This is magic to account for the banner, and should probably be made
|
|
// less hard-coded.
|
|
var buffer = 48;
|
|
|
|
JX.DOM.scrollToPosition(null, JX.$V(this.getAnchor()).y - buffer);
|
|
},
|
|
|
|
setAnchor: function(node) {
|
|
this._anchor = node;
|
|
return this;
|
|
},
|
|
|
|
getAnchor: function() {
|
|
return this._anchor;
|
|
},
|
|
|
|
setIcon: function(icon) {
|
|
this._getIconObject().setIcon(icon);
|
|
return this;
|
|
},
|
|
|
|
setColor: function(color) {
|
|
this._getIconObject().setColor(color);
|
|
return this;
|
|
},
|
|
|
|
setTooltip: function(tip) {
|
|
var node = this._getIconObject().getNode();
|
|
JX.Stratcom.addSigil(node, 'has-tooltip');
|
|
JX.Stratcom.getData(node).tip = tip;
|
|
JX.Stratcom.getData(node).align = 'W';
|
|
JX.Stratcom.getData(node).size = 'auto';
|
|
return this;
|
|
},
|
|
|
|
show: function() {
|
|
this._visible = true;
|
|
return this;
|
|
},
|
|
|
|
hide: function() {
|
|
this._visible = false;
|
|
return this;
|
|
},
|
|
|
|
isVisible: function() {
|
|
return this._visible;
|
|
}
|
|
|
|
}
|
|
|
|
});
|