[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 var DROPDOWN_NAME = "Dropdown menu", 2 DROPDOWN; 3 4 /** 5 * Provides an in browser PDF editor. 6 * 7 * @module moodle-assignfeedback_editpdf-editor 8 */ 9 10 /** 11 * This is a drop down list of buttons triggered (and aligned to) a button. 12 * 13 * @namespace M.assignfeedback_editpdf 14 * @class dropdown 15 * @constructor 16 * @extends M.core.dialogue 17 */ 18 DROPDOWN = function(config) { 19 config.draggable = false; 20 config.centered = false; 21 config.width = 'auto'; 22 config.visible = false; 23 config.footerContent = ''; 24 DROPDOWN.superclass.constructor.apply(this, [config]); 25 }; 26 27 Y.extend(DROPDOWN, M.core.dialogue, { 28 /** 29 * Initialise the menu. 30 * 31 * @method initializer 32 * @return void 33 */ 34 initializer: function(config) { 35 var button, body, headertext, bb; 36 DROPDOWN.superclass.initializer.call(this, config); 37 38 bb = this.get('boundingBox'); 39 bb.addClass('assignfeedback_editpdf_dropdown'); 40 41 // Align the menu to the button that opens it. 42 button = this.get('buttonNode'); 43 44 // Close the menu when clicked outside (excluding the button that opened the menu). 45 body = this.bodyNode; 46 47 headertext = Y.Node.create('<h3/>'); 48 headertext.addClass('accesshide'); 49 headertext.setHTML(this.get('headerText')); 50 body.prepend(headertext); 51 52 body.on('clickoutside', function(e) { 53 if (this.get('visible')) { 54 // Note: we need to compare ids because for some reason - sometimes button is an Object, not a Y.Node. 55 if (e.target.get('id') !== button.get('id') && e.target.ancestor().get('id') !== button.get('id')) { 56 e.preventDefault(); 57 this.hide(); 58 } 59 } 60 }, this); 61 62 button.on('click', function(e) { 63 e.preventDefault(); this.show(); 64 }, this); 65 button.on('key', this.show, 'enter,space', this); 66 }, 67 68 /** 69 * Override the show method to align to the button. 70 * 71 * @method show 72 * @return void 73 */ 74 show: function() { 75 var button = this.get('buttonNode'), 76 result = DROPDOWN.superclass.show.call(this); 77 this.align(button, [Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BL]); 78 79 return result; 80 } 81 }, { 82 NAME: DROPDOWN_NAME, 83 ATTRS: { 84 /** 85 * The header for the drop down (only accessible to screen readers). 86 * 87 * @attribute headerText 88 * @type String 89 * @default '' 90 */ 91 headerText: { 92 value: '' 93 }, 94 95 /** 96 * The button used to show/hide this drop down menu. 97 * 98 * @attribute buttonNode 99 * @type Y.Node 100 * @default null 101 */ 102 buttonNode: { 103 value: null 104 } 105 } 106 }); 107 108 Y.Base.modifyAttrs(DROPDOWN, { 109 /** 110 * Whether the widget should be modal or not. 111 * 112 * Moodle override: We override this for commentsearch to force it always false. 113 * 114 * @attribute Modal 115 * @type Boolean 116 * @default false 117 */ 118 modal: { 119 getter: function() { 120 return false; 121 } 122 } 123 }); 124 125 M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; 126 M.assignfeedback_editpdf.dropdown = DROPDOWN;
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 |