mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
feat(sharing): Load widgets from service
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
angular.module('habitrpg').controller("FooterCtrl",
|
||||
['$scope', '$rootScope', 'User', '$http', 'Notification', 'ApiUrl',
|
||||
function($scope, $rootScope, User, $http, Notification, ApiUrl) {
|
||||
['$scope', '$rootScope', 'User', '$http', 'Notification', 'ApiUrl', 'Social',
|
||||
function($scope, $rootScope, User, $http, Notification, ApiUrl, Social) {
|
||||
|
||||
$scope.loadWidgets = Social.loadWidgets;
|
||||
|
||||
if(env.isStaticPage){
|
||||
$scope.languages = env.avalaibleLanguages;
|
||||
@@ -31,20 +33,8 @@ function($scope, $rootScope, User, $http, Notification, ApiUrl) {
|
||||
// Stripe
|
||||
$.getScript('//checkout.stripe.com/v2/checkout.js');
|
||||
|
||||
// Twitter
|
||||
$.getScript('https://platform.twitter.com/widgets.js');
|
||||
|
||||
// Facebook
|
||||
(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
|
||||
// Tumblr
|
||||
$.getScript('https://assets.tumblr.com/share-button.js');
|
||||
// Social sharing buttons
|
||||
loadWidgets();
|
||||
|
||||
/* Google Content Experiments
|
||||
if (window.env.NODE_ENV === 'production') {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared', 'Content', 'Stats',
|
||||
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared, Content, Stats) {
|
||||
habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$http', '$state', 'Guide', 'Shared', 'Content', 'Stats', 'Social',
|
||||
function($rootScope, $scope, $location, User, $http, $state, Guide, Shared, Content, Stats, Social) {
|
||||
$scope.profile = User.user;
|
||||
|
||||
$scope.statCalc = Stats;
|
||||
|
||||
$.getScript('https://platform.twitter.com/widgets.js');
|
||||
$scope.loadWidgets = Social.loadWidgets;
|
||||
|
||||
$scope.hideUserAvatar = function() {
|
||||
$(".userAvatar").hide();
|
||||
|
||||
29
website/public/js/services/socialServices.js
Normal file
29
website/public/js/services/socialServices.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.factory('Social', socialFactory);
|
||||
|
||||
socialFactory.$inject = [];
|
||||
|
||||
function socialFactory() {
|
||||
|
||||
function loadWidgets() {
|
||||
// Facebook
|
||||
(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
|
||||
// Tumblr
|
||||
$.getScript('https://assets.tumblr.com/share-button.js');
|
||||
|
||||
// Twitter
|
||||
$.getScript('https://platform.twitter.com/widgets.js');
|
||||
}
|
||||
}
|
||||
}());
|
||||
@@ -52,6 +52,7 @@
|
||||
"js/services/challengeServices.js",
|
||||
"js/services/paymentServices.js",
|
||||
"js/services/questServices.js",
|
||||
"js/services/socialServices.js",
|
||||
"js/services/statServices.js",
|
||||
|
||||
"js/filters/money.js",
|
||||
|
||||
@@ -16,5 +16,7 @@ script(type='text/ng-template', id='modals/levelUp.html')
|
||||
p=env.t('fullyHealed')
|
||||
br
|
||||
button.btn.btn-primary(ng-click='$close()')=env.t('huzzah')
|
||||
.modal-footer(style='margin-top:0')
|
||||
.modal-footer(style='margin-top:0', ng-init='loadWidgets()')
|
||||
a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I+got+to+Level+{{::user.stats.lvl}}+in+Habitica+by+improving+my+real-life+habits!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/level-up&count=none')=env.t('tweet')
|
||||
.fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/level-up', data-layout='button')
|
||||
a.tumblr-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/level-up', data-notes='none')
|
||||
|
||||
Reference in New Issue
Block a user