mobileoa-common-modules
Version:
移动办公平台前端公共功能模块
31 lines (28 loc) • 902 B
JavaScript
var angular = require('angular');
require('../modules');
;
/**
* 信息发布Detail页面 缓存服务
*/
var module = angular.module('info.directives');
module.directive('addRight', function($timeout) {
return {
restrict: 'C',
link: function(scope, element, attrs) {
var promise = $timeout(function() {
var rightWidth = element[0].getBoundingClientRect().width,
leftWidth = element[0].previousElementSibling.getBoundingClientRect().width,
screenWidth = screen.width;
if(leftWidth + rightWidth > screenWidth - 20) {
element[0].style.width = '50%';
element[0].style.whiteSpace = 'nowrap';
element[0].style.overflow = 'hidden';
element[0].style.textOverflow = 'ellipsis';
}
}, 16);
scope.$on('$destroy', function() {
$timeout.cancel(promise);
});
}
};
});