mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Add changes related to PR review
This commit is contained in:
@@ -3,64 +3,50 @@ function atTruncateLink (scope, el, attr, ctrl) {
|
||||
let string = attr.string;
|
||||
let maxlength = attr.maxlength;
|
||||
|
||||
truncateController.init(scope, string, maxlength);
|
||||
truncateController.init(el, string, maxlength);
|
||||
}
|
||||
|
||||
function AtTruncateController ($filter, $scope) {
|
||||
function AtTruncateController (strings) {
|
||||
let vm = this;
|
||||
vm.toolTipContent = 'Copy full revision to clipboard.';
|
||||
|
||||
let el;
|
||||
let string;
|
||||
let maxlength;
|
||||
vm.strings = strings;
|
||||
|
||||
vm.init = (scope, _string_, _maxlength_) => {
|
||||
vm.string = _string_;
|
||||
vm.init = (_el_, _string_, _maxlength_) => {
|
||||
el = _el_;
|
||||
string = _string_;
|
||||
maxlength = _maxlength_;
|
||||
vm.truncatedString = $filter('limitTo')(vm.string, maxlength, 0);
|
||||
}
|
||||
|
||||
vm.copy = function() {
|
||||
vm.toolTipContent = 'Copied to clipboard.';
|
||||
|
||||
let textArea = document.createElement("textarea");
|
||||
|
||||
// Place in top-left corner of screen regardless of scroll position.
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.top = 0;
|
||||
textArea.style.left = 0;
|
||||
|
||||
// Ensure it has a small width and height. Setting to 1px / 1em
|
||||
// doesn't work as this gives a negative w/h on some browsers.
|
||||
textArea.style.width = '2em';
|
||||
textArea.style.height = '2em';
|
||||
|
||||
// We don't need padding, reducing the size if it does flash render.
|
||||
textArea.style.padding = 0;
|
||||
|
||||
// Clean up any borders.
|
||||
textArea.style.border = 'none';
|
||||
textArea.style.outline = 'none';
|
||||
textArea.style.boxShadow = 'none';
|
||||
|
||||
// Avoid flash of white box if rendered for any reason.
|
||||
textArea.style.background = 'transparent';
|
||||
|
||||
textArea.value = vm.string;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
|
||||
document.execCommand('copy');
|
||||
|
||||
document.body.removeChild(textArea);
|
||||
vm.truncatedString = string.substring(0, maxlength);
|
||||
};
|
||||
|
||||
vm.tooltip = {
|
||||
popover: {
|
||||
text: vm.strings.components.truncate.DEFAULT,
|
||||
on: 'mouseover',
|
||||
position: 'top',
|
||||
icon: 'fa fa-clone',
|
||||
resetOnExit: true,
|
||||
click: copyToClipboard
|
||||
}
|
||||
};
|
||||
|
||||
function copyToClipboard() {
|
||||
vm.tooltip.popover.text = vm.strings.components.truncate.COPIED;
|
||||
|
||||
let textarea = el[0].getElementsByClassName('at-Truncate-textarea')[0];
|
||||
textarea.value = string;
|
||||
textarea.select();
|
||||
|
||||
document.execCommand('copy');
|
||||
};
|
||||
}
|
||||
|
||||
AtTruncateController.$inject = ['$filter', '$scope' ];
|
||||
|
||||
AtTruncateController.$inject = ['ComponentsStrings'];
|
||||
|
||||
function atTruncate(pathService) {
|
||||
return {
|
||||
restrict: 'EA',
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
templateUrl: pathService.getPartialPath('components/truncate/truncate'),
|
||||
@@ -68,6 +54,7 @@ function atTruncate(pathService) {
|
||||
controllerAs: 'vm',
|
||||
link: atTruncateLink,
|
||||
scope: {
|
||||
state: '=',
|
||||
maxLength: '@',
|
||||
string: '@'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user