forked from HenningM/angular-textfill
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-textfill.js
More file actions
47 lines (41 loc) · 1.23 KB
/
angular-textfill.js
File metadata and controls
47 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(function() {
'use strict';
angular
.module('ngTextFill', [])
.directive('textfill', textfillDirective);
textfillDirective.$inject = ['$timeout'];
function textfillDirective($timeout) {
return {
restrict: 'A',
scope: {
textfill: '@',
textfillOnSuccess: '=',
textfillOnFail: '=',
textfillOnComplete: '='
},
template: '<span>{{textfill}}</span>',
link: link
};
function link(scope, element, attr) {
var container = element;
var options = {
innerTag: attr.innerTag || "span",
debug: attr.debug || false,
minFontPixels: parseInt(attr.minFontPixels, 10) || 4,
maxFontPixels: parseInt(attr.maxFontPixels, 10) || 40,
widthOnly: attr.widthOnly || false,
explicitHeight: attr.explicitHeight || null,
explicitWidth: attr.explicitWidth || null,
success: scope.textfillOnSuccess || null,
fail: scope.textfillOnFail || null,
complete: scope.textfillOnComplete || null
};
$timeout(function() {
container.textfill(options);
});
scope.$watch('textfill', function () {
container.textfill(options);
});
}
}
})(window, window.angular);