diff --git a/website/public/js/controllers/notificationCtrl.js b/website/public/js/controllers/notificationCtrl.js index bbaf4925a8..df9cdfc8ec 100644 --- a/website/public/js/controllers/notificationCtrl.js +++ b/website/public/js/controllers/notificationCtrl.js @@ -61,7 +61,11 @@ habitrpg.controller('NotificationCtrl', }); $rootScope.$watch('user.stats.lvl', function(after, before) { - if ((after === before) || (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest'))) return; + if (after === before) return; + if (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest')) return; + if (after === 3) return; // Drop system unlock. FIXME can we do this without hardcoding? + if (after === 50) return; // Orb of Rebirth unlock FIXME as above + if (!User.user.flags.classSelected && User.user.stats.lvl >= 10) return $rootScope.openModal('chooseClass', {controller:'UserCtrl', keyboard:false, backdrop:'static'}); if (after > before) { Notification.lvl(); $rootScope.playSound('Level_Up'); @@ -157,13 +161,6 @@ habitrpg.controller('NotificationCtrl', $rootScope.openModal('achievements/contributor'); }); - // Classes modal - $rootScope.$watch('!user.flags.classSelected && user.stats.lvl >= 10', function(after, before){ - if(after){ - $rootScope.openModal('chooseClass', {controller:'UserCtrl', keyboard:false, backdrop:'static'}); - } - }); - // Completed quest modal $scope.$watch('user.party.quest.completed', function(after, before){ if (!after) return; diff --git a/website/public/js/controllers/partyCtrl.js b/website/public/js/controllers/partyCtrl.js index 40af2b7e61..cb53ac3eb5 100644 --- a/website/public/js/controllers/partyCtrl.js +++ b/website/public/js/controllers/partyCtrl.js @@ -1,12 +1,13 @@ 'use strict'; -habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests', - function($rootScope,$scope,Groups,Chat,User,Challenges,$state,$compile,Analytics,Quests) { +habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','Challenges','$state','$compile','Analytics','Quests','Social', + function($rootScope,$scope,Groups,Chat,User,Challenges,$state,$compile,Analytics,Quests,Social) { $scope.type = 'party'; $scope.text = window.env.t('party'); $scope.group = $rootScope.party = Groups.party(); $scope.newGroup = new Groups.Group({type:'party'}); $scope.inviteOrStartParty = Groups.inviteOrStartParty; + $scope.loadWidgets = Social.loadWidgets; if ($state.is('options.social.party')) { $scope.group.$syncParty(); // Sync party automatically when navigating to party page diff --git a/website/public/js/services/socialServices.js b/website/public/js/services/socialServices.js index e4738eaa35..23ac719118 100644 --- a/website/public/js/services/socialServices.js +++ b/website/public/js/services/socialServices.js @@ -11,19 +11,27 @@ 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')); + if (typeof FB === 'undefined') { + (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')); + } else { + FB.XFBML.parse(); // http://stackoverflow.com/questions/29133563/ + } // Tumblr $.getScript('https://assets.tumblr.com/share-button.js'); // Twitter - $.getScript('https://platform.twitter.com/widgets.js'); + if (typeof twttr === 'undefined') { + $.getScript('https://platform.twitter.com/widgets.js'); + } else { + twttr.widgets.load(); + } } return { diff --git a/website/public/manifest.json b/website/public/manifest.json index 4ebc3a3e66..5a96670531 100644 --- a/website/public/manifest.json +++ b/website/public/manifest.json @@ -123,6 +123,7 @@ "js/services/analyticsServices.js", "js/services/notificationServices.js", "js/services/sharedServices.js", + "js/services/socialServices.js", "js/services/statServices.js", "common/script/public/userServices.js", "js/controllers/authCtrl.js", @@ -152,6 +153,7 @@ "js/services/analyticsServices.js", "js/services/notificationServices.js", "js/services/sharedServices.js", + "js/services/socialServices.js", "js/services/statServices.js", "common/script/public/userServices.js", "js/controllers/authCtrl.js", diff --git a/website/src/routes/pages.js b/website/src/routes/pages.js index 05ef2f9574..e2ec340888 100644 --- a/website/src/routes/pages.js +++ b/website/src/routes/pages.js @@ -33,7 +33,7 @@ _.each(pages, function(name){ // -------- Social Media Sharing -------- -var shareables = ['level-up','hatch-pet','raise-pet']; +var shareables = ['level-up','hatch-pet','raise-pet','unlock-quest','won-challenge']; _.each(shareables, function(name){ router.get('/social/' + name, i18n.getUserLanguage, locals, function(req, res) { diff --git a/website/views/shared/modals/quests.jade b/website/views/shared/modals/quests.jade index 371060cfff..63197dc04b 100644 --- a/website/views/shared/modals/quests.jade +++ b/website/views/shared/modals/quests.jade @@ -106,8 +106,15 @@ script(type='text/ng-template', id='modals/questDrop.html') button.btn.btn-primary(ng-click='inviteOrStartParty(group); $close()', ng-if='!party.members')=env.t('startAParty') button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty') button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater') - .modal-footer(style='margin-top:0') - a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I+leveled+up+to+{{::user.stats.lvl}}+in+Habitica!&via=habitica&url=https://habitica.com/social/level-up&count=none')=env.t('tweet') + .modal-footer(style='margin-top:0', ng-init='loadWidgets()') + .container-fluid + .row + .col-xs-3 + a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I unlocked the quest {{::selectedQuest.text()}} in Habitica!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/unlock-quest&count=none')=env.t('tweet') + .col-xs-4(style='margin-left:.8em') + .fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/unlock-quest', data-layout='button') + .col-xs-4(style='margin-left:.8em') + a.tumblr-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/unlock-quest', data-notes='none') script(type='text/ng-template', id='modals/ownedQuests.html') .modal-header diff --git a/website/views/shared/modals/won-challenge.jade b/website/views/shared/modals/won-challenge.jade index 81bc9febcb..e5af481f48 100644 --- a/website/views/shared/modals/won-challenge.jade +++ b/website/views/shared/modals/won-challenge.jade @@ -24,5 +24,14 @@ script(type='text/ng-template', id='modals/wonChallenge.html') .col-xs-4(style='padding:0') .achievement-karaoke-2x(style='margin-top: 2em') p=env.t('congratulations') - .modal-footer(style='margin-top:0') + br button.btn.btn-primary(ng-click='$close()')=env.t('hurray') + .modal-footer(style='margin-top:0', ng-init='loadWidgets()') + .container-fluid + .row + .col-xs-3 + a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I just won the Challenge {{::user.achievements.challenges[user.achievements.challenges.length - 1]}} in Habitica!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/won-challenge&count=none')=env.t('tweet') + .col-xs-4(style='margin-left:.8em') + .fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/won-challenge', data-layout='button') + .col-xs-4(style='margin-left:.8em') + a.tumblr-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/won-challenge', data-notes='none') diff --git a/website/views/social/unlock-quest.jade b/website/views/social/unlock-quest.jade new file mode 100644 index 0000000000..f3442fa3e6 --- /dev/null +++ b/website/views/social/unlock-quest.jade @@ -0,0 +1,15 @@ +doctype html +html + head + meta(name='twitter:card' content='summary') + meta(name='twitter:site' content='@habitica') + meta(name='twitter:title' content='Unlocked a Quest!') + meta(name='twitter:description' content='In Habitica, you can defeat fearsome monsters and devious villains with real-life productivity. I\'ve earned just such a Quest with my progress!') + meta(name='twitter:image' content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo.png') + meta(property='og:url', content='https://habitica.com/social/level-up') + meta(property='og:type', content='website') + meta(property='og:title', content='Unlocked a Quest!') + meta(property='og:description', content='In Habitica, you can defeat fearsome monsters and devious villains with real-life productivity. I\'ve earned just such a Quest with my progress!') + meta(property='og:site_name', content='Habitica') + meta(property='og:image', content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo_300x300.png') + meta(property='fb:app_id', content='128307497299777') diff --git a/website/views/social/won-challenge.jade b/website/views/social/won-challenge.jade new file mode 100644 index 0000000000..08ac66b089 --- /dev/null +++ b/website/views/social/won-challenge.jade @@ -0,0 +1,15 @@ +doctype html +html + head + meta(name='twitter:card' content='summary') + meta(name='twitter:site' content='@habitica') + meta(name='twitter:title' content='Won a Challenge!') + meta(name='twitter:description' content='In Habitica, users can challenge one another to accomplish goals in all areas of life. I\'ve won just such a Challenge!') + meta(name='twitter:image' content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo.png') + meta(property='og:url', content='https://habitica.com/social/level-up') + meta(property='og:type', content='website') + meta(property='og:title', content='Won a Challenge!') + meta(property='og:description', content='In Habitica, users can challenge one another to accomplish goals in all areas of life. I\'ve won just such a Challenge!') + meta(property='og:site_name', content='Habitica') + meta(property='og:image', content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo_300x300.png') + meta(property='fb:app_id', content='128307497299777')