MDL-58581 editor_atto: change paragraph icon.
[moodle.git] / lib / editor / atto / plugins / title / yui / build / moodle-atto_title-button / moodle-atto_title-button.js
CommitLineData
adca7326
DW
1YUI.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
62467795
AN
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
adca7326
DW
28/**
29 * Atto text editor title plugin.
30 *
62467795
AN
31 * @namespace M.atto_title
32 * @class button
33 * @extends M.editor_atto.EditorPlugin
adca7326 34 */
adca7326 35
62467795
AN
36var 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 ];
55c0403c 59
62467795
AN
60Y.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({
5530d873 70 icon: 'e/styleparagraph',
62467795
AN
71 globalItemConfig: {
72 callback: this._changeStyle
73 },
74 items: items
75 });
adca7326
DW
76 },
77
78 /**
62467795
AN
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
adca7326 85 */
62467795
AN
86 _changeStyle: function(e, style) {
87 document.execCommand('formatBlock', false, style);
88
89 // Mark as updated
90 this.markUpdated();
adca7326 91 }
62467795 92});
adca7326
DW
93
94
62467795 95}, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});