Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove base controller from HTML tag to after Angular bootstrap and convert I18NFooter and Thanks to component directives. #7283

Merged
merged 15 commits into from
Aug 5, 2019
Prev Previous commit
Next Next commit
Merge
  • Loading branch information
YashJipkate committed Aug 1, 2019
commit 6099a214907eb3f3566137950bca94b374f41d72
79 changes: 38 additions & 41 deletions core/templates/dev/head/I18nFooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,46 @@

require('services/TranslationFileHashLoaderService.ts');

oppia.directive('i18nFooter', ['UrlInterpolationService', function(
UrlInterpolationService) {
return {
restrict: 'E',
scope: {},
bindToController: {},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/i18n-footer.directive.html'),
controllerAs: '$ctrl',
controller: [
'$cookies', '$http', '$rootScope', '$scope', '$timeout', '$translate',
'UserService',
function(
$cookies, $http, $rootScope, $scope, $timeout, $translate,
UserService) {
var ctrl = this;
// Changes the language of the translations.
var preferencesDataUrl = '/preferenceshandler/data';
var siteLanguageUrl = '/save_site_language';
ctrl.supportedSiteLanguages = constants.SUPPORTED_SITE_LANGUAGES;
angular.module('oppia').directive('i18nFooter', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
restrict: 'E',
scope: {},
bindToController: {},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/i18n-footer.directive.html'),
controllerAs: '$ctrl',
controller: [
'$http', '$timeout', '$translate', 'UserService',
function($http, $timeout, $translate, UserService) {
var ctrl = this;
// Changes the language of the translations.
var preferencesDataUrl = '/preferenceshandler/data';
var siteLanguageUrl = '/save_site_language';
ctrl.supportedSiteLanguages = constants.SUPPORTED_SITE_LANGUAGES;

// The $timeout seems to be necessary for the dropdown to show anything
// at the outset, if the default language is not English.
$timeout(function() {
// $translate.use() returns undefined until the language file is fully
// loaded, which causes a blank field in the dropdown, hence we use
// $translate.proposedLanguage() as suggested in
// http://stackoverflow.com/a/28903658
ctrl.currentLanguageCode = $translate.use() ||
$translate.proposedLanguage();
}, 50);
// The $timeout seems to be necessary for the dropdown to show anything
// at the outset, if the default language is not English.
$timeout(function() {
// $translate.use() returns undefined until the language file is fully
// loaded, which causes a blank field in the dropdown, hence we use
// $translate.proposedLanguage() as suggested in
// http://stackoverflow.com/a/28903658
ctrl.currentLanguageCode = $translate.use() ||
$translate.proposedLanguage();
}, 50);

ctrl.changeLanguage = function() {
$translate.use(ctrl.currentLanguageCode);
UserService.getUserInfoAsync().then(function(userInfo) {
if (userInfo.isLoggedIn()) {
$http.put(siteLanguageUrl, {
site_language_code: ctrl.currentLanguageCode
});
}
});
};
}]};
ctrl.changeLanguage = function() {
$translate.use(ctrl.currentLanguageCode);
UserService.getUserInfoAsync().then(function(userInfo) {
if (userInfo.isLoggedIn()) {
$http.put(siteLanguageUrl, {
site_language_code: ctrl.currentLanguageCode
});
}
});
};
}]};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ']' should move to the next line to match the opening indentation.

The '}' should move to the line after that.

In general, when you see a gap that's too big between indentation levels, please fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #7066.

}]);

angular.module('oppia').config([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
require('domain/utilities/UrlInterpolationService.ts');
require('services/contextual/DocumentAttributeCustomizationService.ts');

var oppia = require('AppInit.ts').module;

oppia.controller('Maintenance', [
angular.module('oppia').controller('Maintenance', [
'$rootScope', '$scope', 'DocumentAttributeCustomizationService',
'UrlInterpolationService', 'DEV_MODE',
function($rootScope, $scope, DocumentAttributeCustomizationService,
Expand Down
32 changes: 15 additions & 17 deletions core/templates/dev/head/pages/thanks-page/thanks-page.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ require(

require('domain/utilities/UrlInterpolationService.ts');

var oppia = require('AppInit.ts').module;

oppia.directive('thanksPage', ['UrlInterpolationService', function(
UrlInterpolationService) {
return {
restrict: 'E',
scope: {},
bindToController: {},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/pages/thanks-page/thanks-page.directive.html'),
controllerAs: '$ctrl',
controller: ['UrlInterpolationService', function(UrlInterpolationService) {
var ctrl = this;
ctrl.thanksImgUrl = UrlInterpolationService.getStaticImageUrl(
'/general/donate.png');
}]};
}]);
angular.module('oppia').directive('thanksPage', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
restrict: 'E',
scope: {},
bindToController: {},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/pages/thanks-page/thanks-page.directive.html'),
controllerAs: '$ctrl',
controller: ['UrlInterpolationService', function(UrlInterpolationService) {
var ctrl = this;
ctrl.thanksImgUrl = UrlInterpolationService.getStaticImageUrl(
'/general/donate.png');
}]};
}]);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 The Oppia Authors. All Rights Reserved.
// Copyright 2019 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -13,9 +13,10 @@
// limitations under the License.

/**
* @fileoverview Scripts for the 'thanks' page.
* @fileoverview Scripts for the thanks page.
*/

require('AppInit.ts');
require('App.ts');

require('base_components/BaseContentDirective.ts');
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = {
story_viewer:
commonPrefix + '/pages/story-viewer-page/story-viewer-page.scripts.ts',
teach: commonPrefix + '/pages/teach-page/teach-page.scripts.ts',
terms: commonPrefix + '/pages/terms-page/terms-page.controller.ts',
terms: commonPrefix + '/pages/terms-page/terms-page.scripts.ts',
thanks: commonPrefix + '/pages/thanks-page/thanks-page.scripts.ts',
topic_editor:
commonPrefix + '/pages/topic-editor-page/topic-editor-page.scripts.ts',
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.