From da0572f1e4f820570bbb8ac5080fa17952a5760f Mon Sep 17 00:00:00 2001 From: VladimirKuleba Date: Wed, 3 Aug 2016 18:16:42 +0300 Subject: [PATCH] Minor fixes Call textfill after view is ready fix & code style fixes --- angular-textfill.js | 57 +++++++++++++++++++++++++++------------------ bower.json | 2 +- 2 files changed, 35 insertions(+), 24 deletions(-) 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 " ],