mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Merge pull request #4950 from gisikw/force-latest-bailey
Ensure Bailey always displays the most recent message.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ config.json
|
||||
npm-debug.log
|
||||
lib
|
||||
website/public/bower_components
|
||||
website/public/new-stuff.html
|
||||
website/build
|
||||
newrelic_agent.log
|
||||
.bower-tmp
|
||||
|
||||
13
Gruntfile.js
13
Gruntfile.js
@@ -229,8 +229,8 @@ module.exports = function(grunt) {
|
||||
|
||||
// Register tasks.
|
||||
grunt.registerTask('compile:sprites', ['clean:sprite', 'sprite', 'cssmin']);
|
||||
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
|
||||
grunt.registerTask('build:dev', ['browserify', 'stylus']);
|
||||
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres','prepare:staticNewStuff']);
|
||||
grunt.registerTask('build:dev', ['browserify', 'stylus', 'prepare:staticNewStuff']);
|
||||
grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']);
|
||||
|
||||
grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]);
|
||||
@@ -244,6 +244,15 @@ module.exports = function(grunt) {
|
||||
"window.env.translations = " + JSON.stringify(i18n.translations['en']) + ';');
|
||||
});
|
||||
|
||||
grunt.registerTask('prepare:staticNewStuff', function() {
|
||||
var jade = require('jade'),
|
||||
fs = require('fs');
|
||||
fs.writeFileSync(
|
||||
'./website/public/new-stuff.html',
|
||||
jade.compileFile('./website/views/shared/new-stuff.jade')()
|
||||
);
|
||||
});
|
||||
|
||||
if(process.env.NODE_ENV == 'production')
|
||||
grunt.registerTask('default', ['build:prod']);
|
||||
else
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/* Make user and settings available for everyone through root scope.
|
||||
*/
|
||||
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments) {
|
||||
habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce',
|
||||
function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments,$sce) {
|
||||
var user = User.user;
|
||||
|
||||
var initSticky = _.once(function(){
|
||||
@@ -105,11 +105,29 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
||||
$rootScope.set = User.set;
|
||||
$rootScope.authenticated = User.authenticated;
|
||||
|
||||
var forceLoadBailey = function(template, options) {
|
||||
$http.get('/new-stuff.html')
|
||||
.success(function(data) {
|
||||
$rootScope.latestBaileyMessage = $sce.trustAsHtml(data);
|
||||
$modal.open({
|
||||
templateUrl: 'modals/' + template + '.html',
|
||||
controller: options.controller, // optional
|
||||
scope: options.scope, // optional
|
||||
resolve: options.resolve, // optional
|
||||
keyboard: (options.keyboard === undefined ? true : options.keyboard), // optional
|
||||
backdrop: (options.backdrop === undefined ? true : options.backdrop), // optional
|
||||
size: options.size, // optional, 'sm' or 'lg'
|
||||
windowClass: options.windowClass // optional
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Open a modal from a template expression (like ng-click,...)
|
||||
// Otherwise use the proper $modal.open
|
||||
$rootScope.openModal = function(template, options){//controller, scope, keyboard, backdrop){
|
||||
if (!options) options = {};
|
||||
if (options.track) window.ga && ga('send', 'event', 'button', 'click', options.track);
|
||||
if(template === 'newStuff') return forceLoadBailey(template, options);
|
||||
return $modal.open({
|
||||
templateUrl: 'modals/' + template + '.html',
|
||||
controller: options.controller, // optional
|
||||
|
||||
@@ -6,7 +6,7 @@ script(type='text/ng-template', id='modals/newStuff.html')
|
||||
div(class="#{env.worldDmg.bailey ? 'npc_bailey_broken' : 'npc_bailey'}")
|
||||
br
|
||||
br
|
||||
include ../new-stuff
|
||||
div(ng-bind-html='latestBaileyMessage')
|
||||
.modal-footer
|
||||
button.btn.btn-default(ng-click='$close()')=env.t('cool')
|
||||
button.btn.btn-default(ng-click='$close()')=env.t('cool')
|
||||
button.btn.btn-warning(ng-click='dismissAlert(); $close()')=env.t('dismissAlert')
|
||||
|
||||
Reference in New Issue
Block a user