Commit 519ebed6 by Andy Armstrong Committed by GitHub

Merge pull request #12780 from edx/andya/remove-coffeescript

Convert XBlock runtime code from CoffeeScript
parents 93850baf fff88151
**/vendor **/vendor
cms/static/cms/js/build.js
cms/static/cms/js/spec/main.js
cms/static/js/i18n/**/*.js cms/static/js/i18n/**/*.js
lms/static/js/i18n/**/*.js lms/static/js/i18n/**/*.js
lms/static/lms/js/build.js lms/static/lms/js/build.js
......
(function () { (function() {
'use strict'; 'use strict';
var commonLibrariesPath = 'common/js/common_libraries'; var commonLibrariesPath = 'common/js/common_libraries';
var getModule = function (moduleName, excludeCommonDeps) { var getModule = function(moduleName, excludeCommonDeps) {
var module = { var module = {
name: moduleName name: moduleName
}; };
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
return module; return module;
}; };
var getModulesList = function (modules) { var getModulesList = function(modules) {
var result = [getModule(commonLibrariesPath)]; var result = [getModule(commonLibrariesPath)];
return result.concat(modules.map(function (moduleName) { return result.concat(modules.map(function (moduleName) {
return getModule(moduleName, true); return getModule(moduleName, true);
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
/** /**
* Stub out requireJS text in the optimized file, but leave available for non-optimized development use. * Stub out requireJS text in the optimized file, but leave available for non-optimized development use.
*/ */
stubModules: ["text"], stubModules: ['text'],
/** /**
* If shim config is used in the app during runtime, duplicate the config * If shim config is used in the app during runtime, duplicate the config
...@@ -170,4 +170,4 @@ ...@@ -170,4 +170,4 @@
*/ */
logLevel: 1 logLevel: 1
}; };
} ()) }())
(function(requirejs, requireSerial) {
'use strict';
var i, specHelpers, testFiles;
requirejs.config({
baseUrl: '/base/',
paths: {
'gettext': 'xmodule_js/common_static/js/test/i18n',
'mustache': 'xmodule_js/common_static/js/vendor/mustache',
'codemirror': 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror',
'jquery': 'common/js/vendor/jquery',
'jquery-migrate': 'common/js/vendor/jquery-migrate',
'jquery.ui': 'xmodule_js/common_static/js/vendor/jquery-ui.min',
'jquery.form': 'xmodule_js/common_static/js/vendor/jquery.form',
'jquery.markitup': 'xmodule_js/common_static/js/vendor/markitup/jquery.markitup',
'jquery.leanModal': 'xmodule_js/common_static/js/vendor/jquery.leanModal',
'jquery.smoothScroll': 'xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min',
'jquery.scrollTo': 'common/js/vendor/jquery.scrollTo',
'jquery.timepicker': 'xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker',
'jquery.cookie': 'xmodule_js/common_static/js/vendor/jquery.cookie',
'jquery.qtip': 'xmodule_js/common_static/js/vendor/jquery.qtip.min',
'jquery.fileupload': 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload',
'jquery.fileupload-process': 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process', // jshint ignore:line
'jquery.fileupload-validate': 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate', // jshint ignore:line
'jquery.iframe-transport': 'xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport', // jshint ignore:line
'jquery.inputnumber': 'xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill',
'jquery.immediateDescendents': 'xmodule_js/common_static/coffee/src/jquery.immediateDescendents',
'datepair': 'xmodule_js/common_static/js/vendor/timepicker/datepair',
'date': 'xmodule_js/common_static/js/vendor/date',
'text': 'xmodule_js/common_static/js/vendor/requirejs/text',
'underscore': 'common/js/vendor/underscore',
'underscore.string': 'common/js/vendor/underscore.string',
'backbone': 'common/js/vendor/backbone',
'backbone.associations': 'xmodule_js/common_static/js/vendor/backbone-associations-min',
'backbone.paginator': 'common/js/vendor/backbone.paginator',
'tinymce': 'xmodule_js/common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min',
'jquery.tinymce': 'xmodule_js/common_static/js/vendor/tinymce/js/tinymce/jquery.tinymce',
'xmodule': 'xmodule_js/src/xmodule',
'xblock/cms.runtime.v1': 'cms/js/xblock/cms.runtime.v1',
'xblock': 'common/js/xblock',
'utility': 'xmodule_js/common_static/js/src/utility',
'sinon': 'xmodule_js/common_static/js/vendor/sinon-1.17.0',
'squire': 'xmodule_js/common_static/js/vendor/Squire',
'modernizr': 'edx-pattern-library/js/modernizr-custom',
'afontgarde': 'edx-pattern-library/js/afontgarde',
'edxicons': 'edx-pattern-library/js/edx-icons',
'draggabilly': 'xmodule_js/common_static/js/vendor/draggabilly',
'domReady': 'xmodule_js/common_static/js/vendor/domReady',
'URI': 'xmodule_js/common_static/js/vendor/URI.min',
'mathjax': '//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured', // jshint ignore:line
'youtube': '//www.youtube.com/player_api?noext',
'coffee/src/ajax_prefix': 'xmodule_js/common_static/coffee/src/ajax_prefix'
},
shim: {
'gettext': {
exports: 'gettext'
},
'date': {
exports: 'Date'
},
'jquery.ui': {
deps: ['jquery'],
exports: 'jQuery.ui'
},
'jquery.form': {
deps: ['jquery'],
exports: 'jQuery.fn.ajaxForm'
},
'jquery.markitup': {
deps: ['jquery'],
exports: 'jQuery.fn.markitup'
},
'jquery.leanModal': {
deps: ['jquery'],
exports: 'jQuery.fn.leanModal'
},
'jquery.smoothScroll': {
deps: ['jquery'],
exports: 'jQuery.fn.smoothScroll'
},
'jquery.scrollTo': {
deps: ['jquery'],
exports: 'jQuery.fn.scrollTo'
},
'jquery.cookie': {
deps: ['jquery'],
exports: 'jQuery.fn.cookie'
},
'jquery.qtip': {
deps: ['jquery'],
exports: 'jQuery.fn.qtip'
},
'jquery.fileupload': {
deps: ['jquery.ui', 'jquery.iframe-transport'],
exports: 'jQuery.fn.fileupload'
},
'jquery.fileupload-process': {
deps: ['jquery.fileupload']
},
'jquery.fileupload-validate': {
deps: ['jquery.fileupload']
},
'jquery.inputnumber': {
deps: ['jquery'],
exports: 'jQuery.fn.inputNumber'
},
'jquery.tinymce': {
deps: ['jquery', 'tinymce'],
exports: 'jQuery.fn.tinymce'
},
'datepair': {
deps: ['jquery.ui', 'jquery.timepicker']
},
'underscore': {
exports: '_'
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.associations': {
deps: ['backbone'],
exports: 'Backbone.Associations'
},
'backbone.paginator': {
deps: ['backbone'],
exports: 'Backbone.PageableCollection'
},
'youtube': {
exports: 'YT'
},
'codemirror': {
exports: 'CodeMirror'
},
'tinymce': {
exports: 'tinymce'
},
'mathjax': {
exports: 'MathJax',
init: function() {
window.MathJax.Hub.Config({
tex2jax: {
inlineMath: [['\\(', '\\)'], ['[mathjaxinline]', '[/mathjaxinline]']],
displayMath: [['\\[', '\\]'], ['[mathjax]', '[/mathjax]']]
}
});
window.MathJax.Hub.Configured();
}
},
'URI': {
exports: 'URI'
},
'xmodule': {
exports: 'XModule'
},
'sinon': {
exports: 'sinon'
},
'common/js/spec_helpers/jasmine-extensions': {
deps: ['jquery']
},
'common/js/spec_helpers/jasmine-stealth': {
deps: ['underscore', 'underscore.string']
},
'common/js/spec_helpers/jasmine-waituntil': {
deps: ['jquery']
},
'xblock/core': {
exports: 'XBlock',
deps: ['jquery', 'jquery.immediateDescendents']
},
'xblock/runtime.v1': {
exports: 'XBlock',
deps: ['xblock/core']
},
'coffee/src/main': {
deps: ['coffee/src/ajax_prefix']
},
'coffee/src/ajax_prefix': {
deps: ['jquery']
},
'modernizr': {
exports: 'Modernizr'
},
'afontgarde': {
exports: 'AFontGarde'
}
}
});
jasmine.getFixtures().fixturesPath += 'coffee/fixtures';
testFiles = [
'coffee/spec/views/assets_spec',
'js/spec/video/translations_editor_spec',
'js/spec/video/file_uploader_editor_spec',
'js/spec/models/group_configuration_spec'
];
i = 0;
while (i < testFiles.length) {
testFiles[i] = '/base/' + testFiles[i] + '.js';
i++;
}
specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
];
requireSerial(specHelpers.concat(testFiles), function() {
return window.__karma__.start();
});
}).call(this, requirejs, requireSerial); // jshint ignore:line
define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cms.runtime.v1"], define(['js/spec_helpers/edit_helpers', 'js/views/modals/base_modal', 'xblock/cms.runtime.v1'],
function (EditHelpers, BaseModal) { function(EditHelpers, BaseModal) {
'use strict';
describe("Studio Runtime v1", function() { describe('Studio Runtime v1', function() {
var runtime; var runtime;
beforeEach(function () { beforeEach(function() {
EditHelpers.installEditTemplates(); EditHelpers.installEditTemplates();
runtime = new window.StudioRuntime.v1(); runtime = new window.StudioRuntime.v1();
}); });
...@@ -20,7 +21,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm ...@@ -20,7 +21,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
}); });
it('shows save notifications', function() { it('shows save notifications', function() {
var title = "Mock saving...", var title = 'Mock saving...',
notificationSpy = EditHelpers.createNotificationSpy(); notificationSpy = EditHelpers.createNotificationSpy();
runtime.notify('save', { runtime.notify('save', {
state: 'start', state: 'start',
...@@ -34,9 +35,9 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm ...@@ -34,9 +35,9 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
}); });
it('shows error messages', function() { it('shows error messages', function() {
var title = "Mock Error", var title = 'Mock Error',
message = "This is a mock error.", message = 'This is a mock error.',
notificationSpy = EditHelpers.createNotificationSpy("Error"); notificationSpy = EditHelpers.createNotificationSpy('Error');
runtime.notify('error', { runtime.notify('error', {
title: title, title: title,
message: message message: message
...@@ -44,7 +45,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm ...@@ -44,7 +45,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
EditHelpers.verifyNotificationShowing(notificationSpy, title); EditHelpers.verifyNotificationShowing(notificationSpy, title);
}); });
describe("Modal Dialogs", function() { describe('Modal Dialogs', function() {
var MockModal, modal, showMockModal; var MockModal, modal, showMockModal;
MockModal = BaseModal.extend({ MockModal = BaseModal.extend({
...@@ -55,12 +56,12 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm ...@@ -55,12 +56,12 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
showMockModal = function() { showMockModal = function() {
modal = new MockModal({ modal = new MockModal({
title: "Mock Modal" title: 'Mock Modal'
}); });
modal.show(); modal.show();
}; };
beforeEach(function () { beforeEach(function() {
EditHelpers.installEditTemplates(); EditHelpers.installEditTemplates();
}); });
...@@ -68,7 +69,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm ...@@ -68,7 +69,7 @@ define(["js/spec_helpers/edit_helpers", "js/views/modals/base_modal", "xblock/cm
EditHelpers.hideModalIfShowing(modal); EditHelpers.hideModalIfShowing(modal);
}); });
it('cancels a modal dialog', function () { it('cancels a modal dialog', function() {
showMockModal(); showMockModal();
runtime.notify('modal-shown', modal); runtime.notify('modal-shown', modal);
expect(EditHelpers.isShowingModal(modal)).toBeTruthy(); expect(EditHelpers.isShowingModal(modal)).toBeTruthy();
......
define(['jquery', 'backbone', 'xblock/runtime.v1', 'URI', 'gettext', 'js/utils/modal',
'common/js/components/views/feedback_notification'],
function($, Backbone, XBlock, URI, gettext, ModalUtils, NotificationView) {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
var key;
for (key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
},
BaseRuntime = {},
PreviewRuntime = {},
StudioRuntime = {};
BaseRuntime.v1 = (function(_super) {
__extends(v1, _super);
v1.prototype.handlerUrl = function(element, handlerName, suffix, query) {
var uri;
uri = URI(this.handlerPrefix)
.segment($(element).data('usage-id'))
.segment('handler')
.segment(handlerName);
if (suffix !== null) {
uri.segment(suffix);
}
if (query !== null) {
uri.search(query);
}
return uri.toString();
};
function v1() {
v1.__super__.constructor.call(this);
this.dispatcher = _.clone(Backbone.Events);
this.listenTo('save', this._handleSave);
this.listenTo('cancel', this._handleCancel);
this.listenTo('error', this._handleError);
this.listenTo('modal-shown', function(data) {
this.modal = data;
});
this.listenTo('modal-hidden', function() {
this.modal = null;
});
this.listenTo('page-shown', function(data) {
this.page = data;
});
}
/**
* Notify the Studio client-side runtime of an event so that it
* can update the UI in a consistent way.
*
* @param {string} name The name of the event.
* @param {object} data A JSON representation of the data to be included with the event.
*/
v1.prototype.notify = function(name, data) {
this.dispatcher.trigger(name, data);
};
/**
* Listen to a Studio event and invoke the specified callback when it is triggered.
*
* @param {string} name The name of the event.
* @param {function} callback The callback to be invoked.
*/
v1.prototype.listenTo = function(name, callback) {
this.dispatcher.bind(name, callback, this);
};
/**
* Refresh the view for the xblock represented by the specified element.
*
* @param {element} element The element representing the XBlock.
*/
v1.prototype.refreshXBlock = function(element) {
if (this.page) {
this.page.refreshXBlock(element);
}
};
v1.prototype._handleError = function(data) {
var message, title;
message = data.message || data.msg;
if (message) {
// TODO: remove 'Open Assessment' specific default title
title = data.title || gettext('OpenAssessment Save Error');
this.alert = new NotificationView.Error({
title: title,
message: message,
closeIcon: false,
shown: false
});
this.alert.show();
}
};
v1.prototype._handleSave = function(data) {
var message;
// Starting to save, so show a notification
if (data.state === 'start') {
message = data.message || gettext('Saving');
this.notification = new NotificationView.Mini({
title: message
});
this.notification.show();
} else if (data.state === 'end') {
// Finished saving, so hide the notification and refresh appropriately
this._hideAlerts();
if (this.modal && this.modal.onSave) {
// Notify the modal that the save has completed so that it can hide itself
// and then refresh the xblock.
this.modal.onSave();
} else if (data.element) {
// ... else ask it to refresh the newly saved xblock
this.refreshXBlock(data.element);
}
this.notification.hide();
}
};
v1.prototype._handleCancel = function() {
this._hideAlerts();
if (this.modal) {
this.modal.cancel();
this.notify('modal-hidden');
}
};
/**
* Hide any alerts that are being shown.
*/
v1.prototype._hideAlerts = function() {
if (this.alert && this.alert.options.shown) {
this.alert.hide();
}
};
return v1;
})(XBlock.Runtime.v1);
PreviewRuntime.v1 = (function(_super) {
__extends(v1, _super);
function v1() {
return v1.__super__.constructor.apply(this, arguments);
}
v1.prototype.handlerPrefix = '/preview/xblock';
return v1;
})(BaseRuntime.v1);
StudioRuntime.v1 = (function(_super) {
__extends(v1, _super);
function v1() {
return v1.__super__.constructor.apply(this, arguments);
}
v1.prototype.handlerPrefix = '/xblock';
return v1;
})(BaseRuntime.v1);
// Install the runtime's into the global namespace
window.BaseRuntime = BaseRuntime;
window.PreviewRuntime = PreviewRuntime;
window.StudioRuntime = StudioRuntime;
});
requirejs.config({
baseUrl: '/base/',
paths: {
"gettext": "xmodule_js/common_static/js/test/i18n",
"mustache": "xmodule_js/common_static/js/vendor/mustache",
"codemirror": "xmodule_js/common_static/js/vendor/CodeMirror/codemirror",
"jquery": "common/js/vendor/jquery",
"jquery-migrate": "common/js/vendor/jquery-migrate",
"jquery.ui": "xmodule_js/common_static/js/vendor/jquery-ui.min",
"jquery.form": "xmodule_js/common_static/js/vendor/jquery.form",
"jquery.markitup": "xmodule_js/common_static/js/vendor/markitup/jquery.markitup",
"jquery.leanModal": "xmodule_js/common_static/js/vendor/jquery.leanModal",
"jquery.smoothScroll": "xmodule_js/common_static/js/vendor/jquery.smooth-scroll.min",
"jquery.scrollTo": "common/js/vendor/jquery.scrollTo",
"jquery.timepicker": "xmodule_js/common_static/js/vendor/timepicker/jquery.timepicker",
"jquery.cookie": "xmodule_js/common_static/js/vendor/jquery.cookie",
"jquery.qtip": "xmodule_js/common_static/js/vendor/jquery.qtip.min",
"jquery.fileupload": "xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload",
"jquery.fileupload-process": "xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-process",
"jquery.fileupload-validate": "xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.fileupload-validate",
"jquery.iframe-transport": "xmodule_js/common_static/js/vendor/jQuery-File-Upload/js/jquery.iframe-transport",
"jquery.inputnumber": "xmodule_js/common_static/js/vendor/html5-input-polyfills/number-polyfill",
"jquery.immediateDescendents": "xmodule_js/common_static/coffee/src/jquery.immediateDescendents",
"datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair",
"date": "xmodule_js/common_static/js/vendor/date",
"text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "common/js/vendor/underscore",
"underscore.string": "common/js/vendor/underscore.string",
"backbone": "common/js/vendor/backbone",
"backbone.associations": "xmodule_js/common_static/js/vendor/backbone-associations-min",
"backbone.paginator": "common/js/vendor/backbone.paginator",
"tinymce": "xmodule_js/common_static/js/vendor/tinymce/js/tinymce/tinymce.full.min",
"jquery.tinymce": "xmodule_js/common_static/js/vendor/tinymce/js/tinymce/jquery.tinymce",
"xmodule": "xmodule_js/src/xmodule",
"xblock/cms.runtime.v1": "coffee/src/xblock/cms.runtime.v1",
"xblock/core": "xmodule_js/common_static/js/xblock/core",
"xblock": "xmodule_js/common_static/coffee/src/xblock",
"utility": "xmodule_js/common_static/js/src/utility",
"sinon": "xmodule_js/common_static/js/vendor/sinon-1.17.0",
"squire": "xmodule_js/common_static/js/vendor/Squire",
"modernizr": "edx-pattern-library/js/modernizr-custom",
"afontgarde": "edx-pattern-library/js/afontgarde",
"edxicons": "edx-pattern-library/js/edx-icons",
"draggabilly": "xmodule_js/common_static/js/vendor/draggabilly",
"domReady": "xmodule_js/common_static/js/vendor/domReady",
"URI": "xmodule_js/common_static/js/vendor/URI.min",
"mathjax": "//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-MML-AM_SVG&delayStartupUntil=configured",
"youtube": "//www.youtube.com/player_api?noext",
"coffee/src/ajax_prefix": "xmodule_js/common_static/coffee/src/ajax_prefix"
}
shim: {
"gettext": {
exports: "gettext"
},
"date": {
exports: "Date"
},
"jquery.ui": {
deps: ["jquery"],
exports: "jQuery.ui"
},
"jquery.form": {
deps: ["jquery"],
exports: "jQuery.fn.ajaxForm"
},
"jquery.markitup": {
deps: ["jquery"],
exports: "jQuery.fn.markitup"
},
"jquery.leanModal": {
deps: ["jquery"],
exports: "jQuery.fn.leanModal"
},
"jquery.smoothScroll": {
deps: ["jquery"],
exports: "jQuery.fn.smoothScroll"
},
"jquery.scrollTo": {
deps: ["jquery"],
exports: "jQuery.fn.scrollTo"
},
"jquery.cookie": {
deps: ["jquery"],
exports: "jQuery.fn.cookie"
},
"jquery.qtip": {
deps: ["jquery"],
exports: "jQuery.fn.qtip"
},
"jquery.fileupload": {
deps: ["jquery.ui", "jquery.iframe-transport"],
exports: "jQuery.fn.fileupload"
},
"jquery.fileupload-process": {
deps: ["jquery.fileupload"]
},
"jquery.fileupload-validate": {
deps: ["jquery.fileupload"]
},
"jquery.inputnumber": {
deps: ["jquery"],
exports: "jQuery.fn.inputNumber"
},
"jquery.tinymce": {
deps: ["jquery", "tinymce"],
exports: "jQuery.fn.tinymce"
},
"datepair": {
deps: ["jquery.ui", "jquery.timepicker"]
},
"underscore": {
exports: "_"
},
"backbone": {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
"backbone.associations": {
deps: ["backbone"],
exports: "Backbone.Associations"
},
"backbone.paginator": {
deps: ["backbone"],
exports: "Backbone.PageableCollection"
},
"youtube": {
exports: "YT"
},
"codemirror": {
exports: "CodeMirror"
},
"tinymce": {
exports: "tinymce"
},
"mathjax": {
exports: "MathJax",
init: ->
MathJax.Hub.Config
tex2jax:
inlineMath: [
["\\(","\\)"],
['[mathjaxinline]','[/mathjaxinline]']
]
displayMath: [
["\\[","\\]"],
['[mathjax]','[/mathjax]']
]
MathJax.Hub.Configured();
},
"URI": {
exports: "URI"
},
"xmodule": {
exports: "XModule"
},
"sinon": {
exports: "sinon"
},
"common/js/spec_helpers/jasmine-extensions": {
deps: ["jquery"]
},
"common/js/spec_helpers/jasmine-stealth": {
deps: ["underscore", "underscore.string"]
},
"common/js/spec_helpers/jasmine-waituntil": {
deps: ["jquery"]
},
"xblock/core": {
exports: "XBlock",
deps: ["jquery", "jquery.immediateDescendents"]
},
"xblock/runtime.v1": {
exports: "XBlock",
deps: ["xblock/core"]
},
"coffee/src/main": {
deps: ["coffee/src/ajax_prefix"]
},
"coffee/src/ajax_prefix": {
deps: ["jquery"]
},
"modernizr": {
exports: "Modernizr"
},
"afontgarde": {
exports: "AFontGarde"
}
}
});
jasmine.getFixtures().fixturesPath += 'coffee/fixtures'
testFiles = [
'coffee/spec/views/assets_spec',
'js/spec/video/translations_editor_spec',
'js/spec/video/file_uploader_editor_spec',
'js/spec/models/group_configuration_spec'
]
i = 0
while i < testFiles.length
testFiles[i] = '/base/' + testFiles[i] + '.js'
i++
specHelpers = [
'common/js/spec_helpers/jasmine-extensions',
'common/js/spec_helpers/jasmine-stealth',
'common/js/spec_helpers/jasmine-waituntil'
]
# Jasmine has a global stack for creating a tree of specs. We need to load
# spec files one by one, otherwise some end up getting nested under others.
requireSerial specHelpers.concat(testFiles), ->
# start test run, once Require.js is done
window.__karma__.start()
define [
"jquery", "backbone", "xblock/runtime.v1", "URI", "gettext",
"js/utils/modal", "common/js/components/views/feedback_notification"
], ($, Backbone, XBlock, URI, gettext, ModalUtils, NotificationView) ->
@BaseRuntime = {}
class BaseRuntime.v1 extends XBlock.Runtime.v1
handlerUrl: (element, handlerName, suffix, query, thirdparty) ->
uri = URI(@handlerPrefix).segment($(element).data('usage-id'))
.segment('handler')
.segment(handlerName)
if suffix? then uri.segment(suffix)
if query? then uri.search(query)
uri.toString()
constructor: () ->
super()
@dispatcher = _.clone(Backbone.Events)
@listenTo('save', @_handleSave)
@listenTo('cancel', @_handleCancel)
@listenTo('error', @_handleError)
@listenTo('modal-shown', (data) ->
@modal = data)
@listenTo('modal-hidden', () ->
@modal = null)
@listenTo('page-shown', (data) ->
@page = data)
# Notify the Studio client-side runtime of an event so that it can update the UI in a consistent way.
notify: (name, data) ->
@dispatcher.trigger(name, data)
# Listen to a Studio event and invoke the specified callback when it is triggered.
listenTo: (name, callback) ->
@dispatcher.bind(name, callback, this)
# Refresh the view for the xblock represented by the specified element.
refreshXBlock: (element) ->
if @page
@page.refreshXBlock(element)
_handleError: (data) ->
message = data.message || data.msg
if message
# TODO: remove 'Open Assessment' specific default title
title = data.title || gettext("OpenAssessment Save Error")
@alert = new NotificationView.Error
title: title
message: message
closeIcon: false
shown: false
@alert.show()
_handleSave: (data) ->
# Starting to save, so show a notification
if data.state == 'start'
message = data.message || gettext('Saving')
@notification = new NotificationView.Mini
title: message
@notification.show()
# Finished saving, so hide the notification and refresh appropriately
else if data.state == 'end'
@_hideAlerts()
# Notify the modal that the save has completed so that it can hide itself
# and then refresh the xblock.
if @modal and @modal.onSave
@modal.onSave()
# ... else ask it to refresh the newly saved xblock
else if data.element
@refreshXBlock(data.element)
@notification.hide()
_handleCancel: () ->
@_hideAlerts()
if @modal
@modal.cancel()
@notify('modal-hidden')
_hideAlerts: () ->
# Hide any alerts that are being shown
if @alert && @alert.options.shown
@alert.hide()
@PreviewRuntime = {}
class PreviewRuntime.v1 extends BaseRuntime.v1
handlerPrefix: '/preview/xblock'
@StudioRuntime = {}
class StudioRuntime.v1 extends BaseRuntime.v1
handlerPrefix: '/xblock'
...@@ -21,11 +21,13 @@ var options = { ...@@ -21,11 +21,13 @@ var options = {
// Make sure the patterns in sourceFiles and specFiles do not match the same file. // Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run. // Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [ sourceFiles: [
{pattern: 'cms/**/!(*spec|djangojs).js'},
{pattern: 'coffee/src/**/!(*spec).js'}, {pattern: 'coffee/src/**/!(*spec).js'},
{pattern: 'js/**/!(*spec|djangojs).js'} {pattern: 'js/**/!(*spec|djangojs).js'}
], ],
specFiles: [ specFiles: [
{pattern: 'cms/**/*spec.js'},
{pattern: 'coffee/spec/**/*spec.js'}, {pattern: 'coffee/spec/**/*spec.js'},
{pattern: 'js/certificates/spec/**/*spec.js'}, {pattern: 'js/certificates/spec/**/*spec.js'},
{pattern: 'js/spec/**/*spec.js'} {pattern: 'js/spec/**/*spec.js'}
...@@ -37,10 +39,10 @@ var options = { ...@@ -37,10 +39,10 @@ var options = {
], ],
runFiles: [ runFiles: [
{pattern: 'coffee/spec/main.js', included: true} {pattern: 'cms/js/spec/main.js', included: true}
] ]
}; };
module.exports = function (config) { module.exports = function(config) {
configModule.configure(config, options); configModule.configure(config, options);
}; };
...@@ -36,7 +36,7 @@ var options = { ...@@ -36,7 +36,7 @@ var options = {
], ],
runFiles: [ runFiles: [
{pattern: 'coffee/spec/main_squire.js', included: true} {pattern: 'cms/js/spec/main_squire.js', included: true}
] ]
}; };
......
describe "XBlock", ->
beforeEach ->
setFixtures """
<div>
<div class='xblock'
id='vA'
data-runtime-version="A"
data-runtime-class="TestRuntime"
data-init="initFnA"
data-name="a-name"
/>
<div>
<div class='xblock'
id='vZ'
data-runtime-version="Z"
data-runtime-class="TestRuntime"
data-init="initFnZ"
data-request-token="req-token-z"
/>
</div>
<div class='xblock' id='missing-version' data-init='initFnA' data-name='no-version'/>
<div class='xblock' id='missing-init' data-runtime-version="A" data-name='no-init'/>
</div>
"""
describe "initializeBlock", ->
beforeEach ->
window.TestRuntime = {}
@runtimeA = {name: 'runtimeA'}
@runtimeZ = {name: 'runtimeZ'}
TestRuntime.vA = jasmine.createSpy().and.returnValue(@runtimeA)
TestRuntime.vZ = jasmine.createSpy().and.returnValue(@runtimeZ)
window.initFnA = jasmine.createSpy()
window.initFnZ = jasmine.createSpy()
@fakeChildren = ['list', 'of', 'children']
spyOn(XBlock, 'initializeXBlocks').and.returnValue(@fakeChildren)
@vANode = $('#vA')[0]
@vZNode = $('#vZ')[0]
@vABlock = XBlock.initializeBlock(@vANode, 'req-token-a')
@vZBlock = XBlock.initializeBlock(@vZNode)
@missingVersionBlock = XBlock.initializeBlock($('#missing-version')[0])
@missingInitBlock = XBlock.initializeBlock($('#missing-init')[0])
it "loads the right runtime version", ->
expect(TestRuntime.vA).toHaveBeenCalledWith()
expect(TestRuntime.vZ).toHaveBeenCalledWith()
it "loads the right init function", ->
expect(window.initFnA).toHaveBeenCalledWith(@runtimeA, @vANode, {})
expect(window.initFnZ).toHaveBeenCalledWith(@runtimeZ, @vZNode, {})
it "loads when missing versions", ->
expect(@missingVersionBlock.element).toBe($('#missing-version')[0])
expect(@missingVersionBlock.name).toBe('no-version')
it "loads when missing init fn", ->
expect(@missingInitBlock.element).toBe($('#missing-init')[0])
expect(@missingInitBlock.name).toBe('no-init')
it "adds names to blocks", ->
expect(@vABlock.name).toBe('a-name')
it "leaves leaves missing names undefined", ->
expect(@vZBlock.name).toBeUndefined()
it "attaches the element to the block", ->
expect(@vABlock.element).toBe(@vANode)
expect(@vZBlock.element).toBe(@vZNode)
expect(@missingVersionBlock.element).toBe($('#missing-version')[0])
expect(@missingInitBlock.element).toBe($('#missing-init')[0])
it "passes through the request token", ->
expect(XBlock.initializeXBlocks).toHaveBeenCalledWith($(@vANode), 'req-token-a')
expect(XBlock.initializeXBlocks).toHaveBeenCalledWith($(@vZNode), 'req-token-z')
describe "initializeBlocks", ->
beforeEach ->
spyOn(XBlock, 'initializeBlock')
@vANode = $('#vA')[0]
@vZNode = $('#vZ')[0]
it "initializes children", ->
XBlock.initializeBlocks($('#jasmine-fixtures'))
expect(XBlock.initializeBlock).toHaveBeenCalledWith(@vANode, undefined)
expect(XBlock.initializeBlock).toHaveBeenCalledWith(@vZNode, undefined)
it "only initializes matching request tokens", ->
XBlock.initializeBlocks($('#jasmine-fixtures'), 'req-token-z')
expect(XBlock.initializeBlock).not.toHaveBeenCalledWith(@vANode, jasmine.any(Object))
expect(XBlock.initializeBlock).toHaveBeenCalledWith(@vZNode, 'req-token-z')
describe "XBlock.Runtime.v1", ->
beforeEach ->
setFixtures """
<div class='xblock' data-handler-prefix='/xblock/fake-usage-id/handler'/>
"""
@children = [
{name: 'childA'},
{name: 'childB'}
]
@element = $('.xblock')[0]
$(@element).prop('xblock_children', @children)
@runtime = new XBlock.Runtime.v1(@element)
it "provides a list of children", ->
expect(@runtime.children(@element)).toBe(@children)
it "maps children by name", ->
expect(@runtime.childMap(@element, 'childA')).toBe(@children[0])
expect(@runtime.childMap(@element, 'childB')).toBe(@children[1])
class XBlock.Runtime.v1
children: (block) => $(block).prop('xblock_children')
childMap: (block, childName) =>
for child in @children(block)
return child if child.name == childName
# Notify the client-side runtime that an event has occurred.
# This allows the runtime to update the UI in a consistent way
# for different XBlocks.
# `name` is an arbitrary string (for example, "save")
# `data` is an object (for example, {state: 'starting'})
# The default implementation is a no-op.
# WARNING: This is an interim solution and not officially supported!
notify: (name, data) -> undefined
...@@ -54,8 +54,7 @@ var commonFiles = { ...@@ -54,8 +54,7 @@ var commonFiles = {
], ],
sourceFiles: [ sourceFiles: [
{pattern: 'common/js/components/**/*.js'}, {pattern: 'common/js/!(spec_helpers)/**/!(*spec).js'}
{pattern: 'common/js/utils/**/*.js'}
], ],
specFiles: [ specFiles: [
......
(function() {
'use strict';
describe('XBlock', function() {
beforeEach(function() {
return setFixtures(
'<div>\n' +
' <div class="xblock"\n' +
' id="vA"\n' +
' data-runtime-version="A"\n' +
' data-runtime-class="TestRuntime"\n' +
' data-init="initFnA"\n' +
' data-name="a-name"\n' +
' />\n' +
' <div>\n' +
' <div class="xblock"\n' +
' id="vZ"\n' +
' data-runtime-version="Z"\n' +
' data-runtime-class="TestRuntime"\n' +
' data-init="initFnZ"\n' +
' data-request-token="req-token-z"\n' +
' />\n' +
' </div>\n' +
' <div class="xblock" id="missing-version" data-init="initFnA" data-name="no-version"/>\n' +
' <div class="xblock" id="missing-init" data-runtime-version="A" data-name="no-init"/>\n' +
'</div>');
});
describe('initializeBlock', function() {
beforeEach(function() {
window.TestRuntime = {};
this.runtimeA = {
name: 'runtimeA'
};
this.runtimeZ = {
name: 'runtimeZ'
};
window.TestRuntime.vA = jasmine.createSpy().and.returnValue(this.runtimeA);
window.TestRuntime.vZ = jasmine.createSpy().and.returnValue(this.runtimeZ);
window.initFnA = jasmine.createSpy();
window.initFnZ = jasmine.createSpy();
this.fakeChildren = ['list', 'of', 'children'];
spyOn(XBlock, 'initializeXBlocks').and.returnValue(this.fakeChildren);
this.vANode = $('#vA')[0];
this.vZNode = $('#vZ')[0];
this.vABlock = XBlock.initializeBlock(this.vANode, 'req-token-a');
this.vZBlock = XBlock.initializeBlock(this.vZNode);
this.missingVersionBlock = XBlock.initializeBlock($('#missing-version')[0]);
this.missingInitBlock = XBlock.initializeBlock($('#missing-init')[0]);
});
it('loads the right runtime version', function() {
expect(window.TestRuntime.vA).toHaveBeenCalledWith();
expect(window.TestRuntime.vZ).toHaveBeenCalledWith();
});
it('loads the right init function', function() {
expect(window.initFnA).toHaveBeenCalledWith(this.runtimeA, this.vANode, {});
expect(window.initFnZ).toHaveBeenCalledWith(this.runtimeZ, this.vZNode, {});
});
it('loads when missing versions', function() {
expect(this.missingVersionBlock.element).toBe($('#missing-version')[0]);
expect(this.missingVersionBlock.name).toBe('no-version');
});
it('loads when missing init fn', function() {
expect(this.missingInitBlock.element).toBe($('#missing-init')[0]);
expect(this.missingInitBlock.name).toBe('no-init');
});
it('adds names to blocks', function() {
expect(this.vABlock.name).toBe('a-name');
});
it('leaves leaves missing names undefined', function() {
expect(this.vZBlock.name).toBeUndefined();
});
it('attaches the element to the block', function() {
expect(this.vABlock.element).toBe(this.vANode);
expect(this.vZBlock.element).toBe(this.vZNode);
expect(this.missingVersionBlock.element).toBe($('#missing-version')[0]);
expect(this.missingInitBlock.element).toBe($('#missing-init')[0]);
});
it('passes through the request token', function() {
expect(XBlock.initializeXBlocks).toHaveBeenCalledWith($(this.vANode), 'req-token-a');
expect(XBlock.initializeXBlocks).toHaveBeenCalledWith($(this.vZNode), 'req-token-z');
});
});
describe('initializeBlocks', function() {
beforeEach(function() {
spyOn(XBlock, 'initializeBlock');
this.vANode = $('#vA')[0];
this.vZNode = $('#vZ')[0];
});
it('initializes children', function() {
XBlock.initializeBlocks($('#jasmine-fixtures'));
expect(XBlock.initializeBlock).toHaveBeenCalledWith(this.vANode, void 0);
expect(XBlock.initializeBlock).toHaveBeenCalledWith(this.vZNode, void 0);
});
it('only initializes matching request tokens', function() {
XBlock.initializeBlocks($('#jasmine-fixtures'), 'req-token-z');
expect(XBlock.initializeBlock).not.toHaveBeenCalledWith(this.vANode, jasmine.any(Object));
expect(XBlock.initializeBlock).toHaveBeenCalledWith(this.vZNode, 'req-token-z');
});
});
});
}).call(this);
(function() {
'use strict';
describe('XBlock.Runtime.v1', function() {
beforeEach(function() {
setFixtures('<div class="xblock" data-handler-prefix="/xblock/fake-usage-id/handler"/>');
this.children = [
{
name: 'childA'
}, {
name: 'childB'
}
];
this.element = $('.xblock')[0];
$(this.element).prop('xblock_children', this.children);
this.runtime = new XBlock.Runtime.v1(this.element);
});
it('provides a list of children', function() {
expect(this.runtime.children(this.element)).toBe(this.children);
});
it('maps children by name', function() {
expect(this.runtime.childMap(this.element, 'childA')).toBe(this.children[0]);
expect(this.runtime.childMap(this.element, 'childB')).toBe(this.children[1]);
});
});
}).call(this);
(function($, JSON) { (function($, JSON) {
'use strict'; 'use strict';
function initializeBlockLikes(block_class, initializer, element, requestToken) { var XBlock;
var requestToken = requestToken || $(element).data('request-token');
function initializeBlockLikes(blockClass, initializer, element, requestToken) {
var selector;
requestToken = requestToken || $(element).data('request-token');
if (requestToken) { if (requestToken) {
var selector = '.' + block_class + '[data-request-token="' + requestToken + '"]'; selector = '.' + blockClass + '[data-request-token="' + requestToken + '"]';
} else { } else {
var selector = '.' + block_class; selector = '.' + blockClass;
} }
return $(element).immediateDescendents(selector).map(function(idx, elem) { return $(element).immediateDescendents(selector).map(function(idx, elem) {
return initializer(elem, requestToken); return initializer(elem, requestToken);
...@@ -15,17 +17,19 @@ ...@@ -15,17 +17,19 @@
} }
function elementRuntime(element) { function elementRuntime(element) {
var $element = $(element); var $element = $(element),
var runtime = $element.data('runtime-class'); runtime = $element.data('runtime-class'),
var version = $element.data('runtime-version'); version = $element.data('runtime-version'),
var initFnName = $element.data('init'); initFnName = $element.data('init');
if (runtime && version && initFnName) { if (runtime && version && initFnName) {
return new window[runtime]['v' + version]; return new window[runtime]['v' + version]();
} else { } else {
if (runtime || version || initFnName) { if (runtime || version || initFnName) {
var elementTag = $('<div>').append($element.clone()).html(); console.log(
console.log('Block ' + elementTag + ' is missing data-runtime, data-runtime-version or data-init, and can\'t be initialized'); 'Block ' + $element.outerHTML + ' is missing data-runtime, data-runtime-version or data-init, ' +
'and can\'t be initialized'
);
} // else this XBlock doesn't have a JS init function. } // else this XBlock doesn't have a JS init function.
return null; return null;
} }
...@@ -42,14 +46,13 @@ ...@@ -42,14 +46,13 @@
* The constructor is called with the arguments 'runtime', 'element', * The constructor is called with the arguments 'runtime', 'element',
* and then all of 'block_args'. * and then all of 'block_args'.
*/ */
function constructBlock(element, block_args) { function constructBlock(element, blockArgs) {
var block; var block;
var $element = $(element); var $element = $(element);
var runtime = elementRuntime(element); var runtime = elementRuntime(element);
block_args.unshift(element); blockArgs.unshift(element);
block_args.unshift(runtime); blockArgs.unshift(runtime);
if (runtime) { if (runtime) {
...@@ -59,7 +62,7 @@ ...@@ -59,7 +62,7 @@
// This create a new constructor that can then apply() the block_args // This create a new constructor that can then apply() the block_args
// to the initFn. // to the initFn.
function Block() { function Block() {
return initFn.apply(this, block_args); return initFn.apply(this, blockArgs);
} }
Block.prototype = initFn.prototype; Block.prototype = initFn.prototype;
...@@ -78,7 +81,7 @@ ...@@ -78,7 +81,7 @@
return block; return block;
} }
var XBlock = { XBlock = {
Runtime: {}, Runtime: {},
/** /**
...@@ -88,11 +91,12 @@ ...@@ -88,11 +91,12 @@
* the children themselves. * the children themselves.
*/ */
initializeBlock: function(element, requestToken) { initializeBlock: function(element, requestToken) {
var $element = $(element); var $element = $(element),
children, asides;
var requestToken = requestToken || $element.data('request-token'); requestToken = requestToken || $element.data('request-token');
var children = XBlock.initializeXBlocks($element, requestToken); children = XBlock.initializeXBlocks($element, requestToken);
var asides = XBlock.initializeXBlockAsides($element, requestToken); asides = XBlock.initializeXBlockAsides($element, requestToken);
if (asides) { if (asides) {
children = children.concat(asides); children = children.concat(asides);
} }
...@@ -106,7 +110,7 @@ ...@@ -106,7 +110,7 @@
* If requestToken is omitted, use the data-request-token attribute from element, or use * If requestToken is omitted, use the data-request-token attribute from element, or use
* the request-tokens specified on the children themselves. * the request-tokens specified on the children themselves.
*/ */
initializeAside: function(element, requestToken) { initializeAside: function(element) {
var blockUsageId = $(element).data('block-id'); var blockUsageId = $(element).data('block-id');
var blockElement = $(element).siblings('[data-usage-id="' + blockUsageId + '"]')[0]; var blockElement = $(element).siblings('[data-usage-id="' + blockUsageId + '"]')[0];
return constructBlock(element, [blockElement, initArgs(element)]); return constructBlock(element, [blockElement, initArgs(element)]);
......
(function() {
'use strict';
XBlock.Runtime.v1 = (function() {
function v1() {
var _this = this;
this.childMap = function() {
return v1.prototype.childMap.apply(_this, arguments);
};
this.children = function() {
return v1.prototype.children.apply(_this, arguments);
};
}
v1.prototype.children = function(block) {
return $(block).prop('xblock_children');
};
v1.prototype.childMap = function(block, childName) {
var child, _i, _len, _ref;
_ref = this.children(block);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
child = _ref[_i];
if (child.name === childName) {
return child;
}
}
};
/**
* Notify the client-side runtime that an event has occurred.
*
* This allows the runtime to update the UI in a consistent way
* for different XBlocks.
* `name` is an arbitrary string (for example, "save")
* `data` is an object (for example, {state: 'starting'})
* The default implementation is a no-op.
*
* WARNING: This is an interim solution and not officially supported!
*/
v1.prototype.notify = function() {
// Do nothing
};
return v1;
})();
}).call(this);
...@@ -11,7 +11,7 @@ var options = { ...@@ -11,7 +11,7 @@ var options = {
useRequireJs: false, useRequireJs: false,
normalizePathsForCoverageFunc: function (appRoot, pattern) { normalizePathsForCoverageFunc: function(appRoot, pattern) {
return path.join(appRoot, '/common/static/' + pattern); return path.join(appRoot, '/common/static/' + pattern);
}, },
...@@ -50,16 +50,17 @@ var options = { ...@@ -50,16 +50,17 @@ var options = {
// Make sure the patterns in sourceFiles and specFiles do not match the same file. // Make sure the patterns in sourceFiles and specFiles do not match the same file.
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run. // Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
sourceFiles: [ sourceFiles: [
{pattern: 'js/xblock/**/*.js', included: true},
{pattern: 'coffee/src/**/*.js', included: true}, {pattern: 'coffee/src/**/*.js', included: true},
{pattern: 'js/src/**/*.js', included: true}, {pattern: 'common/js/xblock/core.js', included: true},
{pattern: 'js/capa/src/**/*.js', included: true} {pattern: 'common/js/xblock/runtime.v1.js', included: true},
{pattern: 'js/capa/src/**/*.js', included: true},
{pattern: 'js/src/**/*.js', included: true}
], ],
specFiles: [ specFiles: [
{pattern: 'coffee/spec/**/*.js', included: true}, {pattern: 'coffee/spec/**/*.js', included: true},
{pattern: 'js/spec/**/*.js', included: true}, {pattern: 'common/js/spec/xblock/*.js', included: true},
{pattern: 'js/capa/spec/**/*.js', included: true} {pattern: 'js/**/*spec.js', included: true}
], ],
fixtureFiles: [ fixtureFiles: [
...@@ -69,6 +70,6 @@ var options = { ...@@ -69,6 +70,6 @@ var options = {
] ]
}; };
module.exports = function (config) { module.exports = function(config) {
configModule.configure(config, options); configModule.configure(config, options);
}; };
...@@ -1528,9 +1528,14 @@ PIPELINE_CSS = { ...@@ -1528,9 +1528,14 @@ PIPELINE_CSS = {
} }
common_js = set(rooted_glob(COMMON_ROOT / 'static', 'coffee/src/**/*.js')) - set(courseware_js + discussion_js + notes_js + instructor_dash_js) # pylint: disable=line-too-long separately_bundled_js = set(courseware_js + discussion_js + notes_js + instructor_dash_js)
project_js = set(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/**/*.js')) - set(courseware_js + discussion_js + notes_js + instructor_dash_js) # pylint: disable=line-too-long common_js = sorted(set(rooted_glob(COMMON_ROOT / 'static', 'coffee/src/**/*.js')) - separately_bundled_js)
xblock_runtime_js = [
'common/js/xblock/core.js',
'common/js/xblock/runtime.v1.js',
'lms/js/xblock/lms.runtime.v1.js',
]
lms_application_js = sorted(set(rooted_glob(PROJECT_ROOT / 'static', 'coffee/src/**/*.js')) - separately_bundled_js)
PIPELINE_JS = { PIPELINE_JS = {
'base_application': { 'base_application': {
...@@ -1539,13 +1544,14 @@ PIPELINE_JS = { ...@@ -1539,13 +1544,14 @@ PIPELINE_JS = {
}, },
'application': { 'application': {
'source_filenames': (
# Application will contain all paths not in courseware_only_js common_js + xblock_runtime_js + base_application_js + lms_application_js +
'source_filenames': ['js/xblock/core.js'] + sorted(common_js) + sorted(project_js) + base_application_js + [ [
'js/sticky_filter.js', 'js/sticky_filter.js',
'js/query-params.js', 'js/query-params.js',
'js/vendor/moment.min.js', 'js/vendor/moment.min.js',
], ]
),
'output_filename': 'js/lms-application.js', 'output_filename': 'js/lms-application.js',
}, },
'proctoring': { 'proctoring': {
......
@LmsRuntime = {}
class LmsRuntime.v1 extends XBlock.Runtime.v1
handlerUrl: (element, handlerName, suffix, query, thirdparty) ->
courseId = $(element).data("course-id")
usageId = $(element).data("usage-id")
handlerAuth = if thirdparty then "handler_noauth" else "handler"
uri = URI('/courses').segment(courseId)
.segment('xblock')
.segment(usageId)
.segment(handlerAuth)
.segment(handlerName)
if suffix? then uri.segment(suffix)
if query? then uri.search(query)
uri.toString()
...@@ -29,6 +29,7 @@ var options = { ...@@ -29,6 +29,7 @@ var options = {
{pattern: 'common/js/vendor/jquery.js', included: true}, {pattern: 'common/js/vendor/jquery.js', included: true},
{pattern: 'common/js/vendor/jquery-migrate.js', included: true}, {pattern: 'common/js/vendor/jquery-migrate.js', included: true},
{pattern: 'common/js/vendor/underscore.js', included: true}, {pattern: 'common/js/vendor/underscore.js', included: true},
{pattern: 'common/js/xblock/*.js', included: true},
{pattern: 'xmodule_js/common_static/js/src/logger.js', included: true}, {pattern: 'xmodule_js/common_static/js/src/logger.js', included: true},
{pattern: 'xmodule_js/common_static/js/test/i18n.js', included: true}, {pattern: 'xmodule_js/common_static/js/test/i18n.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: true}, {pattern: 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror.js', included: true},
...@@ -38,8 +39,6 @@ var options = { ...@@ -38,8 +39,6 @@ var options = {
{pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true}, {pattern: 'xmodule_js/common_static/js/vendor/jquery-ui.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: true}, {pattern: 'xmodule_js/common_static/js/vendor/URI.min.js', included: true},
{pattern: 'xmodule_js/common_static/js/xblock/*.js', included: true},
{pattern: 'xmodule_js/common_static/coffee/src/xblock/*.js', included: true},
{pattern: 'xmodule_js/src/capa/*.js', included: true}, {pattern: 'xmodule_js/src/capa/*.js', included: true},
{pattern: 'xmodule_js/src/video/*.js', included: true}, {pattern: 'xmodule_js/src/video/*.js', included: true},
{pattern: 'xmodule_js/src/xmodule.js', included: true}, {pattern: 'xmodule_js/src/xmodule.js', included: true},
......
...@@ -56,9 +56,8 @@ ...@@ -56,9 +56,8 @@
'coffee/src/ajax_prefix': 'xmodule_js/common_static/coffee/src/ajax_prefix', 'coffee/src/ajax_prefix': 'xmodule_js/common_static/coffee/src/ajax_prefix',
'coffee/src/instructor_dashboard/student_admin': 'coffee/src/instructor_dashboard/student_admin', 'coffee/src/instructor_dashboard/student_admin': 'coffee/src/instructor_dashboard/student_admin',
'xmodule_js/common_static/js/test/add_ajax_prefix': 'xmodule_js/common_static/js/test/add_ajax_prefix', 'xmodule_js/common_static/js/test/add_ajax_prefix': 'xmodule_js/common_static/js/test/add_ajax_prefix',
'xblock/core': 'xmodule_js/common_static/js/xblock/core', 'xblock/lms.runtime.v1': 'lms/js/xblock/lms.runtime.v1',
'xblock/runtime.v1': 'xmodule_js/common_static/coffee/src/xblock/runtime.v1', 'xblock': 'common/js/xblock',
'xblock/lms.runtime.v1': 'coffee/src/xblock/lms.runtime.v1',
'capa/display': 'xmodule_js/src/capa/display', 'capa/display': 'xmodule_js/src/capa/display',
'string_utils': 'xmodule_js/common_static/js/src/string_utils', 'string_utils': 'xmodule_js/common_static/js/src/string_utils',
'logger': 'xmodule_js/common_static/js/src/logger', 'logger': 'xmodule_js/common_static/js/src/logger',
......
(function(URI) {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
var key;
for (key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
};
this.LmsRuntime = {};
this.LmsRuntime.v1 = (function(_super) {
__extends(v1, _super);
function v1() {
return v1.__super__.constructor.apply(this, arguments);
}
v1.prototype.handlerUrl = function(element, handlerName, suffix, query, thirdparty) {
var courseId, handlerAuth, uri, usageId;
courseId = $(element).data('course-id');
usageId = $(element).data('usage-id');
handlerAuth = thirdparty ? 'handler_noauth' : 'handler';
uri = URI('/courses')
.segment(courseId)
.segment('xblock')
.segment(usageId)
.segment(handlerAuth)
.segment(handlerName);
if (suffix !== null) {
uri.segment(suffix);
}
if (query !== null) {
uri.search(query);
}
return uri.toString();
};
return v1;
})(XBlock.Runtime.v1);
}).call(this, URI); // jshint ignore:line
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment