[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add('moodle-core-popuphelp', function (Y, NAME) { 2 3 /** 4 * A popup help dialogue for Moodle. 5 * 6 * @module moodle-core-popuphelp 7 */ 8 9 /** 10 * A popup help dialogue for Moodle. 11 * 12 * @class M.core.popuphelp 13 * @constructor 14 */ 15 16 function POPUPHELP() { 17 POPUPHELP.superclass.constructor.apply(this, arguments); 18 } 19 20 var SELECTORS = { 21 CLICKABLELINKS: 'span.helptooltip > a', 22 FOOTER: 'div.moodle-dialogue-ft' 23 }, 24 25 CSS = { 26 ICON: 'icon', 27 ICONPRE: 'icon-pre' 28 }, 29 ATTRS = {}; 30 31 // Set the modules base properties. 32 POPUPHELP.NAME = 'moodle-core-popuphelp'; 33 POPUPHELP.ATTRS = ATTRS; 34 35 Y.extend(POPUPHELP, Y.Base, { 36 panel: null, 37 38 /** 39 * Setup the popuphelp. 40 * 41 * @method initializer 42 */ 43 initializer: function() { 44 Y.one('body').delegate('click', this.display_panel, SELECTORS.CLICKABLELINKS, this); 45 }, 46 47 /** 48 * Display the help tooltip. 49 * 50 * @method display_panel 51 * @param {EventFacade} e 52 */ 53 display_panel: function(e) { 54 if (!this.panel) { 55 this.panel = new M.core.tooltip({ 56 bodyhandler: this.set_body_content, 57 footerhandler: this.set_footer, 58 initialheadertext: M.util.get_string('loadinghelp', 'moodle'), 59 initialfootertext: '' 60 }); 61 } 62 63 // Call the tooltip setup. 64 this.panel.display_panel(e); 65 }, 66 67 /** 68 * Override the footer handler to add a 'More help' link where relevant. 69 * 70 * @method set_footer 71 * @param {Object} helpobject The object returned from the AJAX call. 72 */ 73 set_footer: function(helpobject) { 74 // Check for an optional link to documentation on moodle.org. 75 if (helpobject.doclink) { 76 // Wrap a help icon and the morehelp text in an anchor. The class of the anchor should 77 // determine whether it's opened in a new window or not. 78 var doclink = Y.Node.create('<a />') 79 .setAttrs({ 80 'href': helpobject.doclink.link 81 }) 82 .addClass(helpobject.doclink['class']); 83 var helpicon = Y.Node.create('<img />') 84 .setAttrs({ 85 'src': M.util.image_url('docs', 'core') 86 }) 87 .addClass(CSS.ICON) 88 .addClass(CSS.ICONPRE); 89 doclink.appendChild(helpicon); 90 doclink.appendChild(helpobject.doclink.linktext); 91 92 // Set the footerContent to the contents of the doclink. 93 this.set('footerContent', doclink); 94 this.bb.one(SELECTORS.FOOTER).show(); 95 } else { 96 this.bb.one(SELECTORS.FOOTER).hide(); 97 } 98 } 99 }); 100 M.core = M.core || {}; 101 M.core.popuphelp = M.core.popuphelp || null; 102 M.core.init_popuphelp = M.core.init_popuphelp || function(config) { 103 // Only set up a single instance of the popuphelp. 104 if (!M.core.popuphelp) { 105 M.core.popuphelp = new POPUPHELP(config); 106 } 107 return M.core.popuphelp; 108 }; 109 110 111 }, '@VERSION@', {"requires": ["moodle-core-tooltip"]});
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 |