Skip to content

Commit

Permalink
Make the settings panel for the lesson appear when Add New Lesson cli…
Browse files Browse the repository at this point in the history
…cked. Also focus the "title" input when the panel is shown.
  • Loading branch information
brianhogg committed Jan 21, 2025
1 parent 84636e0 commit 4e5fce8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 13 additions & 4 deletions assets/js/builder/Views/Lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ define( [
* @version 3.16.12
*/
events: _.defaults( {
'click .edit-lesson': 'open_lesson_editor',
'click .llms-headline': 'open_lesson_editor',
'click .edit-lesson': 'edit_lesson',
'click .llms-headline': 'edit_lesson',
'click .edit-quiz': 'open_quiz_editor',
'click .edit-assignment': 'open_assignment_editor',
'click .section-prev': 'section_prev',
Expand Down Expand Up @@ -88,7 +88,7 @@ define( [
this.listenTo( this.model, 'change', this.render );

Backbone.pubSub.on( 'lesson-selected', this.on_select, this );
Backbone.pubSub.on( 'new-lesson-added', this.on_select, this );
Backbone.pubSub.on( 'new-lesson-added', this.maybe_open_editor, this );

},

Expand Down Expand Up @@ -139,16 +139,25 @@ define( [
* @since 3.16.0
* @version 3.27.0
*/
open_lesson_editor: function( event ) {
edit_lesson: function( event ) {

if ( event ) {
event.preventDefault();
}

this.open_lesson_editor();
},

open_lesson_editor: function() {
Backbone.pubSub.trigger( 'lesson-selected', this.model, 'lesson' );
this.model.set( '_selected', true );
this.set_hash( false );
},

maybe_open_editor: function( model ) {
if ( this.model.id === model.id ) {
this.open_lesson_editor();
}
},

/**
Expand Down
2 changes: 2 additions & 0 deletions assets/js/builder/Views/LessonEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ define( [

this.render_points_percentage();

this.$('.llms-editable-title').focus();

return this;

},
Expand Down

0 comments on commit 4e5fce8

Please sign in to comment.