You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
isso/isso/js/embed.js

49 lines
1.5 KiB

/*
* Copyright 2013, Martin Zimmermann <info@posativ.org>. All rights reserved.
* Distributed under the MIT license
*/
require(["ready", "app/config", "app/api", "app/isso", "app/count", "app/dom", "app/markup", "app/text/css"], function(domready, config, api, isso, count, $, Mark, css) {
"use strict";
domready(function() {
if (config["css"]) {
var style = $.new("style");
style.type = "text/css";
style.textContent = css.inline;
$("head").append(style);
}
count();
if ($("#isso-thread") === null) {
return console.log("abort, #isso-thread is missing");
}
$("#isso-thread").append($.new('h4'));
$("#isso-thread").append(new isso.Postbox(null));
$("#isso-thread").append('<div id="isso-root"></div>');
api.fetch().then(function(rv) {
if (! rv.length) {
$("#isso-thread > h4").textContent = Mark.up("{{ i18n-no-comments }}");
return;
}
$("#isso-thread > h4").textContent = Mark.up("{{ i18n-num-comments | pluralize : `n` }}", {n: rv.length});
for (var i=0; i < rv.length; i++) {
isso.insert(rv[i], false);
}
}).fail(function(err) {
console.log(err);
}).done(function() {
if (window.location.hash.length > 0) {
$(window.location.hash).scrollIntoView();
}
});
});
});