Commit 49c9cdce by Braden MacDonald

Merge branch 'braden/required-field-fixes' into st-gallen-2016-02-10

parents 719812a4 ef50f191
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
.xblock--drag-and-drop--editor .items-form .item-image-url { .xblock--drag-and-drop--editor .items-form .item-image-url {
width: 81%; width: 81%;
margin-right: 1%; margin: 0 1%;
} }
.xblock--drag-and-drop--editor .items-form .item-width { .xblock--drag-and-drop--editor .items-form .item-width {
...@@ -225,7 +225,6 @@ ...@@ -225,7 +225,6 @@
border: 1px solid #156ab4; border: 1px solid #156ab4;
border-radius: 6px; border-radius: 6px;
padding: 5px 10px; padding: 5px 10px;
margin-top: 15px;
} }
.xblock--drag-and-drop--editor .btn:hover { .xblock--drag-and-drop--editor .btn:hover {
......
...@@ -87,6 +87,10 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -87,6 +87,10 @@ function DragAndDropEditBlock(runtime, element, params) {
return success return success
}, },
scrollToTop: function() {
$('.drag-builder', element).scrollTop(0);
},
clickHandlers: function() { clickHandlers: function() {
var $fbkTab = _fn.build.$el.feedback.tab, var $fbkTab = _fn.build.$el.feedback.tab,
$zoneTab = _fn.build.$el.zones.tab, $zoneTab = _fn.build.$el.zones.tab,
...@@ -129,6 +133,7 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -129,6 +133,7 @@ function DragAndDropEditBlock(runtime, element, params) {
$fbkTab.addClass('hidden'); $fbkTab.addClass('hidden');
$zoneTab.removeClass('hidden'); $zoneTab.removeClass('hidden');
self.scrollToTop();
$(this).one('click', function loadThirdTab(e) { $(this).one('click', function loadThirdTab(e) {
// $zoneTab -> $itemTab // $zoneTab -> $itemTab
...@@ -148,6 +153,7 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -148,6 +153,7 @@ function DragAndDropEditBlock(runtime, element, params) {
$zoneTab.addClass('hidden'); $zoneTab.addClass('hidden');
$itemTab.removeClass('hidden'); $itemTab.removeClass('hidden');
self.scrollToTop();
$(this).addClass('hidden'); $(this).addClass('hidden');
$('.save-button', element).parent() $('.save-button', element).parent()
...@@ -167,6 +173,7 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -167,6 +173,7 @@ function DragAndDropEditBlock(runtime, element, params) {
$zoneTab $zoneTab
.on('click', '.add-zone', function(e) { .on('click', '.add-zone', function(e) {
e.preventDefault();
_fn.build.form.zone.add(); _fn.build.form.zone.add();
}) })
.on('click', '.remove-zone', _fn.build.form.zone.remove) .on('click', '.remove-zone', _fn.build.form.zone.remove)
...@@ -187,13 +194,13 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -187,13 +194,13 @@ function DragAndDropEditBlock(runtime, element, params) {
_fn.build.$el.targetImage.attr('src', new_img_url); _fn.build.$el.targetImage.attr('src', new_img_url);
} }
_fn.data.targetImg = new_img_url; _fn.data.targetImg = new_img_url;
})
.on('input', '.target-image-form #background-description', function(e) {
var new_description = $.trim( var new_description = $.trim(
$('.target-image-form #background-description', element).val() $('.target-image-form #background-description', element).val()
); );
_fn.build.$el.targetImage.attr('alt', new_description); _fn.build.$el.targetImage.attr('alt', new_description);
_fn.data.targetImgDescription = new_description; _fn.data.targetImgDescription = new_description;
}) })
.on('click', '.display-labels-form input', function(e) { .on('click', '.display-labels-form input', function(e) {
_fn.data.displayLabels = $('.display-labels-form input', element).is(':checked'); _fn.data.displayLabels = $('.display-labels-form input', element).is(':checked');
...@@ -204,10 +211,12 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -204,10 +211,12 @@ function DragAndDropEditBlock(runtime, element, params) {
$itemTab $itemTab
.on('click', '.add-item', function(e) { .on('click', '.add-item', function(e) {
e.preventDefault();
_fn.build.form.item.add(); _fn.build.form.item.add();
}) })
.on('click', '.remove-item', _fn.build.form.item.remove) .on('click', '.remove-item', _fn.build.form.item.remove)
.on('click', '.advanced-link a', _fn.build.form.item.showAdvancedSettings); .on('click', '.advanced-link a', _fn.build.form.item.showAdvancedSettings)
.on('input', '.item-image-url', _fn.build.form.item.imageURLChanged);
}, },
form: { form: {
zone: { zone: {
...@@ -426,6 +435,12 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -426,6 +435,12 @@ function DragAndDropEditBlock(runtime, element, params) {
_fn.build.form.item.disableDelete(); _fn.build.form.item.disableDelete();
}, },
imageURLChanged: function(e) {
// Mark the image description field as required if (and only if) an image is specified.
var $imageUrlField = $(e.currentTarget);
var $descriptionField = $imageUrlField.closest('.item').find('.item-image-description');
$descriptionField.prop("required", $imageUrlField.val() != "");
},
enableDelete: function() { enableDelete: function() {
if (_fn.build.form.item.count > 1) { if (_fn.build.form.item.count > 1) {
_fn.build.$el.items.form.find('.remove-item').removeClass('hidden'); _fn.build.$el.items.form.find('.remove-item').removeClass('hidden');
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
<input id="background-url" <input id="background-url"
type="text" type="text"
placeholder="{% trans 'For example, http://example.com/background.png or /static/background.png' %}"> placeholder="{% trans 'For example, http://example.com/background.png or /static/background.png' %}">
<button class="btn">{% trans "Change background" %}</button>
<label class="h3" for="background-description">{% trans "Background description" %}</label> <label class="h3" for="background-description">{% trans "Background description" %}</label>
<textarea required id="background-description" <textarea required id="background-description"
aria-describedby="background-description-description"></textarea> aria-describedby="background-description-description"></textarea>
...@@ -62,7 +63,6 @@ ...@@ -62,7 +63,6 @@
to solve the problem even without seeing the image. to solve the problem even without seeing the image.
{% endblocktrans %} {% endblocktrans %}
</div> </div>
<button class="btn">{% trans "Change background" %}</button>
</form> </form>
</section> </section>
<section class="tab-content"> <section class="tab-content">
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
</div> </div>
<div class="row"> <div class="row">
<label for="item-{{id}}-image-description">{{i18n "Image description (should provide sufficient information to place the item even if the image did not load)"}}</label> <label for="item-{{id}}-image-description">{{i18n "Image description (should provide sufficient information to place the item even if the image did not load)"}}</label>
<textarea required id="item-{{id}}-image-description" <textarea id="item-{{id}}-image-description" {{#if imageURL}}required{{/if}}
class="item-image-description">{{ imageDescription }}</textarea> class="item-image-description">{{ imageDescription }}</textarea>
</div> </div>
<div class="row"> <div class="row">
......
...@@ -3,6 +3,7 @@ import base64 ...@@ -3,6 +3,7 @@ import base64
from collections import namedtuple from collections import namedtuple
import os.path import os.path
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from xblockutils.resources import ResourceLoader from xblockutils.resources import ResourceLoader
...@@ -109,6 +110,8 @@ class SizingTests(InteractionTestBase, BaseIntegrationTest): ...@@ -109,6 +110,8 @@ class SizingTests(InteractionTestBase, BaseIntegrationTest):
def _size_for_mobile(self): def _size_for_mobile(self):
self.browser.set_window_size(375, 627) # iPhone 6 viewport size self.browser.set_window_size(375, 627) # iPhone 6 viewport size
wait = WebDriverWait(self.browser, 2)
wait.until(lambda browser: browser.get_window_size()["width"] == 375)
def test_wide_image_mobile(self): def test_wide_image_mobile(self):
""" Test the upper, larger, wide image in a mobile-sized window """ """ Test the upper, larger, wide image in a mobile-sized window """
......
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