Use LAB.js to load JavaScripts to the chat window

This commit is contained in:
Dmitriy Simushev 2012-10-10 10:06:01 +00:00
parent 4cfac7bbef
commit f5a970e50f
6 changed files with 42 additions and 53 deletions

View File

@ -5,7 +5,8 @@
Copyright (c) 2005-2011 Mibew Messenger Community Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php License: http://mibew.org/license.php
*/ */
var chatController=null,pluginManager=new PluginManager; var chatController=null;
Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&chatController.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){chatController.selectPredefinedAnswer(this)}},"div#changename2 a":function(a){a.onclick=function(){chatController.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){chatController.applyName();return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){13==(a||event).keyCode&& Behaviour.register({"#postmessage a":function(a){a.onclick=function(){var a=$("msgwnd");a&&chatController.postMessage(a.value)}},"select#predefined":function(a){a.onchange=function(){chatController.selectPredefinedAnswer(this)}},"div#changename2 a":function(a){a.onclick=function(){chatController.showNameField();return!1}},"div#changename1 a":function(a){a.onclick=function(){chatController.applyName();return!1}},"div#changename1 input#uname":function(a){a.onkeydown=function(a){13==(a||event).keyCode&&
chatController.applyName()}},"a#refresh":function(a){a.onclick=function(){chatController.refresh()}},"a#togglesound":function(a){a.onclick=function(){chatController.toggleSound()}},"a.closethread":function(a){a.onclick=function(){chatController.closeThread()}}}); chatController.applyName()}},"a#refresh":function(a){a.onclick=function(){chatController.refresh()}},"a#togglesound":function(a){a.onclick=function(){chatController.toggleSound()}},"a.closethread":function(a){a.onclick=function(){chatController.closeThread()}}});
EventHelper.register(window,"onload",function(){FrameUtils.options.cssfile=chatParams.cssfile;var a=new ChatServer(chatParams.serverParams),b=new Thread(chatParams.threadParams);chatParams.initPlugins(pluginManager,b,a);var c=new ChatView(chatParams.localizedStrings,chatParams.predefinedAnswers||[]);chatController=new ChatController(a,c,b,{ignorectrl:-1}.extend(chatParams.controllerParams||{}))}); EventHelper.register(window,"onload",function(){$LAB.setOptions({BasePath:chatParams.jsBasePath}).script("json2.js").wait().script("mibewapi.js").wait().script("chatserver.js").script("thread.js").script("pluginmanager.js").script("brws.js").wait().script("chatcontroller.js").script("chatview.js").wait(function(){FrameUtils.options.cssfile=chatParams.cssfile;var a=new ChatServer(chatParams.serverParams),c=new Thread(chatParams.threadParams),b=new PluginManager;chatParams.initPlugins(b,c,a);b=new ChatView(chatParams.localizedStrings,
chatParams.predefinedAnswers||[]);chatController=new ChatController(a,b,c,{ignorectrl:-1}.extend(chatParams.controllerParams||{}))})});

View File

