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

标签 javascript html css parsing alfresco

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

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

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 文件中。有谁知道我会怎么做?

最佳答案

如果您只想在开始工作流页面进行更改, 你的css应该写在start-workflow.css中,这是由start-workflow.get.head.ftl指向的。此 css 将覆盖其他 css 文件,如 skin.css。

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

关于javascript - 如何从 Alfresco Javascript 中访问本地 CSS 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12427875/

相关文章:

php - javascript 中是否有类似于 php 中的 compact 的函数?

javascript - Factors 函数获取最小公倍数或素数

html - 试图将我的图像定位得低一点,但它会把所有东西都拖下来

javascript - Unslider 未加载到网页上

html - CSS 和 HTML 编码

javascript - Github Typescript --> Javascript 差异比较

javascript - 改变 <select> 的背景颜色

html - ionic 文本区域值不是自动高度

css - Google CSE 边框不会在 IE7、8 和 9 中隐藏

html - Bootstrap 将内容压缩到左侧