mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-22 11:38:24 +00:00
refactor(bs3): misc
This commit is contained in:
parent
56133894d8
commit
cdc13d2ffb
6 changed files with 30 additions and 77 deletions
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
angular.module('authCtrl', [])
|
||||
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','API_URL', '$modal',
|
||||
function($scope, $rootScope, User, $http, $location, $window, API_URL, $modal) {
|
||||
.controller("AuthCtrl", ['$scope', '$rootScope', 'User', '$http', '$location', '$window','API_URL',
|
||||
function($scope, $rootScope, User, $http, $location, $window, API_URL) {
|
||||
var runAuth;
|
||||
var showedFacebookMessage;
|
||||
|
||||
|
|
@ -71,10 +71,8 @@ angular.module('authCtrl', [])
|
|||
if (User.authenticated()) {
|
||||
window.location.href = '/#/tasks';
|
||||
} else {
|
||||
$modal.open({
|
||||
templateUrl: 'modals/login.html'
|
||||
// Using controller: 'AuthCtrl' it causes problems
|
||||
});
|
||||
// Using controller: 'AuthCtrl' it causes problems
|
||||
$rootScope.openModal('login');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', 'API_URL', '$q', 'User', 'Members', '$state', '$modal',
|
||||
function($scope, $rootScope, Shared, Groups, $http, API_URL, $q, User, Members, $state, $modal) {
|
||||
habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '$http', 'API_URL', '$q', 'User', 'Members', '$state',
|
||||
function($scope, $rootScope, Shared, Groups, $http, API_URL, $q, User, Members, $state) {
|
||||
|
||||
$scope.isMember = function(user, group){
|
||||
return ~(group.members.indexOf(user._id));
|
||||
|
|
@ -29,10 +29,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
// We need the member information up top here, but then we pass it down to the modal controller
|
||||
// down below. Better way of handling this?
|
||||
Members.selectMember(uid);
|
||||
$modal.open({
|
||||
templateUrl: 'modals/member.html',
|
||||
controller: 'MemberModalCtrl'
|
||||
});
|
||||
$rootScope.openModal('member', 'MemberModalCtrl');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User', 'Content', '$modal',
|
||||
function($rootScope, $scope, $window, User, Content, $modal) {
|
||||
habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User', 'Content',
|
||||
function($rootScope, $scope, $window, User, Content) {
|
||||
|
||||
var user = User.user;
|
||||
|
||||
|
|
@ -127,10 +127,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User',
|
|||
if (item.lvl && item.lvl > user.stats.lvl)
|
||||
return alert("You must be level " + item.lvl + '.');
|
||||
$rootScope.selectedQuest = item;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/showQuest.html',
|
||||
controller: 'InventoryCtrl'
|
||||
});
|
||||
$rootScope.openModal('showQuest', 'InventoryCtrl');
|
||||
}
|
||||
$scope.closeQuest = function(){
|
||||
$rootScope.selectedQuest = undefined;
|
||||
|
|
@ -149,10 +146,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', '$window', 'User',
|
|||
if (!completedPrevious)
|
||||
return $scope.purchase("quests", item);
|
||||
$rootScope.selectedQuest = item;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/buyQuest.html',
|
||||
controller: 'InventoryCtrl'
|
||||
});
|
||||
$rootScope.openModal('showQuest', 'buyQuest');
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
habitrpg.controller('NotificationCtrl',
|
||||
['$scope', '$rootScope', 'Shared', 'User', 'Guide', 'Notification', '$modal',
|
||||
function ($scope, $rootScope, Shared, User, Guide, Notification, $modal) {
|
||||
['$scope', '$rootScope', 'Shared', 'User', 'Guide', 'Notification',
|
||||
function ($scope, $rootScope, Shared, User, Guide, Notification) {
|
||||
|
||||
$rootScope.$watch('user.stats.hp', function(after, before) {
|
||||
if (after <= 0){
|
||||
$modal.open({
|
||||
templateUrl: 'modals/death.html',
|
||||
keyboard: false,
|
||||
backdrop: 'static'
|
||||
});
|
||||
$rootScope.openModal('death', undefined, undefined, false, 'static');
|
||||
}
|
||||
if (after == before) return;
|
||||
if (User.user.stats.lvl == 0) return;
|
||||
|
|
@ -69,39 +65,29 @@ habitrpg.controller('NotificationCtrl',
|
|||
|
||||
$rootScope.$watch('user.achievements.streak', function(after, before){
|
||||
if(before == undefined || after == before || after < before) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/streak.html'
|
||||
});
|
||||
$rootScope.openModal('achievements/streak');
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.achievements.ultimateGear', function(after, before){
|
||||
if (after === before || after !== true) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/ultimateGear.html'
|
||||
});
|
||||
$rootScope.openModal('achievements/ultimateGear');
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.items.pets', function(after, before){
|
||||
if(_.size(after) === _.size(before) ||
|
||||
Shared.countPets(null, after) < 90) return;
|
||||
User.user.achievements.beastMaster = true;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/beastMaster.html'
|
||||
});
|
||||
$rootScope.openModal('achievements/beastMaster');
|
||||
}, true);
|
||||
|
||||
$rootScope.$watch('user.achievements.rebirths', function(after, before){
|
||||
if(after === before) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/rebirth.html'
|
||||
});
|
||||
$rootScope.openModal('achievements/rebirth');
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.flags.contributor', function(after, before){
|
||||
if (after === before || after !== true) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/contributor.html'
|
||||
});
|
||||
$rootScope.openModal('achievements/contributor');
|
||||
});
|
||||
|
||||
/*_.each(['weapon', 'head', 'chest', 'shield'], function(watched){
|
||||
|
|
@ -119,10 +105,7 @@ habitrpg.controller('NotificationCtrl',
|
|||
// Classes modal
|
||||
$rootScope.$watch('!user.flags.classSelected && user.stats.lvl >= 10', function(after, before){
|
||||
if(after){
|
||||
$modal.open({
|
||||
templateUrl: 'modals/chooseClass.html',
|
||||
controller: 'UserCtrl'
|
||||
});
|
||||
$rootScope.openModal('chooseClass', 'UserCtrl');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -136,25 +119,18 @@ habitrpg.controller('NotificationCtrl',
|
|||
// Math updates modal
|
||||
$rootScope.$watch('!user.flags.mathUpdates', function(after, before){
|
||||
if (after == before || after != true) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/mathUpdates.html'
|
||||
});
|
||||
$rootScope.openModal('mathUpdates');
|
||||
});
|
||||
|
||||
// Completed quest modal
|
||||
$rootScope.$watch('user.party.quest.completed', function(after, before){
|
||||
if (after == before || after != true) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/questCompleted.html',
|
||||
controller: 'InventoryCtrl'
|
||||
});
|
||||
$rootScope.openModal('questCompleted', 'InventoryCtrl');
|
||||
});
|
||||
|
||||
$rootScope.$watch('party.quest.key && !party.quest.active && !questHold && party.quest.members[user._id] == undefined', function(after, before){
|
||||
if (after == before || after != true) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/questInvitation.html'
|
||||
});
|
||||
$rootScope.openModal('questInvitation');
|
||||
});
|
||||
|
||||
$rootScope.$on('responseError', function(ev, error){
|
||||
|
|
|
|||
|
|
@ -66,11 +66,13 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||
|
||||
// Open a modal from a template expression (like ng-click,...)
|
||||
// Otherwise use the proper $modal.open
|
||||
$rootScope.openModal = function(template, controller, scope){
|
||||
$rootScope.openModal = function(template, controller, scope, keyboard, backdrop){
|
||||
return $modal.open({
|
||||
templateUrl: 'modals/' + template + '.html',
|
||||
controller: controller, // optional
|
||||
scope: scope // optional
|
||||
scope: scope, // optional
|
||||
keyboard: keyboard, // optional
|
||||
backdrop: backdrop // optional
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
angular.module('guideServices', []).
|
||||
factory('Guide', ['$rootScope', 'User', '$timeout', '$modal', function($rootScope, User, $timeout, $modal) {
|
||||
factory('Guide', ['$rootScope', 'User', '$timeout', function($rootScope, User, $timeout) {
|
||||
|
||||
/**
|
||||
* Init and show the welcome tour. Note we do it listening to a $rootScope broadcasted 'userLoaded' message,
|
||||
|
|
@ -130,26 +130,12 @@ angular.module('guideServices', []).
|
|||
if (!eggs) {
|
||||
eggs['Wolf'] = 1; // This is also set on the server
|
||||
}
|
||||
$modal.open({
|
||||
templateUrl: 'modals/dropsEnabled.html'
|
||||
});
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.items.pets', function(after, before) {
|
||||
if (User.user.achievements && User.user.achievements.beastMaster) return;
|
||||
if (before >= 90) {
|
||||
User.set({'achievements.beastMaster': true});
|
||||
$modal.open({
|
||||
templateUrl: 'modals/achievements/beastMaster.html'
|
||||
});
|
||||
}
|
||||
$rootScope.openModal('dropsEnabled');
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.flags.rebirthEnabled', function(after, before) {
|
||||
if (alreadyShown(before, after)) return;
|
||||
$modal.open({
|
||||
templateUrl: 'modals/rebirthEnabled.html'
|
||||
});
|
||||
$rootScope.openModal('rebirthEnabled');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue