处理模态框

处理模态框

使用invoke方法打开模态框

在指定位置创建一个新的扩展程序iframe实例。



zohoprojects.invoke("modal.create",modal_location);


Argument Name

Data Type

Description

action

string

"modal.create" - creates or opens a modal box.

modal_location

Object

The relative path of the HTML file that has to be invoked. Example: {"url":"/app/choosefiles.html"};

 

生成一个小部件 ID 和一个字符串常量作为输出。


使用invoke方法关闭模态框

关闭已在指定位置打开的扩展程序的iframe实例。


zohoprojects.invoke("modal.close",modalInfo.widgetID);

 

 

Argument Name

Data Type

Description

action

string

"modal.close" - 关闭打开的模态框。

widgetID

Object

作为“modal.create”输出生成的widgetID应该在这里传递。

 


使用invoke方法调整模态框的大小

将扩展程序的iframe实例调整为指定大小。

 

zohoprojects.invoke("modal.resize", resize_modal);

 

 

Argument Name

Data Type

Description

action

string

"modal.resize" -增加模态框的默认大小.

resize_modal

Object

必须调用的 HTML 文件的相对路径。Example:{"width" : 600,"height" : 400};
Min & Max allowed height 380px & 450 px.
Min & Max allowed width 550px & 950 px.

 

生成一个小部件 ID 和一个字符串常量作为输出。


使用invoke方法关闭附件选择器

关闭在指定位置打开的用于附加文件的扩展程序的iframe实例。


zohoprojects.invoke("attachment_picker.close");

 

实例

为特定小部件创建实例。


zohoprojects.instance(widget_ID);

 

Argument Name

Data Type

Description

ID

string

从调用方法生成的小部件 ID。

 

emit

从当前位置emit数据。

zohoprojects.emit("KeyforMyListener", data);

 

on

监听或接收来自 emit 方法的数据。

zohoprojects.on("KeyforMyListener", data);

 

假设以下示例代码块从父文件“/apps/index.html”调用,并且“/apps/file.html”是子文件。

var modal_location={"url":"/apps/file.html"};
zohoprojects.invoke("modal.create",modal_location).then(function(modalInfo){
var modalInstance=zohoprojects.instance(modalInfo.widgetID);
modalInstance.on("modal.opened", function(){ /* This code listens for the status 'modal.opened' from the child HTML - file.html */
var data = {org: "1234"};
modalInstance.emit("submit", data);
});/* This code throws a status 'submit' along with an object to the child HTML - file.html*/
modalInstance.on("submitted",function(data){
/*This code listens for a status with the key 'submitted' from the child HTML*/
zohoprojects.invoke("modal.close", modalInfo.widgetID);
});

 

假设以下示例代码块从子文件“/apps/file.html”调用,并且“/apps/index.html”是父文件。

var filedetails = {"filename": "abc"};
zohoprojects.on("submit", function (data) {});
/*This code listens for an event with the key "submit" from the parent file index.html  */
zohoprojects.emit("submitted", filedetails);
/* This code throws a status 'submitted' along with an object to the parent file index.html */

 

警报

设置并显示成功或失败警报。


zohoprojects.invoke("alert", {
                            type: "success",  //or "failure"
                            data: "Permission granted successfully"
                        });

 

 

完成迁移


将任务迁移标记为完成。


zohoprojects.invoke("completeTaskTransition"); 

 

关闭迁移

关闭任务迁移弹出窗口。

zohoprojects.invoke("closeTransition");