📄 container.js
字号:
/*
* Copyright 2001-2007 Hippo (www.hippo.nl)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function PerspectiveContainer() {
if(!Cfx.Class.IsDefined(PerspectiveContainer)) {
Cfx.Class.New(PerspectiveContainer, baseComponent);
if(Cfx.Class.IsInitializing(PerspectiveContainer)) {
PerspectiveContainer.Method(init);
PerspectiveContainer.Method(initialized);
PerspectiveContainer.Method(setVisibility);
PerspectiveContainer.Method(setLocation);
PerspectiveContainer.Method(createView);
PerspectiveContainer.Method(getView);
PerspectiveContainer.Method(getDOM);
return;
}
}
// Setup instance data.
this.InitInstance();
this.container = null;
// Return instance.
return this;
function init() {
var containerFrame = this.context.get(this.config.frameName);
this.log.info("Initializing PerspectiveContainer");
// creates hidden container to receive server data
switch(this.context.get("browser")) {
case 'IE':
containerFrame.document.body.insertAdjacentHTML( "afterBegin", '<div id="DIV' + this.config.id + '"></div>' );
var div = containerFrame.document.all( "DIV" + this.config.id );
var html = '<iframe frameborder="0" height="100%" width="100%" name="iframe-' + this.config.id + '" src="' + this.config.frameUrl + '"></iframe>';
div.innerHTML = html;
div.style.display = 'none';
this.container = containerFrame.frames['iframe-' + this.config.id];
break;
case 'MOZ':
var div = containerFrame.document.createElement('DIV');
div.id = "DIV" + this.config.id;
div.style.display = 'none';
div.className='perspective';
containerFrame.document.body.appendChild(div);
var iframe = containerFrame.document.createElement('IFRAME');
iframe.name = "iframe-" + this.config.id;
iframe.id = "iframe-" + this.config.id;
iframe.src = this.config.frameUrl;
iframe.width = "100%";
iframe.height = "100%";
iframe.frameBorder=0;
div.appendChild(iframe);
this.container = iframe;
break;
case 'OPR':
var div = containerFrame.document.createElement('DIV');
div.id = "DIV" + this.config.id;
div.style.display = 'none';
div.className='perspective';
containerFrame.document.body.appendChild(div);
var iframe = containerFrame.document.createElement('IFRAME');
iframe.name = "iframe-" + this.config.id;
iframe.id = "iframe-" + this.config.id;
iframe.src = this.config.frameUrl;
iframe.width = "100%";
iframe.height = "100%";
div.appendChild(iframe);
this.container = iframe;
break;
/*
case 'NS':
this.container = new containerFrame.Layer(100);
this.container.name = containerName;
this.container.visibility = 'hidden';
this.container.clip.width = 100;
this.container.clip.height = 100;
break;
*/
/*
case 'KONQ':
var span = document.createElement('SPAN');
span.id = "SPAN" + containerName;
document.body.appendChild( span );
var iframe = document.createElement('IFRAME');
iframe.name = containerName;
iframe.id = containerName;
span.appendChild( iframe );
container = iframe;
span.style.display = none;
iframe.style.display = none;
iframe.style.visibility = hidden;
iframe.height = 0;
iframe.width = 0;
break;
*/
}
}
function initialized(){
var _doc = null;
switch(this.context.get("browser")) {
case 'OPR':
_doc= this.container.contentDocument;
break;
case 'MOZ':
_doc= this.container.contentDocument;
break;
case 'IE':
_doc=this.container.document;
break;
}
var _res = (_doc != null);
if (_res) _res = _res && (_doc.body != null);
if (_res) _res = _res && (_doc.body.innerHTML != ''); // for mozilla
return _res;
}
function setVisibility( vis ) {
var containerFrame = this.context.get(this.config.frameName);
switch( this.context.get("browser")) {
case 'IE':
containerFrame.document.all("DIV" + this.config.id ).style.display = (vis)? '' : 'none';
break;
case 'MOZ':
containerFrame.document.getElementById("DIV" + this.config.id).style.display = (vis)? '' : 'none';
break;
case 'OPR':
containerFrame.document.getElementById("DIV" + this.config.id).style.display = (vis)? '' : 'none';
break;
/*
case 'NS':
this.container.visibility = (vis)? 'show' : 'hidden';
break;
case 'OPR':
document.getElementById("DIV" + this.id).style.visibility = (vis)? '' : 'hidden';
this.container.width = (vis)? 250 : 0;
this.container.height = (vis)? 100 : 0;
break;
*/
}
}
function setLocation(location) {
switch(this.context.get("browser")) {
case 'MOZ':
this.container.src = location;
break;
}
}
function createView(strId, style) {
switch(this.context.get("browser")) {
case 'OPR':
if (this.container.contentDocument.body != null)
{
var div = this.container.document.createElement('DIV');
div.id = strId;
if (strId == "submenu") { // if not the submenu, we need to indent it to make some space for the submenu. So give an indent class to indent it with CSS
div.className = style;
} else {
div.className = style + ' indentview';
}
this.container.document.body.appendChild(div);
}
break;
case 'MOZ':
if (this.container.contentDocument.body != null)
{
var div = this.container.contentDocument.createElement('DIV');
div.id = strId;
if (strId == "submenu") { // if not the submenu, we need to indent it to make some space for the submenu. So give an indent class to indent it with CSS
div.className = style;
} else {
div.className = style + ' indentview';
}
this.container.contentDocument.body.appendChild(div);
}
break;
case 'IE':
if (this.container.document.body != null)
{
if (strId == "submenu") { // if not the submenu, we need to indent it to make some space for the submenu. So give an indent class to indent it with CSS
this.container.document.body.insertAdjacentHTML( "afterBegin", '<div id="' + strId + '" class="' +style+ '"></div>');
} else {
this.container.document.body.insertAdjacentHTML( "afterBegin", '<div id="' + strId + '" class="' +style+ ' indentview"></div>');
}
}
break;
}
return this.getView(strId);
}
function getView(strId) {
switch(this.context.get("browser")) {
case 'MOZ':
return this.container.contentDocument.getElementById(strId);
case 'OPR':
return this.container.contentDocument.getElementById(strId);
case 'IE':
return this.container.document.all(strId);
}
}
function getDOM() {
switch(this.context.get("browser")) {
case 'IE':
return this.container;
default:
var main = window.top.window.frames['mainframe'];
return main.frames[this.container.id];
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -