aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/comments/frontend/uncollapseinterface.js
blob: 7d90b3a95a1832f8d8e58855d23b8c56f3e73602 (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
// Uncollapses the user interface (uncollapseinterface.js)
HashOver.prototype.uncollapseInterface = function (callback)
{
	// Elements to unhide
	var uncollapseIDs = [ 'form-section', 'comments-section', 'end-links' ];

	// Check if the uncollapse interface link exists
	this.elements.exists ('uncollapse-interface-link', function (uncollapseLink) {
		// If so, add class to hide the uncollapse interface hyperlink
		hashover.classes.add (uncollapseLink, 'hashover-hide-more-link');

		// Wait for the default CSS transition
		setTimeout (function () {
			// Remove the uncollapse interface hyperlink from page
			uncollapseLink.parentNode.removeChild (uncollapseLink);

			// Show hidden form elements
			for (var i = 0, il = uncollapseIDs.length; i < il; i++) {
				hashover.elements.exists (uncollapseIDs[i], function (element) {
					element.style.display = '';
				});
			}

			// Show popular comments section
			if (hashover.setup['collapse-limit'] > 0) {
				hashover.elements.exists ('popular-section', function (popularSection) {
					popularSection.style.display = '';
				});
			}

			// Execute callback
			if (typeof (callback) === 'function') {
				callback ();
			}
		}, 350);
	});
};