Commit 0fe52737 by Filippo Valsorda

allow to change the background image

parent 7ccdeded
...@@ -86,7 +86,6 @@ ...@@ -86,7 +86,6 @@
} }
.xblock--drag-and-drop .target-img { .xblock--drag-and-drop .target-img {
background: url(../img/triangle.png) no-repeat;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
...@@ -219,6 +218,10 @@ ...@@ -219,6 +218,10 @@
margin-left: 0; margin-left: 0;
} }
.xblock--drag-and-drop .drag-builder .target-image-form input {
width: 400px;
}
.xblock--drag-and-drop .zones-form .zone-row label { .xblock--drag-and-drop .zones-form .zone-row label {
display: inline-block; display: inline-block;
width: 18%; width: 18%;
......
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
<header class="tab-header"> <header class="tab-header">
<h3>Zone Positions</h3> <h3>Zone Positions</h3>
</header> </header>
<section class="tab-content target-image-form">
<label>New background URL:</label>
<input type="text">
<button class="btn">Change background</button>
</section>
<section class="tab-content"> <section class="tab-content">
<div class="items"> <div class="items">
<form class="zones-form"></form> <form class="zones-form"></form>
......
...@@ -128,6 +128,9 @@ var dragAndDrop = (function() { ...@@ -128,6 +128,9 @@ var dragAndDrop = (function() {
// Get count of all active items // Get count of all active items
_fn.items.init(); _fn.items.init();
// Set the target image
_fn.$target.css('background', 'url(' + _fn.data.targetImg + ') no-repeat');
}, },
build: { build: {
...@@ -149,6 +152,7 @@ var dragAndDrop = (function() { ...@@ -149,6 +152,7 @@ var dragAndDrop = (function() {
init: function() { init: function() {
_fn.build.clickHandlers(); _fn.build.clickHandlers();
_fn.build.form.zone.add(); _fn.build.form.zone.add();
_fn.$target.css('background', 'url(' + _fn.data.targetImg + ') no-repeat');
}, },
clickHandlers: function() { clickHandlers: function() {
var $fbkTab = _fn.build.$el.feedback.tab, var $fbkTab = _fn.build.$el.feedback.tab,
...@@ -179,6 +183,15 @@ var dragAndDrop = (function() { ...@@ -179,6 +183,15 @@ var dragAndDrop = (function() {
// Placeholder shim for IE9 // Placeholder shim for IE9
$.placeholder.shim(); $.placeholder.shim();
})
.on( 'click', '.target-image-form button', function(e) {
e.preventDefault();
_fn.data.targetImg = $('.target-image-form input').val();
_fn.$target.css('background', 'url(' + _fn.data.targetImg + ') no-repeat');
// Placeholder shim for IE9
$.placeholder.shim();
}); });
$itemTab $itemTab
...@@ -639,11 +652,11 @@ var dragAndDrop = (function() { ...@@ -639,11 +652,11 @@ var dragAndDrop = (function() {
} }
}, },
// SAMPLE: What the data may look like
data: { data: {
feedback: {}, feedback: {},
items: [], items: [],
zones: [] zones: [],
targetImg: 'img/triangle.png'
} }
}; };
......
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