editactionsview.js

来自「Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是」· JavaScript 代码 · 共 248 行

JS
248
字号
/*
* 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 EditActionsView() {
  if ( Cfx.Class.IsDefined(EditActionsView) == false ) {
    Cfx.Class.New( EditActionsView, View );
    if( Cfx.Class.IsInitializing( EditActionsView, View )) {
     
      EditActionsView.Method(do_openfolder);      
      EditActionsView.Method(load);
      EditActionsView.Method(makeCollection);
      EditActionsView.Method(deleteResource);
      EditActionsView.Method(deleteCollection);
      EditActionsView.Method(workflowAction);
      EditActionsView.Method(defaultAction);
      EditActionsView.Method(proppatch);
      EditActionsView.Method(editDocument);
      EditActionsView.Method(saveDocument);
      EditActionsView.Method(publishDocument);
      EditActionsView.Method(requestPublicationDocument);
      EditActionsView.Method(showMessage);
      EditActionsView.Method(showMessageWindow);
      EditActionsView.Method(publish);
      EditActionsView.Method(closeDocument);     
      EditActionsView.Method(saveDraft);
      EditActionsView.Method(refreshOnSave);
   return;
    }
  }
  this.InitInstance();
  return this;
  
  function load(str){
  	 
    if (this.log.debugging()) {
      this.log.debug("load: " + str  + " into view: " + this.ele.id);     
    }
    try {
      this.ele.innerHTML = str;
      var cont = this.context.get("pcontainer");
      // TODO: forms_onload gooit een exception, welke wel netjes wordt opgevangen:
      // TODO: undefined TypeError 'forms_onloadHandlers.length' is null or not an object
      /*
      if (this.log.debugging()) {
        this.log.debug("calling cont.container.forms_onload();");
      }
      cont.container.forms_onload();
      */
    } 
    catch(error) {
      this.log.error(error, "error during loading of view");
    }  
  }
  
  function do_openfolder() {
    this.log.debug("$$$$$$$$ do_openfolder!");
    //var localparams = [{key:'url',val:"/no/resource/selected"}];
    //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, this.resourceID);
    this.refresh();
    //this.resourceID = localparams;
  }

  function makeCollection(params) {
    if(params[0].val){
      this.refresh();
      //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, this.resourceID);    
    }
  }

  function deleteResource(params) {
    if (this.loaded)
    {
      this.showMessage(params); 
      if (params[0].val) {
        var localparams = [{key:'url',val:"/no/resource/selected"}];
        //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, localparams);
        //this.resourceID = localparams;
        this.saveRPC(localparams);
        window.parent.frames['topframe'].workbench.showMenu('documents');
      }
      else {
        alert(params[1].val);
      }
    }
  }

  function deleteCollection(params) {
    this.deleteResource(params);
  }

  function workflowAction(params) {
    this.showMessage(params);
    if(params[5] && params[5].key=="actionEventName")
    {
      if(params[5].val=="requestPublication")
      {
        this.sm.lookup('framework.eventmanager').fireEvent('closeDocument', params);
        new Ajax.Request('/actions/unlockDocumentAfterEditing'+params[2].val);
      }
      else if (params[5].val=="publish")
      {
        this.sm.lookup('framework.eventmanager').fireEvent('closeDocument', params);
      	new Ajax.Request('/actions/unlockDocumentAfterEditing'+params[2].val);
      }
      else if (params[5].val=="requestDeletion")
      {
        this.sm.lookup('framework.eventmanager').fireEvent('closeDocument', params);
      	new Ajax.Request('/actions/unlockDocumentAfterEditing'+params[2].val);
      }
      else
	  {
		this.refresh();    
	  }
    }
    else
    {
		this.refresh();    
    }
    //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, this.resourceID);    
  }

  function defaultAction(params) {
    //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, params);
    this.doRPC(params);
  }

  function proppatch(params) {
    if(params[0].val){
      //this.sm.lookup("cms.workbench.rc").doCall(this.config.appUrl, this, this.resourceID);
      this.refresh();    
    }
    else {
      //alert(params[1].val);
    }
  }
  
  function editDocument(params) 
  {  
    if (params[0].val)
    {
      this.url = params[0].val; // remember currently opened document
      var type = params[1].val;
      var localparams = [{key:'url',val:this.url},{key:'mode',val:'selected'}];
      this.resourceID = localparams;
      this.callWithDelay('do_openfolder()',this.longDelay,0);
    }
  }

  function saveDocument(params)
  {     
    this.showMessage(params); 
    this.editDocument(params);
  }
  
  function publishDocument(params)
  { 
    this.showMessage(params); 
     var myArray = params[3].val.split(" ");
     var id = myArray[0];
     var eleId = myArray[1];
     
     window.top.window.frames['mainframe'].window.frames['iframe-editingContainer'].document.forms[id].elements[eleId].click();
     
  }

  function requestPublicationDocument(params)
  {
    this.showMessage(params); 
  	 var myArray = params[3].val.split(" ");
  	 var id = myArray[0];
  	 var eleId = myArray[1];
  	 window.top.window.frames['mainframe'].window.frames['iframe-editingContainer'].document.forms[id].elements[eleId].click();
  	 
  }
  
  function showMessage(params)
  {
    if (params[0].val)
    {
      for (var i = 0; i < params.length; i++)
      {
        if (params[i].key == "editorMessage" && params[i].val != "")
        {
          this.showMessageWindow(params[i].val);
          //alert(params[i].val);
        }
      }
    }
  }
  
  function showMessageWindow(message)
  {
  
    var w = 480, h = 340;
    if (document.all) 
    {
      /* the following is only available after onLoad */
      w = document.body.clientWidth;
      h = document.body.clientHeight;
}
    else if (document.layers) 
    {
     w = window.innerWidth;
     h = window.innerHeight;
    }

    var popW = 300, popH = 200;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
    //var messagePopup = window.open('/editing/cf2/messagePopup.html?message='+message,'popup','width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
  }
  
  function publish(params) 
  {
    this.refresh();
  }
  

  function closeDocument(uri) 
  {
    this.sm.lookup("framework.rc").doCall('/editing/cf2/closed.html', this,null);  
  }
  
  function saveDraft(params) 
  {
    this.showMessage(params);
    this.refresh();
  }

  function refreshOnSave(params) 
  {
    this.refresh();
  }

  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?