1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/assets/javascripts/directives/twitter.js.erb
2020-01-22 12:43:08 +01:00

44 lines
1.2 KiB
Plaintext

/* global twitterFetcher */
/**
* This directive will show the last tweet.
* Usage: <twitter />
*/
Application.Directives.directive('twitter', ['Setting',
function (Setting) {
return ({
restrict: 'E',
templateUrl: '<%= asset_path "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();
}
});
}
]);