提交 b3ea0313 编写于 作者: U unknown

api中加入了dialog方法

上级 3cb9e504
......@@ -460,7 +460,7 @@ o2.widget.Dialog = o2.DL = new Class({
// // this.content.setStyle("display", "block");
// //this.fireEvent("postShow");
var pn = this.node.getOffsetParent();
var pn = this.node.getOffsetParent() || this.node.getParent();
var p = pn.getPosition();
var h = this.css.to.height.toInt();
......
......@@ -1718,6 +1718,9 @@ MWF.xScript.CMSEnvironment = function(ev){
"notice": function(content, type, target, where, offset, option){
_form.notice(content, type, target, where, offset, option);
},
"dialog": function ( options ) {
_form.dialog( options );
},
"addEvent": function(e, f){_form.addEvent(e, f);},
"openWork": function(id, completedId, title, options){
var op = options || {};
......
......@@ -3125,30 +3125,32 @@ MWF.xScript.Environment = function(ev){
_form.notice(content, type, target, where, offset, option);
},
/**弹出一个对话框文档
/**弹出一个对话框
* @method dialog
* @static
* @param {(Object)} options
* 弹出框选项:<br/>
* 如果有buttonList参数,则ok,cancel参数无效。<br/>
* 对话框内容的优先级为moduleName、content、url、html、text,有前面的参数则后面的参数无效。<br/>
* 对话框内容的优先级为moduleName、content、url、html、text,有前面的参数则后面的参数无效。<br/>
* 调用弹出框对象后各事件执行先手顺序 onQueryLoad-->onPostLoad-->onQueryShow-->onPostShow。<br/>
* 其他说明如下:
* <pre><code class="language-js">{
* "style" : "o2", //(string)可选,弹出框使用的样式,默认是o2,系统内置一些样式,比如:default,blue_flat,o2,flat等,对应样式文件位置:webserver\o2_core\o2\widget\$Dialog,用户也可以自己增加自定义样式风格,对应文件及结构参考已有样式风格。
* "style" : "default", //(string)可选,弹出框使用的样式,默认是user,系统内置一些样式,比如:user,blue_flat,o2,flat等,对应样式文件位置:webserver\o2_core\o2\widget\$Dialog,用户也可以自己增加自定义样式风格,对应文件及结构参考已有样式风格。
* "title" : "", //(string)可选,弹出框头部标题,在isTitle参数为true时有效。
* "width" : 300, //(number)可选,弹出框宽度。 默认值:300
* "height" : 150, //(number)可选,弹出框高度。 默认值:150
* "isTitle" : true, //(boolean)可选,弹出框是否有标题栏。默认值:true。
* "isMax" : false, //(boolean)可选,标题栏是否有最大化按钮,相对应有还原按钮,默认值:false。
* "isClose" : false, //(boolean)可选,标题栏是否有关闭按钮。默认值:false。
* "isResize" : true, //(boolean)可选,弹出框大小是否可调整。默认值:true。
* "isMove" : true, //(boolean)可选,弹出框是否可移动。默认值:true。
* "offset" : {"x":-200, "y": -100} //(object)可选,弹出框相对容器(container)的x轴y轴位置偏移量,空则居中。
* "offset" : {"x":-200, "y": -100}, //(object)可选,弹出框相对容器(container)的x轴y轴位置偏移量,空则居中。
* "mask" : true, //(boolean)可选,是否需要遮罩层。默认值:true。
* "duration" : true, //(number)可选,动画显示弹出框效果时间。默认值:200。
* "zindex": 100, //(number)可选,弹出框的z轴优先级,默认为100(日期控件的zindex为300,选人控件为1000,最好不要高于300)。
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
......@@ -3156,18 +3158,19 @@ MWF.xScript.Environment = function(ev){
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ], //(Array)可选,定义底部按钮,比如“确认”,“关闭”按钮等,数组列表。无该参数则默认有确定和取消两个按钮,这个时候options可以传入ok或者cancel方法作为回调。如果传入空数组“[]”则底部无按钮。
* "ok": function(){}, //(function) 可选,options.buttonList为空的时候,该方法作为“确定”按钮的回调方法,options.buttonList不为空则忽略该方法。
* "close": function(){}, //(function) 可选,options.buttonList为空的时候,该方法作为“取消”按钮的回调方法,options.buttonList不为空则忽略该方法。
* "container" : this.form.getApp().content, //(Element/Dom)可选,弹出框层dom对象需要插入页面html内元素的位置,移动端默认插入到body中,PC端默认插入到表单节点所在容器(this.form.getApp().content)。
* "moduleName": "div1", //内容参数,优先级为1,(String)可选,表示表单组件名称,系统会获取该组件的node节点作为对话框内容,关闭对话框节点会插回到原来的位置。
* "content": this.form.get("div1").node, //内容参数,优先级为2,(Element/Dom)可选,对话框内容,关闭对话框节点会插回到原来的位置。
* ], //(Array)可选,定义底部按钮,数组列表。无该参数则默认有确定和取消两个按钮,这个时候options可以传入ok或者cancel方法作为回调。如果传入空数组“[]”则底部无按钮。
* "ok": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“确定”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
* "close": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“取消”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
* "container" : this.form.getApp().content, //(Element/Dom)可选,弹出框层dom对象的父dom,位置相对对象。移动端默认插入到body中,PC端默认插入到表单节点所在容器(this.form.getApp().content)。
* "moduleName": "div_1", //内容参数,优先级为1,(String)可选,表示表单组件名称,系统会获取该组件的node节点作为对话框内容,关闭对话框节点会插回到原来的位置。
* "content": this.form.get("div1").node, //内容参数,优先级为2,(Element/Dom)可选,对话框内容,如果节点在document中,关闭对话框节点会插回到原来的位置。
* "url": "http://xxx/xxx.html", //内容参数,优先级为3,(String)可选,该参数所指向的内容作为对话框的内容。
* "html": "<div>html内容</div>", //内容参数,优先级为4,(String)可选,对话框的html内容。
* "text": "文本内容", //内容参数,优先级为5,(String)可选,对话框的文本内容。
......@@ -3176,25 +3179,117 @@ MWF.xScript.Environment = function(ev){
* "onQueryLoad": function(){}, //(function) 可选,弹出框载入前事件,this指向对话框对象。
* "onPostLoad": function(){}, //(function) 可选,弹出框载入后事件,this指向对话框对象。
* "onQueryShow": function(){}, //(function) 可选,弹出框显示前事件,this指向对话框对象。
* "onPostShow": function(){}, //(function) 可选,弹出框显示后事件,this指向对话框对象。
* "onPostShow": function(){} //(function) 可选,弹出框显示后事件,this指向对话框对象。
* }</code></pre>
* @example
//启动一个通知公告
this.form.createDocument("", "通知公告");
* //打开一个对话框,使用html作为内容
* var _self = this;
* this.form.dialog({
* "title": "填写内容",
* "width": "500",
* "height": "300",
* "html": "<div>内容:</div><div><input type='text'></div>",
* "ok": function(){
* var value = this.node.getElement("input").value; //this指向对话框对象
* if( !value ){
* _self.form.notice("请填写内容", "info");
* return false; //返回false不关闭对话框
* }else{
* return true; //返回true关闭对话框
* }
* }
*});
* @example
//启动一个通知公告,标题为:关于XX的通知,启动后提示
this.form.createDocument("", "通知公告", {"subject": "关于XX的通知"}, function(json){
this.form.notice("创建成功!", "success");
}.bind(this));
* //打开一个对话框,使用表单中的div_1组件作为内容
* var _self = this;
* this.form.dialog({
* "title": "填写内容",
* "width": "400",
* "height": "200",
* "moduleName": "div_1", //内容为表单上的组件,标识为div_1
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
* var value = _self.form.get("textfield").getData(); //获取div_1中的组件textfield的值
* if( !value ){
* _self.form.notice("请填写内容","info");
* }else{
* this.close();
* }
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ]
* });
* @example
//启动一个通知公告,标题为:关于XX的通知,启动后提示
this.form.createDocument({
category : "通知公告",
data : {"subject": "关于XX的通知"},
callback : function(json){
this.form.notice("创建成功!", "success");
}.bind(this)
});
* //打开一个对话框,创建Dom节点作为内容
* var _self = this;
* var content = new Element("div");
* new Element("label", {
* text: "内容:"
* }).inject(content);
* new Element("input", {
* type: "text"
* }).inject(content);
* this.form.dialog({
* "title": "填写内容",
* "width": "400",
* "height": "200",
* "zindex": 301, //z轴优先级为301
* "content": content, //new Element创建的内容,也可以使用 this.form.get(xx).node 作为内容
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
* var value = this.node.getElement("input").get("value"); //获取对话框节点中的input的值
* if( !value ){
* _self.form.notice("请填写内容","info");
* }else{
* this.close();
* }
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ],
* "onQueryClose": function(){
* console.log("-onQueryClose-");
* },
* "onPostClose": function(){
* console.log("-onPostClose-");
* },
* "onQueryLoad":function(){
* console.log("-onQueryLoad-");
* },
* "onPostLoad": function(){
* console.log("-onPostLoad-");
* },
* "onQueryShow": function(){
* console.log("-onQueryshow-");
* },
* "onPostShow": function(){
* console.log("-onPostShow-");
* }.bind(this)
* });
*/
"dialog": function ( options ) {
_form.dialog( options );
......
......@@ -1808,6 +1808,16 @@ if (!MWF.xScript || !MWF.xScript.PageEnvironment) {
"notice": function (content, type, target, where, offset, option) {
_form.notice(content, type, target, where, offset, option);
},
/**打开一个对话框
* @method dialog
* @static
* @see module:form.dialog
*/
"dialog": function ( options ) {
_form.dialog( options );
},
/**给页面添加事件。
* @method addEvent
* @static
......
......@@ -4309,6 +4309,15 @@ MWF.xScript.ViewEnvironment = function (ev) {
_form.notice(content, type, target, where, offset, option);
},
/**打开一个对话框
* @method dialog
* @static
* @see module:form.dialog
*/
"dialog": function ( options ) {
_form.dialog( options );
},
/** 给视图添加事件。
* @method addEvent
* @static
......
......@@ -2838,34 +2838,45 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
dialog: function( options ){
if( !options )options = {};
var opts = {
"style" : options.stype || "o2",
"style" : options.style || "user",
"title": options.title || "",
"width": options.width || 300,
"height" : options.height || 150,
"isMax": o2.typeOf( options.isMax ) ? options.isMax : false,
"isClose": o2.typeOf( options.isClose ) ? options.isClose : true,
"isResize": o2.typeOf( options.isResize ) ? options.isResize : true,
"isMove": o2.typeOf( options.isMove ) ? options.isMove : true,
"isTitle": o2.typeOf( options.isTitle ) ? options.isTitle : true,
"isMax": o2.typeOf( options.isMax ) === "boolean" ? options.isMax : false,
"isClose": o2.typeOf( options.isClose ) === "boolean" ? options.isClose : true,
"isResize": o2.typeOf( options.isResize ) === "boolean" ? options.isResize : true,
"isMove": o2.typeOf( options.isMove ) === "boolean" ? options.isMove : true,
"isTitle": o2.typeOf( options.isTitle ) === "boolean" ? options.isTitle : true,
"offset": options.offset || null,
"mask": o2.typeOf( options.mask ) ? options.mask : true,
"mask": o2.typeOf( options.mask ) === "boolean" ? options.mask : true,
"container": options.container || ( layout.mobile ? $(documtn.body) : this.app.content ),
"duration": options.duration || 200,
"lp": options.lp || null,
"zindex": ( options.zindex || 100 ).toInt(),
"buttonList": options.buttonList || [
{
"text": this.app.lp.button.ok,
"type": "ok",
"text": MWF.LP.process.button.ok,
"action": function(){
if(options.ok)options.ok( this );
this.close();
if(options.ok){
var flag = options.ok.call( this );
if( flag === true || o2.typeOf(flag) === "null" )this.close();
}else{
this.close();
}
}
},
{
"text": this.app.lp.button.cancel,
"type": "cancel",
"text": MWF.LP.process.button.cancel,
"action": function(){
if(options.close)options.close(this);
this.close();
if(options.close){
var flag = options.close.call(this);
if( flag === true || o2.typeOf(flag) === "null" )this.close();
}else{
this.close();
}
}
}
]
......@@ -2873,14 +2884,16 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
var positionNode;
if( options.moduleName ){
var module, _form = this.form, name = options.moduleName, subformName = options.subformName;
if( subformName && _form.all[subformName +"_"+ name] ){
module = _form.all[subformName +"_"+ name];
var module, name = options.moduleName, subformName = options.subformName;
if( subformName && this.all[subformName +"_"+ name] ){
module = this.all[subformName +"_"+ name];
}else{
module = _form.all[name];
module = this.all[name];
}
if( module ){
opts.content = module.node;
positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
}
if( module )opts.content = module.node;
positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
}else if( options.content ) {
opts.content = options.content;
var parent = opts.content.getParent();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册