mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Added a css based truncate directive
This commit is contained in:
parent
efda0be1f0
commit
56ce853a1d
1 changed files with 37 additions and 0 deletions
37
src/kibana/directives/css_truncate.js
Normal file
37
src/kibana/directives/css_truncate.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
define(function (require) {
|
||||
var module = require('modules').get('kibana/directives');
|
||||
var $ = require('jquery');
|
||||
var _ = require('lodash');
|
||||
|
||||
module.directive('cssTruncate', function ($compile) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
link: function ($scope, $elem, attrs) {
|
||||
|
||||
$elem.css({
|
||||
overflow: 'hidden',
|
||||
'white-space': 'nowrap',
|
||||
'text-overflow': 'ellipsis',
|
||||
'word-break': 'break-all',
|
||||
});
|
||||
|
||||
if (!_.isUndefined(attrs.cssTruncateExpandable)) {
|
||||
$elem.css({'cursor': 'pointer'});
|
||||
$elem.bind('click', function () {
|
||||
if ($elem.css('white-space') !== 'normal') {
|
||||
$elem.css({'white-space': 'normal'});
|
||||
} else {
|
||||
$elem.css({'white-space': 'nowrap'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
$elem.unbind('click');
|
||||
$elem.unbind('mouseenter');
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue