MDL-44164 atto: Refactor the world
[moodle.git] / lib / editor / atto / plugins / indent / yui / build / moodle-atto_indent-button / moodle-atto_indent-button-debug.js
blob9dc6ee5aae34cc0c3e43a2c093860c466424346e
1 YUI.add('moodle-atto_indent-button', function (Y, NAME) {
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.
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/>.
19  * @package    atto_indent
20  * @copyright  2013 Damyon Wiese  <damyon@moodle.com>
21  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22  */
24 /**
25  * @module     moodle-atto_indent-button
26  */
28 /**
29  * Atto text editor indent plugin.
30  *
31  * @namespace M.atto_indent
32  * @class button
33  * @extends M.editor_atto.EditorPlugin
34  */
36 Y.namespace('M.atto_indent').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
37     initializer: function() {
38         this.addButton({
39             // This is adding a <blockquote> which is not ideal but that is the easiest to put in place
40             // for now. When disabling the styleWithCSS, some browser will use <blockquote> so we cannot
41             // rely on it for <div>s, and that would not work when indenting lists either....
42             // Handling it ourselves is even worse as it would require to get a parent and wrap
43             // a div with a margin around it. Considering that multiple <p> should end up in the
44             // same <div>, that table cells should not be wrapped, and that lists work differently too.
45             icon: 'e/increase_indent',
46             title: 'indent',
47             buttonName: 'indent',
48             callback: function() {
49                 document.execCommand('indent', false, null);
51                 // Some browsers add style attributes to the blockquote, let's get rid of them.
52                 // It is really tricky to figure out what blockquote was just added, so removing
53                 // the styles on all of them seems OK.
54                 // Eg. Chrome changes the selection after adding the blockquote, so we cannot target it.
55                 // IE adds a dir attribute to the blockquote too, but it's probably OK to leave it...
56                 this.editor.all('blockquote').removeAttribute('style');
58                 // Mark the text as having been updated.
59                 this.markUpdated();
60             }
61         });
63         this.addBasicButton({
64             exec: 'outdent',
65             icon: 'e/decrease_indent',
66             title: 'outdent'
67         });
68     }
69 });
72 }, '@VERSION@', {"requires": ["moodle-editor_atto-plugin"]});