1/** 2 * Javascript functionality for LMS Navigation Module. 3 * 4 * @uses jQuery 5 * 6 */ 7 8window.lms_navigation = (function (window, document, jQuery) { 9 'use strict'; 10 11 var app = { 12 13 /** 14 * 15 * Add event callbacks. 16 * 17 */ 18 init: function () { 19 jQuery('.sidebar .courseware-module > a').on('click', app.modules_click); 20 }, 21 22 /** 23 * Callback for jQuery 'click' event. 24 * 25 * 1. If the current module does not have any children, move on. 26 * 2. Close all module children (lessons) for the ancestor class (course). 27 * 3. Toggle the current module's children (lessons) 28 * 29 * @param {object} event The current event object. 30 * @return {void} 31 */ 32 modules_click: function (event) { 33 var $this = jQuery(event.currentTarget), 34 $parent = $this.parent('li.courseware-module'), 35 $children = $parent.find('ul.sub-menu:first'), 36 $visible = $children.is(':visible'); 37 38 //* if module doesn't have child, return 39 if (!$children.length) { 40 return; 41 } 42 43 //* prevent default link from opening 44 event.preventDefault(); 45 46 //* collapse module children 47 $children.stop(true).slideUp(); 48 49 //* if current target children not visible, show them 50 if (!$visible) { 51 $children.stop(true).slideDown(); 52 } 53 } 54 }; 55 56 //* let jQuery initialize 57 jQuery(document).ready(app.init); 58 59 //* return the object 60 return app; 61 62})(window, document, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.