[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add('moodle-course-modchooser', function (Y, NAME) { 2 3 /** 4 * The activity chooser dialogue for courses. 5 * 6 * @module moodle-course-modchooser 7 */ 8 9 var CSS = { 10 PAGECONTENT: 'body', 11 SECTION: null, 12 SECTIONMODCHOOSER: 'span.section-modchooser-link', 13 SITEMENU: 'div.block_site_main_menu', 14 SITETOPIC: 'div.sitetopic' 15 }; 16 17 var MODCHOOSERNAME = 'course-modchooser'; 18 19 /** 20 * The activity chooser dialogue for courses. 21 * 22 * @constructor 23 * @class M.course.modchooser 24 * @extends M.core.chooserdialogue 25 */ 26 var MODCHOOSER = function() { 27 MODCHOOSER.superclass.constructor.apply(this, arguments); 28 }; 29 30 Y.extend(MODCHOOSER, M.core.chooserdialogue, { 31 /** 32 * The current section ID. 33 * 34 * @property sectionid 35 * @private 36 * @type Number 37 * @default null 38 */ 39 sectionid: null, 40 41 /** 42 * Set up the activity chooser. 43 * 44 * @method initializer 45 */ 46 initializer: function() { 47 var sectionclass = M.course.format.get_sectionwrapperclass(); 48 if (sectionclass) { 49 CSS.SECTION = '.' + sectionclass; 50 } 51 var dialogue = Y.one('.chooserdialoguebody'); 52 var header = Y.one('.choosertitle'); 53 var params = {}; 54 this.setup_chooser_dialogue(dialogue, header, params); 55 56 // Initialize existing sections and register for dynamically created sections 57 this.setup_for_section(); 58 M.course.coursebase.register_module(this); 59 }, 60 61 /** 62 * Update any section areas within the scope of the specified 63 * selector with AJAX equivalents 64 * 65 * @method setup_for_section 66 * @param baseselector The selector to limit scope to 67 */ 68 setup_for_section: function(baseselector) { 69 if (!baseselector) { 70 baseselector = CSS.PAGECONTENT; 71 } 72 73 // Setup for site topics 74 Y.one(baseselector).all(CSS.SITETOPIC).each(function(section) { 75 this._setup_for_section(section); 76 }, this); 77 78 // Setup for standard course topics 79 if (CSS.SECTION) { 80 Y.one(baseselector).all(CSS.SECTION).each(function(section) { 81 this._setup_for_section(section); 82 }, this); 83 } 84 85 // Setup for the block site menu 86 Y.one(baseselector).all(CSS.SITEMENU).each(function(section) { 87 this._setup_for_section(section); 88 }, this); 89 }, 90 91 /** 92 * Update any section areas within the scope of the specified 93 * selector with AJAX equivalents 94 * 95 * @method _setup_for_section 96 * @private 97 * @param baseselector The selector to limit scope to 98 */ 99 _setup_for_section: function(section) { 100 var chooserspan = section.one(CSS.SECTIONMODCHOOSER); 101 if (!chooserspan) { 102 return; 103 } 104 var chooserlink = Y.Node.create("<a href='#' />"); 105 chooserspan.get('children').each(function(node) { 106 chooserlink.appendChild(node); 107 }); 108 chooserspan.insertBefore(chooserlink); 109 chooserlink.on('click', this.display_mod_chooser, this); 110 }, 111 /** 112 * Display the module chooser 113 * 114 * @method display_mod_chooser 115 * @param {EventFacade} e Triggering Event 116 */ 117 display_mod_chooser: function(e) { 118 // Set the section for this version of the dialogue 119 if (e.target.ancestor(CSS.SITETOPIC)) { 120 // The site topic has a sectionid of 1 121 this.sectionid = 1; 122 } else if (e.target.ancestor(CSS.SECTION)) { 123 var section = e.target.ancestor(CSS.SECTION); 124 this.sectionid = section.get('id').replace('section-', ''); 125 } else if (e.target.ancestor(CSS.SITEMENU)) { 126 // The block site menu has a sectionid of 0 127 this.sectionid = 0; 128 } 129 this.display_chooser(e); 130 }, 131 132 /** 133 * Helper function to set the value of a hidden radio button when a 134 * selection is made. 135 * 136 * @method option_selected 137 * @param {String} thisoption The selected option value 138 * @private 139 */ 140 option_selected: function(thisoption) { 141 // Add the sectionid to the URL. 142 this.hiddenRadioValue.setAttrs({ 143 name: 'jump', 144 value: thisoption.get('value') + '§ion=' + this.sectionid 145 }); 146 } 147 }, 148 { 149 NAME: MODCHOOSERNAME, 150 ATTRS: { 151 /** 152 * The maximum height (in pixels) of the activity chooser. 153 * 154 * @attribute maxheight 155 * @type Number 156 * @default 800 157 */ 158 maxheight: { 159 value: 800 160 } 161 } 162 }); 163 M.course = M.course || {}; 164 M.course.init_chooser = function(config) { 165 return new MODCHOOSER(config); 166 }; 167 168 169 }, '@VERSION@', {"requires": ["moodle-core-chooserdialogue", "moodle-course-coursebase"]});
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 |