4fe35b550860099eb9a90f280a1623a4828f3be3
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / iframepanel.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 /**
16 * iFrame panel
17 */
18
19 Ext.ns('TYPO3');
20
21 TYPO3.iframePanel = Ext.extend(Ext.Panel, {
22 name: 'iframe',
23 iframe: null,
24 src: Ext.isIE && Ext.isSecure ? Ext.SSL_SECURE_URL : 'about:blank',
25 showLoadingIndicator: true,
26
27 // component build
28 initComponent: function() {
29 this.bodyCfg = {
30 tag: 'iframe',
31 frameborder: '0',
32 src: this.src,
33 name: this.name,
34 style: 'float:left;' // this is needed to prevent offset of 2.5 pixel, see #15771
35 }
36 TYPO3.iframePanel.superclass.initComponent.apply(this, arguments);
37
38 // apply the addListener patch for 'message:tagging'
39 this.addListener = this.on;
40
41 },
42
43 onRender : function() {
44 TYPO3.iframePanel.superclass.onRender.apply(this, arguments);
45 this.iframe = window.frames[this.name];
46 this.body.dom['onload'] = this.loadHandler.createDelegate(this);
47 },
48
49 loadHandler: function() {
50 this.src = this.body.dom.src;
51 this.finishLoader();
52 },
53
54 getIframe: function() {
55 return this.iframe;
56 },
57 getUrl: function() {
58 return this.body.dom.src;
59 },
60
61 setUrl: function(source) {
62 this.body.dom.src = source;
63 this.startLoader();
64 },
65
66 resetUrl: function() {
67 this.setUrl(this.src);
68 },
69
70 getIdFromUrl: function() {
71 var url = Ext.urlDecode(this.getUrl().split('?')[1]);
72 return url.id;
73 },
74
75 refresh: function() {
76 if (!this.isVisible()) {
77 return;
78 }
79 this.startLoader();
80 this.body.dom.src = this.body.dom.src;
81 },
82
83 /**
84 * wrapper function for nprogress
85 */
86 startLoader: function() {
87 if (this.showLoadingIndicator) {
88 require(['nprogress'], function(NProgress) {
89 NProgress.configure({parent: '.t3js-scaffold-content-module', showSpinner: false});
90 NProgress.start();
91 });
92 }
93 },
94
95 finishLoader: function() {
96 if (this.showLoadingIndicator) {
97 require(['nprogress'], function(NProgress) {
98 NProgress.done();
99 });
100 }
101 }
102 });
103 Ext.reg('iframePanel', TYPO3.iframePanel);