Index: lams_central/web/includes/javascript/addLesson.js =================================================================== diff -u -ra65568cc36db07abf19550359c0db03a9561c964 -r23096623cbfaccffc0b32c9090ab463539a173c8 --- lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision a65568cc36db07abf19550359c0db03a9561c964) +++ lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 23096623cbfaccffc0b32c9090ab463539a173c8) @@ -25,6 +25,9 @@ ldTreeview.init('#learningDesignTree', function(event, node) { + // deselect LD if highlighted in "recently used sequences" section + $('div#accessDiv .access-selected').removeClass('access-selected'); + // hide existing LD image $('.ldChoiceDependentCanvasElement').css('display', 'none'); @@ -61,6 +64,8 @@ addLesson(); } }); + + loadRecentlyAccessedLearningDesigns(); } //checks whether element is visible in the current viewport @@ -293,7 +298,11 @@ if (!learningDesignId) { var ldNode = tree.treeview('getSelected')[0]; - learningDesignId = ldNode.learningDesignId; + if (ldNode == null) { + learningDesignId = +$('div#accessDiv .access-selected').data('learningDesignId'); + } else { + learningDesignId = ldNode.learningDesignId; + } } if (!learningDesignId) { @@ -548,6 +557,61 @@ } } +function loadRecentlyAccessedLearningDesigns(){ + var access = null; + $.ajax({ + cache : false, + async : false, + url : LAMS_URL + "authoring/getLearningDesignAccess.do", + dataType : 'json', + data : { + }, + success : function(response) { + access = response; + } + }); + + + if (access) { + var accessCell = $('#accessDiv'); + accessCell.children('div.access').remove(); + $.each(access, function(){ + $('
').addClass('access') + .data({ + 'title' : this.title, + 'learningDesignId' : this.learningDesignId, + 'folderID' : this.workspaceFolderId + }) + .text(this.title) + .appendTo(accessCell) + .click(function(){ + // deselect LD in main tree + var selectedNode = tree.treeview('getSelected')[0]; + if (selectedNode != null) { + tree.treeview('unselectNode', selectedNode); + } + // deselect node in access list + $('.access-selected', accessCell).removeClass('access-selected'); + + // select clicked node + var accessEntry = $(this).addClass('access-selected'), + learningDesignID = +accessEntry.data('learningDesignId'); + + // hide existing LD image + $('.ldChoiceDependentCanvasElement').css('display', 'none'); + + $('#lessonNameInput').val(accessEntry.data('title')); + //focus element only if it's visible in the current viewport (to avoid unwanted scrolling) + if (isElementInViewport($('#lessonNameInput'))) { + $('#lessonNameInput').focus(); + } + // display "loading" animation and finally LD thumbnail + loadLearningDesignSVG(learningDesignID); + }); + }); + } +} + // ********** CLASS TAB FUNCTIONS ********** function fillUserContainer(users, containerId) {