Commit 0c0a3f86 authored by JC Brand's avatar JC Brand

Remove the need for having an HTML snippet in the body.

parent c05c2ee9
...@@ -2480,9 +2480,10 @@ ...@@ -2480,9 +2480,10 @@
}); });
this.ChatBoxViews = Backbone.View.extend({ this.ChatBoxViews = Backbone.View.extend({
el: '#conversejs',
initialize: function () { initialize: function () {
this.render();
var views = {}; var views = {};
this.get = function (id) { return views[id]; }; this.get = function (id) { return views[id]; };
this.set = function (id, view) { views[id] = view; }; this.set = function (id, view) { views[id] = view; };
...@@ -2509,6 +2510,23 @@ ...@@ -2509,6 +2510,23 @@
}, this); }, this);
}, },
render: function () {
this.$el.html(converse.templates.trimmed_chats());
},
_ensureElement: function() {
if (!this.el) {
var $el = $('#conversejs');
if (!$el.length) {
$el = $('<div id="conversejs">');
$('body').append($el);
}
this.setElement($el, false);
} else {
this.setElement(_.result(this, 'el'), false);
}
},
trimOpenChats: function (view) { trimOpenChats: function (view) {
/* This method is called before a new chat box will be opened. /* This method is called before a new chat box will be opened.
* *
...@@ -2964,32 +2982,6 @@ ...@@ -2964,32 +2982,6 @@
} }
}); });
this.TrimmedChatBoxes = Backbone.View.extend({
/* A view for trimmed chat boxes and chat rooms.
* XXX: Add this view inside ChatBoxViews's $el (i.e. #conversejs)
*/
tagName: 'div',
id: 'trimmed-chatboxes',
initialize: function () {
var views = {};
this.get = function (id) { return views[id]; };
this.set = function (id, view) { views[id] = view; };
this.getAll = function () { return views; };
this.$el.html(converse.templates.trimmed_chats());
this.model.on("add", function (item) {
if (!item.get('trimmed')) {
return;
}
this.show(item);
}, this);
},
show: function (item) {
this.$('.box-flyout').append(converse.templates.trim_chat());
}
});
this.RosterView = Backbone.View.extend({ this.RosterView = Backbone.View.extend({
tagName: 'dl', tagName: 'dl',
id: 'converse-roster', id: 'converse-roster',
......
...@@ -9,6 +9,7 @@ Changelog ...@@ -9,6 +9,7 @@ Changelog
2. Configuration options for the chat toolbar have changed. 2. Configuration options for the chat toolbar have changed.
Please refer to the `relevant documentation http://devbox:8890/docs/html/index.html#visible-toolbar-buttons`_. Please refer to the `relevant documentation http://devbox:8890/docs/html/index.html#visible-toolbar-buttons`_.
* No initial HTML markup is now needed in the document body for converse.js to work. [jcbrand]
* All date handling is now done with moment.js. [jcbrand] * All date handling is now done with moment.js. [jcbrand]
* Add a new toolbar button for clearing chat messages. [jcbrand] * Add a new toolbar button for clearing chat messages. [jcbrand]
* Chat boxes and rooms can now be resized vertically. [jcbrand] * Chat boxes and rooms can now be resized vertically. [jcbrand]
......
...@@ -52,13 +52,6 @@ bottom of your page (after the closing *</body>* element). ...@@ -52,13 +52,6 @@ bottom of your page (after the closing *</body>* element).
}); });
}); });
Finally, Converse.js requires a special snippet of HTML markup to be included in your page:
::
<div id="conversejs"></div>
The `index.html <https://github.com/jcbrand/converse.js/blob/master/index.html>`_ file inside the The `index.html <https://github.com/jcbrand/converse.js/blob/master/index.html>`_ file inside the
Converse.js repository serves as a nice usable example of this. Converse.js repository serves as a nice usable example of this.
......
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
<link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" /> <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
<script data-main="main" src="components/requirejs/require.js"></script> <script data-main="main" src="components/requirejs/require.js"></script>
<script src="../components/jquery/dist/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="js/init.js"></script>
</head> </head>
<body id="page-top" data-spy="scroll" data-target=".navbar-custom"> <body id="page-top" data-spy="scroll" data-target=".navbar-custom">
...@@ -209,15 +214,6 @@ ...@@ -209,15 +214,6 @@
</div> </div>
</div> </div>
</section> </section>
<!-- Core JavaScript Files -->
<script src="../components/jquery/dist/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/init.js"></script>
<div id="conversejs"></div>
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment