Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * @module moodle-editor_atto-editor
18
 * @submodule filepicker
19
 */
20
 
21
/**
22
 * Filepicker options for the Atto editor.
23
 *
24
 * See {{#crossLink "M.editor_atto.Editor"}}{{/crossLink}} for details.
25
 *
26
 * @namespace M.editor_atto
27
 * @class EditorFilepicker
28
 */
29
 
30
function EditorFilepicker() {}
31
 
32
EditorFilepicker.ATTRS = {
33
    /**
34
     * The options for the filepicker.
35
     *
36
     * @attribute filepickeroptions
37
     * @type object
38
     * @default {}
39
     */
40
    filepickeroptions: {
41
        value: {}
42
    }
43
};
44
 
45
EditorFilepicker.prototype = {
46
    /**
47
     * Should we show the filepicker for this filetype?
48
     *
49
     * @method canShowFilepicker
50
     * @param string type The media type for the file picker.
51
     * @return {boolean}
52
     */
53
    canShowFilepicker: function(type) {
54
        return (typeof this.get('filepickeroptions')[type] !== 'undefined');
55
    },
56
 
57
    /**
58
     * Show the filepicker.
59
     *
60
     * This depends on core_filepicker, and then call that modules show function.
61
     *
62
     * @method showFilepicker
63
     * @param {string} type The media type for the file picker.
64
     * @param {function} callback The callback to use when selecting an item of media.
65
     * @param {object} [context] The context from which to call the callback.
66
     */
67
    showFilepicker: function(type, callback, context) {
68
        var self = this;
69
        Y.use('core_filepicker', function(Y) {
70
            var options = Y.clone(self.get('filepickeroptions')[type], true);
71
            options.formcallback = callback;
72
            if (context) {
73
                options.magicscope = context;
74
            }
75
 
76
            M.core_filepicker.show(Y, options);
77
        });
78
    }
79
};
80
 
81
Y.Base.mix(Y.M.editor_atto.Editor, [EditorFilepicker]);