@ -7,7 +7,6 @@
*/ */
var chatController = null; var chatController = null;
var pluginManager = new PluginManager();
Behaviour.register({ Behaviour.register({
'#postmessage a' : function(el) { '#postmessage a' : function(el) {
@ -68,18 +67,31 @@ Behaviour.register({
}); });
EventHelper.register(window, 'onload', function(){ EventHelper.register(window, 'onload', function(){
FrameUtils.options.cssfile = chatParams.cssfile; $LAB
var chatServer = new ChatServer(chatParams.serverParams); .setOptions({BasePath: chatParams.jsBasePath})
var thread = new Thread(chatParams.threadParams); .script('json2.js').wait()
chatParams.initPlugins(pluginManager, thread, chatServer); .script('mibewapi.js').wait()
var chatView = new ChatView( .script('chatserver.js')
chatParams.localizedStrings, .script('thread.js')
chatParams.predefinedAnswers || [] .script('pluginmanager.js')
); .script('brws.js').wait()
chatController = new ChatController( .script('chatcontroller.js')
chatServer, .script('chatview.js')
chatView, .wait(function() {
thread, FrameUtils.options.cssfile = chatParams.cssfile;
{ignorectrl: -1}.extend(chatParams.controllerParams || {}) var chatServer = new ChatServer(chatParams.serverParams);
); var thread = new Thread(chatParams.threadParams);
var pluginManager = new PluginManager();
chatParams.initPlugins(pluginManager, thread, chatServer);
var chatView = new ChatView(
chatParams.localizedStrings,
chatParams.predefinedAnswers || []
);
chatController = new ChatController(
chatServer,
chatView,
thread,
{ignorectrl: -1}.extend(chatParams.controllerParams || {})
);
});
}); });

View File

@ -5,16 +5,13 @@
<link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css"> <link rel="stylesheet" type="text/css" href="${tplroot}/chat.css">
${page:additional_css} ${page:additional_css}
${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/thread.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/LAB.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/mibewapi.js"></script> ${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/pluginmanager.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/json2.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/brws.js"></script>
<script type="text/javascript" language="javascript"><!-- <script type="text/javascript" language="javascript"><!--
var chatParams = { var chatParams = {
cssfile: "${tplroot}/chat.css", cssfile: "${tplroot}/chat.css",
jsBasePath: "${webimroot}/js/${jsver}/",
localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"}, localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"},
${if:agent}${if:canpost} ${if:agent}${if:canpost}
predefinedAnswers: ${page:fullPredefinedAnswers}, predefinedAnswers: ${page:fullPredefinedAnswers},
@ -38,9 +35,6 @@ var chatParams = {
} }
//--> //-->
</script> </script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script>
<style type="text/css"> <style type="text/css">
#header{ #header{

View File

@ -5,16 +5,13 @@
<link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css"> <link rel="stylesheet" type="text/css" href="${tplroot}/chat.css">
${page:additional_css} ${page:additional_css}
${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/thread.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/LAB.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/mibewapi.js"></script> ${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/pluginmanager.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/json2.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/brws.js"></script>
<script type="text/javascript" language="javascript"><!-- <script type="text/javascript" language="javascript"><!--
var chatParams = { var chatParams = {
cssfile: "${tplroot}/chat.css", cssfile: "${tplroot}/chat.css",
jsBasePath: "${webimroot}/js/${jsver}/",
localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"}, localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"},
${if:agent}${if:canpost} ${if:agent}${if:canpost}
predefinedAnswers: ${page:fullPredefinedAnswers}, predefinedAnswers: ${page:fullPredefinedAnswers},
@ -38,9 +35,6 @@ var chatParams = {
} }
//--> //-->
</script> </script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script>
<style type="text/css"> <style type="text/css">
.tplimage { .tplimage {

View File

@ -6,17 +6,14 @@
<link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" media="all" /> <link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" media="all" />
${page:additional_css} ${page:additional_css}
${page:additional_js}
<script type="text/javascript" src="${webimroot}/js/${jsver}/common.js"></script> <script type="text/javascript" src="${webimroot}/js/${jsver}/common.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/thread.js"></script> <script type="text/javascript" src="${webimroot}/js/${jsver}/LAB.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/mibewapi.js"></script> ${page:additional_js}
<script type="text/javascript" src="${webimroot}/js/${jsver}/pluginmanager.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/json2.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/brws.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var chatParams = { var chatParams = {
cssfile: "${tplroot}/chat.css", cssfile: "${tplroot}/chat.css",
jsBasePath: "${webimroot}/js/${jsver}/",
localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"}, localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"},
${if:agent}${if:canpost} ${if:agent}${if:canpost}
predefinedAnswers: ${page:fullPredefinedAnswers}, predefinedAnswers: ${page:fullPredefinedAnswers},
@ -79,9 +76,6 @@
window.onresize = setTrueHeight; window.onresize = setTrueHeight;
//--> //-->
</script> </script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/chatview.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script>
<script type="text/javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> <script type="text/javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script>
</head> </head>
<body class="body"> <body class="body">

View File

@ -5,16 +5,13 @@
<link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css"> <link rel="stylesheet" type="text/css" href="${tplroot}/chat.css">
${page:additional_css} ${page:additional_css}
${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/common.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/thread.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/LAB.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/mibewapi.js"></script> ${page:additional_js}
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/pluginmanager.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/json2.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/brws.js"></script>
<script type="text/javascript" language="javascript"><!-- <script type="text/javascript" language="javascript"><!--
var chatParams = { var chatParams = {
cssfile: "${tplroot}/chat.css", cssfile: "${tplroot}/chat.css",
jsBasePath: "${webimroot}/js/${jsver}/",
localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"}, localizedStrings: {closeConfirmation:"${page:chat.close.confirmation}"},
${if:agent}${if:canpost} ${if:agent}${if:canpost}
predefinedAnswers: ${page:fullPredefinedAnswers}, predefinedAnswers: ${page:fullPredefinedAnswers},
@ -38,9 +35,6 @@ var chatParams = {
} }
//--> //-->
</script> </script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatserver.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatview.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatcontroller.js"></script>
<script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script> <script type="text/javascript" language="javascript" src="${webimroot}/js/${jsver}/chatinit.js"></script>
<style type="text/css"> <style type="text/css">
.isound { background: url(${tplroot}/images/buttons/sound.gif) no-repeat; width: 19px; height: 19px; } .isound { background: url(${tplroot}/images/buttons/sound.gif) no-repeat; width: 19px; height: 19px; }