Add confirmation popover for Rebirth

Add confirmation popover for Fortify/Reroll

Add tests for reroll and rebirth
This commit is contained in:
Georgi Gardev
2015-12-16 18:49:56 +02:00
committed by Blade Barringer
parent d53ac4c66f
commit f6f82cafc4
7 changed files with 155 additions and 28 deletions

View File

@@ -2,8 +2,8 @@
// Make user and settings available for everyone through root scope.
habitrpg.controller('SettingsCtrl',
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared',
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared) {
['$scope', 'User', '$rootScope', '$http', 'ApiUrl', 'Guide', '$location', '$timeout', 'Content', 'Notification', 'Shared', '$compile',
function($scope, User, $rootScope, $http, ApiUrl, Guide, $location, $timeout, Content, Notification, Shared, $compile) {
// FIXME we have this re-declared everywhere, figure which is the canonical version and delete the rest
// $scope.auth = function (id, token) {
@@ -90,14 +90,54 @@ habitrpg.controller('SettingsCtrl',
$scope.availableFormats = ['MM/dd/yyyy','dd/MM/yyyy', 'yyyy/MM/dd'];
$scope.reroll = function(){
User.user.ops.reroll({});
$rootScope.$state.go('tasks');
$scope.reroll = function(confirm){
$scope.popoverEl.popover('destroy')
if (confirm) {
User.user.ops.reroll({});
$rootScope.$state.go('tasks');
}
}
$scope.rebirth = function(){
User.user.ops.rebirth({});
$rootScope.$state.go('tasks');
$scope.clickReroll = function($event){
$scope.popoverEl = $($event.target);
var html = $compile(
'<a ng-controller="SettingsCtrl" ng-click="$close(); reroll(true)">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="reroll(false)">' + window.env.t('cancel') + '</a><br/>'
)($scope);
$scope.popoverEl.popover('destroy').popover({
html: true,
placement: 'top',
trigger: 'manual',
title: window.env.t('confirmFortify'),
content: html
}).popover('show');
}
$scope.rebirth = function(confirm){
$scope.popoverEl.popover('destroy')
if (confirm) {
User.user.ops.rebirth({});
$rootScope.$state.go('tasks');
}
}
$scope.clickRebirth = function($event){
$scope.popoverEl = $($event.target);
var html = $compile(
'<a ng-controller="SettingsCtrl" ng-click="$close(); rebirth(true)">' + window.env.t('confirm') + '</a><br/>\n<a ng-click="rebirth(false)">' + window.env.t('cancel') + '</a><br/>'
)($scope);
$scope.popoverEl.popover('destroy').popover({
html: true,
placement: 'top',
trigger: 'manual',
title: window.env.t('confirmReborn'),
content: html
}).popover('show');
}
$scope.changeUser = function(attr, updates){