01/01: Change the title based on the current page
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit b4694b38abfa84ae7ded37198b63e6b351061976 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jul 4 15:21:46 2014 +0200 Change the title based on the current page --- pollen-ui-angular/src/main/webapp/i18n/en.js | 15 +++++-- pollen-ui-angular/src/main/webapp/i18n/fr.js | 19 ++++++--- pollen-ui-angular/src/main/webapp/index.html | 7 ++-- pollen-ui-angular/src/main/webapp/js/app.js | 2 +- .../main/webapp/js/controllers/favoriteListCtrl.js | 6 ++- .../src/main/webapp/js/controllers/mainCtrl.js | 8 ++++ .../src/main/webapp/js/controllers/pollCtrl.js | 47 +++++++++++++++------- .../src/main/webapp/js/controllers/userCtrl.js | 24 +++++++---- pollen-ui-angular/src/main/webapp/js/directives.js | 33 +++++++++++++++ .../src/main/webapp/partials/poll-comment.html | 2 +- .../src/main/webapp/partials/user-edit.html | 2 +- .../main/webapp/partials/user-lostPassword.html | 2 +- .../src/main/webapp/partials/user-register.html | 2 +- 13 files changed, 126 insertions(+), 43 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index e4643f8..38d01f0 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -1,9 +1,16 @@ var translateEN = { -'title.forgotPassword' : 'Forget Password', -'title.register' : 'Register', -'title.editUser' : 'Edit Profile', -'title.comment' : 'Comment', +'title.home' : 'Home', +'title.poll.create' : 'Create new poll', +'title.poll.edit' : 'Edit poll', +'title.poll.vote' : 'Vote', +'title.poll.comment' : 'Comment', +'title.poll.result' : 'Result of poll', +'title.poll.list' : 'List of poll', +'title.user.register' : 'Register', +'title.user.edit' : 'Edit Profile', +'title.user.forgotPassword' : 'Forget Password', +'title.user.list' : 'List of user', 'newPoll' : 'New Poll', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index d6c1c7c..85aab6a 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -1,9 +1,16 @@ var translateFR = { -'title.forgotPassword' : 'Récupération du Mot de Passe', -'title.register' : 'Inscription', -'title.editUser' : 'Modification de votre profile', -'title.comment' : 'Laisser un Commentaire', +'title.home' : 'Accueil', +'title.poll.create' : 'Création d\'un nouveau sondage', +'title.poll.edit' : 'Edition du sondage', +'title.poll.vote' : 'Voter', +'title.poll.comment' : 'Laisser un Commentaire', +'title.poll.result' : 'Résultat du sondage', +'title.poll.list' : 'Liste des sondages', +'title.user.register' : 'Inscription', +'title.user.edit' : 'Modification de votre profile', +'title.user.forgotPassword' : 'Récupération du Mot de Passe', +'title.user.list' : 'Liste des utilisateurs', 'newPoll' : 'Nouveau Sondage', @@ -49,14 +56,14 @@ var translateFR = { 'poll.link.result' : 'Lien du résultat du sondage', 'poll.link.clone' : 'Cloner le sondage', 'poll.link.export' : 'Exporter le sondage', -'poll.link.close' : 'Fermer les votes du sondage', +'poll.link.close' : 'Clore les votes du sondage', 'poll.link.delete' : 'Supprimer le sondage', 'poll.edit' : 'Clique pour éditer', 'poll.desc' : 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise', 'poll.saved' : 'Sondage sauvegardé', 'poll.cloned' : 'Sondage cloné', -'poll.closed' : 'Sondage fermé', +'poll.closed' : 'Sondage clos', 'poll.deleted' : 'Sondage supprimé', 'poll.restricted.name' : 'Nom du votant', 'poll.restricted.mail' : 'Courriel du votant', diff --git a/pollen-ui-angular/src/main/webapp/index.html b/pollen-ui-angular/src/main/webapp/index.html index a995313..34ec952 100644 --- a/pollen-ui-angular/src/main/webapp/index.html +++ b/pollen-ui-angular/src/main/webapp/index.html @@ -19,9 +19,9 @@ #L% --> -<html ng-app="pollen"> +<html ng-app="pollen" ng-controller="MainCtrl"> <head> - <title>Pollen</title> + <title>{{ title || "Pollen" }}</title> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="lib/bootstrap/dist/css/bootstrap.min.css" /> @@ -41,7 +41,7 @@ <script language="javascript" type="text/javascript" src="lib/jqplot/jquery.jqplot.min.js"></script> <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.barRenderer.min.js"></script> <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.pieRenderer.min.js"></script> - <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"> </script> + <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script> <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.pointLabels.min.js"></script> <script language="javascript" type="text/javascript" src="lib/jqplot/plugins/jqplot.highlighter.min.js"></script> @@ -57,6 +57,7 @@ <script language="javascript" type="text/javascript" src="js/app.js"></script> <script language="javascript" type="text/javascript" src="js/directives.js"></script> <script language="javascript" type="text/javascript" src="js/services.js"></script> + <script language="javascript" type="text/javascript" src="js/controllers/mainCtrl.js"></script> <script language="javascript" type="text/javascript" src="js/controllers/pollCtrl.js"></script> <script language="javascript" type="text/javascript" src="js/controllers/userCtrl.js"></script> <script language="javascript" type="text/javascript" src="js/controllers/favoriteListCtrl.js"></script> diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index 8c3d08f..28ff905 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'pollControllers', 'userControllers', 'favoriteListControllers', 'localeControllers', 'alertControllers', 'ui.bootstrap', 'pascalprecht.translate', 'ngAnimate']) +var pollen = angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'pollControllers', 'userControllers', 'favoriteListControllers', 'localeControllers', 'alertControllers', 'ui.bootstrap', 'pascalprecht.translate', 'ngAnimate']) .config(['$httpProvider', function($httpProvider) { // edit header for locale and sessionToken $httpProvider.interceptors.push('httpInterceptor'); diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js index b531a7a..932e82c 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js @@ -19,10 +19,12 @@ * #L% */ angular.module('favoriteListControllers', []) -.controller('FavoriteListCtrl', ['$scope', 'FavoriteList', 'FavoriteListMember', '$translate', '$routeParams', - function ($scope, FavoriteList, FavoriteListMember, $translate, $routeParams) { +.controller('FavoriteListCtrl', ['$scope', 'FavoriteList', 'FavoriteListMember', '$translate', '$routeParams', 'Page', + function ($scope, FavoriteList, FavoriteListMember, $translate, $routeParams, Page) { $scope.data = {}; + Page.setTitle('user.favoriteList'); + var paginationParameter = {pageSize: conf.favoriteListDefaultPageSize}; if (angular.isUndefined(paginationParameter.pageSize)) { paginationParameter.pageSize = -1; diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/mainCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/mainCtrl.js new file mode 100644 index 0000000..d0ccb2a --- /dev/null +++ b/pollen-ui-angular/src/main/webapp/js/controllers/mainCtrl.js @@ -0,0 +1,8 @@ +pollen.controller('MainCtrl', ['$scope', 'Page', + function ($scope, Page) { + + $scope.$on('titleChange', function () { + $scope.title = Page.title(); + }) +}]) + diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index e050af6..a7ec70c 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -19,13 +19,14 @@ * #L% */ angular.module('pollControllers', []) -.controller('HomeCtrl', ['$scope', 'Poll', function ($scope, Poll) { +.controller('HomeCtrl', ['$scope', 'Poll', 'Page', function ($scope, Poll, Page) { + Page.setTitle('title.home'); Poll.skeletonNew(); }]) .controller('PollCtrl', - ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', - function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll) { + ['$scope', '$rootScope', '$controller', '$sce', '$timeout', '$routeParams', '$location', 'SessionStorage', '$translate', '$route', '$q', 'Poll', 'Page', + function ( $scope, $rootScope, $controller, $sce, $timeout, $routeParams, $location, SessionStorage, $translate, $route, $q, Poll, Page) { $scope.setTab = function (defaultValue) { if (angular.isDefined($routeParams.tab)) { return $routeParams.tab; @@ -215,6 +216,10 @@ angular.module('pollControllers', []) }); } }) + + $scope.$watch('data.poll.title', function (newVal) { + Page.setValue($scope.data.poll.title); + }); }); $scope.voteCountingIsBoolean = function () { @@ -452,10 +457,12 @@ angular.module('pollControllers', []) }); }]) -.controller('PollCreateCtrl', ['$scope', '$rootScope', '$controller', '$location', 'Poll', 'SessionStorage', 'PollVoterList', - function ( $scope, $rootScope, $controller, $location, Poll, SessionStorage, PollVoterList) { +.controller('PollCreateCtrl', ['$scope', '$rootScope', '$controller', '$location', 'Poll', 'SessionStorage', 'PollVoterList', 'Page', + function ( $scope, $rootScope, $controller, $location, Poll, SessionStorage, PollVoterList, Page) { $controller('PollAdminCtrl', {$scope:$scope}); + Page.setTitle('title.poll.create'); + $scope.globalVariables.create = true; var initPoll = function () { @@ -520,10 +527,12 @@ angular.module('pollControllers', []) }]) -.controller('PollEditCtrl', ['$scope', '$rootScope', '$controller', '$routeParams', '$location', '$timeout', '$translate', 'Poll', 'PollChoice', 'PollVote', 'PollVoterList', 'PollVoterListMember', 'FavoriteList', 'SessionStorage', - function ( $scope, $rootScope, $controller, $routeParams, $location, $timeout, $translate, Poll, PollChoice, PollVote, PollVoterList, PollVoterListMember, FavoriteList, SessionStorage) { +.controller('PollEditCtrl', ['$scope', '$rootScope', '$controller', '$routeParams', '$location', '$timeout', '$translate', 'Poll', 'PollChoice', 'PollVote', 'PollVoterList', 'PollVoterListMember', 'FavoriteList', 'SessionStorage', 'Page', + function ( $scope, $rootScope, $controller, $routeParams, $location, $timeout, $translate, Poll, PollChoice, PollVote, PollVoterList, PollVoterListMember, FavoriteList, SessionStorage, Page) { $controller('PollAdminCtrl', {$scope:$scope}); + Page.setTitle('title.poll.edit'); + $scope.globalVariables.edit = true; //////////////////////////////// @@ -866,10 +875,12 @@ angular.module('pollControllers', []) }]) -.controller('PollVoteCtrl', ['$scope', '$rootScope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$location', - function ($scope, $rootScope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $location) { +.controller('PollVoteCtrl', ['$scope', '$rootScope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$location', 'Page', + function ($scope, $rootScope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $location, Page) { $controller('PollCtrl', {$scope:$scope}); + Page.setTitle('title.poll.vote'); + $scope.tab = $scope.setTab('vote'); var initPoll = function () { @@ -1000,10 +1011,12 @@ angular.module('pollControllers', []) }]) .controller('PollCommentCtrl', - ['$scope', '$rootScope', '$controller', '$routeParams', 'Poll', 'PollComment', '$translate', '$location', - function ( $scope, $rootScope, $controller, $routeParams, Poll, PollComment, $translate, $location) { + ['$scope', '$rootScope', '$controller', '$routeParams', 'Poll', 'PollComment', '$translate', '$location', 'Page', + function ( $scope, $rootScope, $controller, $routeParams, Poll, PollComment, $translate, $location, Page) { $controller('PollCtrl', {$scope:$scope}); + Page.setTitle('title.poll.comment'); + if (angular.isDefined($routeParams.commentToken)) { $scope.commentToken = $routeParams.commentToken; } @@ -1151,10 +1164,12 @@ angular.module('pollControllers', []) }]) -.controller('PollResultCtrl', ['$scope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$filter', - function ($scope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $filter) { +.controller('PollResultCtrl', ['$scope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$filter', 'Page', + function ($scope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $filter, Page) { $controller('PollCtrl', {$scope:$scope}); + Page.setTitle('title.poll.result'); + $scope.translateTitle = { '0' : "{{ 'poll.result.title.zero' | translate }}", 'one' : "{{ 'poll.result.title.one' | translate }}", @@ -1222,10 +1237,12 @@ angular.module('pollControllers', []) }]) .controller('PollListCtrl', - ['$scope', '$rootScope', '$controller', '$routeParams', '$location', 'Poll', - function ($scope, $rootScope, $controller, $routeParams, $location, Poll) { + ['$scope', '$rootScope', '$controller', '$routeParams', '$location', 'Poll', 'Page', + function ($scope, $rootScope, $controller, $routeParams, $location, Poll, Page) { $scope.data = {}; + Page.setTitle('title.poll.list'); + if (angular.isDefined(conf.pollDefaultPageSize)) { $scope.pageSize = conf.pollDefaultPageSize; } diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js index 4935fad..a64dad8 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -19,8 +19,9 @@ * #L% */ angular.module('userControllers', []) - .controller('UserRegisterCtrl', ['$scope', '$rootScope', '$location', 'User', 'SessionStorage', - function ($scope, $rootScope, $location, User, SessionStorage) { +.controller('UserRegisterCtrl', ['$scope', '$rootScope', '$location', 'User', 'SessionStorage', 'Page', + function ($scope, $rootScope, $location, User, SessionStorage, Page) { + Page.setTitle('title.user.register'); if (angular.isDefined(SessionStorage.get().user)) { $rootScope.$broadcast('newError', 'user.error.logout.mandatory'); @@ -44,8 +45,10 @@ } }]) -.controller('UserLostPasswordCtrl', ['$scope', '$rootScope', '$translate', '$location', 'SessionStorage', 'UserLostPassword', - function ($scope, $rootScope, $translate, $location, SessionStorage, UserLostPassword) { +.controller('UserLostPasswordCtrl', ['$scope', '$rootScope', '$translate', '$location', 'SessionStorage', 'UserLostPassword', 'Page', + function ($scope, $rootScope, $translate, $location, SessionStorage, UserLostPassword, Page) { + Page.setTitle('title.user.forgotPassword'); + if (angular.isDefined(SessionStorage.get().user)) { $rootScope.$broadcast('newError', 'user.error.logout.mandatory'); $location.url('/'); @@ -73,7 +76,10 @@ -.controller('UserEditCtrl', ['$scope', '$rootScope', '$routeParams', '$route', '$location', 'User', 'SessionStorage', function ($scope, $rootScope, $routeParams, $route, $location, User, SessionStorage) { +.controller('UserEditCtrl', ['$scope', '$rootScope', '$routeParams', '$route', '$location', 'User', 'SessionStorage', 'Page', + function ($scope, $rootScope, $routeParams, $route, $location, User, SessionStorage, Page) { + Page.setTitle('title.user.edit'); + if (angular.isUndefined($scope.data)) { $scope.data = {user:{}}; } @@ -108,8 +114,11 @@ } }]) -.controller('UserListCtrl', ['$scope', '$routeParams', 'User', - function ($scope, $routeParams, User) { +.controller('UserListCtrl', ['$scope', '$routeParams', 'User', 'Page', + function ($scope, $routeParams, User, Page) { + + Page.setTitle('title.user.list'); + if (angular.isUndefined($scope.data)) { $scope.data = {user:{}}; } @@ -132,7 +141,6 @@ } User.get({paginationParameter:paginationParameter}, function (data) { - console.log(data); $scope.data.users = data.elements; $scope.data.usersPagination = data.pagination }); diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index ad58548..f3ef921 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -21,6 +21,39 @@ angular.module('pollenDirective', []) ////////////////////////////////////// +///// PAGE ///// +////////////////////////////////////// + +.factory('Page', ['$rootScope', '$filter', function ($rootScope, $filter) { + var title = ''; + var value; + return { + title : function () { + var makeTitle = "Pollen"; + if (title != '') { + makeTitle += " - " + $filter('translate')(title); + + } + + if (value !== undefined) { + makeTitle += " - " + value; + } + + return makeTitle; + }, + setTitle: function(newTitle, newValue) { + title = newTitle; + value = newValue; + $rootScope.$broadcast('titleChange'); + }, + setValue: function(newValue) { + value = newValue; + $rootScope.$broadcast('titleChange'); + } + }; +}]) + +////////////////////////////////////// ///// FOCUS ME ///// ////////////////////////////////////// diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-comment.html b/pollen-ui-angular/src/main/webapp/partials/poll-comment.html index a584ca5..841eb54 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-comment.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-comment.html @@ -20,7 +20,7 @@ --> <div> <h1>{{ data.poll.title }}</h1> - <h2>{{ 'title.comment' | translate }}</h2> + <h2>{{ 'title.poll.comment' | translate }}</h2> <!-- begin for add comment --> <form class="form-horizontal" ng-submit="postComment()" novalidate> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-edit.html b/pollen-ui-angular/src/main/webapp/partials/user-edit.html index 765d96e..1d75891 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-edit.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-edit.html @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<h2> {{ 'title.editUser' | translate }} </h2> +<h2> {{ 'title.user.edit' | translate }} </h2> <form class="horizontal-form" ng-submit="editUser()"> <div class="control-group"> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-lostPassword.html b/pollen-ui-angular/src/main/webapp/partials/user-lostPassword.html index dd28daa..d1bb5f5 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-lostPassword.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-lostPassword.html @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<h2>{{ 'title.forgotPassword' | translate }}</h2> +<h2>{{ 'title.user.forgotPassword' | translate }}</h2> <form ng-submit="submit()" class="form-horizontal"> <div class="control-group"> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-register.html b/pollen-ui-angular/src/main/webapp/partials/user-register.html index ea75471..b9e5c36 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-register.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-register.html @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> -<h2>{{ 'title.register' | translate }}</h2> +<h2>{{ 'title.user.register' | translate }}</h2> <form ng-submit="submit()" class="form-horizontal"> <div class="control-group"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm