mirror of https://github.com/zulip/zulip.git
Switch to Handlebars templating
Benchmarks [1] show it's much faster than ICanHaz, though we will have to work to realize those gains. [1] http://jsperf.com/jquery-template-table-performance/77 (imported from commit b037a6f15e27fd49af88f814ff949811dbcd48f2)
This commit is contained in:
parent
efe4410f9f
commit
4793cee888
|
@ -12,13 +12,18 @@
|
|||
|
||||
{% block customhead %}
|
||||
|
||||
{% icanhazjs "zephyr" %}
|
||||
{% icanhazjs "subscription" %}
|
||||
<script id="template_zephyr" type="text/x-handlebars-template">
|
||||
{% rawjstemplate "zephyr" %}
|
||||
</script>
|
||||
|
||||
<script id="template_subscription" type="text/x-handlebars-template">
|
||||
{% rawjstemplate "subscription" %}
|
||||
</script>
|
||||
|
||||
{% autoescape off %}
|
||||
<link href="/static/styles/pygments.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="/static/third/jquery/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="/static/third/ich/ICanHaz.min.js"></script>
|
||||
<script type="text/javascript" src="/static/third/handlebars/handlebars-1.0.rc.1.js"></script>
|
||||
<script type="text/javascript" src="/static/js/zephyr.js"></script>
|
||||
<script type="text/javascript" src="/static/js/hotkey.js"></script>
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
/*jslint browser: true, devel: true, sloppy: true,
|
||||
plusplus: true, nomen: true, regexp: true */
|
||||
/*global $: false, jQuery: false, ich: false,
|
||||
/*global $: false, jQuery: false, Handlebars: false,
|
||||
zephyr_json: false, initial_pointer: false, email: false,
|
||||
class_list: false, instance_list: false, people_list: false */
|
||||
|
||||
// Compile Handlebars templates.
|
||||
var templates = {};
|
||||
$(function () {
|
||||
templates.zephyr = Handlebars.compile($("#template_zephyr").html());
|
||||
templates.subscription = Handlebars.compile($("#template_subscription").html());
|
||||
});
|
||||
|
||||
function register_huddle_onclick(zephyr_row, sender) {
|
||||
zephyr_row.find(".zephyr_sender").click(function (e) {
|
||||
prepare_huddle(sender);
|
||||
|
@ -61,7 +68,7 @@ $(function () {
|
|||
$('#subscriptions_table tr').remove();
|
||||
if (data) {
|
||||
$.each(data.subscriptions, function (index, name) {
|
||||
$('#subscriptions_table').append(ich.subscription({subscription: name}));
|
||||
$('#subscriptions_table').append(templates.subscription({subscription: name}));
|
||||
});
|
||||
}
|
||||
$('#new_subscriptions').focus().select();
|
||||
|
@ -239,7 +246,7 @@ $(function () {
|
|||
success: function (resp, statusText, xhr, form) {
|
||||
$("#new_subscription").val("");
|
||||
var name = $.parseJSON(xhr.responseText).data;
|
||||
$('#subscriptions_table').prepend(ich.subscription({subscription: name}));
|
||||
$('#subscriptions_table').prepend(templates.subscription({subscription: name}));
|
||||
class_list.push(name);
|
||||
$("#subscriptions-status").fadeOut(0);
|
||||
},
|
||||
|
@ -647,7 +654,7 @@ function add_to_tables(zephyr, parent, table_name) {
|
|||
|
||||
zephyr.dom_id = table_name + zephyr.id;
|
||||
|
||||
var new_tr = ich.zephyr(zephyr);
|
||||
var new_tr = $(templates.zephyr(zephyr));
|
||||
table.append(new_tr);
|
||||
register_huddle_onclick(new_tr, zephyr.sender_email);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue