Use Mustache style variable interpolation.
This commit is contained in:
parent
c01201be4e
commit
1442774856
49
converse.js
49
converse.js
@ -17,6 +17,11 @@
|
|||||||
'burry.js/burry'
|
'burry.js/burry'
|
||||||
], function (Burry) {
|
], function (Burry) {
|
||||||
var store = new Burry.Store('collective.xmpp.chat');
|
var store = new Burry.Store('collective.xmpp.chat');
|
||||||
|
// Use Mustache style syntax for variable interpolation
|
||||||
|
_.templateSettings = {
|
||||||
|
evaluate : /\{\[([\s\S]+?)\]\}/g,
|
||||||
|
interpolate : /\{\{([\s\S]+?)\}\}/g
|
||||||
|
};
|
||||||
_.str = require('underscore.string');
|
_.str = require('underscore.string');
|
||||||
return factory(jarnxmpp, jQuery, store, _, console);
|
return factory(jarnxmpp, jQuery, store, _, console);
|
||||||
}
|
}
|
||||||
@ -24,6 +29,10 @@
|
|||||||
} else {
|
} else {
|
||||||
// Browser globals
|
// Browser globals
|
||||||
var store = new Burry.Store('collective.xmpp.chat');
|
var store = new Burry.Store('collective.xmpp.chat');
|
||||||
|
_.templateSettings = {
|
||||||
|
evaluate : /\{\[([\s\S]+?)\]\}/g,
|
||||||
|
interpolate : /\{\{([\s\S]+?)\}\}/g
|
||||||
|
};
|
||||||
root.xmppchat = factory(jarnxmpp, jQuery, store, _, console || {log: function(){}});
|
root.xmppchat = factory(jarnxmpp, jQuery, store, _, console || {log: function(){}});
|
||||||
}
|
}
|
||||||
}(this, function (jarnxmpp, $, store, _, console) {
|
}(this, function (jarnxmpp, $, store, _, console) {
|
||||||
@ -121,15 +130,15 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
message_template: _.template(
|
message_template: _.template(
|
||||||
'<div class="chat-message <%=extra_classes%>">' +
|
'<div class="chat-message {{extra_classes}}">' +
|
||||||
'<span class="chat-message-<%=sender%>"><%=time%> <%=username%>: </span>' +
|
'<span class="chat-message-{{sender}}">{{time}} {{username}}: </span>' +
|
||||||
'<span class="chat-message-content"><%=message%></span>' +
|
'<span class="chat-message-content">{{message}}</span>' +
|
||||||
'</div>'),
|
'</div>'),
|
||||||
|
|
||||||
action_template: _.template(
|
action_template: _.template(
|
||||||
'<div class="chat-message <%=extra_classes%>">' +
|
'<div class="chat-message {{extra_classes}}">' +
|
||||||
'<span class="chat-message-<%=sender%>"><%=time%>: </span>' +
|
'<span class="chat-message-{{sender}}">{{time}}: </span>' +
|
||||||
'<span class="chat-message-content"><%=message%></span>' +
|
'<span class="chat-message-content">{{message}}</span>' +
|
||||||
'</div>'),
|
'</div>'),
|
||||||
|
|
||||||
appendMessage: function (message) {
|
appendMessage: function (message) {
|
||||||
@ -404,7 +413,7 @@
|
|||||||
|
|
||||||
template: _.template(
|
template: _.template(
|
||||||
'<div class="chat-head chat-head-chatbox">' +
|
'<div class="chat-head chat-head-chatbox">' +
|
||||||
'<div class="chat-title"> <%= fullname %> </div>' +
|
'<div class="chat-title"> {{ fullname }} </div>' +
|
||||||
'<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' +
|
'<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' +
|
||||||
'<p class="user-custom-message"><p/>' +
|
'<p class="user-custom-message"><p/>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
@ -502,8 +511,8 @@
|
|||||||
},
|
},
|
||||||
room_template: _.template(
|
room_template: _.template(
|
||||||
'<dd class="chatroom">' +
|
'<dd class="chatroom">' +
|
||||||
'<a class="open-room" room-jid="<%=jid%>" title="Click to open this chatroom" href="#">' +
|
'<a class="open-room" room-jid="{{jid}}" title="Click to open this chatroom" href="#">' +
|
||||||
'<%=name%></a></dd>'),
|
'{{name}}</a></dd>'),
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.on('update-rooms-list', function (ev) {
|
this.on('update-rooms-list', function (ev) {
|
||||||
@ -662,7 +671,7 @@
|
|||||||
|
|
||||||
template: _.template(
|
template: _.template(
|
||||||
'<div class="chat-head chat-head-chatroom">' +
|
'<div class="chat-head chat-head-chatroom">' +
|
||||||
'<div class="chat-title"> <%= name %> </div>' +
|
'<div class="chat-title"> {{ name }} </div>' +
|
||||||
'<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' +
|
'<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' +
|
||||||
'<p class="chatroom-topic"><p/>' +
|
'<p class="chatroom-topic"><p/>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
@ -691,7 +700,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
onLeave: function () {
|
onLeave: function () {
|
||||||
var controlboxview = xmppchat.chatboxesview.views['controlbox'];
|
var controlboxview = xmppchat.chatboxesview.views.controlbox;
|
||||||
if (controlboxview) {
|
if (controlboxview) {
|
||||||
controlboxview.roomspanel.trigger('update-rooms-list');
|
controlboxview.roomspanel.trigger('update-rooms-list');
|
||||||
}
|
}
|
||||||
@ -990,14 +999,14 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
template: _.template(
|
template: _.template(
|
||||||
'<a class="open-chat" title="Click to chat with this contact" href="#"><%= fullname %></a>' +
|
'<a class="open-chat" title="Click to chat with this contact" href="#">{{ fullname }}</a>' +
|
||||||
'<a class="remove-xmpp-contact" title="Click to remove this contact" href="#"></a>'),
|
'<a class="remove-xmpp-contact" title="Click to remove this contact" href="#"></a>'),
|
||||||
|
|
||||||
pending_template: _.template(
|
pending_template: _.template(
|
||||||
'<%= fullname %>' +
|
'{{ fullname }}' +
|
||||||
'<a class="remove-xmpp-contact" title="Click to remove this contact" href="#"></a>'),
|
'<a class="remove-xmpp-contact" title="Click to remove this contact" href="#"></a>'),
|
||||||
|
|
||||||
request_template: _.template('<%= fullname %>' +
|
request_template: _.template('{{ fullname }}' +
|
||||||
'<button type="button" class="accept-xmpp-request">' +
|
'<button type="button" class="accept-xmpp-request">' +
|
||||||
'Accept</button>' +
|
'Accept</button>' +
|
||||||
'<button type="button" class="decline-xmpp-request">' +
|
'<button type="button" class="decline-xmpp-request">' +
|
||||||
@ -1364,14 +1373,14 @@
|
|||||||
|
|
||||||
change_status_message_template: _.template(
|
change_status_message_template: _.template(
|
||||||
'<form id="set-custom-xmpp-status">' +
|
'<form id="set-custom-xmpp-status">' +
|
||||||
'<input type="text" class="custom-xmpp-status" <%= chat_status %>" placeholder="Custom status"/>' +
|
'<input type="text" class="custom-xmpp-status" {{ chat_status }}" placeholder="Custom status"/>' +
|
||||||
'<button type="submit">Save</button>' +
|
'<button type="submit">Save</button>' +
|
||||||
'</form>'),
|
'</form>'),
|
||||||
|
|
||||||
status_template: _.template(
|
status_template: _.template(
|
||||||
'<div class="xmpp-status">' +
|
'<div class="xmpp-status">' +
|
||||||
'<a class="choose-xmpp-status <%= presence_type %>" href="#" title="Click to change your chat status">' +
|
'<a class="choose-xmpp-status {{ presence_type }}" href="#" title="Click to change your chat status">' +
|
||||||
'<%= chat_status %> <span class="value"><%= chat_status %></span>' +
|
'{{ chat_status }} <span class="value">{{ chat_status }}</span>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'<a class="change-xmpp-status-message" href="#" Title="Click here to write a custom status message"></a>' +
|
'<a class="change-xmpp-status-message" href="#" Title="Click here to write a custom status message"></a>' +
|
||||||
'</div>'),
|
'</div>'),
|
||||||
@ -1420,9 +1429,9 @@
|
|||||||
|
|
||||||
option_template: _.template(
|
option_template: _.template(
|
||||||
'<li>' +
|
'<li>' +
|
||||||
'<a href="#" class="<%= value %>">' +
|
'<a href="#" class="{{ value }}">' +
|
||||||
'<%= text %>' +
|
'{{ text }}' +
|
||||||
'<span class="value"><%= value %></span>' +
|
'<span class="value">{{ value }}</span>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'</li>'),
|
'</li>'),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user