Page MenuHomestyx hydra

No OneTemporary

diff --git a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
index 90357c6252..a49293f343 100644
--- a/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
+++ b/webroot/rsrc/js/application/differential/behavior-dropdown-menus.js
@@ -1,143 +1,146 @@
/**
* @provides javelin-behavior-differential-dropdown-menus
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-stratcom
* phabricator-dropdown-menu
* phabricator-menu-item
*/
JX.behavior('differential-dropdown-menus', function(config) {
function show_more(container) {
var nodes = JX.DOM.scry(container, 'tr', 'context-target');
for (var ii = 0; ii < nodes.length; ii++) {
var show = JX.DOM.scry(nodes[ii], 'a', 'show-more');
for (var jj = 0; jj < show.length; jj++) {
if (JX.Stratcom.getData(show[jj]).type != 'all') {
continue;
}
var event_data = {
context : nodes[ii],
show : show[jj]
};
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
}
}
}
function build_menu(button, data) {
function link_to(name, uri) {
var item = new JX.PhabricatorMenuItem(
name,
JX.bind(null, window.open, uri),
uri);
item.setDisabled(!uri);
return item;
}
var reveal_item = new JX.PhabricatorMenuItem('', function () {
show_more(JX.$(data.containerID));
});
var diffusion_item;
if (data.diffusionURI) {
// Show this only if we have a link, since when this appears in Diffusion
// it is otherwise potentially confusing.
diffusion_item = link_to('Browse in Diffusion', data.diffusionURI);
}
var menu = new JX.PhabricatorDropdownMenu(buttons[ii])
.addItem(reveal_item);
var visible_item = new JX.PhabricatorMenuItem('', function () {
JX.Stratcom.invoke('differential-toggle-file', null, {
diff: JX.DOM.scry(JX.$(data.containerID), 'table', 'differential-diff'),
});
});
menu.addItem(visible_item);
if (diffusion_item) {
menu.addItem(diffusion_item);
}
menu.addItem(link_to('View Standalone', data.standaloneURI));
if (data.leftURI) {
menu.addItem(link_to('Show Raw File (Left)', data.leftURI));
}
if (data.rightURI) {
menu.addItem(link_to('Show Raw File (Right)', data.rightURI));
}
if (data.editor) {
menu.addItem(new JX.PhabricatorMenuItem(
'Open in Editor',
JX.bind(null, location.assign, data.editor), // Open in the same window.
data.editor));
}
if (data.editorConfigure) {
menu.addItem(link_to('Configure Editor', data.editorConfigure));
}
menu.listen(
'open',
function() {
// When the user opens the menu, check if there are any "Show More"
// links in the changeset body. If there aren't, disable the "Show
// Entire File" menu item since it won't change anything.
var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more');
if (nodes.length) {
reveal_item.setDisabled(false);
reveal_item.setName('Show Entire File');
} else {
reveal_item.setDisabled(true);
reveal_item.setName('Entire File Shown');
}
+ visible_item.setDisabled(true);
+ visible_item.setName("Can't Toggle Unloaded File");
var diffs = JX.DOM.scry(JX.$(data.containerID),
'table', 'differential-diff');
if (diffs.length > 1) {
JX.$E(
'More than one node with sigil "differential-diff" was found in "'+
data.containerID+'."');
} else if (diffs.length == 1) {
diff = diffs[0];
+ visible_item.setDisabled(false);
if (JX.Stratcom.getData(diff).hidden) {
visible_item.setName('Expand File');
} else {
visible_item.setName('Collapse File');
}
} else {
// Do nothing when there is no diff shown in the table. For example,
// the file is binary.
}
});
}
var buttons = JX.DOM.scry(window.document, 'a', 'differential-view-options');
for (var ii = 0; ii < buttons.length; ii++) {
build_menu(buttons[ii], JX.Stratcom.getData(buttons[ii]));
}
JX.Stratcom.listen(
'click',
'differential-reveal-all',
function(e) {
var containers = JX.DOM.scry(
JX.$('differential-review-stage'),
'div',
'differential-changeset');
for (var i=0; i < containers.length; i++) {
show_more(containers[i]);
}
e.kill();
});
});
diff --git a/webroot/rsrc/js/application/differential/behavior-toggle-files.js b/webroot/rsrc/js/application/differential/behavior-toggle-files.js
index 4d623b35d4..4f01c32055 100644
--- a/webroot/rsrc/js/application/differential/behavior-toggle-files.js
+++ b/webroot/rsrc/js/application/differential/behavior-toggle-files.js
@@ -1,62 +1,85 @@
/**
* @provides javelin-behavior-differential-toggle-files
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
* phabricator-keyboard-shortcut
*/
JX.behavior('differential-toggle-files', function(config) {
JX.Stratcom.listen(
'differential-toggle-file',
null,
function(e) {
if (e.getData().diff.length != 1) {
return;
}
var diff = e.getData().diff[0],
data = JX.Stratcom.getData(diff);
if(data.hidden) {
data.hidden = false;
JX.DOM.show(diff);
} else {
data.hidden = true;
JX.DOM.hide(diff);
}
JX.Stratcom.invoke('differential-toggle-file-toggled');
});
JX.Stratcom.listen(
'differential-toggle-file-request',
null,
function(e) {
var elt = e.getData().element;
while (elt !== document.body) {
- if (JX.Stratcom.hasSigil(elt, 'differential-diff') &&
- JX.Stratcom.getData(elt).hidden) {
- JX.Stratcom.invoke('differential-toggle-file', null, {
- diff: [ elt ],
- });
+ if (JX.Stratcom.hasSigil(elt, 'differential-changeset')) {
+ var diffs = JX.DOM.scry(elt, 'table', 'differential-diff');
+ for (var i = 0; i < diffs.length; ++i) {
+ if (JX.Stratcom.getData(diffs[i]).hidden) {
+ JX.Stratcom.invoke('differential-toggle-file', null, {
+ diff: [ diffs[i] ],
+ });
+ }
+ }
return;
}
elt = elt.parentNode;
}
});
JX.Stratcom.listen(
- 'hashchange',
- null,
+ 'click',
+ 'tag:a',
function(e) {
- var id = window.location.hash;
- if (!id.match(/^#/)) {
+ var link = e.getNode('tag:a');
+ var id = link.getAttribute('href');
+ if (!id.match(/^#.+/)) {
return;
}
+ // The target may have either a matching name or a matching id.
+ var target;
+ try {
+ target = JX.$(id.substr(1));
+ } catch(err) {
+ var named = document.getElementsByName(id.substr(1));
+ var matches = [];
+ for (var i = 0; i < named.length; ++i) {
+ if (named[i].tagName.toLowerCase() == 'a') {
+ matches.push(named[i]);
+ }
+ }
+ if (matches.length == 1) {
+ target = matches[0];
+ } else {
+ return;
+ }
+ }
JX.Stratcom.invoke('differential-toggle-file-request', null, {
- element: JX.$(id.substr(1)),
+ element: target,
});
// This event is processed after the hash has changed, so it doesn't
// automatically jump there like we want.
- JX.DOM.scrollTo(JX.$(id.substr(1)));
+ JX.DOM.scrollTo(target);
});
});

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 1, 9:07 AM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
430331
Default Alt Text
(7 KB)

Event Timeline