diff --git a/angular-textfill.js b/angular-textfill.js
index 975c591..74e1c03 100644
--- a/angular-textfill.js
+++ b/angular-textfill.js
@@ -1,7 +1,13 @@
-'use strict'
+(function() {
+ 'use strict';
-angular.module('ngTextFill', [])
- .directive('textfill', ['$timeout', function ($timeout) {
+ angular
+ .module('ngTextFill', [])
+ .directive('textfill', textfillDirective);
+
+ textfillDirective.$inject = ['$timeout'];
+
+ function textfillDirective($timeout) {
return {
restrict: 'A',
scope: {
@@ -11,26 +17,31 @@ angular.module('ngTextFill', [])
textfillOnComplete: '='
},
template: '{{textfill}}',
- link: function (scope, element, attr) {
- var container = element,
- options = {
- innerTag: attr.innerTag || "span",
- debug: attr.debug || false,
- minFontPixels: parseInt(attr.minFontPixels) || 4,
- maxFontPixels: parseInt(attr.maxFontPixels) || 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
- };
+ 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);
- });
- }
- };
- }]);
+ scope.$watch('textfill', function () {
+ container.textfill(options);
+ });
+ }
+ }
+})(window, window.angular);
diff --git a/bower.json b/bower.json
index 40b7eef..ef64b01 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "angular-textfill",
- "version": "0.1.4",
+ "version": "0.1.5",
"authors": [
"Henning Morud "
],