Skip to content

Commit

Permalink
Select content of field when focusing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtyaka committed Aug 12, 2016
1 parent 087598e commit 9845083
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drag_and_drop_v2/public/js/drag_and_drop_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ function DragAndDropEditBlock(runtime, element, params) {

// Hide settings that are specific to assessment mode
_fn.build.$el.feedback.form.find('.problem-mode').trigger('change');

// Set focus on first input field.
$element.find('input:first').select();
},

validate: function() {
Expand Down Expand Up @@ -137,7 +140,7 @@ function DragAndDropEditBlock(runtime, element, params) {
$fbkTab.addClass('hidden');
$zoneTab.removeClass('hidden');
self.scrollToTop();
$zoneTab.find('input:first').focus();
$zoneTab.find('input:first').select();

$(this).one('click', function loadThirdTab(e) {
// $zoneTab -> $itemTab
Expand All @@ -158,7 +161,7 @@ function DragAndDropEditBlock(runtime, element, params) {
$zoneTab.addClass('hidden');
$itemTab.removeClass('hidden');
self.scrollToTop();
$itemTab.find('input:first').focus();
$itemTab.find('input:first').select();

$(this).addClass('hidden');
$('.save-button', element).parent()
Expand All @@ -184,7 +187,7 @@ function DragAndDropEditBlock(runtime, element, params) {
e.preventDefault();
_fn.build.form.zone.add();
// Set focus to first field of the new zone.
$('.zones-form .zone-row:last input[type=text]:first', element).select().focus();
$('.zones-form .zone-row:last input[type=text]:first', element).select();
})
.on('click', '.remove-zone', _fn.build.form.zone.remove)
.on('input', '.zone-row input', _fn.build.form.zone.changedInputHandler)
Expand Down Expand Up @@ -225,7 +228,7 @@ function DragAndDropEditBlock(runtime, element, params) {
e.preventDefault();
_fn.build.form.item.add();
// Set focus to first field of the new item.
$('.items-form .item:last input[type=text]:first', element).select().focus();
$('.items-form .item:last input[type=text]:first', element).select();
})
.on('click', '.remove-item', _fn.build.form.item.remove)
.on('click', '.advanced-link button', _fn.build.form.item.showAdvancedSettings)
Expand Down

0 comments on commit 9845083

Please sign in to comment.