Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into author-tag-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
oswellchan committed Mar 15, 2016
2 parents 999a658 + c53b2ef commit 76ee130
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
3 changes: 3 additions & 0 deletions core/templates/dev/head/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ oppia.factory('urlService', ['$window', function($window) {
},
isIframed: function() {
return !!(this.getUrlParams().iframed);
},
getPathname: function() {
return window.location.pathname;
}
};
}]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
// Service for the create/upload exploration buttons and modals.
oppia.factory('ExplorationCreationButtonService', [
'$filter', '$http', '$modal', '$timeout', '$rootScope', '$window',
'validatorsService', 'alertsService', 'focusService', 'siteAnalyticsService',
'validatorsService', 'alertsService', 'focusService',
'siteAnalyticsService', 'urlService',
function(
$filter, $http, $modal, $timeout, $rootScope, $window,
validatorsService, alertsService, focusService, siteAnalyticsService) {
validatorsService, alertsService, focusService,
siteAnalyticsService, urlService) {
var getModalInstance = function(categoryList, isUploadModal) {
var modalInstance = $modal.open({
backdrop: true,
Expand Down Expand Up @@ -138,31 +140,37 @@ oppia.factory('ExplorationCreationButtonService', [
showCreateExplorationModal: function(categoryList) {
alertsService.clearWarnings();

siteAnalyticsService.registerOpenExplorationCreationModalEvent();
var currentPathname = urlService.getPathname();

getModalInstance(categoryList, false).result.then(function(result) {
var category = $filter('normalizeWhitespace')(result.category);
if (!validatorsService.isValidEntityName(category, true)) {
return;
}
if (currentPathname !== '/my_explorations') {
window.location.replace('/my_explorations?mode=create');
} else {
siteAnalyticsService.registerOpenExplorationCreationModalEvent();

$rootScope.loadingMessage = 'Creating exploration';
$http.post('/contributehandler/create_new', {
category: category,
language_code: result.languageCode,
objective: $filter('normalizeWhitespace')(result.objective),
title: result.title
}).success(function(data) {
siteAnalyticsService.registerCreateNewExplorationEvent(
data.explorationId);
$timeout(function() {
$window.location = '/create/' + data.explorationId;
}, 150);
return false;
}).error(function() {
$rootScope.loadingMessage = '';
getModalInstance(categoryList, false).result.then(function(result) {
var category = $filter('normalizeWhitespace')(result.category);
if (!validatorsService.isValidEntityName(category, true)) {
return;
}

$rootScope.loadingMessage = 'Creating exploration';
$http.post('/contributehandler/create_new', {
category: category,
language_code: result.languageCode,
objective: $filter('normalizeWhitespace')(result.objective),
title: result.title
}).success(function(data) {
siteAnalyticsService.registerCreateNewExplorationEvent(
data.explorationId);
$timeout(function() {
$window.location = '/create/' + data.explorationId;
}, 150);
return false;
}).error(function() {
$rootScope.loadingMessage = '';
});
});
});
}
},
showUploadExplorationModal: function(categoryList) {
alertsService.clearWarnings();
Expand Down

0 comments on commit 76ee130

Please sign in to comment.