Relocating inside the cms namespace

Addressing feedback
This commit is contained in:
Felipe Montoya
2016-06-23 16:30:57 -05:00
parent 27d4e4bdc2
commit c32b30ba94
20 changed files with 33 additions and 34 deletions

View File

@@ -6,7 +6,7 @@ define([
'backbone-relational',
'backbone.associations',
'gettext',
'js/main',
'cms/js/main',
'js/certificates/models/signatory',
'js/certificates/collections/signatories'
],

View File

@@ -1,2 +1,2 @@
define(['js/base', 'js/main', 'js/src/logger', 'datepair', 'accessibility',
define(['js/base', 'cms/js/main', 'js/src/logger', 'datepair', 'accessibility',
'ieshim', 'tooltip_manager', 'lang_edx', 'js/models/course']);

View File

@@ -1,6 +1,6 @@
define([
'jquery', 'underscore', 'js/models/xblock_container_info', 'js/views/pages/container',
'js/collections/component_template', 'xmodule', 'js/main',
'js/collections/component_template', 'xmodule', 'cms/js/main',
'xblock/cms.runtime.v1'
],
function($, _, XBlockContainerInfo, ContainerPage, ComponentTemplates, xmoduleLoader) {

View File

@@ -1,5 +1,5 @@
define([
'js/models/explicit_url', 'js/views/tabs', 'xmodule', 'js/main', 'xblock/cms.runtime.v1'
'js/models/explicit_url', 'js/views/tabs', 'xmodule', 'cms/js/main', 'xblock/cms.runtime.v1'
], function (TabsModel, TabsEditView, xmoduleLoader) {
'use strict';
return function (courseLocation, explicitUrl) {

View File

@@ -1,6 +1,6 @@
define([
'jquery', 'underscore', 'js/models/xblock_info', 'js/views/pages/paged_container',
'js/views/library_container', 'js/collections/component_template', 'xmodule', 'js/main',
'js/views/library_container', 'js/collections/component_template', 'xmodule', 'cms/js/main',
'xblock/cms.runtime.v1'
],
function($, _, XBlockInfo, PagedContainerPage, LibraryContainerView, ComponentTemplates, xmoduleLoader) {

View File

@@ -1,71 +0,0 @@
(function(AjaxPrefix) {
'use strict';
define(['domReady', 'jquery', 'underscore.string', 'backbone', 'gettext',
'common/js/components/views/feedback_notification', 'coffee/src/ajax_prefix',
'jquery.cookie'],
function(domReady, $, str, Backbone, gettext, NotificationView) {
var main;
main = function() {
AjaxPrefix.addAjaxPrefix(jQuery, function() {
return $("meta[name='path_prefix']").attr('content');
});
window.CMS = window.CMS || {};
window.CMS.URL = window.CMS.URL || {};
window.onTouchBasedDevice = function() {
return navigator.userAgent.match(/iPhone|iPod|iPad|Android/i);
};
_.extend(window.CMS, Backbone.Events);
Backbone.emulateHTTP = true;
$.ajaxSetup({
headers: {
'X-CSRFToken': $.cookie('csrftoken')
},
dataType: 'json'
});
$(document).ajaxError(function(event, jqXHR, ajaxSettings) {
var message, msg;
if (ajaxSettings.notifyOnError === false) {
return;
}
if (jqXHR.responseText) {
try {
message = JSON.parse(jqXHR.responseText).error;
} catch (error) {
message = str.truncate(jqXHR.responseText, 300);
}
} else {
message = gettext('This may be happening because of an error with our server' +
'or your internet connection. Try refreshing the page or making' +
'sure you are online.');
}
msg = new NotificationView.Error({
'title': gettext("Studio's having trouble saving your work"),
'message': message
});
return msg.show();
});
$.postJSON = function(url, data, callback) {
if ($.isFunction(data)) {
callback = data;
data = undefined;
}
return $.ajax({
url: url,
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(data),
success: callback
});
};
return domReady(function() {
if (window.onTouchBasedDevice()) {
return $('body').addClass('touch-based-device');
}
});
};
main();
return main;
});
}).call(this, AjaxPrefix); //jshint ignore:line

View File

@@ -1,6 +1,6 @@
define([
'backbone', 'underscore', 'gettext', 'js/models/group', 'js/collections/group',
'backbone.associations', 'js/main'
'backbone.associations', 'cms/js/main'
],
function(Backbone, _, gettext, GroupModel, GroupCollection) {
'use strict';

View File

@@ -1,5 +1,5 @@
define(["backbone", "underscore", "gettext", "js/models/chapter", "js/collections/chapter",
"backbone.associations", "js/main"],
"backbone.associations", "cms/js/main"],
function(Backbone, _, gettext, ChapterModel, ChapterCollection) {
var Textbook = Backbone.AssociatedModel.extend({

View File

@@ -1,81 +0,0 @@
(function(sandbox) {
'use strict';
require(["jquery", "backbone", "js/main", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "jquery.cookie"],
function($, Backbone, main, AjaxHelpers) {
describe("CMS", function() {
return it("should initialize URL", function() {
return expect(window.CMS.URL).toBeDefined();
});
});
describe("main helper", function() {
beforeEach(function() {
this.previousAjaxSettings = $.extend(true, {}, $.ajaxSettings);
spyOn($, "cookie").and.callFake(function(param) {
if (param === "csrftoken") {
return "stubCSRFToken";
}
});
return main();
});
afterEach(function() {
$.ajaxSettings = this.previousAjaxSettings;
return $.ajaxSettings;
});
it("turn on Backbone emulateHTTP", function() {
return expect(Backbone.emulateHTTP).toBeTruthy();
});
return it("setup AJAX CSRF token", function() {
return expect($.ajaxSettings.headers["X-CSRFToken"]).toEqual("stubCSRFToken");
});
});
describe("AJAX Errors", function() {
var server;
server = null;
beforeEach(function() {
return appendSetFixtures(sandbox({
id: "page-notification"
}));
});
afterEach(function() {
return server && server.restore();
});
it("successful AJAX request does not pop an error notification", function() {
server = AjaxHelpers.server([
200, {
"Content-Type": "application/json"
}, "{}"
]);
expect($("#page-notification")).toBeEmpty();
$.ajax("/test");
expect($("#page-notification")).toBeEmpty();
server.respond();
return expect($("#page-notification")).toBeEmpty();
});
it("AJAX request with error should pop an error notification", function() {
server = AjaxHelpers.server([
500, {
"Content-Type": "application/json"
}, "{}"
]);
$.ajax("/test");
server.respond();
expect($("#page-notification")).not.toBeEmpty();
return expect($("#page-notification")).toContainElement('div.wrapper-notification-error');
});
it("can override AJAX request with error so it does not pop an error notification", function() {
server = AjaxHelpers.server([
500, {
"Content-Type": "application/json"
}, "{}"
]);
$.ajax({
url: "/test",
notifyOnError: false
});
server.respond();
return expect($("#page-notification")).toBeEmpty();
});
});
});
}).call(this, sandbox); //jshint ignore:line

View File

@@ -1,5 +1,5 @@
define([
'backbone', 'js/main', 'js/models/group_configuration',
'backbone', 'cms/js/main', 'js/models/group_configuration',
'js/models/group', 'js/collections/group', 'squire'
], function (Backbone, main, GroupConfigurationModel, GroupModel, GroupCollection, Squire) {
'use strict';

View File

@@ -1,6 +1,6 @@
define([ "jquery", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "js/spec_helpers/edit_helpers",
"js/views/container", "js/models/xblock_info", "jquery.simulate",
"xmodule", "js/main", "xblock/cms.runtime.v1"],
"xmodule", "cms/js/main", "xblock/cms.runtime.v1"],
function ($, AjaxHelpers, EditHelpers, ContainerView, XBlockInfo) {
describe("Container View", function () {

View File

@@ -1,5 +1,5 @@
define(["jquery", "URI", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers", "common/js/components/utils/view_utils",
"js/views/xblock", "js/models/xblock_info", "xmodule", "js/main", "xblock/cms.runtime.v1"],
"js/views/xblock", "js/models/xblock_info", "xmodule", "cms/js/main", "xblock/cms.runtime.v1"],
function ($, URI, AjaxHelpers, ViewUtils, XBlockView, XBlockInfo) {
"use strict";
describe("XBlockView", function() {

View File

@@ -3,7 +3,7 @@
*/
define(["jquery", "underscore", "edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers",
"common/js/spec_helpers/template_helpers", "js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock",
"js/collections/component_template", "xmodule", "js/main", "xblock/cms.runtime.v1"],
"js/collections/component_template", "xmodule", "cms/js/main", "xblock/cms.runtime.v1"],
function($, _, AjaxHelpers, TemplateHelpers, modal_helpers, EditXBlockModal, ComponentTemplates) {
var installMockXBlock, uninstallMockXBlock, installMockXModule, uninstallMockXModule,