mirror of
https://github.com/Mibew/design.git
synced 2025-01-22 18:10:33 +03:00
Create Thread Log JavaScript application
This commit is contained in:
parent
b4f99c1c18
commit
503c17352c
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
default_app_js - Build JavaScript files related to default application
|
default_app_js - Build JavaScript files related to default application
|
||||||
chat_app_js - Build JavaScript files related to chat application
|
chat_app_js - Build JavaScript files related to chat application
|
||||||
|
thread_log_app_js - Build JavaScript files related to thread log application
|
||||||
users_app_js - Build JavaScript files related to users application
|
users_app_js - Build JavaScript files related to users application
|
||||||
|
|
||||||
core_handlebars - Compile Handlebars templates of the Core
|
core_handlebars - Compile Handlebars templates of the Core
|
||||||
@ -272,6 +273,14 @@
|
|||||||
<echo>Users JavaScript application built.</echo>
|
<echo>Users JavaScript application built.</echo>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<!-- Compile and concatenate JavaScript files related to thread log application -->
|
||||||
|
<target name="thread_log_app_js" depends="default_app_js">
|
||||||
|
<antcall target="app_js">
|
||||||
|
<param name="app_name" value="thread_log" />
|
||||||
|
</antcall>
|
||||||
|
<echo>Thread log JavaScript application built.</echo>
|
||||||
|
</target>
|
||||||
|
|
||||||
<!-- Compile Handlebars templates of the Core -->
|
<!-- Compile Handlebars templates of the Core -->
|
||||||
<target name="core_handlebars">
|
<target name="core_handlebars">
|
||||||
<echo>Compile Handlebars templates of the Core</echo>
|
<echo>Compile Handlebars templates of the Core</echo>
|
||||||
@ -301,7 +310,7 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Build all project -->
|
<!-- Build all project -->
|
||||||
<target name="all" depends="chat_app_js,users_app_js,styles_all">
|
<target name="all" depends="chat_app_js,thread_log_app_js,users_app_js,styles_all">
|
||||||
<echo>Mibew Messenger built.</echo>
|
<echo>Mibew Messenger built.</echo>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
8
src/messenger/webim/js/compiled/thread_log/app.js
Normal file
8
src/messenger/webim/js/compiled/thread_log/app.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Mibew Messenger project.
|
||||||
|
http://mibew.org
|
||||||
|
|
||||||
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
(function(b,c){var a=new c.Marionette.Application;a.addRegions({messagesRegion:"#messages-region"});a.addInitializer(function(c){a.messagesRegion.show(new b.Views.MessagesCollection({collection:new b.Collections.Messages(c.messages)}))});b.Application=a})(Mibew,Backbone);
|
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Mibew Messenger project.
|
||||||
|
http://mibew.org
|
||||||
|
|
||||||
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
(function(a){a.Views.MessagesCollection=a.Views.CollectionBase.extend({itemView:a.Views.Message,className:"messages-collection"})})(Mibew);
|
@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Mibew Messenger project.
|
||||||
|
http://mibew.org
|
||||||
|
|
||||||
|
Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
(function(a,b){a.Collections.Messages=b.Collection.extend({model:a.Models.Message})})(Mibew,Backbone,_);
|
3
src/messenger/webim/js/compiled/thread_log_app.js
Normal file
3
src/messenger/webim/js/compiled/thread_log_app.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
;(function(a,b){a.Collections.Messages=b.Collection.extend({model:a.Models.Message})})(Mibew,Backbone,_);
|
||||||
|
(function(a){a.Views.MessagesCollection=a.Views.CollectionBase.extend({itemView:a.Views.Message,className:"messages-collection"})})(Mibew);
|
||||||
|
(function(b,c){var a=new c.Marionette.Application;a.addRegions({messagesRegion:"#messages-region"});a.addInitializer(function(c){a.messagesRegion.show(new b.Views.MessagesCollection({collection:new b.Collections.Messages(c.messages)}))});b.Application=a})(Mibew,Backbone);
|
27
src/messenger/webim/js/source/thread_log/app.js
Normal file
27
src/messenger/webim/js/source/thread_log/app.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* @preserve This file is part of Mibew Messenger project.
|
||||||
|
* http://mibew.org
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
* License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function (Mibew, Backbone) {
|
||||||
|
|
||||||
|
// Create application instance
|
||||||
|
var App = new Backbone.Marionette.Application();
|
||||||
|
|
||||||
|
// Define regions
|
||||||
|
App.addRegions({
|
||||||
|
messagesRegion: '#messages-region'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize application
|
||||||
|
App.addInitializer(function(options){
|
||||||
|
App.messagesRegion.show(new Mibew.Views.MessagesCollection({
|
||||||
|
collection: new Mibew.Collections.Messages(options.messages)
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
Mibew.Application = App;
|
||||||
|
})(Mibew, Backbone);
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* @preserve This file is part of Mibew Messenger project.
|
||||||
|
* http://mibew.org
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
* License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(Mibew) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Represents messages list view
|
||||||
|
*/
|
||||||
|
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
||||||
|
/** @lends Mibew.Views.MessagesCollection.prototype */
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default item view constructor.
|
||||||
|
* @type Function
|
||||||
|
*/
|
||||||
|
itemView: Mibew.Views.Message,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class name for view's DOM element
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
className: 'messages-collection'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
})(Mibew);
|
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @preserve This file is part of Mibew Messenger project.
|
||||||
|
* http://mibew.org
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2011 Mibew Messenger Community
|
||||||
|
* License: http://mibew.org/license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(Mibew, Backbone, _){
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Represents messages list
|
||||||
|
*/
|
||||||
|
Mibew.Collections.Messages = Backbone.Collection.extend(
|
||||||
|
/** @lends Mibew.Collections.Message.prototype */
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Default contructor for model
|
||||||
|
* @type Function
|
||||||
|
*/
|
||||||
|
model: Mibew.Models.Message
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
})(Mibew, Backbone, _);
|
@ -53,12 +53,13 @@ if (isset($_GET['threadid'])) {
|
|||||||
// Build messages list
|
// Build messages list
|
||||||
$lastid = -1;
|
$lastid = -1;
|
||||||
$messages = $thread_info['thread']->getMessages(false, $lastid);
|
$messages = $thread_info['thread']->getMessages(false, $lastid);
|
||||||
foreach ($messages as $key => $msg) {
|
$result = array();
|
||||||
if ($msg['kind'] == Thread::KIND_AVATAR) {
|
foreach ($messages as $msg) {
|
||||||
unset($messages[$key]);
|
if ($msg['kind'] != Thread::KIND_AVATAR) {
|
||||||
|
$result[] = $msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$page['threadMessages'] = json_encode($messages);
|
$page['threadMessages'] = json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_menu($operator, false);
|
prepare_menu($operator, false);
|
||||||
|
@ -18,24 +18,28 @@
|
|||||||
$page['title'] = getlocal("thread.chat_log");
|
$page['title'] = getlocal("thread.chat_log");
|
||||||
|
|
||||||
function tpl_header() { global $page, $webimroot; ?>
|
function tpl_header() { global $page, $webimroot; ?>
|
||||||
<script type="text/javascript" src="<?php echo($webimroot); ?>/js/compiled/common.js"></script>
|
|
||||||
<script type="text/javascript" src="<?php echo($webimroot); ?>/js/compiled/handlebars.js"></script>
|
<!-- External libs -->
|
||||||
<script type="text/javascript" src="<?php echo($webimroot); ?>/js/compiled/handlebars_helpers.js"></script>
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo($webimroot); ?>/js/compiled/messageview.js"></script>
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/json2.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo($webimroot); ?>/js/templates/compiled/message.tpl.js"></script>
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/underscore-min.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/backbone-min.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/backbone.marionette.min.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/libs/handlebars.js"></script>
|
||||||
|
|
||||||
|
<!-- Application files -->
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/compiled/mibewapi.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/compiled/default_app.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo $webimroot ?>/js/compiled/thread_log_app.js"></script>
|
||||||
|
|
||||||
|
<!-- Start application -->
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
EventHelper.register(window, 'onload', function() {
|
jQuery(document).ready(function(){
|
||||||
var threadMessages = <?php echo($page['threadMessages']); ?>;
|
Mibew.Application.start({
|
||||||
var messageEl = document.getElementById('message');
|
messages: <?php echo($page['threadMessages']); ?>
|
||||||
var messageView = new MessageView();
|
});
|
||||||
for (var index in threadMessages) {
|
|
||||||
if (! threadMessages.hasOwnProperty(index)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
messageEl.innerHTML += messageView.themeMessage(threadMessages[index]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// --></script>
|
//--></script>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
function tpl_content() { global $page, $webimroot, $errors;
|
function tpl_content() { global $page, $webimroot, $errors;
|
||||||
@ -104,13 +108,7 @@ $chatthread = $page['thread_info']['thread'];
|
|||||||
<br clear="all"/>
|
<br clear="all"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="message" id="message">
|
<div class="message" id="messages-region"></div>
|
||||||
<?php
|
|
||||||
foreach( $page['threadMessages'] as $message ) {
|
|
||||||
echo $message;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
Loading…
Reference in New Issue
Block a user