summaryrefslogtreecommitdiff
path: root/js/smartphone-spoiler.js
blob: 24629a3d9bf04a5419872643e4758ae2c39667d0 (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
/*
 * smartphone-spoiler.js
 * https://github.com/savetheinternet/Tinyboard/blob/master/js/smartphone-spoiler.js
 *
 * Released under the MIT license
 * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
 * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net> 
 *
 * Usage:
 *   $config['additional_javascript'][] = 'js/mobile-style.js';
 *   $config['additional_javascript'][] = 'js/smartphone-spoiler.js';
 *
 */

onready(function(){
	if(device_type == 'mobile') {
		var fix_spoilers = function(where) {
			var spoilers = where.getElementsByClassName('spoiler');
			for(var i = 0; i < spoilers.length; i++) {
				spoilers[i].onmousedown = function() {
					this.style.color = 'white';
				};
			}
		};
		fix_spoilers(document);

	        // allow to work with auto-reload.js, etc.
	        $(document).bind('new_post', function(e, post) {
	                fix_spoilers(post);
        	});             
	
	}
});