From ae1217821acc6b11483dc91f109383703c782d01 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 11 Oct 2015 13:13:13 +0200 Subject: [PATCH] Check if label exist before add spaces --- src/coffee/toggle_switch.coffee | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/coffee/toggle_switch.coffee b/src/coffee/toggle_switch.coffee index b160fa8..3ef3ab0 100644 --- a/src/coffee/toggle_switch.coffee +++ b/src/coffee/toggle_switch.coffee @@ -131,25 +131,31 @@ angular.module('sc-toggle-switch', ['stcs-templates']) $scope.knobLabelStr = angular.copy($scope.knobLabel) if ($scope.leftLabel.length == max) - while ($scope.rightLabelStr.length < max) - $scope.rightLabelStr = '\u00a0' + $scope.rightLabelStr + '\u00a0' + if $scope.rightLabelStr + while ($scope.rightLabelStr.length < max) + $scope.rightLabelStr = '\u00a0' + $scope.rightLabelStr + '\u00a0' - while ($scope.knobLabelStr.length < max) - $scope.knobLabelStr = '\u00a0' + $scope.knobLabelStr + '\u00a0' + if $scope.knobLabelStr + while ($scope.knobLabelStr.length < max) + $scope.knobLabelStr = '\u00a0' + $scope.knobLabelStr + '\u00a0' else if ($scope.rightLabel.length == max) - while ($scope.leftLabelStr.length < max) - $scope.leftLabelStr = '\u00a0' + $scope.leftLabelStr + '\u00a0' + if $scope.leftLabelStr + while ($scope.leftLabelStr.length < max) + $scope.leftLabelStr = '\u00a0' + $scope.leftLabelStr + '\u00a0' - while ($scope.knobLabelStr.length < max) - $scope.knobLabelStr = '\u00a0' + $scope.knobLabelStr + '\u00a0' + if $scope.knobLabelStr + while ($scope.knobLabelStr.length < max) + $scope.knobLabelStr = '\u00a0' + $scope.knobLabelStr + '\u00a0' else - while ($scope.leftLabelStr.length < max) - $scope.leftLabelStr = '\u00a0' + $scope.leftLabelStr + '\u00a0' + if $scope.leftLabelStr + while ($scope.leftLabelStr.length < max) + $scope.leftLabelStr = '\u00a0' + $scope.leftLabelStr + '\u00a0' - while ($scope.rightLabelStr.length < max) - $scope.rightLabelStr = '\u00a0' + $scope.rightLabelStr + '\u00a0' + if $scope.rightLabelStr + while ($scope.rightLabelStr.length < max) + $scope.rightLabelStr = '\u00a0' + $scope.rightLabelStr + '\u00a0' $scope.$watch 'leftLabel', ->