mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Improved hotkey handling
With this commit the hotkey 'd' for diff always shows the global diff. Previously only the last file diff was shown. We changed the implementation so that the first matched href specified by the hotkey is called.
This commit is contained in:
parent
c571e95f61
commit
dfb63d16c2
|
@ -32,6 +32,22 @@ if (!Function.prototype.bind) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String includes polyfill, taken from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
||||||
|
if (!String.prototype.includes) {
|
||||||
|
String.prototype.includes = function(search, start) {
|
||||||
|
'use strict';
|
||||||
|
if (typeof start !== 'number') {
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start + search.length > this.length) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return this.indexOf(search, start) !== -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
* Common functions
|
* Common functions
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
|
@ -870,17 +886,25 @@ Hotkeys.prototype.showHotkeys = function() {
|
||||||
|
|
||||||
Hotkeys.prototype.getSapEvent = function(sSapEvent) {
|
Hotkeys.prototype.getSapEvent = function(sSapEvent) {
|
||||||
|
|
||||||
var result = "";
|
var fnNormalizeSapEventHref = function(sSapEvent, oSapEvent) {
|
||||||
|
if (new RegExp(sSapEvent + "$" ).test(oSapEvent.href)
|
||||||
|
|| (new RegExp(sSapEvent + "\\?" ).test(oSapEvent.href))) {
|
||||||
|
return oSapEvent.href.replace("sapevent:","");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var aSapEvents = document.querySelectorAll('a[href^="sapevent:' + sSapEvent + '"]');
|
var aSapEvents = document.querySelectorAll('a[href^="sapevent:' + sSapEvent + '"]');
|
||||||
|
|
||||||
[].forEach.call(aSapEvents, function(sapEvent){
|
var aFilteredAndNormalizedSapEvents =
|
||||||
if (new RegExp(sSapEvent + "$" ).test(sapEvent.href)
|
[].map.call(aSapEvents, function(oSapEvent){
|
||||||
|| (new RegExp(sSapEvent + "\\?" ).test(sapEvent.href))) {
|
return fnNormalizeSapEventHref(sSapEvent, oSapEvent);
|
||||||
result = sapEvent.href.replace("sapevent:","");
|
})
|
||||||
}
|
.filter(function(elem){
|
||||||
});
|
// remove false positives
|
||||||
|
return (elem && !elem.includes("sapevent:"));
|
||||||
|
});
|
||||||
|
|
||||||
return result;
|
return (aFilteredAndNormalizedSapEvents && aFilteredAndNormalizedSapEvents[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user