Skip to content

Commit

Permalink
Remove oppia module export. (oppia#7259)
Browse files Browse the repository at this point in the history
* Half

* half

* half

* Cleanup

* Cleanup

* Cleanup

* Break line

* Remove var oppia from App.ts

* Removed var oppia

* Removed var oppia

* Partial lint

* FIx FE

* Partial lint

* Partial lint

* Partial lint

* Partial lint

* Fix learner dashboard

* Partial lint

* Lint

* Address review

* Update package.json

* Update package.json

* Revert "Update package.json"

This reverts commit 0530a8c.

* Revert "Update package.json"

This reverts commit c18ff6a.

* Revert "Address review"

This reverts commit 333e7fa.

* Revert package.json
  • Loading branch information
YashJipkate authored and seanlip committed Aug 1, 2019
1 parent 22fdc7f commit 3923234
Show file tree
Hide file tree
Showing 740 changed files with 7,204 additions and 8,302 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"error",
"array",
],
"angular/di-order": "error",
"angular/di-unused": "error",
"angular/directive-restrict": [
"error",
Expand Down
12 changes: 5 additions & 7 deletions core/templates/dev/head/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ require('app.constants.ts');
// loaded after app.constants.ts
require('I18nFooter.ts');

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

oppia.config([
angular.module('oppia').config([
'$compileProvider', '$cookiesProvider', '$httpProvider',
'$interpolateProvider', '$locationProvider',
function(
Expand Down Expand Up @@ -148,7 +146,7 @@ oppia.config([
}
]);

oppia.config(['$provide', function($provide) {
angular.module('oppia').config(['$provide', function($provide) {
$provide.decorator('$log', ['$delegate', 'DEV_MODE',
function($delegate, DEV_MODE) {
var _originalError = $delegate.error;
Expand All @@ -172,7 +170,7 @@ oppia.config(['$provide', function($provide) {
]);
}]);

oppia.config(['toastrConfig', function(toastrConfig) {
angular.module('oppia').config(['toastrConfig', function(toastrConfig) {
angular.extend(toastrConfig, {
allowHtml: false,
iconClasses: {
Expand All @@ -191,8 +189,8 @@ oppia.config(['toastrConfig', function(toastrConfig) {

// Overwrite the built-in exceptionHandler service to log errors to the backend
// (so that they can be fixed).
oppia.factory('$exceptionHandler', ['$log', 'CsrfTokenService',
function($log, CsrfTokenService) {
angular.module('oppia').factory('$exceptionHandler', [
'$log', 'CsrfTokenService', function($log, CsrfTokenService) {
var MIN_TIME_BETWEEN_ERRORS_MSEC = 5000;
var timeOfLastPostedError = Date.now() - MIN_TIME_BETWEEN_ERRORS_MSEC;

Expand Down
17 changes: 7 additions & 10 deletions core/templates/dev/head/AppInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ const downgradedModule = downgradeModule(bootstrapFn);

declare var angular: any;

var oppia = angular.module(
'oppia', [
'dndLists', 'headroom', 'infinite-scroll', 'ngAnimate',
'ngAudio', 'ngCookies', 'ngImgCrop', 'ngJoyRide', 'ngMaterial',
'ngResource', 'ngSanitize', 'ngTouch', 'pascalprecht.translate',
'toastr', 'ui.bootstrap', 'ui.sortable', 'ui.tree', 'ui.validate',
downgradedModule
].concat(
angular.module('oppia', [
'dndLists', 'headroom', 'infinite-scroll', 'ngAnimate',
'ngAudio', 'ngCookies', 'ngImgCrop', 'ngJoyRide', 'ngMaterial',
'ngResource', 'ngSanitize', 'ngTouch', 'pascalprecht.translate',
'toastr', 'ui.bootstrap', 'ui.sortable', 'ui.tree', 'ui.validate',
downgradedModule
].concat(
window.GLOBALS ? (window.GLOBALS.ADDITIONAL_ANGULAR_MODULES || []) : []))
// This directive is the downgraded version of the Angular component to
// bootstrap the Angular 8.
Expand All @@ -76,5 +75,3 @@ var oppia = angular.module(
downgradeComponent({
component: ServiceBootstrapComponent
}) as angular.IDirectiveFactory);

exports.module = oppia;
13 changes: 5 additions & 8 deletions core/templates/dev/head/I18nFooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
* @author milagro.teruel@gmail.com (Milagro Teruel)
*/

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

oppia.controller('I18nFooter', [
'$cookies', '$http', '$rootScope', '$scope', '$timeout', '$translate',
'UserService',
function(
$cookies, $http, $rootScope, $scope, $timeout, $translate,
UserService) {
angular.module('oppia').controller('I18nFooter', [
'$http', '$scope', '$timeout', '$translate', 'UserService',
function($http, $scope, $timeout, $translate, UserService) {
// Changes the language of the translations.
var preferencesDataUrl = '/preferenceshandler/data';
var siteLanguageUrl = '/save_site_language';
Expand Down Expand Up @@ -55,7 +52,7 @@ oppia.controller('I18nFooter', [
}
]);

oppia.config([
angular.module('oppia').config([
'$translateProvider', 'DEFAULT_TRANSLATIONS',
function($translateProvider, DEFAULT_TRANSLATIONS) {
var availableLanguageKeys = [];
Expand Down
110 changes: 60 additions & 50 deletions core/templates/dev/head/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
* @fileoverview Shared constants for the Oppia module.
*/

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

for (var constantName in constants) {
oppia.constant(constantName, constants[constantName]);
angular.module('oppia').constant(constantName, constants[constantName]);
}

// Translations of strings that are loaded in the front page. They are listed
// here to be loaded synchronously with the script to prevent a FOUC or
// Flash of Untranslated Content.
// See http://angular-translate.github.io/docs/#/guide/12_asynchronous-loading
oppia.constant('DEFAULT_TRANSLATIONS', {
angular.module('oppia').constant('DEFAULT_TRANSLATIONS', {
I18N_LIBRARY_PAGE_TITLE: 'Library',
I18N_LIBRARY_LOADING: 'Loading',
I18N_SIGNUP_PAGE_SUBTITLE: 'Registration',
Expand All @@ -41,46 +39,48 @@ oppia.constant('DEFAULT_TRANSLATIONS', {
I18N_SIGNUP_LOADING: 'Loading'
});

oppia.constant('RULE_SUMMARY_WRAP_CHARACTER_COUNT', 30);
angular.module('oppia').constant('RULE_SUMMARY_WRAP_CHARACTER_COUNT', 30);

oppia.constant(
angular.module('oppia').constant(
'FEEDBACK_SUBJECT_MAX_CHAR_LIMIT',
constants.FEEDBACK_SUBJECT_MAX_CHAR_LIMIT);

/* Called always when learner moves to a new card.
Also called when card is selected by clicking on progress dots */
oppia.constant('EVENT_ACTIVE_CARD_CHANGED', 'activeCardChanged');
angular.module('oppia').constant(
'EVENT_ACTIVE_CARD_CHANGED', 'activeCardChanged');
/* Called when the learner moves to a new card that they haven't seen before. */
oppia.constant('EVENT_NEW_CARD_OPENED', 'newCardOpened');
oppia.constant(
angular.module('oppia').constant('EVENT_NEW_CARD_OPENED', 'newCardOpened');
angular.module('oppia').constant(
'EDITABLE_EXPLORATION_DATA_DRAFT_URL_TEMPLATE',
'/createhandler/data/<exploration_id>?apply_draft=<apply_draft>');
oppia.constant(
angular.module('oppia').constant(
'EDITABLE_EXPLORATION_DATA_URL_TEMPLATE',
'/createhandler/data/<exploration_id>');
oppia.constant(
angular.module('oppia').constant(
'EXPLORATION_DATA_URL_TEMPLATE',
'/explorehandler/init/<exploration_id>');
oppia.constant(
angular.module('oppia').constant(
'EXPLORATION_VERSION_DATA_URL_TEMPLATE',
'/explorehandler/init/<exploration_id>?v=<version>');
oppia.constant(
angular.module('oppia').constant(
'VOICEOVER_EXPLORATION_DATA_URL_TEMPLATE',
'/createhandler/voiceover/<exploration_id>');
/* New card is available but user hasn't gone to it yet (when oppia
gives a feedback and waits for user to press 'continue').
Not called when a card is selected by clicking progress dots */
oppia.constant('EVENT_NEW_CARD_AVAILABLE', 'newCardAvailable');
angular.module('oppia').constant(
'EVENT_NEW_CARD_AVAILABLE', 'newCardAvailable');

oppia.constant('WARNING_TYPES', {
angular.module('oppia').constant('WARNING_TYPES', {
// These must be fixed before the exploration can be saved.
CRITICAL: 'critical',
// These must be fixed before publishing an exploration to the public
// library.
ERROR: 'error'
});

oppia.constant('STATE_ERROR_MESSAGES', {
angular.module('oppia').constant('STATE_ERROR_MESSAGES', {
ADD_INTERACTION: 'Please add an interaction to this card.',
STATE_UNREACHABLE: 'This card is unreachable.',
UNABLE_TO_END_EXPLORATION: (
Expand All @@ -93,72 +93,82 @@ oppia.constant('STATE_ERROR_MESSAGES', {
'There is an answer among the top 10 which has no explicit feedback.')
});

oppia.constant(
angular.module('oppia').constant(
'EXPLORATION_SUMMARY_DATA_URL_TEMPLATE', '/explorationsummarieshandler/data');

oppia.constant('EXPLORATION_AND_SKILL_ID_PATTERN', /^[a-zA-Z0-9_-]+$/);
angular.module('oppia').constant(
'EXPLORATION_AND_SKILL_ID_PATTERN', /^[a-zA-Z0-9_-]+$/);

// We use a slash because this character is forbidden in a state name.
oppia.constant('PLACEHOLDER_OUTCOME_DEST', '/');
oppia.constant('INTERACTION_DISPLAY_MODE_INLINE', 'inline');
oppia.constant('LOADING_INDICATOR_URL', '/activity/loadingIndicator.gif');
oppia.constant('OBJECT_EDITOR_URL_PREFIX', '/object_editor_template/');
angular.module('oppia').constant('PLACEHOLDER_OUTCOME_DEST', '/');
angular.module('oppia').constant('INTERACTION_DISPLAY_MODE_INLINE', 'inline');
angular.module('oppia').constant(
'LOADING_INDICATOR_URL', '/activity/loadingIndicator.gif');
angular.module('oppia').constant(
'OBJECT_EDITOR_URL_PREFIX', '/object_editor_template/');
// Feature still in development.
// NOTE TO DEVELOPERS: This should be synchronized with the value in feconf.
oppia.constant('ENABLE_ML_CLASSIFIERS', false);
angular.module('oppia').constant('ENABLE_ML_CLASSIFIERS', false);
// Feature still in development.
oppia.constant('INFO_MESSAGE_SOLUTION_IS_INVALID_FOR_EXPLORATION',
angular.module('oppia').constant(
'INFO_MESSAGE_SOLUTION_IS_INVALID_FOR_EXPLORATION',
'The current solution does not lead to another card.');
oppia.constant('PARAMETER_TYPES', {
angular.module('oppia').constant('PARAMETER_TYPES', {
REAL: 'Real',
UNICODE_STRING: 'UnicodeString'
});

// The maximum number of nodes to show in a row of the state graph.
oppia.constant('MAX_NODES_PER_ROW', 4);
angular.module('oppia').constant('MAX_NODES_PER_ROW', 4);
// The following variable must be at least 3. It represents the maximum length,
// in characters, for the name of each node label in the state graph.
oppia.constant('MAX_NODE_LABEL_LENGTH', 15);
angular.module('oppia').constant('MAX_NODE_LABEL_LENGTH', 15);

// If an $http request fails with the following error codes, a warning is
// displayed.
oppia.constant('FATAL_ERROR_CODES', [400, 401, 404, 500]);
angular.module('oppia').constant('FATAL_ERROR_CODES', [400, 401, 404, 500]);

// Do not modify these, for backwards-compatibility reasons.
oppia.constant('COMPONENT_NAME_CONTENT', 'content');
oppia.constant('COMPONENT_NAME_HINT', 'hint');
oppia.constant('COMPONENT_NAME_SOLUTION', 'solution');
oppia.constant('COMPONENT_NAME_FEEDBACK', 'feedback');
oppia.constant('COMPONENT_NAME_EXPLANATION', 'explanation');
oppia.constant('COMPONENT_NAME_WORKED_EXAMPLE', 'worked_example');

oppia.constant('ACTION_TYPE_EXPLORATION_START', 'ExplorationStart');
oppia.constant('ACTION_TYPE_ANSWER_SUBMIT', 'AnswerSubmit');
oppia.constant('ACTION_TYPE_EXPLORATION_QUIT', 'ExplorationQuit');

oppia.constant('ISSUE_TYPE_EARLY_QUIT', 'EarlyQuit');
oppia.constant(
angular.module('oppia').constant('COMPONENT_NAME_CONTENT', 'content');
angular.module('oppia').constant('COMPONENT_NAME_HINT', 'hint');
angular.module('oppia').constant('COMPONENT_NAME_SOLUTION', 'solution');
angular.module('oppia').constant('COMPONENT_NAME_FEEDBACK', 'feedback');
angular.module('oppia').constant('COMPONENT_NAME_EXPLANATION', 'explanation');
angular.module('oppia').constant(
'COMPONENT_NAME_WORKED_EXAMPLE', 'worked_example');

angular.module('oppia').constant(
'ACTION_TYPE_EXPLORATION_START', 'ExplorationStart');
angular.module('oppia').constant('ACTION_TYPE_ANSWER_SUBMIT', 'AnswerSubmit');
angular.module('oppia').constant(
'ACTION_TYPE_EXPLORATION_QUIT', 'ExplorationQuit');

angular.module('oppia').constant('ISSUE_TYPE_EARLY_QUIT', 'EarlyQuit');
angular.module('oppia').constant(
'ISSUE_TYPE_MULTIPLE_INCORRECT_SUBMISSIONS', 'MultipleIncorrectSubmissions');
oppia.constant('ISSUE_TYPE_CYCLIC_STATE_TRANSITIONS', 'CyclicStateTransitions');
oppia.constant('SITE_NAME', 'Oppia.org');
angular.module('oppia').constant(
'ISSUE_TYPE_CYCLIC_STATE_TRANSITIONS', 'CyclicStateTransitions');
angular.module('oppia').constant('SITE_NAME', 'Oppia.org');

oppia.constant('DEFAULT_PROFILE_IMAGE_PATH', '/avatar/user_blue_72px.png');
angular.module('oppia').constant(
'DEFAULT_PROFILE_IMAGE_PATH', '/avatar/user_blue_72px.png');

oppia.constant('LOGOUT_URL', '/logout');
angular.module('oppia').constant('LOGOUT_URL', '/logout');

oppia.constant(
angular.module('oppia').constant(
'EVENT_QUESTION_SUMMARIES_INITIALIZED', 'questionSummariesInitialized');

// TODO(vojtechjelinek): Move these to separate file later, after we establish
// process to follow for Angular constants (#6731).
oppia.constant(
angular.module('oppia').constant(
'SUBTOPIC_PAGE_EDITOR_DATA_URL_TEMPLATE',
'/subtopic_page_editor_handler/data/<topic_id>/<subtopic_id>');
oppia.constant(
angular.module('oppia').constant(
'EDITABLE_TOPIC_DATA_URL_TEMPLATE', '/topic_editor_handler/data/<topic_id>');

oppia.constant('LABEL_FOR_CLEARING_FOCUS', 'labelForClearingFocus');
angular.module('oppia').constant(
'LABEL_FOR_CLEARING_FOCUS', 'labelForClearingFocus');

// TODO(bhenning): This constant should be provided by the backend.
oppia.constant(
angular.module('oppia').constant(
'COLLECTION_DATA_URL_TEMPLATE', '/collection_handler/data/<collection_id>');
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ require('domain/utilities/UrlInterpolationService.ts');
require('services/contextual/UrlService.ts');
require('services/stateful/BackgroundMaskService.ts');

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

oppia.directive('baseContent', [
angular.module('oppia').directive('baseContent', [
'UrlInterpolationService',
function(UrlInterpolationService) {
return {
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/AlertsService.ts');

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

oppia.directive('warningLoader', [
angular.module('oppia').directive('warningLoader', [
'UrlInterpolationService',
function(UrlInterpolationService) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ require('services/contextual/UrlService.ts');
require('services/SiteAnalyticsService.ts');
require('services/UserService.ts');

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

oppia.directive('createActivityButton', [
angular.module('oppia').directive('createActivityButton', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
restrict: 'E',
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/SiteAnalyticsService.ts');

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

oppia.factory('ExplorationEmbedButtonService', [
angular.module('oppia').factory('ExplorationEmbedButtonService', [
'$uibModal', 'SiteAnalyticsService', 'UrlInterpolationService',
function($uibModal, SiteAnalyticsService, UrlInterpolationService) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ require('services/contextual/DeviceInfoService.ts');

require('pages/exploration-player-page/exploration-player-page.constants.ts');

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

oppia.directive('hintAndSolutionButtons', [
angular.module('oppia').directive('hintAndSolutionButtons', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
restrict: 'E',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

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

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

oppia.directive('socialButtons', [
angular.module('oppia').directive('socialButtons', [
'UrlInterpolationService', function(UrlInterpolationService) {
return {
restrict: 'E',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
require('services/ContextService.ts');
require('services/RteHelperService.ts');

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

oppia.directive('ckEditor4Rte', [
angular.module('oppia').directive('ckEditor4Rte', [
'ContextService', 'RteHelperService', 'PAGE_CONTEXT',
function(ContextService, RteHelperService, PAGE_CONTEXT) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ require('rich_text_components/richTextComponentsRequires.ts');
require('services/HtmlEscaperService.ts');
require('services/RteHelperService.ts');

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

oppia.run([
'$timeout', '$compile', '$rootScope', '$uibModal', 'RteHelperService',
angular.module('oppia').run([
'$timeout', '$compile', '$rootScope', 'RteHelperService',
'HtmlEscaperService',
function($timeout, $compile, $rootScope, $uibModal, RteHelperService,
function($timeout, $compile, $rootScope, RteHelperService,
HtmlEscaperService) {
var _RICH_TEXT_COMPONENTS = RteHelperService.getRichTextComponents();
_RICH_TEXT_COMPONENTS.forEach(function(componentDefn) {
Expand Down
Loading

0 comments on commit 3923234

Please sign in to comment.