[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 var COLOURPICKER_NAME = "Colourpicker", 2 COLOURPICKER; 3 4 /** 5 * Provides an in browser PDF editor. 6 * 7 * @module moodle-assignfeedback_editpdf-editor 8 */ 9 10 /** 11 * COLOURPICKER 12 * This is a drop down list of colours. 13 * 14 * @namespace M.assignfeedback_editpdf 15 * @class colourpicker 16 * @constructor 17 * @extends M.assignfeedback_editpdf.dropdown 18 */ 19 COLOURPICKER = function(config) { 20 COLOURPICKER.superclass.constructor.apply(this, [config]); 21 }; 22 23 Y.extend(COLOURPICKER, M.assignfeedback_editpdf.dropdown, { 24 25 /** 26 * Initialise the menu. 27 * 28 * @method initializer 29 * @return void 30 */ 31 initializer: function(config) { 32 var colourlist = Y.Node.create('<ul role="menu" class="assignfeedback_editpdf_menu"/>'), 33 body; 34 35 // Build a list of coloured buttons. 36 Y.each(this.get('colours'), function(rgb, colour) { 37 var button, listitem, title, img, iconname; 38 39 title = M.util.get_string(colour, 'assignfeedback_editpdf'); 40 iconname = this.get('iconprefix') + colour; 41 img = M.util.image_url(iconname, 'assignfeedback_editpdf'); 42 button = Y.Node.create('<button><img alt="' + title + '" src="' + img + '"/></button>'); 43 button.setAttribute('data-colour', colour); 44 button.setAttribute('data-rgb', rgb); 45 button.setStyle('backgroundImage', 'none'); 46 listitem = Y.Node.create('<li/>'); 47 listitem.append(button); 48 colourlist.append(listitem); 49 }, this); 50 51 body = Y.Node.create('<div/>'); 52 53 // Set the call back. 54 colourlist.delegate('click', this.callback_handler, 'button', this); 55 colourlist.delegate('key', this.callback_handler, 'down:13', 'button', this); 56 57 // Set the accessible header text. 58 this.set('headerText', M.util.get_string('colourpicker', 'assignfeedback_editpdf')); 59 60 // Set the body content. 61 body.append(colourlist); 62 this.set('bodyContent', body); 63 64 COLOURPICKER.superclass.initializer.call(this, config); 65 }, 66 callback_handler: function(e) { 67 e.preventDefault(); 68 69 var callback = this.get('callback'), 70 callbackcontext = this.get('context'), 71 bind; 72 73 this.hide(); 74 75 // Call the callback with the specified context. 76 bind = Y.bind(callback, callbackcontext, e); 77 78 bind(); 79 } 80 }, { 81 NAME: COLOURPICKER_NAME, 82 ATTRS: { 83 /** 84 * The list of colours this colour picker supports. 85 * 86 * @attribute colours 87 * @type {String: String} (The keys of the array are the colour names and the values are localized strings) 88 * @default {} 89 */ 90 colours: { 91 value: {} 92 }, 93 94 /** 95 * The function called when a new colour is chosen. 96 * 97 * @attribute callback 98 * @type function 99 * @default null 100 */ 101 callback: { 102 value: null 103 }, 104 105 /** 106 * The context passed to the callback when a colour is chosen. 107 * 108 * @attribute context 109 * @type Y.Node 110 * @default null 111 */ 112 context: { 113 value: null 114 }, 115 116 /** 117 * The prefix for the icon image names. 118 * 119 * @attribute iconprefix 120 * @type String 121 * @default 'colour_' 122 */ 123 iconprefix: { 124 value: 'colour_' 125 } 126 } 127 }); 128 129 M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; 130 M.assignfeedback_editpdf.colourpicker = COLOURPICKER;
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 |