Index: lams_central/web/main.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/main.jsp,v diff -u -r1.77.2.44 -r1.77.2.45 --- lams_central/web/main.jsp 10 Feb 2017 14:35:47 -0000 1.77.2.44 +++ lams_central/web/main.jsp 18 Feb 2017 16:22:22 -0000 1.77.2.45 @@ -275,14 +275,14 @@ Index: lams_central/web/css/main.css =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/css/Attic/main.css,v diff -u -r1.1.2.14 -r1.1.2.15 --- lams_central/web/css/main.css 29 Nov 2016 08:44:48 -0000 1.1.2.14 +++ lams_central/web/css/main.css 18 Feb 2017 16:22:22 -0000 1.1.2.15 @@ -307,6 +307,9 @@ vertical-align: middle; border-radius: 10px; } +#notificationsPendingCount.btn-default { + background-color: #ddd; +} /*DIALOGS*/ .dialogContainer { Index: lams_central/web/includes/javascript/addLesson.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/addLesson.js,v diff -u -r1.7.2.12 -r1.7.2.13 --- lams_central/web/includes/javascript/addLesson.js 3 Dec 2016 09:41:13 -0000 1.7.2.12 +++ lams_central/web/includes/javascript/addLesson.js 18 Feb 2017 16:22:22 -0000 1.7.2.13 @@ -1,4 +1,4 @@ -// ********** MAIN FUNCTIONS ********** +// ********** MAIN FUNCTIONS ********** var tree, lastSelectedUsers = {}, sortOrderAscending = {}, @@ -7,7 +7,6 @@ originalThumbnailWidth = 0, originalThumbnailHeight = 0; - /** * For tabs changing. */ @@ -50,13 +49,17 @@ }); tree.singleNodeHighlight = true; - tree.subscribe('clickEvent', function(event){ - if (!event.node.data.learningDesignId){ - // it is a folder + tree.subscribe('clickEvent', function(event) { + // if it's a folder - do not select it. if design is already selected - do not allow deselecting it on subsequent click + if (!event.node.data.learningDesignId || event.node.highlightState == 1) { return false; } $('#lessonNameInput').val(event.node.label); + //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 $('.ldChoiceDependentCanvasElement').css('display', 'none'); @@ -67,13 +70,46 @@ } }); tree.subscribe('clickEvent',tree.onEventToggleHighlight); + tree.subscribe('dblClickEvent', function(event){ + + // if it's a folder - do not select it + if (!event.node.data.learningDesignId) { + return false; + } + + //trigger "clickEvent" first so that addLesson() function will know which element is selected + tree.fireEvent("clickEvent", event); + + // start lesson + addLesson(); + }); tree.render(); // expand the first (user) folder tree.getRoot().children[0].expand(); + + // ability to start a lesson on pressing Enter button in a lesson name input + $('#lessonNameInput').on('keyup', function (e) { + if (e.keyCode == 13) { + addLesson(); + } + }); } +//checks whether element is visible in the current viewport +function isElementInViewport(el) { + el = el[0]; + var rect = el.getBoundingClientRect(); + return ( + rect.top >= 0 && + rect.left >= 0 && + rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ + rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ + ); +} + + function initClassTab(){ // users variable is declared in newLesson.jsp fillUserContainer(users.selectedLearners, 'selected-learners'); Index: lams_central/web/includes/javascript/main.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/Attic/main.js,v diff -u -r1.1.2.24 -r1.1.2.25 --- lams_central/web/includes/javascript/main.js 9 Feb 2017 17:45:44 -0000 1.1.2.24 +++ lams_central/web/includes/javascript/main.js 18 Feb 2017 16:22:22 -0000 1.1.2.25 @@ -446,6 +446,13 @@ }, success : function(count) { $('#notificationsPendingCount').text(count == 0 ? '0' : count); + + //#notificationsPendingCount will have .btn-primary class when there are some messages available and .btn-default otherwise + if (count == 0) { + $('#notificationsPendingCount').removeClass("btn-primary").addClass("btn-default"); + } else { + $('#notificationsPendingCount').removeClass("btn-default").addClass("btn-primary"); + } } }); } Index: lams_central/web/less/main.less =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/less/Attic/main.less,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_central/web/less/main.less 3 Nov 2016 05:19:42 -0000 1.1.2.1 +++ lams_central/web/less/main.less 18 Feb 2017 16:22:22 -0000 1.1.2.2 @@ -351,6 +351,9 @@ vertical-align: middle; border-radius: 10px; } +#notificationsPendingCount.btn-default { + background-color: #ddd; +} /*DIALOGS*/ .dialogContainer {