newdocumentwizardview.js
来自「Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是」· JavaScript 代码 · 共 179 行
JS
179 行
function CocoonFormView() {
if ( Cfx.Class.IsDefined(CocoonFormView) == false ) {
Cfx.Class.New(CocoonFormView, View );
if( Cfx.Class.IsInitializing(CocoonFormView)) {
CocoonFormView.Method(load);
CocoonFormView.Method(parseForm);
CocoonFormView.Method(evalScripts);
CocoonFormView.Method(refresh);
return;
}
}
this.InitInstance();
this.parsingHead = false;
return this;
function refresh() {
this.context.get("pcontainer").getView(this.getId()).innerHTML = '';
this.sm.lookup("framework.rc").getText(this.config.appUrl + this.config.bootParam, this, "load");
}
function load(xmlString) {
//for now parse text as xml
//TODO: change pattern for activate function, need some kind of factoryfor the default doCall type
var xmlDoc = Sarissa.getDomDocument();
xmlDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
var headerScripts = new Array();
var bodyScripts = new Array();
var x = this.parseForm(xmlDoc.documentElement, headerScripts, bodyScripts);
var body = (x.getElementsByTagName("body"))[0];
//copy with sarisssa fails? so parse to string
var myCont = this.context.get("pcontainer").getView(this.getId());
var result = '';
for(var i=0; i<body.childNodes.length; i++) {
if(body.childNodes[i].nodeType == Node.ELEMENT_NODE)
result += new XMLSerializer().serializeToString(body.childNodes[i]);
}
myCont.innerHTML = result;
bodyScripts.push("forms_onload()");
this.evalScripts(bodyScripts);
}
function evalScripts(bodyScripts) {
for (var i = 0; i < bodyScripts.length; i++) {
this.context.get("pcontainer").getDOM().eval(bodyScripts[i]);
}
}
function parseForm(node, headerScripts, bodyScripts) {
switch(node.nodeType) {
case Node.ELEMENT_NODE:
if (node.nodeName.toLowerCase() == "head") {
parsingHead = true;
}
if (node.nodeName.toLowerCase() == "body") {
parsingHead = false;
}
if (node.nodeName.toLowerCase() == "script") {
// Collect scripts
if(parsingHead)
headerScripts.push(node.firstChild && node.firstChild.nodeValue);
else
bodyScripts.push(node.firstChild && node.firstChild.nodeValue);
node.parentNode.removeChild(node);
return;
}
if(node.nodeName.toLowerCase() == "form") {
if(node.hasAttribute("action") && node.getAttribute("action") == '') {
node.setAttribute("action", this.config.appUrl + this.config.bootParam);
}
}
var children = node.childNodes;
for (var j = 0; j < children.length; j++) {
var imported = this.parseForm(children[j], headerScripts, bodyScripts);
}
break;
}
return node;
}
}
function NewDocumentView() {
if ( Cfx.Class.IsDefined( NewDocumentView ) == false ) {
Cfx.Class.New( NewDocumentView, LazyView );
if( Cfx.Class.IsInitializing( NewDocumentView)) {
return;
}
}
this.InitInstance();
this.stopWords = new Array();
return this;
}
//////////////////////////////////////////////////////////////////////////////
// New Document Wizard View class
// (c) 2004 - jreijn@hippo.nl
//
// @extends View
// Description:
// Shows new document view
//
//////////////////////////////////////////////////////////////////////////////
/*
function NewDocumentView() {
if ( Cfx.Class.IsDefined( NewDocumentView ) == false ) {
Cfx.Class.New( NewDocumentView, CocoonFormView );
if( Cfx.Class.IsInitializing( NewDocumentView)) {
NewDocumentView.Method(newDocument);
NewDocumentView.Method(configure);
return;
}
}
this.InitInstance();
this.stopWords = new Array();
return this;
function configure(config) {
this.baseClass.configure.apply(this, [config]) //super call
if(Cfx.Js.IsDefined(config.stopWords)) {
//framework converted comma seperated list to array
if(Cfx.Js.IsArray(config.stopWords)) {
this.stopWords = config.stopWords
}
else if(Cfx.Js.IsString(config.stopWords) &&
(config.stopWords.startsWith("/") || config.stopWords.startsWith("http://"))
) {
//load by request
this.log.debug("before request");
try {
var xml = this.sm.lookup("framework.rc").getXML(this.config.stopWords);
var nodes = xml.documentElement.childNodes;
for(var i=0; i < nodes.length; i++){
var node = nodes[i];
var nodeType = node.nodeType;
if(nodeType == Node.ELEMENT_NODE) {
var txt = Sarissa.getText(node,false);
if(!(Cfx.Js.IsEmpty(txt)))
this.stopWords.push(txt);
}
}
}catch(e){ this.log.error(e,"");}
}
}
this.log.debug("Stopwords: " + this.stopWords);
}
function newDocument(params) {
if(params[0].val){
//alert(params[1].val);
//this.doRPC(params);
}
else {
alert(params[1].val);
}
}
}
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?