Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow authors to put div content in a separate file #90

Merged
merged 3 commits into from
Jul 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/lab/common/controllers/div-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
define(function (require) {

var inherit = require('common/inherit'),
InteractiveComponent = require('common/controllers/interactive-component');
InteractiveComponent = require('common/controllers/interactive-component'),
alert = require('common/alert');

/**
* Simplest component controller which just inherits from InteractiveComponent, simply
Expand All @@ -17,10 +18,29 @@ define(function (require) {
// Call super constructor.
InteractiveComponent.call(this, "div", component, scriptingAPI, controller);
var content = component.content;
if (content && content.join) {
content = content.join("\n");
var divController = this;
if (component.url) {
// make sure the user sets the width and height because otherwise the layout
// will be broken
if( component.width === "auto" || component.height === "auto") {
alert("This interactive has a remote div component.\n"+
"The width and/or height is not set.\n"+
"Please set both the width and height.");
}


$.ajax(component.url, {
dataType: "html",
complete: function (data){
divController.$element.append(data.responseText);
}
});
} else {
if (content && content.join) {
content = content.join("\n");
}
this.$element.append(content);
}
this.$element.append(content);
}
inherit(DivController, InteractiveComponent);

Expand Down
5 changes: 4 additions & 1 deletion src/lab/common/controllers/interactive-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ define(function() {
required: true
},
content: {
defaultValue: ""
conflictsWith: ["url"]
},
url: {
conflictsWith: ["content"]
},
width: {
defaultValue: "auto"
Expand Down