代码之家  ›  专栏  ›  技术社区  ›  This 0ne Pr0grammer

如何从Alfresco Javascript中访问本地CSS文件?

  •  0
  • This 0ne Pr0grammer  · 技术社区  · 13 年前

    所以我已经能够在Alfresco找到一种形式,叫做 skin.css 这允许我更改数据表项的突出显示颜色。但是,我只希望能够在工作流过程中更改此属性,而不是因为它适用于整个共享网站的所有数据列表元素。

    首先,我有一个脚本,它根据规则启动,将任何更新/新文件移动到指定的文件夹中,然后启动该文件的工作流。在启动工作流的过程中,包项目列表中填充了与刚移动/工作流启动的文档位于同一文件夹中的所有文档。以下是脚本:

    function main()
    {
        var counter=0;
        //Administrative Adjudication space/folder MUST exist under companyhome.
        var rootSpaceName = companyhome.childByNamePath("mainFolder");
    
        //If the rootspacename is null (not previously created), then exit the program as we have nothing to do.
        if(rootSpaceName == null)
        {
            logger.log("Company Home/mainFolder does not exist, so we have nothing to do.");
            return;
        }
        else
        {
            logger.log("Company Home/mainFolder exists, so carry on our process.");
            //Creates an array of all the children under the rootSpaceName
            var childList = rootSpaceName.children;
            //Creates a variable which counts the number of children in the childList array
            var count = childList.length;
            //var seconds = new Date().getTime() / 1000;
    
            //If there are no children in the rootSpaceName folder, exit the program.
            if(count == 0)
            {
                logger.log("Company Home/mainFolder does not have child, nothing to do.");
                return;
            }
            else
            {
                for(var i = 0; i < count; i++)
                {
                    //Title MUST exist.
                    var childTitle = childList[i].properties["hearing:childTitle"];
                    //Author MUST exist.
                    var childAuthor = childList[i].properties["hearing:childAuthor"];
                    logger.log("childTitle: " + childTitle);
                    logger.log("childAuthor: " + childAuthor);
    
                    if(childTitle == null || childAuthor == null)
                    {
                        logger.log(i + ". Both the childTitle and childAuthor are null...");
                        continue;                             
                    }
    
                    var child = childList[i];
    
                    if(child.isContainer == false)
                    {
                        for(var j = 0; j < count; j++)
                        {
                            var newChildName = childList[j].properties.name;
                            logger.log("New child name: " + newChildName);
                            var newChild = childList[j];
    
                            if((newChild.isContainer == true) && (childTitle == newChildName))
                            {
                                logger.log("There is a currently existing folder with the same name as the title of original child");
                                var newSpaceName = rootSpaceName.childByNamePath(newChildName);
                                var newChildList = newSpaceName.children;
                                var newCount = newChildList.length;
    
                                for(var k = 0; k < newCount; k++)
                                {
                                    var newNewChildName = newChildList[k].properties.name;
                                    var newNewchildAuthor = newChildList[k].properties.author;
                                    var newNewChild = newChildList[k];
    
                                    if((newNewChild.isContainer == true) && (newNewchildAuthor == childAuthor))
                                    {
                                        var currentSpace = newSpaceName.childByNamePath(newNewChildName);                                  
    
                                        if(child.isDocument == true)
                                        {
                                            //Only want the workflow to run once so we increment count
                                            counter=counter+1;
                                            child.move(currentSpace);
                                            //If Count is 1, then run workflow
                                            if(counter==1)
                                            {                   
                                                //starts HelloWorldUI workflow                 
                                                var wfdef=workflow.getDefinitionByName("activiti$helloWorldUI");
    
                                                if(wfdef)
                                                {
                                                    var wfparams=new Array();
                                                    wfparams["bpm:workflowDescription"]="";
                                                    wfparams["bpm:groupAssignee"]=people.getGroup("GROUP_Managers");
    
                                                    var wfpackage=workflow.createPackage();
                                                    var rootSpaceName=currentSpace;
                                                    var childList=rootSpaceName.children;
                                                    var count=childList.length;
    
                                                    //add all existing documents in the space to the workflow
                                                    for(var i = 0; i < count; i++)
                                                    {
                                                        wfpackage.addNode(childList[i]);
                                                    }
    
                                                    var wfpath=wfdef.startWorkflow(wfpackage,wfparams);
                                                    var tasks=wfpath.getTasks();
    
                                                    for each(task in tasks)
                                                    {
                                                        task.endTask(null);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
    
                            else
    
                            {
                                // If title folder is already created, not need to create again.
                                var newSpaceName = companyhome.childByNamePath("mainFolder/" + childTitle);
    
                                if(newSpaceName == null)
                                {
                                    newSpaceName = rootSpaceName.createFolder(childTitle);
                                    logger.log("mainFolder/" + childTitle + " is created.");
                                }
    
                                // If author folder is already created, not need to create again.
                                var newNewSpaceName = companyhome.childByNamePath("mainFolder/" + childTitle + "/" + childAuthor);
    
                                if(newNewSpaceName == null)
                                {
                                    newNewSpaceName = newSpaceName.createFolder(childAuthor);
                                    logger.log("mainFolder/" + childTitle + "/" + childAuthor + " is created.");
                                }
    
                                if(child.isDocument == true)
                                {
                                    counter=counter + 1;
                                    child.move(newNewSpaceName);
    
                                    if(counter == 1)
                                    {
                                        var wfdef=workflow.getDefinitionByName("activiti$helloWorldUI");
    
                                        if(wfdef)
                                        {
                                            var wfparams=new Array();
                                            wfparams["bpm:workflowDescription"]="";
                                            wfparams["bpm:groupAssignee"]=people.getGroup("GROUP_Managers");
                                            var wfpackage=workflow.createPackage();
                                            var rootSpaceName=newNewSpaceName;
                                            var childList=rootSpaceName.children;
                                            var count=childList.length;
    
                                            //add all items from the space to the workflow
                                            for(var i = 0; i <c ount; i++)
                                            {
                                                wfpackage.addNode(childList[i]);
                                            }   
    
                                            var wfpath=wfdef.startWorkflow(wfpackage,wfparams);
                                            var tasks=wfpath.getTasks();
    
                                            for each(task in tasks)
                                            {
                                                task.endTask(null);
                                            }
    
                                        }
                                    }
                                    logger.log("Moving file " + child.properties.name);
                                }
                            }
                        }
                    }
                }
            }
        }
        return;
    }
    
    main();
    

    我希望能够创建某种函数,该函数只能在工作流过程中调用以访问skin.css文件,并基本上设置 .yui-skin-default tr.yui-dt-first{background-color:#FFF} 在CSS文件中。有人知道我会怎么做吗?

    2 回复  |  直到 13 年前
        1
  •  1
  •   swemon    13 年前

    如果你只想在 启动工作流 页 你的css应该用 start-workflow.css start-workflow.get.head.ftl .此css将在其他css文件(如skin.css)中覆盖。

    像这样,您可以覆盖任何css,只影响启动工作流页面,而不是其他页面。 您可以尝试其他与工作流相关的页面。

        2
  •  1
  •   cimmanon    13 年前

    我发现了一个bookmarklet,它可以让你在任何你想要的页面上插入CSS文件。唯一不利的一面是,每次加载页面时都必须运行它。

    http://allben.net/post/2010/01/30/CSS-JavaScript-Injection-Bookmarklets.aspx