[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 // This file is part of Moodle - http://moodle.org/ 2 // 3 // Moodle is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // Moodle is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 15 16 /** 17 * @package atto_managefiles 18 * @copyright 2014 Frédéric Massart 19 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 20 */ 21 22 /** 23 * @module moodle-atto-managefiles-button 24 */ 25 26 /** 27 * Atto text editor managefiles plugin. 28 * 29 * @namespace M.atto_link 30 * @class button 31 * @extends M.editor_atto.EditorPlugin 32 */ 33 34 var LOGNAME = 'atto_managefiles'; 35 36 Y.namespace('M.atto_managefiles').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], { 37 38 /** 39 * A reference to the current selection at the time that the dialogue 40 * was opened. 41 * 42 * @property _currentSelection 43 * @type Range 44 * @private 45 */ 46 _currentSelection: null, 47 48 initializer: function() { 49 if (this.get('disabled')) { 50 return; 51 } 52 53 var host = this.get('host'), 54 area = this.get('area'), 55 options = host.get('filepickeroptions'); 56 57 if (options.image && options.image.itemid) { 58 area.itemid = options.image.itemid; 59 this.set('area', area); 60 } else { 61 Y.log('Plugin managefiles not available because itemid is missing.', 62 'warn', LOGNAME); 63 return; 64 } 65 66 this.addButton({ 67 icon: 'e/manage_files', 68 callback: this._displayDialogue 69 }); 70 }, 71 72 /** 73 * Display the manage files. 74 * 75 * @method _displayDialogue 76 * @private 77 */ 78 _displayDialogue: function(e) { 79 e.preventDefault(); 80 81 var dialogue = this.getDialogue({ 82 headerContent: M.util.get_string('managefiles', LOGNAME), 83 width: '800px', 84 focusAfterHide: true 85 }); 86 87 var iframe = Y.Node.create('<iframe></iframe>'); 88 // We set the height here because otherwise it is really small. That might not look 89 // very nice on mobile devices, but we considered that enough for now. 90 iframe.setStyles({ 91 height: '700px', 92 border: 'none', 93 width: '100%' 94 }); 95 iframe.setAttribute('src', this._getIframeURL()); 96 97 dialogue.set('bodyContent', iframe) 98 .show(); 99 100 this.markUpdated(); 101 }, 102 103 /** 104 * Returns the URL to the file manager. 105 * 106 * @param _getIframeURL 107 * @return {String} URL 108 * @private 109 */ 110 _getIframeURL: function() { 111 var args = Y.mix({ 112 elementid: this.get('host').get('elementid') 113 }, 114 this.get('area')); 115 return M.cfg.wwwroot + '/lib/editor/atto/plugins/managefiles/manage.php?' + 116 Y.QueryString.stringify(args); 117 } 118 }, { 119 ATTRS: { 120 disabled: { 121 value: true 122 }, 123 area: { 124 value: {} 125 } 126 } 127 });
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 |