File size: 1,253 Bytes
36ddefa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
var SidebarUtils = {
	createSection: function (labelText, content) {
		var legend = $('<legend/>').text(labelText);
		var upBtn = SidebarUtils.createScrollButton(true, content);
		var downBtn = SidebarUtils.createScrollButton(false, content);
		
		var section = $('<fieldset/>')
			.addClass('section')
			.append(legend)
			.append(upBtn)
			.append(
				content
					.addClass('content')
					.bind('mousewheel', function(event, delta){
						this.scrollTop -= (delta * 10);
						event.preventDefault();
					})
			)
			.append(downBtn);
		
		return {
			section: section,
			legend: legend,
			upBtn: upBtn,
			content: content,
			downBtn: downBtn
		};
	},
	
	createListSection: function (labelText) {
		var content = $('<ul/>').addClass('list');
		return SidebarUtils.createSection(labelText, content);
	},
	
	createScrollButton: function (up, target) {
		var cls = up ? 'scrollup' : 'scrolldown';
		var amount = (up ? '-' : '+') + '=300px';
		
		return $('<div/>')
			.addClass(cls)
			.bind('mousedown mouseup touchstart touchend', function (event) {
		    	if (event.type == 'mousedown' || event.type == 'touchstart') {
					target.animate({"scrollTop": amount}, 3000, 'linear');
		    	} else {
		        	target.stop();
		    	}
			});
	}
};