00926cffbf3dbd236994c9915a3b7be63ea54381
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / js / typo3pageModule.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2010 Steffen Gebert <steffen@steffen-gebert.de>
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 * A copy is found in the textfile GPL.txt and important notices to the license
16 * from the author is found in LICENSE.txt distributed with these scripts.
17 *
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 Ext.ns('TYPO3', 'TYPO3.Components');
28
29 TYPO3.Components.PageModule = {
30 /**
31 * Initialization
32 */
33 init: function() {
34 this.enableHighlighting();
35 },
36
37 /**
38 * This method is used to bind the higlighting function "setActive"
39 * to the mouseenter event and the "setInactive" to the mouseleave event.
40 */
41 enableHighlighting: function() {
42 Ext.select('div.t3-page-ce')
43 .on('mouseenter',this.setActive, this)
44 .on('mouseleave',this.setInactive, this);
45 },
46
47 /**
48 * This method is used to unbind the higlighting function "setActive"
49 * from the mouseenter event and the "setInactive" from the mouseleave event.
50 */
51 disableHighlighting: function() {
52 Ext.select('div.t3-page-ce')
53 .un('mouseenter', this.setActive, this)
54 .un('mouseleave', this.setInactive, this);
55 },
56
57 /**
58 * This method is used as an event handler when the
59 * user hovers the a content element.
60 */
61 setActive: function(event, target) {
62 Ext.get(target).findParent('div.t3-page-ce', null, true).addClass('active');
63 },
64
65 /**
66 * This method is used as event handler to unset active state of
67 * a content element when the mouse of the user leaves the
68 * content element.
69 */
70 setInactive: function(event, target) {
71 Ext.get(target).findParent('div.t3-page-ce', null, true).removeClass('active');
72
73 }
74 }
75
76 Ext.onReady(function() {
77 TYPO3.Components.PageModule.init();
78 });