[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 // Javascript functions for Topics course format 2 3 M.course = M.course || {}; 4 5 M.course.format = M.course.format || {}; 6 7 /** 8 * Get sections config for this format 9 * 10 * The section structure is: 11 * <ul class="topics"> 12 * <li class="section">...</li> 13 * <li class="section">...</li> 14 * ... 15 * </ul> 16 * 17 * @return {object} section list configuration 18 */ 19 M.course.format.get_config = function() { 20 return { 21 container_node : 'ul', 22 container_class : 'topics', 23 section_node : 'li', 24 section_class : 'section' 25 }; 26 } 27 28 /** 29 * Swap section 30 * 31 * @param {YUI} Y YUI3 instance 32 * @param {string} node1 node to swap to 33 * @param {string} node2 node to swap with 34 * @return {NodeList} section list 35 */ 36 M.course.format.swap_sections = function(Y, node1, node2) { 37 var CSS = { 38 COURSECONTENT : 'course-content', 39 SECTIONADDMENUS : 'section_add_menus' 40 }; 41 42 var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y)); 43 // Swap menus. 44 sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS)); 45 } 46 47 /** 48 * Process sections after ajax response 49 * 50 * @param {YUI} Y YUI3 instance 51 * @param {array} response ajax response 52 * @param {string} sectionfrom first affected section 53 * @param {string} sectionto last affected section 54 * @return void 55 */ 56 M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { 57 var CSS = { 58 SECTIONNAME : 'sectionname' 59 }, 60 SELECTORS = { 61 SECTIONLEFTSIDE : '.left .section-handle img' 62 }; 63 64 if (response.action == 'move') { 65 // If moving up swap around 'sectionfrom' and 'sectionto' so the that loop operates. 66 if (sectionfrom > sectionto) { 67 var temp = sectionto; 68 sectionto = sectionfrom; 69 sectionfrom = temp; 70 } 71 72 // Update titles and move icons in all affected sections. 73 var ele, str, stridx, newstr; 74 75 for (var i = sectionfrom; i <= sectionto; i++) { 76 // Update section title. 77 var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>'); 78 sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content); 79 // Update move icon. 80 ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); 81 str = ele.getAttribute('alt'); 82 stridx = str.lastIndexOf(' '); 83 newstr = str.substr(0, stridx +1) + i; 84 ele.setAttribute('alt', newstr); 85 ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed. 86 } 87 } 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |