diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index ca8bac7..35979a4 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -88,6 +88,8 @@ contextMenuItemsForElement:(NSDictionary *)element NSLog(@"Could not find selected ref!"); return defaultMenuItems; } + if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) + return [historyController menuItemsForPaths:[NSArray arrayWithObject:[[[node attributes] getNamedItem:@"representedFile"] value]]]; node = [node parentNode]; } diff --git a/html/views/history/history.js b/html/views/history/history.js index 087f802..b5270cd 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -202,26 +202,32 @@ var showDiff = function() { var link = document.createElement("a"); link.setAttribute("href", "#" + id); p.appendChild(link); - var buttonType = "" + var buttonType = ""; + var finalFile = ""; if (name1 == name2) { buttonType = "changed" - link.appendChild(document.createTextNode(name1)); + finalFile = name1; if (mode_change) p.appendChild(document.createTextNode(" mode " + old_mode + " -> " + new_mode)); } else if (name1 == "/dev/null") { buttonType = "created"; - link.appendChild(document.createTextNode(name2)); + finalFile = name2; } else if (name2 == "/dev/null") { buttonType = "deleted"; - link.appendChild(document.createTextNode(name1)); + finalFile = name1; } else { buttonType = "renamed"; - link.appendChild(document.createTextNode(name2)); + finalFile = name2; p.insertBefore(document.createTextNode(name1 + " -> "), link); } + + link.appendChild(document.createTextNode(finalFile)); + button.setAttribute("representedFile", finalFile); + link.setAttribute("representedFile", finalFile); + button.setAttribute("class", "button " + buttonType); button.appendChild(document.createTextNode(buttonType)); $("files").appendChild(button);