aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/comments/frontend/getmainelement.js
blob: 58da468c926faa66eaec69d9473c0b2183395f2e (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
38
// Get main HashOver UI element (getmainelement.js)
HashOverConstructor.prototype.getMainElement = function (id)
{
	id = id || 'hashover';

	// Attempt to get main HashOver element
	var element = document.getElementById (id);

	// Check if the HashOver element exists
	if (element === null) {
		// If not, get HashOver script tag
		var script = this.constructor.script;

		// Create div tag for HashOver comments to appear in
		element = this.elements.create ('div', { id: id });

		// Place the main HashOver element on the page
		script.parentNode.insertBefore (element, script);
	}

	// Add main HashOver class
	this.classes.add (element, 'hashover');

	// Check if HashOver is prepared
	if (this.constructor.prepared === true) {
		// If so, add class for differentiating desktop and mobile styling
		this.classes.add (element, 'hashover-' + this.setup['device-type']);

		// And add class to indicate user login status
		if (this.setup['user-is-logged-in'] === true) {
			this.classes.add (element, 'hashover-logged-in');
		} else {
			this.classes.add (element, 'hashover-logged-out');
		}
	}

	return element;
};