0fe43212969c7a0da776bd019a7f1ed5dabe2d1e
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Resources / Public / JavaScript / HTMLArea / Extjs / ux / ToolbarText.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * Ext.ux.Toolbar.HTMLAreaToolbarText extends Ext.Toolbar.TextItem
16 */
17 define('TYPO3/CMS/Rtehtmlarea/HTMLArea/Extjs/ux/ToolbarText',
18 ['TYPO3/CMS/Rtehtmlarea/HTMLArea/Event/Event'],
19 function (Event) {
20
21 var ToolbarText = Ext.extend(Ext.Toolbar.TextItem, {
22
23 /**
24 * Constructor
25 */
26 initComponent: function () {
27 ToolbarText.superclass.initComponent.call(this);
28 this.addListener({
29 afterrender: {
30 fn: this.initEventListeners,
31 single: true
32 }
33 });
34 },
35
36 /**
37 * Initialize listeners
38 */
39 initEventListeners: function () {
40 // Monitor toolbar updates in order to refresh the state of the button
41 var self = this;
42 Event.on(this.getToolbar(), 'HTMLAreaEventToolbarUpdate', function (event, mode, selectionEmpty, ancestors, endPointsInSameBlock) { Event.stopEvent(event); self.onUpdateToolbar(mode, selectionEmpty, ancestors, endPointsInSameBlock); return false; });
43 },
44
45 /**
46 * Get a reference to the editor
47 */
48 getEditor: function() {
49 return RTEarea[this.toolbar.editorId].editor;
50 },
51
52 /**
53 * Get a reference to the toolbar
54 */
55 getToolbar: function() {
56 return this.toolbar;
57 },
58
59 /**
60 * Handler invoked when the toolbar is updated
61 */
62 onUpdateToolbar: function (mode, selectionEmpty, ancestors, endPointsInSameBlock) {
63 this.setDisabled(mode === 'textmode' && !this.textMode);
64 if (!this.disabled) {
65 this.plugins['onUpdateToolbar'](this, mode, selectionEmpty, ancestors, endPointsInSameBlock);
66 }
67 }
68 });
69
70 return ToolbarText;
71
72 });