Ability to use Enter instead of Ctrl-Enter

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@484 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-04-24 15:09:46 +00:00
parent 6f5074deba
commit ed75f8df9f
9 changed files with 35 additions and 19 deletions

View File

@ -1 +1 @@
var myAgent="";var xj=0;var myRealAgent="";function yj(){var zj=["opera","msie","safari","firefox","netscape","mozilla"];var qj=navigator.userAgent.toLowerCase();for(var i=0;i<zj.length;i++){var $j=zj[i];if(qj.indexOf($j)!=-1){myAgent=$j;if(!window.RegExp)break;var _j=new RegExp($j+"[ \/]?([0-9]+(\.[0-9]+)?)");if(_j.exec(qj)!=null){xj=parseFloat(RegExp.$1);} break;} } myRealAgent=myAgent;if(navigator.product=="Gecko")myAgent="moz";} yj();function getEl(name){return document.getElementById(name);}
var myAgent="";var $j=0;var myRealAgent="";function _j(){var mk=["opera","msie","safari","firefox","netscape","mozilla"];var tj=navigator.userAgent.toLowerCase();for(var i=0;i<mk.length;i++){var nk=mk[i];if(tj.indexOf(nk)!=-1){myAgent=nk;if(!window.RegExp)break;var qk=new RegExp(nk+"[ \/]?([0-9]+(\.[0-9]+)?)");if(qk.exec(tj)!=null){$j=parseFloat(RegExp.$1);} break;} } myRealAgent=myAgent;if(navigator.product=="Gecko")myAgent="moz";} _j();function getEl(name){return document.getElementById(name);}

File diff suppressed because one or more lines are too long

View File

@ -41,10 +41,14 @@ var FrameUtils = {
scrollDown: function(frm) {
var vbottom = this.getDocument(frm).getElementById('bottom');
if( myAgent == 'opera' ) {
try {
frm.contentWindow.scrollTo(0,this.getDocument(frm).getElementById('content').clientHeight);
} else if( vbottom )
} catch(e) {}
}
if( vbottom ) {
vbottom.scrollIntoView(false);
}
}
};
Ajax.ChatThreadUpdater = Class.create();
@ -250,11 +254,15 @@ Class.inherit( Ajax.ChatThreadUpdater, Ajax.Base, {
}
},
isSendkey: function(ctrlpressed, key) {
return ((key==13 && (ctrlpressed || this._options.ignorectrl)) || (key==10));
},
handleKeyDown: function(k) {
if( k ){ ctrl=k.ctrlKey;k=k.which; } else { k=event.keyCode;ctrl=event.ctrlKey; }
if( this._options.message && ((k==13 && (ctrl || myRealAgent == 'opera')) || (k==10)) ) {
if( this._options.message && this.isSendkey(ctrl, k) ) {
var mmsg = this._options.message.value;
if( myRealAgent == 'opera' ) {
if( this._options.ignorectrl ) {
mmsg = mmsg.replace(/[\r\n]+$/,'');
}
this.postMessage( mmsg );
@ -315,11 +323,6 @@ Behaviour.register({
Chat.threadUpdater.postMessage(message.value);
};
},
'a#sndmessagelnk' : function(el) {
if( myRealAgent == 'opera' ) {
el.innerHTML = el.innerHTML.replace('Ctrl-','');
}
},
'select#predefined' : function(el) {
el.onchange = function() {
var message = $('msgwnd');
@ -382,5 +385,5 @@ Behaviour.register({
EventHelper.register(window, 'onload', function(){
Chat.webimRoot = threadParams.wroot;
Chat.cssfile = threadParams.cssfile;
Chat.threadUpdater = new Ajax.ChatThreadUpdater(({container:myRealAgent=='safari'?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}).extend( threadParams || {} ));
Chat.threadUpdater = new Ajax.ChatThreadUpdater(({ignorectrl:-1,container:myRealAgent=='safari'?self.frames[0]:$("chatwnd"),avatar:$("avatarwnd"),message:$("msgwnd")}).extend( threadParams || {} ));
});

View File

@ -12,7 +12,7 @@
//- onComplete, obj, params, $apply$
//- threadParams, servl, frequency, user, threadid, token, cssfile
//- updaterOptions, url, company, agentservl, noclients, wroot, havemenu, showpopup
//- updaterOptions, url, company, agentservl, noclients, wroot, havemenu, showpopup, ignorectrl
var Class = {

File diff suppressed because one or more lines are too long

View File

@ -304,7 +304,13 @@ function setup_chatview_for_user($thread,$level) {
$page['chat.title'] = topage($settings['chattitle']);
setup_logo();
if($settings['sendmessagekey'] == 'enter') {
$page['send_shortcut'] = "Enter";
$page['ignorectrl'] = 1;
} else {
$page['send_shortcut'] = "Ctrl-Enter";
$page['ignorectrl'] = 0;
}
$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
$page['mailLink'] = "$webimroot/client.php?".$params."&level=$level&act=mailthread";
@ -354,7 +360,14 @@ function setup_chatview_for_operator($thread,$operator) {
$page['chat.title'] = topage($settings['chattitle']);
setup_logo();
if($settings['sendmessagekey'] == 'enter') {
$page['send_shortcut'] = "Enter";
$page['ignorectrl'] = 1;
} else {
$page['send_shortcut'] = "Ctrl-Enter";
$page['ignorectrl'] = 0;
}
if($settings['enablessl'] == "1" && !is_secure_request()) {
$page['sslLink'] = get_app_location(true, true)."/operator/agent.php?thread=".$thread['threadid']."&token=".$thread['ltoken'];
}

View File

@ -7,7 +7,7 @@
<script type="text/javascript" language="javascript" src="${webimroot}/js/common.js?v=160a1"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/brws.js?v=160a1"></script>
<script language="javascript"><!--
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:2,${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css" };
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:2,${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl} };
//--></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/chat.js?v=160a1"></script>
</head>

View File

@ -8,7 +8,7 @@
<script type="text/javascript" language="javascript" src="${webimroot}/js/common.js?v=160a1"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/brws.js?v=160a1"></script>
<script language="javascript"><!--
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:2,${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css" };
var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",frequency:2,${if:user}user:"true",${endif:user}threadid:${page:ct.chatThreadId},token:${page:ct.token},cssfile:"${tplroot}/chat.css",ignorectrl:${page:ignorectrl} };
//--></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/chat.js?v=160a1"></script>
</head>

View File

@ -79,7 +79,7 @@ require_once('inc_errors.php');
<div class="field">
<div class="flabel"><?php echo getlocal("page.gen_button.code") ?></div>
<div class="fvaluewithta">
<div class="fvaluewithta" dir="ltr">
<textarea cols="44" rows="15"><?php echo htmlspecialchars($page['buttonCode']) ?></textarea>
</div>
<div class="fdescr"><?php echo getlocal("page.gen_button.code.description") ?></div>