aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/comments/api/frontends/latest/init.js
blob: 77185cdd5fcdd585e201e29fd9ed13d7cd19c1cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// HashOver latest comments UI initialization process (init.js)
HashOverLatest.prototype.init = function ()
{
	// Shorthand
	var comments = this.instance.comments.primary;

	// Initial comments HTML
	var html = '';

	// Append theme CSS if enabled
	this.optionalMethod ('appendCSS', [ 'hashover-widget' ]);

	// Add main HashOver element to this HashOver instance
	this.instance['main-element'] = this.getMainElement ('hashover-widget');

	// Templatify UI HTML strings
	for (var element in this.ui) {
		this.ui[element] = this.strings.templatify (this.ui[element]);
	}

	// Parse every comment
	for (var i = 0, il = comments.length; i < il; i++) {
		html += this.comments.parse (comments[i]);
	}

	// Add comments to element's innerHTML
	if ('insertAdjacentHTML' in this.instance['main-element']) {
		this.instance['main-element'].insertAdjacentHTML ('beforeend', html);
	} else {
		this.instance['main-element'].innerHTML = html;
	}

	// Add control events
	for (var i = 0, il = comments.length; i < il; i++) {
		this.addControls (comments[i]);
	}
};