在LiveCycle Designer中包括Moment.js [英] Including Moment.js in LiveCycle Designer

查看:114
本文介绍了在LiveCycle Designer中包括Moment.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天来,我一直在尝试使用Adobe Livecycle Designer创建的动态PDF中包含实际的Moment.js库.

For few days I've been trying to include the actual Moment.js library in my dynamic PDF which I've created with Adobe Livecycle Designer.

我们使用的是旧版本(1.7.2),没有任何问题,但是现在我只收到功能不存在"错误.

We've used an older version (1.7.2) without any problems but now I only get a 'Function not exist' error.

有人对此有任何经验吗?

Does anyone have any expierience with this?

谢谢.

推荐答案

如何在Adobe LiveCycle表单中包含Moment.js:

How to include Moment.js in an Adobe LiveCycle Form:

  1. 下载缩小的脚本
  2. 在LiveCycle Designer中打开您的表单并创建一个名为MOMENTJSMIN的脚本对象
  3. 将缩小的脚本复制到该脚本对象
  4. 在LiveCycle Designer的脚本编辑器"窗口中,按以下方式编辑MOMENTJSMIN脚本对象:
  5. 删除所有脚本,直到但不包括第二个花括号{:

  1. Download the minified script
  2. In LiveCycle Designer open your form and create a Script Object called MOMENTJSMIN
  3. Copy the minified script into that Script Object
  4. In the Script Editor window of LiveCycle Designer, edit MOMENTJSMIN Script Object in the following manner:
  5. Remove all the script up to but not including the second curly brace { :

!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function()

  • 从缩小的脚本的末尾删除圆括号和分号

  • Remove the rounded parenthesis and semicolon from the end of the minified script

    将此行添加到缩小脚本的开头:

    Add this line to the beginning of the minified script:

    if (xfa.momentjs == undefined) xfa.momentjs = function()
    

  • 在MOMENTJSMIN脚本对象中,在脚本结束后添加以下函数:

  • In the MOMENTJSMIN Script Object add this function after the end of the script:

    function getMomentJS(){
        return xfa.momentjs();
    }
    

  • 现在,您的MOMENTJSMIN脚本对象已设置为向整个表单中的脚本提供Moment.js.

    Now your MOMENTJSMIN script object is set up to provide Moment.js to scripts throughout your form.

    要在您的任何脚本中使用Moment.js,请使用以下行启动脚本对象或事件脚本:

    To use Moment.js in any of your script, start your script object or event script with this line:

    var moment = MOMENTJSMIN.getMomentJS();
    

    现在,您可以在脚本中以该行开头的任何地方使用moment().例如:

    Now you can use moment() anywhere in the script that starts with that line. eg:

    var moment = MOMENTJSMIN.getMomentJS();
    var jan07 = moment([2007, 0, 29]);
    app.alert(moment().format("dddd, MMMM Do YYYY, h:mm:ss a"));
    app.alert(jan07.format("dddd, MMMM Do YYYY") + " was " + jan07.fromNow());
    app.alert(moment.isDate(new Date()));
    

    这篇关于在LiveCycle Designer中包括Moment.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