Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(style): fix code style issues in ~-attr directive
Browse files Browse the repository at this point in the history
  • Loading branch information
knalli committed Sep 15, 2016
1 parent 7476153 commit 1848bc8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/directive/translate-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ function translateAttrDirective($translate, $rootScope) {
previousAttributes = {};

// Main update translations function
var updateTranslations = function() {
var updateTranslations = function () {
angular.forEach(translateAttr, function (translationId, attributeName) {
if (!translationId) return;
if (!translationId) {
return;
}
previousAttributes[attributeName] = true;

// if translation id starts with '.' and translateNamespace given, prepend namespace
Expand All @@ -94,23 +96,26 @@ function translateAttrDirective($translate, $rootScope) {
delete previousAttributes[attributeName];
}
});
}
};

// Watch for attribute changes
watchAttribute(
scope, attr.translateAttr,
scope,
attr.translateAttr,
function (newValue) { translateAttr = newValue; },
function() { updateTranslations() }
updateTranslations
);
// Watch for value changes
watchAttribute(
scope, attr.translateValues,
scope,
attr.translateValues,
function (newValue) { translateValues = newValue; },
function() { updateTranslations() }
updateTranslations
);

if (attr.translateValues)
if (attr.translateValues) {
scope.$watch(attr.translateValues, updateTranslations, true);
}

// Replaced watcher on translateLanguage with event listener
scope.$on('translateLanguageChanged', updateTranslations);
Expand All @@ -126,7 +131,10 @@ function translateAttrDirective($translate, $rootScope) {
}

function watchAttribute(scope, attribute, valueCallback, changeCallback) {
if (!attribute) return;
'use strict';
if (!attribute) {
return;
}
if (attribute.substr(0, 2) === '::') {
attribute = attribute.substr(2);
} else {
Expand Down

0 comments on commit 1848bc8

Please sign in to comment.