Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support login

  • Loading branch information...
commit 36b5c3656f6eccc3e7f5bc8c5ff0298bf346bfdd 1 parent 4434153
@zzdhidden zzdhidden authored
View
2  build/discuz.mk
@@ -4,6 +4,7 @@ PRODUCT_NAME = discuz
JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
${JS_SRC_DIR}/ui.user.js\
+ ${JS_SRC_DIR}/ui.login.js\
${JS_SRC_DIR}/ui.buddy.js\
${JS_SRC_DIR}/ui.room.js\
${JS_SRC_DIR}/ui.menu.js\
@@ -14,6 +15,7 @@ JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
CSS_APP_FILES = ${CSS_SRC_DIR}/buddy.css\
${CSS_SRC_DIR}/setting.css\
${CSS_SRC_DIR}/user.css\
+ ${CSS_SRC_DIR}/login.css\
${CSS_SRC_DIR}/room.css\
${CSS_SRC_DIR}/menu.css\
${APP_SRC_DIR}/chatlink.css\
View
2  build/discuzX.mk
@@ -4,6 +4,7 @@ PRODUCT_NAME = discuzX
JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
${JS_SRC_DIR}/ui.user.js\
+ ${JS_SRC_DIR}/ui.login.js\
${JS_SRC_DIR}/ui.buddy.js\
${JS_SRC_DIR}/ui.room.js\
${JS_SRC_DIR}/ui.menu.js\
@@ -14,6 +15,7 @@ JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
CSS_APP_FILES = ${CSS_SRC_DIR}/buddy.css\
${CSS_SRC_DIR}/setting.css\
${CSS_SRC_DIR}/user.css\
+ ${CSS_SRC_DIR}/login.css\
${CSS_SRC_DIR}/room.css\
${CSS_SRC_DIR}/menu.css\
${APP_SRC_DIR}/chatlink.css\
View
2  build/phpbb.mk
@@ -4,6 +4,7 @@ PRODUCT_NAME = phpbb
JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
${JS_SRC_DIR}/ui.user.js\
+ ${JS_SRC_DIR}/ui.login.js\
${JS_SRC_DIR}/ui.buddy.js\
${JS_SRC_DIR}/ui.room.js\
${JS_SRC_DIR}/ui.menu.js\
@@ -14,6 +15,7 @@ JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
CSS_APP_FILES = ${CSS_SRC_DIR}/buddy.css\
${CSS_SRC_DIR}/setting.css\
${CSS_SRC_DIR}/user.css\
+ ${CSS_SRC_DIR}/login.css\
${CSS_SRC_DIR}/room.css\
${CSS_SRC_DIR}/menu.css\
${APP_SRC_DIR}/chatlink.css\
View
2  build/phpwind.mk
@@ -4,6 +4,7 @@ PRODUCT_NAME = phpwind
JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
${JS_SRC_DIR}/ui.user.js\
+ ${JS_SRC_DIR}/ui.login.js\
${JS_SRC_DIR}/ui.buddy.js\
${JS_SRC_DIR}/ui.room.js\
${JS_SRC_DIR}/ui.menu.js\
@@ -14,6 +15,7 @@ JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
CSS_APP_FILES = ${CSS_SRC_DIR}/buddy.css\
${CSS_SRC_DIR}/setting.css\
${CSS_SRC_DIR}/user.css\
+ ${CSS_SRC_DIR}/login.css\
${CSS_SRC_DIR}/room.css\
${CSS_SRC_DIR}/menu.css\
${APP_SRC_DIR}/chatlink.css\
View
2  build/uchome.mk
@@ -4,6 +4,7 @@ PRODUCT_NAME = uchome
JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
${JS_SRC_DIR}/ui.user.js\
+ ${JS_SRC_DIR}/ui.login.js\
${JS_SRC_DIR}/ui.buddy.js\
${JS_SRC_DIR}/ui.room.js\
${JS_SRC_DIR}/ui.menu.js\
@@ -14,6 +15,7 @@ JS_APP_FILES = ${JS_SRC_DIR}/ui.setting.js\
CSS_APP_FILES = ${CSS_SRC_DIR}/buddy.css\
${CSS_SRC_DIR}/setting.css\
${CSS_SRC_DIR}/user.css\
+ ${CSS_SRC_DIR}/login.css\
${CSS_SRC_DIR}/room.css\
${CSS_SRC_DIR}/menu.css\
${APP_SRC_DIR}/chatlink.css\
View
16 css/buddy.css
@@ -1,11 +1,23 @@
#webim-buddy{
padding: .3em 0;
}
+
+#webim-buddy .webim-buddy-error{
+ padding: .2em .5em;
+ margin: .5em 0;
+}
+
+#webim-buddy .webim-buddy-logo{
+ background: url("../images/logo.png") no-repeat center;
+ height: 100px;
+}
+
#webim-buddy .webim-buddy-search{
padding: 0em 1.6em 0em 0em;
margin: .3em .5em .5em;
display: none;
}
+
#webim-buddy .webim-buddy-search input{
border: none;
background: none;
@@ -16,11 +28,13 @@
/*
*/
}
+
#webim-buddy .webim-buddy-search em{
float: right;
display: inline;
margin: .1em -1.5em 0 0;
}
+
#webim-buddy .webim-buddy-online{
padding: 1em;
text-align: center;
@@ -30,10 +44,12 @@
#webim-buddy .webim-buddy-online a{
padding: 1em 2em;
}
+
#webim-buddy .webim-buddy-content{
padding: .2em .5em .3em;
position:relative;
}
+
/*fuck ie6 why ?*/
* html #webim-buddy .webim-buddy-content{
position: fixed;
View
31 css/login.css
@@ -0,0 +1,31 @@
+/*webim login*/
+
+.webim .webim-login{
+ padding: 0 1em;
+}
+.webim .webim-login p{
+ overflow: hidden;
+ margin: 1em 0;
+}
+.webim .webim-login form label{
+ float: left;
+ width: 33%;
+}
+.webim .webim-login form input
+,.webim .webim-login form select{
+ float: left;
+ width: 60%;
+ color: inherit;
+}
+.webim .webim-login form .webim-login-submit{
+ float: none;
+ padding: .2em 0;
+}
+
+.webim .webim-login-notice{
+}
+
+.webim .webim-login-error{
+ padding: .2em .5em;
+ margin: .5em 0;
+}
2  im
@@ -1 +1 @@
-Subproject commit 34c43b204098aea82e2cb7f383a8110a8758e91f
+Subproject commit 44a48dc317f2384054f01631b60db49b05330b19
View
BIN  images/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
16 js/i18n/webim-en.js
@@ -52,9 +52,8 @@ webim.ui.i18n.store('en',{
"chat with":"Chat with {{name}}",
"chat with me":"Chat with me",
"new message":"New Message",
- "connect error":"Connect error",
- "disconnect":"Disconnect",
- "online error":"Failed to online",
+ "Connect Error":"Connect error",
+ "Disconnect":"Disconnect",
"play_sound": "Play sound for new messages",
"buddy_sticky": "Keep friends window open",
"msg_auto_pop": "Auto pop-up window for new message",
@@ -83,7 +82,16 @@ webim.ui.i18n.store('en',{
"location": "location",
"from": "from",
"download history": "Download histories",
- "font color": "Font color"
+ "font color": "Font color",
+ "Not Found": "Not Found",
+ "Not Authorized" : "Not Authorized",
+ "IM Server Not Found": "IM Server Not Found",
+ "IM Server Not Authorized": "IM Server Not Authorized",
+ "username": "Username",
+ "password": "Password",
+ "question": "Question",
+ "answer": "Answer",
+ "login": "Login"
});
webim.ui.i18n.store('en',{
View
16 js/i18n/webim-zh-CN.js
@@ -52,9 +52,8 @@ webim.ui.i18n.store('zh-CN',{
"chat with":"和{{name}}聊天",
"chat with me":"和我聊天",
"new message":"有新消息",
- "connect error":"连接失败",
- "disconnect":"连接断开",
- "online error":"登录失败",
+ "Connect Error":"连接失败",
+ "Disconnect":"连接断开",
"play_sound": "收到新消息时播放提示音",
"buddy_sticky": "保持聊天窗口始终打开",
"msg_auto_pop": "新消息时自动弹出聊天窗口",
@@ -83,7 +82,16 @@ webim.ui.i18n.store('zh-CN',{
"location": "正在",
"from": "来自",
"download history": "下载历史记录",
- "font color": "文字颜色"
+ "font color": "文字颜色",
+ "Not Found" : "连接网络失败",
+ "Not Authorized" : "登录失败",
+ "IM Server Not Found": "未找到IM服务器",
+ "IM Server Not Authorized": "登录IM服务器失败",
+ "username": "用户名",
+ "password": "密码",
+ "question": "问题",
+ "answer": "答案",
+ "login": "登录"
});
webim.ui.i18n.store('zh-CN',{
View
16 js/i18n/webim-zh-TW.js
@@ -52,9 +52,8 @@ webim.ui.i18n.store('zh-TW',{
"chat with":"和{{name}}聊天",
"chat with me":"和我聊天",
"new message":"有新消息",
- "connect error":"連接失敗",
- "disconnect":"連接斷開",
- "online error":"登錄失敗",
+ "Connect Error":"連接失敗",
+ "Disconnect":"連接斷開",
"play_sound": "收到新消息時播放提示音",
"buddy_sticky": "保持聊天窗口始終打開",
"msg_auto_pop": "新消息時自動彈出聊天窗口",
@@ -83,7 +82,16 @@ webim.ui.i18n.store('zh-TW',{
"location": "正在",
"from": "來自",
"download history": "下載歷史記錄",
- "font color": "文字顏色"
+ "font color": "文字顏色",
+ "Not Found" : "連接網絡失敗",
+ "Not Authorized" : "登錄失敗",
+ "IM Server Not Found": "未找到IM服務器",
+ "IM Server Not Authorized": "登錄IM服務器失敗",
+ "username": "用戶名",
+ "password": "密碼",
+ "question": "問題",
+ "answer": "答案",
+ "login": "登錄"
});
webim.ui.i18n.store('zh-TW',{
View
47 js/ui.buddy.js
@@ -26,7 +26,7 @@ app("buddy", {
var ui = this, im = ui.im, buddy = im.buddy, layout = ui.layout;
var buddyUI = ui.buddy = new webimUI.buddy(null, extend({
title: i18n("buddy")
- }, options));
+ }, options ) );
layout.addWidget(buddyUI, extend({
title: i18n("buddy"),
@@ -37,9 +37,15 @@ app("buddy", {
isMinimize: !im.status.get("b"),
titleVisibleLength: 19
}, options.windowOptions));
- if(!options.disable_user){
- ui.addApp("user");
- buddyUI.window.subHeader(ui.user.element);
+ if(!options.disable_user) {
+ ui.addApp( "user", options.userOptions );
+ if( options.is_login ) {
+ buddyUI.window.subHeader( ui.user.element );
+ ui.user._initElement = true;
+ }
+ }
+ if( !options.is_login && !options.disable_login ) {
+ ui.addApp("login", extend( { container: buddyUI.$.content }, options.loginOptions ) );
}
//buddy events
im.setting.bind("update",function(key, val){
@@ -49,8 +55,6 @@ app("buddy", {
buddyUI.bind("select", function(info){
ui.addChat("buddy", info.id);
ui.layout.focusChat("buddy", info.id);
- }).bind("online",function(){
- im.online();
});
buddyUI.window.bind("displayStateChange",function(type){
if(type != "minimize"){
@@ -62,9 +66,6 @@ app("buddy", {
buddy.option("active", false);
}
});
- function count_buddy(){
- return buddy.count({presence:"online"}) - buddy.count({presence:"online", show: "invisible"});
- }
var mapId = function(a){ return isObject(a) ? a.id : a };
var grepVisible = function(a){ return a.show != "invisible" && a.presence == "online"};
@@ -91,19 +92,26 @@ app("buddy", {
},
go: function(){
var ui = this, im = ui.im, buddy = im.buddy, buddyUI = ui.buddy;
+ ui.user && !ui.user._initElement && buddyUI.window.subHeader(ui.user.element);
buddyUI.titleCount();
+ hide( buddyUI.$.logo );
+ buddyUI.hideError();
},
- stop: function(type){
+ stop: function(type, msg){
var ui = this, im = ui.im, buddy = im.buddy, buddyUI = ui.buddy;
buddyUI.offline();
- type && buddyUI.notice(type);
+ if ( type == "online" || type == "connect" ) {
+ buddyUI.showError( msg );
+ }
}
});
widget("buddy",{
template: '<div id="webim-buddy" class="webim-buddy">\
<div id=":search" class="webim-buddy-search ui-state-default ui-corner-all"><em class="ui-icon ui-icon-search"></em><input id=":searchInput" type="text" value="" /></div>\
- <div class="webim-buddy-content">\
+ <div class="webim-buddy-content" id=":content">\
+ <div id=":logo" class="webim-buddy-logo">&nbsp;</div>\
+ <div class="ui-state-error webim-login-error ui-corner-all" style="display: none;" id=":error"></div>\
<div id=":empty" class="webim-buddy-empty"><%=empty buddy%></div>\
<ul id=":ul"></ul>\
</div>\
@@ -209,14 +217,15 @@ self.trigger("offline");
online: function(){
var self = this, $ = self.$, win = self.window;
self.notice("connect");
- show($.empty);
+ hide( $.empty );
},
offline: function(){
var self = this, $ = self.$, win = self.window;
- self.notice("offline");
- show($.empty);
self.scroll(false);
self.removeAll();
+ hide( $.empty );
+ show( $.logo );
+ self.notice("offline");
},
_updateInfo:function(el, info){
el = el.firstChild;
@@ -327,6 +336,14 @@ self.trigger("offline");
el && el.firstChild.click();
return el;
},
+ hideError: function() {
+ hide( this.$.error );
+ },
+ showError: function( msg ) {
+ var er = this.$.error;
+ er.innerHTML = i18n( msg );
+ show( er );
+ },
destroy: function(){
}
});
View
81 js/ui.login.js
@@ -0,0 +1,81 @@
+/*
+* ui.login:
+*
+*/
+app("login", {
+ init: function(options){
+ options = options || {};
+ var ui = this, im = ui.im;
+ var loginUI = ui.login = new webimUI.login(null, options);
+ options.container && options.container.appendChild( loginUI.element );
+ loginUI.bind( "login", function( params ){
+ im.online( params );
+ });
+ },
+ go: function() {
+ this.login.hide();
+ },
+ stop: function( type, msg ) {
+ //type == "online" && this.login.showError( msg );
+ }
+});
+
+widget("login", {
+ questions: null,
+ notice: "",
+ template: '<div> \
+ <div id=":login" class="webim-login"> \
+ <div class="webim-login-notice" id=":notice"></div>\
+ <div class="ui-state-error webim-login-error ui-corner-all" style="display: none;" id=":error"></div>\
+ <form id=":form">\
+ <p><label for=":username"><%=username%></label><input name="username" id=":username" type="text" /></p>\
+ <p><label for=":password"><%=password%></label><input name="password" id=":password" type="password" /></p>\
+ <div id=":more">\
+ <p><label for=":question"><%=question%></label><select name="question" id=":question" ></select></p>\
+ <p><label for=":answer"><%=answer%></label><input name="answer" id=":answer" type="text" /></p>\
+ </div>\
+ <p><input name="submit" id=":submit" class="ui-state-default ui-corner-all webim-login-submit" value="<%=login%>" type="submit" /></p>\
+ </form>\
+ </div>'
+},{
+ _init: function() {
+ var self = this, questions = self.options.questions, $ = self.$;
+ if ( questions && questions.length ) {
+ each( questions, function(n, v) {
+ var option = document.createElement( "option" );
+ option.value = v[0];
+ option.innerHTML = v[1];
+ $.question.appendChild( option );
+ } );
+ } else {
+ hide( $.more );
+ }
+ $.notice.innerHTML = self.options.notice;
+
+ },
+ _initEvents: function() {
+ var self = this, $ = self.$;
+ hoverClass( $.submit, "ui-state-hover" );
+ addEvent( $.form, "submit", function( e ) {
+ self.trigger( "login", [{ username: $.username.value, password: $.password.value, question: $.question.value, answer: $.answer.value }] );
+ preventDefault( e );
+ } );
+ },
+ hide: function() {
+ hide( this.element );
+ },
+ show: function() {
+ show( this.element );
+ },
+ hideError: function() {
+ hide( this.$.error );
+ },
+ showError: function( msg ) {
+ var er = this.$.error;
+ er.innerHTML = i18n( msg );
+ show( er );
+ },
+ destroy: function(){
+ }
+});
+
View
2  test/index.html
@@ -33,6 +33,7 @@
<link href="../css/layout.css" media="all" type="text/css" rel="stylesheet"/>
<link href="../css/setting.css" media="all" type="text/css" rel="stylesheet"/>
<link href="../css/user.css" media="all" type="text/css" rel="stylesheet"/>
+ <link href="../css/login.css" media="all" type="text/css" rel="stylesheet"/>
<link href="../css/buddy.css" media="all" type="text/css" rel="stylesheet"/>
<link href="../css/room.css" media="all" type="text/css" rel="stylesheet"/>
<link href="../css/emot.css" media="all" type="text/css" rel="stylesheet"/>
@@ -52,6 +53,7 @@
<script type="text/javascript" src="../js/ui.menu.js" ></script>
<script type="text/javascript" src="../js/ui.hotpost.js" ></script>
<script type="text/javascript" src="../js/ui.user.js" ></script>
+ <script type="text/javascript" src="../js/ui.login.js" ></script>
<script type="text/javascript" src="../js/ui.buddy.js" ></script>
<script type="text/javascript" src="../js/ui.room.js" ></script>
<script type="text/javascript" src="../js/ui.chat.js" ></script>
View
11 test/unit/ui.js
@@ -2,6 +2,7 @@ module("ui");
webim.notification.defaults.url = "data/notifications.php";
test("webim.ui", 1, function() {
stop();
+ var is_login = false;
webim.ui.ready(function(){
webim = window.webim;
_path = "images/";
@@ -22,12 +23,18 @@ test("webim.ui", 1, function() {
im.user({"uid":"1","id":"admin","nick":"admin","pic_url":"http:\/\/test.com\/project\/uc\/discuzX\/uc_server\/avatar.php?uid=0&size=small","url":"home.php?mod=space&uid=1"});
ui.addApp("menu", {"data": menu});
ui.layout.addShortcut( menu);
- ui.addApp("buddy");
+ ui.addApp("buddy", {
+ is_login: is_login,
+ loginOptions: {
+ questions: [["0", "安全提问(未设置请忽略)"], ["1", "母亲的名字"], ["2", "爷爷的名字"], ["3", "父亲出生的城市"], ["4", "你其中一位老师的名字"], ["5", "你个人计算机的型号"], ["6", "你最喜欢的餐馆名称"], ["7", "驾驶执照最后四位数字"]],
+ notice: "请使用UChome帐号登录"
+ }
+ });
ui.addApp("room");
ui.addApp("notification");
ui.addApp("setting", {"data": webim.setting.defaults.data});
ui.render();
- im.autoOnline() && im.online();
+ is_login && im.autoOnline() && im.online();
//im.online();
im.bind("go", function(data){
data.connection.server = "../im/test/" + data.connection.server;
Please sign in to comment.
Something went wrong with that request. Please try again.