Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('moodle-atto_title-button', function (Y, NAME) {
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/*
19
 * @package    atto_title
20
 * @copyright  2013 Damyon Wiese  <damyon@moodle.com>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
/**
25
 * @module moodle-atto_title-button
26
 */
27
 
28
/**
29
 * Atto text editor title plugin.
30
 *
31
 * @namespace M.atto_title
32
 * @class button
33
 * @extends M.editor_atto.EditorPlugin
34
 */
35
 
36
var component = 'atto_title',
37
    styles = [
38
        {
39
            text: 'h3',
40
            callbackArgs: '<h3>'
41
        },
42
        {
43
            text: 'h4',
44
            callbackArgs: '<h4>'
45
        },
46
        {
47
            text: 'h5',
48
            callbackArgs: '<h5>'
49
        },
50
        {
51
            text: 'pre',
52
            callbackArgs: '<pre>'
53
        },
54
        {
55
            text: 'p',
56
            callbackArgs: '<p>'
57
        }
58
    ];
59
 
60
Y.namespace('M.atto_title').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
61
    initializer: function() {
62
        var items = [];
63
        Y.Array.each(styles, function(style) {
64
            items.push({
65
                text: M.util.get_string(style.text, component),
66
                callbackArgs: style.callbackArgs
67
            });
68
        });
69
        this.addToolbarMenu({
70
            icon: 'e/styleparagraph',
71
            globalItemConfig: {
72
                callback: this._changeStyle
73
            },
74
            items: items
75
        });
76
    },
77
 
78
    /**
79
     * Change the title to the specified style.
80
     *
81
     * @method _changeStyle
82
     * @param {EventFacade} e
83
     * @param {string} color The new style
84
     * @private
85
     */
86
    _changeStyle: function(e, style) {
87
        document.execCommand('formatBlock', false, style);
88
 
89
        // Mark as updated
90
        this.markUpdated();
91
    }
92
});
93
 
94
 
95
}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});