/**
* 可以在页面上显示 分享路径
*/
Rsd.define('Rsd.tool.HtmlShareBox', {
extend: 'Rsd.container.Dialog',
requires: [
'Rsd.form.Button',
'Rsd.form.Label',
'Rsd.form.Link',
'Rsd.form.CheckBox',
'Rsd.control.IframeBox',
'Rsd.control.ListView'
],
src:"",
data:null,
items:[
{
xtype:'iframe',
flex:1,
//width:'100%',
height:'100%',
src:'javascript:void(0)',
ctrl:{style:{boder:'1px red solid'}},
label:{
position:'bottom',
space:0,
xtype:'container',
header:false,
height:60,
style:{lineHeight:60,display:'flex'},
layout:'hbox',
items:[
{
xtype:'list',
label:{position:'left',content:'读者列表'},
style:{color: '#999289',textAlign:'left'},
height:40,
flex:1,
},
{
xtype:'button',
height:40,
width:120,
text:'分 享',
handler:'btn_share'
}
]
},
onload:'iframe_load'
}
],
/**
*
* @param {*} config
*/
constructor: function HtmlShareBox(config) {
config = config || {};
this.apply(config);
this.items[0].src = Rsd.getRedjsHost()+'plugin/editormd/app/view.html';
// this.items[0].label.position = 'right';
// this.items[0].label.height = '100%';
// this.items[0].label.width = 100;
},
/**
*
*/
load:function load()
{
var me = this;
me.callParent();
},
/**
*
* @param {*} key
*/
download:function download(key)
{
if(Rsd.isEmpty(key))
{
return;
}
var me = this;
Rsd.app.requestService(this.fileDownloadServiceName,{filename:key+".md"}, function(resp) {
if(resp.success)
{
//更新当前key
me.key = key;
me.render_html(resp.data,function(){
//处理回调
});
}
});
},
/**
*
* @param {*} evt
* @returns
*/
iframe_load:function iframe_load(evt)
{
var me = this;
if(evt.target.src !== me.items[0].src)
{
return;
}
var c_win = me.items[0].ctrl.element.contentWindow;
if(c_win.document.readyState !== "complete")
{
console.error('document current state is:' + c_win.document.readyState );
return;
}
if(me.data)
{
me.render_html(me.data);
}
if(me.key)
{
me.download(me.key);
}
},
render_html:function render_html(data,callback)
{
var me = this;
var c_win = me.items[0].ctrl.element.contentWindow;
if(c_win.render)
{
c_win.render(data,callback);
return;
}
console.error(c_win.location.href + "未实现接口:render");
},
btn_share:function btn_share()
{
//this.items[0].label.content.hide();
Rsd.popup('show show box');
}
});