Permalink
Browse files

5.5

  • Loading branch information...
emqplus committed Jun 1, 2014
1 parent ee2a1e4 commit 606f213dd621b695cee828eeea3a9b4b6236e244
Showing with 70 additions and 3 deletions.
  1. +6 −0 CHANGELOG.md
  2. +1 −0 Makefile
  3. +1 −1 README.md
  4. +40 −0 src/presence.js
  5. +21 −1 src/webim.js
  6. +1 −1 version
View
@@ -1,6 +1,12 @@
CHANGELOG
================================
5.5
---------------------------------
* 修复IE8, IE9兼容性问题:
1) IE9下搜狗中文输入法,消息无法发送
2) jsonp模式下,客服机器人窗口无法打开
5.4
---------------------------------
* 从该版本起记录变化:)
View
@@ -18,6 +18,7 @@ BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/setting.js\
${SRC_DIR}/status.js\
${SRC_DIR}/buddy.js\
${SRC_DIR}/presence.js\
${SRC_DIR}/room.js\
${SRC_DIR}/history.js \
View
@@ -1,4 +1,4 @@
WebIM javascript lib
WebIM Core lib
=====================================================
View
@@ -0,0 +1,40 @@
/**
* presence //联系人
*/
model( "presence", {
}, {
_init: function() {
var self = this;
self.data = self.data || {};
self.set( self.data );
},
get: function(id) {
return this.data[id];
},
set: function(data) {
var self = this;
var status = {};
for(var id in data) {
var show = data[id], presence = "online";
if(show == "unavailable" || show == "invisible") {
presence = "offline";
}
status[presence] = status[presence] || [];
status[presence].push({id: id, show: show});
}
for( var key in status ) {
self.trigger(key, [status[key]]);
}
},
clear: function() {
var self = this;
self.data = [];
}
});
View
@@ -22,11 +22,14 @@ extend(webim.prototype, {
show: 'unavailable'
}
};
self.models = {}
ajax.settings.dataType = options.jsonp ? "jsonp" : "json";
self.status = new webim.status();
self.setting = new webim.setting();
self.models['presence'] = new webim.presence();
self.buddy = new webim.buddy();
self.room = new webim.room(null, self.data );
self.history = new webim.history(null, self.data );
@@ -62,14 +65,28 @@ extend(webim.prototype, {
self.trigger( "beforeOnline", [ post_data ] );
},
_go: function() {
var self = this, data = self.data, history = self.history, buddy = self.buddy, room = self.room;
var self = this, data = self.data, history = self.history, buddy = self.buddy, room = self.room, presence = self.models['presence'];
self.state = webim.ONLINE;
history.options.userInfo = data.user;
var ids = [];
//buddies
each( data.buddies, function(n, v) {
history.init( "chat", v.id, v.history );
});
buddy.set( data.buddies );
//added in version 5.5
//presences
if(data.presences) {
presence.set(data.presences);
} else {
presence.set(map(data.buddies, function(b) {
var p = {};
p[b.id] = b.show;
return p;
}));
}
//rooms
each( data.rooms, function(n, v) {
history.init( "grpchat", v.id, v.history );
@@ -109,6 +126,7 @@ extend(webim.prototype, {
self.data.user.presence = "offline";
self.data.user.show = "unavailable";
self.buddy.clear();
self.models['presence'].clear();
self.room.clear();
self.history.clean();
self.trigger("offline", [type, msg] );
@@ -122,6 +140,7 @@ extend(webim.prototype, {
, setting = self.setting
, history = self.history
, buddy = self.buddy
, presence = self.models['presence']
, room = self.room;
self.bind( "message", function( e, data ) {
@@ -323,6 +342,7 @@ extend(webim.prototype, {
function idsArray( ids ) {
return ids && ids.split ? ids.split( "," ) : ( isArray( ids ) ? ids : ( parseInt( ids ) ? [ parseInt( ids ) ] : [] ) );
}
function model( name, defaults, proto ) {
function m( data, options ) {
var self = this;
View
@@ -1 +1 @@
5.4
5.5

0 comments on commit 606f213

Please sign in to comment.