1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-10 00:46:15 +01:00
fab-manager/app/frontend/src/javascript/directives/home/twitter.js

44 lines
1.2 KiB
JavaScript

/* global twitterFetcher */
/**
* This directive will show the last tweet.
* Usage: <twitter />
*/
Application.Directives.directive('twitter', ['Setting',
function (Setting) {
return ({
restrict: 'E',
templateUrl: '/home/twitter.html',
link ($scope, element, attributes) {
// Twitter username
$scope.twitterName = null;
// constructor
const initialize = function () {
Setting.get({ name: 'twitter_name' }, function (data) {
$scope.twitterName = data.setting.value;
if ($scope.twitterName) {
const configProfile = {
'profile': { 'screenName': $scope.twitterName },
'domId': 'twitter',
'maxTweets': 1,
'enableLinks': true,
'showUser': false,
'showTime': true,
'showImages': false,
'showRetweet': true,
'showInteraction': false,
'lang': Fablab.locale
};
twitterFetcher.fetch(configProfile);
}
})
};
// !!! MUST BE CALLED AT THE END of the directive
return initialize();
}
});
}
]);