Commit a6aae729 by Andy Armstrong

Address the next round of review comments.

parent 88d95d11
...@@ -6,6 +6,7 @@ from nose.tools import assert_equal, assert_in # pylint: disable=E0611 ...@@ -6,6 +6,7 @@ from nose.tools import assert_equal, assert_in # pylint: disable=E0611
from terrain.steps import reload_the_page from terrain.steps import reload_the_page
from common import type_in_codemirror from common import type_in_codemirror
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from cms.envs.common import FEATURES
@world.absorb @world.absorb
...@@ -54,6 +55,11 @@ def click_new_component_button(step, component_button_css): ...@@ -54,6 +55,11 @@ def click_new_component_button(step, component_button_css):
world.css_click(component_button_css) world.css_click(component_button_css)
if FEATURES['USE_CONTAINER_PAGE_FOR_TESTING']:
unit_url = world.browser.url
container_url = unit_url.replace('/unit/', '/container/')
world.visit(container_url)
def _click_advanced(): def _click_advanced():
css = 'ul.problem-type-tabs a[href="#tab2"]' css = 'ul.problem-type-tabs a[href="#tab2"]'
......
...@@ -7,6 +7,9 @@ from xmodule.modulestore.django import loc_mapper, modulestore ...@@ -7,6 +7,9 @@ from xmodule.modulestore.django import loc_mapper, modulestore
__all__ = ['edge', 'event', 'landing'] __all__ = ['edge', 'event', 'landing']
EDITING_TEMPLATES = [
"basic-modal", "modal-button", "edit-xblock-modal", "editor-mode-button", "upload-dialog", "image-modal"
]
# points to the temporary course landing page with log in and sign up # points to the temporary course landing page with log in and sign up
def landing(request, org, course, coursename): def landing(request, org, course, coursename):
......
...@@ -99,6 +99,9 @@ FEATURES = { ...@@ -99,6 +99,9 @@ FEATURES = {
# Turn off Advanced Security by default # Turn off Advanced Security by default
'ADVANCED_SECURITY': False, 'ADVANCED_SECURITY': False,
# Switch acceptance tests to use the container page instead of the unit page
'USE_CONTAINER_PAGE_FOR_TESTING': False,
} }
ENABLE_JASMINE = False ENABLE_JASMINE = False
......
...@@ -218,9 +218,10 @@ define([ ...@@ -218,9 +218,10 @@ define([
"js/spec/views/unit_spec", "js/spec/views/unit_spec",
"js/spec/views/xblock_spec", "js/spec/views/xblock_spec",
"js/spec/views/xblock_container_spec",
"js/spec/views/xblock_editor_spec", "js/spec/views/xblock_editor_spec",
"js/spec/views/pages/container_spec",
"js/spec/views/modals/base_modal_spec", "js/spec/views/modals/base_modal_spec",
"js/spec/views/modals/edit_xblock_spec", "js/spec/views/modals/edit_xblock_spec",
......
define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course", define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course",
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks", "js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
"js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification", "js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification",
"js/spec_helpers/create_sinon", "jasmine-stealth"], "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers", "jasmine-stealth"],
(Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, create_sinon) -> (Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, create_sinon) ->
feedbackTpl = readFixtures('system-feedback.underscore') feedbackTpl = readFixtures('system-feedback.underscore')
...@@ -272,8 +272,8 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js ...@@ -272,8 +272,8 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
tpl = readFixtures("edit-chapter.underscore") tpl = readFixtures("edit-chapter.underscore")
beforeEach -> beforeEach ->
setFixtures($("<script>", {id: "edit-chapter-tpl", type: "text/template"}).text(tpl)) modal_helpers.installModalTemplates()
appendSetFixtures($("<script>", {id: "system-feedback-tpl", type: "text/template"}).text(feedbackTpl)) appendSetFixtures($("<script>", {id: "edit-chapter-tpl", type: "text/template"}).text(tpl))
@model = new Chapter @model = new Chapter
name: "Chapter 1" name: "Chapter 1"
asset_path: "/ch1.pdf" asset_path: "/ch1.pdf"
......
...@@ -22,9 +22,7 @@ define(["jquery", "underscore", "js/views/modals/base_modal", "js/spec_helpers/m ...@@ -22,9 +22,7 @@ define(["jquery", "underscore", "js/views/modals/base_modal", "js/spec_helpers/m
}); });
afterEach(function() { afterEach(function() {
if (modal && modal_helpers.isShowingModal(modal)) { modal_helpers.hideModalIfShowing(modal);
modal.hide();
}
}); });
describe("Single Modal", function() { describe("Single Modal", function() {
......
...@@ -14,16 +14,14 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -14,16 +14,14 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
edit_helpers.installEditTemplates(); edit_helpers.installEditTemplates();
appendSetFixtures('<div class="xblock" data-locator="mock-xblock" data-display-name="Mock XBlock"></div>'); appendSetFixtures('<div class="xblock" data-locator="mock-xblock" data-display-name="Mock XBlock"></div>');
model = new XBlockInfo({ model = new XBlockInfo({
id: 'testCourse/branch/published/block/verticalFFF', id: 'testCourse/branch/draft/block/verticalFFF',
display_name: 'Test Unit', display_name: 'Test Unit',
category: 'vertical' category: 'vertical'
}); });
}); });
afterEach(function() { afterEach(function() {
if (modal && edit_helpers.isShowingModal(modal)) { edit_helpers.cancelModalIfShowing();
edit_helpers.cancelModal(modal);
}
}); });
describe("XBlock Editor", function() { describe("XBlock Editor", function() {
...@@ -161,9 +159,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -161,9 +159,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
}); });
it('does not show any mode buttons', function() { it('does not show any mode buttons', function() {
var requests = create_sinon.requests(this), var requests = create_sinon.requests(this);
editorButton,
settingsButton;
modal = showModal(requests, mockXModuleEditorHtml); modal = showModal(requests, mockXModuleEditorHtml);
expect(modal.$('.editor-modes li').length).toBe(0); expect(modal.$('.editor-modes li').length).toBe(0);
}); });
......
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers", define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers",
"js/views/xblock_container", "js/models/xblock_info"], "js/views/pages/container", "js/models/xblock_info"],
function ($, create_sinon, edit_helpers, XBlockContainerView, XBlockInfo) { function ($, create_sinon, edit_helpers, XBlockContainerPage, XBlockInfo) {
describe("XBlockContainerView", function() { describe("XBlockContainerView", function() {
var model, containerView, respondWithMockXBlockEditorFragment, mockContainerView; var model, containerView, respondWithMockXBlockEditorFragment, mockContainerPage;
mockContainerView = readFixtures('mock/mock-container-view.underscore'); mockContainerPage = readFixtures('mock/mock-container-page.underscore');
beforeEach(function () { beforeEach(function () {
edit_helpers.installEditTemplates(); edit_helpers.installEditTemplates();
appendSetFixtures(mockContainerView); appendSetFixtures(mockContainerPage);
model = new XBlockInfo({ model = new XBlockInfo({
id: 'testCourse/branch/published/block/verticalFFF', id: 'testCourse/branch/draft/block/verticalFFF',
display_name: 'Test Unit', display_name: 'Test Unit',
category: 'vertical' category: 'vertical'
}); });
containerView = new XBlockContainerView({ containerView = new XBlockContainerPage({
model: model, model: model,
el: $('#content') el: $('#content')
}); });
...@@ -59,7 +59,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers" ...@@ -59,7 +59,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers"
describe("Editing an xblock", function() { describe("Editing an xblock", function() {
var mockContainerXBlockHtml, var mockContainerXBlockHtml,
mockXBlockEditorHtml, mockXBlockEditorHtml,
saved; saved,
newDisplayName = 'New Display Name';
beforeEach(function () { beforeEach(function () {
saved = false; saved = false;
...@@ -67,6 +68,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers" ...@@ -67,6 +68,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers"
return { return {
save: function() { save: function() {
saved = true; saved = true;
return {
data: "<p>Some HTML</p>",
metadata: {
display_name: newDisplayName
}
};
} }
}; };
}; };
...@@ -74,9 +81,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers" ...@@ -74,9 +81,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers"
afterEach(function() { afterEach(function() {
window.MockXBlock = null; window.MockXBlock = null;
if (edit_helpers.isShowingModal()) { edit_helpers.cancelModalIfShowing();
edit_helpers.cancelModal();
}
}); });
mockContainerXBlockHtml = readFixtures('mock/mock-container-xblock.underscore'); mockContainerXBlockHtml = readFixtures('mock/mock-container-xblock.underscore');
......
...@@ -6,8 +6,9 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers ...@@ -6,8 +6,9 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
var model, editor; var model, editor;
beforeEach(function () { beforeEach(function () {
edit_helpers.installEditTemplates();
model = new XBlockInfo({ model = new XBlockInfo({
id: 'testCourse/branch/published/block/verticalFFF', id: 'testCourse/branch/draft/block/verticalFFF',
display_name: 'Test Unit', display_name: 'Test Unit',
category: 'vertical' category: 'vertical'
}); });
...@@ -50,8 +51,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers ...@@ -50,8 +51,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/edit_helpers
mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-editor.underscore'); mockXModuleEditorHtml = readFixtures('mock/mock-xmodule-editor.underscore');
beforeEach(function() { beforeEach(function() {
edit_helpers.installEditTemplates();
// Mock the VerticalDescriptor so that the module can be rendered // Mock the VerticalDescriptor so that the module can be rendered
window.VerticalDescriptor = XModule.Descriptor; window.VerticalDescriptor = XModule.Descriptor;
}); });
......
...@@ -7,7 +7,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js ...@@ -7,7 +7,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "URI", "js/views/xblock", "js
beforeEach(function () { beforeEach(function () {
model = new XBlockInfo({ model = new XBlockInfo({
id: 'testCourse/branch/published/block/verticalFFF', id: 'testCourse/branch/draft/block/verticalFFF',
display_name: 'Test Unit', display_name: 'Test Unit',
category: 'vertical' category: 'vertical'
}); });
......
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
* Provides helper methods for invoking Studio editors in Jasmine tests. * Provides helper methods for invoking Studio editors in Jasmine tests.
*/ */
define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock", define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers", "js/views/modals/edit_xblock",
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"], "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
function($, create_sinon, modal_helpers, EditXBlockModal) { function($, create_sinon, modal_helpers, EditXBlockModal) {
var editorTemplate = readFixtures('metadata-editor.underscore'), var editorTemplate = readFixtures('metadata-editor.underscore'),
numberEntryTemplate = readFixtures('metadata-number-entry.underscore'), numberEntryTemplate = readFixtures('metadata-number-entry.underscore'),
stringEntryTemplate = readFixtures('metadata-string-entry.underscore'), stringEntryTemplate = readFixtures('metadata-string-entry.underscore'),
feedbackTemplate = readFixtures('system-feedback.underscore'),
editXBlockModalTemplate = readFixtures('edit-xblock-modal.underscore'), editXBlockModalTemplate = readFixtures('edit-xblock-modal.underscore'),
editorModeButtonTemplate = readFixtures('editor-mode-button.underscore'), editorModeButtonTemplate = readFixtures('editor-mode-button.underscore'),
installEditTemplates, installEditTemplates,
...@@ -37,10 +36,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers ...@@ -37,10 +36,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/modal_helpers
return modal; return modal;
}; };
return { return $.extend(modal_helpers, {
'installEditTemplates': installEditTemplates, 'installEditTemplates': installEditTemplates,
'showEditModal': showEditModal, 'showEditModal': showEditModal
'isShowingModal': modal_helpers.isShowingModal, });
'cancelModal': modal_helpers.cancelModal
};
}); });
...@@ -7,8 +7,11 @@ define(["jquery"], ...@@ -7,8 +7,11 @@ define(["jquery"],
modalButtonTemplate = readFixtures('modal-button.underscore'), modalButtonTemplate = readFixtures('modal-button.underscore'),
feedbackTemplate = readFixtures('system-feedback.underscore'), feedbackTemplate = readFixtures('system-feedback.underscore'),
installModalTemplates, installModalTemplates,
getModalElement,
isShowingModal, isShowingModal,
cancelModal; hideModalIfShowing,
cancelModal,
cancelModalIfShowing;
installModalTemplates = function(append) { installModalTemplates = function(append) {
if (append) { if (append) {
...@@ -20,31 +23,46 @@ define(["jquery"], ...@@ -20,31 +23,46 @@ define(["jquery"],
appendSetFixtures($("<script>", { id: "modal-button-tpl", type: "text/template" }).text(modalButtonTemplate)); appendSetFixtures($("<script>", { id: "modal-button-tpl", type: "text/template" }).text(modalButtonTemplate));
}; };
isShowingModal = function(modal) { getModalElement = function(modal) {
var modalElement; var modalElement;
if (modal) { if (modal) {
modalElement = modal.$('.wrapper-modal-window'); modalElement = modal.$('.wrapper-modal-window');
} else { } else {
modalElement = $('.wrapper-modal-window'); modalElement = $('.wrapper-modal-window');
} }
return modalElement;
};
isShowingModal = function(modal) {
var modalElement = getModalElement(modal);
return modalElement.length > 0; return modalElement.length > 0;
}; };
hideModalIfShowing = function(modal) {
if (isShowingModal(modal)) {
modal.hide();
}
};
cancelModal = function(modal) { cancelModal = function(modal) {
var modalElement, cancelButton; var modalElement, cancelButton;
if (modal) { modalElement = getModalElement(modal);
modalElement = modal.$('.wrapper-modal-window');
} else {
modalElement = $('.wrapper-modal-window');
}
cancelButton = modalElement.find('.action-cancel'); cancelButton = modalElement.find('.action-cancel');
expect(cancelButton.length).toBe(1); expect(cancelButton.length).toBe(1);
cancelButton.click(); cancelButton.click();
}; };
cancelModalIfShowing = function(modal) {
if (isShowingModal(modal)) {
cancelModal(modal);
}
};
return { return {
'installModalTemplates': installModalTemplates, 'installModalTemplates': installModalTemplates,
'isShowingModal': isShowingModal, 'isShowingModal': isShowingModal,
'cancelModal': cancelModal 'hideModalIfShowing': hideModalIfShowing,
'cancelModal': cancelModal,
'cancelModalIfShowing': cancelModalIfShowing
}; };
}); });
...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "gettext", "js/views/feedback_prompt" ...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "gettext", "js/views/feedback_prompt"
function(BaseView, _, gettext, PromptView, NotificationView) { function(BaseView, _, gettext, PromptView, NotificationView) {
var AssetView = BaseView.extend({ var AssetView = BaseView.extend({
initialize: function() { initialize: function() {
this.template = _.template($("#asset-tpl").text()); this.template = this.loadTemplate("asset");
this.listenTo(this.model, "change:locked", this.updateLockState); this.listenTo(this.model, "change:locked", this.updateLockState);
}, },
tagName: "tr", tagName: "tr",
......
...@@ -11,7 +11,7 @@ define(["jquery", "underscore", "gettext", "js/views/paging", "js/views/asset", ...@@ -11,7 +11,7 @@ define(["jquery", "underscore", "gettext", "js/views/paging", "js/views/asset",
initialize : function() { initialize : function() {
PagingView.prototype.initialize.call(this); PagingView.prototype.initialize.call(this);
var collection = this.collection; var collection = this.collection;
this.template = _.template($("#asset-library-tpl").text()); this.template = this.loadTemplate("asset-library");
this.listenTo(collection, 'destroy', this.handleDestroy); this.listenTo(collection, 'destroy', this.handleDestroy);
this.registerSortableColumn('js-asset-name-col', gettext('Name'), 'display_name', 'asc'); this.registerSortableColumn('js-asset-name-col', gettext('Name'), 'display_name', 'asc');
this.registerSortableColumn('js-asset-date-col', gettext('Date Added'), 'date_added', 'desc'); this.registerSortableColumn('js-asset-date-col', gettext('Date Added'), 'date_added', 'desc');
......
...@@ -58,6 +58,20 @@ define(["jquery", "underscore", "backbone", "js/utils/handle_iframe_binding"], ...@@ -58,6 +58,20 @@ define(["jquery", "underscore", "backbone", "js/utils/handle_iframe_binding"],
hideLoadingIndicator: function() { hideLoadingIndicator: function() {
$('.ui-loading').hide(); $('.ui-loading').hide();
},
/**
* Loads the named template from the page, or logs an error if it fails.
* @param name The name of the template.
* @returns The loaded template.
*/
loadTemplate: function(name) {
var templateSelector = "#" + name + "-tpl",
templateText = $(templateSelector).text();
if (!templateText) {
console.error("Failed to load " + name + " template");
}
return _.template(templateText);
} }
}); });
......
...@@ -10,7 +10,7 @@ define(["js/views/baseview", "underscore", "jquery"], function(BaseView, _, $) { ...@@ -10,7 +10,7 @@ define(["js/views/baseview", "underscore", "jquery"], function(BaseView, _, $) {
initialize : function() { initialize : function() {
var self = this; var self = this;
this.template = _.template($("#checklist-tpl").text()); this.template = this.loadTemplate('checklist');
this.collection.fetch({ this.collection.fetch({
reset: true, reset: true,
complete: function() { complete: function() {
......
...@@ -11,7 +11,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/views/feedback_noti ...@@ -11,7 +11,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/views/feedback_noti
}, },
initialize: function() { initialize: function() {
this.template = _.template($("#course_info_handouts-tpl").text()); this.template = this.loadTemplate('course_info_handouts');
var self = this; var self = this;
this.model.fetch({ this.model.fetch({
complete: function() { complete: function() {
......
...@@ -13,7 +13,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/models/course_updat ...@@ -13,7 +13,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/models/course_updat
}, },
initialize: function() { initialize: function() {
this.template = _.template($("#course_info_update-tpl").text()); this.template = this.loadTemplate('course_info_update');
this.render(); this.render();
// when the client refetches the updates as a whole, re-render them // when the client refetches the updates as a whole, re-render them
this.listenTo(this.collection, 'reset', this.render); this.listenTo(this.collection, 'reset', this.render);
......
...@@ -3,7 +3,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette ...@@ -3,7 +3,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette
_.str = str; // used in template _.str = str; // used in template
var EditChapter = BaseView.extend({ var EditChapter = BaseView.extend({
initialize: function() { initialize: function() {
this.template = _.template($("#edit-chapter-tpl").text()); this.template = this.loadTemplate('edit-chapter');
this.listenTo(this.model, "change", this.render); this.listenTo(this.model, "change", this.render);
}, },
tagName: "li", tagName: "li",
...@@ -54,7 +54,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette ...@@ -54,7 +54,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette
var msg = new FileUploadModel({ var msg = new FileUploadModel({
title: _.template(gettext("Upload a new PDF to “<%= name %>”"), title: _.template(gettext("Upload a new PDF to “<%= name %>”"),
{name: course.escape('name')}), {name: course.escape('name')}),
message: "Please select a PDF file to upload.", message: gettext("Please select a PDF file to upload."),
mimeTypes: ['application/pdf'] mimeTypes: ['application/pdf']
}); });
var that = this; var that = this;
......
...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "jquery", "js/views/edit_chapter", "j ...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "jquery", "js/views/edit_chapter", "j
function(BaseView, _, $, EditChapterView, NotificationView) { function(BaseView, _, $, EditChapterView, NotificationView) {
var EditTextbook = BaseView.extend({ var EditTextbook = BaseView.extend({
initialize: function() { initialize: function() {
this.template = _.template($("#edit-textbook-tpl").text()); this.template = this.loadTemplate('edit-textbook');
this.listenTo(this.model, "invalid", this.render); this.listenTo(this.model, "invalid", this.render);
var chapters = this.model.get('chapters'); var chapters = this.model.get('chapters');
this.listenTo(chapters, "add", this.addOne); this.listenTo(chapters, "add", this.addOne);
......
...@@ -48,11 +48,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery"], funct ...@@ -48,11 +48,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery"], funct
throw "SystemFeedback: intent required (given " + throw "SystemFeedback: intent required (given " +
JSON.stringify(this.options) + ")"; JSON.stringify(this.options) + ")";
} }
var tpl = $("#system-feedback-tpl").text(); this.template = this.loadTemplate("system-feedback");
if(!tpl) {
console.error("Couldn't load system-feedback template");
}
this.template = _.template(tpl);
this.setElement($("#page-"+this.options.type)); this.setElement($("#page-"+this.options.type));
// handle single "secondary" action // handle single "secondary" action
if (this.options.actions && this.options.actions.secondary && if (this.options.actions && this.options.actions.secondary &&
......
...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "jquery", "js/views/edit_textbook", " ...@@ -2,7 +2,7 @@ define(["js/views/baseview", "underscore", "jquery", "js/views/edit_textbook", "
function(BaseView, _, $, EditTextbookView, ShowTextbookView) { function(BaseView, _, $, EditTextbookView, ShowTextbookView) {
var ListTextbooks = BaseView.extend({ var ListTextbooks = BaseView.extend({
initialize: function() { initialize: function() {
this.emptyTemplate = _.template($("#no-textbooks-tpl").text()); this.emptyTemplate = this.loadTemplate('no-textbooks');
this.listenTo(this.collection, 'all', this.render); this.listenTo(this.collection, 'all', this.render);
this.listenTo(this.collection, 'destroy', this.handleDestroy); this.listenTo(this.collection, 'destroy', this.handleDestroy);
}, },
......
...@@ -11,11 +11,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, VideoList, VideoTranslation ...@@ -11,11 +11,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, VideoList, VideoTranslation
// Model is CMS.Models.MetadataCollection, // Model is CMS.Models.MetadataCollection,
initialize : function() { initialize : function() {
var tpl = $("#metadata-editor-tpl").text(); this.template = this.loadTemplate('metadata-editor');
if(!tpl) {
console.error("Couldn't load metadata editor template");
}
this.template = _.template(tpl);
this.$el.html(this.template({numEntries: this.collection.length})); this.$el.html(this.template({numEntries: this.collection.length}));
var counter = 0; var counter = 0;
......
...@@ -5,24 +5,24 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"], ...@@ -5,24 +5,24 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"],
function($, _, gettext, BaseView) { function($, _, gettext, BaseView) {
var BaseModal = BaseView.extend({ var BaseModal = BaseView.extend({
events : { events : {
"click .action-cancel": "cancel" 'click .action-cancel': 'cancel'
}, },
options: $.extend({}, BaseView.prototype.options, { options: $.extend({}, BaseView.prototype.options, {
type: "prompt", type: 'prompt',
closeIcon: false, closeIcon: false,
icon: false, icon: false,
modalName: 'basic', modalName: 'basic',
modalType: 'generic', modalType: 'generic',
modalSize: 'lg', modalSize: 'lg',
title: "" title: ''
}), }),
initialize: function() { initialize: function() {
var parent = this.options.parent, var parent = this.options.parent,
parentElement = this.options.parentElement; parentElement = this.options.parentElement;
this.modalTemplate = _.template($("#basic-modal-tpl").text()); this.modalTemplate = this.loadTemplate('basic-modal');
this.buttonTemplate = _.template($("#modal-button-tpl").text()); this.buttonTemplate = this.loadTemplate('modal-button');
if (parent) { if (parent) {
parentElement = parent.$el; parentElement = parent.$el;
} else if (!parentElement) { } else if (!parentElement) {
...@@ -55,19 +55,16 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"], ...@@ -55,19 +55,16 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"],
* Returns the content to be shown in the modal. * Returns the content to be shown in the modal.
*/ */
getContentHtml: function() { getContentHtml: function() {
return ""; return '';
}, },
show: function() { show: function() {
this.render(); this.render();
this.resize(); this.resize();
this.lastPosition = $(document).scrollTop();
$(window).resize(_.bind(this.resize, this)); $(window).resize(_.bind(this.resize, this));
}, },
hide: function() { hide: function() {
$(document).scrollTop(this.lastPosition);
// Completely remove the modal from the DOM // Completely remove the modal from the DOM
this.undelegateEvents(); this.undelegateEvents();
this.$el.html(''); this.$el.html('');
...@@ -84,9 +81,9 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"], ...@@ -84,9 +81,9 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"],
*/ */
addActionButtons: function() { addActionButtons: function() {
if (this.options.addSaveButton) { if (this.options.addSaveButton) {
this.addActionButton('save', gettext("Save"), true); this.addActionButton('save', gettext('Save'), true);
} }
this.addActionButton('cancel', gettext("Cancel")); this.addActionButton('cancel', gettext('Cancel'));
}, },
/** /**
...@@ -119,8 +116,6 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"], ...@@ -119,8 +116,6 @@ define(["jquery", "underscore", "gettext", "js/views/baseview"],
left = (availableWidth - modalWidth) / 2; left = (availableWidth - modalWidth) / 2;
top = (availableHeight - modalHeight) / 2; top = (availableHeight - modalHeight) / 2;
// modalWindow.width(modalWidth);
// modalWindow.height(modalHeight);
modalWindow.css({ modalWindow.css({
top: top + $(window).scrollTop(), top: top + $(window).scrollTop(),
left: left + $(window).scrollLeft() left: left + $(window).scrollLeft()
......
...@@ -20,8 +20,8 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", ...@@ -20,8 +20,8 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal",
initialize: function() { initialize: function() {
BaseModal.prototype.initialize.call(this); BaseModal.prototype.initialize.call(this);
this.events = _.extend({}, BaseModal.prototype.events, this.events); this.events = _.extend({}, BaseModal.prototype.events, this.events);
this.template = _.template($("#edit-xblock-modal-tpl").text()); this.template = this.loadTemplate('edit-xblock-modal');
this.editorModeButtonTemplate = _.template($("#editor-mode-button-tpl").text()); this.editorModeButtonTemplate = this.loadTemplate('editor-mode-button');
}, },
/** /**
......
define(["backbone", "underscore"], function(Backbone, _) { define(["underscore", "js/views/baseview"], function(_, BaseView) {
var PagingFooter = Backbone.View.extend({ var PagingFooter = BaseView.extend({
events : { events : {
"click .next-page-link": "nextPage", "click .next-page-link": "nextPage",
"click .previous-page-link": "previousPage", "click .previous-page-link": "previousPage",
...@@ -11,7 +11,7 @@ define(["backbone", "underscore"], function(Backbone, _) { ...@@ -11,7 +11,7 @@ define(["backbone", "underscore"], function(Backbone, _) {
var view = options.view, var view = options.view,
collection = view.collection; collection = view.collection;
this.view = view; this.view = view;
this.template = _.template($("#paging-footer-tpl").text()); this.template = this.loadTemplate("paging-footer");
collection.bind('add', _.bind(this.render, this)); collection.bind('add', _.bind(this.render, this));
collection.bind('remove', _.bind(this.render, this)); collection.bind('remove', _.bind(this.render, this));
collection.bind('reset', _.bind(this.render, this)); collection.bind('reset', _.bind(this.render, this));
......
define(["backbone", "underscore", "gettext"], function(Backbone, _, gettext) { define(["underscore", "gettext", "js/views/baseview"], function(_, gettext, BaseView) {
var PagingHeader = Backbone.View.extend({ var PagingHeader = BaseView.extend({
events : { events : {
"click .next-page-link": "nextPage", "click .next-page-link": "nextPage",
"click .previous-page-link": "previousPage" "click .previous-page-link": "previousPage"
...@@ -10,7 +10,7 @@ define(["backbone", "underscore", "gettext"], function(Backbone, _, gettext) { ...@@ -10,7 +10,7 @@ define(["backbone", "underscore", "gettext"], function(Backbone, _, gettext) {
var view = options.view, var view = options.view,
collection = view.collection; collection = view.collection;
this.view = view; this.view = view;
this.template = _.template($("#paging-header-tpl").text()); this.template = this.loadTemplate("paging-header");
collection.bind('add', _.bind(this.render, this)); collection.bind('add', _.bind(this.render, this));
collection.bind('remove', _.bind(this.render, this)); collection.bind('remove', _.bind(this.render, this));
collection.bind('reset', _.bind(this.render, this)); collection.bind('reset', _.bind(this.render, this));
...@@ -42,16 +42,16 @@ define(["backbone", "underscore", "gettext"], function(Backbone, _, gettext) { ...@@ -42,16 +42,16 @@ define(["backbone", "underscore", "gettext"], function(Backbone, _, gettext) {
fmts = gettext('Showing %(current_span)s%(start)s-%(end)s%(end_span)s out of %(total_span)s%(total)s total%(end_span)s, sorted by %(order_span)s%(sort_order)s%(end_span)s %(sort_direction)s'); fmts = gettext('Showing %(current_span)s%(start)s-%(end)s%(end_span)s out of %(total_span)s%(total)s total%(end_span)s, sorted by %(order_span)s%(sort_order)s%(end_span)s %(sort_direction)s');
return '<p>' + interpolate(fmts, { return '<p>' + interpolate(fmts, {
start: Math.min(start + 1, end), start: Math.min(start + 1, end),
end: end, end: end,
total: total, total: total,
sort_order: sortName, sort_order: sortName,
sort_direction: sortDirectionName, sort_direction: sortDirectionName,
current_span: '<span class="count-current-shown">', current_span: '<span class="count-current-shown">',
total_span: '<span class="count-total">', total_span: '<span class="count-total">',
order_span: '<span class="sort-order">', order_span: '<span class="sort-order">',
end_span: '</span>' end_span: '</span>'
}, true) + "</p>"; }, true) + "</p>";
}, },
nextPage: function() { nextPage: function() {
......
...@@ -9,7 +9,7 @@ define(["js/views/baseview", "underscore", "js/views/feedback_prompt", "js/views ...@@ -9,7 +9,7 @@ define(["js/views/baseview", "underscore", "js/views/feedback_prompt", "js/views
return this; return this;
}, },
initialize: function() { initialize: function() {
this.template = _.template($("#section-name-edit-tpl").text()); this.template = this.loadTemplate('section-name-edit');
this.listenTo(this.model, "invalid", this.showInvalidMessage); this.listenTo(this.model, "invalid", this.showInvalidMessage);
this.render(); this.render();
}, },
......
...@@ -15,7 +15,7 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", "jquery ...@@ -15,7 +15,7 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", "jquery
initialize: function() { initialize: function() {
BaseModal.prototype.initialize.call(this); BaseModal.prototype.initialize.call(this);
this.events = _.extend({}, BaseModal.prototype.events, this.events); this.events = _.extend({}, BaseModal.prototype.events, this.events);
this.template = _.template($("#upload-dialog-tpl").text()); this.template = this.loadTemplate("upload-dialog");
this.listenTo(this.model, "change", this.renderContents); this.listenTo(this.model, "change", this.renderContents);
this.options.title = this.model.get('title'); this.options.title = this.model.get('title');
}, },
...@@ -81,7 +81,7 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", "jquery ...@@ -81,7 +81,7 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal", "jquery
}); });
}, },
progress: function(event, position, total, percentComplete) { progress: function(event, position, total) {
this.model.set({ this.model.set({
"uploadedBytes": position, "uploadedBytes": position,
"totalBytes": total "totalBytes": total
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import json import json
from contentstore.utils import PublishState from contentstore.utils import PublishState
from contentstore.views.helpers import xblock_studio_url from contentstore.views.helpers import xblock_studio_url, EDITING_TEMPLATES
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
%> %>
<%block name="title">${_("Container")}</%block> <%block name="title">${_("Container")}</%block>
...@@ -14,7 +14,7 @@ from django.utils.translation import ugettext as _ ...@@ -14,7 +14,7 @@ from django.utils.translation import ugettext as _
<%block name="header_extras"> <%block name="header_extras">
% for template_name in ["basic-modal", "modal-button", "edit-xblock-modal", "editor-mode-button"]: % for template_name in EDITING_TEMPLATES:
<script type="text/template" id="${template_name}-tpl"> <script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" /> <%static:include path="js/${template_name}.underscore" />
</script> </script>
...@@ -30,14 +30,14 @@ main_xblock_info = { ...@@ -30,14 +30,14 @@ main_xblock_info = {
}; };
%> %>
<script type='text/javascript'> <script type='text/javascript'>
require(["domReady!", "jquery", "js/models/xblock_info", "js/views/xblock_container", require(["domReady!", "jquery", "js/models/xblock_info", "js/views/pages/container",
"xmodule", "coffee/src/main", "xblock/cms.runtime.v1"], "xmodule", "coffee/src/main", "xblock/cms.runtime.v1"],
function(doc, $, XBlockInfo, XBlockContainerView) { function(doc, $, XBlockInfo, XBlockContainerPage) {
var view, mainXBlockInfo; var view, mainXBlockInfo;
mainXBlockInfo = new XBlockInfo(${json.dumps(main_xblock_info) | n}); mainXBlockInfo = new XBlockInfo(${json.dumps(main_xblock_info) | n});
view = new XBlockContainerView({ view = new XBlockContainerPage({
el: $('#content'), el: $('#content'),
model: mainXBlockInfo model: mainXBlockInfo
}); });
......
<div id="content"> <div id="content">
<div class="wrapper-mast wrapper" data-location="" data-display-name="" data-category="">
<header class="mast has-actions has-navigation">
<div class="wrapper-mast wrapper" data-location="" data-display-name="" data-category=""> <h1 class="page-header">
<header class="mast has-actions has-navigation"> <small class="navigation navigation-parents">
<h1 class="page-header">
<small class="navigation navigation-parents"> <a href="/unit/TestCourse/branch/draft/block/vertical8eb" class="navigation-link navigation-parent">Unit 1</a>
<a href="#" class="navigation-link navigation-current">Nested Vertical Test</a>
<a href="/unit/TestCourse/branch/draft/block/vertical8eb" class="navigation-link navigation-parent">Unit 1</a> </small>
<a href="#" class="navigation-link navigation-current">Nested Vertical Test</a> </h1>
</small>
</h1> <nav class="nav-actions">
<h3 class="sr">Page Actions</h3>
<nav class="nav-actions"> <ul>
<h3 class="sr">Page Actions</h3>
<ul>
</ul>
</nav>
</header>
</div>
<div class="wrapper-content wrapper">
<div class="inner-wrapper">
<section class="content-area">
<article class="content-primary window">
<section class="wrapper-xblock level-page" data-locator="TestCourse/branch/draft/block/vertical131">
</section>
<div class="no-container-content is-hidden">
<p>This page has no content yet.</p>
</div>
<div class="ui-loading is-hidden">
<p><span class="spin"><i class="icon-refresh"></i></span> <span class="copy">Loading...</span></p>
</div>
</article>
<aside class="content-supplementary" role="complimentary">
<div class="bit-publishing">
<h3 class="title-3">Publishing Status</h3>
<p class="copy">
This content is published with unit <a href="/unit/TestCourse/branch/draft/block/vertical8eb">Unit 1</a>.
Say something useful about <a href="/unit/TestCourse/branch/draft/block/vertical8eb">Unit 1</a> being in draft or private mode.
</p>
</div>
<div class="bit">
<h3 class="title-3">What can I do on this page?</h3>
<ul class="list-details">
<li class="item-detail">You can view course components that contain other components on this page. In the case of experiment blocks, this allows you to confirm that you have properly configured your experiment groups.</li>
</ul>
</div>
</aside>
</section>
</div>
</div>
<script type="text/javascript">
require(['js/sock']);
</script>
<div class="wrapper-sock wrapper">
<ul class="list-actions list-cta">
<li class="action-item">
<a href="#sock" class="cta cta-show-sock"><i class="icon-question-sign"></i> <span class="copy">Looking for Help with Studio?</span></a>
</li>
</ul>
<div class="wrapper-inner wrapper">
<section class="sock" id="sock">
<header>
<h2 class="title sr">edX Studio Help</h2>
</header>
<div class="support">
<h3 class="title">Studio Support</h3>
<div class="copy">
<p>Need help with Studio? Creating a course is complex, so we're here to help. Take advantage of our documentation, help center, as well as our edX101 introduction course for course authors.</p>
</div>
<ul class="list-actions">
<li class="action-item">
<a href="http://files.edx.org/Getting_Started_with_Studio.pdf" class="action action-primary" title="This is a PDF Document">Download Studio Documentation</a>
<span class="tip">How to use Studio to build your course</span>
</li>
<li class="action-item">
<a href="http://help.edge.edx.org/" rel="external" class="action action-primary" title="This link will open in a new browser window/tab">Studio Help Center</a>
<span class="tip">Studio Help Center</span>
</li>
<li class="action-item">
<a href="https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about" rel="external" class="action action-primary" title="This link will open in a new browser window/tab">Enroll in edX101</a>
<span class="tip">How to use Studio to build your course</span>
</li>
</ul> </ul>
</div> </nav>
</header>
<div class="feedback"> </div>
<h3 class="title">Contact us about Studio</h3>
<div class="copy">
<p>Have problems, questions, or suggestions about Studio? We're also here to listen to any feedback you want to share.</p>
</div>
<ul class="list-actions">
<li class="action-item">
<a href="http://help.edge.edx.org/discussion/new" class="action action-primary show-tender" title="Use our feedback tool, Tender, to share your feedback"><i class="icon-comments"></i>Contact Us</a> <div class="wrapper-content wrapper">
</li> <div class="inner-wrapper">
</ul> <section class="content-area">
</div>
</section> <article class="content-primary window">
<section class="wrapper-xblock level-page" data-locator="TestCourse/branch/draft/block/vertical131">
</section>
<div class="no-container-content is-hidden">
<p>This page has no content yet.</p>
</div>
<div class="ui-loading is-hidden">
<p><span class="spin"><i class="icon-refresh"></i></span> <span class="copy">Loading...</span></p>
</div>
</article>
<aside class="content-supplementary" role="complimentary">
</aside>
</section>
</div>
</div> </div>
</div>
<div id="page-notification"></div> <div id="page-notification"></div>
</div> </div>
\ No newline at end of file
<%inherit file="base.html" /> <%inherit file="base.html" />
<%! <%!
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from contentstore.views.helpers import EDITING_TEMPLATES
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from xmodule.modulestore.django import loc_mapper from xmodule.modulestore.django import loc_mapper
%> %>
...@@ -10,7 +11,7 @@ from xmodule.modulestore.django import loc_mapper ...@@ -10,7 +11,7 @@ from xmodule.modulestore.django import loc_mapper
<%block name="bodyclass">is-signedin course unit view-unit feature-upload</%block> <%block name="bodyclass">is-signedin course unit view-unit feature-upload</%block>
<%block name="header_extras"> <%block name="header_extras">
% for template_name in ["image-modal", "basic-modal", "modal-button", "edit-xblock-modal", "editor-mode-button", "upload-dialog"]: % for template_name in EDITING_TEMPLATES:
<script type="text/template" id="${template_name}-tpl"> <script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" /> <%static:include path="js/${template_name}.underscore" />
</script> </script>
......
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