feat(sharing): Buttons for more modals

This commit is contained in:
Sabe Jones
2015-10-29 16:33:27 -04:00
parent 22caaa7eda
commit c28afc9abc
9 changed files with 76 additions and 22 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -11,6 +11,7 @@
function loadWidgets() {
// Facebook
if (typeof FB === 'undefined') {
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
@@ -18,12 +19,19 @@
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
if (typeof twttr === 'undefined') {
$.getScript('https://platform.twitter.com/widgets.js');
} else {
twttr.widgets.load();
}
}
return {

View File

@@ -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",

View File

@@ -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) {

View File

@@ -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

View File

@@ -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')

View File

@@ -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')

View File

@@ -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')