提交 a77d9c26 编写于 作者: F fancy

聊天的tab标题根据组件名称

上级 1647a4ee
......@@ -32,10 +32,23 @@ MWF.xApplication.IMV2.Main = new Class({
};
this.emojiList.push(emoji);
}
},
onQueryClose: function () {
this.closeListening()
this.closeListening();
},
// 获取组件名称
loadComponentName: function () {
o2.Actions.load("x_component_assemble_control").ComponentAction.get("IMV2", function (json) {
var imComponent = json.data;
if (imComponent && imComponent.title) {
this.setTitle(imComponent.title);
}
}.bind(this), function (err) {
console.log(err);
})
},
// 加载应用
loadApplication: function (callback) {
var url = this.path + this.options.style + "/im.html";
this.content.loadHtml(url, { "bind": { "lp": this.lp, "data": {} }, "module": this }, function () {
......@@ -52,7 +65,9 @@ MWF.xApplication.IMV2.Main = new Class({
}.bind(this));
}.bind(this));
this.loadComponentName();
},
// 监听ws消息
startListening: function () {
if (layout.desktop && layout.desktop.message) {
this.messageNumber = layout.desktop.message.items.length;
......@@ -70,13 +85,14 @@ MWF.xApplication.IMV2.Main = new Class({
}.bind(this), 1000);
}
},
// 关闭监听
closeListening: function () {
if (this.listener) {
clearInterval(this.listener);
}
},
// 接收新的消息 会话列表更新 或者 聊天窗口更新
reciveNewMessage: function() {
reciveNewMessage: function () {
//查询会话数据
this._checkConversationMessage();
//查询聊天数据
......@@ -138,13 +154,13 @@ MWF.xApplication.IMV2.Main = new Class({
}.bind(this));
},
//修改群名
tapUpdateConvTitle: function() {
tapUpdateConvTitle: function () {
this.chatTitleMoreMenuNode.setStyle("display", "none");
var form = new MWF.xApplication.IMV2.UpdateConvTitleForm(this, {}, {}, { app: this.app });
form.create();
},
//修改群成员
tapUpdateConvMembers: function() {
tapUpdateConvMembers: function () {
this.chatTitleMoreMenuNode.setStyle("display", "none");
var members = [];
for (var i = 0; i < this.conversationNodeItemList.length; i++) {
......@@ -187,46 +203,46 @@ MWF.xApplication.IMV2.Main = new Class({
document.body.addEvent("mousedown", this.hideFun);
},
// 点击发送文件消息
showChooseFile: function() {
if (!this.uploadFileAreaNode){
showChooseFile: function () {
if (!this.uploadFileAreaNode) {
this.createUploadFileNode();
}
this.fileUploadNode.click();
},
//创建文件选择框
createUploadFileNode: function(){
createUploadFileNode: function () {
this.uploadFileAreaNode = new Element("div");
var html = "<input name=\"file\" type=\"file\" multiple/>";
this.uploadFileAreaNode.set("html", html);
this.fileUploadNode = this.uploadFileAreaNode.getFirst();
this.fileUploadNode.addEvent("change", function(){
var files = this.fileUploadNode.files;
if (files.length) {
var file = files.item(0);
var formData = new FormData();
formData.append('file', file);
formData.append('fileName', file.name);
var fileExt = file.name.substring(file.name.lastIndexOf("."));
// 图片消息
var type = "file"
if (fileExt.toLowerCase() == ".bmp" || fileExt.toLowerCase() == ".jpeg"
|| fileExt.toLowerCase() == ".png" || fileExt.toLowerCase() == ".jpg") {
type = "image"
}else { // 文件消息
type = "file"
}
//上传文件
o2.Actions.load("x_message_assemble_communicate").ImAction.uploadFile(this.conversationId, type, formData, "{}", function (json) {
if (json.data) {
var fileId = json.data.id
var fileExtension = json.data.fileExtension
var fileName = json.data.fileName
this._newImageOrFileMsgAndSend(type, fileId, fileName, fileExtension)
}
}.bind(this), function (error) {
console.log(error);
}.bind(this))
this.fileUploadNode.addEvent("change", function () {
var files = this.fileUploadNode.files;
if (files.length) {
var file = files.item(0);
var formData = new FormData();
formData.append('file', file);
formData.append('fileName', file.name);
var fileExt = file.name.substring(file.name.lastIndexOf("."));
// 图片消息
var type = "file"
if (fileExt.toLowerCase() == ".bmp" || fileExt.toLowerCase() == ".jpeg"
|| fileExt.toLowerCase() == ".png" || fileExt.toLowerCase() == ".jpg") {
type = "image"
} else { // 文件消息
type = "file"
}
//上传文件
o2.Actions.load("x_message_assemble_communicate").ImAction.uploadFile(this.conversationId, type, formData, "{}", function (json) {
if (json.data) {
var fileId = json.data.id
var fileExtension = json.data.fileExtension
var fileName = json.data.fileName
this._newImageOrFileMsgAndSend(type, fileId, fileName, fileExtension)
}
}.bind(this), function (error) {
console.log(error);
}.bind(this))
}
}.bind(this));
},
hideEmojiBox: function () {
......@@ -251,7 +267,7 @@ MWF.xApplication.IMV2.Main = new Class({
form.create()
},
//更新群名
updateConversationTitle: function(title, convId) {
updateConversationTitle: function (title, convId) {
var conv = {
id: convId,
title: title,
......@@ -275,7 +291,7 @@ MWF.xApplication.IMV2.Main = new Class({
}.bind(this))
},
//更新群成员
updateConversationMembers: function(members, convId) {
updateConversationMembers: function (members, convId) {
var conv = {
id: convId,
personList: members,
......@@ -334,14 +350,14 @@ MWF.xApplication.IMV2.Main = new Class({
}
},
//创建图片或文件消息
_newImageOrFileMsgAndSend: function(type, fileId, fileName, fileExt) {
_newImageOrFileMsgAndSend: function (type, fileId, fileName, fileExt) {
var distinguishedName = layout.session.user.distinguishedName;
var time = this._currentTime();
var body = {
"body": "[文件]",
"type": type,
"fileId": fileId,
"fileExtension": fileExt,
"body": "[文件]",
"type": type,
"fileId": fileId,
"fileExtension": fileExt,
"fileName": fileName
};
var bodyJson = JSON.stringify(body);
......@@ -519,7 +535,7 @@ MWF.xApplication.IMV2.Main = new Class({
} else if (msgBody.type == "file") { //文件
var mapBox = new Element("span").inject(lastNode);
var fileIcon = this._getFileIcon(msgBody.fileExtension);
new Element("img", { "src": "../x_component_IMV2/$Main/file_icons/"+fileIcon, "width": 48, "height": 48 }).inject(mapBox);
new Element("img", { "src": "../x_component_IMV2/$Main/file_icons/" + fileIcon, "width": 48, "height": 48 }).inject(mapBox);
var downloadUrl = this._getFileDownloadUrl(msgBody.fileId);
new Element("a", { "href": downloadUrl, "target": "_blank", "text": msgBody.fileName }).inject(mapBox);
} else {//text
......@@ -579,7 +595,7 @@ MWF.xApplication.IMV2.Main = new Class({
} else if (msgBody.type == "file") { //文件
var mapBox = new Element("span").inject(lastNode);
var fileIcon = this._getFileIcon(msgBody.fileExtension);
new Element("img", { "src": "../x_component_IMV2/$Main/file_icons/"+fileIcon, "width": 48, "height": 48 }).inject(mapBox);
new Element("img", { "src": "../x_component_IMV2/$Main/file_icons/" + fileIcon, "width": 48, "height": 48 }).inject(mapBox);
var downloadUrl = this._getFileDownloadUrl(msgBody.fileId);
new Element("a", { "href": downloadUrl, "target": "_blank", "text": msgBody.fileName }).inject(mapBox);
} else {//text
......@@ -681,10 +697,10 @@ MWF.xApplication.IMV2.Main = new Class({
return "icon_file_psd.png";
} else if (ext === "tmp") {
return "icon_file_tmp.png";
}else {
} else {
return "icon_file_unkown.png";
}
}else {
} else {
return "icon_file_unkown.png";
}
},
......@@ -877,7 +893,7 @@ MWF.xApplication.IMV2.ConversationItem = new Class({
this.messageTimeNode.set("text", time);
}
},
refreshConvTitle: function(title) {
refreshConvTitle: function (title) {
this.titleNode.set("text", title);
},
addCheckClass: function () {
......@@ -1024,10 +1040,10 @@ MWF.xApplication.IMV2.CreateConversationForm = new Class({
if (data) {
if (this.options["isUpdateMember"] === true) {
this.app.updateConversationMembers(data.person, this.app.conversationId);
}else {
this.app.newConversation(data.person, this.options["personCount"] === 1 ? "single": "group");
} else {
this.app.newConversation(data.person, this.options["personCount"] === 1 ? "single" : "group");
}
this.close();
}
}
......@@ -1054,13 +1070,13 @@ MWF.xApplication.IMV2.UpdateConvTitleForm = new Class({
" <td styles='formTableValue14' item='title' colspan='3'></td></tr>" +
"</table>";
this.formTableArea.set("html", html);
this.form = new MForm(this.formTableArea, this.data || {}, {
isEdited: true,
style: "minder",
hasColon: true,
itemTemplate: {
title: {text: "群名", type: "text", notEmpty: true },
title: { text: "群名", type: "text", notEmpty: true },
}
}, this.app);
this.form.load();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册