MDL-42026 Atto: Remove the styles from the headings menu + focus when opened
[moodle.git] / lib / editor / atto / plugins / title / yui / build / moodle-atto_title-button / moodle-atto_title-button-debug.js
CommitLineData
c90641fa
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
18/**
19 * Atto text editor title plugin.
20 *
21 * @package editor-atto
22 * @copyright 2013 Damyon Wiese <damyon@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25M.atto_title = M.atto_title || {
26 init : function(params) {
2b636130
JF
27 var click_h3 = function(e, elementid) {
28 M.atto_title.change_title(e, elementid, '<h3>');
c90641fa 29 };
2b636130
JF
30 var click_h4 = function(e, elementid) {
31 M.atto_title.change_title(e, elementid, '<h4>');
32 };
33 var click_h5 = function(e, elementid) {
34 M.atto_title.change_title(e, elementid, '<h5>');
35 };
36 var click_pre = function(e, elementid) {
37 M.atto_title.change_title(e, elementid, '<pre>');
c90641fa
DW
38 };
39 var click_blockquote = function(e, elementid) {
2b636130 40 M.atto_title.change_title(e, elementid, '<blockquote>');
c90641fa
DW
41 };
42 var click_p = function(e, elementid) {
2b636130 43 M.atto_title.change_title(e, elementid, '<p>');
c90641fa
DW
44 };
45
bb76233d
DW
46 var h3 = M.util.get_string('h3', 'atto_title');
47 var h4 = M.util.get_string('h4', 'atto_title');
48 var h5 = M.util.get_string('h5', 'atto_title');
49 var pre = M.util.get_string('pre', 'atto_title');
50 var blockquote = M.util.get_string('blockquote', 'atto_title');
51 var p = M.util.get_string('p', 'atto_title');
c90641fa
DW
52
53 M.editor_atto.add_toolbar_menu(params.elementid,
54 'title',
55 params.icon,
36973d70 56 params.group,
c90641fa 57 [
2b636130
JF
58 {'text' : h3, 'handler' : click_h3},
59 {'text' : h4, 'handler' : click_h4},
60 {'text' : h5, 'handler' : click_h5},
61 {'text' : pre, 'handler' : click_pre},
c90641fa
DW
62 {'text' : blockquote, 'handler' : click_blockquote},
63 {'text' : p, 'handler' : click_p}
64 ]);
2b636130
JF
65 },
66
a0191412
DW
67 /**
68 * Handle a choice from the menu (insert the node in the text editor matching elementid).
69 * @param event e - The event that triggered this.
70 * @param string elementid - The id of the editor
71 * @param string node - The html to insert
72 */
2b636130
JF
73 change_title : function(e, elementid, node) {
74 e.preventDefault();
75 if (!M.editor_atto.is_active(elementid)) {
76 M.editor_atto.focus(elementid);
77 }
78 document.execCommand('formatBlock', false, node);
c90641fa
DW
79 }
80};
81
82
83}, '@VERSION@', {"requires": ["node"]});